Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CEGUIStaticTextProperties.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIStaticTextProperties.cpp
00003         created:        10/7/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Implements properties for the StaticText class
00007 *************************************************************************/
00008 /*************************************************************************
00009     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00010     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00011 
00012     This library is free software; you can redistribute it and/or
00013     modify it under the terms of the GNU Lesser General Public
00014     License as published by the Free Software Foundation; either
00015     version 2.1 of the License, or (at your option) any later version.
00016 
00017     This library is distributed in the hope that it will be useful,
00018     but WITHOUT ANY WARRANTY; without even the implied warranty of
00019     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020     Lesser General Public License for more details.
00021 
00022     You should have received a copy of the GNU Lesser General Public
00023     License along with this library; if not, write to the Free Software
00024     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025 *************************************************************************/
00026 #include "elements/CEGUIStaticTextProperties.h"
00027 #include "elements/CEGUIStaticText.h"
00028 #include "CEGUIPropertyHelper.h"
00029 
00030 
00031 // Start of CEGUI namespace section
00032 namespace CEGUI
00033 {
00034 
00035 // Start of StaticTextProperties namespace section
00036 namespace StaticTextProperties
00037 {
00038 String  TextColours::get(const PropertyReceiver* receiver) const
00039 {
00040         return PropertyHelper::colourRectToString(static_cast<const StaticText*>(receiver)->getTextColours());
00041 }
00042 
00043 
00044 void    TextColours::set(PropertyReceiver* receiver, const String& value)
00045 {
00046         static_cast<StaticText*>(receiver)->setTextColours(PropertyHelper::stringToColourRect(value));
00047 }
00048 
00049 
00050 String  HorzFormatting::get(const PropertyReceiver* receiver) const
00051 {
00052         switch(static_cast<const StaticText*>(receiver)->getHorizontalFormatting())
00053         {
00054         case StaticText::RightAligned:
00055                 return String((utf8*)"RightAligned");
00056                 break;
00057 
00058         case StaticText::HorzCentred:
00059                 return String((utf8*)"HorzCentred");
00060                 break;
00061 
00062         case StaticText::HorzJustified:
00063                 return String((utf8*)"HorzJustified");
00064                 break;
00065 
00066         case StaticText::WordWrapLeftAligned:
00067                 return String((utf8*)"WordWrapLeftAligned");
00068                 break;
00069 
00070         case StaticText::WordWrapRightAligned:
00071                 return String((utf8*)"WordWrapRightAligned");
00072                 break;
00073 
00074         case StaticText::WordWrapCentred:
00075                 return String((utf8*)"WordWrapCentred");
00076                 break;
00077 
00078         case StaticText::WordWrapJustified:
00079                 return String((utf8*)"WordWrapJustified");
00080                 break;
00081 
00082         default:
00083                 return String((utf8*)"LeftAligned");
00084                 break;
00085         }
00086 }
00087 
00088 
00089 void    HorzFormatting::set(PropertyReceiver* receiver, const String& value)
00090 {
00091         StaticText::HorzFormatting fmt;
00092 
00093         if (value == (utf8*)"RightAligned")
00094         {
00095                 fmt = StaticText::RightAligned;
00096         }
00097         else if (value == (utf8*)"HorzCentred")
00098         {
00099                 fmt = StaticText::HorzCentred;
00100         }
00101         else if (value == (utf8*)"HorzJustified")
00102         {
00103                 fmt = StaticText::HorzJustified;
00104         }
00105         else if (value == (utf8*)"WordWrapLeftAligned")
00106         {
00107                 fmt = StaticText::WordWrapLeftAligned;
00108         }
00109         else if (value == (utf8*)"WordWrapRightAligned")
00110         {
00111                 fmt = StaticText::WordWrapRightAligned;
00112         }
00113         else if (value == (utf8*)"WordWrapCentred")
00114         {
00115                 fmt = StaticText::WordWrapCentred;
00116         }
00117         else if (value == (utf8*)"WordWrapJustified")
00118         {
00119                 fmt = StaticText::WordWrapJustified;
00120         }
00121         else
00122         {
00123                 fmt = StaticText::LeftAligned;
00124         }
00125 
00126         static_cast<StaticText*>(receiver)->setHorizontalFormatting(fmt);
00127 }
00128 
00129 
00130 String  VertFormatting::get(const PropertyReceiver* receiver) const
00131 {
00132         switch(static_cast<const StaticText*>(receiver)->getVerticalFormatting())
00133         {
00134         case StaticText::BottomAligned:
00135                 return String((utf8*)"BottomAligned");
00136                 break;
00137 
00138         case StaticText::VertCentred:
00139                 return String((utf8*)"VertCentred");
00140                 break;
00141 
00142         default:
00143                 return String((utf8*)"TopAligned");
00144                 break;
00145         }
00146 }
00147 
00148 
00149 void    VertFormatting::set(PropertyReceiver* receiver, const String& value)
00150 {
00151         StaticText::VertFormatting fmt;
00152 
00153         if (value == (utf8*)"BottomAligned")
00154         {
00155                 fmt = StaticText::BottomAligned;
00156         }
00157         else if (value == (utf8*)"VertCentred")
00158         {
00159                 fmt = StaticText::VertCentred;
00160         }
00161         else
00162         {
00163                 fmt = StaticText::TopAligned;
00164         }
00165 
00166         static_cast<StaticText*>(receiver)->setVerticalFormatting(fmt);
00167 }
00168 
00169 
00170 String  VertScrollbar::get(const PropertyReceiver* receiver) const
00171 {
00172         return PropertyHelper::boolToString(static_cast<const StaticText*>(receiver)->isVerticalScrollbarEnabled());
00173 }
00174 
00175 
00176 void    VertScrollbar::set(PropertyReceiver* receiver, const String& value)
00177 {
00178         static_cast<StaticText*>(receiver)->setVerticalScrollbarEnabled(PropertyHelper::stringToBool(value));
00179 }
00180 
00181 String  HorzScrollbar::get(const PropertyReceiver* receiver) const
00182 {
00183         return PropertyHelper::boolToString(static_cast<const StaticText*>(receiver)->isHorizontalScrollbarEnabled());
00184 }
00185 
00186 
00187 void    HorzScrollbar::set(PropertyReceiver* receiver, const String& value)
00188 {
00189         static_cast<StaticText*>(receiver)->setHorizontalScrollbarEnabled(PropertyHelper::stringToBool(value));
00190 }
00191 
00192 } // End of  StaticTextProperties namespace section
00193 
00194 } // End of  CEGUI namespace section

Generated on Wed Sep 7 09:56:34 2005 for Crazy Eddies GUI System by  doxygen 1.4.3