Mbtk's PixMap

/* MPM is similar to XPM but always has alpha channel and can refer to style colors using $propname. Rendered MPMs are stored per display and are referenced by their "name" (mbtk_kw_t). Each named mpm is really a set of different renders for different style colors ("palettes"). */ typedef struct mbtk_mpm_render_s mbtk_mpm_render_t; typedef struct mbtk_mpm_styled_s mbtk_mpm_styled_t; struct mbtk_mpm_styled_s { const char **mpm; /* original input */ unsigned is_xpm:1; /* if original input is an XPM3 */ mbtk_mpm_render_t *head; /* singly linked list of the mpm redered to different color sets (per styleprops) */ }; struct mbtk_mpm_render_s { mbtk_pixmap_t pxm; struct { int len; /* number of pairs */ unsigned long *kw_clr; /* pairs of styleprop keyword and associated color embedded in this render */ } palette; mbtk_mpm_render_t *next; }; /* Register a new mpm without rendering it; returns 0 on success; error: already registered */ int mbtk_mpm_set(mbtk_display_t *display, mbtk_kw_t id, const char **mpm); int mbtk_xpm_set(mbtk_display_t *display, mbtk_kw_t id, const char **xpm); /* Render the named mpm for a given style and bind it to the window. Pixmaps are typically not unbound until the window is destroyed, assuming if a widget needed a pixmap+style combo once, it will need it again. If pxm_out is not NULL, it is loaded with the pointer to the cached rendered pixmap selected for style/sp. */ mbtk_px_id_t mbtk_mpm_get(mbtk_window_t *win, const mbtk_style_t *style, mbtk_styleprop_t *sp, mbtk_kw_t id, mbtk_pixmap_t **pxm_out); /* Return the first rendered pixmap for id; useful if metadata (like dimensions) is needed */ mbtk_pixmap_t *mbtk_mpm_get_first(mbtk_display_t *display, mbtk_kw_t id);

/*** Low level calls ***/

/* Color map format: [0] is the number of entries*2, [1] is unused, entries start from [2] and are kw + packed_color pairs */ int mbtk_draw_import_mpm(mbtk_display_t *display, const mbtk_style_t *style, mbtk_styleprop_t *sp, mbtk_pixmap_t *dst, unsigned long *dst_clrmap, const char **mpm); /* Import an XPM3 with 1 char per color */ int mbtk_draw_import_xpm(mbtk_display_t *display, mbtk_pixmap_t *dst, const char **xpm);