SavvyUI C++ UI Library
Loading...
Searching...
No Matches
MenuBar.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Component.h
"
4
5
enum class
MenuItemType
{
6
Invalid
= 0,
7
TextItem
= 1,
8
PopupItem
= 2,
9
SeparatorItem
= 3
10
};
11
12
class
Menu
;
13
class
MenuItem
14
{
15
public
:
16
MenuItemType
_itemType
;
17
long
_actionId
;
// Identifier for the menu action (used in event handling)
18
wstring
_text
;
// Text to display on the menu item
19
Menu
*
_popupItem
;
20
21
MenuItem
();
22
virtual
~MenuItem
();
23
};
24
25
class
Menu
26
{
27
MenuHandle
_hMenu;
// Native Windows menu handle
28
29
public
:
30
31
wstring
_menuName
;
32
vector<MenuItem *>
_items
;
// List of menu items (commands or separators)
33
Bounds
_menuNameRect
;
34
35
Menu
();
36
virtual
~Menu
();
37
38
MenuHandle
getHandle
();
39
40
void
addTextItem
(
long
actionId,
const
wstring& text);
41
Menu
*
addPopupItem
(
const
wstring& text);
42
void
addSeparatorItem
();
43
};
44
45
class
MenuBar
:
public
Component
46
{
47
MenuHandle
_hMenuBar;
// Handle to the native Windows menu bar
48
vector<Menu *> _menus;
// Collection of menus attached to this menu bar
49
50
long
_highlightedMenuIndex;
51
52
protected
:
53
54
BOOL
getCreateWindowOptions
(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
55
56
void
windowCreated
();
57
58
public
:
59
60
MenuBar
();
61
virtual
~MenuBar
();
62
67
Menu
*
addMenu
(
const
wstring& menuName);
68
73
void
setMenu
(
WinHandle
hWnd);
74
75
public
:
76
77
int
getPreferredHeight
();
78
79
void
onPaint
(
Graphics
* g);
80
81
void
onWindowResized
();
82
83
void
onMousePressed
(
WinHandle
hWnd,
int
x,
int
y,
int
clickCount, BOOL shiftPressed, BOOL ctrlPressed);
84
void
onMouseMoved
(
WinHandle
hWnd,
int
x,
int
y, BOOL shiftPressed, BOOL ctrlPressed);
85
86
void
addActionListener
(
ActionListener
* l);
87
};
WinHandle
HWND WinHandle
Definition
Common.h:16
MenuHandle
HMENU MenuHandle
Definition
Common.h:18
Component.h
IconSourceType::Invalid
@ Invalid
Definition
Graphics.h:11
MenuItemType
MenuItemType
Definition
MenuBar.h:5
MenuItemType::SeparatorItem
@ SeparatorItem
Definition
MenuBar.h:9
MenuItemType::TextItem
@ TextItem
Definition
MenuBar.h:7
MenuItemType::PopupItem
@ PopupItem
Definition
MenuBar.h:8
ActionListener
Definition
EventListeners.h:46
Bounds
Definition
Common.h:21
Component::Component
Component()
Constructs a new Component instance.
Graphics
Definition
Graphics.h:171
MenuBar::~MenuBar
virtual ~MenuBar()
MenuBar::MenuBar
MenuBar()
MenuBar::setMenu
void setMenu(WinHandle hWnd)
MenuBar::onWindowResized
void onWindowResized()
Called when the component's window is resized.
MenuBar::addMenu
Menu * addMenu(const wstring &menuName)
MenuBar::onPaint
void onPaint(Graphics *g)
Called to paint the component's client area.
MenuBar::windowCreated
void windowCreated()
Abstract method called after the window has been created.
MenuBar::getPreferredHeight
int getPreferredHeight()
Returns the preferred height of the component.
MenuBar::onMousePressed
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is pressed within the component.
MenuBar::getCreateWindowOptions
BOOL getCreateWindowOptions(wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Abstract method to get window creation options.
MenuBar::addActionListener
void addActionListener(ActionListener *l)
MenuBar::onMouseMoved
void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is moved within the component.
Menu
Definition
MenuBar.h:26
Menu::addPopupItem
Menu * addPopupItem(const wstring &text)
Menu::_menuNameRect
Bounds _menuNameRect
Definition
MenuBar.h:33
Menu::~Menu
virtual ~Menu()
Menu::_items
vector< MenuItem * > _items
Definition
MenuBar.h:32
Menu::addTextItem
void addTextItem(long actionId, const wstring &text)
Menu::Menu
Menu()
Menu::_menuName
wstring _menuName
Definition
MenuBar.h:31
Menu::addSeparatorItem
void addSeparatorItem()
Menu::getHandle
MenuHandle getHandle()
MenuItem::_text
wstring _text
Definition
MenuBar.h:18
MenuItem::_itemType
MenuItemType _itemType
Definition
MenuBar.h:16
MenuItem::~MenuItem
virtual ~MenuItem()
MenuItem::_actionId
long _actionId
Definition
MenuBar.h:17
MenuItem::_popupItem
Menu * _popupItem
Definition
MenuBar.h:19
MenuItem::MenuItem
MenuItem()
MenuBar.h
Generated by
1.14.0