SavvyUI C++ UI Library
Loading...
Searching...
No Matches
IconMenu Class Reference

A menu component that displays a list of items, each with an icon and text. More...

#include <IconMenu.h>

Inheritance diagram for IconMenu:
Component

Public Member Functions

 IconMenu ()
virtual ~IconMenu ()
void clear ()
 Removes all menu items and clears the menu.
void setTitle (const wstring &title)
 Sets the title displayed at the top of the menu.
void setPinnable (BOOL isPinnable)
long addItem (const wstring &imageFile, const wstring &itemText)
 Adds a new item to the menu.
long addItem (int imageResourceID, const ImageType &imageType, const wstring &itemText)
void onPaint (Graphics *g)
 Paints the menu, drawing visible items with their icons and text.
void onWindowResized ()
 Handles resizing of the menu window, recalculating layout.
void onArrowUp (BOOL shiftPressed, BOOL ctrlPressed)
 Handles keyboard navigation: moves selection up.
void onArrowDown (BOOL shiftPressed, BOOL ctrlPressed)
 Handles keyboard navigation: moves selection down.
void onPageUp (BOOL shiftPressed, BOOL ctrlPressed)
 Handles page-up keyboard navigation.
void onPageDown (BOOL shiftPressed, BOOL ctrlPressed)
 Handles page-down keyboard navigation.
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 onMousePressed (WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
 Handles mouse press events, selecting or interacting with items.
void onMouseReleased (WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
 Called when the mouse button is released within the component.
void onMouseRightClicked (WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
 Handles mouse right-click events, possibly for context menu or other actions.
BOOL onMouseWheel (WinHandle hWnd, int x, int y, int delta)
 Handles mouse wheel scrolling for scrolling through menu items.
BOOL getScrollingInfo (__int64 &scrollMin, __int64 &scrollMax, __int64 &pageSize)
 Retrieves scroll bar information for scrolling through items.
void setScrollbarTopOffset (__int64 firstVisibleRow)
 Sets the scrollbar's top offset (first visible item).
void addSelectionChangedListener (SelectionChangeListener *l)
 Adds a listener to receive selection change events.
Public Member Functions inherited from Component
 Component ()
 Constructs a new Component instance.
virtual ~Component ()
 Virtual destructor.
long getId ()
 Gets the unique ID assigned to this component.
void setParent (Component *parent)
ComponentgetParent ()
wstring getComponentType ()
 Gets the component type string.
BOOL isWindowCreated ()
 Returns whether the native window has been created.
WinHandle getWindowHandle ()
 Returns the native WinHandle for this component.
int createComponent (WinHandle hParent, Bounds rect, long nCmd=-1, BOOL isVisible=TRUE)
 Creates the component's native window as a child of hParent.
void setFont (long fontSize, BOOL isBold=FALSE, BOOL isItalic=FALSE, BOOL isUnderlined=FALSE, const wstring &fontName=L"Arial")
 Sets the font for the component.
void showBorder (BOOL bShow=TRUE)
void setEnabled (BOOL bEnable=TRUE)
 Enables or disables the component.
void setVisible (BOOL bShow=TRUE)
 Shows or hides the component.
void GetClientRect (Bounds &rect)
void GetWindowRect (Bounds &rect)
void moveWindow (long x, long y, long width, long height, BOOL bRedraw=TRUE)
 Moves and resizes the component window.
void reconfigureScrollBar ()
 Forces the component to recalculate the scrollbar info.
void setMouseWheelDelta (int delta)
 Sets the accumulated mouse wheel delta.
int getMouseWheelDelta ()
 Gets the current mouse wheel delta.
virtual int getMinimumHeight ()
 Returns the minimum height the component can have.
virtual int getPreferredHeight ()
 Returns the preferred height of the component.
void repaint (WinHandle hWnd=NULL)
 Requests the component to repaint itself.
void clearQueuedPaintRequest ()
 clears the queued paint request. This function should only be called internally from the library.
virtual void onWindowMoved ()
 Called when the component's window is moved.
virtual void onAction (WinHandle hTarget, long actionId, const ProcParams &procParams)
 Called when an action occurs on the component.
virtual void onSelectionChanged (WinHandle hTarget, int itemIndex, const wstring &itemText, BOOL itemChecked, const ProcParams &procParams)
 Called when the selection changes.
virtual void onDataChanged (WinHandle hTarget, const wstring &newValue, const ProcParams &procParams)
 Called when data changes in the component.
virtual BOOL onHorzScroll (WinHandle hTarget, const ProcParams &procParams)
 Called on horizontal scroll events.
virtual BOOL onDrawMeasureItem (LPMEASUREITEMSTRUCT dis, const ProcParams &procParams)
 Called when measuring an item for owner-draw controls.
virtual BOOL onDrawItem (LPDRAWITEMSTRUCT dis, const ProcParams &procParams)
 Called when drawing an item for owner-draw controls.
virtual void onMouseMoved (WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
 Called when the mouse is moved within the component.
virtual void onArrowLeft (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onArrowRight (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyInsert (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyDelete (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyBackSpace (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyTyped (wchar_t ch, BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyTab (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyEnter (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF1 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF2 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF3 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF4 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF5 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF6 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF7 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF8 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF9 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF10 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF11 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onKeyF12 (BOOL shiftPressed, BOOL ctrlPressed)
virtual void onFocusGained ()
 Called when the component gains keyboard focus.
virtual void onFocusLost ()
 Called when the component loses keyboard focus.
virtual void onTimer (unsigned int timerId)
 Called on timer events.
void updateScrollbarTopOffset (__int64 firstVisibleRow)
 Updates the scrollbar's top offset based on the current first visible row.

Protected Member Functions

BOOL getCreateWindowOptions (wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
 Sets window creation options specific to the IconMenu.
void windowCreated ()
 Called once the native window is created; performs initialization.
Protected Member Functions inherited from Component
long getActionId ()
 Returns the component's action command ID.
void doNotSubclass ()
 Marks this component's native window to avoid subclassing.
void startTimer (unsigned int timerId, unsigned int milliseconds)
 Starts a timer with the given ID and interval.
void stopTimer (unsigned int timerId)
 Stops the timer identified by timerId.
void protectedAddDataChangedListener (DataChangeListener *l)
 Adds a data change listener.
void protectedAddSelectionChangedListener (SelectionChangeListener *l)
 Adds a selection change listener.
void protectedAddActionListener (ActionListener *l)
 Adds an action listener.
void protectedAddItemDoubleClickedListener (RowDoubleClickListener *l)
 Adds a row double-click listener.
void protectedFireDataChangedEvent (const wstring &oldValue, const wstring &newValue)
 Fires a data changed event to registered listeners.
void protectedFireSelectionChangedEvent (long selectionIndex=-1, const wstring &selectionValue=L"", BOOL checked=FALSE)
 Fires a selection changed event to registered listeners.
void protectedFireActionEvent (long actionId=-1, const wstring &actionName=L"")
 Fires an action event to registered listeners.
void protectedFireItemDoubleClickedEvent (__int64 rowIndex)
 Fires a row double-click event to registered listeners.

Additional Inherited Members

Protected Attributes inherited from Component
WinHandle _hWnd
 Handle to the native window associated with this component.
wstring _componentType
 String representing the component type (e.g., "Button", "ComboBox").
BOOL _showBorder

Detailed Description

A menu component that displays a list of items, each with an icon and text.

Supports scrolling, keyboard navigation, and mouse interaction.

Constructor & Destructor Documentation

◆ IconMenu()

IconMenu::IconMenu ( )

◆ ~IconMenu()

virtual IconMenu::~IconMenu ( )
virtual

Member Function Documentation

◆ addItem() [1/2]

long IconMenu::addItem ( const wstring & imageFile,
const wstring & itemText )

Adds a new item to the menu.

Parameters
imageFilePath to the icon image file for the item.
itemTextText label for the item.
Returns
The index of the newly added item.

◆ addItem() [2/2]

long IconMenu::addItem ( int imageResourceID,
const ImageType & imageType,
const wstring & itemText )

◆ addSelectionChangedListener()

void IconMenu::addSelectionChangedListener ( SelectionChangeListener * l)

Adds a listener to receive selection change events.

Parameters
lPointer to a SelectionChangeListener.

◆ clear()

void IconMenu::clear ( )

Removes all menu items and clears the menu.

◆ getCreateWindowOptions()

BOOL IconMenu::getCreateWindowOptions ( wstring & title,
UINT & widownStyles,
wstring & wndClassName,
BOOL & isCustomWndProc )
protectedvirtual

Sets window creation options specific to the IconMenu.

Parameters
titleOutput parameter to receive window title.
widownStylesOutput parameter to receive window styles.
wndClassNameOutput parameter to receive window class name.
isCustomWndProcOutput parameter indicating if a custom window procedure is used.
Returns
TRUE if options are successfully set.

Implements Component.

◆ getScrollingInfo()

BOOL IconMenu::getScrollingInfo ( __int64 & scrollMin,
__int64 & scrollMax,
__int64 & pageSize )
virtual

Retrieves scroll bar information for scrolling through items.

Parameters
scrollMinOutput minimum scroll value.
scrollMaxOutput maximum scroll value.
pageSizeOutput visible page size.
Returns
TRUE if scroll info was successfully retrieved.

Reimplemented from Component.

◆ onArrowDown()

void IconMenu::onArrowDown ( BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Handles keyboard navigation: moves selection down.

Reimplemented from Component.

◆ onArrowUp()

void IconMenu::onArrowUp ( BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Handles keyboard navigation: moves selection up.

Reimplemented from Component.

◆ onKeyEnd()

void IconMenu::onKeyEnd ( BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Handles keyboard End key navigation: moves selection to last item.

Reimplemented from Component.

◆ onKeyHome()

void IconMenu::onKeyHome ( BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Handles keyboard Home key navigation: moves selection to first item.

Reimplemented from Component.

◆ onMousePressed()

void IconMenu::onMousePressed ( WinHandle hWnd,
int x,
int y,
int clickCount,
BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Handles mouse press events, selecting or interacting with items.

Reimplemented from Component.

◆ onMouseReleased()

void IconMenu::onMouseReleased ( WinHandle hWnd,
int x,
int y,
BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Called when the mouse button is released within the component.

Reimplemented from Component.

◆ onMouseRightClicked()

void IconMenu::onMouseRightClicked ( WinHandle hWnd,
int x,
int y,
BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Handles mouse right-click events, possibly for context menu or other actions.

Reimplemented from Component.

◆ onMouseWheel()

BOOL IconMenu::onMouseWheel ( WinHandle hWnd,
int x,
int y,
int delta )
virtual

Handles mouse wheel scrolling for scrolling through menu items.

Returns
TRUE if the event was handled, FALSE otherwise.

Reimplemented from Component.

◆ onPageDown()

void IconMenu::onPageDown ( BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Handles page-down keyboard navigation.

Reimplemented from Component.

◆ onPageUp()

void IconMenu::onPageUp ( BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Handles page-up keyboard navigation.

Reimplemented from Component.

◆ onPaint()

void IconMenu::onPaint ( Graphics * g)
virtual

Paints the menu, drawing visible items with their icons and text.

Parameters
hDCHandle to the device context.

Reimplemented from Component.

◆ onWindowResized()

void IconMenu::onWindowResized ( )
virtual

Handles resizing of the menu window, recalculating layout.

Reimplemented from Component.

◆ setPinnable()

void IconMenu::setPinnable ( BOOL isPinnable)

◆ setScrollbarTopOffset()

void IconMenu::setScrollbarTopOffset ( __int64 firstVisibleRow)
virtual

Sets the scrollbar's top offset (first visible item).

Reimplemented from Component.

◆ setTitle()

void IconMenu::setTitle ( const wstring & title)

Sets the title displayed at the top of the menu.

Parameters
titleThe title string.

◆ windowCreated()

void IconMenu::windowCreated ( )
protectedvirtual

Called once the native window is created; performs initialization.

Implements Component.


The documentation for this class was generated from the following file: