Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/foxtools/MFXBaseObject.h
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2004-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file MFXBaseObject.h
15
/// @author Mathew Robertson
16
/// @author Daniel Krajzewicz
17
/// @author Michael Behrisch
18
/// @date 2004-03-19
19
///
20
//
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include <FXHash.h>
26
using namespace FX;
27
28
namespace FXEX {
29
30
/**
31
* Define so that all types and all id's can go to a specific function.
32
* This is particularily useful if you just want to forward the event to a target
33
* but not specifically use the onDefault method.
34
*
35
* Note: if FXApp* is not specified, then FXApp::Instance() is used.
36
*/
37
#define FXMAPALL(func) {MKUINT(MINKEY,MINTYPE),MKUINT(MAXKEY,MAXTYPE),&func}
38
39
/**
40
* Define so that we can use it to 'redirect' all unhandled events, of a specific key/ID
41
*/
42
#define FXMAPKEY(key,func) {MKUINT(key,MINTYPE),MKUINT(key,MAXTYPE),&func}
43
44
45
/**
46
* This is a base class for ojects which can send messages to the application
47
*/
48
class /* FXAPI // patch by Daniel Krajzewicz 24.02.2004 */
49
MFXBaseObject : public FXObject {
50
FXDECLARE(MFXBaseObject)
51
52
protected:
53
/// flags defined are the same as those defined in FXWindow, etc.
54
enum {
55
FLAG_ENABLED = 0x00000002, // enabled
56
FLAG_UPDATE = 0x00000004, // needs update
57
FLAG_FOCUSED = 0x00000010, // has focus
58
FLAG_DIRTY = 0x00000020, // dirty
59
FLAG_RECALC = 0x00000040, // needs recalculation
60
FLAG_DEFAULT = 0x00000200, // set to default
61
FLAG_INITIAL = 0x00000400, // set to initial value
62
FLAG_ACTIVE = 0x00001000, // active
63
FLAG_CHANGED = 0x00010000, // changed
64
FLAG_READONLY = 0x10000000 // read only
65
};
66
67
private:
68
FXApp* app; // application pointer
69
70
protected:
71
FXObject* target; // application target
72
FXSelector message; // application message
73
void* data; // user data
74
FXuint datalen; // length of user data
75
FXuint flags; // state flags
76
FXuint options; // option flags
77
78
public:
79
enum {
80
ID_NONE = 0,
81
ID_DELETE = 6,
82
ID_DISABLE,
83
ID_ENABLE,
84
ID_SETVALUE = 17,
85
ID_SETINTVALUE,
86
ID_SETREALVALUE,
87
ID_SETSTRINGVALUE,
88
ID_SETINTRANGE,
89
ID_SETREALRANGE,
90
ID_GETINTVALUE,
91
ID_GETREALVALUE,
92
ID_GETSTRINGVALUE,
93
ID_XML,
94
ID_META,
95
ID_COMMENT,
96
ID_DOCUMENT,
97
ID_TAG,
98
ID_CONTENT,
99
ID_LAST
100
};
101
102
public:
103
long onCmdEnable(FXObject*, FXSelector, void*);
104
long onCmdDisable(FXObject*, FXSelector, void*);
105
long onUpdate(FXObject*, FXSelector, void*);
106
107
public:
108
/// Just supply the target and selector (de-serialisation too)
109
MFXBaseObject(FXObject* tgt = NULL, FXSelector sel = 0);
110
111
/// Alternnatively, supply the app object as well
112
MFXBaseObject(FXApp* a, FXObject* tgt = NULL, FXSelector sel = 0);
113
114
/// application pointer
115
FXApp* getApp();
116
117
/// get the target
118
FXObject* getTarget() {
119
return target;
120
}
121
122
/// set the target
123
void setTarget(FXObject* tgt) {
124
target = tgt;
125
}
126
127
/// get the message
128
FXSelector getSelector() {
129
return message;
130
}
131
132
/// set the selector
133
void setSelector(FXSelector sel) {
134
message = sel;
135
}
136
137
/// get user data
138
void* getUserData() {
139
return data;
140
}
141
142
/// set user data
143
void setUserData(void* d) {
144
data = d;
145
}
146
147
/// get user daat length
148
FXuint getUserDataLen() {
149
return datalen;
150
}
151
152
/// set the user data length
153
void setUserDataLen(FXuint len) {
154
datalen = len;
155
}
156
157
/// are we enabled?
158
FXbool isEnabled() {
159
return (flags & FLAG_ENABLED) != 0;
160
}
161
162
/// enable us
163
virtual void enable() {
164
flags |= FLAG_ENABLED;
165
}
166
167
/// disable us
168
virtual void disable() {
169
flags &= ~FLAG_ENABLED;
170
}
171
172
/// are we modifiable
173
virtual FXbool isReadonly() {
174
return (flags & FLAG_READONLY) != 0;
175
}
176
177
/// set modifiable mode
178
virtual void setReadonly(FXbool mode = TRUE);
179
180
/// create resource
181
virtual void create() {}
182
183
/// detach resource
184
virtual void detach() {}
185
186
/// destroy resource
187
virtual void destroy() {}
188
189
/// save object to stream
190
virtual void save(FXStream& store) const;
191
192
/// load object from stream
193
virtual void load(FXStream& store);
194
195
/// dtor
196
virtual ~MFXBaseObject();
197
};
198
199
} // namespace FXEX
200
201