UIpane.h
1.99 KB
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
#ifndef __UIPane__
#define __UIPane__
#include "UI.h"
#include "UIevent.h"
#define kInvalidID -1
typedef void * UIPaneDataPtr;
typedef struct uiitem * UIItemPtr;
typedef struct uipane * UIPanePtr;
typedef void (*TPaneDrawProc)(UIPanePtr pPane, Gfx **ppGfx);
typedef void (*TItemDrawProc)(UIItemPtr pItem, Gfx **ppGfx);
typedef char (*THandleEventProc)(UIPanePtr pPane, UIEvent *pEvent);
typedef struct uipane
{
Rect bounds; /* In screen coordinates. */
int numItems; /* The number of UIItems this pane contains. */
UIItemPtr itemList; /* A pointer to the the pane's list of UIItems (stored somewhere in pane data) */
UIPaneDataPtr pData; /* Reference to pane-specific data including storage for the UIItem list. */
TPaneDrawProc DrawProc;
THandleEventProc HandleEventProc;
} UIPane;
typedef struct uiitem
{
int id; /* The item's unique id. Often matches the array index if it is stored in one. */
Rect bounds; /* In pane coordinates. */
char fIsSelected; /* Indicates the selection state of the UIItem. */
char fIsClicked; /* Indicates if the item is being clicked on. */
Sprite * pSpriteIcon; /* The item's sprite data in it has an icon, NULL if it does not. */
UIPane * pPane; /* The pane which contains this item. Used to convert pane to screen coords. */
TItemDrawProc DrawProc;
} UIItem;
void Pane_Init (UIPane *pPane);
char Pane_ItemClicked (UIPane *pPane, Point *pPt, UIItem **ppItem);
char Pane_GetSelectedItem (UIPane *pPane, UIItem **ppItem);
void Pane_DeselectAllItems (UIPane *pPane);
void Item_Init (UIItem *pItem, int id);
void Item_GetScreenBounds (UIItem *pItem, Rect *pRect);
void Item_SetSelected (UIItem *pItem, char isSelected);
char Item_IsSelected (UIItem *pItem);
#endif /* __UIPane__ */