Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

Ars::XCheckBox Class Reference

A checkbox control. More...

#include <xcheckbox.h>

Inheritance diagram for Ars::XCheckBox:

Inheritance graph
[legend]
Collaboration diagram for Ars::XCheckBox:

Collaboration graph
[legend]

Public Member Functions

 XCheckBox (void)
 ~XCheckBox (void)
 Standard destructor.

virtual const bool SetupWindow (const Message &msg)
 Deregister the setup_window message.

virtual const bool ToggleCheck (void)
virtual void Draw (void)
 Draws the checkbox.

virtual const bool evMouseButtonUp (const MouseMessage &msg)
virtual const bool evMouseLClick (const CtrlMessage &msg)

Detailed Description

A checkbox control.

The checkbox will generate CTRL_xCLICK messages when clicked with the mouse (where x is the button L,M,R) It will also generate a CTRL_VALUECHANGE message whenever the checkbox is toggled Checkboxes do not display their own labels

Definition at line 12 of file xcheckbox.h.


Constructor & Destructor Documentation

Ars::XCheckBox::XCheckBox void   ) 
 

Constructs a new checkbox

Parameters:
WindowRect A CRect that defines the outer limits of the control
aStr the rest of the resource to initialize the object

Definition at line 6 of file xcheckbox.cpp.

00007 {
00008 }

Ars::XCheckBox::~XCheckBox void   ) 
 

Standard destructor.

Definition at line 10 of file xcheckbox.cpp.

00011 {
00012 }


Member Function Documentation

void Ars::XCheckBox::Draw void   )  [virtual]
 

Draws the checkbox.

Default the text is on the right side of the check box...

Reimplemented from Ars::XLabel.

Definition at line 26 of file xcheckbox.cpp.

References Ars::XRect::BottomLeft(), Ars::XRect::BottomRight(), Ars::HPaint::DrawLine(), Ars::HPaint::DrawRect(), Ars::XBox::DrawSunken(), Ars::RGBColor::FadeColor(), Ars::Thing::GetBgColor(), Ars::Thing::GetFgColor(), Ars::HPaint::GetFontSize(), Ars::Painter::GetStates(), Ars::Thing::GetWindowRect(), Ars::XRect::Grow(), HALIGN_MASK, Ars::XRect::Height(), Ars::Thing::ResetState(), S_ALIGN_LEFT, S_CHECKED, Ars::XRect::SetRight(), Ars::Thing::SetState(), Ars::XRect::TopLeft(), Ars::XRect::TopRight(), and VALIGN_MASK.

00027 {
00028         XRect   r( GetWindowRect() );
00029 
00031         x += Height();
00032         const unsigned long     stateBak = GetStates();
00033         ResetState( VALIGN_MASK|HALIGN_MASK );
00034         SetState( S_ALIGN_LEFT );
00035         XLabel::Draw();
00036         SetState( stateBak );
00037         x -= Height();
00038 
00039         //      delimit the right border to the box
00040         r.SetRight( r.x + r.Height() );
00041         
00042         r.Grow( (r.Height() - GetFontSize()) / (-2) );
00043         DrawSunken( r , GetBgColor() );
00044         r.Grow( -1 );
00045 
00046         DrawRect( r , true , GetFgColor().FadeColor( 32 ) , GetFgColor().FadeColor( 64 ) );
00047         
00048         if( GetStates() & S_CHECKED )
00049         {
00050                 DrawLine( r.TopLeft() , r.BottomRight() , GetFgColor().FadeColor( -32 ) );
00051                 DrawLine( r.TopLeft() + XPoint( 1 , 0 ) , r.BottomRight() + XPoint( 0 , -1 ) , GetFgColor().FadeColor( 32 ) );
00052                 DrawLine( r.TopRight() , r.BottomLeft() , GetFgColor().FadeColor( -32 ) );
00053                 DrawLine( r.TopRight() + XPoint( 0 , 1 ) , r.BottomLeft() + XPoint( 1 , 0 ) , GetFgColor().FadeColor( 32 ) );
00054         }
00055 }

const bool Ars::XCheckBox::evMouseButtonUp const MouseMessage msg  )  [virtual]
 

Reimplemented from Ars::Window.

Definition at line 57 of file xcheckbox.cpp.

References ArsSendMessage.

00058 {
00059         bool ans = XLabel::evMouseButtonUp( msg );
00060 
00061         if( ans )
00062                 ArsSendMessage( CtrlMessage( Message::CTRL_LCLICK, this, this, 0 ) );
00063 
00064         return ans;
00065 }

const bool Ars::XCheckBox::evMouseLClick const CtrlMessage msg  )  [virtual]
 

Reimplemented from Ars::MessageClient.

Definition at line 67 of file xcheckbox.cpp.

References ArsSendMessage, Ars::Message::Destination(), Ars::Window::GetParent(), Ars::Painter::GetStates(), S_DISABLED, and ToggleCheck().

00068 {
00069         bool    ans = XLabel::evMouseLClick( msg );
00070 
00071         if( (GetStates() & S_DISABLED) != S_DISABLED )
00072         {
00073                 if( msg.Destination() == this )
00074                 {
00075                         ArsSendMessage( CtrlMessage( Message::CTRL_VALUECHANGE , GetParent() , this , ToggleCheck() ) );
00076                         ans = true;
00077                 }
00078         }
00079         return ans;
00080 }

const bool Ars::XCheckBox::SetupWindow const Message msg  )  [virtual]
 

Deregister the setup_window message.

Reimplemented from Ars::XLabel.

Definition at line 14 of file xcheckbox.cpp.

00015 {
00016         XLabel::SetupWindow( msg );
00017 
00018         MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_BUTTONDOWN);
00019         MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_BUTTONUP);
00020         MessageServer::Instance().RegisterMessageClient(this, Message::MOUSE_MOVE);
00021         MessageServer::Instance().RegisterMessageClient(this, Message::CTRL_LCLICK);
00022         
00023         return true;
00024 }

virtual const bool Ars::XCheckBox::ToggleCheck void   )  [inline, virtual]
 

Definition at line 27 of file xcheckbox.h.

References Ars::Thing::ResetState(), S_CHECKED, and Ars::Thing::SetState().

Referenced by evMouseLClick().

00028         {
00029                 if( !SetState( S_CHECKED ) )
00030                 {
00031                         ResetState( S_CHECKED );
00032                         return false;
00033                 }
00034                 return true;
00035         }


The documentation for this class was generated from the following files:
Generated on Fri Dec 5 04:06:55 2003 for Borqueror by doxygen 1.3.3