32 #ifndef TBX_TREEVIEW_H_
33 #define TBX_TREEVIEW_H_
35 #include "../gadget.h"
40 class TreeViewNodeSelectedListener;
41 class TreeViewNodeExpandedListener;
42 class TreeViewNodeRenamedListener;
43 class TreeViewNodeDraggedListener;
44 class TreeViewScrollListener;
47 typedef int TreeNodeId;
48 class TreeViewCurrentNode;
65 enum {TOOLBOX_CLASS = 0x4028};
140 unsigned int state()
const {
return int_property(0x4029);}
141 void state(
unsigned int new_state) {
int_property(0x4028, new_state);}
142 bool state_flag(
unsigned int flag)
const {
return (state() & flag) != 0;}
143 void state_flag(
unsigned int flag,
bool set);
145 bool allow_vscroll()
const {
return state_flag(1);}
146 void allow_vscroll(
bool value) {state_flag(1, value);}
147 bool allow_hscroll()
const {
return state_flag(2);}
148 void allow_hscroll(
bool value) {state_flag(2, value);}
149 bool auto_update()
const {
return state_flag(4);}
150 void auto_update(
bool value) {state_flag(4, value);}
151 bool show_current_node()
const {
return state_flag(8);}
152 void show_current_node(
bool value) {state_flag(8, value);}
153 bool plot_lines()
const {
return state_flag(16);}
154 void plot_lines(
bool value) {state_flag(16, value);}
155 bool allow_selection()
const {
return state_flag(32);}
156 void allow_selection(
bool value) {state_flag(32,value);}
157 bool notify_selection()
const {
return state_flag(64);}
158 void notify_selection(
bool value) {state_flag(64, value);}
159 bool select_children()
const {
return state_flag(1u<<7);}
160 void select_children(
bool value) {state_flag(1u<<7, value);}
161 bool allow_expand()
const {
return state_flag(1u<<8);}
162 void allow_expand(
bool value) {state_flag(1u<<8, value);}
163 bool notify_expansion()
const {
return state_flag(1u<<9);}
164 void notify_expansion(
bool value) {state_flag(1u<<9, value);}
165 bool expand_by_default()
const {
return state_flag(1u<<10);}
166 void expand_by_default(
bool value) {state_flag(1u<<10, value);}
167 bool allow_rename()
const {
return state_flag(1u<<11);}
168 void allow_rename(
bool value) {state_flag(1u<<11, value);}
169 bool notify_rename()
const {
return state_flag(1u<<12);}
170 void notify_rename(
bool value) {state_flag(1u<<12, value);}
171 bool allow_drags()
const {
return state_flag(1u<<13);}
172 void allow_drags(
bool value) {state_flag(1u<<13, value);}
173 bool notify_drag_end()
const {
return state_flag(1u<<14);}
174 void notify_drag_end(
bool value) {state_flag(1u<<14, value);}
175 bool all_events()
const {
return state_flag(1u<<15);}
176 void all_events(
bool value) {state_flag(1u<<15,value);}
177 bool double_click_expands()
const {
return state_flag(1u<<16);}
178 void double_click_expands(
bool value) {state_flag(1u<<16,value);}
179 bool flat_mode()
const {
return state_flag(1u<<17);}
180 void flat_mode(
bool value) {state_flag(1u<<17,value);}
181 bool text_below_sprite()
const {
return state_flag(1u<<18);}
182 void text_below_sprite(
bool value) {state_flag(1u<<18,value);}
183 bool sort_display()
const {
return state_flag(1u<<19);}
184 void sort_display(
bool value) {state_flag(1u<<19,value);}
185 bool sort_reversed()
const {
return state_flag(1u<<20);}
186 void sort_reversed(
bool value) {state_flag(1u<<20,value);}
187 bool sort_by_sprite()
const {
return state_flag(1u<<21);}
188 void sort_by_sprite(
bool value) {state_flag(1u<<21,value);}
272 void private_word(
void *word) {
int_property(0x402e, (
int)word);}
273 void *private_word()
const {
return (
void *)
int_property(0x4031);}
287 unsigned int state()
const;
288 bool has_next_sibling()
const {
return (state() & (1u<<0)) != 0;}
289 bool has_prev_sibling()
const {
return (state() & (1u<<1)) != 0;}
290 bool has_child()
const {
return (state() & (1u<<2)) != 0;}
291 bool parent_is_root()
const {
return (state() & (1u<<3)) != 0;}
292 bool has_sprite()
const {
return (state() & (1u<<4)) != 0;}
293 bool has_expanded_sprite()
const {
return (state() & (1u<<5)) != 0;}
294 bool has_text()
const {
return (state() & (1u<<6)) != 0;}
295 bool expanded()
const {
return (state() & (1u<<7)) != 0;}
296 bool selected()
const {
return (state() & (1u<<8)) != 0;}
298 TreeNodeId
add_child(
const std::string &text);
std::string string_property(int property_id) const
Get a string property from the toolbox object.
Definition: component.cc:261
TreeView wrapper class for an underlying toolbox TreeView gadget.
Definition: treeview.h:63
TreeView & operator=(const TreeView &other)
Assign a TreeView field to refer to the same underlying toolbox gadget as another.
Definition: treeview.h:107
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
TreeViewCurrentNode(const TreeViewCurrentNode &other)
Construct from an existing tree view current node.
Definition: treeview.h:241
void erase()
Delete the current tree node.
Definition: treeview.cc:589
ObjectId handle() const
Return the object handle for his component.
Definition: component.h:95
Window underlying_window() const
Get underlying window used for the treeview.
Definition: treeview.cc:190
TreeViewCurrentNode & operator=(const TreeViewCurrentNode &other)
Assign from an existing tree view current node.
Definition: treeview.h:247
The Window object represents a toolbox window.
Definition: window.h:70
std::string expanded_sprite_name() const
Get the name of the expanded sprite for the current node.
Definition: treeview.cc:352
TreeView(const Component &other)
Construct a TreeView field from a Component.
Definition: treeview.h:101
TreeNodeId node_id() const
Get the ID of the current node.
Definition: treeview.h:264
int int_property(int property_id) const
Get an integer property from the toolbox Component.
Definition: component.cc:165
bool move_next(bool sorted=false)
Move current node to next sibling.
Definition: treeview.cc:393
Listener for node selected events.
Definition: treeviewlisteners.h:75
bool operator==(const TreeViewCurrentNode &other) const
Check if this current tree node item refers to the current node of the same tree view.
Definition: treeview.h:253
bool move_first_selected()
Move current node to first selected node.
Definition: treeview.cc:455
bool move_child(bool sorted=false)
Move current node to first child.
Definition: treeview.cc:425
void update_display()
Update the display.
Definition: treeview.cc:175
Base class for components in an object.
Definition: component.h:42
void remove_scroll_listener(TreeViewScrollListener *listener)
Remove a listener for when the tree view is scrolled.
Definition: treeview.cc:290
void add_node_expanded_listener(TreeViewNodeExpandedListener *listener)
Add a listener for when a node is expanded or contracted.
Definition: treeview.cc:226
ObjectId _handle
Underlying toolbox handle.
Definition: component.h:45
TreeView & operator=(const Gadget &other)
Assign a writable field to refer to the same underlying toolbox gadget as an existing Gadget.
Definition: treeview.h:115
ComponentId id() const
Get the component ID of this component.
Definition: component.h:103
TreeView(const Gadget &other)
Construct a TreeView from another gadget.
Definition: treeview.h:92
TreeViewCurrentNode()
Construct an uninitialised TreeViewCurrentNode.
Definition: treeview.h:230
std::string sprite_name() const
Get the name of the sprite for the current node.
Definition: treeview.cc:330
TreeView(const TreeView &other)
Construct a TreeView from another TreeView.
Definition: treeview.h:81
void select(bool select, bool add)
Select/deselect a node.
Definition: treeview.cc:503
bool operator!=(const TreeViewCurrentNode &other) const
Check if this current tree node item refers to the current node of the same tree view.
Definition: treeview.h:259
TreeNodeId add_child(const std::string &text)
Add a new node as the child of the current node.
Definition: treeview.cc:550
bool move_parent()
Move current node to the parent.
Definition: treeview.cc:440
TreeView & operator=(const Component &other)
Assign a TreeView field to refer to the same underlying toolbox component as an existing Gadget.
Definition: treeview.h:124
bool move_next_selected()
Move current node to the next selected node.
Definition: treeview.cc:470
Listener for node dragged events.
Definition: treeviewlisteners.h:200
Listener for node expanded events.
Definition: treeviewlisteners.h:109
void menu(Menu menu)
Set menu for treeview.
Definition: treeview.h:193
void add_node_dragged_listener(TreeViewNodeDraggedListener *listener)
Add a listener for when a node is dragged.
Definition: treeview.cc:263
~TreeView()
Destroy a TreeView gadget.
Definition: treeview.h:74
void make_visible()
Make current node visible in the tree.
Definition: treeview.cc:518
void add_scroll_listener(TreeViewScrollListener *listener)
Add a listener for when the tree view is scrolled.
Definition: treeview.cc:281
bool move_prev(bool sorted=false)
Move current node to previous sibling.
Definition: treeview.cc:409
bool operator!=(const Gadget &other) const
Check if this TreeView refers to the same underlying toolbox gadget as another gadget.
Definition: treeview.h:138
void clear()
Delete all nodes from the tree.
Definition: treeview.cc:158
Class representing the current node in a tree view.
Definition: treeview.h:228
TreeViewCurrentNode current_node()
Get the current tree view node.
Definition: treeview.cc:112
void add_node_selected_listener(TreeViewNodeSelectedListener *listener)
Add a listener for when a node is selected or deselected.
Definition: treeview.cc:208
void sprite(int sprite_area_id, const std::string &sprite_name, const std::string &expanded_sprite_name)
Set the sprites used for the current tree_view node.
Definition: treeview.cc:311
void expand(bool expand, bool recurse=false)
Expand or contract the current node.
Definition: treeview.cc:486
int _id
Underlying toolbox component id.
Definition: component.h:46
void move_to(TreeNodeId id)
Move current node to a give node id.
Definition: treeview.cc:375
This is the base class for all Gadgets.
Definition: gadget.h:49
void remove_node_expanded_listener(TreeViewNodeExpandedListener *listener)
Remove a listener for when a node is expanded or contracted.
Definition: treeview.cc:235
void check_toolbox_class(int class_id) const
Check the underlying gadget class for this object has the given class id.
Definition: gadget.cc:47
void remove_node_selected_listener(TreeViewNodeSelectedListener *listener)
Remove a listener for when a node is selected or deselected.
Definition: treeview.cc:217
TreeNodeId find_node(int x, int y)
Find the tree node at the given location.
Definition: treeview.cc:138
void remove_node_dragged_listener(TreeViewNodeDraggedListener *listener)
Remove a listener for when a node is dragged.
Definition: treeview.cc:272
TreeView()
Construct an uninitialised TreeView.
Definition: treeview.h:67
bool operator==(const Gadget &other) const
Check if this TreeView refers to the same underlying toolbox gadget as another gadget.
Definition: treeview.h:131
TreeNodeId add_sibling(const std::string &text)
Add a new node as the child of the current node.
Definition: treeview.cc:571