Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Menu by
Revision 9:c9df0b33d176, committed 2015-03-13
- Comitter:
- charly
- Date:
- Fri Mar 13 18:44:49 2015 +0000
- Parent:
- 8:fbaeab73fe1a
- Child:
- 10:2b6ddf53b05e
- Commit message:
- Refactored Selection to MenuItem; Added comments
Changed in this revision
--- a/Menu.cpp Fri Jan 16 22:23:34 2015 +0000
+++ b/Menu.cpp Fri Mar 13 18:44:49 2015 +0000
@@ -1,6 +1,6 @@
#include "mbed.h"
#include "Menu.h"
-#include "Selection.h"
+#include "MenuItem.h"
Menu::Menu(char *id) : menuID(id)
{
@@ -8,7 +8,7 @@
CurrentSelection = 0;
}
-void Menu::add(const Selection &toAdd)
+void Menu::add(const MenuItem &toAdd)
{
selections.push_back(toAdd);
}
--- a/Menu.h Fri Jan 16 22:23:34 2015 +0000
+++ b/Menu.h Fri Mar 13 18:44:49 2015 +0000
@@ -2,24 +2,41 @@
#define MENU_H
#include "mbed.h"
-#include "Selection.h"
+#include "MenuItem.h"
#include <vector>
-class Selection;
+class MenuItem;
+/** Menu: Create Menues with Submenues, MenuItems, actions,...
+*
+*/
class Menu {
private:
public:
- vector<Selection> selections;
+ /** vector of of Menu-Items
+ *
+ */
+ vector<MenuItem> selections;
+
+ /** name of a menu
+ */
char *menuID;
// currently selected Item in Menu (used to return to this point from submenu)
int CurrentSelection;
+ /** a menu
+ */
Menu(char *);
- void add(const Selection &toAdd);
+ /** add an Item to the menu
+ */
+ void add(const MenuItem &toAdd);
+ /** change the text of an menu-item
+ */
void changeText(int position, char *newText);
+ /** get current text of menu-item
+ */
char *getText(int);
};
#endif
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MenuItem.cpp Fri Mar 13 18:44:49 2015 +0000
@@ -0,0 +1,6 @@
+#include "mbed.h"
+#include "MenuItem.h"
+#include "TextLCD.h"
+
+MenuItem::MenuItem(void (*userAction)(), int position, Menu *child, char* text) :
+ userAction(userAction), selText(text), pos(position), childMenu(child) {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/MenuItem.h Fri Mar 13 18:44:49 2015 +0000
@@ -0,0 +1,33 @@
+#ifndef MENUITEM_H
+#define MENUITEM_H
+
+#include "Menu.h"
+
+class Menu;
+
+/** MenuItem is a menu-item of menu
+*/
+class MenuItem {
+ private:
+
+ public:
+ /** pointer to user-action to execute when menu item is selected
+ */
+ void (*userAction)();
+ /** Text of Menue-Item to display
+ */
+ char* selText;
+ /** position of menuitem in menu
+ */
+ int pos;
+ /** Pointer to child-menue
+ */
+ Menu *childMenu;
+
+ /** a sub-menu
+ */
+ MenuItem(void (*)(), int, Menu *, char *);
+
+};
+
+#endif
\ No newline at end of file
--- a/Navigator.cpp Fri Jan 16 22:23:34 2015 +0000
+++ b/Navigator.cpp Fri Mar 13 18:44:49 2015 +0000
@@ -57,9 +57,9 @@
{
Menu *lastMenu;
- if(activeMenu->selections[_cursorPos].fun != NULL) {
+ if(activeMenu->selections[_cursorPos].userAction != NULL) {
//execute function
- (activeMenu->selections[_cursorPos].fun)();
+ (activeMenu->selections[_cursorPos].userAction)();
// refresh the Menu
//printMenu();
//printCursor();
--- a/Navigator.h Fri Jan 16 22:23:34 2015 +0000 +++ b/Navigator.h Fri Mar 13 18:44:49 2015 +0000 @@ -13,7 +13,7 @@ * * @code * - * #include "Selection.h" + * #include "MenuItem.h" * #include "Menu.h" * #include "Navigator.h" * #include <vector>
--- a/Selection.cpp Fri Jan 16 22:23:34 2015 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-#include "mbed.h"
-#include "Selection.h"
-#include "TextLCD.h"
-
-Selection::Selection(void (*fun)(), int position, Menu *child, char* text) :
- fun(fun), selText(text), pos(position), childMenu(child) {}
--- a/Selection.h Fri Jan 16 22:23:34 2015 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-#ifndef SELECTION_H
-#define SELECTION_H
-
-#include "Menu.h"
-
-class Menu;
-
-class Selection {
- private:
-
- public:
- void (*fun)(); // pointer to a function to execute
- char* selText; // selection text
- int pos; // selection position
- Menu *childMenu;
-
- Selection(void (*)(), int, Menu *, char *);
-
-};
-
-#endif
\ No newline at end of file
