CheckBox Class Reference

#include <check_box.h>

Inheritance diagram for CheckBox:

Inheritance graph
[legend]
Collaboration diagram for CheckBox:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 CheckBox (const std::string &label, const Rectanglei &rect, bool value=true)
 ~CheckBox ()
void Draw (const Point2i &mousePosition, Surface &surf) const
WidgetClic (const Point2i &mousePosition, uint button)
void SetSizePosition (const Rectanglei &rect)
bool GetValue () const
void SetValue (bool value)
void SetVisible (bool visible)

Protected Attributes

Texttxt_label
bool m_value
Spritem_checked_image
bool hidden

Detailed Description

Definition at line 31 of file check_box.h.


Constructor & Destructor Documentation

CheckBox::CheckBox ( const std::string &  label,
const Rectanglei rect,
bool  value = true 
)

Definition at line 27 of file check_box.cpp.

00028 {
00029   Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false);   
00030   m_checked_image = resource_manager.LoadSprite( res, "menu/check");
00031   resource_manager.UnLoadXMLProfile( res);
00032   
00033   m_checked_image->cache.EnableLastFrameCache();
00034  
00035   SetPosition( rect.GetPosition() );
00036   SetSize( rect.GetSize() );
00037 
00038   SetSizeY( (*Font::GetInstance(Font::FONT_SMALL)).GetHeight() );
00039   m_value = value;
00040 
00041   txt_label = new Text(label, white_color, Font::GetInstance(Font::FONT_SMALL));
00042   hidden = false;
00043 }

Here is the call graph for this function:

CheckBox::~CheckBox (  ) 

Definition at line 45 of file check_box.cpp.

00046 {
00047   delete m_checked_image;
00048   delete txt_label;
00049 }


Member Function Documentation

Widget * CheckBox::Clic ( const Point2i mousePosition,
uint  button 
) [virtual]

Reimplemented from Widget.

Definition at line 66 of file check_box.cpp.

00067 {
00068   need_redrawing = true;
00069   m_value = !m_value;
00070   return this ;
00071 }

void CheckBox::Draw ( const Point2i mousePosition,
Surface surf 
) const [virtual]

Implements Widget.

Reimplemented in PictureTextCBox.

Definition at line 51 of file check_box.cpp.

00052 {
00053   if (!hidden)
00054     {
00055       txt_label->DrawTopLeft( GetPosition() );
00056       
00057       if (m_value)
00058         m_checked_image->SetCurrentFrame(0);
00059       else 
00060         m_checked_image->SetCurrentFrame(1);
00061       
00062       m_checked_image->Blit(surf, GetPositionX() + GetSizeX() - 16, GetPositionY());
00063     }
00064 }

Here is the call graph for this function:

bool CheckBox::GetValue (  )  const

Definition at line 78 of file check_box.cpp.

00079 {
00080   return m_value;
00081 }

Here is the caller graph for this function:

void CheckBox::SetSizePosition ( const Rectanglei rect  )  [virtual]

Implements Widget.

Reimplemented in PictureTextCBox.

Definition at line 73 of file check_box.cpp.

00074 {
00075   StdSetSizePosition(rect);
00076 }

Here is the call graph for this function:

void CheckBox::SetValue ( bool  value  ) 

Definition at line 83 of file check_box.cpp.

00084 {
00085   m_value = value;
00086 }

Here is the caller graph for this function:

void CheckBox::SetVisible ( bool  visible  ) 

Definition at line 88 of file check_box.cpp.

00089 {
00090   if (hidden == visible) {
00091     hidden = !visible;
00092     need_redrawing = true;
00093   }
00094 }

Here is the caller graph for this function:


Member Data Documentation

bool CheckBox::hidden [protected]

Definition at line 37 of file check_box.h.

Sprite* CheckBox::m_checked_image [protected]

Definition at line 36 of file check_box.h.

bool CheckBox::m_value [protected]

Definition at line 35 of file check_box.h.

Text* CheckBox::txt_label [protected]

Definition at line 34 of file check_box.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 13:41:51 2007 for Wormux by  doxygen 1.4.7