From: ewt Date: Mon, 17 Jun 1996 15:14:58 +0000 (+0000) Subject: Keeps data with listbox items, allows changing of text in listbox item X-Git-Tag: 0-1~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=bf9c535d1f6583c77e5b9aae40176dd44dd4fc55;p=thirdparty%2Fnewt.git Keeps data with listbox items, allows changing of text in listbox item --- diff --git a/checkbox.c b/checkbox.c index eac2866..74a6e79 100644 --- a/checkbox.c +++ b/checkbox.c @@ -15,6 +15,7 @@ struct checkbox { enum type type; char value; int active, inactive; + void * data; }; static void cbDrawIt(newtComponent c, int active); @@ -31,7 +32,7 @@ static struct componentOps cbOps = { } ; newtComponent newtListitem(int left, int top, char * text, int isDefault, - newtComponent prevItem) { + newtComponent prevItem, void * data) { newtComponent co; struct checkbox * li; @@ -41,10 +42,27 @@ newtComponent newtListitem(int left, int top, char * text, int isDefault, li->inactive = COLORSET_LISTBOX; li->active = COLORSET_ACTLISTBOX; + li->data = data; return co; } +void * newtListitemGetData(newtComponent co) { + struct checkbox * rb = co->data; + + return rb->data; +} + +void newtListitemSet(newtComponent co, char * text) { + struct checkbox * li = co->data; + + free(li->text); + li->text = strdup(text); + + if (strlen(text) + 4 > co->width) + co->width = strlen(text) + 4; +} + newtComponent newtRadiobutton(int left, int top, char * text, int isDefault, newtComponent prevButton) { newtComponent co;