Adding Data to Controls

OBJECTS

  typedef void (*ControlFunc)  (Control *c);

FUNCTIONS

  void  set_control_value(Control *c, long value);
  long  get_control_value(Control *c);

  void  set_control_data(Control *c, void *data);
  void *get_control_data(Control *c);

  void  on_control_action(Control *c, ControlFunc action);

  void  activate_control(Control *c);

NOTES

Every control can have a long integer value associated with it. Some controls, such as scrollbars and listboxes use this integer value to represent the current state of the control.

For programmer-defined controls, the set_control_value and get_control_value functions exist to allow setting this value, or finding the value.

If a control's state is more complex than an integer, more data must be stored with a control. The set_control_data function can store a pointer with a control, which could point to a data structure in memory. To find the value of this data pointer, use get_control_data. Note, this function returns the pointer as a void pointer so it is necessary to store this to the appropriate pointer type before use.

A control can have a call-back function associated with it for normal uses. This call-back is usually called by controls (such as buttons) whenever the user clicks on the control.

The function to be called can be set using the on_control_action function. This can be used to set or change a button's response to events.

The activate_control function will call a control's call-back (if the function pointer is not NULL, which it is by default).