Labels


A number of objects like buttons, edit-boxes, containers, etc. may have a text label. This label may primarly contain the text to be shown on the surface of the object in a manner that is useful (e.g. the edit-box will put it to the left of the input field, but the container will put it at top as a header).

The label must not necessarily be static or constant memory, the object will make a copy of the text. Labelled objects will adapt thier size to the size of the text.

The label may be extended with additional information.

If you need to actually draw any of the above control-characters - just type them twice in the string.
See also: AddButton, MkMenuItem, AddIcon, Req.
int CguiLoadImage(const char *filename, const char *imagename, int type, int id);

This function loads an image with name `imagename' from file `filename'.
Why? - The image as well as its name will be registered in the CGUI system which means: An image associated with a node may be referred from objects that are put into that node (at any depth). I.e. if `id' is a window, any object put into that window can use that image, or if `id' is a container, any object put into that container can use it. Also all objects of a sub-window can use the images of a parent window.
If you want to make an image `global' (i.e. it will remain in memory until CGUI is shut down), just pass 0 for `id'.
Loading images from 8-bit colour files to a screen mode of 8-bit colour will only work properly if all pictures uses one common palette. Loading 8-bit colour files into high colour or true colour modes will work properly only if transparent colour is not used. The same limitation applies to the reverse (high -> 8).
In short: to avoid problems use 24-bits files, and at least 15 bit colour-depth on the screen.

Parameters:

Return value: The id of the node where the image is stored if sucessful othewise -1.
See also: RegisterImage, ScrMode, GetRegisteredImage.
int RegisterImage(void *data, const char *imagename, int type, int id);

Works analogous to `CguiLoadImage' but registers an image that is already in memory. `RegisterImage' will not make a copy of `bmp' so it must not be freed or reallocated as long as it is in use (i.e. as long as object id is not destroyed).
In contrary to images loaded from file the registered ones will not be automaticallay adjusted when CGUI dialogue for changeing the screen settings are used.
The `type' parameter shall be either of the IMAGE_* values meaning: Call `RegisterImage' with NULL for `data' if you want to unregister a previously registered image (the name is your handle). You can also replace a previous registration by subsequent calls to `RegisterImage' using the same name. This can be used to make simple animations on objects (which includes plain image objects like those made by `AddTag'), see also the examples.
Return value: 0 if it failed (i.e. unknown type, unknown id), else 1.
See also: CguiLoadImage, GetRegisteredImage.
const void *GetRegisteredImage(const char *imagename, int *type, int id);

Returns a pointer to an image with name `imagename' in node `id' that has previously been registered by `RegisterImage' or `CguiLoadImage'. The integer pointed to by `type' will be set to the type of the image, see IMAGE_* macros. The type of the returned pointer corresponds to the type value.
See also: RegisterImage, CguiLoadImage.

Back to contents