SavvyUI C++ UI Library
Loading...
Searching...
No Matches
ButtonGrid.h
Go to the documentation of this file.
1#pragma once
2
3#include "Component.h"
4#include "Scrollbar.h"
5
14
24{
25 Scrollbar _scrollBar;
26
27 wstring _title;
28 vector<ButtonGridItem> _items;
29 Direction _iconPosition;
30
31 long _minWidth;
32 long _columnsPerRow;
33 long _maxVisibleItems;
34 __int64 _firstVisibleItem;
35 __int64 _lastVisibleItem;
36 __int64 _currentItem;
37
38 __int64 _indexOfPressedItem;
39
40protected:
41
50 BOOL getCreateWindowOptions(wstring& title, UINT& windowStyles, wstring& wndClassName, BOOL& isCustomWndProc);
51
56
57public:
58
61
63 virtual ~ButtonGrid();
64
68 void clear();
69
74 void setMinColumnWidth(long minWidth);
75
80 void setTitle(const wstring& title);
81
87 void setImagePosition(const Direction& imagePosition);
88
95 long addButton(const wstring& itemText, const IconSource& iconSource = IconSource());
96
103 void enableButton(const wstring& itemText, BOOL enabled = TRUE);
104
109
115
118 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed);
119 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed);
120 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed);
121 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed);
122 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed);
123 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed);
125
128 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
129 void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
130 void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
131 void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
132 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
134
140
141public:
142
143 void scrollBarActivity(__int64 firstVisibleItem);
145};
Direction
Definition Common.h:122
HWND WinHandle
Definition Common.h:16
Definition EventListeners.h:46
Definition Common.h:21
void onPaint(Graphics *g)
Paints the button grid on the screen.
void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse button is released within the component.
void onWindowResized()
Handles window resize events and recalculates layout.
BOOL getCreateWindowOptions(wstring &title, UINT &windowStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Sets the options used to create the native window.
void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the right mouse button is clicked within the component.
void addActionListener(ActionListener *l)
Registers an ActionListener to receive item click events.
void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed)
void clear()
Clears all items from the grid.
void enableButton(const wstring &itemText, BOOL enabled=TRUE)
enables/disabled button.
void setTitle(const wstring &title)
Sets the grid's title.
void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed)
void onPageDown(BOOL shiftPressed, BOOL ctrlPressed)
void windowCreated()
Called when the window is created.
void scrollBarRepaint()
void scrollBarActivity(__int64 firstVisibleItem)
void setMinColumnWidth(long minWidth)
Sets the minimum width for columns in the grid layout.
void setImagePosition(const Direction &imagePosition)
Sets the position of the image displayed on the button.
virtual ~ButtonGrid()
Destructor. Cleans up any allocated resources.
long addButton(const wstring &itemText, const IconSource &iconSource=IconSource())
Adds a button to the grid.
ButtonGrid()
Constructor. Initializes the grid.
void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed)
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is pressed within the component.
void onPageUp(BOOL shiftPressed, BOOL ctrlPressed)
void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed)
void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is moved within the component.
BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta)
Called when the mouse wheel is used over the component.
Definition ButtonGrid.h:7
Bounds _imageRect
Definition ButtonGrid.h:12
wstring _text
Definition ButtonGrid.h:10
Bounds _rect
Definition ButtonGrid.h:12
IconSource _iconSource
Definition ButtonGrid.h:9
Bounds _textRect
Definition ButtonGrid.h:12
BOOL _isDisabled
Definition ButtonGrid.h:11
Component()
Constructs a new Component instance.
Definition Graphics.h:171
Definition Graphics.h:125
Definition Scrollbar.h:14
Definition Scrollbar.h:6