Eclipse SUMO - Simulation of Urban MObility
FXBaseObject.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2004-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
17 //
18 /****************************************************************************/
19 
20 #ifndef FXBASEOBJECT_H
21 #define FXBASEOBJECT_H
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <FXHash.h>
30 using namespace FX;
31 #ifndef FXOBJECT_H
32 #include <FXObject.h>
33 using namespace FX;
34 #endif
35 namespace FXEX {
36 
44 #define FXMAPALL(func) {MKUINT(MINKEY,MINTYPE),MKUINT(MAXKEY,MAXTYPE),&func}
45 
49 #define FXMAPKEY(key,func) {MKUINT(key,MINTYPE),MKUINT(key,MAXTYPE),&func}
50 
51 
55 class /* FXAPI // patch by Daniel Krajzewicz 24.02.2004 */
56  FXBaseObject : public FXObject {
57  FXDECLARE(FXBaseObject)
58 
59 protected:
61  enum {
62  FLAG_ENABLED = 0x00000002, // enabled
63  FLAG_UPDATE = 0x00000004, // needs update
64  FLAG_FOCUSED = 0x00000010, // has focus
65  FLAG_DIRTY = 0x00000020, // dirty
66  FLAG_RECALC = 0x00000040, // needs recalculation
67  FLAG_DEFAULT = 0x00000200, // set to default
68  FLAG_INITIAL = 0x00000400, // set to initial value
69  FLAG_ACTIVE = 0x00001000, // active
70  FLAG_CHANGED = 0x00010000, // changed
71  FLAG_READONLY = 0x10000000 // read only
72  };
73 
74 private:
75  FXApp* app; // application pointer
76 
77 protected:
78  FXObject* target; // application target
79  FXSelector message; // application message
80  void* data; // user data
81  FXuint datalen; // length of user data
82  FXuint flags; // state flags
83  FXuint options; // option flags
84 
85 public:
86  enum {
87  ID_NONE = 0,
88  ID_DELETE = 6,
91  ID_SETVALUE = 17,
106  ID_LAST
107  };
108 
109 public:
110  long onCmdEnable(FXObject*, FXSelector, void*);
111  long onCmdDisable(FXObject*, FXSelector, void*);
112  long onUpdate(FXObject*, FXSelector, void*);
113 
114 public:
116  FXBaseObject(FXObject* tgt = NULL, FXSelector sel = 0);
117 
119  FXBaseObject(FXApp* a, FXObject* tgt = NULL, FXSelector sel = 0);
120 
122  FXApp* getApp();
123 
125  FXObject* getTarget() {
126  return target;
127  }
128 
130  void setTarget(FXObject* tgt) {
131  target = tgt;
132  }
133 
135  FXSelector getSelector() {
136  return message;
137  }
138 
140  void setSelector(FXSelector sel) {
141  message = sel;
142  }
143 
145  void* getUserData() {
146  return data;
147  }
148 
150  void setUserData(void* d) {
151  data = d;
152  }
153 
155  FXuint getUserDataLen() {
156  return datalen;
157  }
158 
160  void setUserDataLen(FXuint len) {
161  datalen = len;
162  }
163 
165  FXbool isEnabled() {
166  return (flags & FLAG_ENABLED) != 0;
167  }
168 
170  virtual void enable() {
171  flags |= FLAG_ENABLED;
172  }
173 
175  virtual void disable() {
176  flags &= ~FLAG_ENABLED;
177  }
178 
180  virtual FXbool isReadonly() {
181  return (flags & FLAG_READONLY) != 0;
182  }
183 
185  virtual void setReadonly(FXbool mode = TRUE);
186 
188  virtual void create() {}
189 
191  virtual void detach() {}
192 
194  virtual void destroy() {}
195 
197  virtual void save(FXStream& store) const;
198 
200  virtual void load(FXStream& store);
201 
203  virtual ~FXBaseObject();
204 };
205 
206 } // namespace FXEX
207 #endif // FXBASEOBJECT_H
208 
void * getUserData()
get user data
Definition: FXBaseObject.h:145
virtual void create()
create resource
Definition: FXBaseObject.h:188
virtual void disable()
disable us
Definition: FXBaseObject.h:175
virtual void enable()
enable us
Definition: FXBaseObject.h:170
FXbool isEnabled()
are we enabled?
Definition: FXBaseObject.h:165
FXObject * getTarget()
get the target
Definition: FXBaseObject.h:125
void setUserDataLen(FXuint len)
set the user data length
Definition: FXBaseObject.h:160
void setUserData(void *d)
set user data
Definition: FXBaseObject.h:150
FXSelector getSelector()
get the message
Definition: FXBaseObject.h:135
void setTarget(FXObject *tgt)
set the target
Definition: FXBaseObject.h:130
FXSelector message
Definition: FXBaseObject.h:79
virtual void destroy()
destroy resource
Definition: FXBaseObject.h:194
void setSelector(FXSelector sel)
set the selector
Definition: FXBaseObject.h:140
FXObject * target
Definition: FXBaseObject.h:78
virtual FXbool isReadonly()
are we modifiable
Definition: FXBaseObject.h:180
FXuint getUserDataLen()
get user daat length
Definition: FXBaseObject.h:155
virtual void detach()
detach resource
Definition: FXBaseObject.h:191