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

CSCheckBox Class Reference

#include <CSCheckBox.h>

Inheritance diagram for CSCheckBox:

CSGrafikElement CSMessageDispatchable CSMessageListener

Public Member Functions

virtual std::string getType ()
 CSCheckBox (void)
virtual ~CSCheckBox ()
virtual void paint (SDL_Surface *destination, SDL_Rect *parentViewport)
void reactOnMessageCheckBox (CSMessage *message)
virtual void reactOnMessage (CSMessage *message)
 to be overloaded

virtual void layoutSetup ()

Static Public Attributes

const char * CLASS = "CSCheckBox"
 static element, name of this class (introsepection)


Protected Member Functions

void layoutSetupCheckBox ()

Constructor & Destructor Documentation

CSCheckBox::CSCheckBox void   ) 
 

Definition at line 12 of file CSCheckBox.cpp.

References BUTTON_DEFAULT, CHECKBOX_CHANGED_MESSAGE, layoutSetup(), LOG_ENTER, LOG_EXIT, CSGrafikElement::setLayoutManager(), and CSMessage::setSubtype().

00012                            : CSGrafikElement(0, 0)
00013 {
00014     static char *functionName="CSCheckBox";
00015     LOG_ENTER 
00016     mCheckState = false;
00017     mState = BUTTON_DEFAULT;
00018     setLayoutManager(new CSLayoutManagerXY());
00019 
00020     MESSAGE_CHECKBOX_CHANGED.setSubtype(CHECKBOX_CHANGED_MESSAGE);
00021     layoutSetup();
00022     LOG_EXIT
00023 }

Here is the call graph for this function:

virtual CSCheckBox::~CSCheckBox  )  [inline, virtual]
 

Definition at line 32 of file CSCheckBox.h.

00032 {}


Member Function Documentation

void CSCheckBox::layoutSetupCheckBox  )  [protected]
 

Definition at line 102 of file CSCheckBox.cpp.

References CSGrafikElement::getBorder(), CSLAF::getCurrentLAF(), CSBorder::getTotalHeight(), CSInset::getTotalHeight(), LOG_ENTER, and LOG_EXIT.

Referenced by layoutSetup().

00103 {
00104     static char *functionName="layoutSetupCheckBox";
00105     LOG_ENTER 
00106     CSLAF *laf = CSLAF::getCurrentLAF(); // make sure laf is loaded/initialized at least once
00107 
00108     mMinHeight = laf->getCheckBoxSize() - mInset.getTotalHeight() - getBorder()->getTotalHeight();
00109     mMinWidth = mMinHeight; // build a square
00110     
00111     mHeight = mMinHeight + mInset.getTotalHeight() + getBorder()->getTotalHeight();
00112     mWidth = mHeight; // build a square
00113 
00114     LOG_EXIT
00115 }

Here is the call graph for this function:

virtual std::string CSCheckBox::getType  )  [inline, virtual]
 

Reimplemented from CSGrafikElement.

Definition at line 30 of file CSCheckBox.h.

References CLASS.

00030 {return (std::string) CLASS;}

void CSCheckBox::paint SDL_Surface *  destination,
SDL_Rect *  parentViewport
[virtual]
 

Reimplemented from CSGrafikElement.

Definition at line 25 of file CSCheckBox.cpp.

References CSGrafikElement::getBorder(), CSGrafikElement::getElementArea(), CSInset::getSizeNorth(), CSBorder::getSizeNorth(), CSInset::getSizeWest(), CSBorder::getSizeWest(), CSBorder::getTotalWidth(), CSGrafikElement::getWidth(), and CSGrafikElement::line().

00026 {
00027     static char *functionName="paint";
00028     SDL_Rect elementArea = getElementArea();
00029     elementArea.x += parentViewport->x;
00030     elementArea.y += parentViewport->y;
00031     
00032     if (mCheckState)
00033     {
00034         int w = getWidth() - getBorder()->getTotalWidth() -1;
00035         int x = getBorder()->getSizeWest() + mInset.getSizeWest();
00036         int y = getBorder()->getSizeNorth() + mInset.getSizeNorth();
00037         line(destination, &elementArea,x,y+2*w/3,x+w/3,y+w,0x000000);
00038         line(destination, &elementArea,x+w/3,y+w,x+w,y,0x000000);
00039         x++;
00040         line(destination, &elementArea,x,y+2*w/3,x+w/3,y+w,0x000000);
00041         line(destination, &elementArea,x+w/3,y+w,x+w,y,0x000000);
00042     }
00043 }

Here is the call graph for this function:

void CSCheckBox::reactOnMessageCheckBox CSMessage message  ) 
 

Definition at line 50 of file CSCheckBox.cpp.

References GuiMessage::actionId, BUTTON_ENABLED, BUTTON_PRESSED, CSMessage::getSubtype(), CSMessage::getType(), GUI_MESSAGE, CSMessage::mIsHandled, MOUSE_BUTTON_PRESSED_MESSAGE, MOUSE_BUTTON_RELEASED_MESSAGE, GuiMessage::newCheckBoxState, CSGrafikElement::reactOnMessageGrafikElement(), GuiMessage::receiver, and CSMessageDispatchable::sendMessage().

Referenced by reactOnMessage().

00051 {
00052     static char *functionName="reactOnMessage";
00053     if (message->mIsHandled)
00054     {
00055         reactOnMessageGrafikElement(message);
00056         return;
00057     }
00058     if (message->getType() == GUI_MESSAGE)
00059     {
00060         GuiMessage *gm = (GuiMessage *) message;
00061         if (gm->receiver != this)
00062         {
00063             if (message->getSubtype() ==  MOUSE_BUTTON_RELEASED_MESSAGE)
00064             {
00065                 mState = mState & (~BUTTON_PRESSED);
00066                 gm->mIsHandled = true;
00067             }
00068         }
00069         else // receiver == this
00070         {
00071             switch (message->getSubtype())
00072             {
00073                 case MOUSE_BUTTON_RELEASED_MESSAGE:
00074                 {
00075                     mState = mState & (~BUTTON_PRESSED);
00076                     MESSAGE_CHECKBOX_CHANGED.actionId = mActionId;
00077                     MESSAGE_CHECKBOX_CHANGED.newCheckBoxState = mCheckState;
00078                     MESSAGE_CHECKBOX_CHANGED.mIsHandled = false;
00079                     sendMessage(MESSAGE_CHECKBOX_CHANGED);
00080                     gm->mIsHandled = true;
00081                     break;
00082                 }
00083 
00084                 case MOUSE_BUTTON_PRESSED_MESSAGE:
00085                 {
00086                     if (mState & BUTTON_ENABLED)
00087                     {
00088                         mState = mState | BUTTON_PRESSED;
00089                         mCheckState = !mCheckState;
00090 
00091                         // callback
00092                     }
00093                     gm->mIsHandled = true;
00094                     break;
00095                 }
00096             }
00097         }
00098     }
00099     reactOnMessageGrafikElement(message);
00100 }

Here is the call graph for this function:

void CSCheckBox::reactOnMessage CSMessage message  )  [virtual]
 

to be overloaded

Reimplemented from CSGrafikElement.

Definition at line 45 of file CSCheckBox.cpp.

References reactOnMessageCheckBox().

00046 {
00047     reactOnMessageCheckBox(message);
00048 }

Here is the call graph for this function:

virtual void CSCheckBox::layoutSetup  )  [inline, virtual]
 

Reimplemented from CSGrafikElement.

Definition at line 37 of file CSCheckBox.h.

References layoutSetupCheckBox().

Referenced by CSCheckBox().

Here is the call graph for this function:


Field Documentation

const char * CSCheckBox::CLASS = "CSCheckBox" [static]
 

static element, name of this class (introsepection)

Reimplemented from CSGrafikElement.

Definition at line 10 of file CSCheckBox.cpp.

Referenced by CSLAF::getBackgroundColorDisabledInternal(), CSLAF::getBackgroundColorEnabledInternal(), CSLAF::getBorderInternal(), CSLAF::getHorizontalElementSpacingInternal(), getType(), and CSLAF::getVerticalElementSpacingInternal().


Generated on Wed Jul 14 00:44:02 2004 for CSLib by doxygen 1.3.6