SavvyUI C++ UI Library
Loading...
Searching...
No Matches
ButtonMenu.h
Go to the documentation of this file.
1#pragma once
2
3#include "Component.h"
4#include "Scrollbar.h"
5
15
24{
25 Scrollbar _scrollBar;
26
27 wstring _title;
28 vector<ButtonMenuItem> _items;
29 Direction _iconPosition;
30 BOOL _isPinnable;
31
32 long _maxVisibleItems;
33 __int64 _firstVisibleItem;
34 __int64 _lastVisibleItem;
35 __int64 _currentItem;
36 __int64 _moveOverItemIndex;
37 long _lastMouseMoveX;
38 long _lastMouseMoveY;
39 long _style;
40
41 __int64 _indexOfPressedItem;
42
43protected:
44
53 BOOL getCreateWindowOptions(wstring& title, UINT& windowStyles, wstring& wndClassName, BOOL& isCustomWndProc);
54
59
60public:
61
64
66 virtual ~ButtonMenu();
67
70
73
75 void setPinnable(BOOL isPinnable = TRUE);
76
78 void clear();
79
84 void setTitle(const wstring& title);
85
91 void setImagePosition(const Direction& imagePosition);
92
99 long addItem(const wstring& itemText, const wstring& itemId = L"", const IconSource& iconSource = IconSource());
100
107 void enableItem(const wstring& itemText, BOOL enabled = TRUE);
108
111
114
120
123
126 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed);
127 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed);
128 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed);
129 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed);
130 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed);
131 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed);
133
136 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
137 void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
138 void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
139 void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
140 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
142
148
149public:
150
151 void scrollBarActivity(__int64 firstVisibleItem);
153};
Direction
Definition Common.h:122
HWND WinHandle
Definition Common.h:16
Definition Common.h:21
void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed)
void enableButtonStyle()
Enables button-style rendering of items.
void windowCreated()
Called after the window has been created.
void setPinnable(BOOL isPinnable=TRUE)
Enables pinnable button state.
void enableLinkStyle()
Enables link-style rendering of items.
void clear()
Removes all items from the menu.
void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse button is released within the component.
void addSelectionChangedListener(SelectionChangeListener *l)
Adds a listener to be notified when the selection changes.
void onPaint(Graphics *g)
Paints 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.
void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed)
void setTitle(const wstring &title)
Sets the menu title.
void onWindowResized()
Called when the window is resized.
virtual ~ButtonMenu()
Destructor.
long getSelectedItem()
Gets the index of the currently selected item.
BOOL getCreateWindowOptions(wstring &title, UINT &windowStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Retrieves window creation options.
BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta)
Called when the mouse wheel is used over the component.
void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed)
void setImagePosition(const Direction &imagePosition)
Sets the position of the image displayed on the button.
ButtonMenu()
Constructor.
long addItem(const wstring &itemText, const wstring &itemId=L"", const IconSource &iconSource=IconSource())
Adds a new item to the menu.
void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the right mouse button is clicked within the component.
void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is moved within the component.
long getItemCount()
Returns the number of items in the menu.
void scrollBarActivity(__int64 firstVisibleItem)
void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed)
void onPageUp(BOOL shiftPressed, BOOL ctrlPressed)
void onPageDown(BOOL shiftPressed, BOOL ctrlPressed)
void scrollBarRepaint()
void enableItem(const wstring &itemText, BOOL enabled=TRUE)
enables/disabled button.
Definition ButtonMenu.h:7
wstring _text
Definition ButtonMenu.h:10
IconSource _iconSource
Definition ButtonMenu.h:11
wstring _id
Definition ButtonMenu.h:9
Bounds _rect
Definition ButtonMenu.h:13
Bounds _imageRect
Definition ButtonMenu.h:13
Bounds _textRect
Definition ButtonMenu.h:13
BOOL _isDisabled
Definition ButtonMenu.h:12
Component()
Constructs a new Component instance.
Definition Graphics.h:171
Definition Graphics.h:125
Definition Scrollbar.h:14
Definition Scrollbar.h:6
Definition EventListeners.h:31