SavvyUI C++ UI Library
|
Base class for all UI components providing window creation, event handling, and listener management. More...
#include <Component.h>
Public Member Functions | |
Component () | |
Constructs a new Component instance. | |
virtual | ~Component () |
Virtual destructor. | |
long | getId () |
Gets the unique ID assigned to this component. | |
void | setParent (Component *parent) |
Component * | getParent () |
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 | onPaint (Graphics *g) |
Called to paint the component's client area. | |
virtual void | onWindowResized () |
Called when the component's window is resized. | |
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 | onMousePressed (WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed) |
Called when the mouse is pressed within 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 BOOL | onMouseWheel (WinHandle hWnd, int x, int y, int delta) |
Called when the mouse wheel is used over the component. | |
virtual void | onArrowLeft (BOOL shiftPressed, BOOL ctrlPressed) |
virtual void | onArrowRight (BOOL shiftPressed, BOOL ctrlPressed) |
virtual void | onArrowUp (BOOL shiftPressed, BOOL ctrlPressed) |
virtual void | onArrowDown (BOOL shiftPressed, BOOL ctrlPressed) |
virtual void | onPageUp (BOOL shiftPressed, BOOL ctrlPressed) |
virtual void | onPageDown (BOOL shiftPressed, BOOL ctrlPressed) |
virtual void | onKeyHome (BOOL shiftPressed, BOOL ctrlPressed) |
virtual void | onKeyEnd (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. | |
virtual BOOL | getScrollingInfo (__int64 &scrollMin, __int64 &scrollMax, __int64 &pageSize) |
Provides scrolling information if supported. | |
virtual void | setScrollbarTopOffset (__int64 firstVisibleRow) |
Sets the scrollbar's top offset. | |
void | updateScrollbarTopOffset (__int64 firstVisibleRow) |
Updates the scrollbar's top offset based on the current first visible row. |
Protected Member Functions | |
virtual BOOL | getCreateWindowOptions (wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)=0 |
Abstract method to get window creation options. | |
virtual void | windowCreated ()=0 |
Abstract method called after the window has been created. | |
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. |
Protected Attributes | |
WinHandle | _hWnd |
Handle to the native window associated with this component. | |
wstring | _componentType |
String representing the component type (e.g., "Button", "ComboBox"). | |
BOOL | _showBorder |
Base class for all UI components providing window creation, event handling, and listener management.
This abstract class provides common functionality for windowed components, including:
Derived classes must implement getCreateWindowOptions() and windowCreated() to specify window creation details and initialization logic.
Component::Component | ( | ) |
Constructs a new Component instance.
|
virtual |
Virtual destructor.
void Component::clearQueuedPaintRequest | ( | ) |
clears the queued paint request. This function should only be called internally from the library.
int Component::createComponent | ( | WinHandle | hParent, |
Bounds | rect, | ||
long | nCmd = -1, | ||
BOOL | isVisible = TRUE ) |
Creates the component's native window as a child of hParent.
hParent | Parent window handle. |
rect | Initial window rectangle. |
nCmd | Optional command ID associated with the component. |
isVisible | TRUE to show the window immediately. |
|
protected |
Marks this component's native window to avoid subclassing.
|
protected |
Returns the component's action command ID.
void Component::GetClientRect | ( | Bounds & | rect | ) |
wstring Component::getComponentType | ( | ) |
Gets the component type string.
|
protectedpure virtual |
Abstract method to get window creation options.
Derived classes must override this to provide window title, styles, class name, and whether a custom window procedure is used.
title | Output window title. |
widownStyles | Output window styles. |
wndClassName | Output window class name. |
isCustomWndProc | Output TRUE if a custom window procedure is used. |
Implemented in Accordion, Button, ButtonGrid, ButtonMenu, Calendar, CardPanel, Chart, ChartLegend, CheckBox, CheckComboBox, CheckList, ComboBox, DateTimePicker, Dialog, Frame, Grid, GridView, IconMenu, Image, Label, ListBox, MaskedField, PanelBase, PickList, ProgressBar, Radio, Rating, Slider, Switch, TabPane, TextArea, TextField, ToggleButton, Toolbar, ToolTip, and TreeView.
long Component::getId | ( | ) |
Gets the unique ID assigned to this component.
|
virtual |
Returns the minimum height the component can have.
int Component::getMouseWheelDelta | ( | ) |
Gets the current mouse wheel delta.
Component * Component::getParent | ( | ) |
|
virtual |
Returns the preferred height of the component.
Reimplemented in CheckBox, CheckComboBox, ComboBox, DateTimePicker, MaskedField, ProgressBar, Rating, Slider, Switch, TextArea, TextField, and ToggleButton.
|
inlinevirtual |
Provides scrolling information if supported.
scrollMin | Output minimum scroll value. |
scrollMax | Output maximum scroll value. |
pageSize | Output page size. |
Reimplemented in ButtonGrid, ButtonMenu, CheckList, FluidPanel, Grid, GridPanel, IconMenu, ListBox, Radio, and TreeView.
WinHandle Component::getWindowHandle | ( | ) |
Returns the native WinHandle for this component.
void Component::GetWindowRect | ( | Bounds & | rect | ) |
BOOL Component::isWindowCreated | ( | ) |
Returns whether the native window has been created.
void Component::moveWindow | ( | long | x, |
long | y, | ||
long | width, | ||
long | height, | ||
BOOL | bRedraw = TRUE ) |
Moves and resizes the component window.
x | New X coordinate. |
y | New Y coordinate. |
width | New width. |
height | New height. |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in ButtonGrid, ButtonMenu, CheckList, Grid, IconMenu, ListBox, Radio, and TreeView.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in ButtonGrid, ButtonMenu, CheckList, Grid, IconMenu, ListBox, Radio, and TreeView.
|
inlinevirtual |
|
inlinevirtual |
Called when drawing an item for owner-draw controls.
dis | Pointer to DRAWITEMSTRUCT. |
procParams | Additional parameters. |
Reimplemented in PanelBase.
|
inlinevirtual |
Called when measuring an item for owner-draw controls.
dis | Pointer to MEASUREITEMSTRUCT. |
procParams | Additional parameters. |
Reimplemented in PanelBase.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Called on horizontal scroll events.
hTarget | Handle to the target window. |
procParams | Additional parameters. |
Reimplemented in PanelBase.
|
inlinevirtual |
Reimplemented in Calendar.
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in ButtonGrid, ButtonMenu, CheckList, Grid, IconMenu, ListBox, Radio, and TreeView.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in ButtonGrid, ButtonMenu, CheckList, Grid, IconMenu, ListBox, Radio, and TreeView.
|
inlinevirtual |
|
inlinevirtual |
Reimplemented in Grid.
|
inlinevirtual |
Reimplemented in Calendar.
|
inlinevirtual |
Called when the mouse is moved within the component.
Reimplemented in Button, ButtonMenu, Rating, and Slider.
|
inlinevirtual |
Called when the mouse is pressed within the component.
Reimplemented in Button, ButtonGrid, ButtonMenu, Calendar, CheckBox, CheckComboBox, CheckList, DateTimePicker, Grid, IconMenu, ListBox, Radio, Rating, Slider, Switch, TabPane, ToggleButton, Toolbar, ToolTip, and TreeView.
|
inlinevirtual |
Called when the mouse button is released within the component.
Reimplemented in Button, ButtonGrid, ButtonMenu, IconMenu, Slider, and Toolbar.
|
inlinevirtual |
Called when the right mouse button is clicked within the component.
Reimplemented in ButtonGrid, ButtonMenu, IconMenu, and TreeView.
|
inlinevirtual |
Called when the mouse wheel is used over the component.
hWnd | Handle to the window receiving the event. |
x | X coordinate of the mouse. |
y | Y coordinate of the mouse. |
delta | Mouse wheel delta. |
Reimplemented in ButtonGrid, ButtonMenu, Calendar, CheckList, FluidPanel, Grid, GridPanel, IconMenu, ListBox, Radio, Toolbar, and TreeView.
|
inlinevirtual |
Reimplemented in ButtonGrid, ButtonMenu, CheckList, Grid, IconMenu, ListBox, Radio, and TreeView.
|
inlinevirtual |
Reimplemented in ButtonGrid, ButtonMenu, CheckList, Grid, IconMenu, ListBox, Radio, and TreeView.
|
inlinevirtual |
Called to paint the component's client area.
Reimplemented in Accordion, Button, ButtonGrid, ButtonMenu, Calendar, CardPanel, Chart, CheckBox, CheckComboBox, CheckList, DateTimePicker, FluidPanel, Grid, GridPanel, GridView, IconMenu, Image, Label, ListBox, PickList, ProgressBar, Radio, Rating, Slider, Switch, TabPane, ToggleButton, Toolbar, ToolTip, and TreeView.
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Called when the component's window is moved.
Reimplemented in CardPanel, CheckComboBox, DateTimePicker, Dialog, Frame, and PanelBase.
|
inlinevirtual |
Called when the component's window is resized.
Reimplemented in Accordion, ButtonGrid, ButtonMenu, Calendar, CardPanel, Chart, ChartLegend, CheckBox, CheckComboBox, CheckList, DateTimePicker, FluidPanel, Frame, Grid, GridPanel, GridView, IconMenu, Label, ListBox, PickList, ProgressBar, Radio, Slider, Switch, TabPane, Toolbar, ToolTip, and TreeView.
|
protected |
Adds an action listener.
l | Pointer to an ActionListener instance. |
|
protected |
Adds a data change listener.
l | Pointer to a DataChangeListener instance. |
|
protected |
Adds a row double-click listener.
l | Pointer to a RowDoubleClickListener instance. |
|
protected |
Adds a selection change listener.
l | Pointer to a SelectionChangeListener instance. |
|
protected |
Fires an action event to registered listeners.
actionId | Action identifier. |
actionName | Name of the action. |
|
protected |
Fires a data changed event to registered listeners.
oldValue | Previous data value. |
newValue | New data value. |
|
protected |
Fires a row double-click event to registered listeners.
rowIndex | Index of the double-clicked row. |
|
protected |
Fires a selection changed event to registered listeners.
selectionIndex | Index of the new selection. |
selectionValue | Text of the new selection. |
checked | Checked state (for multi-select). |
void Component::reconfigureScrollBar | ( | ) |
Forces the component to recalculate the scrollbar info.
void Component::repaint | ( | WinHandle | hWnd = NULL | ) |
Requests the component to repaint itself.
void Component::setEnabled | ( | BOOL | bEnable = TRUE | ) |
Enables or disables the component.
bEnable | TRUE to enable, FALSE to disable. |
void Component::setFont | ( | long | fontSize, |
BOOL | isBold = FALSE, | ||
BOOL | isItalic = FALSE, | ||
BOOL | isUnderlined = FALSE, | ||
const wstring & | fontName = L"Arial" ) |
Sets the font for the component.
fontSize | Font size in points. |
isBold | TRUE to make font bold. |
isItalic | TRUE to make font italic. |
isUnderlined | TRUE to underline the font. |
fontName | Name of the font family. |
void Component::setMouseWheelDelta | ( | int | delta | ) |
Sets the accumulated mouse wheel delta.
delta | Mouse wheel delta value. |
void Component::setParent | ( | Component * | parent | ) |
|
inlinevirtual |
Sets the scrollbar's top offset.
firstVisibleRow | The first visible row index. |
Reimplemented in ButtonGrid, ButtonMenu, CheckList, FluidPanel, Grid, GridPanel, IconMenu, ListBox, Radio, and TreeView.
void Component::setVisible | ( | BOOL | bShow = TRUE | ) |
Shows or hides the component.
bShow | TRUE to show, FALSE to hide. |
void Component::showBorder | ( | BOOL | bShow = TRUE | ) |
|
protected |
Starts a timer with the given ID and interval.
timerId | Identifier for the timer. |
milliseconds | Timer interval in milliseconds. |
|
protected |
Stops the timer identified by timerId.
timerId | Identifier of the timer to stop. |
void Component::updateScrollbarTopOffset | ( | __int64 | firstVisibleRow | ) |
Updates the scrollbar's top offset based on the current first visible row.
Should be called by components displaying scrollbars.
firstVisibleRow | The first visible row index. |
|
protectedpure virtual |
Abstract method called after the window has been created.
Used to perform any initialization that requires a valid window handle.
Implemented in Accordion, Button, ButtonGrid, ButtonMenu, Calendar, CardPanel, Chart, ChartLegend, CheckBox, CheckComboBox, CheckList, ComboBox, DateTimePicker, Dialog, FluidPanel, Frame, Grid, GridPanel, GridView, IconMenu, Image, Label, ListBox, MaskedField, PickList, ProgressBar, Radio, Rating, Slider, Switch, TabPane, TextArea, TextField, ToggleButton, Toolbar, ToolTip, and TreeView.
|
protected |
String representing the component type (e.g., "Button", "ComboBox").
|
protected |
Handle to the native window associated with this component.
|
protected |