aboutsummaryrefslogtreecommitdiffstats
path: root/include/gwin/list.h
blob: 307226c95fdbf20acf504147dcc63dc7dc6f0587 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
 * This file is subject to the terms of the GFX License. If a copy of
 * the license was not distributed with this file, you can obtain one at:
 *
 *              http://ugfx.org/license.html
 */

/**
 * @file	include/gwin/list.h
 * @brief	GWIN list widget header file
 *
 * @defgroup List List
 * @ingroup GWIN
 *
 * @details		GWIN allows it to create a list widget.
 *
 * @pre			GFX_USE_GDISP must be set to TRUE in your gfxconf.h
 * @pre			GFX_USE_GWIN must be set to TRUE in your gfxconf.h
 * @pre			GDISP_NEED_TEXT must be set to TRUE in your gfxconf.h
 * @pre			GWIN_NEED_LIST must be set to TRUE in your gfxconf.h
 * @pre			The font you want to use must be enabled in your gfxconf.h
 *
 * @{
 */

#ifndef _GWIN_LIST_H
#define _GWIN_LIST_H

// This file is included within "gwin/gwin.h"

/**
 * @brief	The event type for a list event
 */
#define GEVENT_GWIN_LIST	(GEVENT_GWIN_FIRST+4)

/**
 * @brief	A list event
 */
typedef struct GEventGWinList {
	GEventType		type;		// The type of this event (GEVENT_GWIN_LIST)
	GHandle			list;		// The list
	int				item;		// The item that has been selected (or unselected in a multi-select listbox)
} GEventGWinList;

// A list window
typedef struct GListObject {
	GWidgetObject	w;
	int				cnt;		// Number of items currently in the list (quicker than counting each time)
	gfxQueueASync	list_head;	// The list of items
} GListObject;

#ifdef __cplusplus
extern "C" {
#endif

GHandle gwinListCreate(GListObject *widget, GWidgetInit *pInit);

int gwinListAddItem(GHandle gh, const char* item, bool_t useAlloc);

char* gwinListItemGetText(GHandle gh, int item);

int gwinListFindText(GHandle gh, const char* text);

void gwinListItemSetParam(GHandle gh, int item, uint16_t param);

uint16_t gwinListItemGetParam(GHandle gh, int item);

void nListDeleteAll(GHandle gh);

void gwinListItemDelete(GHandle gh, int item);

int gwinListItemCount(GHandle gh);

bool_t gwinListItemIsSelected(GHandle gh, int item);

int gwinListGetSelected(GHandle gh);

#ifdef __cplusplus
}
#endif

#endif // _GWIN_LIST_H
/** @} */