ubit
uboxes.hpp
1 /************************************************************************
2  *
3  * uboxes.hpp : misc containers.
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 _uboxes_hpp_
18 #define _uboxes_hpp_ 1
19 #include <ubit/ubox.hpp>
20 namespace ubit {
21 
22  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
33  class UFlowbox: public UBox {
34  public:
35  UCLASS(UFlowbox)
36 
37  UFlowbox(UArgs args = UArgs::none);
42  static UStyle* createStyle();
43  };
44 
45  inline UFlowbox& uflowbox(UArgs args = UArgs::none) {return *new UFlowbox(args);}
47 
48 
49  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
58  class UBar: public UBox {
59  public:
60  UCLASS(UBar)
61 
62  UBar(UArgs args = UArgs::none): UBox(args) {}
64 
65  static UStyle* createStyle();
66  };
67 
68  inline UBar& ubar(UArgs args = UArgs::none) {return *new UBar(args);}
70 
71 
72  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
81  class UStatusbar: public UBox {
82  public:
83  UCLASS(UStatusbar)
84 
85  UStatusbar(UArgs args = UArgs::none): UBox(args) {}
87 
88  static UStyle* createStyle();
89  };
90 
91  inline UStatusbar& ustatusbar(UArgs args = UArgs::none) {return *new UStatusbar(args);}
93 
94 
95  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
98  class UCardbox : public UBox {
99  public:
100  UCLASS(UCardbox)
101 
102  UCardbox(UArgs args = UArgs::none);
104 
105  virtual ~UCardbox();
106 
107  static UStyle* createStyle();
108 
109  virtual UCardbox& addCard(UBox& card);
114  virtual UCardbox& addTab(UArgs tab_content, UBox& card);
120  virtual UBox* getCard(int index) const;
122 
123  virtual int getCardIndex(UBox& card) const;
125 
126  virtual UBox* getSelectedCard() const;
128 
129  virtual int getSelectedIndex() const;
131 
132  virtual void setSelectedCard(UBox& card);
134 
135  virtual void setSelectedIndex(int index);
137 
138  UChoice& choice();
140 
141  UListbox& tablist() {return *ptabs;}
143 
144 #ifndef NO_DOC
145  protected:
146  uptr<UListbox> ptabs;
147  virtual void setSelectedImpl();
148 #endif
149  };
150 
151  inline UCardbox& ucardbox(UArgs args = UArgs::none) {return *new UCardbox(args);}
153 
154 
155  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
161  class UDocbox : public UBox {
162  public:
163  UCLASS(UDocbox)
164 
165  UDocbox(UArgs args = UArgs::none);
166  virtual ~UDocbox();
167 
168  virtual UBox& titlebar() {return *ptitlebar;}
169  virtual UScrollpane& scrollpane() {return *pspane;}
170  virtual UBox& content() {return *pcontent;}
171  virtual UScale& scale() {return *pscale;}
172  virtual void iconify(bool);
173  virtual bool isIconified() const;
174  virtual void zoom(float value = 1.);
175  virtual void zoomIn();
176  virtual void zoomOut();
177  virtual void setZoomQuantum(float);
178 
179 #ifndef NO_DOC
180  protected:
181  uptr<UBox> ptitlebar, pcontent;
182  uptr<UScrollpane> pspane;
183  uptr<UScale> pscale;
184  float zoom_quantum;
185 #endif
186  };
187 
188 
189  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
192  class UAlertbox : public UBox {
193  public:
194  UCLASS(UAlertbox)
195 
196  UAlertbox(UArgs args = UArgs::none);
197 
198  static UStyle* createStyle();
199 
200  // NB: show doit etre redefini, sinon show("abcd") est pris comme show(bool)
201  // a cause des conversions implicites (stupides) du C++
202  virtual void show(bool b) {UBox::show(b);}
203  virtual void show(const char* msg) {showMsg(msg);}
204  virtual void show(const UStr& msg) {showMsg(msg);}
205 
206  virtual void showMsg(const char* msg);
207  virtual void showMsg(const UStr& msg);
209 
210  private:
211  UElem message;
212  };
213 
214 }
215 #endif
UFlowBox = Box with a Flow Layout (similar to an HTML page).
Definition: uboxes.hpp:33
Box container.
Definition: ubox.hpp:64
Status bar.
Definition: uboxes.hpp:81
Makes the children of a widget (exclusively) selectable.
Definition: uchoice.hpp:30
UBar = horizontal toolbar or status bar.
Definition: uboxes.hpp:58
Alertbox gadget.
Definition: uboxes.hpp:192
UListbox & tablist()
returns the tab list.
Definition: uboxes.hpp:141
lightweight general purpose container.
Definition: uelem.hpp:44
List widget: enforces a list layout and makes buttons (and items, checkboxes, etc) contained in this ...
Definition: ulistbox.hpp:117
Smart Pointer for UObject instances (.
Definition: uobject.hpp:365
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
A box with (optionnal) scrollbars that manages a viewport.
Definition: uscrollpane.hpp:37
Definition: uhardfont.hpp:31
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
Widget scale.
Definition: uboxgeom.hpp:31
virtual void show(bool b)
shows/hides this object.
Definition: uboxes.hpp:202
Card box (or Tabbed Pane).
Definition: uboxes.hpp:98
UFlowbox(UArgs args=UArgs::none)
create a new flowbox;
Definition: uboxes.cpp:135
Compiled Object Style.
Definition: ustyle.hpp:44
virtual void show(bool=true)
shows/hides this object.
Definition: uelem.cpp:468
document box gadget.
Definition: uboxes.hpp:161
Ubit String.
Definition: ustr.hpp:72