ubit
utreebox.hpp
1 /************************************************************************
2 *
3 * utreebox.cpp
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6 *
7 * ***********************************************************************
8 * COPYRIGHT NOTICE :
9 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15 * ***********************************************************************/
16 
17 #ifndef _utreebox_hpp_
18 #define _utreebox_hpp_ 1
19 #include <ubit/ulistbox.hpp>
20 namespace ubit {
21 
25 class UTreebox : public UListbox {
26 public:
27  UCLASS(UTreebox)
28 
29  UTreebox(const UArgs& = UArgs::none);
31 
32  virtual ~UTreebox();
33 
34  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
35 
36  virtual UTreenode* getSelectedNode() const;
38 
39  virtual void setSelectedNode(UTreenode&);
41 
42  virtual int getSelectedIndex() const;
44 
45  virtual UTreebox& setSelectedIndex(int n);
47 
48 private:
49  friend class UTreenode;
50 };
51 
52 UTreebox& utreebox(const UArgs& = UArgs::none);
54 
55 /* ==================================================== ===== ======= */
59 class UTreenode : public UBox {
60 public:
61  UCLASS(UTreenode)
62 
63  UTreenode(const UArgs& label = UArgs::none);
65 
66  UTreenode(const UArgs& label, const UArgs& subnode_list);
68 
69  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
70 
71  virtual void addNode(UTreenode&);
72  virtual void removeNode(UTreenode&);
73 
74  virtual void expand(bool = true);
75  virtual void collapse() {expand(false);}
77 
78  //virtual void setOffset(UHmargin&);
79 
80  UBox& label() {return *plabel;}
81  const UBox& label() const {return *plabel;}
83 
84  UBox& subnodes() {return *psubnodes;}
85  const UBox& subnodes() const {return *psubnodes;}
87 
88 private:
89  friend class UTreebox;
90  uptr<UBox> plabel, psubnodes;
91  uptr<UBox> pexpander;
92  void constructs(const UArgs& label, const UArgs& subnode_list);
93 };
94 
95 UTreenode& utreenode(const UArgs& label = UArgs::none);
97 
98 UTreenode& utreenode(const UArgs& label, const UArgs& subnode_list);
100 
101 }
102 #endif
103 
virtual UTreenode * getSelectedNode() const
returns the selected node; null if there is no selected node.
Definition: utreebox.cpp:40
Box container.
Definition: ubox.hpp:64
virtual UTreebox & setSelectedIndex(int n)
selects the Nth node; selects the last node if n = -1.
Definition: utreebox.cpp:54
virtual void collapse()
expand/collapse the treenode.
Definition: utreebox.hpp:75
Node in a Tree widget.
Definition: utreebox.hpp:59
UTreebox(const UArgs &=UArgs::none)
creates a new tree widget (
Definition: utreebox.cpp:35
Tree widget.
Definition: utreebox.hpp:25
const UBox & label() const
the box that contains the label of the treenode.
Definition: utreebox.hpp:81
List widget: enforces a list layout and makes buttons (and items, checkboxes, etc) contained in this ...
Definition: ulistbox.hpp:117
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
Definition: uhardfont.hpp:31
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
virtual int getSelectedIndex() const
returns the index of the selected node; -1 if there is no selected node.
Definition: utreebox.cpp:50
virtual void setSelectedNode(UTreenode &)
selects this node.
Definition: utreebox.cpp:46
const UBox & subnodes() const
the box that contains the subnodes of the treenode.
Definition: utreebox.hpp:85