Menu system broken

Dependencies:   ANSITermMenuSystem

Fork of menuSystemMbed by Ryan Scott

Committer:
Rybowonder
Date:
Sat May 04 17:37:57 2013 +0000
Revision:
8:6ddb8c26387a
Parent:
5:92389cf2106d
For Mitchener

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedDevLondon 0:a5ece7312edc 1 //
mbedDevLondon 0:a5ece7312edc 2 // MainMenu.cpp
mbedDevLondon 0:a5ece7312edc 3 // menuSystem
mbedDevLondon 0:a5ece7312edc 4 //
mbedDevLondon 0:a5ece7312edc 5 // Created by BradDSmith on 2013-02-26.
mbedDevLondon 0:a5ece7312edc 6 // Copyright (c) 2013 BradDSmith. All rights reserved.
mbedDevLondon 0:a5ece7312edc 7 //
mbedDevLondon 0:a5ece7312edc 8
mbedDevLondon 0:a5ece7312edc 9 #include "MainMenu.h"
mbedDevLondon 0:a5ece7312edc 10
mbedDevLondon 0:a5ece7312edc 11 #include "console.h"
mbedDevLondon 0:a5ece7312edc 12
mbedDevLondon 0:a5ece7312edc 13 MainMenu::MainMenu()
mbedDevLondon 0:a5ece7312edc 14 {
Rybowonder 4:1178a1905490 15 selecteditem = 0; //April 9th 2013 Ask Brad about Glitch
mbedDevLondon 0:a5ece7312edc 16 highlightedItem = 0;
mbedDevLondon 0:a5ece7312edc 17 maxitems = MAXITEMS;
Rybowonder 4:1178a1905490 18 selectionstatus = false;
mbedDevLondon 0:a5ece7312edc 19 }
mbedDevLondon 0:a5ece7312edc 20
mbedDevLondon 0:a5ece7312edc 21 void MainMenu::setMaxItems(int max)
mbedDevLondon 0:a5ece7312edc 22 {
mbedDevLondon 0:a5ece7312edc 23 maxitems = max;
mbedDevLondon 0:a5ece7312edc 24 }
mbedDevLondon 0:a5ece7312edc 25
mbedDevLondon 0:a5ece7312edc 26 void MainMenu::setMenuItem(int locID, int menuID, const char * menuText, int x, int y)
mbedDevLondon 0:a5ece7312edc 27 {
mbedDevLondon 0:a5ece7312edc 28 if(locID <maxitems){
mbedDevLondon 0:a5ece7312edc 29 menuItem[locID].initialize(menuID, (char *)menuText,x, y);
mbedDevLondon 0:a5ece7312edc 30 }
mbedDevLondon 0:a5ece7312edc 31 }
mbedDevLondon 0:a5ece7312edc 32
mbedDevLondon 0:a5ece7312edc 33 void MainMenu::printMenu()
mbedDevLondon 0:a5ece7312edc 34 {
Rybowonder 4:1178a1905490 35 const char * msg = Title.c_str();
Rybowonder 4:1178a1905490 36 printXY( (char *)msg, 5, 0);
mbedDevLondon 0:a5ece7312edc 37 for (int i = 0; i < maxitems; i++) {
mbedDevLondon 0:a5ece7312edc 38 menuItem[i].print();
mbedDevLondon 0:a5ece7312edc 39 }
mbedDevLondon 0:a5ece7312edc 40
mbedDevLondon 0:a5ece7312edc 41 menuItem[highlightedItem].highlight();
Rybowonder 4:1178a1905490 42 if (selectionstatus == true)
Rybowonder 4:1178a1905490 43 {
Rybowonder 4:1178a1905490 44 menuItem[selecteditem].showselect(); //April 9th 2013 Ask Brad about Glitch
Rybowonder 4:1178a1905490 45 }
mbedDevLondon 0:a5ece7312edc 46 }
mbedDevLondon 0:a5ece7312edc 47
mbedDevLondon 0:a5ece7312edc 48 void MainMenu::highlightNextItem()
mbedDevLondon 0:a5ece7312edc 49 {
mbedDevLondon 0:a5ece7312edc 50 menuItem[highlightedItem].removeHighLight();
mbedDevLondon 0:a5ece7312edc 51
mbedDevLondon 0:a5ece7312edc 52 highlightedItem++;
mbedDevLondon 0:a5ece7312edc 53 if(highlightedItem >= maxitems)highlightedItem = 0;
Rybowonder 5:92389cf2106d 54 // highlightedItem--;
Rybowonder 5:92389cf2106d 55 // if(highlightedItem < 0)highlightedItem = maxitems - 1 ;
mbedDevLondon 0:a5ece7312edc 56
mbedDevLondon 0:a5ece7312edc 57 menuItem[highlightedItem].highlight();
mbedDevLondon 0:a5ece7312edc 58 }
mbedDevLondon 0:a5ece7312edc 59
mbedDevLondon 0:a5ece7312edc 60 void MainMenu::highlightPrevItem()
mbedDevLondon 0:a5ece7312edc 61 {
mbedDevLondon 0:a5ece7312edc 62 menuItem[highlightedItem].removeHighLight();
mbedDevLondon 0:a5ece7312edc 63
Rybowonder 5:92389cf2106d 64 highlightedItem--;
Rybowonder 5:92389cf2106d 65 if(highlightedItem < 0)highlightedItem = maxitems - 1 ;
Rybowonder 5:92389cf2106d 66 // highlightedItem++;
Rybowonder 5:92389cf2106d 67 // if(highlightedItem >= maxitems)highlightedItem = 0;
mbedDevLondon 0:a5ece7312edc 68
mbedDevLondon 0:a5ece7312edc 69 menuItem[highlightedItem].highlight();
mbedDevLondon 0:a5ece7312edc 70 }
mbedDevLondon 0:a5ece7312edc 71
mbedDevLondon 0:a5ece7312edc 72 int MainMenu::getHighlightedItem()
mbedDevLondon 0:a5ece7312edc 73 {
mbedDevLondon 0:a5ece7312edc 74 return menuItem[highlightedItem].getMenuID();
mbedDevLondon 0:a5ece7312edc 75 }
mbedDevLondon 0:a5ece7312edc 76
mbedDevLondon 0:a5ece7312edc 77 void MainMenu::erase()
mbedDevLondon 0:a5ece7312edc 78 {
mbedDevLondon 0:a5ece7312edc 79 for (int i = 0; i < maxitems; i++) {
mbedDevLondon 0:a5ece7312edc 80 menuItem[i].erase();
mbedDevLondon 0:a5ece7312edc 81 }
mbedDevLondon 0:a5ece7312edc 82 }
Rybowonder 4:1178a1905490 83
Rybowonder 4:1178a1905490 84 void MainMenu::selection()
Rybowonder 4:1178a1905490 85 {
Rybowonder 4:1178a1905490 86 selecteditem = highlightedItem;
Rybowonder 4:1178a1905490 87 menuItem[selecteditem].showselect();
Rybowonder 4:1178a1905490 88 }
Rybowonder 4:1178a1905490 89
Rybowonder 4:1178a1905490 90 void MainMenu::removeselection()
Rybowonder 4:1178a1905490 91 {
Rybowonder 4:1178a1905490 92 menuItem[selecteditem].removeselect();
Rybowonder 4:1178a1905490 93 }
Rybowonder 4:1178a1905490 94
Rybowonder 4:1178a1905490 95 string MainMenu::getTitle()
Rybowonder 4:1178a1905490 96 {
Rybowonder 4:1178a1905490 97 return Title;
Rybowonder 4:1178a1905490 98 }
Rybowonder 4:1178a1905490 99 void MainMenu::setTitle(string NewTitle)
Rybowonder 4:1178a1905490 100 {
Rybowonder 4:1178a1905490 101 Title = NewTitle;
Rybowonder 4:1178a1905490 102 }
Rybowonder 4:1178a1905490 103
Rybowonder 4:1178a1905490 104 void MainMenu::setselectstatus()
Rybowonder 4:1178a1905490 105 {
Rybowonder 4:1178a1905490 106 selectionstatus = true;
Rybowonder 5:92389cf2106d 107 }
Rybowonder 5:92389cf2106d 108
Rybowonder 5:92389cf2106d 109 int MainMenu::getselecteditem()
Rybowonder 5:92389cf2106d 110 {
Rybowonder 5:92389cf2106d 111 return selecteditem;
Rybowonder 4:1178a1905490 112 }