Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

Menu.h

00001 00002 00003 #ifndef MOD_MENU_H 00004 #define MOD_MENU_H 00005 00006 //Licence: LGPL 00007 //Copyright: Visti Andresen 00008 00009 #include "MenuItem.h" 00010 #include "TextSelection.h" 00011 #include "TextEntry.h" 00012 #include "Button.h" 00013 #include "BackButton.h" 00014 #include "Key.h" 00015 #include "Font.h" 00016 #include <vector> 00017 00018 /**An class fo handling menus, either */ 00019 class Menu : public MenuItem 00020 { 00021 public: 00022 /**Types defining the apperance of a menu.*/ 00023 enum MenuType { 00024 NORMAL /**The Menu is centered on screen, the menu must be able to fit 00025 the screen.*/ 00026 ,SCROLLING /**The Menu moves up and down keeping the "selected" menu item 00027 sentered.*/ 00028 }; 00029 00030 Menu(const string &label, const string &name, Font *font, MenuType type = NORMAL); 00031 virtual ~Menu(); 00032 /**Sets the size of the virtual screen*/ 00033 void setVirtualScreenSize(float width, float height); 00034 /**Adds a child tho this menu, use this method to add sub menus / 00035 menu items.*/ 00036 void addChild(MenuItem *item); 00037 00038 /**Loads this menus from the file, will be called recurcivly on the 00039 children.*/ 00040 void load(ifstream &file); 00041 /**Saves this menus to the file, will be called recurcivly on the 00042 children.*/ 00043 void save(ofstream &file); 00044 void draw(float x, float y, float zoom); 00045 00046 /**Renders the menu on screen, different from draw in that renderMenu 00047 renders the menu with children. draw only draws the menu as a sub menu*/ 00048 virtual void renderMenu(); 00049 Type getType(){return MENU;}; 00050 float getWidth(float zoom); 00051 float getHeight(float zoom); 00052 string &getName(){return name_;} 00053 bool handleKeyEvent(SDL_Event *event); 00054 /**Returns if the current menu is selected, when a menu is selected it should 00055 be showed with renderMenu.*/ 00056 bool getSelected(){return isSelected_;} 00057 00058 /**Sets the menus selected state.*/ 00059 void setSelected(bool isSelected){isSelected_ = isSelected;} 00060 00061 /**Recurcivly finds an child og subchild.*/ 00062 MenuItem *findItem(const string &name); 00063 00064 private: 00065 float itemZoom(unsigned int item); 00066 00067 string label_, name_; 00068 Font *font_; 00069 float menuSpace_; 00070 unsigned int selectedItem_; 00071 vector<MenuItem*> items_; 00072 bool hasFocus_; 00073 bool isSelected_; 00074 float screenWidth_, screenHeight_; 00075 MenuType type_;; 00076 }; 00077 00078 #endif

Generated on Wed Sep 1 14:46:57 2004 by doxygen 1.3.7