Ocean
Loading...
Searching...
No Matches
PopupMenu.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_WIN_POPUP_MENU_H
9#define META_OCEAN_PLATFORM_WIN_POPUP_MENU_H
10
12
13#include <vector>
14
15namespace Ocean
16{
17
18namespace Platform
19{
20
21namespace Win
22{
23
24/**
25 * This class implements a popup menu.
26 * @ingroup platformwin
27 */
28class OCEAN_PLATFORM_WIN_EXPORT PopupMenu
29{
30 protected:
31
32 /**
33 * Definition of a vector holding popup menus.
34 */
35 typedef std::vector<PopupMenu*> PopupMenus;
36
37 public:
38
39 /**
40 * Creates a new popup menu object.
41 */
43
44 /**
45 * Destructs a popup menu object.
46 */
48
49 /**
50 * Returns the number of menu entries (not any sub-entries).
51 * @return Number of menu entries
52 */
53 size_t size() const;
54
55 /**
56 * Adds a new menu entry.
57 * @param text The text of the menu entry
58 * @param id the unique entry id that is returned if this entry is selected, must not be zero
59 * @param checked True, if the entry is checked
60 * @return True, if succeeded
61 */
62 bool addEntry(const std::wstring& text, const unsigned int id, const bool checked = false);
63
64 /**
65 * Adds a seperator menu entry.
66 * @return True, if succeeded
67 */
69
70 /**
71 * Adds a new sub-menu entry.
72 * @param text The text of the sub-menu entry
73 * @return The reference of the new sub-menu
74 */
75 PopupMenu& addMenu(const std::wstring& text);
76
77 /**
78 * Shows the menu at a specified screen position and returns the selected entry id.
79 * @param x The horizontal display position in screen coordinates
80 * @param y The vertical display position in screen coordinates
81 * @param parent The parent window handle, must not be zero
82 * @return The id of the selected menu entry, zero if no entry has been selected
83 */
84 unsigned int show(const int x, const int y, const HWND parent);
85
86 /**
87 * Shows the menu at the current cursor (mouse) position and returns the selected entry id.
88 * @param parent The parent window handle, must not be zero
89 * @return The id of the selected menu entry, zero if no entry has been selected
90 */
91 unsigned int show(const HWND parent);
92
93 protected:
94
95 /// The handle of this menu.
96 HMENU handle_ = nullptr;
97
98 /// The sub-menus of this menu.
100};
101
102}
103
104}
105
106}
107
108#endif // META_OCEAN_PLATFORM_WIN_POPUP_MENU_H
This class implements a popup menu.
Definition PopupMenu.h:29
PopupMenu()
Creates a new popup menu object.
PopupMenu & addMenu(const std::wstring &text)
Adds a new sub-menu entry.
unsigned int show(const HWND parent)
Shows the menu at the current cursor (mouse) position and returns the selected entry id.
~PopupMenu()
Destructs a popup menu object.
size_t size() const
Returns the number of menu entries (not any sub-entries).
bool addSeparator()
Adds a seperator menu entry.
bool addEntry(const std::wstring &text, const unsigned int id, const bool checked=false)
Adds a new menu entry.
unsigned int show(const int x, const int y, const HWND parent)
Shows the menu at a specified screen position and returns the selected entry id.
PopupMenus subMenus_
The sub-menus of this menu.
Definition PopupMenu.h:99
std::vector< PopupMenu * > PopupMenus
Definition of a vector holding popup menus.
Definition PopupMenu.h:35
The namespace covering the entire Ocean framework.
Definition Accessor.h:15