#ifndef COMET_BUTTON_H #define COMET_BUTTON_H #include #include #include // For pointers only #define CAST(ptr, type) ((type *)ptr) typedef struct Button Button; typedef void (* ButtonAction)(Button *btn); typedef struct { double r, g, b, a; } Color; struct Button { bool simple; int padding; PangoAlignment align; Color color; Color line_color; }; typedef struct { Button btn; Color text_color; char *text; ButtonAction action; gpointer action_data; } ButtonSimple; typedef struct { Button btn; GList *children; } ButtonGroup; // NOTE: For the moment all button specific functions take a generic button // pointer and assert the right type, so the check should be done by the caller Button *button_simple_create(PangoAlignment align, Color color, Color line_color); // Takes ownership of text void button_simple_set_text(Button *btn, char *text, Color text_color); const char *button_simple_get_text(Button *btn); void button_simple_set_action(Button *btn, ButtonAction action, gpointer data); ButtonAction button_simple_get_action(Button *btn); Button *button_group_create(PangoAlignment align, Color color, Color line_color); void button_group_append(Button *btn, Button *child); void button_set_padding(Button *btn, int padding); void button_destroy(Button *btn); #endif // vim: ts=4 sw=4 et