-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMenu.h
More file actions
99 lines (64 loc) · 2.37 KB
/
Menu.h
File metadata and controls
99 lines (64 loc) · 2.37 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#pragma once
#include <AEEDisp.h>
#include <AEEShell.h>
#include <AEEText.h>
#include <AEE.h>
typedef struct CMenu CMenu;
typedef struct CMenuEntryGroup CMenuEntryGroup;
typedef struct CMenuEntry CMenuEntry;
typedef struct CMenuManager CMenuManager;
struct CMenuEntry {
const AECHAR *label;
void (*callback)(CMenuEntry *entry, void *);
void (*releaseCallback)(CMenuEntry *entry, void *);
CMenu *(*submenuCallback)(CMenuEntry *entry, void *);
CMenuEntryGroup *parent;
IImage *icon;
boolean iconLoaded;
AEEImageInfo iconInfo;
ITextCtl *textCtl;
void *userData;
};
void CMenuEntry_Init(CMenuEntry *self, CMenuEntryGroup *parent);
void CMenuEntry_SetTextInput(CMenuEntry *self, IShell *shell, const AECHAR *initialText);
void CMenuEntry_UpdateLabel(CMenuEntry *self, const AECHAR *label);
void CMenuEntry_SetIcon(CMenuEntry *self, IImage *icon);
void CMenuEntry_Free(CMenuEntry *self);
struct CMenuEntryGroup {
const AECHAR *groupLabel;
uint32 numEntries;
uint32 capacity;
CMenuEntry **entries;
CMenu *parent;
};
void CMenuEntryGroup_Init(CMenuEntryGroup *self, CMenu *parent);
void CMenuEntryGroup_Sort(CMenuEntryGroup *self);
int CMenuEntryGroup_AddNewEntry(CMenuEntryGroup *self, const AECHAR *label, CMenuEntry **ppEntry);
void CMenuEntryGroup_Clear(CMenuEntryGroup *self);
void CMenuEntryGroup_Free(CMenuEntryGroup *self);
struct CMenu {
uint32 numGroups;
CMenuEntryGroup **groups;
void *userData;
CMenu *backMenu;
void (*backHandler)(CMenuManager *manager, CMenu *menu, void *userData);
};
void CMenu_DefaultBackHandler(CMenuManager *manager, CMenu *menu, void *userData);
void CMenu_Init(CMenu *self);
int CMenu_AddNewGroup(CMenu *self, CMenuEntryGroup **ppGroup);
void CMenu_Free(CMenu *self);
struct CMenuManager {
IShell *shell;
IDisplay *display;
int displayWidth, displayHeight;
CMenu *currentMenu;
CMenuEntry *currentMenuEntry;
int scrollOffset;
};
int CMenuManager_Init(CMenuManager *self, IShell *shell);
void CMenuManager_Free(CMenuManager *self);
void CMenuManager_Render(CMenuManager *self);
void CMenuManager_OpenMenu(CMenuManager *self, CMenu *menu);
void CMenuManager_FixScroll(CMenuManager *self);
void CMenuManager_SelectEntry(CMenuManager *self, CMenuEntry *entry);
boolean CMenuManager_HandleEvent(CMenuManager *self, AEEEvent eCode, uint16 wParam, uint32 dwParam);