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

FX::FXDataTarget Class Reference

A Data Target allows a widget to be directly connected with a associated variable, without any additional "glue code". More...

#include <FXDataTarget.h>

Inheritance diagram for FX::FXDataTarget:
FX::FXObject

Public Types

enum  {
  DT_VOID =0, DT_BOOL, DT_CHAR, DT_UCHAR,
  DT_SHORT, DT_USHORT, DT_INT, DT_UINT,
  DT_LONG, DT_ULONG, DT_FLOAT, DT_DOUBLE,
  DT_STRING, DT_LAST
}
 
enum  { ID_VALUE =1, ID_OPTION =ID_VALUE+10001, ID_LAST =ID_OPTION+10000 }
 

Public Member Functions

long onCmdValue (FXObject *, FXSelector, void *)
 
long onUpdValue (FXObject *, FXSelector, void *)
 
long onCmdOption (FXObject *, FXSelector, void *)
 
long onUpdOption (FXObject *, FXSelector, void *)
 
 FXDataTarget ()
 Associate with nothing.
 
 FXDataTarget (FXObject *tgt, FXSelector sel)
 Associate with nothing.
 
 FXDataTarget (FXbool &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with character variable.
 
 FXDataTarget (FXchar &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with character variable.
 
 FXDataTarget (FXuchar &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with unsigned character variable.
 
 FXDataTarget (FXshort &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with signed short variable.
 
 FXDataTarget (FXushort &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with unsigned short variable.
 
 FXDataTarget (FXint &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with int variable.
 
 FXDataTarget (FXuint &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with unsigned int variable.
 
 FXDataTarget (FXlong &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with long variable.
 
 FXDataTarget (FXulong &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with unsigned long variable.
 
 FXDataTarget (FXfloat &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with float variable.
 
 FXDataTarget (FXdouble &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with double variable.
 
 FXDataTarget (FXString &value, FXObject *tgt=nullptr, FXSelector sel=0)
 Associate with string variable.
 
void setTarget (FXObject *t)
 Set the message target object for this data target.
 
FXObjectgetTarget () const
 Get the message target object for this data target, if any.
 
void setSelector (FXSelector sel)
 Set the message identifier for this data target.
 
FXSelector getSelector () const
 Get the message identifier for this data target.
 
FXuint getType () const
 Return type of data its connected to.
 
void * getData () const
 Return pointer to data its connected to.
 
void connect ()
 Associate with nothing.
 
void connect (FXbool &value)
 Associate with FXbool variable.
 
void connect (FXchar &value)
 Associate with character variable.
 
void connect (FXuchar &value)
 Associate with unsigned character variable.
 
void connect (FXshort &value)
 Associate with signed short variable.
 
void connect (FXushort &value)
 Associate with unsigned short variable.
 
void connect (FXint &value)
 Associate with int variable.
 
void connect (FXuint &value)
 Associate with unsigned int variable.
 
void connect (FXlong &value)
 Associate with long variable.
 
void connect (FXulong &value)
 Associate with unsigned long variable.
 
void connect (FXfloat &value)
 Associate with float variable.
 
void connect (FXdouble &value)
 Associate with double variable.
 
void connect (FXString &value)
 Associate with string variable.
 
void connect (FXObject *tgt, FXSelector sel)
 Associate with nothing; also set target and message.
 
void connect (FXbool &value, FXObject *tgt, FXSelector sel)
 Associate with character variable; also set target and message.
 
void connect (FXchar &value, FXObject *tgt, FXSelector sel)
 Associate with character variable; also set target and message.
 
void connect (FXuchar &value, FXObject *tgt, FXSelector sel)
 Associate with unsigned character variable; also set target and message.
 
void connect (FXshort &value, FXObject *tgt, FXSelector sel)
 Associate with signed short variable; also set target and message.
 
void connect (FXushort &value, FXObject *tgt, FXSelector sel)
 Associate with unsigned short variable; also set target and message.
 
void connect (FXint &value, FXObject *tgt, FXSelector sel)
 Associate with int variable; also set target and message.
 
void connect (FXuint &value, FXObject *tgt, FXSelector sel)
 Associate with unsigned int variable; also set target and message.
 
void connect (FXlong &value, FXObject *tgt, FXSelector sel)
 Associate with long variable; also set target and message.
 
void connect (FXulong &value, FXObject *tgt, FXSelector sel)
 Associate with unsigned long variable; also set target and message.
 
void connect (FXfloat &value, FXObject *tgt, FXSelector sel)
 Associate with float variable; also set target and message.
 
void connect (FXdouble &value, FXObject *tgt, FXSelector sel)
 Associate with double variable; also set target and message.
 
void connect (FXString &value, FXObject *tgt, FXSelector sel)
 Associate with string variable; also set target and message.
 
virtual ~FXDataTarget ()
 Destroy.
 
- Public Member Functions inherited from FX::FXObject
const FXchar * getClassName () const
 Get class name of some object.
 
FXbool isMemberOf (const FXMetaClass *metaclass) const
 Check if object is member of metaclass.
 
virtual long tryHandle (FXObject *sender, FXSelector sel, void *ptr)
 Try handle message safely, catching certain exceptions.
 
virtual long onDefault (FXObject *, FXSelector, void *)
 Called for unhandled messages.
 
virtual void save (FXStream &store) const
 Save object to stream.
 
virtual void load (FXStream &store)
 Load object from stream.
 
virtual ~FXObject ()
 Virtual destructor.
 

Protected Attributes

void * data
 
FXObjecttarget
 
FXSelector message
 
FXuint type
 

Detailed Description

A Data Target allows a widget to be directly connected with a associated variable, without any additional "glue code".

This connection is bi-directional: widgets can not only only change the associated variable, but also query the associated variable, and reflect its value in the widget.

The value of the associated variable is changed by the data target when it receives a SEL_COMMAND or SEL_CHANGED message from the widget. Conversely, the widget's state may be updated from the data target's associated variable when the it receives a SEL_UPDATE query message from the widget.

Valuator widgets should send an ID_VALUE message to the data target. When a data target receives the ID_VALUE message, it will obtain the value of the sending valuator widget by querying it with a ID_GETINTVALUE, ID_GETLONGVALUE, ID_GETREALVALUE, or ID_GETSTRINGVALUE message, depending on the type of the associated variable.

Radio Buttons, Menu Commands, and so on can also be connected to a data target. In this case, the widget must send an ID_OPTION+i message; the value of the associated variable will be obtained from the message itself, by simply subtracting ID_OPTION from the message ID, that is to say, the value will be i (-10000 <= i <= 10000).

Updating of widgets from the data target is performed when the widget sends the data target a SEL_UPDATE message. For ID_VALUE update queries, the data target responds with ID_SETINTVALUE, ID_SETLONGVALUE, ID_SETREALVALUE, or ID_SETSTRINGVALUE depending on the type of the associated variable. For ID_OPTION+i update queries, the data target responds with a ID_CHECK or ID_UNCHECK depending on whether the connected variable's value is equal to i or not.

A data target may be subclassed to handle additional, user-defined data types; to this end, the message handlers return 1 if the type is one of DT_VOID...DT_STRING and 0 otherwise.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
ID_OPTION 

Will cause the FXDataTarget to ask sender for value.

ID_LAST 

ID_OPTION+i will set the value to i where -10000<=i<=10000.


The documentation for this class was generated from the following file:

Copyright © 1997-2022 Jeroen van der Zijp