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

gui::Button Class Reference

#include <Button.h>

Inheritance diagram for gui::Button:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Button (Surface *, coord_t x, coord_t y, coord_t w, coord_t h, SurfaceHelper *=NULL)
 Button (Surface *, coord_t x, coord_t y, buttonstyle_t, SurfaceHelper *=NULL)
 ~Button ()
void Draw ()
SDL_Surface * GetScreen ()

Private Attributes

SDL_Surface * m_screen_inverted
SDL_Surface * m_screen_inactive
buttonstyle_t m_style

Constructor & Destructor Documentation

gui::Button::Button Surface ,
coord_t  x,
coord_t  y,
coord_t  w,
coord_t  h,
SurfaceHelper = NULL
 

Definition at line 58 of file Button.cpp.

References BUTTON_DEFAULT_BG_B, BUTTON_DEFAULT_BG_G, BUTTON_DEFAULT_BG_R, BUTTON_DEFAULT_FC_B, BUTTON_DEFAULT_FC_G, BUTTON_DEFAULT_FC_R, BUTTON_DEFAULT_FG_B, BUTTON_DEFAULT_FG_G, BUTTON_DEFAULT_FG_R, BUTTON_DEFAULT_FW, gui::coord_t, m_screen_inactive, and m_screen_inverted.

00059 :Surface(s,x,y,w,h,pclHelper) 00060 ,m_screen_inverted(NULL) 00061 ,m_screen_inactive(NULL) 00062 ,m_style(0) 00063 { 00064 SetBgColor(BUTTON_DEFAULT_BG_R,BUTTON_DEFAULT_BG_G,BUTTON_DEFAULT_BG_B); 00065 SetFgColor(BUTTON_DEFAULT_FG_R,BUTTON_DEFAULT_FG_G,BUTTON_DEFAULT_FG_B); 00066 SetFrameWidth(BUTTON_DEFAULT_FW); 00067 SetFrameColor(BUTTON_DEFAULT_FC_R,BUTTON_DEFAULT_FC_G,BUTTON_DEFAULT_FC_B); 00068 00069 m_screen_inverted = CreateSDLSurface(true); 00070 m_screen_inactive = CreateSDLSurface(true); 00071 }

gui::Button::Button Surface ,
coord_t  x,
coord_t  y,
buttonstyle_t  ,
SurfaceHelper = NULL
 

Definition at line 74 of file Button.cpp.

References BUTTON_DEFAULT_BG_B, BUTTON_DEFAULT_BG_G, BUTTON_DEFAULT_BG_R, BUTTON_DEFAULT_FC_B, BUTTON_DEFAULT_FC_G, BUTTON_DEFAULT_FC_R, BUTTON_DEFAULT_FG_B, BUTTON_DEFAULT_FG_G, BUTTON_DEFAULT_FG_R, BUTTON_DEFAULT_FW, m_screen_inactive, m_screen_inverted, and SBSIZE.

00075 :Surface(s,x,y,SBSIZE,SBSIZE,pclHelper) 00076 ,m_screen_inverted(NULL) 00077 ,m_screen_inactive(NULL) 00078 ,m_style(st) 00079 { 00080 SetBgColor(BUTTON_DEFAULT_BG_R,BUTTON_DEFAULT_BG_G,BUTTON_DEFAULT_BG_B); 00081 SetFgColor(BUTTON_DEFAULT_FG_R,BUTTON_DEFAULT_FG_G,BUTTON_DEFAULT_FG_B); 00082 SetFrameWidth(BUTTON_DEFAULT_FW); 00083 SetFrameColor(BUTTON_DEFAULT_FC_R,BUTTON_DEFAULT_FC_G,BUTTON_DEFAULT_FC_B); 00084 00085 m_screen_inverted = CreateSDLSurface(true); 00086 m_screen_inactive = CreateSDLSurface(true); 00087 }

gui::Button::~Button  ) 
 

Definition at line 90 of file Button.cpp.

References m_screen_inactive, and m_screen_inverted.

00091 { 00092 if (m_screen_inverted) 00093 { 00094 SDL_FreeSurface(m_screen_inverted); 00095 } 00096 if (m_screen_inactive) 00097 { 00098 SDL_FreeSurface(m_screen_inactive); 00099 } 00100 }


Member Function Documentation

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

Reimplemented from gui::Surface.

Definition at line 103 of file Button.cpp.

References BUTTONSTYLE_SBDOWN, BUTTONSTYLE_SBLEFT, BUTTONSTYLE_SBRIGHT, BUTTONSTYLE_SBUP, gui::coord_t, DEB, gui::Surface::GetBgColor(), gui::Surface::GetClientRectPtr(), gui::Surface::GetFgColor(), gui::Surface::GetFrameColor(), gui::Surface::GetFrameWidth(), gui::Surface::GetH(), gui::Surface::GetText(), gui::Surface::GetTTFont(), gui::Surface::GetW(), m_screen_inverted, m_style, SDL_fillTriangle(), and SPACED.

00104 { 00105 SDL_Rect *area = GetClientRectPtr(); 00106 // color_t color = GetBgColor(); 00107 TTFont *font = GetTTFont(); 00108 SDL_Color fg; 00109 SDL_Color bg; 00110 coord_t x1; 00111 coord_t y1; 00112 coord_t x2; 00113 coord_t y2; 00114 coord_t x3; 00115 coord_t y3; 00116 // bool bMinneInverted = IsInverted(); 00117 00118 // SetInverted(false); 00119 00120 DEB(printf(" ******** Button redraw\n");) 00121 00122 GetFgColor(fg); 00123 GetBgColor(bg); 00124 00125 #define SPACED 3 00126 00127 switch (m_style) 00128 { 00129 case BUTTONSTYLE_SBUP: // Scrollbar 00130 x1 = area -> w / 2; 00131 y1 = SPACED; 00132 x2 = SPACED; 00133 y2 = area -> h - SPACED; 00134 x3 = area -> w - SPACED; 00135 y3 = area -> h - SPACED; 00136 // m_screen 00137 SDL_FillRect(m_screen, area, GetBgColor()); 00138 SDL_fillTriangle(m_screen, x1,y1, x2,y2, x3,y3, GetFgColor()); 00139 // m_screen_inverted 00140 SDL_FillRect(m_screen_inverted, area, GetFgColor()); 00141 SDL_fillTriangle(m_screen_inverted, x1,y1, x2,y2, x3,y3, GetBgColor()); 00142 // m_screen_inactive 00143 break; 00144 case BUTTONSTYLE_SBDOWN: // Scrollbar 00145 x1 = SPACED; 00146 y1 = SPACED; 00147 x2 = area -> w - SPACED; 00148 y2 = SPACED; 00149 x3 = area -> w / 2; 00150 y3 = area -> h - SPACED; 00151 // m_screen 00152 SDL_FillRect(m_screen, area, GetBgColor()); 00153 SDL_fillTriangle(m_screen, x1,y1, x2,y2, x3,y3, GetFgColor()); 00154 // m_screen_inverted 00155 SDL_FillRect(m_screen_inverted, area, GetFgColor()); 00156 SDL_fillTriangle(m_screen_inverted, x1,y1, x2,y2, x3,y3, GetBgColor()); 00157 // m_screen_inactive 00158 break; 00159 case BUTTONSTYLE_SBRIGHT: // Scrollbar 00160 x1 = SPACED; 00161 y1 = SPACED; 00162 x2 = area -> w - SPACED; 00163 y2 = area -> h / 2; 00164 x3 = SPACED; 00165 y3 = area -> h - SPACED; 00166 // m_screen 00167 SDL_FillRect(m_screen, area, GetBgColor()); 00168 SDL_fillTriangle(m_screen, x1,y1, x2,y2, x3,y3, GetFgColor()); 00169 // m_screen_inverted 00170 SDL_FillRect(m_screen_inverted, area, GetFgColor()); 00171 SDL_fillTriangle(m_screen_inverted, x1,y1, x2,y2, x3,y3, GetBgColor()); 00172 // m_screen_inactive 00173 break; 00174 case BUTTONSTYLE_SBLEFT: // Scrollbar 00175 x1 = SPACED; 00176 y1 = area -> h / 2; 00177 x2 = area -> w - SPACED; 00178 y2 = SPACED; 00179 x3 = area -> w - SPACED; 00180 y3 = area -> h - SPACED; 00181 // m_screen 00182 SDL_FillRect(m_screen, area, GetBgColor()); 00183 SDL_fillTriangle(m_screen, x1,y1, x2,y2, x3,y3, GetFgColor()); 00184 // m_screen_inverted 00185 SDL_FillRect(m_screen, area, GetFgColor()); 00186 SDL_fillTriangle(m_screen, x1,y1, x2,y2, x3,y3, GetBgColor()); 00187 // m_screen_inactive 00188 break; 00189 00190 default: 00191 { 00192 // Normal 00193 SDL_FillRect(m_screen, area, GetBgColor()); 00194 00195 if (font && font -> GetFont()) 00196 { 00197 SDL_Rect rect = sge_TTF_TextSize(font -> GetFont(), (char *)GetText()); 00198 coord_t x = GetW() / 2 - rect.w / 2; 00199 coord_t y = GetH() / 2 + font -> GetH() / 2; 00200 00201 sge_tt_textoutf(m_screen, font -> GetFont(), 00202 x,y, 00203 fg.r,fg.g,fg.b, 00204 bg.r,bg.g,bg.b, 00205 SDL_ALPHA_OPAQUE, 00206 "%s",GetText() ); 00207 } 00208 DrawFrame(m_screen, GetFrameWidth(), GetFrameColor()); 00209 00210 // Inverted 00211 SDL_FillRect(m_screen_inverted, area, GetFgColor()); 00212 00213 if (font && font -> GetFont()) 00214 { 00215 SDL_Rect rect = sge_TTF_TextSize(font -> GetFont(), (char *)GetText()); 00216 coord_t x = GetW() / 2 - rect.w / 2; 00217 coord_t y = GetH() / 2 + font -> GetH() / 2; 00218 00219 sge_tt_textoutf(m_screen_inverted, font -> GetFont(), 00220 x,y, 00221 bg.r,bg.g,bg.b, 00222 fg.r,fg.g,fg.b, 00223 SDL_ALPHA_OPAQUE, 00224 "%s",GetText() ); 00225 } 00226 DrawFrame(m_screen_inverted, GetFrameWidth(), GetFrameColor()); 00227 00228 // Inactive 00229 } // case 0 00230 break; 00231 } // switch (m_style) 00232 // SetInverted(bMinneInverted); 00233 }

SDL_Surface * gui::Button::GetScreen  )  [virtual]
 

Reimplemented from gui::Surface.

Definition at line 236 of file Button.cpp.

References gui::Surface::IsInverted(), and m_screen_inverted.

00237 { 00238 if (IsInverted()) 00239 { 00240 return m_screen_inverted; 00241 } 00242 /* 00243 if (IsInactive()) 00244 { 00245 return m_screen_inactive; 00246 } 00247 */ 00248 return m_screen; 00249 }


Member Data Documentation

SDL_Surface* gui::Button::m_screen_inactive [private]
 

Definition at line 46 of file Button.h.

Referenced by Button(), and ~Button().

SDL_Surface* gui::Button::m_screen_inverted [private]
 

Definition at line 45 of file Button.h.

Referenced by Button(), Draw(), GetScreen(), and ~Button().

buttonstyle_t gui::Button::m_style [private]
 

Definition at line 47 of file Button.h.

Referenced by Draw().


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