WinDom: Resource Library

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

# Resource Library
[Reference documentation]

Using external and internal resource file. More...

## Defines
#define | mt_RsrcFree(app) mt_rsrc_free(app->aes_global)
| Release from memory resource file loaded by mt_RsrcLoad().
#define | RsrcFree() mt_rsrc_free(gl_appvar->aes_global)
| See mt_RsrcFree().
## Functions
int | mt_RsrcLoad (APPvar *app, const char *name)
| Load a resource file in memory.
void | mt_RsrcXtype (APPvar *app, int mode, OBJECT **rs_trindex, int num_tree)
| Install/remove WinDom extended objects.
void | mt_RsrcFixCicon (APPvar *app, OBJECT *object, int num_obs, int num_cib, INT16 palette[][4], void *fix)
| Fix color icons to the current screen resolution.
void | mt_RsrcFreeCicon (APPvar *app, void *fix)
| Release from memory fixed color icons.
int | mt_RsrcUserDraw (APPvar *app, int mode, WINDOW *win, int __index, func_userdraw draw, void *data)
| associate a drawing function to an objet formular
void * | mt_RsrcXload (APPvar *app, const char *name)
| load multiple extended GEM resource file.
void | mt_RsrcXfree (APPvar *app, void *rsc)
| Release memory allocated by mt_RsrcXload().
int | mt_RsrcGaddr (APPvar *app, void *rsc, int type, int __index, void *addr)
| retrieve an address object from a loaded resource file.
rscHDR * | mt_RsrcGhdr (APPvar *app, void *rsc)
| return the header of the RSC

## Detailed Description

Using external and internal resource file.

## Define Documentation

#define mt_RsrcFree | ( | app |  | ) | mt_rsrc_free(app->aes_global)

| Release from memory resource file loaded by mt_RsrcLoad().

#define RsrcFree | (
|  | ) | mt_rsrc_free(gl_appvar->aes_global)

| See mt_RsrcFree().

## Function Documentation

void mt_RsrcFixCicon | ( | APPvar * | app,
|  | OBJECT * | object,
|  | int | num_obs,
|  | int | num_cib,
|  | INT16 | palette[][4],
|  | void * | _fix
| ) |

  | Fix color icons to the current screen resolution. Parameters:
  | app | application descriptor,
  | object | pointer to an objects tree,
  | num_obs | number of objects in object,
  | num_cib | number of color icons in object,
  | palette | color palette,
  | _fix | pointer to a structure containing the fixed icons.
mt_RsrcFixCicon() fixes the color icons to the current resolution. When a resource file is loaded by mt_RsrcLoad(), color icon are fixed by AES. mt_RsrcXload() fixes icon colors too. The parameter palette is optional and can be set to NULL. This parameter is provided by the RSH file (created by resource editor program). After the call of mt_RsrcFixCicon(), the structure _fix is filled with the fixed icon and will be released by calling mt_RsrcFreeCicon(). See also: mt_RsrcFreeCicon().

void mt_RsrcFreeCicon | ( | APPvar * | app,
|  | void * | _fix
| ) |

  | Release from memory fixed color icons. Parameters:
  | app | application descriptor,
  | _fix | pointer filled in by mt_RsrcFixCicon().
See also: mt_RsrcFixCicon()

int mt_RsrcGaddr | ( | APPvar * | app,
|  | void * | _rsc,
|  | int | type,
|  | int | index,
|  | void * | addr
| ) |

  | retrieve an address object from a loaded resource file. Parameters:
  | app | application descriptor,
  | _rsc | resource descriptor or NULL
  | type | type of object to retrieval. Possible values are: R_TREE object tree (pointer to array of OBJECT) R_OBJECT individual object (pointer to OBJECT) R_TEDINFO TEDINFO structure R_ICONBLK ICONBLK structure R_BITBLK BITBLK structure R_STRING, R_FRSTR free string R_IMAGEDATA, FRIMG free image data R_OBSPEC ob_spec field within OBJECTs R_TEPTEXT te_ptext field within TEDINFOs R_TEPTMPLT te_ptmplt field within TEDINFOs R_TEPVALID te_pvalid field within TEDINFOs R_IBPMASK ib_pmask field within ICONBLKs R_IBPDATA ib_pdata field within ICONBLKs R_BIPDATA bi_pdata field within ICONBLKs
  | index | object index to retrieval,
  | addr | address of object,
Returns: 0 or negative code error. mt_RsrcGaddr() has the same action than mt_rsrc_gaddr() on resource loaded by mt_RsrcXload(). Parameter _rsc is a value returned by mt_RsrcXload(). If parameter _rsc is NULL, mt_RsrcGaddr() retreivals object from resource loaded by mt_RsrcLoad(). See also: mt_RsrcXload(), mt_RsrcLoad().

rscHDR* mt_RsrcGhdr | ( | APPvar * | app,
|  | void * | rsc
| ) |

  | return the header of the RSC Parameters:
  | app | application descriptor,
  | rsc | pointer to a resource descriptor,
Returns: address of resource header, or NULL if an error occurs. mt_RsrcGhdr() returns the header of a resource loaded by mt_RsrcXload(). The header is a rscHDR structure (defined in windom.h) containing some information about the resource.
    typedef struct {
      long      nobs;   // number of OBJECT items
      long      ntree;  // number of tree OBJECT
      long      nted;   // number of TEDINFO items
      long      ncib;   // number of CICON items
      long      nib;
      long      nbb;
      long      nfstr;  // number of string items
      long      nfimg;  // number of IMAGE items
      OBJECT    *object; // address of OBJECTS
      TEDINFO   *tedinfo; // address of TEDINFO
      ICONBLK   *iconblk; // address of ICONBLK
      BITBLK    *bitblk;  // address of BITBLK
      CICON     *cicon;   // address of CICON
      CICONBLK  *ciconblk; // table of CICONBLK
      char      **frstr;
      BITBLK    **frimg;
      OBJECT    **trindex;  // address of tree OBJECTS
      } rscHDR;
     *
See also: mt_RsrcXload()

int mt_RsrcLoad | ( | APPvar * | app,
|  | const char * | name
| ) |

  | Load a resource file in memory. Parameters:
  | app | application descriptor,
  | name | GEM resource file name to load.
Returns: 0 if an error occured, 1 otherwise. mt_RsrcLoad() replaces the AES mt_rsrc_load() function. The resource filename can be in a TOS format (e.g. with backslash characters) or MiNT format (e.g. with slash characters). mt_RsrcLoad() uses conv_path() to make the convertion. mt_RsrcLoad() fills in the app->ntree variable with the number of tree contained in the resource file. Trick : mt_RsrcLoad() use PATH environment variable to locate resource file. See also: mt_RsrcFree(), mt_RsrcXload()

int mt_RsrcUserDraw | ( | APPvar * | app,
|  | int | mode,
|  | WINDOW * | win,
|  | int | index,
|  | func_userdraw | draw,
|  | void * | data
| ) |

  | associate a drawing function to an objet formular Parameters:
  | app | application descriptor,
  | mode | OC_FORM or OC_TOOLBAR,
  | win | window descriptor,
  | index | object index,
  | draw | address of drawing function,
  | data | address of an user data,
Returns: a negative code error or 0 otherwise. mt_RsrcUserDraw() attaches a drawing function to an object. AES will call the function draw() to draw the object. Refer to the documentation of the func_userdraw type for a description of the userdef callback function interface. See also: mt_RsrcXtype(), func_userdraw.

void mt_RsrcXfree | ( | APPvar * | app,
|  | void * | rsc
| ) |

  | Release memory allocated by mt_RsrcXload(). Parameters:
  | app | application descriptor,
  | rsc | pointer to resource structure (provided by mt_RsrcXload()),
See also: mt_RsrcXload().

void* mt_RsrcXload | ( | APPvar * | app,
|  | const char * | name
| ) |

  | load multiple extended GEM resource file. Parameters:
  | app | application descriptor,
  | name | GEM resource file name to load.
Returns: a pointer to a ressource descriptor in memory or NULL if an error occurs. As mt_RsrcLoad(), mt_RsrcXload() load in memory a resource file. The difference is RsrcXload() can load severals resource file. In addition ,RsrcXload() can load extended resource files (as specified by AES 3.4) on all TOS system. mt_RsrcXload() use the PATH environment variable to locate the resource file (in this case, the filename should not be a pathname). The function returns a pointer which identify the resource or a NULL value if an error occurs. The pointer must be kept in memory because it is used by mt_RsrcGaddr() to get an object address in resource and it is used by mt_RsrcXfree() to release resource memory. Icons colors are automatically fixed by mt_RsrcXload() using mt_RsrcFixCicon() and transformed into a XCICON extended type. Due to this, color icons are displaying on any TOS version. To access to ICONBLK structure of a XCICON object, use the macro GET_XCICON(). Example
     {
      void *rsc1, *rsc2;
      OBJECT *tree;
      // Loads resources
      rsc1 = RsrcXload( "myrsc1.rsc");
      rsc2 = RsrcXload( "myrsc2.rsc");
      // Get an object
      RsrcGaddr( rsc1, R_TREE, FORM1, &tree);
      ...
      RsrcXfree( rsc2);
      RsrcXfree( rsc1);
    }
See also: mt_RsrcXfree(), mt_RsrcGaddr(), mt_RsrcLoad().

void mt_RsrcXtype | ( | APPvar * | app,
|  | int | mode,
|  | OBJECT ** | trindex,
|  | int | num_tree
| ) |

  | Install/remove WinDom extended objects. Parameters:
  | app | application descriptor,
  | mode | possible values are : RSRC_XTYPE : install extended objects (for objects having an extended type), RSRC_X3D : install extended object for all objects, RSRC_XALL : RSRC_XTYPE + RSRC_X3D, 0 : uninstall extended objects.
  | trindex | address of object tree array or NULL,
  | num_tree | number of object tree in trindex.
mt_RsrcXtype() installs or removes WinDom extended objects. It can work on internal resource, loaded by mt_RsrcLoad() or mt_RsrcXload(), or on external resource, included in the C-source during the compilation. An WinDom extended object is an object having a special value in ob_type field of the OBJECT structure. The low byte of ob_type is used by AES to identify the type of object (button, box, text, ...). The high byte is not read by AES. WinDom uses it to specify new objects. mt_RsrcXtype() transform theses objects into a G_USERDEF objects or insersly can restore objects previously transformed. The mode parameter describes the action to perform. Mode RSRC_XTYPE installs extended type for objects having an extended type. There is a second mode, RSRC_X3D, which installs new object types with a 3D look for all objects. The goal of this mode is to allow your dialog boxes to have the same aspect with MagiC, Naes, TOS or any other GEM system. Addressed objects are buttons and boxes (!U)without extended types(!u). And off course, these two modes can be cumulated (mode RSRC_XALL). To fix the objects in the internal resource, the trindex parameter must set to NULL and the trindex parameter is not used. To fix an external resource, the trindex parameter should be filled with the address of object trees in the resource. This address is supplied with the RSH file created by your resource editor. The RSH file must be include in your source code with an `#include` directive. The num_tree value is also supplied with the RSH file. When the application finishes, extended objects should be freed by a call to RsrcXtype() with mode 0.