This project is a DIY mbed version of your favorite childhood game
Dependencies: mbed 4DGL-uLCD-SE LCD_fonts SDFileSystem MMA8452
menu.h@0:bce994168592, 2019-04-14 (annotated)
- Committer:
- aklaussen
- Date:
- Sun Apr 14 01:39:35 2019 +0000
- Revision:
- 0:bce994168592
publish working code;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
aklaussen | 0:bce994168592 | 1 | #include <string> |
aklaussen | 0:bce994168592 | 2 | #include <vector> |
aklaussen | 0:bce994168592 | 3 | #include <memory> |
aklaussen | 0:bce994168592 | 4 | |
aklaussen | 0:bce994168592 | 5 | class Menu { |
aklaussen | 0:bce994168592 | 6 | public: |
aklaussen | 0:bce994168592 | 7 | //methods |
aklaussen | 0:bce994168592 | 8 | int select(); |
aklaussen | 0:bce994168592 | 9 | void draw(); |
aklaussen | 0:bce994168592 | 10 | void update_selection(); |
aklaussen | 0:bce994168592 | 11 | void set_active(); |
aklaussen | 0:bce994168592 | 12 | void add_child(Menu* child); |
aklaussen | 0:bce994168592 | 13 | //static methods |
aklaussen | 0:bce994168592 | 14 | static void go_back(); |
aklaussen | 0:bce994168592 | 15 | static void clear_cursor(); |
aklaussen | 0:bce994168592 | 16 | static void draw_cursor(); |
aklaussen | 0:bce994168592 | 17 | static void update_cursor(); |
aklaussen | 0:bce994168592 | 18 | static std::string run(); |
aklaussen | 0:bce994168592 | 19 | |
aklaussen | 0:bce994168592 | 20 | //members |
aklaussen | 0:bce994168592 | 21 | std::string name; |
aklaussen | 0:bce994168592 | 22 | std::string label; |
aklaussen | 0:bce994168592 | 23 | Menu * parent; |
aklaussen | 0:bce994168592 | 24 | std::vector<Menu*> entries; |
aklaussen | 0:bce994168592 | 25 | void (*onClick) (); |
aklaussen | 0:bce994168592 | 26 | |
aklaussen | 0:bce994168592 | 27 | //constructors |
aklaussen | 0:bce994168592 | 28 | Menu (std::string name="", |
aklaussen | 0:bce994168592 | 29 | std::string label="", |
aklaussen | 0:bce994168592 | 30 | void (*onClick)()=NULL); |
aklaussen | 0:bce994168592 | 31 | |
aklaussen | 0:bce994168592 | 32 | private: |
aklaussen | 0:bce994168592 | 33 | static Menu* active_menu; |
aklaussen | 0:bce994168592 | 34 | static int selected_entry; |
aklaussen | 0:bce994168592 | 35 | }; |
aklaussen | 0:bce994168592 | 36 | |
aklaussen | 0:bce994168592 | 37 |