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
13
22class ButtonGrid : public Component
23{
24 wstring _title;
25 vector<ButtonGridItem> _items;
26 Direction _iconPosition;
27
28 long _minWidth;
29 long _columnsPerRow;
30 long _maxVisibleItems;
31 long _firstVisibleItem;
32 long _lastVisibleItem;
33 long _currentItem;
34
35 long _indexOfPressedItem;
36
37protected:
38
47 BOOL getCreateWindowOptions(wstring& title, UINT& windowStyles, wstring& wndClassName, BOOL& isCustomWndProc);
48
53
54public:
55
58
60 virtual ~ButtonGrid();
61
65 void clear();
66
71 void setMinColumnWidth(long minWidth);
72
77 void setTitle(const wstring& title);
78
84 void setImagePosition(const Direction& imagePosition);
85
92 long addButton(const wstring& itemText, const IconSource& iconSource = IconSource());
93
100 void enableButton(const wstring& itemText, BOOL enabled = TRUE);
101
106
112
115 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed);
116 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed);
117 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed);
118 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed);
119 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed);
120 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed);
122
125 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
126 void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
127 void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
128 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
130
138 BOOL getScrollingInfo(__int64& scrollMin, __int64& scrollMax, __int64& pageSize);
139
144 void setScrollbarTopOffset(__int64 firstVisibleRow);
145
151};
Direction
Definition Common.h:114
HWND WinHandle
Definition Common.h:16
Definition EventListeners.h:46
Definition Common.h:20
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.
BOOL getScrollingInfo(__int64 &scrollMin, __int64 &scrollMax, __int64 &pageSize)
Retrieves scroll range and page size information.
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 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 setScrollbarTopOffset(__int64 firstVisibleRow)
Sets the top row index for vertical scrollbar.
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)
BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta)
Called when the mouse wheel is used over the component.
Definition ButtonGrid.h:6
Bounds _imageRect
Definition ButtonGrid.h:11
wstring _text
Definition ButtonGrid.h:9
Bounds _rect
Definition ButtonGrid.h:11
IconSource _iconSource
Definition ButtonGrid.h:8
Bounds _textRect
Definition ButtonGrid.h:11
BOOL _isDisabled
Definition ButtonGrid.h:10
Component()
Constructs a new Component instance.
Definition Graphics.h:161
Definition Graphics.h:115