SavvyUI C++ UI Library
Loading...
Searching...
No Matches
TreeView.h
Go to the documentation of this file.
1#pragma once
2
3#include "Component.h"
4#include "PopupMenu.h"
5
20
22{
23public:
24 wstring _nodeType;
25};
26
30class TreeView : public Component
31{
32 wstring _title;
33 vector<TreeViewItem> _allItems;
34 vector<TreeViewItem> _visibleItems;
35
36 vector<TreeViewMenuItem> _contextMenuItems;
37
38 long _maxVisibleItems;
39 long _firstVisibleItem;
40 long _lastVisibleItem;
41 long _currentItem;
42
46 void ReloadVisibleItems();
47
48protected:
49 BOOL getCreateWindowOptions(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
51
52public:
57
61 virtual ~TreeView();
62
66 void clear();
67
72 void setTitle(const wstring& title);
73
82 long addItem(const wstring& itemText, const wstring& itemId = L"", const wstring& parentId = L"", const wstring& nodeType = L"");
83
89
95
102 void addContextMenuItem(long actionId, const wstring& text, const wstring& nodeType = L"");
103
108
109 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed);
110 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed);
111 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed);
112 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed);
113 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed);
114 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed);
115
116 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
117 void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
118 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
120
128 BOOL getScrollingInfo(__int64& scrollMin, __int64& scrollMax, __int64& pageSize);
129
134 void setScrollbarTopOffset(__int64 firstVisibleRow);
135
141
147};
HWND WinHandle
Definition Common.h:16
Definition EventListeners.h:46
Definition Common.h:20
Component()
Constructs a new Component instance.
Definition Graphics.h:161
Definition PopupMenu.h:6
Definition EventListeners.h:31
void setTitle(const wstring &title)
Sets the title of the TreeView.
void clear()
Clears all items from the TreeView.
void setScrollbarTopOffset(__int64 firstVisibleRow)
Sets the scroll position based on the top visible row index.
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.
void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed)
void onPaint(Graphics *g)
Called to paint the component's client area.
void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is pressed within the component.
void windowCreated()
Abstract method called after the window has been created.
long getItemCount()
Gets the total count of items in the TreeView.
void addActionListener(ActionListener *l)
Adds an action listener to respond to user interactions.
void onPageUp(BOOL shiftPressed, BOOL ctrlPressed)
void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed)
void onWindowResized()
Called when the component's window is resized.
void addSelectionChangedListener(SelectionChangeListener *l)
Adds a listener for selection changes.
void onPageDown(BOOL shiftPressed, BOOL ctrlPressed)
void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the right mouse button is clicked within the component.
void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed)
void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed)
long addItem(const wstring &itemText, const wstring &itemId=L"", const wstring &parentId=L"", const wstring &nodeType=L"")
Adds a new item to the TreeView.
TreeView()
Constructs a new TreeView object.
BOOL getScrollingInfo(__int64 &scrollMin, __int64 &scrollMax, __int64 &pageSize)
Provides information for scrollbar rendering.
BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta)
Called when the mouse wheel is used over the component.
BOOL getCreateWindowOptions(wstring &title, UINT &widownStyles, wstring &wndClassName, BOOL &isCustomWndProc)
Abstract method to get window creation options.
virtual ~TreeView()
Destructor.
Definition TreeView.h:7
Bounds _textRect
Definition TreeView.h:15
BOOL _isExpanded
Definition TreeView.h:18
Bounds _expandCollapseRect
Definition TreeView.h:13
BOOL _hasChildren
Definition TreeView.h:17
wstring _nodeType
Definition TreeView.h:12
wstring _text
Definition TreeView.h:11
long _indentLevel
Definition TreeView.h:16
wstring _parentId
Definition TreeView.h:9
wstring _id
Definition TreeView.h:10
Bounds _iconRect
Definition TreeView.h:14
Definition TreeView.h:22
wstring _nodeType
Definition TreeView.h:24