Ocean
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
11
#include "
ocean/platform/win/Win.h
"
12
13
#include <vector>
14
15
namespace
Ocean
16
{
17
18
namespace
Platform
19
{
20
21
namespace
Win
22
{
23
24
/**
25
* This class implements a popup menu.
26
* @ingroup platformwin
27
*/
28
class
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
*/
42
PopupMenu
();
43
44
/**
45
* Destructs a popup menu object.
46
*/
47
~PopupMenu
();
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
*/
68
bool
addSeparator
();
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.
99
PopupMenus
subMenus_
;
100
};
101
102
}
103
104
}
105
106
}
107
108
#endif
// META_OCEAN_PLATFORM_WIN_POPUP_MENU_H
Win.h
Ocean::Platform::Win::PopupMenu
This class implements a popup menu.
Definition:
PopupMenu.h:29
Ocean::Platform::Win::PopupMenu::PopupMenu
PopupMenu()
Creates a new popup menu object.
Ocean::Platform::Win::PopupMenu::show
unsigned int show(const HWND parent)
Shows the menu at the current cursor (mouse) position and returns the selected entry id.
Ocean::Platform::Win::PopupMenu::~PopupMenu
~PopupMenu()
Destructs a popup menu object.
Ocean::Platform::Win::PopupMenu::size
size_t size() const
Returns the number of menu entries (not any sub-entries).
Ocean::Platform::Win::PopupMenu::addSeparator
bool addSeparator()
Adds a seperator menu entry.
Ocean::Platform::Win::PopupMenu::addEntry
bool addEntry(const std::wstring &text, const unsigned int id, const bool checked=false)
Adds a new menu entry.
Ocean::Platform::Win::PopupMenu::show
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.
Ocean::Platform::Win::PopupMenu::subMenus_
PopupMenus subMenus_
The sub-menus of this menu.
Definition:
PopupMenu.h:99
Ocean::Platform::Win::PopupMenu::PopupMenus
std::vector< PopupMenu * > PopupMenus
Definition of a vector holding popup menus.
Definition:
PopupMenu.h:35
Ocean::Platform::Win::PopupMenu::addMenu
PopupMenu & addMenu(const std::wstring &text)
Adds a new sub-menu entry.
Ocean
The namespace covering the entire Ocean framework.
Definition:
Accessor.h:15
impl
ocean
platform
win
PopupMenu.h
Generated on Wed Nov 13 2024 18:48:18 for Ocean by
1.9.1