Menu Class Reference
[2D Graphical User Inteface]

Generic menu

A menu is a collection of Widget with a simple box color in background. More...

#include <Menu.hh>

Inheritance diagram for Menu:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Menu (const uint x, const uint y, SDL_Surface *screen, const ushort width=MENU_WIDTH, const string title="")
 constructor
 Menu (const uint x, const uint y, SDL_Surface *screen, const ushort width, const ushort height, const string title="")
 constructor
 ~Menu ()
 destructor
void draw ()
 Method to draw the menu.
void refresh ()
 Method to refresh the menu.
void erase ()
 Method to erase the menu.
ushort mousebuttondown (const uint mousex=0, const uint mousey=0)
 Method to do an action when mouse button is down.
void mousemotion (const uint mousex, const uint mousey)
 Method to do an action when the mouse is moved.
void addWidget (Widget *widget)
 Method to add a widget in the menu.
void addWidget (Widget *widget, const uint x, const uint y)
 Method to add a widget in the menu.
void deleteWidget (const ushort indice)
 Method to delete a widget in the menu.
void setbgColor (SDL_Color bgColor)
 Method to set the value of background color of the menu.
SDL_Color getbgColor ()
 Method to get the value of the background color of the menu.
void setfgColor (SDL_Color fgColor)
 Method to set the value of foreground color of the menu.
SDL_Color getfgColor ()
 Method to get the value of the foreground color of the menu.
ushort getwidth ()
ushort getheight ()
ushort getnbwidget ()
ushort getpadx ()
ushort getpady ()

Detailed Description

Generic menu

A menu is a collection of Widget with a simple box color in background.

Author:
poltuiu
Date:
2006-04-15


Constructor & Destructor Documentation

Menu::Menu ( const uint  x,
const uint  y,
SDL_Surface *  screen,
const ushort  width = MENU_WIDTH,
const string  title = "" 
)

constructor

Parameters:
x is the x coordinate of the menu in the window
y is the y coordiante of the menu in the window
screen is the container father of the menu
width is the width of the menu box
title string if menu has title

Menu::Menu ( const uint  x,
const uint  y,
SDL_Surface *  screen,
const ushort  width,
const ushort  height,
const string  title = "" 
)

constructor

Parameters:
x is the x coordinate of the menu in the window
y is the y coordiante of the menu in the window
screen is the container father of the menu
width is the width of the menu box
height is the height of the menu box
title string if menu has title


Member Function Documentation

void Menu::addWidget ( Widget widget,
const uint  x,
const uint  y 
)

Method to add a widget in the menu.

Parameters:
widget is a reference to the widget to add
x is the x coordinate of the widget (relative to menu box)
y is the y coordinate of the widget (relative to menu box)
Note:
menu is used like a stack : last widget added is the bottom of the menu

void Menu::addWidget ( Widget widget  ) 

Method to add a widget in the menu.

Parameters:
widget is a reference to the widget to add
Note:
menu is used like a stack : last widget added is the bottom of the menu

void Menu::deleteWidget ( const ushort  indice  ) 

Method to delete a widget in the menu.

Parameters:
indice is the index of the button to delete

void Menu::draw (  )  [virtual]

Method to draw the menu.

Note:
The draw method is called to draw the element the first time

Implements Widget.

SDL_Color Menu::getbgColor (  )  [inline]

Method to get the value of the background color of the menu.

Returns:
the color in SDL_Color format

SDL_Color Menu::getfgColor (  )  [inline]

Method to get the value of the foreground color of the menu.

Returns:
the color in SDL_Color format

ushort Menu::mousebuttondown ( const uint  mousex = 0,
const uint  mousey = 0 
) [virtual]

Method to do an action when mouse button is down.

Parameters:
mousex is the coordinate x of the mouse pointer
mousey is the coordinate y of the mouse pointer
Returns:
the action associated with the button used

Reimplemented from Widget.

void Menu::mousemotion ( const uint  mousex,
const uint  mousey 
) [virtual]

Method to do an action when the mouse is moved.

This method do mousemotion for each button of the menu

Parameters:
mousex is the coordinate x of the mouse pointer
mousey is the coordinate y of the mouse pointer

Implements Widget.

void Menu::refresh (  )  [virtual]

Method to refresh the menu.

Note:
This method is used to redraw the element

Implements Widget.

void Menu::setbgColor ( SDL_Color  bgColor  ) 

Method to set the value of background color of the menu.

Note:
It's necessary to do a refresh() after to redraw the menu
Parameters:
bgColor is the new background color of the menu

void Menu::setfgColor ( SDL_Color  fgColor  ) 

Method to set the value of foreground color of the menu.

Parameters:
fgColor is the new foreground color of the menu


The documentation for this class was generated from the following files:
Generated on Sat Jun 23 16:11:06 2007 for Stechec/TBT by  doxygen 1.4.7