swk

static widget kit
git clone git://git.suckless.org/swk
Log | Files | Refs | README | LICENSE

commit a0e35a79ba83c7146791f474aeddb2ee0abf9878
parent ed732914f2977b61230b569e9aed9ecbe29bc69e
Author: pancake <pancake@nopcode.org>
Date:   Mon, 26 Apr 2010 00:31:30 +0200

initial implementation of swk_option widget
Diffstat:
swk.c | 25+++++++++++++++++++++++++
swk.h | 1+
test.c | 8++++++++
3 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/swk.c b/swk.c @@ -295,3 +295,28 @@ void swk_filler(SwkEvent *e) { /* empty widget */ } + +void +swk_option(SwkEvent *e) { + Rect r; + switch(e->type) { + case EClick: + if(e->box==e->box->data) + e->box->data = NULL; + else e->box->data = e->box; + break; + case EExpose: + r = e->box->r; + r.w = r.h = 1; + if(e->box==e->box->data) + swk_gi_fill(r, ColorFG); + else swk_gi_rect(r, ColorFG); + if(e->win->box == e->box) + swk_gi_line(r.x, r.y+1, r.w, 0, ColorHI); + r.x+=2; + swk_gi_text(r, e->box->text); + break; + default: + break; + } +} diff --git a/swk.h b/swk.h @@ -91,6 +91,7 @@ void swk_label(SwkEvent *e); void swk_entry(SwkEvent *e); void swk_password(SwkEvent *e); void swk_filler(SwkEvent *e); +void swk_option(SwkEvent *e); /* graphic backend */ diff --git a/test.c b/test.c @@ -29,6 +29,9 @@ static SwkBox helloworld[] = { { .cb=mybutton, .text="yes" }, { .cb=mybutton, .text="no" }, { .cb=swk_filler, }, + SWK_BOX_NEWLINE(1), + { .cb=swk_option, .text="remember values", }, + { .cb=swk_option, .text="pasta barata", }, SWK_BOX_NEWLINE(5), { .cb=swk_label, .text="--swktest", }, { .cb=NULL } @@ -40,6 +43,11 @@ main() { .title="Hello World", .boxes=helloworld, .box=helloworld+10 +/* + // TODO: application workflow + .ok=cb + .cancel=cb +*/ }; if(!swk_init(&w)) return 1;