ubit
utable.hpp
1 /************************************************************************
2  *
3  * utable.hpp
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 _utable_hpp_
18 #define _utable_hpp_ 1
19 #include <vector>
20 #include <ubit/ubox.hpp>
21 #include <ubit/uboxes.hpp>
22 namespace ubit {
23 
27  class UTable: public UBox {
28  public:
29  UCLASS(UTable)
30 
31  UTable(UArgs a = UArgs::none): UBox(a) {}
33 
34  static UStyle* createStyle();
35  };
36 
37  inline UTable& utable(UArgs a = UArgs::none) {return *new UTable(a);}
39 
40 
41  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
46  class UTrow: public UElem {
47  public:
48  UCLASS(UTrow)
49 
50  UTrow(UArgs a = UArgs::none): UElem(a) {}
52 
53  static UStyle* createStyle();
54  };
55 
56  inline UTrow& utrow(UArgs a = UArgs::none) {return *new UTrow(a);}
58 
59 
60  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
65  class UTcell: public UFlowbox {
66  public:
67  UCLASS(UTcell)
68 
71 
72  UTcell(short colspan, UArgs a = UArgs::none);
74 
75  UTcell(short colspan, short rowspan, UArgs a = UArgs::none);
77 
78  static UStyle* createStyle();
79 
80  void setColspan(short);
81  void setRowspan(short);
82  short getColspan() {return colspan;}
83  short getRowspan() {return rowspan;}
84 
85  private:
86  short colspan, rowspan;
87  };
88 
89 
90  inline UTcell& utcell(UArgs a = UArgs::none) {return *new UTcell(a);}
92 
93  inline UTcell& utcell(short colspan, UArgs a = UArgs::none) {return *new UTcell(colspan,a);}
95 
96  inline UTcell& utcell(short colspan, short rowspan, UArgs a = UArgs::none) {return *new UTcell(colspan,rowspan,a);}
98 
99 
100  /* ==================================================== ===== ======= */
101 
102  struct UViewCell {
103  UViewCell();
104  float d, min_d, max_d, spec_d, percent;
105  int rowspan, colspan;
106  };
107 
108  class UTableView: public UView {
109  public:
110  static UViewStyle style; // renderer
111  virtual UViewStyle* getViewStyle() {return &style;}
112 
113  UTableView(UBox*, UView* parview, UHardwinImpl*);
114  virtual ~UTableView();
115 
116  static UView* createView(UBox*, UView* parview, UHardwinImpl*);
117  virtual UTableView* toTableView() {return this;}
118 
119 #ifndef NO_DOC
120  std::vector<UViewCell> cols, lines;
121  int lcur, ccur;
122  int ccount, lcount;
123  virtual bool doLayout(UUpdateContext&, class UViewLayout&);
124  static void tableDoLayout(class UTableLayoutImpl&, UUpdateContext& ctx,
125  UElem& grp, UViewLayout&);
126  static void rowDoLayout(UView* row_view, class UTableLayoutImpl&,
127  UUpdateContext& parctx, UElem& grp, UViewLayout&);
128 #endif
129  };
130 
131 }
132 #endif
Definition: utable.cpp:132
UFlowBox = Box with a Flow Layout (similar to an HTML page).
Definition: uboxes.hpp:33
Definition: utable.hpp:108
Box container.
Definition: ubox.hpp:64
Table Row.
Definition: utable.hpp:46
Definition: utable.hpp:102
UTable(UArgs a=UArgs::none)
creates a new table widget (
Definition: utable.hpp:31
lightweight general purpose container.
Definition: uelem.hpp:44
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
Box View.
Definition: uview.hpp:65
Specifies the View Style of an UBox.
Definition: uview.hpp:42
Definition: uupdatecontext.hpp:32
Definition: uhardfont.hpp:31
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
Definition: uwinImpl.hpp:84
Definition: uviewImpl.hpp:114
UTable = class for creating (simplified) HTML like tables.
Definition: utable.hpp:27
Table Cell.
Definition: utable.hpp:65
Compiled Object Style.
Definition: ustyle.hpp:44