diff options
-rw-r--r-- | src/engine.cpp | 5 | ||||
-rw-r--r-- | src/gui/menu.cpp | 19 | ||||
-rw-r--r-- | src/gui/menu.h | 7 | ||||
-rw-r--r-- | src/gui/menuitem.cpp | 1 |
4 files changed, 21 insertions, 11 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 7a777f86..2073c0d3 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -165,8 +165,9 @@ Engine::Engine() requestTradeDialog = new RequestTradeDialog(); /* Menu items */ - std::vector<MenuItem> items; - items.push_back(MenuItem("First")); + std::vector<MenuItem*> items; + items.push_back(new MenuItem("First")); + items.push_back(new MenuItem("Second")); menu = new Menu("Menu", items); // Initialize window posisitons diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 74721d09..8018b561 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -23,10 +23,10 @@ #include "menu.h" -Menu::Menu(const std::string& menulabel, std::vector<MenuItem>& items): +Menu::Menu(const std::string& menulabel, std::vector<MenuItem *> items): Window(menulabel) { - setContentSize(40,60); + setContentSize(52,60); fill(items); } @@ -34,12 +34,19 @@ Menu::~Menu() { } -void Menu::fill(std::vector<MenuItem>& items) +void Menu::fill(std::vector<MenuItem *> items) { - for(std::vector<MenuItem>::iterator item = items.begin(); + int i=0; + + for(std::vector<MenuItem *>::iterator item = items.begin(); item != items.end(); ++item) { - item->setPosition(0,0); - add(&*item); + MenuItem *optr; + optr = *item; + optr->setSize(50,10); + optr->setPosition(0,i); + i=i+10; + add(*item); } } + diff --git a/src/gui/menu.h b/src/gui/menu.h index a726e6a8..5d905c86 100644 --- a/src/gui/menu.h +++ b/src/gui/menu.h @@ -33,14 +33,17 @@ class Menu : public Window { /** * Constructor. */ - Menu(const std::string& menulabel, std::vector<MenuItem>& items); + Menu(const std::string& menulabel, std::vector<MenuItem *> items); /** * Destructor. */ ~Menu(); - void fill(std::vector<MenuItem>& items); + /** + * Fill menu with menuitems + */ + void fill(std::vector<MenuItem *> items); }; diff --git a/src/gui/menuitem.cpp b/src/gui/menuitem.cpp index 4bc073be..490e2f61 100644 --- a/src/gui/menuitem.cpp +++ b/src/gui/menuitem.cpp @@ -57,7 +57,6 @@ MenuItem::MenuItem(const std::string& label): } } addMouseListener(this); - setSize(50,10); } MenuItem::~MenuItem() |