-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMenuItem.h
More file actions
executable file
·70 lines (49 loc) · 2.46 KB
/
MenuItem.h
File metadata and controls
executable file
·70 lines (49 loc) · 2.46 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
#ifndef MenuItem_h
#define MenuItem_h
#include <Arduino.h>
#define FlashString __FlashStringHelper
// Abstract class
class MenuItem {
protected:
MenuItem* parent;
const char* text;
bool is_flash, enabled;
public:
MenuItem(MenuItem* parent, const FlashString* text) : parent(parent), enabled(true) { setText(text); }
MenuItem(MenuItem* parent, const char* text) : parent(parent), enabled(true) { setText(text); }
virtual MenuItem* getParent() { return parent; }
virtual void setParent(MenuItem* parent) { this->parent = parent; }
virtual bool isTextFlash() { return is_flash; }
virtual const char* getText() { return text; }
virtual void setText(const FlashString* text) { this->is_flash = 1; this->text = reinterpret_cast<PGM_P>(text); }
virtual void setText(const char *text) { this->is_flash = 0; this->text = text; }
virtual const char* getSecondaryText() { return NULL; }
virtual char getTypeId() = 0;
virtual bool isEnabled() { return this->enabled; }
virtual void setState(bool enabled) { this->enabled = enabled; }
// Called when the parent menu select the item
/* Ritorna un booleano
Se vero: l'oggetto vorrà prendere il controllo
Se false: l'oggetto ritornerà subito il controllo al padre.
*/
virtual bool activate() = 0;
// Triggered when the current action is cancelled. (Back button pressed)
// TODO: Determine what this function can return
virtual void deactivate() = 0;
// This events are triggerd only if the item is active.
// ------
// Called when event "next" is triggered
// Usually this event is triggered when a down or right key is pressed
virtual void doNext() = 0;
// Called when event "prev" is triggered
// Usually this event is triggered when up or left key is pressed
virtual void doPrev() = 0;
// Called when event "action" is triggered
// Usually this event is triggered when center or ok key is pressed
// Ritorna un puntatore ad un MenuItem che verrà attivato.
// Se ritorna this o NULL, l'oggetto stesso manterrà il controllo.
virtual MenuItem* action() = 0;
virtual bool back() { return true; }
virtual ~MenuItem() {}
};
#endif