Skip to content

Commit

Permalink
Add Menu mvalue() and prev_mvalue()
Browse files Browse the repository at this point in the history
  • Loading branch information
MoAlyousef committed Jul 26, 2024
1 parent 25d5b41 commit 9159391
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
4 changes: 3 additions & 1 deletion include/cfl_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ extern "C" {
const Fl_Menu_Item *item \
); \
void widget##_set_menu_box(widget *self, int b); \
int widget##_menu_box(const widget *self);
int widget##_menu_box(const widget *self); \
Fl_Menu_Item *widget##_mvalue(const widget *); \
Fl_Menu_Item *widget##_prev_mvalue(const widget *);

typedef struct Fl_Menu_Item Fl_Menu_Item;

Expand Down
17 changes: 15 additions & 2 deletions src/cfl_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@
int widget##_menu_box(const widget *self) { \
LOCK(auto ret = self->menu_box()); \
return ret; \
} \
Fl_Menu_Item *widget##_mvalue(const widget *self) { \
LOCK(auto ret = self->mvalue()); \
return (Fl_Menu_Item *)ret; \
} \
Fl_Menu_Item *widget##_prev_mvalue(const widget *self) { \
LOCK(auto ret = self->prev_mvalue()); \
return (Fl_Menu_Item *)ret; \
}

WIDGET_CLASS(Fl_Menu_Bar)
Expand Down Expand Up @@ -252,7 +260,11 @@ const Fl_Menu_Item *Fl_Menu_Item_pulldown(
const Fl_Menu_Item *title,
int menubar
) {
LOCK(auto ret = self->pulldown(X, Y, W, H, picked, (const Fl_Menu_ *)menu, title, menubar));
LOCK(
auto ret = self->pulldown(
X, Y, W, H, picked, (const Fl_Menu_ *)menu, title, menubar
)
);
return ret;
}

Expand Down Expand Up @@ -365,7 +377,8 @@ void Fl_Menu_Item_set_callback(Fl_Menu_Item *self, Fl_Callback *c, void *p) {
}

void Fl_Menu_Item_do_callback(Fl_Menu_Item *self, Fl_Widget *w) {
LOCK(if (self->callback() && ((Fl_Menu_*)w)->find_index(self) >= 0) self->do_callback(w));
LOCK(if (self->callback() && ((Fl_Menu_ *)w)->find_index(self) >= 0)
self->do_callback(w));
}

void *Fl_Menu_Item_user_data(const Fl_Menu_Item *self) {
Expand Down

0 comments on commit 9159391

Please sign in to comment.