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

gui::ScrollBarV Class Reference

#include <ScrollBarV.h>

Inheritance diagram for gui::ScrollBarV:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ScrollBarV (Surface *, coord_t x, coord_t y, coord_t w, coord_t h, SurfaceHelper *=NULL)
 ScrollBarV (Surface *, SurfaceHelper *=NULL)
 ~ScrollBarV ()
void Draw ()
void SetPos (long)
void SetMax (long, long=1)
long GetPos ()
void OnEvent (surface_event_t *)

Private Attributes

HotButton m_up
HotButton m_down
long m_pos
long m_max
long m_step

Constructor & Destructor Documentation

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

Definition at line 60 of file ScrollBarV.cpp.

References BUTTONSTYLE_SBDOWN, BUTTONSTYLE_SBUP, gui::coord_t, m_down, m_up, and SBSIZE.

00061 :Surface(s,x,y,w,h,sh) 00062 ,m_up(this, w - SBSIZE, 0, BUTTONSTYLE_SBUP) 00063 ,m_down(this, w - SBSIZE, h - SBSIZE, BUTTONSTYLE_SBDOWN) 00064 ,m_pos(0) 00065 ,m_max(100) 00066 ,m_step(1) 00067 { 00068 SetBgColor(128,128,0); 00069 SetFgColor(255,255,128); 00070 SetFrameWidth(0); 00071 SetFrameColor(0,255,128); 00072 00073 AddChild(&m_up); 00074 AddChild(&m_down); 00075 }

gui::ScrollBarV::ScrollBarV Surface ,
SurfaceHelper = NULL
 

Definition at line 78 of file ScrollBarV.cpp.

References BUTTONSTYLE_SBDOWN, BUTTONSTYLE_SBUP, m_down, m_up, and SBSIZE.

00079 :Surface(s,s -> GetClientRectPtr() -> w - SBSIZE,0, 00080 SBSIZE, 00081 s -> GetClientRectPtr() -> h - SBSIZE, /* avoid hotspot */ 00082 sh) 00083 ,m_up(this, GetW() - SBSIZE, 0, BUTTONSTYLE_SBUP) 00084 ,m_down(this, GetW() - SBSIZE, GetH() - SBSIZE, BUTTONSTYLE_SBDOWN) 00085 ,m_pos(0) 00086 ,m_max(100) 00087 ,m_step(1) 00088 { 00089 SetBgColor(128,128,0); 00090 SetFgColor(255,255,128); 00091 SetFrameWidth(0); 00092 SetFrameColor(0,255,128); 00093 00094 AddChild(&m_up); 00095 AddChild(&m_down); 00096 }

gui::ScrollBarV::~ScrollBarV  ) 
 

Definition at line 99 of file ScrollBarV.cpp.

00100 { 00101 }


Member Function Documentation

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

Reimplemented from gui::Surface.

Definition at line 149 of file ScrollBarV.cpp.

References gui::Surface::GetBgColor(), gui::Surface::GetClientRect(), gui::Surface::GetFgColor(), m_max, m_pos, m_step, and SBSIZE.

00150 { 00151 SDL_Rect a = GetClientRect(); 00152 long range = a.h - 2 * SBSIZE - SBSIZE / 2; 00153 long y; 00154 long h; 00155 00156 SDL_FillRect(m_screen, &a, GetBgColor()); 00157 00158 y = (m_pos * range) / m_max + SBSIZE; 00159 h = (m_step * range) / m_max; 00160 if (h < SBSIZE / 2) 00161 { 00162 h = SBSIZE / 2; 00163 } 00164 a.y = y; 00165 a.h = h; 00166 SDL_FillRect(m_screen, &a, GetFgColor()); 00167 a.x++; 00168 a.y++; 00169 a.w -= 2; 00170 a.h -= 2; 00171 SDL_FillRect(m_screen, &a, GetBgColor()); 00172 }

long gui::ScrollBarV::GetPos  ) 
 

Definition at line 118 of file ScrollBarV.cpp.

References m_pos.

00119 { 00120 return m_pos; 00121 }

void gui::ScrollBarV::OnEvent surface_event_t  )  [virtual]
 

Reimplemented from gui::Surface.

Definition at line 124 of file ScrollBarV.cpp.

References gui::Surface::GetLocalID(), GUI_EVENT_BUTTON, m_down, m_max, m_pos, m_step, m_up, and gui::surface_event_t.

00125 { 00126 if (pstEvent -> type == GUI_EVENT_BUTTON) 00127 { 00128 if (pstEvent -> local_id == m_down.GetLocalID()) 00129 { 00130 if (m_pos + m_step < m_max) 00131 { 00132 m_pos += m_step; 00133 SetDirty(true); 00134 } 00135 } 00136 else 00137 if (pstEvent -> local_id == m_up.GetLocalID()) 00138 { 00139 if (m_pos - m_step >= 0) 00140 { 00141 m_pos -= m_step; 00142 SetDirty(true); 00143 } 00144 } 00145 } 00146 }

void gui::ScrollBarV::SetMax long  ,
long  = 1
 

Definition at line 111 of file ScrollBarV.cpp.

References m_max, and m_step.

00112 { 00113 m_max = l; 00114 m_step = step; 00115 }

void gui::ScrollBarV::SetPos long   ) 
 

Definition at line 104 of file ScrollBarV.cpp.

References m_pos.

00105 { 00106 m_pos = l; 00107 SetDirty(true); 00108 }


Member Data Documentation

HotButton gui::ScrollBarV::m_down [private]
 

Definition at line 46 of file ScrollBarV.h.

Referenced by OnEvent(), and ScrollBarV().

long gui::ScrollBarV::m_max [private]
 

Definition at line 48 of file ScrollBarV.h.

Referenced by Draw(), OnEvent(), and SetMax().

long gui::ScrollBarV::m_pos [private]
 

Definition at line 47 of file ScrollBarV.h.

Referenced by Draw(), GetPos(), OnEvent(), and SetPos().

long gui::ScrollBarV::m_step [private]
 

Definition at line 49 of file ScrollBarV.h.

Referenced by Draw(), OnEvent(), and SetMax().

HotButton gui::ScrollBarV::m_up [private]
 

Definition at line 45 of file ScrollBarV.h.

Referenced by OnEvent(), and ScrollBarV().


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