WinDom: Component Library

- Main Page
- Modules
- Data Structures
- Files
- Related Pages

# Component Library
[Reference documentation]

Group of functions to manage COMPONENTs. More...

## Data Structures
struct | _component
| The WinDom COMPONENT representation structure. More...
struct | _sliderinfo
struct | _component
| The WinDom COMPONENT representation structure. More...
## Defines
#define | CPNT_MAXSIZE (LONG_MAX)
#define | CLT_VERTICAL 0
| COMPONENT layout type values.
#define | CLT_HORIZONTAL 1
#define | CLT_STACK 2
#define | CS_INTERACTIVE 0x0010
| COMPONENT status bitmask values. can get CM_GETFOCUS and CM_LOSEFOCUS.
#define | CS_HSLIDE 0x0020
#define | CS_VSLIDE 0x0040
#define | CS_HIDDEN 0x0080
#define | CS_CLIP 0x0100
#define | CS_PROPORTIONAL 0x0200
| visible contents proportions changes (needs redraw) on resize
#define | CS_RESERVED 0x00010000UL
| internal: reserved for internal use
#define | CS_FOCUSED 0x00020000UL
| internal: COMPONENT is currently under focus
#define | CS_IN_USE 0x00080000UL
| internal: COMPONENT is in use: should not be free-ed (see mt_CompDelete())
#define | CS_DESTROYED 0x00040000UL
| internal: COMPONENT should be free-ed as soon as possible
#define | CM_GETFOCUS 0x44c0
| COMPONENT special messages. received upon getting focus.
#define | CM_LOSEFOCUS 0x44c1
| received upon losing focus
#define | CM_REFLOW 0x44c2
| reflow the component according to the layout settings
#define | CM_REPOSED 0x44c3
| move&resize the component
#define | CF_WINDOW 0x44e0
| COMPONENT special messages. the WINDOW the component is hooked to or NULL if none.
#define | CF_MAXSIZE 0x44e1
| fixed maximum size rectagle FIXME: rename?
#define | CF_HSLIDE 0x44d0
| FIXME: TODO.
#define | CF_VSLIDE 0x44d1
| FIXME: TODO.
#define | CF_FOCUS 0x44d2
| Focus component pointer.
#define | WD_CCRT 0x43435254L
| COMPONENT/WINDOW relation magic values. 'CCRT': component container's root win/component component/window.
#define | WD_CCWD 0x43435744L
| 'CCWD': component window/window component
#define | WD_CWGT 0x43573743L
| 'CWGT': window widget component
#define | FOR_EACH_CHILD(i, list)
#define | CDT_SLIDER_POS 0x455f4dUL
#define | CDT_SLIDER_SIZE 0x455f4eUL
#define | CDT_SLIDER_CONTROL 0x455f4fUL
#define | WD_CPNT_HSLIDE_INFO 0x43485349L
| COMPONENT slider data magic data defines.
#define | WD_CPNT_VSLIDE_INFO 0x43565349L
#define | VSLIDERINFO(app, c) ((C_SLIDERINFO*)mt_CompDataSearch( app, c, WD_CPNT_VSLIDE_INFO))
#define | HSLIDERINFO(app, c) ((C_SLIDERINFO*)mt_CompDataSearch( app, c, WD_CPNT_HSLIDE_INFO))
## Typedefs
typedef _component | COMPONENT
typedef void __CDECL(* | func_comp_evntdata )(COMPONENT *, long buff[8], void *, APPvar *app)
typedef void __CDECL(* | func_comp_evnt )(COMPONENT *, long buff[8], APPvar *app)
typedef _sliderinfo | C_SLIDERINFO
## Functions
COMPONENT * | mt_CompCreate (APPvar *app, short type, long size, short flex)
| Create a COMPONENT.
COMPONENT * | mt_CompFind (APPvar *app, COMPONENT *p, short mx, short my)
int | mt_CompDelete (APPvar *app, COMPONENT *p)
| Delete a COMPONENT created by mt_CompCreate().
void | mt_CompAttach (APPvar *app, COMPONENT *p, COMPONENT *c)
| Attach a COMPONENT as children of an another COMPONENT.
int | mt_CompDataAttach (APPvar *app, COMPONENT *c, long magic, void *data)
| Insert data into the component data list.
int | mt_CompDataDelete (APPvar *app, COMPONENT *c, long magic)
| Remove a data linked into a component.
void * | mt_CompDataSearch (APPvar *app, COMPONENT *c, long magic)
| Component magic value data search.
int | mt_CompSet (APPvar *app, COMPONENT *c, short type, long par1, long par2, long par3, long par4)
int | mt_CompSetPtr (APPvar *app, COMPONENT *c, short mode, void *par1, void *par2)
int | mt_CompGetLGrect (APPvar *app, COMPONENT *c, short type, LGRECT *rect)
void * | mt_CompGetPtr (APPvar *app, COMPONENT *c, short type)
int | mt_CompEvntAdd (APPvar *app, COMPONENT *p, short msg, func_comp_evnt proc, int mode)
| TODO: DOCS.
int | mt_CompEvntDataAdd (APPvar *app, COMPONENT *c, short msg, func_comp_evntdata proc, void *data, int mode)
| TODO: DOCS.
int | mt_CompEvntAttach (APPvar *app, COMPONENT *p, short msg, func_comp_evnt proc)
| TODO: DOCS.
int | mt_CompEvntDataAttach (APPvar *app, COMPONENT *c, short msg, func_comp_evntdata proc, void *data)
| TODO: DOCS.
int | mt_CompEvntExec (APPvar *app, COMPONENT *p, long buff[8])
| TODO: DOCS.
void | mt_CompEvntClear (APPvar *app, COMPONENT *c)
| TODO: DOCS.
int | mt_CompEvntRemove (APPvar *app, COMPONENT *c, int msg, void *proc)
| TODO: DOCS.
int | mt_CompEvntDelete (APPvar *app, COMPONENT *c, int msg)
| TODO: DOCS.
void | mt_CompEvntEnable (APPvar *app, COMPONENT *c, int msg)
| Enable all callback functions bound to an event.
void | mt_CompEvntDisable (APPvar *app, COMPONENT *c, int msg)
| Disable all callback functions bound to an event.
void | mt_CompEvntRedraw (APPvar *app, COMPONENT *c)
void | mt_CompEvntRedrawLGrect (APPvar *app, COMPONENT *c, LGRECT *rdraw)
int | mt_CompSliderAttach (APPvar *app, COMPONENT *p, short type)
| Define a COMPONENT to become slidable.

## Detailed Description

Group of functions to manage COMPONENTs.

This is quite experimental at the moment, but we need feedback to stabilise the component API, so don't hesitate to give it a try, and moreover to stress this API !

## Define Documentation

#define CDT_SLIDER_CONTROL 0x455f4fUL

#define CDT_SLIDER_POS 0x455f4dUL

#define CDT_SLIDER_SIZE 0x455f4eUL

#define CF_FOCUS 0x44d2

| Focus component pointer.

#define CF_HSLIDE 0x44d0

| FIXME: TODO.

#define CF_MAXSIZE 0x44e1

| fixed maximum size rectagle FIXME: rename?

#define CF_VSLIDE 0x44d1

| FIXME: TODO.

#define CF_WINDOW 0x44e0

| COMPONENT special messages. the WINDOW the component is hooked to or NULL if none.

#define CLT_HORIZONTAL 1

#define CLT_STACK 2

#define CLT_VERTICAL 0

| COMPONENT layout type values.

#define CM_GETFOCUS 0x44c0

| COMPONENT special messages. received upon getting focus.

#define CM_LOSEFOCUS 0x44c1

| received upon losing focus

#define CM_REFLOW 0x44c2

| reflow the component according to the layout settings

#define CM_REPOSED 0x44c3

| move&resize the component

#define CPNT_MAXSIZE (LONG_MAX)

#define CS_CLIP 0x0100

#define CS_DESTROYED 0x00040000UL

| internal: COMPONENT should be free-ed as soon as possible

#define CS_FOCUSED 0x00020000UL

| internal: COMPONENT is currently under focus

#define CS_HIDDEN 0x0080

#define CS_HSLIDE 0x0020

#define CS_IN_USE 0x00080000UL

| internal: COMPONENT is in use: should not be free-ed (see mt_CompDelete())

#define CS_INTERACTIVE 0x0010

| COMPONENT status bitmask values. can get CM_GETFOCUS and CM_LOSEFOCUS.

#define CS_PROPORTIONAL 0x0200

| visible contents proportions changes (needs redraw) on resize

#define CS_RESERVED 0x00010000UL

| internal: reserved for internal use

#define CS_VSLIDE 0x0040

#define FOR_EACH_CHILD | ( | i,
|  | list |  | ) |

| Value:
    listForEach( COMPONENT *, i, list ) \
            if ( !(((COMPONENT*)(i))->status & CS_HIDDEN) )

#define HSLIDERINFO | ( | app,
|  | c |  | ) | ((C_SLIDERINFO*)mt_CompDataSearch( app, c, WD_CPNT_HSLIDE_INFO))

#define VSLIDERINFO | ( | app,
|  | c |  | ) | ((C_SLIDERINFO*)mt_CompDataSearch( app, c, WD_CPNT_VSLIDE_INFO))

#define WD_CCRT 0x43435254L

| COMPONENT/WINDOW relation magic values. 'CCRT': component container's root win/component component/window.

#define WD_CCWD 0x43435744L

| 'CCWD': component window/window component

#define WD_CPNT_HSLIDE_INFO 0x43485349L

| COMPONENT slider data magic data defines.

#define WD_CPNT_VSLIDE_INFO 0x43565349L

#define WD_CWGT 0x43573743L

| 'CWGT': window widget component

## Typedef Documentation

typedef struct _sliderinfo C_SLIDERINFO

typedef struct _component COMPONENT

typedef void __CDECL(* func_comp_evnt)(COMPONENT *, long buff[8], APPvar *app)

typedef void __CDECL(* func_comp_evntdata)(COMPONENT *, long buff[8], void *, APPvar *app)

## Function Documentation

void mt_CompAttach | ( | APPvar * | app,
|  | COMPONENT * | p,
|  | COMPONENT * | c
| ) |

  | Attach a COMPONENT as children of an another COMPONENT. Parameters:
  | app | application descriptor,
  | p | parent component,
  | c | children component.
As one can see, COMPONENTs are hierarchical in a similar way to AES OBJECTS.

COMPONENT* mt_CompCreate | ( | APPvar * | app,
|  | short | type,
|  | long | size,
|  | short | flex
| ) |

  | Create a COMPONENT. Parameters:
  | app | application descriptor,
  | type | Component layout type : CLT_VERTICAL : a vertical layout, CLT_HORIZONTAL : an horizontal layout, CLT_STACK : a stack layout,
  | size | size of compoment, avalaible with CLT_VERTICAL and CLT_HORIZONTAL,
  | flex | flexibility of the component. 0 means fixed size.
See also: mt_CompDelete(). Note: If flex > 0 then the component status is set to CS_PROPORTIONAL.

int mt_CompDataAttach | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | long | magic,
|  | void * | data
| ) |

  | Insert data into the component data list. Parameters:
  | app | application descriptor,
  | c | component descriptor,
  | magic | magic number identifying data,
  | data | data to link.
Returns: A value of 0 on success, or 1 in the replacement case. Negative error code. In case the magic data is already present its value is replaced. See also: mt_CompDataSearch(), mt_CompDataDelete().

int mt_CompDataDelete | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | long | magic
| ) |

  | Remove a data linked into a component. Parameters:
  | app | application descriptor,
  | magic | magic number identifying data,
  | c | component descriptor.
Returns: a value of 0 on success or E_NOTFOUND when the magic data item is not found. Remove the magic data item from the component data list.

void* mt_CompDataSearch | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | long | magic
| ) |

  | Component magic value data search. Parameters:
  | app | application descriptor,
  | c | component descriptor to inspect,
  | magic | data magic number to search,
Returns: the data attached for the magic id, or NULL if not found. The same function than mt_DataSearch() related to COMPONENT instead of WINDOW. See also: mt_CompDataAttach(), mt_CompDataDelete().

int mt_CompDelete | ( | APPvar * | app,
|  | COMPONENT * | p
| ) |

  | Delete a COMPONENT created by mt_CompCreate(). This issues the WM_DESTROY event on the particular component and calls itself recursively on the children. After that it deletes and COMPONENT internal data and finally the `p` instance itself. Parameters:
  | app | application descriptor,
  | p | component to delete.

int mt_CompEvntAdd | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | short | msg,
|  | func_comp_evnt | proc,
|  | int | mode
| ) |

  | TODO: DOCS. Parameters:
  | app | application descriptor
  | c |
  | msg |
  | proc |
  | mode |

int mt_CompEvntAttach | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | short | msg,
|  | func_comp_evnt | proc
| ) |

  | TODO: DOCS. Parameters:
  | app | application descriptor
  | c |
  | msg |
  | proc |

void mt_CompEvntClear | ( | APPvar * | app,
|  | COMPONENT * | c
| ) |

  | TODO: DOCS. Parameters:
  | app | application descriptor
  | c |

int mt_CompEvntDataAdd | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | short | msg,
|  | func_comp_evntdata | proc,
|  | void * | data,
|  | int | mode
| ) |

  | TODO: DOCS. Parameters:
  | app | application descriptor
  | c |
  | msg |
  | proc |
  | data |
  | mode |

int mt_CompEvntDataAttach | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | short | msg,
|  | func_comp_evntdata | proc,
|  | void * | data
| ) |

  | TODO: DOCS. Parameters:
  | app | application descriptor
  | c |
  | msg |
  | proc |
  | data |

int mt_CompEvntDelete | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | int | msg
| ) |

  | TODO: DOCS. Parameters:
  | app | application descriptor
  | c |
  | msg |

void mt_CompEvntDisable | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | int | msg
| ) |

  | Disable all callback functions bound to an event. Parameters:
  | app | application descriptor,
  | c | component descriptor.
  | msg | event to disable.
mt_CompEvntDisable() disables an event : callback functions bound to this event will not be executed (by mt_CompEvntExec() then by mt_EvntWindom()). This function is used to disable an event temporarily. See also: mt_CompEvntExec(), mt_CompEventEnable().

void mt_CompEvntEnable | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | int | msg
| ) |

  | Enable all callback functions bound to an event. Parameters:
  | app | application descriptor,
  | c | target component
  | msg | event to enable.
mt_CompEvntEnable() enables an event previously disabled by mt_CompEvntDisable(). See also: mt_CompEvntExec(), mt_CompEventDisable().

int mt_CompEvntExec | ( | APPvar * | app,
|  | COMPONENT * | p,
|  | long | buff[8]
| ) |

  | TODO: DOCS. Parameters:
  | app | application descriptor
  | p |
  | buff |

void mt_CompEvntRedraw | ( | APPvar * | app,
|  | COMPONENT * | c
| ) |

void mt_CompEvntRedrawLGrect | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | LGRECT * | rdraw
| ) |

int mt_CompEvntRemove | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | int | msg,
|  | void * | proc
| ) |

  | TODO: DOCS. Parameters:
  | app | application descriptor
  | c |
  | msg |
  | proc |

COMPONENT* mt_CompFind | ( | APPvar * | app,
|  | COMPONENT * | p,
|  | short | mx,
|  | short | my
| ) |

int mt_CompGetLGrect | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | short | type,
|  | LGRECT * | rect
| ) |

void* mt_CompGetPtr | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | short | type
| ) |

int mt_CompSet | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | short | type,
|  | long | par1,
|  | long | par2,
|  | long | par3,
|  | long | par4
| ) |

int mt_CompSetPtr | ( | APPvar * | app,
|  | COMPONENT * | c,
|  | short | mode,
|  | void * | par1,
|  | void * | par2
| ) |

int mt_CompSliderAttach | ( | APPvar * | app,
|  | COMPONENT * | p,
|  | short | type
| ) |

  | Define a COMPONENT to become slidable. Parameters:
  | app | application descriptor,
  | p | targeted component,
  | type | type of slider to define : CS_HSLIDE defines an horizontal slider, CS_VSLIDE defines an vertical slider,
Returns: O or a negative code error otherwise.