Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

gui::MenuItem Class Reference

#include <MenuItem.h>

Inheritance diagram for gui::MenuItem:

Inheritance graph
[legend]
Collaboration diagram for gui::MenuItem:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MenuItem (Surface *, const string &text, TTFont *=NULL, SurfaceHelper *=NULL)
 ~MenuItem ()
void CreateMenuItem ()
void Draw ()
void OnMouseIn ()
void OnMouseOut ()
void OnClick (coord_t, coord_t)
void SetClickCloses (bool)
void DumpMembers (FILE *)

Private Attributes

bool m_bClickCloses

Constructor & Destructor Documentation

gui::MenuItem::MenuItem Surface ,
const string &  text,
TTFont = NULL,
SurfaceHelper = NULL
 

Definition at line 58 of file MenuItem.cpp.

References gui::Surface::GetTTFont().

00059 :Surface(s,pclHelper) 00060 ,m_bClickCloses(true) 00061 { 00062 TTFont *font; 00063 SDL_Rect rect; 00064 00065 SetText(txt); 00066 if (pclFont) 00067 { 00068 SetTTFont(pclFont); 00069 } 00070 SetClickable(true); 00071 SetInverted(false); 00072 00073 font = GetTTFont(); 00074 font -> GetRect(txt, rect); 00075 00076 SetFrameWidth(0); 00077 SetW(rect.w + rect.h + 8, false); 00078 SetH(rect.h, false); 00079 }

gui::MenuItem::~MenuItem  ) 
 

Definition at line 88 of file MenuItem.cpp.

00089 { 00090 }


Member Function Documentation

void gui::MenuItem::CreateMenuItem  ) 
 

Definition at line 82 of file MenuItem.cpp.

References gui::Surface::RecreateSurfaces().

00083 { 00084 RecreateSurfaces(); 00085 }

void gui::MenuItem::Draw  )  [virtual]
 

Reimplemented from gui::Surface.

Reimplemented in gui::PopupMenuItem, and gui::SeparatorMenuItem.

Definition at line 93 of file MenuItem.cpp.

References gui::coord_t, gui::Surface::GetBgColor(), gui::Surface::GetClientRectPtr(), gui::Surface::GetFgColor(), gui::Surface::GetH(), and gui::Surface::GetTTFont().

00094 { 00095 SDL_Rect *area = GetClientRectPtr(); 00096 Uint32 color; 00097 TTFont *font = GetTTFont(); 00098 SDL_Color fg; 00099 SDL_Color bg; 00100 00101 /* 00102 if (IsInverted()) 00103 { 00104 color = GetBgColor(); 00105 memmove(&fg,&color,4); 00106 color = GetFgColor(); 00107 memmove(&bg,&color,4); 00108 } 00109 else 00110 { 00111 */ 00112 color = GetFgColor(); 00113 memmove(&fg,&color,4); 00114 color = GetBgColor(); 00115 memmove(&bg,&color,4); 00116 // } 00117 00118 // color 0 - transparent 00119 SDL_FillRect(m_screen, area, color); 00120 00121 if (font && font -> GetFont()) 00122 { 00123 coord_t h = font -> GetH(); 00124 coord_t y = GetH() / 2 + h / 2; 00125 00126 sge_tt_textoutf(m_screen, font -> GetFont(), 00127 GetH() + 4,y, 00128 fg.r,fg.g,fg.b, 00129 bg.r,bg.g,bg.b, 00130 SDL_ALPHA_OPAQUE, 00131 "%s",GetText()); 00132 } 00133 }

void gui::MenuItem::DumpMembers FILE *   )  [virtual]
 

Reimplemented from gui::Surface.

Reimplemented in gui::PopupMenuItem.

Definition at line 179 of file MenuItem.cpp.

References m_bClickCloses, and util::Xml::Write().

00180 { 00181 Xml xml(fil); 00182 00183 Surface::DumpMembers(fil); 00184 00185 xml.Write("CLICKCLOSES",m_bClickCloses); 00186 }

void gui::MenuItem::OnClick coord_t  ,
coord_t 
[virtual]
 

Reimplemented from gui::Surface.

Reimplemented in gui::PopupMenuItem.

Definition at line 156 of file MenuItem.cpp.

References gui::Surface::CloseAll(), gui::Surface::GetBond(), gui::Surface::GetParent(), m_bClickCloses, gui::Surface::OnButton(), and gui::Surface::RemoveAllBonds().

00157 { 00158 if (m_bClickCloses) 00159 { 00160 Surface *head = GetParent(); 00161 00162 while (head -> GetBond()) 00163 { 00164 head = head -> GetBond(); 00165 } 00166 head -> CloseAll(); 00167 head -> RemoveAllBonds(); 00168 } 00169 OnButton(); 00170 }

void gui::MenuItem::OnMouseIn  )  [virtual]
 

Reimplemented from gui::Surface.

Definition at line 136 of file MenuItem.cpp.

References gui::Surface::IsClickable().

00137 { 00138 if (IsClickable()) 00139 { 00140 SetInverted(true); 00141 SetDirty(true); 00142 } 00143 }

void gui::MenuItem::OnMouseOut  )  [virtual]
 

Reimplemented from gui::Surface.

Definition at line 146 of file MenuItem.cpp.

References gui::Surface::IsClickable().

00147 { 00148 if (IsClickable()) 00149 { 00150 SetInverted(false); 00151 SetDirty(true); 00152 } 00153 }

void gui::MenuItem::SetClickCloses bool   ) 
 

Definition at line 173 of file MenuItem.cpp.

References m_bClickCloses.

00174 { 00175 m_bClickCloses = b; 00176 }


Member Data Documentation

bool gui::MenuItem::m_bClickCloses [private]
 

Definition at line 42 of file MenuItem.h.

Referenced by DumpMembers(), OnClick(), and SetClickCloses().


The documentation for this class was generated from the following files:
Generated for My SDL C++ Gui by doxygen 1.3.6

www.TV-friendship.com
The matchmaking service with an all new twist.

Quantum 'Teleportation'
Some thoughts
Page, code, and content Copyright (C) 2004 by Anders Hedström