diff options
| author | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-05 16:24:45 +0500 |
|---|---|---|
| committer | maxim nikonov <maxim.nikonov@hqo.co> | 2026-02-05 16:24:45 +0500 |
| commit | cdf2832347b8fdf0389cd373c2ead0ac5d071037 (patch) | |
| tree | 96f9771aed0710899aa6cbba2a84dadfe76e996e /src/Fl_Menu.cxx | |
| parent | db214d1145e46d527a46d1fc2519548d2c4d23f1 (diff) | |
wip
Diffstat (limited to 'src/Fl_Menu.cxx')
| -rw-r--r-- | src/Fl_Menu.cxx | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/src/Fl_Menu.cxx b/src/Fl_Menu.cxx index 94d7e952e..c574d32b1 100644 --- a/src/Fl_Menu.cxx +++ b/src/Fl_Menu.cxx @@ -48,7 +48,7 @@ extern char fl_draw_shortcut; // Local variables: // appearance of current menus are pulled from this parent widget: -static const Fl_Menu_* button = nullptr; +static const Fl_Menu_* button = 0; // // ==== Declarations =========================================================== @@ -73,11 +73,11 @@ static const Fl_Menu_* button = nullptr; // of windows is slow, and we don't want to fall behind the events. // values for Menu_State.state: -enum class State { - INIT = 0, // no mouse up or down since popup() called - PUSHED, // mouse has been pushed on a normal item - MENU_PUSHED, // mouse has been pushed on a menu title - DONE, // exit the popup, the current item was picked +enum { + MENU_STATE_INIT = 0, + MENU_STATE_PUSHED, + MENU_STATE_MENU_PUSHED, + MENU_STATE_DONE, }; /* @@ -85,8 +85,8 @@ enum class State { */ struct Menu_State { - // menu item under the mouse pinter or selected by keyboard, or nullptr - const Fl_Menu_Item* current_item = nullptr; + // menu item under the mouse pinter or selected by keyboard, or 0 + const Fl_Menu_Item* current_item = 0; // index of the menu window that contains the current_item menu_index_t current_menu_ix = 0; @@ -95,7 +95,7 @@ struct Menu_State item_index_t current_item_ix = -1; // pointers to open menu windows - Menu_Window* menu_window[20] { nullptr }; + Menu_Window* menu_window[20] { 0 }; // number of open menuwindows menu_index_t num_menus = 0; @@ -104,11 +104,11 @@ struct Menu_State // horizontally arranged level 0 menu item list bool in_menubar = false; - // State::INIT, etc. See above - State state = State::INIT; + // MENU_STATE_INIT, etc. See above + int state = MENU_STATE_INIT; // simulate a button in the top level of a menubar - Menu_Window* menubar_button_helper = nullptr; + Menu_Window* menubar_button_helper = 0; // check if mouse coordinates are inside any of the menu windows bool is_inside(int mx, int my); @@ -155,7 +155,7 @@ struct Menu_State }; // Global state of menu windows and popup windows. -static Menu_State* menu_state = nullptr; +static Menu_State* menu_state = 0; // @@ -188,10 +188,10 @@ protected: public: // Store a pointer to the first item in the menu array. - const Fl_Menu_Item* menu { nullptr }; + const Fl_Menu_Item* menu { 0 }; // Use this to check this is a Fl_Menu_Window or a derived window class. - virtual Menu_Window* as_menuwindow() { return nullptr; } + virtual Menu_Window* as_menuwindow() { return 0; } }; // @@ -204,7 +204,7 @@ public: class Menu_Title_Window : public Menu_Window_Basetype { /* Draw the contents of the menu title window. */ - void draw() override { + void draw() { menu->draw(0, 0, w(), h(), button, 2); } @@ -240,7 +240,7 @@ class Menu_Window : public Menu_Window_Basetype friend struct Fl_Menu_Item; // Draw this window, either entirely, or just the selected and deselect items. - void draw() override; + void draw(); // Draw a single menu item in this window void draw_entry(const Fl_Menu_Item*, int i, int erase); @@ -277,10 +277,10 @@ public: ~Menu_Window(); // Override to fixup the current selection - void hide() override; + void hide(); // Override to handle all incoming events - int handle(int) override; + int handle(int); // Change the index of the selected item, -1 for none. Trigger chatty callbacks // and marks the window area of the newly selected item for redraw. @@ -303,10 +303,10 @@ public: bool is_inside(int x, int y); // Fake runtime type information - Menu_Window* as_menuwindow() override { return this; } + Menu_Window* as_menuwindow() { return this; } // Optional title for menubar windows and floating menus - Menu_Title_Window* title { nullptr }; + Menu_Title_Window* title { 0 }; // Height of the tallest menu item in the array, zero == menubar. int item_height { 0 }; @@ -328,7 +328,7 @@ public: bool menubar_title { false }; // In a cascading window, this points to the menu window that opened this menu. - Menu_Window *origin { nullptr }; + Menu_Window *origin { 0 }; // Used by the window driver int offset_y { 0 }; @@ -441,7 +441,7 @@ int Menu_State::handle_shortcut() { if (m) { set_current_item(m, mymenu, item); if (!m->submenu()) - state = State::DONE; + state = MENU_STATE_DONE; return 1; } } @@ -490,7 +490,7 @@ int Menu_State::handle_select() { if (current_item && !current_item->selectable()) return 1; // Mark the menu 'done' which will trigger the callback - state = State::DONE; + state = MENU_STATE_DONE; return 1; } @@ -499,7 +499,7 @@ int Menu_State::handle_select() { */ int Menu_State::handle_cancel() { set_current_item(0, -1, 0); - state = State::DONE; + state = MENU_STATE_DONE; return 1; } @@ -556,7 +556,7 @@ int Menu_State::handle_mouse_events(int e) { switch (e) { case FL_MOVE: { static int use_part1_extra = Fl::screen_driver()->need_menu_handle_part1_extra(); - if (use_part1_extra && state == State::DONE) { + if (use_part1_extra && state == MENU_STATE_DONE) { return 1; // Fix for STR #2619 } } @@ -573,7 +573,7 @@ int Menu_State::handle_mouse_events(int e) { if ((!in_menubar || mymenu) && !is_inside(mx, my)) { set_current_item(0, -1, 0); if (e==FL_PUSH) - state = State::DONE; + state = MENU_STATE_DONE; return 1; } for (mymenu = num_menus-1; ; mymenu--) { @@ -583,12 +583,12 @@ int Menu_State::handle_mouse_events(int e) { if (mymenu <= 0) { // buttons in menubars must be deselected if we move outside of them! if (current_menu_ix==-1 && e==FL_PUSH) { - state = State::DONE; + state = MENU_STATE_DONE; return 1; } if (current_item && current_menu_ix==0 && !current_item->submenu()) { if (e==FL_PUSH) { - state = State::DONE; + state = MENU_STATE_DONE; set_current_item(0, -1, 0); } return 1; @@ -602,9 +602,9 @@ int Menu_State::handle_mouse_events(int e) { if (current_item && current_item->submenu() // this is a menu title && item != menu_window[mymenu]->selected // and it is not already on && !current_item->callback_) // and it does not have a callback - state = State::MENU_PUSHED; + state = MENU_STATE_MENU_PUSHED; else - state = State::PUSHED; + state = MENU_STATE_PUSHED; } } return 1; @@ -612,7 +612,7 @@ int Menu_State::handle_mouse_events(int e) { // Mouse must either be held down/dragged some, or this must be // the second click (not the one that popped up the menu): if ( !Fl::event_is_click() - || state == State::PUSHED + || state == MENU_STATE_PUSHED || (in_menubar && current_item && !current_item->submenu()) // button ) { #if 0 // makes the check/radio items leave the menu up @@ -625,7 +625,7 @@ int Menu_State::handle_mouse_events(int e) { // do nothing if they try to pick an inactive item, or a submenu with no callback if (!current_item || (current_item->selectable() && (!current_item->submenu() || current_item->callback_ || (in_menubar && current_menu_ix <= 0)))) - state = State::DONE; + state = MENU_STATE_DONE; } return 1; } @@ -690,7 +690,7 @@ bool Menu_State::create_submenu(const Fl_Rect &r, Menu_Window& cw, const Fl_Menu // delete all the old menus and create new one: while (num_menus > current_menu_ix+1) delete menu_window[--num_menus]; menu_window[num_menus++] = new Menu_Window(menutable, nX, nY, - title?1:0, 0, nullptr, title, false, (bool)menubar, + title?1:0, 0, 0, title, false, (bool)menubar, (title ? 0 : cw.x()) ); if (num_menus >= 2 && menu_window[num_menus-2]->item_height) { menu_window[num_menus-1]->origin = menu_window[num_menus-2]; @@ -710,10 +710,10 @@ void Menu_State::delete_unused_menus(Menu_Window& cw, const Fl_Menu_Item* m) { delete menu_window[--num_menus]; if (in_menubar && (current_menu_ix == 0)) { // kludge so "menubar buttons" turn "on" by using menu title: - menubar_button_helper = new Menu_Window(nullptr, + menubar_button_helper = new Menu_Window(0, cw.x()+cw.titlex(current_item_ix), cw.y()+cw.h(), 0, 0, - nullptr, m, false, true); + 0, m, false, true); menubar_button_helper->title->show(); } } @@ -723,7 +723,7 @@ void Menu_State::delete_unused_menus(Menu_Window& cw, const Fl_Menu_Item* m) { // // Static members: -Fl_Window *Menu_Window::parent_ = nullptr; +Fl_Window *Menu_Window::parent_ = 0; int Menu_Window::display_height_ = 0; @@ -733,7 +733,7 @@ int Menu_Window::display_height_ = 0; \param[in] X, Y position relative to parent_ \param[in] Wp, Hp initial minimum size; if Wp is 0, the window will open on the screen with X and Y, else it will open in the screen with the mouse pointer. - \param[in] picked pointer to the currently picked menu item, can be nullptr + \param[in] picked pointer to the currently picked menu item, can be 0 \param[in] t pointer to the menutitle window \param[in] in_menubar set if part of an Fl_Menu_Bar menu \param[in] mb_title set if the title window is also the button in Fl_Menu_Bar @@ -959,7 +959,7 @@ int Menu_Window::handle_part2(int e, int ret) { // now, so that Carbon can continue undisturbed with handling window // manager events, like dragging the application window. Menu_State &pp = *menu_state; - if (pp.state == State::DONE) { + if (pp.state == MENU_STATE_DONE) { hide(); if (pp.menubar_button_helper) { pp.menubar_button_helper->hide(); @@ -1249,7 +1249,7 @@ int Fl_Menu_Item::size() const { \param[in] m start from this menu item inside an array \return a pointer to the next menu item. If the label() of the returned - item is nullptr, the function reached the end of the array and + item is 0, the function reached the end of the array and no next item was found. */ static const Fl_Menu_Item* next_visible_or_not(const Fl_Menu_Item* m) { @@ -1274,7 +1274,7 @@ static const Fl_Menu_Item* next_visible_or_not(const Fl_Menu_Item* m) { \param[in] n advance by n items \return a pointer to the next menu item. If the label() of the returned - item is nullptr, the function reached the end of the array and + item is 0, the function reached the end of the array and no next item was found. */ const Fl_Menu_Item* Fl_Menu_Item::next(int n) const { @@ -1439,7 +1439,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown( goto STARTUP; } - pp.current_item = nullptr; + pp.current_item = 0; pp.current_menu_ix = 0; pp.current_item_ix = -1; if (menubar) { @@ -1458,7 +1458,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown( goto STARTUP; } - // the main loop: runs until p.state goes to State::DONE or the menu + // the main loop: runs until p.state goes to MENU_STATE_DONE or the menu // widget is deleted (e.g. from a timer callback, see STR #3503): for (;;) { @@ -1478,14 +1478,14 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown( Fl::wait(); if (pbutton && wp.deleted()) // menu widget has been deleted (STR #3503) break; - if (pp.state == State::DONE) break; // done. + if (pp.state == MENU_STATE_DONE) break; // done. if (pp.current_item == oldi) continue; } // only do rest if item changes: if (pp.menubar_button_helper) { delete pp.menubar_button_helper; - pp.menubar_button_helper = nullptr; + pp.menubar_button_helper = 0; } // turn off "menubar button" if (!pp.current_item) { // pointing at nothing @@ -1496,7 +1496,7 @@ const Fl_Menu_Item* Fl_Menu_Item::pulldown( if (pp.menubar_button_helper) { delete pp.menubar_button_helper; - pp.menubar_button_helper = nullptr; + pp.menubar_button_helper = 0; } initial_item = 0; // stop the startup code if (pp.current_menu_ix < 0 || pp.current_menu_ix >= pp.num_menus) { @@ -1658,7 +1658,7 @@ Fl_Window *Fl_Window_Driver::menu_parent(int *display_height) { /* Cast to menuwindow if win is of claa menuwindow and the driver is initialized. */ static Menu_Window *to_menuwindow(Fl_Window *win) { - if (!Fl_Window_Driver::driver(win)->popup_window() || !win->menu_window()) return nullptr; + if (!Fl_Window_Driver::driver(win)->popup_window() || !win->menu_window()) return 0; return ((Menu_Window_Basetype*)win)->as_menuwindow(); } |
