ubit
ustyle.hpp
1 /************************************************************************
2  *
3  * ustyle.hpp: Element and Box styles
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 _ustyle_hpp_
18 #define _ustyle_hpp_ 1
19 #include <ubit/udefs.hpp>
20 #include <ubit/uborder.hpp>
21 #include <ubit/ufont.hpp>
22 #include <ubit/ugeom.hpp>
23 #include <ubit/uon.hpp>
24 namespace ubit {
25 
26  struct ULocalProps {
27  ULocalProps();
28 
29  USizeSpec size; // object size
30  UPaddingSpec padding; // space beween content and border (if any)
31  const UBorder* border; // object border
32  const UBackground* background; // image or color background of the component
33  float alpha; // for alpha blending
34  // const UShape* shape; // shape of the component
35  // if this group is not null the objects it contains are added to children for
36  // display (e.g. for adding list-item or checkboxes markers)
37  UElem* content; // NB: = null in most cases
38  };
39 
40 
44  class UStyle {
45  public:
46  UStyle();
47  virtual ~UStyle();
48  virtual const UStyle& getStyle(UUpdateContext*) const {return *this;}
49 
50  void setAlpha(float a) {local.alpha = a;}
51  //void setBackground(const UBackground*);
52  void setBorder(const UBorder* b) {local.border = b;}
53  void setCursor(const UCursor* c) {cursor = c;}
54  void setFont(const UFont* f) {font = f;}
55  void setSize(ULength width, ULength height);
56  void setPadding(ULength horiz, ULength vert);
57  void setHorizPadding(ULength left, ULength right);
58  void setVertPadding(ULength top, ULength bottom);
59 
60  const UColor* getColor(const UElem&) const;
61  const UColor* getBgcolor(const UElem&) const;
62  void setColors(UColor& all_colors);
63  void setColors(UColor& unselected_colors, UColor& selected_colors);
64  void setBgcolors(UColor& all_colors);
65  void setBgcolors(UColor& unselected_colors, UColor& selected_colors);
66  void setColor(int action, UColor&);
67  void setBgcolor(int action, UColor&);
68 
69  // champs locaux a l'object, pas heritables
70  ULocalProps local;
71 
72  // champs heritables
73  char orient;
74  char valign, halign;
75  short vspacing, hspacing;
76  const UViewStyle* viewStyle;
77  //UEdit* edit;
78  const UFont* font;
79  const UCursor* cursor;
80  const UStr* textSeparator; // text separator between children when printing
81  UColor* colors[2 * UOn::ACTION_COUNT];
82  UColor* bgcolors[2 * UOn::ACTION_COUNT];
83  //const UColor *color, *bgcolor;
84  //class UAttrList* attrs;
85  };
86 
87 }
88 #endif
Length of positions (UPos), sizes (USize) and padding (UPadding)
Definition: ulength.hpp:59
Widget background.
Definition: ubackground.hpp:30
Color attribute of an element or a widget.
Definition: ucolor.hpp:73
lightweight general purpose container.
Definition: uelem.hpp:44
Box padding.
Definition: ulength.hpp:150
UBox Border.
Definition: uborder.hpp:27
Font of a UElem or UBox container.
Definition: ufont.hpp:30
Specifies the View Style of an UBox.
Definition: uview.hpp:42
Definition: uupdatecontext.hpp:32
Definition: uhardfont.hpp:31
Definition: ustyle.hpp:26
Definition: ulength.hpp:142
Mouse cursor property.
Definition: ucursor.hpp:31
Compiled Object Style.
Definition: ustyle.hpp:44
Ubit String.
Definition: ustr.hpp:72