From b89398608993f2e50b7c7edd8aabe7cb1c1c216b Mon Sep 17 00:00:00 2001 From: Mateusz Kaduk Date: Sat, 21 May 2005 08:48:54 +0000 Subject: Fixed menu so it is working.. --- src/engine.cpp | 5 +++-- src/gui/menu.cpp | 19 +++++++++++++------ src/gui/menu.h | 7 +++++-- src/gui/menuitem.cpp | 1 - 4 files changed, 21 insertions(+), 11 deletions(-) (limited to 'src') 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 items; - items.push_back(MenuItem("First")); + std::vector 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& items): +Menu::Menu(const std::string& menulabel, std::vector items): Window(menulabel) { - setContentSize(40,60); + setContentSize(52,60); fill(items); } @@ -34,12 +34,19 @@ Menu::~Menu() { } -void Menu::fill(std::vector& items) +void Menu::fill(std::vector items) { - for(std::vector::iterator item = items.begin(); + int i=0; + + for(std::vector::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& items); + Menu(const std::string& menulabel, std::vector items); /** * Destructor. */ ~Menu(); - void fill(std::vector& items); + /** + * Fill menu with menuitems + */ + void fill(std::vector 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() -- cgit v1.2.3-70-g09d2