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

MyGUI_MenuItem.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_MenuItem.h"
00025 #include "MyGUI_SkinManager.h"
00026 #include "MyGUI_SubWidgetManager.h"
00027 
00028 namespace MyGUI
00029 {
00030 
00031     MenuItem::MenuItem()
00032     {
00033     }
00034 
00035     void MenuItem::_initialise(WidgetStyle _style, const IntCoord& _coord, Align _align, ResourceSkin* _info, WidgetPtr _parent, ICroppedRectangle * _croppedParent, IWidgetCreator * _creator, const std::string& _name)
00036     {
00037         Base::_initialise(_style, _coord, _align, _info, _parent, _croppedParent, _creator, _name);
00038 
00039         WidgetPtr parent = getParent();
00040         MYGUI_ASSERT(parent, "MenuItem must have parent MenuCtrl");
00041         if (!parent->isType<MenuCtrl>())
00042         {
00043             WidgetPtr client = parent;
00044             parent = client->getParent();
00045             MYGUI_ASSERT(parent, "MenuItem must have parent MenuCtrl");
00046             MYGUI_ASSERT(parent->getClientWidget() == client, "MenuItem must have parent MenuCtrl");
00047             MYGUI_ASSERT(parent->isType<MenuCtrl>(), "MenuItem must have parent MenuCtrl");
00048         }
00049         mOwner = parent->castType<MenuCtrl>();
00050 
00051         initialiseWidgetSkin(_info);
00052 
00053         // нам нуженфокус клавы
00054         this->mNeedKeyFocus = true;
00055     }
00056 
00057     MenuItem::~MenuItem()
00058     {
00059         shutdownWidgetSkin();
00060         mOwner->_notifyDeleteItem(this);
00061     }
00062 
00063     WidgetPtr MenuItem::baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name)
00064     {
00065         WidgetPtr widget = Base::baseCreateWidget(_style, _type, _skin, _coord, _align, _layer, _name);
00066         MenuCtrlPtr child = widget->castType<MenuCtrl>(false);
00067         if (child) mOwner->_wrapItemChild(this, child);
00068         return widget;
00069     }
00070 
00071     void MenuItem::baseChangeWidgetSkin(ResourceSkin* _info)
00072     {
00073         shutdownWidgetSkin();
00074         Button::baseChangeWidgetSkin(_info);
00075         initialiseWidgetSkin(_info);
00076     }
00077 
00078     void MenuItem::initialiseWidgetSkin(ResourceSkin* _info)
00079     {
00080     }
00081 
00082     void MenuItem::shutdownWidgetSkin()
00083     {
00084     }
00085 
00086     void MenuItem::onMouseButtonPressed(int _left, int _top, MouseButton _id)
00087     {
00088         Base::onMouseButtonPressed(_left, _top, _id);
00089     }
00090 
00091     void MenuItem::onMouseButtonReleased(int _left, int _top, MouseButton _id)
00092     {
00093         Base::onMouseButtonReleased(_left, _top, _id);
00094     }
00095 
00096     void MenuItem::setCaption(const UString& _value)
00097     {
00098         Button::setCaption(_value);
00099         mOwner->_notifyUpdateName(this);
00100     }
00101 
00102     const UString& MenuItem::getItemName()
00103     {
00104         return mOwner->getItemName(this);
00105     }
00106 
00107     void MenuItem::setItemName(const UString& _value)
00108     {
00109         mOwner->setItemName(this, _value);
00110     }
00111 
00112     void MenuItem::setItemData(Any _data)
00113     {
00114         mOwner->setItemData(this, _data);
00115     }
00116 
00117     void MenuItem::removeItem()
00118     {
00119         mOwner->removeItem(this);
00120     }
00121 
00122     void MenuItem::setItemId(const std::string& _id)
00123     {
00124         mOwner->setItemId(this, _id);
00125     }
00126 
00127     const std::string& MenuItem::getItemId()
00128     {
00129         return mOwner->getItemId(this);
00130     }
00131 
00132     size_t MenuItem::getItemIndex()
00133     {
00134         return mOwner->getItemIndex(this);
00135     }
00136 
00137     MenuCtrlPtr MenuItem::createItemChild()
00138     {
00139         return mOwner->createItemChild(this);
00140     }
00141 
00142     void MenuItem::setItemType(MenuItemType _type)
00143     {
00144         mOwner->setItemType(this, _type);
00145     }
00146 
00147     MenuItemType MenuItem::getItemType()
00148     {
00149         return mOwner->getItemType(this);
00150     }
00151 
00152     void MenuItem::setItemChildVisible(bool _visible)
00153     {
00154         mOwner->setItemChildVisible(this, _visible);
00155     }
00156 
00157     MenuCtrlPtr MenuItem::getItemChild()
00158     {
00159         return mOwner->getItemChild(this);
00160     }
00161 
00162     void MenuItem::setProperty(const std::string& _key, const std::string& _value)
00163     {
00164         if (_key == "MenuItem_Id") setItemId(_value);
00165         else if (_key == "MenuItem_Type") setItemType(MenuItemType::parse(_value));
00166         else Base::setProperty(_key, _value);
00167     }
00168 
00169 } // namespace MyGUI

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1