File: DemoKeeper.cpp

package info (click to toggle)
mygui 3.2.2%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 36,228 kB
  • sloc: cpp: 118,031; ansic: 30,202; xml: 15,544; cs: 12,602; tcl: 776; python: 417; makefile: 34
file content (84 lines) | stat: -rw-r--r-- 2,336 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*!
	@file
	@author		Albert Semenov
	@date		08/2008
*/
#include "Precompiled.h"
#include "DemoKeeper.h"
#include "Base/Main.h"

#ifdef MYGUI_STATIC
#include "Plugin.h"
plugin::Plugin* plugin_item = nullptr;
#endif

#if MYGUI_DEBUG_MODE
	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
		#define plugin_name "Plugin_StrangeButton_d.dll"
	#else
		#define plugin_name "libPlugin_StrangeButton_d.so"
	#endif
#else
	#if MYGUI_PLATFORM == MYGUI_PLATFORM_WIN32
		#define plugin_name "Plugin_StrangeButton.dll"
	#else
		#define plugin_name "libPlugin_StrangeButton.so"
	#endif
#endif

namespace demo
{

	DemoKeeper::DemoKeeper() :
		m_button(nullptr)
	{
	}

	void DemoKeeper::setupResources()
	{
		base::BaseManager::setupResources();
		addResourceLocation(getRootMedia() + "/Common/Demos");
	}

	void DemoKeeper::createScene()
	{
		base::BaseDemoManager::createScene();
		MyGUI::LayoutManager::getInstance().loadLayout("Wallpaper.layout");
		const MyGUI::VectorWidgetPtr& root = MyGUI::LayoutManager::getInstance().loadLayout("HelpPanel.layout");
		root.at(0)->findWidget("Text")->castType<MyGUI::TextBox>()->setCaption("Example of using plugins in MyGUI. Actually nothing interesting to look at.");

		const MyGUI::IntSize& view = MyGUI::RenderManager::getInstance().getViewSize();
		const MyGUI::IntSize size(300, 26);

#ifdef MYGUI_STATIC
		plugin_item = new plugin::Plugin();
		MyGUI::PluginManager::getInstance().installPlugin(plugin_item);
#else
		MyGUI::PluginManager::getInstance().loadPlugin(plugin_name);
#endif

		MyGUI::Widget* widget = MyGUI::Gui::getInstance().createWidgetT("StrangeButton", "Button", MyGUI::IntCoord((view.width - size.width) / 2, (view.height - size.height) / 2, size.width, size.height), MyGUI::Align::Default, "Main");
		m_button = widget->castType<MyGUI::TextBox>();
		m_button->setCaption("Plugin StrangeButton demo");
	}

	void DemoKeeper::destroyScene()
	{
		MyGUI::Gui::getInstance().destroyChildWidget(m_button);

#ifdef MYGUI_STATIC
		MyGUI::PluginManager::getInstance().uninstallPlugin(plugin_item);
		delete plugin_item;
		plugin_item = nullptr;
#else
#	ifdef _DEBUG
		MyGUI::PluginManager::getInstance().unloadPlugin("Plugin_StrangeButton_d.dll");
#	else
		MyGUI::PluginManager::getInstance().unloadPlugin("Plugin_StrangeButton.dll");
#	endif
#endif
	}

} // namespace demo

MYGUI_APP(demo::DemoKeeper)