summaryrefslogtreecommitdiff
path: root/src/Fl_Button.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2025-12-01 18:36:04 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2025-12-01 23:06:37 +0100
commit5a6a7eb009cde5c0613418a11b0fb637f0cd9468 (patch)
tree87c694ec64091c02af916a7b959f16127c8c52e2 /src/Fl_Button.cxx
parent2e169770396fed12b3b9200b3354322924b36537 (diff)
Add background (`bg`) attribute to table of boxtypes
This is a first step to fix some background (re-)drawing issues in widgets. A new bit in the array of boxtypes can be used to determine if a particular boxtype uses a solid background (e.g. all FL_*_BOX types) or if the parent widget is responsible for drawing it (FL_NO_BOX and all FL_*_FRAME) types, and maybe more ... The old struct member `set` in the struct of boxtypes has been renamed to `flags` and is now used as a bit field. Except these changes, this first commit fixes the focus box drawing of specific boxtypes, as seen in unittest_schemes.cxx in the Fl_Check_Button with label "Check", and very likely more.
Diffstat (limited to 'src/Fl_Button.cxx')
-rw-r--r--src/Fl_Button.cxx40
1 files changed, 23 insertions, 17 deletions
diff --git a/src/Fl_Button.cxx b/src/Fl_Button.cxx
index e586e5ffa..3df97875b 100644
--- a/src/Fl_Button.cxx
+++ b/src/Fl_Button.cxx
@@ -1,7 +1,7 @@
//
// Button widget for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2014 by Bill Spitzak and others.
+// Copyright 1998-2025 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -150,28 +150,34 @@ int Fl_Button::handle(int event) {
if (when() & FL_WHEN_RELEASE) do_callback(FL_REASON_RELEASED);
return 1;
case FL_SHORTCUT:
- if (!(shortcut() ?
- Fl::test_shortcut(shortcut()) : test_shortcut())) return 0;
- if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this);
+ if (!(shortcut() ? Fl::test_shortcut(shortcut()) : test_shortcut()))
+ return 0;
+ if (Fl::visible_focus() && handle(FL_FOCUS))
+ Fl::focus(this);
goto triggered_by_keyboard;
- case FL_FOCUS :
- case FL_UNFOCUS :
+ case FL_FOCUS:
+ case FL_UNFOCUS:
if (Fl::visible_focus()) {
- if (box() == FL_NO_BOX) {
- // Widgets with the FL_NO_BOX boxtype need a parent to
- // redraw, since it is responsible for redrawing the
- // background...
- int X = x() > 0 ? x() - 1 : 0;
- int Y = y() > 0 ? y() - 1 : 0;
- if (window()) window()->damage(FL_DAMAGE_ALL, X, Y, w() + 2, h() + 2);
+ if (!Fl::box_bg(box())) {
+ // Widgets with boxtypes that don't draw the background need a parent
+ // to redraw, since it is responsible for drawing the background...
+ if (window()) {
+ int X = x() > 0 ? x() - 1 : 0;
+ int Y = y() > 0 ? y() - 1 : 0;
+ window()->damage(FL_DAMAGE_ALL, X, Y, w() + 2, h() + 2);
+ }
} else {
- if (box() && (fl_box(box())==box())) redraw();
- else redraw_label();
+ if (box() && (fl_box(box()) == box())) // ? FIXME ?
+ redraw();
+ else
+ redraw_label();
}
return 1;
- } else return 0;
+ } else {
+ return 0;
+ }
/* NOTREACHED */
- case FL_KEYBOARD :
+ case FL_KEYBOARD:
if (Fl::focus() == this && Fl::event_key() == ' ' &&
!(Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META))) {
triggered_by_keyboard: // from FL_SHORTCUT