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
14
22class ButtonMenu : public Component
23{
24 wstring _title;
25 vector<ButtonMenuItem> _items;
26 Direction _iconPosition;
27 BOOL _isPinnable;
28
29 long _maxVisibleItems;
30 long _firstVisibleItem;
31 long _lastVisibleItem;
32 long _currentItem;
33 long _moveOverItemIndex;
34 long _lastMouseMoveX;
35 long _lastMouseMoveY;
36 long _style;
37
38 long _indexOfPressedItem;
39
40protected:
41
50 BOOL getCreateWindowOptions(wstring& title, UINT& windowStyles, wstring& wndClassName, BOOL& isCustomWndProc);
51
56
57public:
58
61
63 virtual ~ButtonMenu();
64
67
70
72 void setPinnable(BOOL isPinnable = TRUE);
73
75 void clear();
76
81 void setTitle(const wstring& title);
82
88 void setImagePosition(const Direction& imagePosition);
89
96 long addItem(const wstring& itemText, const wstring& itemId = L"", const IconSource& iconSource = IconSource());
97
104 void enableItem(const wstring& itemText, BOOL enabled = TRUE);
105
108
111
117
120
123 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed);
124 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed);
125 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed);
126 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed);
127 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed);
128 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed);
130
133 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
134 void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
135 void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
136 void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
137 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
139
147 BOOL getScrollingInfo(__int64& scrollMin, __int64& scrollMax, __int64& pageSize);
148
153 void setScrollbarTopOffset(__int64 firstVisibleRow);
154
160};
Direction
Definition Common.h:114
HWND WinHandle
Definition Common.h:16
Definition Common.h:20
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.
BOOL getScrollingInfo(__int64 &scrollMin, __int64 &scrollMax, __int64 &pageSize)
Retrieves information about scrolling limits and page size.
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 onArrowUp(BOOL shiftPressed, BOOL ctrlPressed)
void onPageUp(BOOL shiftPressed, BOOL ctrlPressed)
void setScrollbarTopOffset(__int64 firstVisibleRow)
Sets the vertical scrollbar position by row offset.
void onPageDown(BOOL shiftPressed, BOOL ctrlPressed)
void enableItem(const wstring &itemText, BOOL enabled=TRUE)
enables/disabled button.
Definition ButtonMenu.h:6
wstring _text
Definition ButtonMenu.h:9
IconSource _iconSource
Definition ButtonMenu.h:10
wstring _id
Definition ButtonMenu.h:8
Bounds _rect
Definition ButtonMenu.h:12
Bounds _imageRect
Definition ButtonMenu.h:12
Bounds _textRect
Definition ButtonMenu.h:12
BOOL _isDisabled
Definition ButtonMenu.h:11
Component()
Constructs a new Component instance.
Definition Graphics.h:161
Definition Graphics.h:115
Definition EventListeners.h:31