Ocean
WxPopupMenu.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_PLATFORM_WXWIDGETS_WX_POPUP_MENU_H
9 #define META_OCEAN_PLATFORM_WXWIDGETS_WX_POPUP_MENU_H
10 
12 
13 namespace Ocean
14 {
15 
16 namespace Platform
17 {
18 
19 namespace WxWidgets
20 {
21 
22 /**
23  * This class implements a popup menu.
24  * @ingroup platformwxwidgets
25  */
26 class OCEAN_PLATFORM_WXWIDGETS_EXPORT WxPopupMenu : public wxMenu
27 {
28  public:
29 
30  /**
31  * Creates a new popup menu.
32  */
33  WxPopupMenu() = default;
34 
35  /**
36  * Pops this menu up.
37  * @param parent The parent window, must be valid
38  * @param x The horizontal popup position
39  * @param y The vertical popup position
40  * @param invalidId The resulting id if no menu entry has been selected
41  * @return The id of the selected menu entry, or invalidId
42  */
43  int popup(wxWindow& parent, const int x = -1, const int y = -1, const int invalidId = -1);
44 
45  /**
46  * Pops this menu up if no associated parent window is known.
47  * @param x The horizontal popup position
48  * @param y The vertical popup position
49  * @param invalidId The resulting id if no menu entry has been selected
50  * @return The id of the selected menu entry, or invalidId
51  */
52  int popup(const int x = -1, const int y = -1, const int invalidId = -1);
53 
54  protected:
55 
56  /**
57  * Exchanges the default event handler of all sub menus by the event handler from the root menu.
58  * @param rootMenu The root menu providing the event handler
59  * @param menu The menu which's event handler will be exchanged, may be the rootMenu
60  */
61  static void exchangeEventHandler(wxMenu& rootMenu, wxMenu& menu);
62 
63  /**
64  * Menu click event function.
65  * @param event The event object
66  */
67  void onPopupMenuClick(wxCommandEvent& event);
68 
69  protected:
70 
71  /// The selected id.
72  int menuId_ = -1;
73 };
74 
75 }
76 
77 }
78 
79 }
80 
81 #endif // META_OCEAN_PLATFORM_WXWIDGETS_WX_POPUP_MENU_H
This class implements a popup menu.
Definition: WxPopupMenu.h:27
int popup(const int x=-1, const int y=-1, const int invalidId=-1)
Pops this menu up if no associated parent window is known.
int popup(wxWindow &parent, const int x=-1, const int y=-1, const int invalidId=-1)
Pops this menu up.
WxPopupMenu()=default
Creates a new popup menu.
static void exchangeEventHandler(wxMenu &rootMenu, wxMenu &menu)
Exchanges the default event handler of all sub menus by the event handler from the root menu.
void onPopupMenuClick(wxCommandEvent &event)
Menu click event function.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15