generic API for widget rendering and styling; see: doc/ref/style.html

/* A stroke is typically a line or arc drawn with a pen that has a color and a width. The pen is often square-tip and width is interpreted as side length of the square. Tip shape and interpretation of width is defined by the style implementation. */ typedef struct mbtk_stroke_s { mbtk_color_t color; unsigned char width; } mbtk_stroke_t; /* A style implemenetation */ struct mbtk_style_s { /* Set a property of a style struct */ int (*getset_prop)(const mbtk_style_t *style, mbtk_styleprop_t *dst, mbtk_kw_t key, mbtk_arg_t *get, mbtk_arg_t *set); /* Return 0 and set the minimum size for rendering the specified widget; when returns -1, a widget-specific minsize funciton will need to be called instead */ int (*minsize)(const mbtk_style_t *style, mbtk_widget_t *w, long *mx, long *my); /* called to draw the base or overlay widget; first all bases are drawn then all overlays, recursively, from the root down in a BFS. If returns non-zero, the style has no idea how to draw the widget and the fallback mechanism should be invoked */ int (*draw_widget)(const mbtk_style_t *style, mbtk_widget_t *w); int (*draw_widget_overlay)(const mbtk_style_t *style, mbtk_widget_t *w); /* Low level draw functions: background rectangle and box frame; used by widget fallback draw functions */ void (*draw_box_frame)(mbtk_window_t *win, const mbtk_styleprop_t *sp, mbtk_widget_flags_t flg, long x, long y, long w, long h); void (*draw_box_overlay)(mbtk_window_t *win, const mbtk_styleprop_t *sp, mbtk_widget_flags_t flg, long x, long y, long w, long h); void (*draw_bg_rect)(mbtk_window_t *win, const mbtk_styleprop_t *sp, mbtk_widget_flags_t flg, long x, long y, long w, long h); void (*set_fg_color)(mbtk_window_t *win, const mbtk_styleprop_t *sp_, mbtk_widget_flags_t flg); void (*min_box_frame_size)(mbtk_window_t *win, const mbtk_styleprop_t *sp_, mbtk_widget_flags_t flg, long *left, long *right, long *top, long *bottom); long propsize; /* size of the opaque styleprop struct, in bytes */ }; /* Standard style prop field names */ extern mbtk_kw_t mbtk_kw_bg_color, mbtk_kw_bg_activated_color, mbtk_kw_fg_color; extern mbtk_kw_t mbtk_kw_hilight_color; extern mbtk_kw_t mbtk_kw_frame_width, mbtk_kw_text_halign, mbtk_kw_text_valign; /* Get or set style property. Return 0 on success. */ int mbtk_display_style_get_prop(mbtk_display_t *src, mbtk_kw_t key, mbtk_arg_t *dst); int mbtk_display_style_set_prop(mbtk_display_t *dst, mbtk_kw_t key, mbtk_arg_t value); int mbtk_style_get_prop(const mbtk_style_t *style, mbtk_styleprop_t *src, mbtk_kw_t key, mbtk_arg_t *dst); int mbtk_style_set_prop(const mbtk_style_t *style, mbtk_styleprop_t *dst, mbtk_kw_t key, mbtk_arg_t value);