2015-05-01 02:09:57 +02:00
|
|
|
#ifndef OPENMW_MWGUI_LAYOUT_H
|
|
|
|
#define OPENMW_MWGUI_LAYOUT_H
|
2010-07-09 21:21:04 +02:00
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <string>
|
2022-06-27 19:13:17 +02:00
|
|
|
#include <string_view>
|
2022-06-04 15:26:36 +02:00
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
#include <MyGUI_Widget.h>
|
2010-07-09 21:21:04 +02:00
|
|
|
|
2018-09-09 16:06:25 +04:00
|
|
|
#include <components/debug/debuglog.hpp>
|
|
|
|
|
2015-05-01 02:09:57 +02:00
|
|
|
namespace MWGui
|
2010-07-09 21:21:04 +02:00
|
|
|
{
|
|
|
|
/** The Layout class is an utility class used to load MyGUI layouts
|
|
|
|
from xml files, and to manipulate member widgets.
|
|
|
|
*/
|
|
|
|
class Layout
|
2022-06-27 19:13:17 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
Layout(std::string_view layout)
|
|
|
|
: mMainWidget(nullptr)
|
2018-09-09 16:06:25 +04:00
|
|
|
{
|
|
|
|
initialise(layout);
|
2015-01-10 02:50:43 +01:00
|
|
|
assert(mMainWidget);
|
2018-09-09 16:06:25 +04:00
|
|
|
}
|
2022-09-22 21:26:05 +03:00
|
|
|
|
2018-09-09 16:06:25 +04:00
|
|
|
virtual ~Layout()
|
|
|
|
{
|
2022-09-22 21:26:05 +03:00
|
|
|
try
|
|
|
|
{
|
2015-01-10 02:50:43 +01:00
|
|
|
shutdown();
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2018-09-09 16:06:25 +04:00
|
|
|
catch (const MyGUI::Exception& e)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2018-09-09 16:06:25 +04:00
|
|
|
Log(Debug::Error) << "Error in the destructor: " << e.what();
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
2018-09-09 16:06:25 +04:00
|
|
|
}
|
2010-07-09 21:21:04 +02:00
|
|
|
|
2022-06-27 19:13:17 +02:00
|
|
|
MyGUI::Widget* getWidget(std::string_view name);
|
2015-01-10 02:50:43 +01:00
|
|
|
|
2010-07-09 21:21:04 +02:00
|
|
|
template <typename T>
|
2022-06-27 19:13:17 +02:00
|
|
|
void getWidget(T*& _widget, std::string_view _name)
|
2010-07-09 21:21:04 +02:00
|
|
|
{
|
2015-01-10 02:50:43 +01:00
|
|
|
MyGUI::Widget* w = getWidget(_name);
|
|
|
|
T* cast = w->castType<T>(false);
|
|
|
|
if (!cast)
|
2022-09-22 21:26:05 +03:00
|
|
|
{
|
2015-01-10 02:50:43 +01:00
|
|
|
MYGUI_EXCEPT("Error cast : dest type = '" << T::getClassTypeName() << "' source name = '"
|
|
|
|
<< w->getName() << "' source type = '" << w->getTypeName()
|
|
|
|
<< "' in layout '" << mLayoutName << "'");
|
2022-09-22 21:26:05 +03:00
|
|
|
}
|
|
|
|
else
|
2015-01-10 02:50:43 +01:00
|
|
|
_widget = cast;
|
2010-07-09 21:21:04 +02:00
|
|
|
}
|
|
|
|
|
2022-09-22 21:26:05 +03:00
|
|
|
private:
|
2015-01-10 02:50:43 +01:00
|
|
|
void initialise(std::string_view layout);
|
2010-07-09 21:21:04 +02:00
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
void shutdown();
|
2010-07-09 21:21:04 +02:00
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
public:
|
|
|
|
void setCoord(int x, int y, int w, int h);
|
2012-03-24 23:24:19 +01:00
|
|
|
|
2022-08-24 22:16:03 +02:00
|
|
|
virtual void setVisible(bool b);
|
2010-07-09 21:21:04 +02:00
|
|
|
|
2022-08-16 21:15:03 +02:00
|
|
|
void setText(std::string_view name, std::string_view caption);
|
2010-07-09 21:21:04 +02:00
|
|
|
|
2013-12-03 18:42:35 +01:00
|
|
|
// NOTE: this assume that mMainWidget is of type Window.
|
|
|
|
void setTitle(std::string_view title);
|
2012-04-16 15:48:01 +02:00
|
|
|
|
2015-01-10 02:50:43 +01:00
|
|
|
MyGUI::Widget* mMainWidget;
|
2010-07-09 21:21:04 +02:00
|
|
|
|
|
|
|
protected:
|
|
|
|
std::string mPrefix;
|
|
|
|
std::string mLayoutName;
|
|
|
|
MyGUI::VectorWidgetPtr mListWindowRoot;
|
|
|
|
};
|
2015-05-01 02:09:57 +02:00
|
|
|
}
|
2010-07-09 21:21:04 +02:00
|
|
|
#endif
|