00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MYGUI_GUI_H__
00024 #define __MYGUI_GUI_H__
00025
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Types.h"
00028 #include "MyGUI_Instance.h"
00029 #include "MyGUI_XmlDocument.h"
00030 #include "MyGUI_IWidgetCreator.h"
00031 #include "MyGUI_IUnlinkWidget.h"
00032 #include "MyGUI_Widget.h"
00033
00034 namespace MyGUI
00035 {
00036
00037 typedef delegates::CMultiDelegate1<float> FrameEventDelegate;
00038
00039 class MYGUI_EXPORT Gui : public IWidgetCreator, public IUnlinkWidget
00040 {
00041 friend class WidgetManager;
00042 MYGUI_INSTANCE_HEADER( Gui )
00043
00044 public:
00051 void initialise(const std::string& _core = "core.xml", const std::string& _logFileName = MYGUI_LOG_FILENAME);
00052
00054 void shutdown();
00055
00056
00066 Widget* createWidgetT(const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
00067 {
00068 return baseCreateWidget(WidgetStyle::Overlapped, _type, _skin, _coord, _align, _layer, _name);
00069 }
00071 Widget* 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 = "")
00072 {
00073 return createWidgetT(_type, _skin, IntCoord(_left, _top, _width, _height), _align, _layer, _name);
00074 }
00076 Widget* createWidgetRealT(const std::string& _type, const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
00077 {
00078 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);
00079 }
00081 Widget* 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 = "")
00082 {
00083 return createWidgetT(_type, _skin, IntCoord((int)(_left*mViewSize.width), (int)(_top*mViewSize.height), (int)(_width*mViewSize.width), (int)(_height*mViewSize.height)), _align, _layer, _name);
00084 }
00085
00086
00088 template <typename T>
00089 T* createWidget(const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
00090 {
00091 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
00092 }
00094 template <typename T>
00095 T* createWidget(const std::string& _skin, int _left, int _top, int _width, int _height, Align _align, const std::string& _layer, const std::string& _name = "")
00096 {
00097 return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, IntCoord(_left, _top, _width, _height), _align, _layer, _name));
00098 }
00100 template <typename T>
00101 T* createWidgetReal(const std::string& _skin, const FloatCoord& _coord, Align _align, const std::string& _layer, const std::string& _name = "")
00102 {
00103 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
00104 }
00106 template <typename T>
00107 T* createWidgetReal(const std::string& _skin, float _left, float _top, float _width, float _height, Align _align, const std::string& _layer, const std::string& _name = "")
00108 {
00109 return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name));
00110 }
00111
00113 const IntSize& getViewSize() const { return mViewSize; }
00114
00115 int getViewWidth() { return mViewSize.width; }
00116 int getViewHeight() { return mViewSize.height; }
00117
00118
00122 bool injectMouseMove(int _absx, int _absy, int _absz);
00126 bool injectMousePress(int _absx, int _absy, MouseButton _id);
00130 bool injectMouseRelease(int _absx, int _absy, MouseButton _id);
00131
00135 bool injectKeyPress(KeyCode _key, Char _text = 0);
00139 bool injectKeyRelease(KeyCode _key);
00140
00142 void destroyWidget(Widget* _widget);
00143
00145 void destroyWidgets(VectorWidgetPtr& _widgets);
00146
00148 void destroyWidgets(EnumeratorWidgetPtr& _widgets);
00149
00153 Widget* findWidgetT(const std::string& _name, bool _throw = true);
00154
00158 Widget* findWidgetT(const std::string& _name, const std::string& _prefix, bool _throw = true)
00159 {
00160 return findWidgetT(_prefix + _name, _throw);
00161 }
00162
00163
00167 template <typename T>
00168 T* findWidget(const std::string& _name, bool _throw = true)
00169 {
00170 Widget* widget = findWidgetT(_name, _throw);
00171 if (nullptr == widget) return nullptr;
00172 return widget->castType<T>(_throw);
00173 }
00174
00178 template <typename T>
00179 T* findWidget(const std::string& _name, const std::string& _prefix, bool _throw = true)
00180 {
00181 return findWidget<T>(_prefix + _name, _throw);
00182 }
00183
00184
00186 void setVisiblePointer(bool _visible);
00188 bool isVisiblePointer();
00189
00190
00191
00193 bool load(const std::string& _file);
00194
00195 void resizeWindow(const IntSize& _size);
00196
00198 void destroyChildWidget(Widget* _widget) { _destroyChildWidget(_widget); }
00199
00201 void destroyAllChildWidget() { _destroyAllChildWidget(); }
00202
00204
00205
00207 EnumeratorWidgetPtr getEnumerator() { return EnumeratorWidgetPtr(mWidgetChild); }
00208
00209
00210
00214 void _injectFrameEntered(float _time);
00215
00216
00221 FrameEventDelegate eventFrameStart;
00222
00223
00224 #ifndef MYGUI_DONT_USE_OBSOLETE
00225
00226 MYGUI_OBSOLETE("use : void Gui::destroyWidgets(VectorWidgetPtr &_widgets)")
00227 void destroyWidgetsVector(VectorWidgetPtr& _widgets) { destroyWidgets(_widgets); }
00228
00229 MYGUI_OBSOLETE("use : void Gui::setVisiblePointer(bool _value)")
00230 void hidePointer() { setVisiblePointer(false); }
00231 MYGUI_OBSOLETE("use : void Gui::setVisiblePointer(bool _value)")
00232 void showPointer() { setVisiblePointer(true); }
00233 MYGUI_OBSOLETE("use : bool Gui::isVisiblePointer()")
00234 bool isShowPointer() { return isVisiblePointer(); }
00235 MYGUI_OBSOLETE("called be renderer, do not call it manually")
00236 void injectFrameEntered(float _time) { }
00237
00238 #endif // MYGUI_DONT_USE_OBSOLETE
00239
00240 private:
00241
00242 virtual Widget* baseCreateWidget(WidgetStyle _style, const std::string& _type, const std::string& _skin, const IntCoord& _coord, Align _align, const std::string& _layer, const std::string& _name);
00243
00244
00245 void _destroyChildWidget(Widget* _widget);
00246
00247
00248 void _destroyAllChildWidget();
00249
00250 virtual void _unlinkWidget(Widget* _widget);
00251
00252
00253 virtual void _linkChildWidget(Widget* _widget);
00254
00255
00256 virtual void _unlinkChildWidget(Widget* _widget);
00257
00258
00259 private:
00260
00261 VectorWidgetPtr mWidgetChild;
00262
00263
00264 IntSize mViewSize;
00265
00266
00267 InputManager * mInputManager;
00268 SubWidgetManager * mSubWidgetManager;
00269 LayerManager* mLayerManager;
00270 SkinManager* mSkinManager;
00271 WidgetManager* mWidgetManager;
00272 FontManager* mFontManager;
00273 ControllerManager* mControllerManager;
00274 PointerManager* mPointerManager;
00275 ClipboardManager* mClipboardManager;
00276 LayoutManager* mLayoutManager;
00277 DynLibManager* mDynLibManager;
00278 PluginManager* mPluginManager;
00279 LanguageManager* mLanguageManager;
00280 ResourceManager* mResourceManager;
00281 FactoryManager* mFactoryManager;
00282
00283 };
00284
00285 }
00286
00287 #endif // __MYGUI_GUI_H__