00001 /************************************************************************ 00002 filename: CEGUITextItemProperties.cpp 00003 created: 8/4/2005 00004 author: Tomas Lindquist Olsen (based on code by Paul D Turner) 00005 *************************************************************************/ 00006 /************************************************************************* 00007 Crazy Eddie's GUI System (http://www.cegui.org.uk) 00008 Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk) 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this library; if not, write to the Free Software 00022 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 *************************************************************************/ 00024 #include "elements/CEGUITextItemProperties.h" 00025 #include "elements/CEGUITextItem.h" 00026 #include "CEGUIPropertyHelper.h" 00027 00028 // Start of CEGUI namespace section 00029 namespace CEGUI 00030 { 00031 // Start of TextItemProperties namespace section 00032 namespace TextItemProperties 00033 { 00034 00035 String TextXOffset::get(const PropertyReceiver* receiver) const 00036 { 00037 return PropertyHelper::floatToString(static_cast<const TextItem*>(receiver)->getTextXOffset()); 00038 } 00039 00040 void TextXOffset::set(PropertyReceiver* receiver, const String& value) 00041 { 00042 static_cast<TextItem*>(receiver)->setTextXOffset(PropertyHelper::stringToFloat(value)); 00043 } 00044 00045 00046 String TextColour::get(const PropertyReceiver* receiver) const 00047 { 00048 return PropertyHelper::colourToString(static_cast<const TextItem*>(receiver)->getTextColour()); 00049 } 00050 00051 00052 void TextColour::set(PropertyReceiver* receiver, const String& value) 00053 { 00054 static_cast<TextItem*>(receiver)->setTextColour(PropertyHelper::stringToColour(value)); 00055 } 00056 00057 00058 String TextFormatting::get(const PropertyReceiver* receiver) const 00059 { 00060 switch(static_cast<const TextItem*>(receiver)->getTextFormatting()) 00061 { 00062 case RightAligned: 00063 return String((utf8*)"RightAligned"); 00064 break; 00065 00066 case Centred: 00067 return String((utf8*)"HorzCentred"); 00068 break; 00069 00070 case Justified: 00071 return String((utf8*)"HorzJustified"); 00072 break; 00073 00074 case WordWrapLeftAligned: 00075 return String((utf8*)"WordWrapLeftAligned"); 00076 break; 00077 00078 case WordWrapRightAligned: 00079 return String((utf8*)"WordWrapRightAligned"); 00080 break; 00081 00082 case WordWrapCentred: 00083 return String((utf8*)"WordWrapCentred"); 00084 break; 00085 00086 case WordWrapJustified: 00087 return String((utf8*)"WordWrapJustified"); 00088 break; 00089 00090 default: 00091 return String((utf8*)"LeftAligned"); 00092 break; 00093 } 00094 } 00095 00096 00097 void TextFormatting::set(PropertyReceiver* receiver, const String& value) 00098 { 00099 CEGUI::TextFormatting fmt; 00100 00101 if (value == (utf8*)"RightAligned") 00102 { 00103 fmt = RightAligned; 00104 } 00105 else if (value == (utf8*)"HorzCentred") 00106 { 00107 fmt = Centred; 00108 } 00109 else if (value == (utf8*)"HorzJustified") 00110 { 00111 fmt = Justified; 00112 } 00113 else if (value == (utf8*)"WordWrapLeftAligned") 00114 { 00115 fmt = WordWrapLeftAligned; 00116 } 00117 else if (value == (utf8*)"WordWrapRightAligned") 00118 { 00119 fmt = WordWrapRightAligned; 00120 } 00121 else if (value == (utf8*)"WordWrapCentred") 00122 { 00123 fmt = WordWrapCentred; 00124 } 00125 else if (value == (utf8*)"WordWrapJustified") 00126 { 00127 fmt = WordWrapJustified; 00128 } 00129 else 00130 { 00131 fmt = LeftAligned; 00132 } 00133 00134 static_cast<TextItem*>(receiver)->setTextFormatting(fmt); 00135 } 00136 00137 } // End of TextItemProperties namespace section 00138 } // End of CEGUI namespace section