Library to display menus on TextLCDs. Interaction with functions Up,Down and Select (Buttons or RPG) Based on menu-library from pyeh9
Fork of Menu by
Library to display menus on TextLCDs. Interaction with functions Up,Down and Select (Buttons or RPG) Based on menu-library from pyeh9
MenuItem.h@11:6814cbc83ae0, 2016-01-13 (annotated)
- Committer:
- charly
- Date:
- Wed Jan 13 19:59:21 2016 +0000
- Revision:
- 11:6814cbc83ae0
- Parent:
- 10:2b6ddf53b05e
added show_longtext() to display a long text. With scrollbars.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
charly | 9:c9df0b33d176 | 1 | #ifndef MENUITEM_H |
charly | 9:c9df0b33d176 | 2 | #define MENUITEM_H |
charly | 9:c9df0b33d176 | 3 | |
charly | 9:c9df0b33d176 | 4 | #include "Menu.h" |
charly | 9:c9df0b33d176 | 5 | |
charly | 9:c9df0b33d176 | 6 | class Menu; |
charly | 9:c9df0b33d176 | 7 | |
charly | 9:c9df0b33d176 | 8 | /** MenuItem is a menu-item of menu |
charly | 9:c9df0b33d176 | 9 | */ |
charly | 9:c9df0b33d176 | 10 | class MenuItem { |
charly | 9:c9df0b33d176 | 11 | private: |
charly | 9:c9df0b33d176 | 12 | |
charly | 9:c9df0b33d176 | 13 | public: |
charly | 10:2b6ddf53b05e | 14 | /** modes of MenuItems |
charly | 10:2b6ddf53b05e | 15 | */ |
charly | 10:2b6ddf53b05e | 16 | enum mode{ |
charly | 10:2b6ddf53b05e | 17 | /** default mode: just display the Menu-Text an perform user_action |
charly | 10:2b6ddf53b05e | 18 | */ |
charly | 10:2b6ddf53b05e | 19 | mode_default = 0, |
charly | 11:6814cbc83ae0 | 20 | |
charly | 10:2b6ddf53b05e | 21 | /** wait_select: Call user_action and then only accept a select |
charly | 10:2b6ddf53b05e | 22 | * use for displaying text, values,... |
charly | 10:2b6ddf53b05e | 23 | * the menu is paused until select is pressed |
charly | 10:2b6ddf53b05e | 24 | */ |
charly | 10:2b6ddf53b05e | 25 | mode_wait_select = 1, |
charly | 11:6814cbc83ae0 | 26 | |
charly | 10:2b6ddf53b05e | 27 | /** mode_yes_no: show text and ask user for yes/no |
charly | 10:2b6ddf53b05e | 28 | * |
charly | 10:2b6ddf53b05e | 29 | */ |
charly | 11:6814cbc83ae0 | 30 | mode_yes_no = 2, |
charly | 11:6814cbc83ae0 | 31 | |
charly | 11:6814cbc83ae0 | 32 | //** mode_long_text: show a long text with scrollbars and wait for select() |
charly | 11:6814cbc83ae0 | 33 | mode_show_longtext = 3 |
charly | 10:2b6ddf53b05e | 34 | }; |
charly | 10:2b6ddf53b05e | 35 | |
charly | 10:2b6ddf53b05e | 36 | /** structure to pass data to menu and back |
charly | 10:2b6ddf53b05e | 37 | */ |
charly | 10:2b6ddf53b05e | 38 | struct menu_data{ |
charly | 10:2b6ddf53b05e | 39 | // Longer text to display. |
charly | 10:2b6ddf53b05e | 40 | // For Yes/No-Question |
charly | 11:6814cbc83ae0 | 41 | // or show_longtext |
charly | 10:2b6ddf53b05e | 42 | char * text; |
charly | 10:2b6ddf53b05e | 43 | //Yes/No Value In and Out |
charly | 10:2b6ddf53b05e | 44 | bool yes_no; |
charly | 10:2b6ddf53b05e | 45 | }; |
charly | 10:2b6ddf53b05e | 46 | |
charly | 9:c9df0b33d176 | 47 | /** pointer to user-action to execute when menu item is selected |
charly | 9:c9df0b33d176 | 48 | */ |
charly | 9:c9df0b33d176 | 49 | void (*userAction)(); |
charly | 9:c9df0b33d176 | 50 | /** Text of Menue-Item to display |
charly | 9:c9df0b33d176 | 51 | */ |
charly | 9:c9df0b33d176 | 52 | char* selText; |
charly | 9:c9df0b33d176 | 53 | /** position of menuitem in menu |
charly | 9:c9df0b33d176 | 54 | */ |
charly | 9:c9df0b33d176 | 55 | int pos; |
charly | 9:c9df0b33d176 | 56 | /** Pointer to child-menue |
charly | 9:c9df0b33d176 | 57 | */ |
charly | 9:c9df0b33d176 | 58 | Menu *childMenu; |
charly | 10:2b6ddf53b05e | 59 | /** itemMode |
charly | 10:2b6ddf53b05e | 60 | */ |
charly | 10:2b6ddf53b05e | 61 | uint8_t itemMode; |
charly | 10:2b6ddf53b05e | 62 | |
charly | 10:2b6ddf53b05e | 63 | menu_data * menu_parameter; |
charly | 9:c9df0b33d176 | 64 | |
charly | 9:c9df0b33d176 | 65 | /** a sub-menu |
charly | 9:c9df0b33d176 | 66 | */ |
charly | 10:2b6ddf53b05e | 67 | MenuItem(void (*)(), int, Menu *, char *, uint8_t = mode_default, menu_data * = NULL); |
charly | 9:c9df0b33d176 | 68 | |
charly | 9:c9df0b33d176 | 69 | }; |
charly | 9:c9df0b33d176 | 70 | |
charly | 9:c9df0b33d176 | 71 | #endif |