Other Pixmap Routines (XForms (Forms Library) - Version 1.2 (Rev. 4) A Graphical User Interface Toolkit for X)

Next: Pixmap Attributes, Previous: Pixmap Interaction, Up: Pixmap Object [Contents][Index]

#### 15.6.4 Other Pixmap Routines

A pixmap file (usually with extension `.xpm`) is an ASCII file that contains the definition of the pixmap as a `char` pointer array that can be included directly into a C (or C++) source file.

To set the actual pixmap being displayed, use one of the following routines:

    void fl_set_pixmap_file(FL_OBJECT *obj, const char *file);
    void fl_set_pixmap_data(FL_OBJECT *obj, char **data);

In the first routine, you specify the pixmap by the filename `file` that contains it. In the second routine, you `#include` the pixmap at compile time and use the pixmap data (an array of `char` pointers) directly. Note that both of these functions do not free the old pixmaps associated with the object. If you’re writing a pixmap browser type applications, be sure to free the old pixmaps by calling

    void fl_free_pixmap_pixmap(FL_OBJECT *obj);

on the pixmap object prior to calling these two routines. This function, in addition to freeing the pixmap and the mask, also frees the colors the pixmap allocated.

To obtain the pixmap ID currently being displayed, the following routine can be used

    Pixmap fl_get_pixmap_pixmap(FL_OBJECT *obj, Pixmap *id,
                                Pixmap *mask);

In some situations, you might already have a pixmap resource ID, e.g., from `fl_read_pixmapfile()` (see below in the "Remarks" subsection). Then you can use the following routine to change the the pixmap

    void fl_set_pixmap_pixmap(FL_OBJECT *obj, Pixmap id,
                              Pixmap mask);

where `mask` is used for transparency (see `fl_read_pixmapfile()`). Use 0 for mask if no special clipping attributes are desired.

This routine does not free the pixmap ID nor the mask already associated with the object. Thus if you no longer need the old pixmaps, they should be freed prior to changing the pixmaps using the function `fl_free_pixmap_pixmap()`.

Pixmaps are by default displayed centered inside the bounding box. However, this can be changed using the following routine

    void fl_set_pixmap_align(FL_OBJECT *obj, int align,
                             int dx, int dy);

where `align` is the same as that used for labels, see Label Attributes and Fonts for a list. `dx` and `dy` are extra margins to leave in addition to the object border width. By default, `dx` and `dy` are set to 3. Note that although you can place a pixmap outside of the bounding box, it probably is not a good idea.

Next: Pixmap Attributes, Previous: Pixmap Interaction, Up: Pixmap Object [Contents][Index]