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
84 BOOL updateItem(const wstring& itemId, const wstring& itemText);
85
86 BOOL deleteItem(const wstring& itemId);
87
88 long addPath(const wstring& itemPath, const wstring& parentId = L"");
89
95
96 BOOL getItem(long itemIndex, wstring& itemText, wstring& itemId, wstring& parentId, wstring& itemPath);
97
102 long getSelectedItem(wstring& itemText, wstring& itemId, wstring& parentId, wstring& itemPath);
103
110 void addContextMenuItem(long actionId, const wstring& text, const wstring& nodeType = L"");
111
116
117 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed);
118 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed);
119 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed);
120 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed);
121 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed);
122 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed);
123
124 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
125 void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
126 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
128
136 BOOL getScrollingInfo(__int64& scrollMin, __int64& scrollMax, __int64& pageSize);
137
142 void setScrollbarTopOffset(__int64 firstVisibleRow);
143
149
155};
HWND WinHandle
Definition Common.h:16
Definition EventListeners.h:46
Definition Common.h:21
Component()
Constructs a new Component instance.
Definition Graphics.h:171
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.
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.
BOOL updateItem(const wstring &itemId, const wstring &itemText)
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)
BOOL deleteItem(const wstring &itemId)
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)
long addPath(const wstring &itemPath, const wstring &parentId=L"")
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.
BOOL getItem(long itemIndex, wstring &itemText, wstring &itemId, wstring &parentId, wstring &itemPath)
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.
long getSelectedItem(wstring &itemText, wstring &itemId, wstring &parentId, wstring &itemPath)
Gets the index of the currently selected item.
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