component* textbutton_create(const text_settings *tconf, const char *text, int disabled, textbutton_click_cb cb, void *userdata) { component *c = widget_create(); component_disable(c, disabled); textbutton *tb = malloc(sizeof(textbutton)); memset(tb, 0, sizeof(textbutton)); tb->text = strdup(text); memcpy(&tb->tconf, tconf, sizeof(text_settings)); tb->click_cb = cb; tb->userdata = userdata; widget_set_obj(c, tb); widget_set_render_cb(c, textbutton_render); widget_set_action_cb(c, textbutton_action); widget_set_tick_cb(c, textbutton_tick); widget_set_free_cb(c, textbutton_free); return c; }
component* spritebutton_create(const text_settings *tconf, const char *text, surface *img, int disabled, spritebutton_click_cb cb, void *userdata) { component *c = widget_create(); component_disable(c, disabled); spritebutton *sb = malloc(sizeof(spritebutton)); memset(sb, 0, sizeof(spritebutton)); if(text != NULL) sb->text = strdup(text); memcpy(&sb->tconf, tconf, sizeof(text_settings)); sb->click_cb = cb; sb->img = img; sb->userdata = userdata; widget_set_obj(c, sb); widget_set_render_cb(c, spritebutton_render); widget_set_action_cb(c, spritebutton_action); widget_set_tick_cb(c, spritebutton_tick); widget_set_free_cb(c, spritebutton_free); return c; }