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
5enum class MenuItemType {
6 Invalid = 0,
10};
11
12class Menu;
14{
15public:
17 long _actionId; // Identifier for the menu action (used in event handling)
18 wstring _text; // Text to display on the menu item
20
22 virtual ~MenuItem();
23};
24
25class Menu
26{
27 MenuHandle _hMenu; // Native Windows menu handle
28
29public:
30
31 wstring _menuName;
32 vector<MenuItem *> _items; // List of menu items (commands or separators)
34
36 virtual ~Menu();
37
39
40 void addTextItem(long actionId, const wstring& text);
41 Menu* addPopupItem(const wstring& text);
43};
44
45class 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
52protected:
53
54 BOOL getCreateWindowOptions(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
55
57
58public:
59
61 virtual ~MenuBar();
62
67 Menu* addMenu(const wstring& menuName);
68
73 void setMenu(WinHandle hWnd);
74
75public:
76
78
79 void onPaint(Graphics* g);
80
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
87};
HWND WinHandle
Definition Common.h:16
HMENU MenuHandle
Definition Common.h:18
@ Invalid
Definition Graphics.h:11
MenuItemType
Definition MenuBar.h:5
@ SeparatorItem
Definition MenuBar.h:9
@ TextItem
Definition MenuBar.h:7
@ PopupItem
Definition MenuBar.h:8
Definition EventListeners.h:46
Definition Common.h:21
Component()
Constructs a new Component instance.
Definition Graphics.h:171
virtual ~MenuBar()
void setMenu(WinHandle hWnd)
void onWindowResized()
Called when the component's window is resized.
Menu * addMenu(const wstring &menuName)
void onPaint(Graphics *g)
Called to paint the component's client area.
void windowCreated()
Abstract method called after the window has been created.
int getPreferredHeight()
Returns the preferred height of the component.
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is pressed within the component.
BOOL getCreateWindowOptions(wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Abstract method to get window creation options.
void addActionListener(ActionListener *l)
void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is moved within the component.
Definition MenuBar.h:26
Menu * addPopupItem(const wstring &text)
Bounds _menuNameRect
Definition MenuBar.h:33
virtual ~Menu()
vector< MenuItem * > _items
Definition MenuBar.h:32
void addTextItem(long actionId, const wstring &text)
wstring _menuName
Definition MenuBar.h:31
void addSeparatorItem()
MenuHandle getHandle()
wstring _text
Definition MenuBar.h:18
MenuItemType _itemType
Definition MenuBar.h:16
virtual ~MenuItem()
long _actionId
Definition MenuBar.h:17
Menu * _popupItem
Definition MenuBar.h:19