Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXDataTarget.h
1 /********************************************************************************
2 * *
3 * D a t a T a r g e t *
4 * *
5 *********************************************************************************
6 * Copyright (C) 1998,2017 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as published by *
10 * the Free Software Foundation; either version 3 of the License, or *
11 * (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public License *
19 * along with this program. If not, see <http://www.gnu.org/licenses/> *
20 ********************************************************************************/
21 #ifndef FXDATATARGET_H
22 #define FXDATATARGET_H
23 
24 #ifndef FXOBJECT_H
25 #include "FXObject.h"
26 #endif
27 
28 namespace FX {
29 
30 
63 class FXAPI FXDataTarget : public FXObject {
64  FXDECLARE(FXDataTarget)
65 protected:
66  void *data; // Associated data
67  FXObject *target; // Target object
68  FXSelector message; // Message ID
69  FXuint type; // Type of data
70 private:
71  FXDataTarget(const FXDataTarget&);
72  FXDataTarget& operator=(const FXDataTarget&);
73 public:
74  long onCmdValue(FXObject*,FXSelector,void*);
75  long onUpdValue(FXObject*,FXSelector,void*);
76  long onCmdOption(FXObject*,FXSelector,void*);
77  long onUpdOption(FXObject*,FXSelector,void*);
78 public:
79  enum {
80  DT_VOID=0,
81  DT_BOOL,
82  DT_CHAR,
83  DT_UCHAR,
84  DT_SHORT,
85  DT_USHORT,
86  DT_INT,
87  DT_UINT,
88  DT_LONG,
89  DT_ULONG,
90  DT_FLOAT,
91  DT_DOUBLE,
92  DT_STRING,
93  DT_LAST
94  };
95 public:
96  enum {
97  ID_VALUE=1,
98  ID_OPTION=ID_VALUE+10001,
99  ID_LAST=ID_OPTION+10000
100  };
101 public:
102 
104  FXDataTarget():data(NULL),target(NULL),message(0),type(DT_VOID){}
105 
107  FXDataTarget(FXObject* tgt,FXSelector sel):data(NULL),target(tgt),message(sel),type(DT_VOID){}
108 
110  FXDataTarget(FXbool& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_BOOL){}
111 
113  FXDataTarget(FXchar& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_CHAR){}
114 
116  FXDataTarget(FXuchar& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_UCHAR){}
117 
119  FXDataTarget(FXshort& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_SHORT){}
120 
122  FXDataTarget(FXushort& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_USHORT){}
123 
125  FXDataTarget(FXint& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_INT){}
126 
128  FXDataTarget(FXuint& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_UINT){}
129 
131  FXDataTarget(FXlong& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_LONG){}
132 
134  FXDataTarget(FXulong& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_ULONG){}
135 
137  FXDataTarget(FXfloat& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_FLOAT){}
138 
140  FXDataTarget(FXdouble& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_DOUBLE){}
141 
143  FXDataTarget(FXString& value,FXObject* tgt=NULL,FXSelector sel=0):data(&value),target(tgt),message(sel),type(DT_STRING){}
144 
145 
147  void setTarget(FXObject *t){ target=t; }
148 
150  FXObject* getTarget() const { return target; }
151 
152 
154  void setSelector(FXSelector sel){ message=sel; }
155 
157  FXSelector getSelector() const { return message; }
158 
159 
161  FXuint getType() const { return type; }
162 
164  void* getData() const { return data; }
165 
166 
168  void connect(){ data=NULL; type=DT_VOID; }
169 
171  void connect(FXbool& value){ data=&value; type=DT_BOOL; }
172 
174  void connect(FXchar& value){ data=&value; type=DT_CHAR; }
175 
177  void connect(FXuchar& value){ data=&value; type=DT_UCHAR; }
178 
180  void connect(FXshort& value){ data=&value; type=DT_SHORT; }
181 
183  void connect(FXushort& value){ data=&value; type=DT_USHORT; }
184 
186  void connect(FXint& value){ data=&value; type=DT_INT; }
187 
189  void connect(FXuint& value){ data=&value; type=DT_UINT; }
190 
192  void connect(FXlong& value){ data=&value; type=DT_LONG; }
193 
195  void connect(FXulong& value){ data=&value; type=DT_ULONG; }
196 
198  void connect(FXfloat& value){ data=&value; type=DT_FLOAT; }
199 
201  void connect(FXdouble& value){ data=&value; type=DT_DOUBLE; }
202 
204  void connect(FXString& value){ data=&value; type=DT_STRING; }
205 
206 
208  void connect(FXObject* tgt,FXSelector sel){ data=NULL; target=tgt; message=sel; type=DT_VOID; }
209 
211  void connect(FXbool& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_BOOL; }
212 
214  void connect(FXchar& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_CHAR; }
215 
217  void connect(FXuchar& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_UCHAR; }
218 
220  void connect(FXshort& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_SHORT; }
221 
223  void connect(FXushort& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_USHORT; }
224 
226  void connect(FXint& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_INT; }
227 
229  void connect(FXuint& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_UINT; }
230 
232  void connect(FXlong& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_LONG; }
233 
235  void connect(FXulong& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_ULONG; }
236 
238  void connect(FXfloat& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_FLOAT; }
239 
241  void connect(FXdouble& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_DOUBLE; }
242 
244  void connect(FXString& value,FXObject* tgt,FXSelector sel){ data=&value; target=tgt; message=sel; type=DT_STRING; }
245 
246 
248  virtual ~FXDataTarget();
249  };
250 
251 }
252 
253 #endif

Copyright © 1997-2016 Jeroen van der Zijp