You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
10 years ago
|
#ifndef OPENMW_MWGUI_LAYOUT_H
|
||
|
#define OPENMW_MWGUI_LAYOUT_H
|
||
15 years ago
|
|
||
10 years ago
|
#include <string>
|
||
|
#include <MyGUI_WidgetDefines.h>
|
||
|
#include <MyGUI_Widget.h>
|
||
15 years ago
|
|
||
10 years ago
|
namespace MWGui
|
||
15 years ago
|
{
|
||
|
/** The Layout class is an utility class used to load MyGUI layouts
|
||
|
from xml files, and to manipulate member widgets.
|
||
|
*/
|
||
|
class Layout
|
||
|
{
|
||
|
public:
|
||
13 years ago
|
Layout(const std::string & _layout, MyGUI::Widget* _parent = nullptr)
|
||
15 years ago
|
: mMainWidget(nullptr)
|
||
|
{ initialise(_layout, _parent); }
|
||
|
virtual ~Layout() { shutdown(); }
|
||
|
|
||
10 years ago
|
MyGUI::Widget* getWidget(const std::string& _name);
|
||
|
|
||
15 years ago
|
template <typename T>
|
||
10 years ago
|
void getWidget(T * & _widget, const std::string & _name)
|
||
15 years ago
|
{
|
||
10 years ago
|
MyGUI::Widget* w = getWidget(_name);
|
||
|
T* cast = w->castType<T>(false);
|
||
|
if (!cast)
|
||
15 years ago
|
{
|
||
10 years ago
|
MYGUI_EXCEPT("Error cast : dest type = '" << T::getClassTypeName()
|
||
|
<< "' source name = '" << w->getName()
|
||
|
<< "' source type = '" << w->getTypeName() << "' in layout '" << mLayoutName << "'");
|
||
15 years ago
|
}
|
||
10 years ago
|
else
|
||
|
_widget = cast;
|
||
15 years ago
|
}
|
||
|
|
||
10 years ago
|
private:
|
||
15 years ago
|
void initialise(const std::string & _layout,
|
||
10 years ago
|
MyGUI::Widget* _parent = nullptr);
|
||
15 years ago
|
|
||
10 years ago
|
void shutdown();
|
||
15 years ago
|
|
||
10 years ago
|
public:
|
||
10 years ago
|
void setCoord(int x, int y, int w, int h);
|
||
15 years ago
|
|
||
10 years ago
|
virtual void setVisible(bool b);
|
||
13 years ago
|
|
||
10 years ago
|
void setText(const std::string& name, const std::string& caption);
|
||
15 years ago
|
|
||
10 years ago
|
// NOTE: this assume that mMainWidget is of type Window.
|
||
|
void setTitle(const std::string& title);
|
||
15 years ago
|
|
||
11 years ago
|
MyGUI::Widget* mMainWidget;
|
||
13 years ago
|
|
||
15 years ago
|
protected:
|
||
|
|
||
|
std::string mPrefix;
|
||
|
std::string mLayoutName;
|
||
|
MyGUI::VectorWidgetPtr mListWindowRoot;
|
||
|
};
|
||
10 years ago
|
}
|
||
15 years ago
|
#endif
|