summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-10-13 12:49:26 +0200
committerMatthias Melcher <github@matthiasm.com>2023-10-13 12:49:26 +0200
commitb1321bb97e254a5aa4d5ed6eef03d89a3892d1f9 (patch)
treef031953def82e39f6c2ef9af50576ed7df9cb19d
parent0af27f6fda2479db5ebd27e22d68bd96ac7eb2da (diff)
#748: Adds option to choose menu window boxtype
...independently from the menu button or menu bar boxtype
-rw-r--r--FL/Fl_Menu_.H11
-rw-r--r--src/Fl_Menu.cxx9
-rw-r--r--src/Fl_Menu_.cxx18
3 files changed, 28 insertions, 10 deletions
diff --git a/FL/Fl_Menu_.H b/FL/Fl_Menu_.H
index 3e7461173..acab1a33b 100644
--- a/FL/Fl_Menu_.H
+++ b/FL/Fl_Menu_.H
@@ -60,6 +60,7 @@ protected:
uchar alloc; // flag indicates if menu_ is a dynamic copy (=1) or not (=0)
uchar down_box_;
+ Fl_Boxtype menu_box_;
Fl_Font textfont_;
Fl_Fontsize textsize_;
Fl_Color textcolor_;
@@ -201,6 +202,16 @@ public:
/** Sets the box type used to surround the currently-selected items in the menus. */
void down_box(Fl_Boxtype b) {down_box_ = b;}
+ /** Get the box type for the menu popup windows.
+ \return the box type, or FL_NO_BOX if Fl_Menu_::box() is to be used instead
+ */
+ Fl_Boxtype menu_box() const { return menu_box_; }
+ /** Set the box type for the menu popup windows.
+ If menu_box set to FL_NO_BOX, the menu window will use Fl_Menu_::box() instead.
+ \param[in] b new box type or FL_NO_BOX
+ */
+ void menu_box(Fl_Boxtype b) { menu_box_ = b; }
+
/** For back compatibility, same as selection_color() */
Fl_Color down_color() const {return selection_color();}
/** For back compatibility, same as selection_color() */
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx
index a213978d3..271bcd50b 100644
--- a/src/Fl_Menu.cxx
+++ b/src/Fl_Menu.cxx
@@ -386,9 +386,12 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
if (m) m = m->first(); // find the first item that needs to be rendered
drawn_selected = -1;
if (button) {
- box(button->box());
- // don't force a box type, but make sure that the background is redrawn
- if (box() == FL_NO_BOX) box(FL_FLAT_BOX);
+ Fl_Boxtype b = button->menu_box();
+ if (b==FL_NO_BOX)
+ b = button->box();
+ if (b==FL_NO_BOX)
+ b = FL_FLAT_BOX;
+ box(b);
} else {
box(FL_UP_BOX);
}
diff --git a/src/Fl_Menu_.cxx b/src/Fl_Menu_.cxx
index 3391b35a6..0d82d92dc 100644
--- a/src/Fl_Menu_.cxx
+++ b/src/Fl_Menu_.cxx
@@ -423,17 +423,21 @@ void Fl_Menu_Item::setonly(Fl_Menu_Item const* first) {
and label string. menu() is initialized to null.
*/
Fl_Menu_::Fl_Menu_(int X,int Y,int W,int H,const char* l)
-: Fl_Widget(X,Y,W,H,l) {
+: Fl_Widget(X,Y,W,H,l),
+ menu_(NULL),
+ value_(NULL),
+ prev_value_(NULL),
+ alloc(0),
+ down_box_(FL_NO_BOX),
+ menu_box_(FL_NO_BOX),
+ textfont_(FL_HELVETICA),
+ textsize_(FL_NORMAL_SIZE),
+ textcolor_(FL_FOREGROUND_COLOR)
+{
set_flag(SHORTCUT_LABEL);
box(FL_UP_BOX);
when(FL_WHEN_RELEASE_ALWAYS);
- value_ = prev_value_ = menu_ = 0;
- alloc = 0;
selection_color(FL_SELECTION_COLOR);
- textfont(FL_HELVETICA);
- textsize(FL_NORMAL_SIZE);
- textcolor(FL_FOREGROUND_COLOR);
- down_box(FL_NO_BOX);
}
/**