• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_StaticText.cpp

Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009     
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014     
00015     MyGUI 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
00018     GNU Lesser General Public License for more details.
00019     
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #include "MyGUI_Precompiled.h"
00024 #include "MyGUI_StaticText.h"
00025 
00026 namespace MyGUI
00027 {
00028 
00029     StaticText::StaticText()
00030     {
00031     }
00032 
00033     void StaticText::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, WidgetPtr _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
00034     {
00035         Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
00036 
00037         initialiseWidgetSkin(_info);
00038     }
00039 
00040     StaticText::~StaticText()
00041     {
00042         shutdownWidgetSkin();
00043     }
00044 
00045     void StaticText::baseChangeWidgetSkin(ResourceSkin* _info)
00046     {
00047         shutdownWidgetSkin();
00048         Base::baseChangeWidgetSkin(_info);
00049         initialiseWidgetSkin(_info);
00050     }
00051 
00052     void StaticText::initialiseWidgetSkin(ResourceSkin* _info)
00053     {
00054         // парсим свойства
00055         const MapString& properties = _info->getProperties();
00056         if (false == properties.empty())
00057         {
00058             MapString::const_iterator iter = properties.end();
00059             if ((iter = properties.find("FontName")) != properties.end()) setFontName(iter->second);
00060             if ((iter = properties.find("FontHeight")) != properties.end()) setFontHeight(utility::parseInt(iter->second));
00061             if ((iter = properties.find("TextAlign")) != properties.end()) setTextAlign(Align::parse(iter->second));
00062             if ((iter = properties.find("TextColour")) != properties.end()) setTextColour(Colour::parse(iter->second));
00063         }
00064     }
00065 
00066     void StaticText::shutdownWidgetSkin()
00067     {
00068     }
00069 
00070     IntCoord StaticText::getTextRegion()
00071     {
00072         return (nullptr == mText) ? IntCoord() : mText->getCoord();
00073     }
00074 
00075     IntSize StaticText::getTextSize()
00076     {
00077         return (nullptr == mText) ? IntSize() : mText->getTextSize();
00078     }
00079 
00080     void StaticText::setTextAlign(Align _align)
00081     {
00082         if (mText != nullptr) mText->setTextAlign(_align);
00083     }
00084 
00085     Align StaticText::getTextAlign()
00086     {
00087         if (mText != nullptr) return mText->getTextAlign();
00088         return Align::Default;
00089     }
00090 
00091     void StaticText::setTextColour(const Colour& _colour)
00092     {
00093         if (nullptr != mText) mText->setTextColour(_colour);
00094     }
00095 
00096     const Colour& StaticText::getTextColour()
00097     {
00098         return (nullptr == mText) ? Colour::Zero : mText->getTextColour();
00099     }
00100 
00101     void StaticText::setFontName(const std::string& _font)
00102     {
00103         if (nullptr != mText) mText->setFontName(_font);
00104     }
00105 
00106     const std::string& StaticText::getFontName()
00107     {
00108         if (nullptr == mText) {
00109             static std::string empty;
00110             return empty;
00111         }
00112         return mText->getFontName();
00113     }
00114 
00115     void StaticText::setFontHeight(int _height)
00116     {
00117         if (nullptr != mText) mText->setFontHeight(_height);
00118     }
00119 
00120     int StaticText::getFontHeight()
00121     {
00122         return (nullptr == mText) ? 0 : mText->getFontHeight();
00123     }
00124 
00125     void StaticText::setProperty(const std::string& _key, const std::string& _value)
00126     {
00127         if (_key == "Text_TextColour") setTextColour(Colour::parse(_value));
00128         else if (_key == "Text_TextAlign") setTextAlign(Align::parse(_value));
00129         else if (_key == "Text_FontName") setFontName(_value);
00130         else if (_key == "Text_FontHeight") setFontHeight(utility::parseValue<int>(_value));
00131         else Base::setProperty(_key, _value);
00132     }
00133 
00134 } // namespace MyGUI

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1