FDOSTUI
FreeDOS Text User Interface
tree.hpp
Go to the documentation of this file.
1 /*
2  TREE.HPP
3 
4  License CC0 PUBLIC DOMAIN
5 
6  To the extent possible under law, Mark J. Olesen has waived all copyright
7  and related or neighboring rights to FDOSTUI Library. This work is published
8  from: United States.
9 */
10 #ifndef __tree_hpp__
11 
12 #include "treeitem.hpp"
13 #include "scrllbar.hpp"
14 
15 class tree : public widget
16 {
17 
18 public:
19 
20  typedef void (*signal_selected_t)(
21  tree const*const i_tree,
22  void* io_user_data);
23 
24  tree(
25  int const i_pos_x,
26  int const i_pos_y,
27  unsigned int const i_len_x,
28  unsigned int const i_len_y);
29 
30  void
31  attach(
32  treeitem*const io_root);
33 
34  virtual void
35  draw() const;
36 
37  virtual
38  ~tree();
39 
40  virtual enum event_response
41  event_key(
42  struct event_key const& i_event);
43 
44  virtual enum event_response
46  struct event_mouse const& i_event);
47 
48  virtual void
49  move(
50  int const i_pos_x,
51  int const i_pos_y);
52 
53  virtual void
54  resize(
55  unsigned int const i_len_x,
56  unsigned int const i_len_y);
57 
58 protected:
59 
65 
66 private:
67 
68  tree();
69 
70  tree(
71  const tree&);
72 
73  tree&
74  operator=(tree const&);
75 
76  int
77  draw(
78  treeitem*const io_item,
79  int const i_pos_x,
80  int const i_pos_y) const;
81 
82  void
83  emit_selected();
84 
85  bool
86  event_hit(
87  treeitem*const io_item,
88  unsigned int const i_pos_y);
89 
90  void
91  key_down();
92 
93  void
94  key_up();
95 
96  void
98 
99  void
101  unsigned int& io_height,
102  unsigned int& io_width,
103  treeitem const& i_item,
104  unsigned int const i_pos_y);
105 };
106 
107 inline void
109  treeitem*const io_root)
110 {
111 
112  delete m_root;
113  m_root= io_root;
114  m_selected= io_root;
115 
116  if (m_root)
117  {
118  treeitem::set_links(m_root, 0, 0, 0);
119  }
120 
122 
123  return;
124 }
125 
126 inline void
128 {
129 
131  {
132  (*m_signal_selected)(this, (*m_selected).m_user_data);
133  }
134 
135  return;
136 }
137 
138 #define __tree_hpp__
139 #endif
virtual enum event_response event_mouse(struct event_mouse const &i_event)
handle mouse event
Definition: tree.cpp:448
A slider widget with navigational arrow buttons at each end.
Definition: scrllbar.hpp:14
void scrollbar_configure()
configure horizontal and veritcal scrollbars
Definition: tree.cpp:253
virtual ~tree()
desctructor
Definition: tree.cpp:46
contains scrollbar class
static void set_links(treeitem *const io_item, treeitem *const io_parent, treeitem *const io_prev, unsigned int const i_level)
sets linkage between tree items
Definition: treeitem.cpp:236
virtual void resize(unsigned int const i_len_x, unsigned int const i_len_y)
resize the widget
Definition: tree.cpp:518
base class for all derived widgets
Definition: widget.hpp:19
void key_down()
handle key down event
Definition: tree.cpp:342
void(* signal_selected_t)(tree const *const i_tree, void *io_user_data)
function prototype to recieve signal
Definition: tree.hpp:20
void key_up()
handle key up event
Definition: tree.cpp:372
scrollbar m_vertical
Definition: tree.hpp:64
treeitem * m_root
Definition: tree.hpp:60
virtual void move(int const i_pos_x, int const i_pos_y)
move the widget to a new position
Definition: tree.dox:105
void attach(treeitem *const io_root)
attach a treeitem to this tree
Definition: tree.hpp:108
event_response
response
Definition: event.h:14
virtual void draw() const
draws the widget
Definition: tree.cpp:125
treeitem * m_selected
Definition: tree.hpp:61
bool event_hit(treeitem *const io_item, unsigned int const i_pos_y)
test if event is in item or it's children
Definition: tree.cpp:292
treeitem widget class
Definition: treeitem.hpp:15
tree widget class
Definition: tree.hpp:15
signal_selected_t m_signal_selected
Definition: tree.hpp:62
contains treeitem widget class
virtual enum event_response event_key(struct event_key const &i_event)
handle key event
Definition: tree.cpp:401
void emit_selected()
emit selected signal
Definition: tree.hpp:127
container for a mouse event
Definition: event.h:37
scrollbar m_horizontal
Definition: tree.hpp:63
container for a keyboard event
Definition: event.h:23