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#include "Scrollbar.h"
6
21
23{
24public:
25 wstring _nodeType;
26};
27
31class TreeView : public Component, public ScrollbarListener
32{
33 Scrollbar _scrollBar;
34
35 wstring _title;
36 vector<TreeViewItem> _allItems;
37 vector<TreeViewItem> _visibleItems;
38
39 vector<TreeViewMenuItem> _contextMenuItems;
40
41 long _maxVisibleItems;
42 __int64 _firstVisibleItem;
43 __int64 _lastVisibleItem;
44 __int64 _currentItem;
45
49 void ReloadVisibleItems();
50
51protected:
52 BOOL getCreateWindowOptions(wstring& title, UINT& widownStyles, wstring& wndClassName, BOOL& isCustomWndProc);
54
55public:
60
64 virtual ~TreeView();
65
69 void clear();
70
75 void setTitle(const wstring& title);
76
85 long addItem(const wstring& itemText, const wstring& itemId = L"", const wstring& parentId = L"", const wstring& nodeType = L"");
86
87 BOOL updateItem(const wstring& itemId, const wstring& itemText);
88
89 BOOL deleteItem(const wstring& itemId);
90
91 long addPath(const wstring& itemPath, const wstring& parentId = L"");
92
98
99 BOOL getItem(long itemIndex, wstring& itemText, wstring& itemId, wstring& parentId, wstring& itemPath);
100
105 long getSelectedItem(wstring& itemText, wstring& itemId, wstring& parentId, wstring& itemPath);
106
113 void addContextMenuItem(long actionId, const wstring& text, const wstring& nodeType = L"");
114
119
120 void onArrowUp(BOOL shiftPressed, BOOL ctrlPressed);
121 void onArrowDown(BOOL shiftPressed, BOOL ctrlPressed);
122 void onPageUp(BOOL shiftPressed, BOOL ctrlPressed);
123 void onPageDown(BOOL shiftPressed, BOOL ctrlPressed);
124 void onKeyHome(BOOL shiftPressed, BOOL ctrlPressed);
125 void onKeyEnd(BOOL shiftPressed, BOOL ctrlPressed);
126
127 void onMousePressed(WinHandle hWnd, int x, int y, int clickCount, BOOL shiftPressed, BOOL ctrlPressed);
128 void onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
129 void onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
130 void onMouseRightClicked(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed);
131 BOOL onMouseWheel(WinHandle hWnd, int x, int y, int delta);
133
139
145
146public:
147
148 void scrollBarActivity(__int64 firstVisibleItem);
150};
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 Scrollbar.h:14
Definition Scrollbar.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 onMouseReleased(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse button is released within the component.
void scrollBarRepaint()
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 onMouseMoved(WinHandle hWnd, int x, int y, BOOL shiftPressed, BOOL ctrlPressed)
Called when the mouse is moved within the component.
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 scrollBarActivity(__int64 firstVisibleItem)
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 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:8
Bounds _textRect
Definition TreeView.h:16
BOOL _isExpanded
Definition TreeView.h:19
Bounds _expandCollapseRect
Definition TreeView.h:14
BOOL _hasChildren
Definition TreeView.h:18
wstring _nodeType
Definition TreeView.h:13
wstring _text
Definition TreeView.h:12
long _indentLevel
Definition TreeView.h:17
wstring _parentId
Definition TreeView.h:10
wstring _id
Definition TreeView.h:11
Bounds _iconRect
Definition TreeView.h:15
Definition TreeView.h:23
wstring _nodeType
Definition TreeView.h:25