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

MyGUI_Gui.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_GUI_H__
00024 #define __MYGUI_GUI_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Align.h"
00028 #include "MyGUI_Instance.h"
00029 #include "MyGUI_Common.h"
00030 #include "MyGUI_XmlDocument.h"
00031 #include "MyGUI_IWidgetCreator.h"
00032 #include "MyGUI_IUnlinkWidget.h"
00033 #include "MyGUI_Widget.h"
00034 
00035 namespace MyGUI
00036 {
00037 
00038     typedef delegates::CMultiDelegate1<float> FrameEventDelegate;
00039 
00040     class MYGUI_EXPORT Gui : public IWidgetCreator, public IUnlinkWidget
00041     {
00042         friend class WidgetManager;
00043         MYGUI_INSTANCE_HEADER(Gui);
00044 
00045     public:
00052         void initialise(const std::string& _core = "core.xml", const std::string& _logFileName = MYGUI_LOG_FILENAME);
00053 
00055         void shutdown();
00056 
00057         // methods for creating widgets
00067         WidgetPtr createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
00068         {
00069             return baseCreateWidget(WidgetStyle::Overlapped, _type, _skin, _coord, _align, _layer, _name);
00070         }
00072         WidgetPtr createWidgetT(const std::string& _type, const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _layer, const std::string& _name = "")
00073         {
00074             return createWidgetT(_type, _skin, IntCoord(_left, _top, _width, _height), _align, _layer, _name);
00075         }
00077         WidgetPtr createWidgetRealT(const std::string& _type, const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
00078         {
00079             return createWidgetT(_type, _skin, IntCoord((int)(_coord.left*mViewSize.width), (int)(_coord.top*mViewSize.height), (int)(_coord.width*mViewSize.width), (int)(_coord.height*mViewSize.height)), _align, _layer, _name);
00080         }
00082         WidgetPtr createWidgetRealT(const std::string& _type, const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _layer, const std::string& _name = "")
00083         {
00084             return createWidgetT(_type, _skin, IntCoord((int)(_left*mViewSize.width), (int)(_top*mViewSize.height), (int)(_width*mViewSize.width), (int)(_height*mViewSize.height)), _align, _layer, _name);
00085         }
00086 
00087         // templates for creating widgets by type
00089         template <typename T>
00090         T* createWidget(const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
00091         {
00092             return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
00093         }
00095         template <typename T>
00096         T* createWidget(const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _layer, const std::string& _name = "")
00097         {
00098             return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, IntCoord(_left, _top, _width, _height), _align, _layer, _name));
00099         }
00101         template <typename T>
00102         T* createWidgetReal(const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
00103         {
00104             return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
00105         }
00107         template <typename T>
00108         T* createWidgetReal(const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _layer, const std::string& _name = "")
00109         {
00110             return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name));
00111         }
00112 
00114         const IntSize& getViewSize() { return mViewSize; }
00115 
00116         int getViewWidth() { return mViewSize.width; }
00117         int getViewHeight() { return mViewSize.height; }
00118 
00122         void injectFrameEntered(float _time);
00123 
00124         // mirror of InputManager methods
00128         bool injectMouseMove(int _absx, int _absy, int _absz);
00132         bool injectMousePress(int _absx, int _absy, MouseButton _id);
00136         bool injectMouseRelease(int _absx, int _absy, MouseButton _id);
00137 
00141         bool injectKeyPress(KeyCode _key, Char _text = 0);
00145         bool injectKeyRelease(KeyCode _key);
00146 
00148         void destroyWidget(WidgetPtr _widget);
00149 
00151         void destroyWidgets(VectorWidgetPtr& _widgets);
00152 
00154         void destroyWidgets(EnumeratorWidgetPtr& _widgets);
00155 
00159         WidgetPtr findWidgetT(const std::string& _name, bool _throw = true);
00160 
00164         WidgetPtr findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw = true)
00165         {
00166             return findWidgetT(_prefix + _name, _throw);
00167         }
00168 
00169         // mirror WidgetManager
00173         template <typename T>
00174         T* findWidget(const std::string& _name, bool _throw = true)
00175         {
00176             WidgetPtr widget = findWidgetT(_name, _throw);
00177             if (nullptr == widget) return nullptr;
00178             return widget->castType<T>(_throw);
00179         }
00180 
00184         template <typename T>
00185         T* findWidget(const std::string& _name, const std::string& _prefix, bool _throw = true)
00186         {
00187             return findWidget<T>(_prefix + _name, _throw);
00188         }
00189 
00190 
00192         void setVisiblePointer(bool _visible);
00194         bool isVisiblePointer();
00195 
00196 
00197         // mirror ResourceManager
00199         bool load(const std::string& _file/*, const std::string& _group = getResourceGroup()*/);
00200 
00201         void resizeWindow(const IntSize& _size);
00202 
00204         void destroyChildWidget(WidgetPtr _widget) { _destroyChildWidget(_widget); }
00205 
00207         void destroyAllChildWidget() { _destroyAllChildWidget(); }
00208 
00210         //static const std::string& getResourceGroup();
00211 
00213         EnumeratorWidgetPtr getEnumerator() { return EnumeratorWidgetPtr(mWidgetChild); }
00214 
00215     /*event:*/
00220         FrameEventDelegate eventFrameStart;
00221 
00222     /*obsolete:*/
00223 #ifndef MYGUI_DONT_USE_OBSOLETE
00224 
00225         MYGUI_OBSOLETE("use : void Gui::destroyWidgets(VectorWidgetPtr &_widgets)")
00226         void destroyWidgetsVector(VectorWidgetPtr& _widgets) { destroyWidgets(_widgets); }
00227 
00228         MYGUI_OBSOLETE("use : void Gui::setVisiblePointer(bool _value)")
00229         void hidePointer() { setVisiblePointer(false); }
00230         MYGUI_OBSOLETE("use : void Gui::setVisiblePointer(bool _value)")
00231         void showPointer() { setVisiblePointer(true); }
00232         MYGUI_OBSOLETE("use : bool Gui::isVisiblePointer()")
00233         bool isShowPointer() { return isVisiblePointer(); }
00234 
00235 #endif // MYGUI_DONT_USE_OBSOLETE
00236 
00237     private:
00238         // создает виджет
00239         virtual WidgetPtr baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name);
00240 
00241         // удяляет неудачника
00242         void _destroyChildWidget(WidgetPtr _widget);
00243 
00244         // удаляет всех детей
00245         void _destroyAllChildWidget();
00246 
00247         virtual void _unlinkWidget(WidgetPtr _widget);
00248 
00249         // добавляет в список виджет
00250         virtual void _linkChildWidget(WidgetPtr _widget);
00251 
00252         // удаляет из списка
00253         virtual void _unlinkChildWidget(WidgetPtr _widget);
00254 
00255 
00256     private:
00257         // вектор всех детей виджетов
00258         VectorWidgetPtr mWidgetChild;
00259 
00260         // размеры экрана
00261         IntSize mViewSize;
00262 
00263         // синглтоны гуя
00264         InputManager * mInputManager;
00265         SubWidgetManager * mSubWidgetManager;
00266         LayerManager* mLayerManager;
00267         SkinManager* mSkinManager;
00268         WidgetManager* mWidgetManager;
00269         FontManager* mFontManager;
00270         ControllerManager* mControllerManager;
00271         PointerManager* mPointerManager;
00272         ClipboardManager* mClipboardManager;
00273         LayoutManager* mLayoutManager;
00274         DynLibManager* mDynLibManager;
00275         PluginManager* mPluginManager;
00276         DelegateManager* mDelegateManager;
00277         LanguageManager* mLanguageManager;
00278         ResourceManager* mResourceManager;
00279         FactoryManager* mFactoryManager;
00280 
00281     };
00282 
00283 } // namespace MyGUI
00284 
00285 #endif // __MYGUI_GUI_H__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1