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

Menu Class Reference

#include <Menu.h>

Inheritance diagram for Menu:

MenuItem List of all members.

Public Types

enum  MenuType { NORMAL, SCROLLING }

Public Member Functions

 Menu (const string &label, const string &name, Font *font, MenuType type=NORMAL)
void setVirtualScreenSize (float width, float height)
void addChild (MenuItem *item)
void load (ifstream &file)
void save (ofstream &file)
void draw (float x, float y, float zoom)
virtual void renderMenu ()
Type getType ()
float getWidth (float zoom)
float getHeight (float zoom)
string & getName ()
bool handleKeyEvent (SDL_Event *event)
bool getSelected ()
void setSelected (bool isSelected)
MenuItemfindItem (const string &name)

Detailed Description

An class fo handling menus, either

Definition at line 19 of file Menu.h.


Member Enumeration Documentation

enum Menu::MenuType
 

Types defining the apperance of a menu.

Enumeration values:
NORMAL  The Menu is centered on screen, the menu must be able to fit the screen.
SCROLLING  The Menu moves up and down keeping the "selected" menu item sentered.

Definition at line 23 of file Menu.h.


Member Function Documentation

void Menu::addChild MenuItem item  ) 
 

Adds a child tho this menu, use this method to add sub menus / menu items.

Definition at line 43 of file Menu.cpp.

void Menu::draw float  x,
float  y,
float  zoom
[virtual]
 

Draws the MenuItem at x,y with a zoom factor of zoom (2 equals double size).

The MenuItem may decide not to apply the scale or to only support some zoom steps, always check getWidth and getHeight if you need the excact size.

Implements MenuItem.

Definition at line 63 of file Menu.cpp.

MenuItem * Menu::findItem const string &  name  ) 
 

Recurcivly finds an child og subchild.

Definition at line 189 of file Menu.cpp.

float Menu::getHeight float  zoom  )  [virtual]
 

Returns the height of this MenuItem at zoom factor zoom, must be excact

Implements MenuItem.

Definition at line 135 of file Menu.cpp.

string& Menu::getName  )  [inline, virtual]
 

Returns the name of the MenuItem used when save is called.

The name may not contain a =.

Implements MenuItem.

Definition at line 52 of file Menu.h.

bool Menu::getSelected  )  [inline]
 

Returns if the current menu is selected, when a menu is selected it should be showed with renderMenu.

Definition at line 56 of file Menu.h.

Type Menu::getType  )  [inline, virtual]
 

Returns the Type of this control.

Implements MenuItem.

Definition at line 49 of file Menu.h.

float Menu::getWidth float  zoom  )  [virtual]
 

Returns the width of this MenuItem at zoom factor zoom, must be excact

Implements MenuItem.

Definition at line 130 of file Menu.cpp.

bool Menu::handleKeyEvent SDL_Event *  event  )  [virtual]
 

Called when a key press/release event occurs, return true if the MenuItem has handled the event.

If true is returned the event handling will stop.

Implements MenuItem.

Definition at line 140 of file Menu.cpp.

void Menu::load ifstream &  file  )  [virtual]
 

Loads this menus from the file, will be called recurcivly on the children.

Reimplemented from MenuItem.

Definition at line 55 of file Menu.cpp.

void Menu::renderMenu  )  [virtual]
 

Renders the menu on screen, different from draw in that renderMenu renders the menu with children. draw only draws the menu as a sub menu

Definition at line 74 of file Menu.cpp.

void Menu::save ofstream &  file  )  [virtual]
 

Saves this menus to the file, will be called recurcivly on the children.

Reimplemented from MenuItem.

Definition at line 48 of file Menu.cpp.

void Menu::setSelected bool  isSelected  )  [inline]
 

Sets the menus selected state.

Definition at line 59 of file Menu.h.

void Menu::setVirtualScreenSize float  width,
float  height
 

Sets the size of the virtual screen

Definition at line 37 of file Menu.cpp.


The documentation for this class was generated from the following files:
Generated on Wed Sep 1 14:46:57 2004 by doxygen 1.3.7