Game Accessibility Library logo SourceForge.net Logo
Game Accessibility Suite: CATGUI/CATLabel.cpp Source File

CATLabel.cpp

Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 /// \file CATLabel.cpp
00003 /// \brief Text label for GUI
00004 /// \ingroup CATGUI
00005 /// 
00006 /// Copyright (c) 2003-2008 by Michael Ellison.
00007 /// See COPYING.txt for the \ref gaslicense License (MIT License).
00008 ///
00009 // $Author: mikeellison $
00010 // $Date: 2008-01-23 01:43:25 -0600 (Wed, 23 Jan 2008) $
00011 // $Revision:   $
00012 // $NoKeywords: $
00013 //---------------------------------------------------------------------------
00014 #include "CATLabel.h"
00015 #include "CATWindow.h"
00016 #include "CATEventDefs.h"
00017 //---------------------------------------------------------------------------
00018 // CATLabel constructor (inherited from CATControl->CATXMLObject)
00019 // \param element - Type name ("Label")
00020 // \param attribs - attribute information for the window
00021 // \param parent - parent XML object (should be a "Window" element)
00022 // \param rootDir - root directory of skin for bin/png load
00023 //---------------------------------------------------------------------------
00024 CATLabel::CATLabel(    const CATString&             element, 
00025                    const CATString&             rootDir)
00026                    : CATControl(element,  rootDir)
00027 {
00028     fAllowClick = false;
00029 }
00030 //---------------------------------------------------------------------------
00031 // CATLabel destructor
00032 //---------------------------------------------------------------------------
00033 CATLabel::~CATLabel()
00034 {
00035 
00036 
00037 }
00038 
00039 /// IsFocusable() returns true if the control can receive
00040 /// focus, and false otherwise.
00041 bool CATLabel::IsFocusable() const
00042 {
00043     return fAllowClick;
00044 }
00045 
00046 /// ParseAttributes() parses the known attributes for an object.
00047 CATResult CATLabel::ParseAttributes()
00048 {
00049     CATResult result = CATControl::ParseAttributes();
00050     CATString attrib;
00051 
00052     fAllowClick = GetAttribute(L"AllowClick",fAllowClick);
00053 
00054     return result;
00055 }
00056 
00057 //---------------------------------------------------------------------------
00058 // Draw() draws the control into the parent window
00059 // \param dirtyRect - portion of control (in window coordinates)
00060 //        that requires redrawing.
00061 //---------------------------------------------------------------------------
00062 void CATLabel::Draw(CATImage* image, const CATRect& dirtyRect)
00063 {
00064     // post draw only for label
00065 }
00066 
00067 
00068 
00069 
00070 void CATLabel::SetString ( const CATString& text )
00071 {
00072     if (text != fText)
00073     {
00074         fText = text;
00075         this->MarkDirty();
00076     }
00077 }
00078 CATString CATLabel::GetString () const
00079 {
00080     return fText;
00081 }
00082 
00083 CATResult CATLabel::OnEvent(const CATEvent& event, CATInt32& retVal)
00084 {
00085     switch (event.fEventCode)
00086     {
00087     case  CATEVENT_GUI_VAL_CHANGE:
00088         // If our command string is the same as the GUI value, then
00089         // we should ensure that our value matches the one
00090         // in the event.
00091         //
00092         // fStringParam1 - command string
00093         // fStringParam2 - String parameter of command
00094         // fStringParam3 - String value of command, or empty if none
00095         // fFloatParam1  - Value of control
00096         // fVoidParam - ptr to control that caused it, or null.
00097         if (this->fCmdString.Compare(event.fStringParam1) == 0)
00098         {
00099             // MAke sure we're not the control that sent it...
00100             if (this != (CATControl*)event.fVoidParam)
00101             {
00102                 this->SetString(event.fStringParam3);
00103                 this->SetValue(event.fFloatParam1, false);
00104                 retVal++;
00105             }
00106         }
00107         break;
00108     default:
00109         return CATControl::OnEvent(event,retVal);
00110     }
00111     return CAT_SUCCESS;
00112 }

Generated on Mon Feb 11 04:09:54 2008 for Game Accessibility Suite by doxygen 1.5.4