MyGUI  3.0.3
MyGUI_TabItem.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_TabItem.h"
00025 
00026 namespace MyGUI
00027 {
00028 
00029     TabItem::TabItem() :
00030         mOwner(nullptr)
00031     {
00032     }
00033 
00034     void TabItem::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, Widget* _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
00035     {
00036         Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
00037 
00038         mOwner = getParent()->castType<Tab>();
00039     }
00040 
00041     TabItem::~TabItem()
00042     {
00043         mOwner->_notifyDeleteItem(this);
00044     }
00045 
00046     void TabItem::setSelected(bool _value)
00047     {
00048         if (_value) setItemSelected();
00049     }
00050 
00051     void TabItem::setCaption(const UString& _value)
00052     {
00053         mOwner->setItemName(this, _value);
00054     }
00055 
00056     const UString& TabItem::getCaption()
00057     {
00058         return mOwner->getItemName(this);
00059     }
00060 
00061     void TabItem::setButtonWidth(int _width)
00062     {
00063         mOwner->setButtonWidth(this, _width);
00064     }
00065 
00066     int TabItem::getButtonWidth()
00067     {
00068         return mOwner->getButtonWidth(this);
00069     }
00070 
00071     const UString& TabItem::getItemName()
00072     {
00073         return mOwner->getItemName(this);
00074     }
00075 
00076     void TabItem::setItemName(const UString& _name)
00077     {
00078         mOwner->setItemName(this, _name);
00079     }
00080 
00081     void TabItem::setItemData(Any _data)
00082     {
00083         mOwner->setItemData(this, _data);
00084     }
00085 
00086     void TabItem::setItemSelected()
00087     {
00088         mOwner->setItemSelected(this);
00089     }
00090 
00091     void TabItem::removeItem()
00092     {
00093         mOwner->removeItem(this);
00094     }
00095 
00096     void TabItem::setProperty(const std::string& _key, const std::string& _value)
00097     {
00098         if (_key == "TabItem_ButtonWidth") setButtonWidth(utility::parseValue<int>(_value));
00099         else if (_key == "TabItem_Select") setSelected(utility::parseValue<bool>(_value));
00100 
00101 #ifndef MYGUI_DONT_USE_OBSOLETE
00102         else if (_key == "Sheet_ButtonWidth")
00103         {
00104             MYGUI_LOG(Warning, "Sheet_ButtonWidth is obsolete, use TabItem_ButtonWidth");
00105             setButtonWidth(utility::parseValue<int>(_value));
00106         }
00107         else if (_key == "Sheet_Select")
00108         {
00109             MYGUI_LOG(Warning, "Sheet_Select is obsolete, use TabItem_Select");
00110             setSelected(utility::parseValue<bool>(_value));
00111         }
00112 #endif // MYGUI_DONT_USE_OBSOLETE
00113 
00114         else
00115         {
00116             Base::setProperty(_key, _value);
00117             return;
00118         }
00119         eventChangeProperty(this, _key, _value);
00120     }
00121 
00122 } // namespace MyGUI