forked from thefossilrecord/beebem-rs97
-
Notifications
You must be signed in to change notification settings - Fork 5
/
listbox.h
77 lines (51 loc) · 1.73 KB
/
listbox.h
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
#ifndef LISTBOX_H
#define LISTBOX_H
#include <SDL.h>
#include <gui/gui.h>
/* List entry:
*/
#define LISTBOX_ENTRY_NAMESIZE 256
typedef struct {
char name[LISTBOX_ENTRY_NAMESIZE+1];
int value;
void *user_p;
// User click callback
} ListBox_Entry;
/* List box:
*/
#define LISTBOX_ALIGN_CENTER EG_BUTTON_ALIGN_CENTER
#define LISTBOX_ALIGN_LEFT EG_BUTTON_ALIGN_LEFT
#define LISTBOX_ALIGN_RIGHT EG_BUTTON_ALIGN_RIGHT
#define LISTBOX_CAPTIONSIZE 64
#define MAX_ROWS 15
typedef struct {
char title[LISTBOX_CAPTIONSIZE+1];
int alignment;
SDL_Color color;
unsigned int count;
ListBox_Entry *entries_p;
EG_Window *window_p;
unsigned int listbox_entries, default_index;
EG_Widget *slidebar_p;
EG_Widget *buttons_p[MAX_ROWS];
int selected, offset;
SDL_Surface *surface_p;
// Quit callback
} ListBox;
ListBox* ListBox_Create(SDL_Surface *surface_p);
void ListBox_Free(ListBox *listbox_p);
void ListBox_SetTitle(ListBox *listbox_p, const char *title_p);
void ListBox_SetColor(ListBox *listbox_p, SDL_Color color);
EG_BOOL ListBox_SetAlignment(ListBox *listbox_p, int alignment);
EG_BOOL ListBox_AddEntry(ListBox *listbox_p, const char *name_p, int user_value, void *user_p);
void ListBox_DeleteEntry(ListBox *listbox_p);
unsigned int ListBox_EntryCount(ListBox *listbox_p);
int ListBox_GetEntryValue(ListBox *listbox_p, unsigned int index);
void* ListBox_GetEntryUserPtr(ListBox *listbox_p, unsigned int index);
const char* ListBox_GetEntryName(ListBox *listbox_p, unsigned int index);
void ListBox_SortEntries(ListBox *listbox_p);
void ListBox_SetDefaultIndex(ListBox *listbox_p, int index);
void ListBox_Show(ListBox *listbox_p);
int ListBox_Run(ListBox *listbox_p);
void ListBox_Hide(ListBox *listbox_p);
#endif