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

A UI component that displays a list of checkable items. More...

#include <CheckList.h>

Inheritance diagram for CheckList:
Component

Public Member Functions

 CheckList ()
 Constructs a new CheckList instance.
virtual ~CheckList ()
 Destroys the CheckList instance.
void setAsPopup (BOOL isPopup)
 Sets whether the checklist is used in a popup context.
BOOL isPopup ()
 Return TRUE if this component is displayed as a popup (e.g. dropdown from CheckComboBox).
void setOptions (const vector< KeyValue > &selections)
 Sets the available options to be shown in the checklist.
void getOptions (vector< KeyValue > &selections)
void setSelectedItems (const vector< KeyValue > &selections)
 Sets which items are selected based on key-value input.
vector< KeyValuegetSelectedItems ()
 Returns the currently selected items in the checklist.
void onPaint (Graphics *g) override
 Called to paint the component's client area.
void onWindowResized () override
 Called when the component's window is resized.
void onArrowUp (BOOL shiftPressed, BOOL ctrlPressed) override
void onArrowDown (BOOL shiftPressed, BOOL ctrlPressed) override
void onPageUp (BOOL shiftPressed, BOOL ctrlPressed) override
void onPageDown (BOOL shiftPressed, BOOL ctrlPressed) override
void onKeyHome (BOOL shiftPressed, BOOL ctrlPressed) override
void onKeyEnd (BOOL shiftPressed, BOOL ctrlPressed) override
void onMousePressed (WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed) override
 Called when the mouse is pressed within the component.
BOOL onMouseWheel (WinHandle hWnd, int x, int y, int delta) override
 Called when the mouse wheel is used over the component.
void onFocusGained () override
 Called when the component gains keyboard focus.
void onFocusLost () override
 Called when the component loses keyboard focus.
BOOL getScrollingInfo (__int64 &scrollMin, __int64 &scrollMax, __int64 &pageSize) override
 Provides scrolling information if supported.
void setScrollbarTopOffset (__int64 firstVisibleRow) override
 Sets the scrollbar's top offset.
void onSelectionChanged (WinHandle hWndCB, int itemIndex, const wstring &itemText, BOOL itemChecked)
 Notifies the checklist of a selection state change for an item.
void addSelectionChangedListener (SelectionChangeListener *l)
 Adds a listener to be notified when item selection changes.
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 ()
ComponentgetTopLevelParent ()
void bringWindowToTop ()
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 (Component *parent, Bounds rect, long nCmd=-1, BOOL isVisible=TRUE)
 Creates the component's native window as a child of hParent.
void setFocus ()
void setFont (long fontSize, BOOL isBold=FALSE, BOOL isItalic=FALSE, BOOL isUnderlined=FALSE, const wstring &fontName=L"Arial")
 Sets the font for the component.
BOOL getCustomFont (long &fontSize, BOOL &isBold, BOOL &isItalic, BOOL &isUnderlined, wstring &fontName)
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 (Component *comp=NULL, BOOL repaintImmediately=FALSE)
 Requests the component to repaint itself.
void clearQueuedPaintRequest ()
 clears the queued paint request. This function should only be called internally from the library.
virtual BOOL getChildren (vector< Component * > &children)
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 void onMouseReleased (WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
 Called when the mouse button is released within the component.
virtual void onMouseRightClicked (WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
 Called when the right mouse button is clicked within the component.
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 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)
 Retrieves the options for creating the checklist window.
void windowCreated ()
 Called after the checklist window is created.
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 UI component that displays a list of checkable items.

CheckList allows for multi-selection using checkboxes. It can operate as a standalone list or be embedded in popup-based components like CheckComboBox.

Constructor & Destructor Documentation

◆ CheckList()

CheckList::CheckList ( )

Constructs a new CheckList instance.

◆ ~CheckList()

virtual CheckList::~CheckList ( )
virtual

Destroys the CheckList instance.

Member Function Documentation

◆ addSelectionChangedListener()

void CheckList::addSelectionChangedListener ( SelectionChangeListener * l)

Adds a listener to be notified when item selection changes.

Parameters
lPointer to a SelectionChangeListener instance.

◆ getCreateWindowOptions()

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

Retrieves the options for creating the checklist window.

Parameters
titleOutput: window title.
widownStylesOutput: window style flags.
wndClassNameOutput: window class name.
isCustomWndProcOutput: whether a custom window procedure is used.
Returns
TRUE if the options were successfully retrieved, FALSE otherwise.

Implements Component.

◆ getOptions()

void CheckList::getOptions ( vector< KeyValue > & selections)

◆ getScrollingInfo()

BOOL CheckList::getScrollingInfo ( __int64 & scrollMin,
__int64 & scrollMax,
__int64 & pageSize )
overridevirtual

Provides scrolling information if supported.

Parameters
scrollMinOutput minimum scroll value.
scrollMaxOutput maximum scroll value.
pageSizeOutput page size.
Returns
TRUE if scrollbar is applicable and info is provided, FALSE otherwise.

Reimplemented from Component.

◆ getSelectedItems()

vector< KeyValue > CheckList::getSelectedItems ( )

Returns the currently selected items in the checklist.

Returns
A vector of selected key-value pairs.

◆ isPopup()

BOOL CheckList::isPopup ( )

Return TRUE if this component is displayed as a popup (e.g. dropdown from CheckComboBox).

◆ onArrowDown()

void CheckList::onArrowDown ( BOOL shiftPressed,
BOOL ctrlPressed )
overridevirtual

Reimplemented from Component.

◆ onArrowUp()

void CheckList::onArrowUp ( BOOL shiftPressed,
BOOL ctrlPressed )
overridevirtual

Reimplemented from Component.

◆ onFocusGained()

void CheckList::onFocusGained ( )
overridevirtual

Called when the component gains keyboard focus.

Reimplemented from Component.

◆ onFocusLost()

void CheckList::onFocusLost ( )
overridevirtual

Called when the component loses keyboard focus.

Reimplemented from Component.

◆ onKeyEnd()

void CheckList::onKeyEnd ( BOOL shiftPressed,
BOOL ctrlPressed )
overridevirtual

Reimplemented from Component.

◆ onKeyHome()

void CheckList::onKeyHome ( BOOL shiftPressed,
BOOL ctrlPressed )
overridevirtual

Reimplemented from Component.

◆ onMousePressed()

void CheckList::onMousePressed ( WinHandle hWnd,
int x,
int y,
int clickCount,
BOOL shiftPressed,
BOOL ctrlPressed )
overridevirtual

Called when the mouse is pressed within the component.

Reimplemented from Component.

◆ onMouseWheel()

BOOL CheckList::onMouseWheel ( WinHandle hWnd,
int x,
int y,
int delta )
overridevirtual

Called when the mouse wheel is used over the component.

Parameters
hWndHandle to the window receiving the event.
xX coordinate of the mouse.
yY coordinate of the mouse.
deltaMouse wheel delta.
Returns
TRUE if the event was handled, FALSE otherwise.

Reimplemented from Component.

◆ onPageDown()

void CheckList::onPageDown ( BOOL shiftPressed,
BOOL ctrlPressed )
overridevirtual

Reimplemented from Component.

◆ onPageUp()

void CheckList::onPageUp ( BOOL shiftPressed,
BOOL ctrlPressed )
overridevirtual

Reimplemented from Component.

◆ onPaint()

void CheckList::onPaint ( Graphics * g)
overridevirtual

Called to paint the component's client area.

Reimplemented from Component.

◆ onSelectionChanged()

void CheckList::onSelectionChanged ( WinHandle hWndCB,
int itemIndex,
const wstring & itemText,
BOOL itemChecked )

Notifies the checklist of a selection state change for an item.

Parameters
hWndCBHandle to the parent combo box or caller.
itemIndexIndex of the item that changed.
itemTextText of the changed item.
itemCheckedWhether the item is now checked.

◆ onWindowResized()

void CheckList::onWindowResized ( )
overridevirtual

Called when the component's window is resized.

Reimplemented from Component.

◆ setAsPopup()

void CheckList::setAsPopup ( BOOL isPopup)

Sets whether the checklist is used in a popup context.

Parameters
isPopupTRUE to mark the checklist as a popup, FALSE otherwise.

◆ setOptions()

void CheckList::setOptions ( const vector< KeyValue > & selections)

Sets the available options to be shown in the checklist.

Parameters
selectionsA list of key-value pairs representing checklist items.

◆ setScrollbarTopOffset()

void CheckList::setScrollbarTopOffset ( __int64 firstVisibleRow)
overridevirtual

Sets the scrollbar's top offset.

Parameters
firstVisibleRowThe first visible row index.

Reimplemented from Component.

◆ setSelectedItems()

void CheckList::setSelectedItems ( const vector< KeyValue > & selections)

Sets which items are selected based on key-value input.

Parameters
selectionsList of selected key-value items.

◆ windowCreated()

void CheckList::windowCreated ( )
protectedvirtual

Called after the checklist window is created.

Implements Component.


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