ubit
uborder.hpp
1 /************************************************************************
2  *
3  * uborder.hpp: widget border
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 _uborder_hpp_
18 #define _uborder_hpp_ 1
19 #include <ubit/uattr.hpp>
20 #include <ubit/ulength.hpp>
21 namespace ubit {
22 
23  class UBorderContent;
24 
27  class UBorder : public UAttr {
28  public:
29  UCLASS(UBorder)
30 
31  enum {NONE, LINE, SHADOW, ETCHED};
33 
34  static UBorder none, empty, line, shadowIn, shadowOut, etchedIn, etchedOut;
36 
37  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
38 
39  UBorder(int decoration = NONE);
40 
41  UBorder(int decoration, const UColor& color, const UColor& bgcolor,
42  float width = 1, float height = 1);
51  UBorder(const UBorder&);
53 
54  virtual ~UBorder();
55 
56  virtual UBorder& operator=(const UBorder&);
57 
58  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
59 
60  int getDecoration() const {return decoration;}
61  UBorder& setDecoration(int decoration);
63 
64  const UColor& getColor() const {return *pcolor;}
65  UBorder& setColor(const UColor&);
67 
68  const UColor& getBgcolor() const {return *pbgcolor;}
69  UBorder& setBgcolor(const UColor&);
71 
72  const UPaddingSpec& getPadding() const {return padding;}
73  UBorder& setPadding(const UPaddingSpec&);
74 
75  bool isRounded() const {return is_rounded;}
77 
78  bool isOverlaid() const {return is_overlaid;}
80 
81  UBorder& setOverlaid(bool state);
82 
83  //float getThickness() const {return thickness;}
84  //UBorder& setThickness(float);
85 
86  virtual void update();
87 
88  virtual void getSize(const UUpdateContext&, UPaddingSpec&) const;
89  virtual void paint(UGraph&, const UUpdateContext&, const URect& r) const;
90  virtual void paintDecoration(UGraph& g, const URect& r, UElem& obj,
91  const UColor& fg, const UColor& bg) const;
92 
93  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
94 #ifndef NO_DOC
95  protected:
96  short decoration;
97  bool is_overlaid, is_rounded;
98  UPaddingSpec padding;
99  uptr<const UColor> pcolor, pbgcolor;
100 
101  UBorder(int decoration, const UColor& color, const UColor& bgcolor,
102  float width, float height, UConst);
103  virtual void constructs(int decoration, const UColor& _color, const UColor& _bgcolor);
104  virtual void putProp(UUpdateContext*, UElem&);
105 #endif
106  };
107 
108  inline UBorder& uborder(UBorder& b) {return *new UBorder(b);}
109 
110  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
111 
114  class URoundBorder : public UBorder {
115  public:
116  UCLASS(URoundBorder)
117 
118  URoundBorder(int decoration = NONE);
119  URoundBorder(int decoration, const UColor& color, const UColor& bgcolor,
120  float width, float height, float arc_w, float arc_h);
121 
122  float getArcWidth() const {return arc_w;}
123  float getArcHeight() const {return arc_h;}
124 
125  virtual void paintDecoration(UGraph& g, const URect& r, UElem& obj,
126  const UColor& fg, const UColor& bg) const;
127  protected:
128  float arc_w, arc_h;
129  };
130 
131 
132  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
133 
136 class UCompositeBorder : public UBorder {
137  public:
138  UCLASS(UCompositeBorder)
139 
141 
142  UCompositeBorder(const UArgs& children);
144 
145  virtual UElem* getSubGroup() const {return pchildren;}
147 
148  virtual void putProp(UUpdateContext*, UElem&);
149 
150 protected:
151  uptr<UElem> pchildren;
152  };
153 
154 }
155 #endif
static UBorder etchedOut
predefined borders.
Definition: uborder.hpp:34
bool isRounded() const
returns true if the border is rounded.
Definition: uborder.hpp:75
Base class for attributes.
Definition: uattr.hpp:97
Definition: uobject.hpp:282
Border that can contain other objects, including elements.
Definition: uborder.hpp:136
virtual void putProp(UUpdateContext *, UElem &)
[impl] changes corresponding value in the UUpdateContext
Definition: uborder.cpp:175
class for drawing on widgets.
Definition: ugraph.hpp:44
2D Rectangle.
Definition: ugeom.hpp:165
Color attribute of an element or a widget.
Definition: ucolor.hpp:73
virtual UElem * getSubGroup() const
[Impl] returns the children.
Definition: uborder.hpp:145
lightweight general purpose container.
Definition: uelem.hpp:44
UBorder & setDecoration(int decoration)
changes the decoration.
Definition: uborder.cpp:129
Box padding.
Definition: ulength.hpp:150
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
UBox Border.
Definition: uborder.hpp:27
bool isOverlaid() const
returns true if the border is overlaid.
Definition: uborder.hpp:78
UBorder & setBgcolor(const UColor &)
changes background color; beware that the color arg is NOT duplicated and can&#39;t be freed...
Definition: uborder.cpp:146
Definition: uupdatecontext.hpp:32
Definition: uhardfont.hpp:31
UBorder & setColor(const UColor &)
changes foreground color; beware that the color arg is NOT duplicated and can&#39;t be freed...
Definition: uborder.cpp:140
virtual void update()
updates parents graphics.
Definition: uborder.cpp:171
Rounded border.
Definition: uborder.hpp:114
Definition: uborder.cpp:97