[hackers] [swk] initial implementation of swk_option widget || pancake

From: <hg_AT_suckless.org>
Date: Sun, 25 Apr 2010 22:37:56 +0000 (UTC)

changeset: 18:e36d61a59af9
tag: tip
user: pancake <pancake_AT_nopcode.org>
date: Mon Apr 26 00:31:30 2010 +0200
files: swk.c swk.h test.c
description:
initial implementation of swk_option widget

diff -r 510dfb51a408 -r e36d61a59af9 swk.c
--- a/swk.c Mon Apr 26 00:13:21 2010 +0200
+++ b/swk.c Mon Apr 26 00:31:30 2010 +0200
@@ -295,3 +295,28 @@
 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 -r 510dfb51a408 -r e36d61a59af9 swk.h
--- a/swk.h Mon Apr 26 00:13:21 2010 +0200
+++ b/swk.h Mon Apr 26 00:31:30 2010 +0200
@@ -91,6 +91,7 @@
 void swk_entry(SwkEvent *e);
 void swk_password(SwkEvent *e);
 void swk_filler(SwkEvent *e);
+void swk_option(SwkEvent *e);
 
 /* graphic backend */
 
diff -r 510dfb51a408 -r e36d61a59af9 test.c
--- a/test.c Mon Apr 26 00:13:21 2010 +0200
+++ b/test.c Mon Apr 26 00:31:30 2010 +0200
@@ -29,6 +29,9 @@
         { .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 @@
                 .title="Hello World",
                 .boxes=helloworld,
                 .box=helloworld+10
+/*
+ // TODO: application workflow
+ .ok=cb
+ .cancel=cb
+*/
         };
         if(!swk_init(&w))
                 return 1;
Received on Sun Apr 25 2010 - 22:37:56 UTC

This archive was generated by hypermail 2.2.0 : Sun Apr 25 2010 - 22:48:04 UTC