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

TreeView component for displaying hierarchical data with expandable nodes. More...

#include <TreeView.h>

Inheritance diagram for TreeView:
Component

Public Member Functions

 TreeView ()
 Constructs a new TreeView object.
virtual ~TreeView ()
 Destructor.
void clear ()
 Clears all items from the TreeView.
void setTitle (const wstring &title)
 Sets the title of the TreeView.
long addItem (const wstring &itemText, const wstring &itemId=L"", const wstring &parentId=L"", const wstring &nodeType=L"")
 Adds a new item to the TreeView.
long getItemCount ()
 Gets the total count of items in the TreeView.
long getSelectedItem ()
 Gets the index of the currently selected item.
void addContextMenuItem (long actionId, const wstring &text, const wstring &nodeType=L"")
 Adds an item to the context menu.
BOOL getScrollingInfo (__int64 &scrollMin, __int64 &scrollMax, __int64 &pageSize)
 Provides information for scrollbar rendering.
void setScrollbarTopOffset (__int64 firstVisibleRow)
 Sets the scroll position based on the top visible row index.
void addActionListener (ActionListener *l)
 Adds an action listener to respond to user interactions.
void addSelectionChangedListener (SelectionChangeListener *l)
 Adds a listener for selection changes.
Event handlers
void onPaint (Graphics *g)
 Called to paint the component's client area.
void onWindowResized ()
 Called when the component's window is resized.
void onArrowUp (BOOL shiftPressed, BOOL ctrlPressed)
void onArrowDown (BOOL shiftPressed, BOOL ctrlPressed)
void onPageUp (BOOL shiftPressed, BOOL ctrlPressed)
void onPageDown (BOOL shiftPressed, BOOL ctrlPressed)
void onKeyHome (BOOL shiftPressed, BOOL ctrlPressed)
void onKeyEnd (BOOL shiftPressed, BOOL ctrlPressed)
void onMousePressed (WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
 Called when the mouse is pressed within the component.
void onMouseRightClicked (WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
 Called when the right mouse button is clicked within the component.
BOOL onMouseWheel (WinHandle hWnd, int x, int y, int delta)
 Called when the mouse wheel is used over the component.
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 onMouseReleased (WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
 Called when the mouse button is released 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 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)
 Abstract method to get window creation options.
void windowCreated ()
 Abstract method called after the window has been 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

TreeView component for displaying hierarchical data with expandable nodes.

Constructor & Destructor Documentation

◆ TreeView()

TreeView::TreeView ( )

Constructs a new TreeView object.

◆ ~TreeView()

virtual TreeView::~TreeView ( )
virtual

Destructor.

Member Function Documentation

◆ addActionListener()

void TreeView::addActionListener ( ActionListener * l)

Adds an action listener to respond to user interactions.

Parameters
lPointer to the ActionListener.

◆ addContextMenuItem()

void TreeView::addContextMenuItem ( long actionId,
const wstring & text,
const wstring & nodeType = L"" )

Adds an item to the context menu.

Parameters
actionIdAction identifier for the menu item.
textDisplay text of the menu item.
nodeTypeNode type this menu item applies to (optional).

◆ addItem()

long TreeView::addItem ( const wstring & itemText,
const wstring & itemId = L"",
const wstring & parentId = L"",
const wstring & nodeType = L"" )

Adds a new item to the TreeView.

Parameters
itemTextThe text for the new item.
itemIdThe unique ID for the new item (optional).
parentIdThe ID of the parent item (optional).
nodeTypeThe node type for the item (optional).
Returns
The index of the newly added item.

◆ addSelectionChangedListener()

void TreeView::addSelectionChangedListener ( SelectionChangeListener * l)

Adds a listener for selection changes.

Parameters
lPointer to the SelectionChangeListener.

◆ clear()

void TreeView::clear ( )

Clears all items from the TreeView.

◆ getCreateWindowOptions()

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

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.

Parameters
titleOutput window title.
widownStylesOutput window styles.
wndClassNameOutput window class name.
isCustomWndProcOutput TRUE if a custom window procedure is used.
Returns
TRUE if options were set successfully.

Implements Component.

◆ getItemCount()

long TreeView::getItemCount ( )

Gets the total count of items in the TreeView.

Returns
Number of items.

◆ getScrollingInfo()

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

Provides information for scrollbar rendering.

Parameters
scrollMinReference to minimum scroll position.
scrollMaxReference to maximum scroll position.
pageSizeReference to page size for scrolling.
Returns
TRUE if successful.

Reimplemented from Component.

◆ getSelectedItem()

long TreeView::getSelectedItem ( )

Gets the index of the currently selected item.

Returns
Selected item index.

◆ onArrowDown()

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

Reimplemented from Component.

◆ onArrowUp()

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

Reimplemented from Component.

◆ onKeyEnd()

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

Reimplemented from Component.

◆ onKeyHome()

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

Reimplemented from Component.

◆ onMousePressed()

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

Called when the mouse is pressed within the component.

Reimplemented from Component.

◆ onMouseRightClicked()

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

Called when the right mouse button is clicked within the component.

Reimplemented from Component.

◆ onMouseWheel()

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

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 TreeView::onPageDown ( BOOL shiftPressed,
BOOL ctrlPressed )
virtual

Reimplemented from Component.

◆ onPageUp()

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

Reimplemented from Component.

◆ onPaint()

void TreeView::onPaint ( Graphics * g)
virtual

Called to paint the component's client area.

Reimplemented from Component.

◆ onWindowResized()

void TreeView::onWindowResized ( )
virtual

Called when the component's window is resized.

Reimplemented from Component.

◆ setScrollbarTopOffset()

void TreeView::setScrollbarTopOffset ( __int64 firstVisibleRow)
virtual

Sets the scroll position based on the top visible row index.

Parameters
firstVisibleRowThe index of the first visible row.

Reimplemented from Component.

◆ setTitle()

void TreeView::setTitle ( const wstring & title)

Sets the title of the TreeView.

Parameters
titleThe new title text.

◆ windowCreated()

void TreeView::windowCreated ( )
protectedvirtual

Abstract method called after the window has been created.

Used to perform any initialization that requires a valid window handle.

Implements Component.


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