Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

PG_PopupMenu::MenuItem Class Reference

A menu item data structure. More...

#include <pgpopupmenu.h>

Inheritance diagram for PG_PopupMenu::MenuItem:

Inheritance graph
[legend]
List of all members.

Public Types

typedef SigC::Slot2< bool,
MenuItem *, PG_Pointer
MenuItemSlot
enum  MI_FLAGS { MIF_NONE = 0, MIF_DISABLED = 0x01, MIF_SEPARATOR = 0x02, MIF_SUBMENU = 0x04 }

Public Member Functions

 MenuItem (PG_PopupMenu *parent, const std::string &caption, int id, MI_FLAGS flags)
 MenuItem (PG_PopupMenu *parent, const std::string &caption, PG_PopupMenu *submenu)
 ~MenuItem ()
bool measureItem (PG_Rect *rect, bool full=false)
bool isPointInside (int x, int y)
void moveTo (int x, int y)
SDL_Surface * getNormal () const
SDL_Surface * getDisabled () const
SDL_Surface * getSelected () const
bool paintNormal (SDL_Surface *canvas, PG_Color *tcol, PG_Color *scol=NULL)
bool paintDisabled (SDL_Surface *canvas, PG_Color *tcol, PG_Color *scol=NULL)
bool paintSelected (SDL_Surface *canvas, PG_Color *tcol, PG_Color *scol=NULL)
void disable ()
void enable ()
bool isDisabled () const
bool isEnabled () const
void select ()
void unselect ()
bool isSelected () const
bool isSeparator () const
bool isSubMenu () const
bool isMute () const
int Width () const
 Return the width of the rectangle.
int Height () const
 Return the height of the rectangle.
int getId () const
PG_PopupMenugetSubMenu () const
const PG_String & getCaption () const
 operator PG_Point const & () const

Public Attributes

SignalSelectMenuItem sigSelectMenuItem

Protected Attributes

unsigned myFlags
PG_String myCaption
PG_String myRightCaption
PG_PopupMenumyParent
PG_PopupMenumySubMenu
int myId
SDL_Surface * sNormal
SDL_Surface * sSelected
SDL_Surface * sDisabled
bool selected

Classes

class  SignalSelectMenuItem
 Signal type declaration. More...

Detailed Description

A menu item data structure.

Author:
Marek Habersack
Even though implemented as a class, MenuItem is not intended to be a new kind of widget - therefore it is derived only from PG_Rect for convenience. The idea is to have a "smart" data type (or a dumb class, if you prefer) that knows how to perform simple and specific actions on itself. The intention is to provide PG_PopupMenu with a fast mechanism for processing menu items - if MenuItem was derived from any of ParaGUI classes it would incurr unnecessary processing overhead.

Todo:
better separator code

icon drawing

Definition at line 87 of file pgpopupmenu.h.


Member Typedef Documentation

typedef SigC::Slot2<bool, MenuItem*, PG_Pointer> PG_PopupMenu::MenuItem::MenuItemSlot
 

Definition at line 105 of file pgpopupmenu.h.


Member Enumeration Documentation

enum PG_PopupMenu::MenuItem::MI_FLAGS
 

Enumeration values:
MIF_NONE 
MIF_DISABLED 
MIF_SEPARATOR 
MIF_SUBMENU 

Definition at line 89 of file pgpopupmenu.h.


Constructor & Destructor Documentation

PG_PopupMenu::MenuItem::MenuItem PG_PopupMenu parent,
const std::string &  caption,
int  id,
MI_FLAGS  flags
 

Definition at line 42 of file pgpopupmenu.cpp.

References MIF_SUBMENU, and myFlags.

PG_PopupMenu::MenuItem::MenuItem PG_PopupMenu parent,
const std::string &  caption,
PG_PopupMenu submenu
 

Definition at line 56 of file pgpopupmenu.cpp.

PG_PopupMenu::MenuItem::~MenuItem  ) 
 

Definition at line 69 of file pgpopupmenu.cpp.


Member Function Documentation

void PG_PopupMenu::MenuItem::disable  )  [inline]
 

Definition at line 373 of file pgpopupmenu.h.

References MIF_DISABLED, and myFlags.

void PG_PopupMenu::MenuItem::enable  )  [inline]
 

Definition at line 377 of file pgpopupmenu.h.

References MIF_DISABLED, and myFlags.

const PG_String & PG_PopupMenu::MenuItem::getCaption  )  const [inline]
 

Definition at line 430 of file pgpopupmenu.h.

References myCaption.

SDL_Surface * PG_PopupMenu::MenuItem::getDisabled  )  const [inline]
 

Definition at line 365 of file pgpopupmenu.h.

References sDisabled.

int PG_PopupMenu::MenuItem::getId  )  const [inline]
 

Definition at line 422 of file pgpopupmenu.h.

References myId.

Referenced by Menu::execAction(), and PG_PopupMenu::item_with_id::operator()().

SDL_Surface * PG_PopupMenu::MenuItem::getNormal  )  const [inline]
 

Definition at line 361 of file pgpopupmenu.h.

References sNormal.

SDL_Surface * PG_PopupMenu::MenuItem::getSelected  )  const [inline]
 

Definition at line 369 of file pgpopupmenu.h.

References sSelected.

PG_PopupMenu * PG_PopupMenu::MenuItem::getSubMenu  )  const [inline]
 

Definition at line 426 of file pgpopupmenu.h.

References mySubMenu.

int PG_PopupMenu::MenuItem::Height  )  const [inline]
 

Return the height of the rectangle.

Returns:
height

Reimplemented from PG_Rect.

Definition at line 418 of file pgpopupmenu.h.

bool PG_PopupMenu::MenuItem::isDisabled  )  const [inline]
 

Definition at line 381 of file pgpopupmenu.h.

References MIF_DISABLED, and myFlags.

Referenced by PG_PopupMenu::eventBlit(), and PG_PopupMenu::eventKeyDown().

bool PG_PopupMenu::MenuItem::isEnabled  )  const [inline]
 

Definition at line 385 of file pgpopupmenu.h.

References myFlags.

bool PG_PopupMenu::MenuItem::isMute  )  const [inline]
 

Definition at line 409 of file pgpopupmenu.h.

References MIF_DISABLED, MIF_SEPARATOR, and myFlags.

Referenced by PG_PopupMenu::handleClick().

bool PG_PopupMenu::MenuItem::isPointInside int  x,
int  y
 

Definition at line 156 of file pgpopupmenu.cpp.

References PG_Rect::my_height, PG_Rect::my_width, PG_Rect::my_xpos, and PG_Rect::my_ypos.

bool PG_PopupMenu::MenuItem::isSelected  )  const [inline]
 

Definition at line 397 of file pgpopupmenu.h.

References selected.

Referenced by PG_PopupMenu::eventBlit().

bool PG_PopupMenu::MenuItem::isSeparator  )  const [inline]
 

Definition at line 401 of file pgpopupmenu.h.

References MIF_SEPARATOR, and myFlags.

Referenced by PG_PopupMenu::eventBlit(), PG_PopupMenu::eventMouseButtonUp(), and measureItem().

bool PG_PopupMenu::MenuItem::isSubMenu  )  const [inline]
 

Definition at line 405 of file pgpopupmenu.h.

References MIF_SUBMENU, and myFlags.

Referenced by PG_PopupMenu::handleClick().

bool PG_PopupMenu::MenuItem::measureItem PG_Rect rect,
bool  full = false
 

Definition at line 91 of file pgpopupmenu.cpp.

References PG_Widget::GetFont(), PG_Widget::GetTextSize(), isSeparator(), PG_PopupMenu::maxItemWidth(), PG_PopupMenu::minTabWidth, PG_Rect::my_height, PG_Rect::my_width, myCaption, myParent, and myRightCaption.

Referenced by PG_PopupMenu::eventBlit(), and PG_PopupMenu::recalcRect().

void PG_PopupMenu::MenuItem::moveTo int  x,
int  y
[inline]
 

Definition at line 356 of file pgpopupmenu.h.

References PG_Point::x, and PG_Point::y.

PG_PopupMenu::MenuItem::operator PG_Point const &  )  const [inline]
 

Definition at line 434 of file pgpopupmenu.h.

bool PG_PopupMenu::MenuItem::paintDisabled SDL_Surface *  canvas,
PG_Color tcol,
PG_Color scol = NULL
[inline]
 

Definition at line 217 of file pgpopupmenu.cpp.

References sDisabled.

Referenced by PG_PopupMenu::eventBlit().

bool PG_PopupMenu::MenuItem::paintNormal SDL_Surface *  canvas,
PG_Color tcol,
PG_Color scol = NULL
[inline]
 

Definition at line 203 of file pgpopupmenu.cpp.

References sNormal.

Referenced by PG_PopupMenu::eventBlit().

bool PG_PopupMenu::MenuItem::paintSelected SDL_Surface *  canvas,
PG_Color tcol,
PG_Color scol = NULL
[inline]
 

Definition at line 210 of file pgpopupmenu.cpp.

References sSelected.

Referenced by PG_PopupMenu::eventBlit().

void PG_PopupMenu::MenuItem::select  )  [inline]
 

Definition at line 389 of file pgpopupmenu.h.

References selected.

void PG_PopupMenu::MenuItem::unselect  )  [inline]
 

Definition at line 393 of file pgpopupmenu.h.

References selected.

Referenced by PG_PopupMenu::eventKeyDown(), and PG_PopupMenu::handleClick().

int PG_PopupMenu::MenuItem::Width  )  const [inline]
 

Return the width of the rectangle.

Returns:
width

Reimplemented from PG_Rect.

Definition at line 414 of file pgpopupmenu.h.


Member Data Documentation

PG_String PG_PopupMenu::MenuItem::myCaption [protected]
 

Definition at line 157 of file pgpopupmenu.h.

Referenced by getCaption(), and measureItem().

unsigned PG_PopupMenu::MenuItem::myFlags [protected]
 

Definition at line 156 of file pgpopupmenu.h.

Referenced by disable(), enable(), isDisabled(), isEnabled(), isMute(), isSeparator(), isSubMenu(), and MenuItem().

int PG_PopupMenu::MenuItem::myId [protected]
 

Definition at line 162 of file pgpopupmenu.h.

Referenced by getId().

PG_PopupMenu* PG_PopupMenu::MenuItem::myParent [protected]
 

Definition at line 159 of file pgpopupmenu.h.

Referenced by measureItem().

PG_String PG_PopupMenu::MenuItem::myRightCaption [protected]
 

Definition at line 158 of file pgpopupmenu.h.

Referenced by measureItem().

PG_PopupMenu* PG_PopupMenu::MenuItem::mySubMenu [protected]
 

Definition at line 161 of file pgpopupmenu.h.

Referenced by getSubMenu().

SDL_Surface* PG_PopupMenu::MenuItem::sDisabled [protected]
 

Definition at line 166 of file pgpopupmenu.h.

Referenced by getDisabled(), and paintDisabled().

bool PG_PopupMenu::MenuItem::selected [protected]
 

Definition at line 168 of file pgpopupmenu.h.

Referenced by isSelected(), select(), and unselect().

SignalSelectMenuItem PG_PopupMenu::MenuItem::sigSelectMenuItem
 

Definition at line 103 of file pgpopupmenu.h.

Referenced by PG_PopupMenu::addMenuItem(), PG_PopupMenu::eventKeyDown(), PG_PopupMenu::handleClick(), and PG_PopupMenu::SetMenuItemSlot().

SDL_Surface* PG_PopupMenu::MenuItem::sNormal [protected]
 

Definition at line 164 of file pgpopupmenu.h.

Referenced by getNormal(), and paintNormal().

SDL_Surface* PG_PopupMenu::MenuItem::sSelected [protected]
 

Definition at line 165 of file pgpopupmenu.h.

Referenced by getSelected(), and paintSelected().


The documentation for this class was generated from the following files:
Generated on Tue Jun 24 02:19:14 2008 for Advanced Strategic Command by  doxygen 1.4.2