summaryrefslogtreecommitdiffstats
path: root/src/tk/check.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tk/check.c')
-rw-r--r--src/tk/check.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/tk/check.c b/src/tk/check.c
index 0b2ea56..b24db0b 100644
--- a/src/tk/check.c
+++ b/src/tk/check.c
@@ -20,6 +20,7 @@
#include <SDL.h>
#include <math.h>
#include "../tk.h"
+#include "style.h"
#include "widget.h"
struct mftk_check {
@@ -27,8 +28,6 @@ struct mftk_check {
enum mftk_check_shape shape;
int butn_width;
int butn_padding;
- SDL_Color *butn_color;
- SDL_Color *mark_color;
int state;
int label_padding;
struct mftk_widget *label;
@@ -38,6 +37,15 @@ struct mftk_check {
void *user_data;
};
+static SDL_Color _mftk_check_butn_color = {
+ .r = MFTK_COLOR_CHKB_R, .g = MFTK_COLOR_CHKB_G,
+ .b = MFTK_COLOR_CHKB_B, .a = MFTK_COLOR_CHKB_A
+};
+static SDL_Color _mftk_check_mark_color = {
+ .r = MFTK_COLOR_CHKM_R, .g = MFTK_COLOR_CHKM_G,
+ .b = MFTK_COLOR_CHKM_B, .a = MFTK_COLOR_CHKM_A
+};
+
void
mftk_check_set_shape(struct mftk_widget *w, enum mftk_check_shape shape)
{
@@ -220,11 +228,13 @@ _mftk_check_render(struct mftk_widget *w, SDL_Renderer *renderer, int x, int y)
rect.w = c->butn_width;
rect.h = c->butn_width;
if (c->shape == MFTK_CHECK_SHAPE_BOX) {
- if (_mftk_check_render_box(&rect, c->butn_color, renderer) < 0){
+ if (_mftk_check_render_box(&rect, &_mftk_check_butn_color,
+ renderer) < 0) {
e = -1;
}
} else {
- if (_mftk_check_render_cir(&rect, c->butn_color, renderer) < 0){
+ if (_mftk_check_render_cir(&rect, &_mftk_check_butn_color,
+ renderer) < 0) {
e = -1;
}
}
@@ -235,12 +245,14 @@ _mftk_check_render(struct mftk_widget *w, SDL_Renderer *renderer, int x, int y)
rect.w -= c->butn_padding * 2;
rect.h -= c->butn_padding * 2;
if (c->shape == MFTK_CHECK_SHAPE_BOX) {
- if (_mftk_check_render_box(&rect, c->mark_color,
+ if (_mftk_check_render_box(&rect,
+ &_mftk_check_mark_color,
renderer) < 0) {
e = -1;
}
} else {
- if (_mftk_check_render_cir(&rect, c->mark_color,
+ if (_mftk_check_render_cir(&rect,
+ &_mftk_check_mark_color,
renderer) < 0) {
e = -1;
}
@@ -266,19 +278,17 @@ _mftk_check_destroy(struct mftk_widget *w)
}
struct mftk_widget *
-mftk_check_new(int butn_width, int butn_padding, SDL_Color *butn_color,
- SDL_Color *mark_color, int state, int label_padding,
- TTF_Font *font, const char *text, SDL_Color *text_color,
- int (*action)(void *, int), int (*submit)(void *),
- void *user_data, SDL_Renderer *renderer)
+mftk_check_new(int butn_width, int butn_padding, int state, int label_padding,
+ TTF_Font *font, const char *text, int (*action)(void *, int),
+ int (*submit)(void *), void *user_data, SDL_Renderer *renderer)
{
struct mftk_widget *w;
struct mftk_check *c;
mftk_widget_init_focusable(w, c, check);
- if (font != NULL && text != NULL && text_color != NULL) {
- c->label = mftk_label_new(font, text, text_color, renderer);
+ if (font != NULL && text != NULL) {
+ c->label = mftk_label_new(font, text, renderer);
if (c->label == NULL) {
free(c);
return NULL;
@@ -288,8 +298,6 @@ mftk_check_new(int butn_width, int butn_padding, SDL_Color *butn_color,
c->shape = MFTK_CHECK_SHAPE_BOX;
c->butn_width = butn_width;
c->butn_padding = butn_padding;
- c->butn_color = butn_color;
- c->mark_color = mark_color;
c->state = state;
c->label_padding = label_padding;
c->steals_focus = SDL_TRUE;