SavvyUI C++ UI Library
Loading...
Searching...
No Matches
Toolbar.h
Go to the documentation of this file.
1#pragma once
2
3#include "Component.h"
4
15
16
21class Toolbar : public Component
22{
26 vector<ToolbarItem> _items;
27
28 long _firstVisibleItem;
29 long _lastVisibleItem;
30
31 long _indexOfPressedItem;
32 BOOL _lastItemIsPartiallyDisplayed;
33
34 Bounds _scrollLeftBtnRect, _scrollRightBtnRect;
35
36protected:
46 BOOL getCreateWindowOptions(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
47
52
53public:
58
62 virtual ~Toolbar();
63
68
73 void onPaint(Graphics *g);
74
77 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
78 void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
79 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
81
90 void addItem(long id, const wstring& text, const IconSource& iconSource = IconSource(), const Direction& iconPosition = Direction::LEFT);
91
98 void enableItem(long id, BOOL enabled = TRUE);
99
107 void onAction(WinHandle hTarget, long actionId, const ProcParams& procParams);
108
115};
Direction
Definition Common.h:114
@ LEFT
Definition Common.h:115
HWND WinHandle
Definition Common.h:16
Definition EventListeners.h:46
Definition Common.h:20
Component()
Constructs a new Component instance.
Definition Graphics.h:161
Definition Graphics.h:115
Definition Component.h:9
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is pressed within the component.
void onWindowResized()
Called when the toolbar window is resized.
void addItem(long id, const wstring &text, const IconSource &iconSource=IconSource(), const Direction &iconPosition=Direction::LEFT)
Adds an item to the toolbar.
Toolbar()
Constructs a new Toolbar instance.
void enableItem(long id, BOOL enabled=TRUE)
enables/disabled items.
void addActionListener(ActionListener *l)
Adds an action listener to the button to handle action events.
virtual ~Toolbar()
Destroys the Toolbar instance.
void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse button is released within the component.
void windowCreated()
Called after the toolbar window is created.
void onPaint(Graphics *g)
Paints the toolbar on the screen.
BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta)
Called when the mouse wheel is used over the component.
void onAction(WinHandle hTarget, long actionId, const ProcParams &procParams)
Handles an action event for this component.
BOOL getCreateWindowOptions(wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Retrieves the options for creating the toolbar window.
Definition Toolbar.h:6
BOOL _isDisabled
Definition Toolbar.h:12
IconSource _iconSource
Definition Toolbar.h:10
Bounds _rect
Definition Toolbar.h:13
wstring _text
Definition Toolbar.h:9
Direction _iconPosition
Definition Toolbar.h:11
long _id
Definition Toolbar.h:8