ubit
uflag.hpp
1 /************************************************************************
2  *
3  * uflag.hpp
4  * (see also UAttrs.hpp for UAttr subclasses)
5  * Ubit GUI Toolkit - Version 6
6  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
7  *
8  * ***********************************************************************
9  * COPYRIGHT NOTICE :
10  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
11  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
12  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
13  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
14  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
15  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
16  * ***********************************************************************/
17 
18 #ifndef _uflag_hpp_
19 #define _uflag_hpp_ 1
20 #include <ubit/uattr.hpp>
21 #include <ubit/ucond.hpp>
22 namespace ubit {
23 
45  class UFlag : public UCond {
46  public:
47  static const UFlag none;
48 
49  UFlag() {}
50  virtual bool verifies(const UUpdateContext&, const UElem&) const;
51  };
52 
53 
54  // ==================================================== Ubit Toolkit =========
58  class UNotFlag : public UCond {
59  public:
60  const UFlag& cond;
61  UNotFlag(const UFlag& c) : cond(c) {}
62  virtual bool verifies(const UUpdateContext&, const UElem&) const;
63  };
64 
67  inline UNotFlag& operator!(const UFlag& c) {return *new UNotFlag(c);}
68 
69 
70  // ==================================================== Ubit Toolkit =========
71  /* [impl] Defines a flag that is inherited in the scene graph.
72  * See: UFlag.
73  */
74  class UFlagdef : public UAttr {
75  public:
76  UCLASS(UFlagdef)
77 
78  UFlagdef();
79  UFlagdef(const UFlag&);
81 
82  UFlagdef& operator=(const UFlag& f) {return set(f);}
83  virtual UFlagdef& set(const UFlag&);
84  virtual UFlagdef& clear();
85 
86  const UFlag* getFlag() const {return flag;}
87 
88  virtual void update();
89  virtual void putProp(UUpdateContext*, UElem&);
90 
91  protected:
92  const UFlag* flag;
93  };
94 
95  inline UFlagdef& uflagdef() {return *new UFlagdef();}
96  inline UFlagdef& uflagdef(const UFlag& f) {return *new UFlagdef(f);}
97 
98 
99  // ==================================================== Ubit Toolkit =========
100  /* [impl] Defines a property that is inherited in the scene graph.
101  * use UAttrval to retreive the property in a (direct or indirect) child.
102  */
103  class UPropdef : public UFlagdef {
104  public:
105  UCLASS(UPropdef)
106  UPropdef();
107  UPropdef(const UFlag&);
108  UPropdef(const UFlag&, UAttr&);
109 
110  virtual UPropdef& set(const UFlag&);
111  virtual UPropdef& set(UAttr&);
112  virtual UPropdef& set(const UFlag&, UAttr&);
113  virtual UPropdef& clear();
114 
115  UAttr* getProp() const {return prop;}
116  virtual void putProp(UUpdateContext*, UElem&);
117 
118  private:
119  uptr<UAttr> prop;
120  };
121 
122  /* ==================================================== ===== ======= */
123  /* [impl] gets the value of an inherited property.
124  * use UPropdef to define a property in a (direct or indirect) parent.
125  */
126  class UPropval : public UAttr {
127  public:
128  UCLASS(UPropval)
129  UPropval();
130  UPropval(const UFlag&);
131 
132  const UFlag* getFlag() const {return flag;}
133 
134  virtual void update();
135  virtual void putProp(UUpdateContext*, UElem&);
136 
137  private:
138  const UFlag* flag;
139  };
140 
141 }
142 #endif
143 
144 
Base class for attributes.
Definition: uattr.hpp:97
Base class for Ubit conditions.
Definition: ucond.hpp:29
Definition: uflag.hpp:103
Flagging conditions.
Definition: uflag.hpp:45
Definition: uflag.hpp:74
lightweight general purpose container.
Definition: uelem.hpp:44
Smart Pointer for UObject instances (.
Definition: uobject.hpp:365
Definition: uupdatecontext.hpp:32
Definition: uhardfont.hpp:31
Definition: uflag.hpp:126
[impl] negation of a UFlag condition.
Definition: uflag.hpp:58