forked from dancol90/MenuLib
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Menu.h
executable file
·61 lines (40 loc) · 1.25 KB
/
Menu.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
/*
This item contains other items.
*/
#include "MenuItem.h"
#include "NumericSelector.h"
#include "Action.h"
#include "CheckBox.h"
#ifndef Menu_h
#define Menu_h
struct ListEntry {
ListEntry(MenuItem* i) : item(i) {
next = NULL; prev = NULL;
}
ListEntry* next;
ListEntry* prev;
MenuItem* item;
};
class Menu : public MenuItem {
public:
typedef void(*MenuEnterCallback)(Menu*);
Menu(MenuItem* parent, const FlashString* text, MenuEnterCallback enter_cb = NULL);
char getTypeId() { return 'm'; }
MenuItem* addItem(MenuItem* item);
void clearItems();
ListEntry* getCollection() { return firstEntry; }
MenuItem* getSelectedItem() { return selectedItem->item; }
ListEntry* getSelectedListEntry() { return selectedItem; }
// MenuItem fields
bool activate();
void deactivate() {}
// Selects the next item in the list
void doNext();
// Selects the prev item in the list
void doPrev();
MenuItem* action();
private:
ListEntry *firstEntry, *lastEntry, *selectedItem;
MenuEnterCallback enter_cb;
};
#endif