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

CEGUIStaticImageProperties.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIStaticImageProperties.cpp
00003         created:        10/7/2004
00004         author:         Paul D Turner
00005         
00006         purpose:        Implements static image properties.
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/CEGUIStaticImageProperties.h"
00027 #include "elements/CEGUIStaticImage.h"
00028 #include "CEGUIPropertyHelper.h"
00029 
00030 
00031 // Start of CEGUI namespace section
00032 namespace CEGUI
00033 {
00034 
00035 // Start of StaticImageProperties namespace section
00036 namespace StaticImageProperties
00037 {
00038 String  Image::get(const PropertyReceiver* receiver) const
00039 {
00040         return PropertyHelper::imageToString(static_cast<const StaticImage*>(receiver)->getImage());
00041 }
00042 
00043 
00044 void    Image::set(PropertyReceiver* receiver, const String& value)
00045 {
00046         static_cast<StaticImage*>(receiver)->setImage(PropertyHelper::stringToImage(value));
00047 }
00048 
00049 
00050 String  ImageColours::get(const PropertyReceiver* receiver) const
00051 {
00052         return PropertyHelper::colourRectToString(static_cast<const StaticImage*>(receiver)->getImageColours());
00053 }
00054 
00055 
00056 void    ImageColours::set(PropertyReceiver* receiver, const String& value)
00057 {
00058         static_cast<StaticImage*>(receiver)->setImageColours(PropertyHelper::stringToColourRect(value));
00059 }
00060 
00061 
00062 String  VertFormatting::get(const PropertyReceiver* receiver) const
00063 {
00064         switch(static_cast<const StaticImage*>(receiver)->getVerticalFormatting())
00065         {
00066         case StaticImage::TopAligned:
00067                 return String((utf8*)"TopAligned");
00068                 break;
00069 
00070         case StaticImage::BottomAligned:
00071                 return String((utf8*)"BottomAligned");
00072                 break;
00073 
00074         case StaticImage::VertTiled:
00075                 return String((utf8*)"VertTiled");
00076                 break;
00077 
00078         case StaticImage::VertCentred:
00079                 return String((utf8*)"VertCentred");
00080                 break;
00081 
00082         default:
00083                 return String((utf8*)"VertStretched");
00084                 break;
00085         }
00086 
00087 }
00088 
00089 
00090 void    VertFormatting::set(PropertyReceiver* receiver, const String& value)
00091 {
00092         StaticImage::VertFormatting fmt;
00093 
00094         if (value == (utf8*)"TopAligned")
00095         {
00096                 fmt = StaticImage::TopAligned;
00097         }
00098         else if (value == (utf8*)"BottomAligned")
00099         {
00100                 fmt = StaticImage::BottomAligned;
00101         }
00102         else if (value == (utf8*)"VertTiled")
00103         {
00104                 fmt = StaticImage::VertTiled;
00105         }
00106         else if (value == (utf8*)"VertCentred")
00107         {
00108                 fmt = StaticImage::VertCentred;
00109         }
00110         else
00111         {
00112                 fmt = StaticImage::VertStretched;
00113         }
00114 
00115         static_cast<StaticImage*>(receiver)->setVerticalFormatting(fmt);
00116 }
00117 
00118 
00119 String  HorzFormatting::get(const PropertyReceiver* receiver) const
00120 {
00121         switch(static_cast<const StaticImage*>(receiver)->getHorizontalFormatting())
00122         {
00123         case StaticImage::LeftAligned:
00124                 return String((utf8*)"LeftAligned");
00125                 break;
00126 
00127         case StaticImage::RightAligned:
00128                 return String((utf8*)"RightAligned");
00129                 break;
00130 
00131         case StaticImage::HorzTiled:
00132                 return String((utf8*)"HorzTiled");
00133                 break;
00134 
00135         case StaticImage::HorzCentred:
00136                 return String((utf8*)"HorzCentred");
00137                 break;
00138 
00139         default:
00140                 return String((utf8*)"HorzStretched");
00141                 break;
00142         }
00143 
00144 }
00145 
00146 
00147 void    HorzFormatting::set(PropertyReceiver* receiver, const String& value)
00148 {
00149         StaticImage::HorzFormatting fmt;
00150 
00151         if (value == (utf8*)"LeftAligned")
00152         {
00153                 fmt = StaticImage::LeftAligned;
00154         }
00155         else if (value == (utf8*)"RightAligned")
00156         {
00157                 fmt = StaticImage::RightAligned;
00158         }
00159         else if (value == (utf8*)"HorzTiled")
00160         {
00161                 fmt = StaticImage::HorzTiled;
00162         }
00163         else if (value == (utf8*)"HorzCentred")
00164         {
00165                 fmt = StaticImage::HorzCentred;
00166         }
00167         else
00168         {
00169                 fmt = StaticImage::HorzStretched;
00170         }
00171 
00172         static_cast<StaticImage*>(receiver)->setHorizontalFormatting(fmt);
00173 }
00174 
00175 } // End of  StaticImageProperties namespace section
00176 
00177 } // End of  CEGUI namespace section

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