summaryrefslogtreecommitdiff
path: root/src/Fl_Check_Browser.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2021-11-07 00:20:44 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2021-11-15 14:41:31 +0100
commite4d8b941025fcdd232e748227634529f752381b7 (patch)
treee44519ea2dd7e335433372ebc4ee7ecee860244b /src/Fl_Check_Browser.cxx
parentd96c980d29c3caecadca49af62def57e86d7eed9 (diff)
Add fl_draw_check() to draw better check marks (issue #68)
This new function can and should be used to draw check marks in widgets that need it, e.g. Fl_Check_Browser (issue #68) and Fl_Check_Button.
Diffstat (limited to 'src/Fl_Check_Browser.cxx')
-rw-r--r--src/Fl_Check_Browser.cxx15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/Fl_Check_Browser.cxx b/src/Fl_Check_Browser.cxx
index 3b327312c..a05c4e409 100644
--- a/src/Fl_Check_Browser.cxx
+++ b/src/Fl_Check_Browser.cxx
@@ -184,20 +184,17 @@ void Fl_Check_Browser::item_draw(void *v, int X, int Y, int, int) const {
int cy = Y + (tsize + 1 - CHECK_SIZE) / 2;
X += 2;
+ // draw the check mark box (always)
fl_color(active_r() ? FL_FOREGROUND_COLOR : fl_inactive(FL_FOREGROUND_COLOR));
fl_loop(X, cy, X, cy + CHECK_SIZE,
X + CHECK_SIZE, cy + CHECK_SIZE, X + CHECK_SIZE, cy);
+
+ // draw the check mark
if (i->checked) {
- int tx = X + 3;
- int tw = CHECK_SIZE - 4;
- int d1 = tw / 3;
- int d2 = tw - d1;
- int ty = cy + (CHECK_SIZE + d2) / 2 - d1 - 2;
- for (int n = 0; n < 3; n++, ty++) {
- fl_line(tx, ty, tx + d1, ty + d1);
- fl_line(tx + d1, ty + d1, tx + tw - 1, ty + d1 - d2 + 1);
- }
+ fl_draw_check(Fl_Rect(X + 1, cy + 1, CHECK_SIZE - 1, CHECK_SIZE - 1), fl_color());
}
+
+ // draw the item text
fl_font(textfont(), tsize);
if (i->selected) {
col = fl_contrast(col, selection_color());