summaryrefslogtreecommitdiff
path: root/src/fl_diamond_box.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2024-04-26 12:42:11 +0200
committerMatthias Melcher <github@matthiasm.com>2024-04-26 12:42:11 +0200
commit281ec24c8f4b7daf7cc4e7c30b640cbe0b33d037 (patch)
tree254e20596d544cb25d32ab2067d9e18afc4ac097 /src/fl_diamond_box.cxx
parent9a0d1f16d7b78a7e789c30728df79166b95da115 (diff)
Box types can now defined and draw their own focus frame, STR 2145, #659
Diffstat (limited to 'src/fl_diamond_box.cxx')
-rw-r--r--src/fl_diamond_box.cxx22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/fl_diamond_box.cxx b/src/fl_diamond_box.cxx
index e5f7749ec..414e5dea3 100644
--- a/src/fl_diamond_box.cxx
+++ b/src/fl_diamond_box.cxx
@@ -59,9 +59,25 @@ static void fl_diamond_down_box(int x,int y,int w,int h,Fl_Color bgcolor) {
fl_color(g[(int)'A']); fl_loop(x+3, y1, x1, y+3, x+w-3, y1, x1, y+h-3);
}
-extern void fl_internal_boxtype(Fl_Boxtype, Fl_Box_Draw_F*);
+void fl_diamond_focus(Fl_Boxtype bt, int x, int y, int w, int h, Fl_Color fg, Fl_Color bg) {
+ w &= -2;
+ h &= -2;
+ x += Fl::box_dx(bt)+4;
+ y += Fl::box_dy(bt)+4;
+ w -= Fl::box_dw(bt)+8;
+ h -= Fl::box_dh(bt)+8;
+ int x1 = x+w/2;
+ int y1 = y+h/2;
+ Fl_Color savecolor = fl_color();
+ fl_color(fl_contrast(fg, bg));
+ fl_line_style(FL_DOT);
+ fl_loop(x,y1, x1,y, x+w,y1, x1,y+h);
+ fl_line_style(FL_SOLID);
+ fl_color(savecolor);
+}
+extern void fl_internal_boxtype(Fl_Boxtype, Fl_Box_Draw_F*, Fl_Box_Draw_Focus_F* =NULL);
Fl_Boxtype fl_define_FL_DIAMOND_BOX() {
- fl_internal_boxtype(_FL_DIAMOND_DOWN_BOX, fl_diamond_down_box);
- fl_internal_boxtype(_FL_DIAMOND_UP_BOX,fl_diamond_up_box);
+ fl_internal_boxtype(_FL_DIAMOND_DOWN_BOX, fl_diamond_down_box, fl_diamond_focus);
+ fl_internal_boxtype(_FL_DIAMOND_UP_BOX, fl_diamond_up_box, fl_diamond_focus);
return _FL_DIAMOND_UP_BOX;
}