MyGUI  3.2.0
MyGUI_SubWidgetBinding.cpp
Go to the documentation of this file.
00001 
00006 /*
00007     This file is part of MyGUI.
00008 
00009     MyGUI is free software: you can redistribute it and/or modify
00010     it under the terms of the GNU Lesser General Public License as published by
00011     the Free Software Foundation, either version 3 of the License, or
00012     (at your option) any later version.
00013 
00014     MyGUI is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU Lesser General Public License for more details.
00018 
00019     You should have received a copy of the GNU Lesser General Public License
00020     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00021 */
00022 #include "MyGUI_Precompiled.h"
00023 #include "MyGUI_SubWidgetBinding.h"
00024 
00025 namespace MyGUI
00026 {
00027 
00028     SubWidgetBinding::SubWidgetBinding()
00029     {
00030         clear();
00031     }
00032 
00033     SubWidgetBinding::SubWidgetBinding(const IntCoord& _coord, Align _aligin, const std::string& _type)
00034     {
00035         create(_coord, _aligin, _type);
00036     }
00037 
00038     void SubWidgetBinding::create(const IntCoord& _coord, Align _aligin, const std::string& _type)
00039     {
00040         clear();
00041         mOffset = _coord;
00042         mAlign = _aligin;
00043         mType = _type;
00044     }
00045 
00046     void SubWidgetBinding::clear()
00047     {
00048         mType = "";
00049         mAlign = Align::Default;
00050         mStates.clear();
00051     }
00052 
00053     void SubWidgetBinding::add(const std::string& _name, IStateInfo* _data, const std::string& _skin)
00054     {
00055         // ищем такой же ключ
00056         MapStateInfo::const_iterator iter = mStates.find(_name);
00057         if (iter != mStates.end())
00058         {
00059             delete _data;
00060             MYGUI_LOG(Warning, "state with name '" << _name << "' already exist in skin '" << _skin << "'");
00061             return;
00062         }
00063         // добавляем
00064         mStates[_name] = _data;
00065     }
00066 
00067 } // namespace MyGUI