MyGUI_Gui.h
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_GUI_H_
#define MYGUI_GUI_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Types.h"
#include "MyGUI_Singleton.h"
#include "MyGUI_XmlDocument.h"
#include "MyGUI_IUnlinkWidget.h"
#include "MyGUI_Widget.h"
#include "MyGUI_BackwardCompatibility.h"
namespace MyGUI
{
using EventHandle_FrameEventDelegate = delegates::MultiDelegate<float>;
class MYGUI_EXPORT Gui : public IUnlinkWidget, public MemberObsolete<Gui>
{
MYGUI_SINGLETON_DECLARATION(Gui);
friend class WidgetManager;
public:
Gui();
void initialise(const std::string& _core = "MyGUI_Core.xml");
#ifndef MYGUI_DONT_USE_OBSOLETE
MYGUI_OBSOLETE(
" is deprecated, use : void Gui::initialise(const std::string& _core) and set log filename in Platform")
void initialise(const std::string& _core, std::string_view _logFileName);
#endif // MYGUI_DONT_USE_OBSOLETE
void shutdown();
// methods for creating widgets
Widget* createWidgetT(
std::string_view _type,
std::string_view _skin,
const IntCoord& _coord,
Align _align,
std::string_view _layer,
std::string_view _name = {});
Widget* createWidgetT(
std::string_view _type,
std::string_view _skin,
int _left,
int _top,
int _width,
int _height,
Align _align,
std::string_view _layer,
std::string_view _name = {});
Widget* createWidgetRealT(
std::string_view _type,
std::string_view _skin,
const FloatCoord& _coord,
Align _align,
std::string_view _layer,
std::string_view _name = {});
Widget* createWidgetRealT(
std::string_view _type,
std::string_view _skin,
float _left,
float _top,
float _width,
float _height,
Align _align,
std::string_view _layer,
std::string_view _name = {});
// templates for creating widgets by type
template<typename T>
T* createWidget(
std::string_view _skin,
const IntCoord& _coord,
Align _align,
std::string_view _layer,
std::string_view _name = {})
{
return static_cast<T*>(createWidgetT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
}
template<typename T>
T* createWidget(
std::string_view _skin,
int _left,
int _top,
int _width,
int _height,
Align _align,
std::string_view _layer,
std::string_view _name = {})
{
return static_cast<T*>(createWidgetT(
T::getClassTypeName(),
_skin,
IntCoord(_left, _top, _width, _height),
_align,
_layer,
_name));
}
template<typename T>
T* createWidgetReal(
std::string_view _skin,
const FloatCoord& _coord,
Align _align,
std::string_view _layer,
std::string_view _name = {})
{
return static_cast<T*>(createWidgetRealT(T::getClassTypeName(), _skin, _coord, _align, _layer, _name));
}
template<typename T>
T* createWidgetReal(
std::string_view _skin,
float _left,
float _top,
float _width,
float _height,
Align _align,
std::string_view _layer,
std::string_view _name = {})
{
return static_cast<T*>(
createWidgetRealT(T::getClassTypeName(), _skin, _left, _top, _width, _height, _align, _layer, _name));
}
void destroyWidget(Widget* _widget);
void destroyWidgets(const VectorWidgetPtr& _widgets);
void destroyWidgets(EnumeratorWidgetPtr& _widgets);
Widget* findWidgetT(std::string_view _name, bool _throw = true) const;
Widget* findWidgetT(std::string_view _name, std::string_view _prefix, bool _throw = true) const;
template<typename T>
T* findWidget(std::string_view _name, bool _throw = true) const
{
Widget* widget = findWidgetT(_name, _throw);
if (nullptr == widget)
return nullptr;
return widget->castType<T>(_throw);
}
template<typename T>
T* findWidget(std::string_view _name, std::string_view _prefix, bool _throw = true) const
{
std::string name{_prefix};
name += _name;
return findWidget<T>(name, _throw);
}
void destroyChildWidget(Widget* _widget);
void destroyAllChildWidget();
EnumeratorWidgetPtr getEnumerator() const;
void frameEvent(float _time) const;
/*events:*/
EventHandle_FrameEventDelegate eventFrameStart;
/*internal:*/
void _linkChildWidget(Widget* _widget);
void _unlinkChildWidget(Widget* _widget);
private:
// создает виджет
Widget* baseCreateWidget(
WidgetStyle _style,
std::string_view _type,
std::string_view _skin,
const IntCoord& _coord,
Align _align,
std::string_view _layer,
std::string_view _name);
// удяляет неудачника
void _destroyChildWidget(Widget* _widget);
// удаляет всех детей
void _destroyAllChildWidget();
void _unlinkWidget(Widget* _widget) override;
private:
// вектор всех детей виджетов
VectorWidgetPtr mWidgetChild;
// синглтоны гуя
InputManager* mInputManager{nullptr};
SubWidgetManager* mSubWidgetManager{nullptr};
LayerManager* mLayerManager{nullptr};
SkinManager* mSkinManager{nullptr};
WidgetManager* mWidgetManager{nullptr};
FontManager* mFontManager{nullptr};
ControllerManager* mControllerManager{nullptr};
PointerManager* mPointerManager{nullptr};
ClipboardManager* mClipboardManager{nullptr};
LayoutManager* mLayoutManager{nullptr};
DynLibManager* mDynLibManager{nullptr};
PluginManager* mPluginManager{nullptr};
LanguageManager* mLanguageManager{nullptr};
ResourceManager* mResourceManager{nullptr};
FactoryManager* mFactoryManager{nullptr};
ToolTipManager* mToolTipManager{nullptr};
bool mIsInitialise{false};
};
} // namespace MyGUI
#endif // MYGUI_GUI_H_
MyGUI_BackwardCompatibility.h
MYGUI_OBSOLETE
#define MYGUI_OBSOLETE(text)
Definition MyGUI_Diagnostic.h:68
MyGUI_IUnlinkWidget.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI_Singleton.h
MYGUI_SINGLETON_DECLARATION
#define MYGUI_SINGLETON_DECLARATION(ClassName)
Definition MyGUI_Singleton.h:112
MyGUI_Types.h
MyGUI_Widget.h
MyGUI_XmlDocument.h
MyGUI::Gui::_unlinkChildWidget
void _unlinkChildWidget(Widget *_widget)
Definition MyGUI_Gui.cpp:268
MyGUI::Gui::shutdown
void shutdown()
Definition MyGUI_Gui.cpp:104
MyGUI::Gui::initialise
void initialise(const std::string &_core="MyGUI_Core.xml")
Definition MyGUI_Gui.cpp:41
MyGUI::Gui::_linkChildWidget
void _linkChildWidget(Widget *_widget)
Definition MyGUI_Gui.cpp:261
MyGUI::Gui::createWidgetReal
T * createWidgetReal(std::string_view _skin, float _left, float _top, float _width, float _height, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.h:140
MyGUI::Gui::createWidget
T * createWidget(std::string_view _skin, const IntCoord &_coord, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.h:98
MyGUI::Gui::WidgetManager
friend class WidgetManager
Definition MyGUI_Gui.h:26
MyGUI::Gui::findWidget
T * findWidget(std::string_view _name, std::string_view _prefix, bool _throw=true) const
Definition MyGUI_Gui.h:189
MyGUI::Gui::findWidget
T * findWidget(std::string_view _name, bool _throw=true) const
Definition MyGUI_Gui.h:177
MyGUI::Gui::findWidgetT
Widget * findWidgetT(std::string_view _name, bool _throw=true) const
Definition MyGUI_Gui.cpp:178
MyGUI::Gui::Gui
Gui(const Gui &)=delete
MyGUI::Gui::createWidgetReal
T * createWidgetReal(std::string_view _skin, const FloatCoord &_coord, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.h:129
MyGUI::Gui::createWidget
T * createWidget(std::string_view _skin, int _left, int _top, int _width, int _height, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.h:109
MyGUI::Gui::createWidgetT
Widget * createWidgetT(std::string_view _type, std::string_view _skin, const IntCoord &_coord, Align _align, std::string_view _layer, std::string_view _name={})
Definition MyGUI_Gui.cpp:275
MyGUI::Gui::eventFrameStart
EventHandle_FrameEventDelegate eventFrameStart
Definition MyGUI_Gui.h:215
MyGUI::IObject::castType
Type * castType(bool _throw=true)
Definition MyGUI_IObject.h:18
MyGUI::IUnlinkWidget
Definition MyGUI_IUnlinkWidget.h:17
MyGUI::InputManager
Definition MyGUI_InputManager.h:27
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::SubWidgetManager
Definition MyGUI_SubWidgetManager.h:17
MyGUI::Widget
widget description should be here.
Definition MyGUI_Widget.h:40
MyGUI::delegates::MultiDelegate
Definition MyGUI_Delegate.h:190
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::FloatCoord
types::TCoord< float > FloatCoord
Definition MyGUI_Types.h:37
MyGUI::EnumeratorWidgetPtr
Enumerator< VectorWidgetPtr > EnumeratorWidgetPtr
Definition MyGUI_WidgetDefines.h:22
MyGUI::EventHandle_FrameEventDelegate
delegates::MultiDelegate< float > EventHandle_FrameEventDelegate
Definition MyGUI_Gui.h:21
MyGUI::IntCoord
types::TCoord< int > IntCoord
Definition MyGUI_Types.h:36
MyGUI::VectorWidgetPtr
std::vector< Widget * > VectorWidgetPtr
Definition MyGUI_WidgetDefines.h:20
MyGUI::Align
Definition MyGUI_Align.h:20
MyGUI::WidgetStyle
Definition MyGUI_WidgetStyle.h:19