SavvyUI C++ UI Library
Loading...
Searching...
No Matches
IconMenu.h
Go to the documentation of this file.
1#pragma once
2
3#include "Component.h"
4#include "Scrollbar.h"
5
18
25class IconMenu : public Component, public ScrollbarListener
26{
27 Scrollbar _scrollBar;
28
29 wstring _title;
30 vector<IconMenuItem> _items;
31
32 long _maxVisibleItems;
33 __int64 _firstVisibleItem;
34 __int64 _lastVisibleItem;
35 __int64 _currentItem;
36
37 __int64 _indexOfPressedItem;
38
39 BOOL _isPinnable;
40
41protected:
50 BOOL getCreateWindowOptions(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
51
56
57public:
59 virtual ~IconMenu();
60
64 void clear();
65
70 void setTitle(const wstring& title);
71
72 void setPinnable(BOOL isPinnable);
73
80 long addItem(const wstring& imageFile, const wstring& itemText);
81 long addItem(int imageResourceID, const ImageType& imageType, const wstring& itemText);
82
87 void onPaint(Graphics *g);
88
93
97 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed);
98
102 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed);
103
107 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed);
108
112 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed);
113
117 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed);
118
122 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed);
123
127 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
128 void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
129 void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
130
134 void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
135
140 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
141
147
148public:
149
150 void scrollBarActivity(__int64 firstVisibleItem);
152};
ImageType
Definition Common.h:141
HWND WinHandle
Definition Common.h:16
Definition Common.h:21
Component()
Constructs a new Component instance.
Definition Graphics.h:171
virtual ~IconMenu()
long addItem(const wstring &imageFile, const wstring &itemText)
Adds a new item to the menu.
void addSelectionChangedListener(SelectionChangeListener *l)
Adds a listener to receive selection change events.
void onPaint(Graphics *g)
Paints the menu, drawing visible items with their icons and text.
void setTitle(const wstring &title)
Sets the title displayed at the top of 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 onPageDown(BOOL shiftPressed, BOOL ctrlPressed)
Handles page-down keyboard navigation.
void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed)
Handles keyboard navigation: moves selection up.
void setPinnable(BOOL isPinnable)
void scrollBarRepaint()
BOOL getCreateWindowOptions(wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Sets window creation options specific to the IconMenu.
void onPageUp(BOOL shiftPressed, BOOL ctrlPressed)
Handles page-up keyboard navigation.
void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Handles mouse right-click events, possibly for context menu or other actions.
long addItem(int imageResourceID, const ImageType &imageType, const wstring &itemText)
void windowCreated()
Called once the native window is created; performs initialization.
void clear()
Removes all menu items and clears the menu.
void onWindowResized()
Handles resizing of the menu window, recalculating layout.
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
Handles mouse press events, selecting or interacting with items.
void scrollBarActivity(__int64 firstVisibleItem)
void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed)
Handles keyboard navigation: moves selection down.
void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed)
Handles keyboard Home key navigation: moves selection to first item.
void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed)
Handles keyboard End key navigation: moves selection to last item.
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)
Handles mouse wheel scrolling for scrolling through menu items.
Definition IconMenu.h:7
wstring _imageFile
Definition IconMenu.h:12
Bounds _textRect
Definition IconMenu.h:16
ImageType _imageType
Definition IconMenu.h:11
Bounds _rect
Definition IconMenu.h:14
BOOL _imageIsResourceID
Definition IconMenu.h:9
int _imageResourceID
Definition IconMenu.h:10
Bounds _imageRect
Definition IconMenu.h:15
wstring _text
Definition IconMenu.h:13
Definition Scrollbar.h:14
Definition Scrollbar.h:6
Definition EventListeners.h:31