diff options
| author | Joel Bodenmann <joel@unormal.org> | 2013-07-27 15:23:52 +0200 | 
|---|---|---|
| committer | Joel Bodenmann <joel@unormal.org> | 2013-07-27 15:23:52 +0200 | 
| commit | 9dfcbef84884f67bb487dc02c642a03ca5d19e32 (patch) | |
| tree | fc0e06606745570342a19934f4bcdca210cce57c /src | |
| parent | 57eeb16aba2613c1329eafbf7d7453cd67f2cc69 (diff) | |
| download | uGFX-9dfcbef84884f67bb487dc02c642a03ca5d19e32.tar.gz uGFX-9dfcbef84884f67bb487dc02c642a03ca5d19e32.tar.bz2 uGFX-9dfcbef84884f67bb487dc02c642a03ca5d19e32.zip  | |
list work in progress
Diffstat (limited to 'src')
| -rw-r--r-- | src/gwin/list.c | 21 | 
1 files changed, 16 insertions, 5 deletions
diff --git a/src/gwin/list.c b/src/gwin/list.c index bfb341af..cc7c40f4 100644 --- a/src/gwin/list.c +++ b/src/gwin/list.c @@ -40,17 +40,28 @@ and use gw->pstyle->pressed->text for the selected text color  typedef struct ListItem {  	gfxQueueASyncItem	q_item;		// This must be the first member in the struct -	uint16_t 			id;  	uint16_t			flags;  	    #define LISTITEM_ALLOCEDTEXT      0x0001  	    #define LISTITEM_SELECTED         0x0002 -	uint16_t			uparam; +	uint16_t			param;		// A parameter the user can specify himself  	const char*			text;  	#if GWIN_LIST_IMAGES  	gdispImage*			pimg;  	#endif  } ListItem; +static int _getSelected(GWidgetObject *gw) { +	gfxQueueASyncItem*	qi; +	uint16_t i; + +	for(qi = gfxQueueASyncPeek(&((GListObject*)gw)->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) { +		if (((ListItem*)qi)->flags & GLIST_FLG_SELECTED) +			return i; +	} + +	return -1; +} +  static void sendListEvent(GWidgetObject *gw) {  	GSourceListener*	psl;  	GEvent*				pe; @@ -58,17 +69,18 @@ static void sendListEvent(GWidgetObject *gw) {  	// Trigger a GWIN list event  	psl = 0; +  	while ((psl = geventGetSourceListener(GWIDGET_SOURCE, psl))) {  		if (!(pe = geventGetEventBuffer(psl)))  			continue  		pse->type = GEVENT_GWIN_SLIDER;  		pse->list = (GHandle)gw; -		pse->item = 42; +		pse->item = _getSelected(gw);  		geventSendEvent(psl);  	} - +	  	#undef pse	  } @@ -104,7 +116,6 @@ static void gwinListDefaultDraw(GWidgetObject* gw, void* param) {  		item_height = gdispGetFontMetric(gwinGetDefaultFont(), fontHeight) + 2;  		item_id = (y - gw->g.y) / item_height; -		printf("item_id = %d\r\n", item_id);  		for(qi = gfxQueueASyncPeek(&gcw->list_head), i = 0; qi; qi = gfxQueueASyncNext(qi), i++) {  			if (item_id == i)  | 
