MyGUI 3.0.1
MyGUI_SubWidgetBinding.h
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 #ifndef __MYGUI_SUB_WIDGET_BINDING_H__
00024 #define __MYGUI_SUB_WIDGET_BINDING_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_ISubWidget.h"
00028 
00029 namespace MyGUI
00030 {
00031 
00032     // вспомогательный класс для инициализации сабскинов
00033     class MYGUI_EXPORT SubWidgetBinding
00034     {
00035         // для доступа к внутренним членам
00036         friend class ResourceSkin;
00037 
00038     public:
00039         SubWidgetBinding()
00040         {
00041             clear();
00042         }
00043 
00044         SubWidgetBinding(const IntCoord& _coord, Align _aligin, const std::string& _type)
00045         {
00046             create(_coord, _aligin, _type);
00047         }
00048 
00049         void create(const IntCoord& _coord, Align _aligin, const std::string& _type)
00050         {
00051             clear();
00052             mOffset = _coord;
00053             mAlign = _aligin;
00054             mType = _type;
00055         }
00056 
00057         void clear()
00058         {
00059             mType = "";
00060             mAlign = Align::Default;
00061             mStates.clear();
00062         }
00063 
00064         void add(const std::string& _name, IStateInfo* _data, const std::string& _skin)
00065         {
00066             // ищем такой же ключ
00067             MapStateInfo::const_iterator iter = mStates.find(_name);
00068             if (iter != mStates.end())
00069             {
00070                 delete _data;
00071                 MYGUI_LOG(Warning, "state with name '" << _name << "' already exist in skin '" << _skin << "'");
00072                 return;
00073             }
00074             // добавляем
00075             mStates[_name] = _data;
00076         }
00077 
00078     private:
00079         IntCoord mOffset;
00080         Align mAlign;
00081         std::string mType;
00082         MapStateInfo mStates;
00083     };
00084 
00085 } // namespace MyGUI
00086 
00087 
00088 #endif // __MYGUI_SUB_WIDGET_BINDING_H__