File: DemoKeeper.cpp

package info (click to toggle)
mygui 3.4.3%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 38,792 kB
  • sloc: cpp: 133,849; ansic: 30,249; xml: 15,794; cs: 12,601; tcl: 776; python: 400; makefile: 35; sh: 4
file content (83 lines) | stat: -rw-r--r-- 3,446 bytes parent folder | download
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
#include "Precompiled.h"
#include "DemoKeeper.h"
#include "Base/Main.h"
#include "WrapPanel.h"
#include "StackPanel.h"
#include "ScrollViewPanel.h"
#include "HyperTextBox.h"

namespace demo
{

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

	void DemoKeeper::createScene()
	{
		base::BaseDemoManager::createScene();
		MyGUI::ResourceManager::getInstance().load("Fonts.xml");
		MyGUI::ResourceManager::getInstance().load("HyperTextSkins.xml");

		const std::string& category = MyGUI::WidgetManager::getInstance().getCategoryName();
		MyGUI::FactoryManager::getInstance().registerFactory<MyGUI::WrapPanel>(category);
		MyGUI::FactoryManager::getInstance().registerFactory<MyGUI::StackPanel>(category);
		MyGUI::FactoryManager::getInstance().registerFactory<MyGUI::ScrollViewPanel>(category);
		MyGUI::FactoryManager::getInstance().registerFactory<MyGUI::HyperTextBox>(category);

		MyGUI::Window* window = MyGUI::Gui::getInstance().createWidget<MyGUI::Window>(
			"WindowCSX",
			MyGUI::IntCoord(10, 10, 500, 500),
			MyGUI::Align::Default,
			"Main");
		MyGUI::IntCoord coord = window->getClientCoord();

		MyGUI::HyperTextBox* hyperText = window->createWidget<MyGUI::HyperTextBox>(
			"HyperTextBox",
			MyGUI::IntCoord(0, 0, coord.width, coord.height),
			MyGUI::Align::Stretch);
		hyperText->eventUrlClick += MyGUI::newDelegate(this, &DemoKeeper::OnClickUrl);

		hyperText->setCaption(
			"<p align='left'><h1>Caption1 left</h1></p>\n"
			"<p align='center'><h2>Caption2 center</h2></p>\n"
			"<p align='right'><h3>Caption3 right</h3></p>\n"
			"<p><s>This is strike.</s></p>\n"
			"<p><s><color value='#FF00FF'>This is strike and colour.</color></s></p>\n"
			"<p><u>This is under.</u></p>\n"
			"<p><color value='#FFFFFF'>This is color.</color></p>\n"
			"<br/>\n"
			"<p><url value='url_text1'>http://www.mygui.info</url></p>\n"
			"<p><i><b><url value='url_text2'>http://www.mygui.info</url></b></i></p>\n"
			"<p>This is image.<img>HandPointerImage</img></p>\n"
			"<p>This is linked image.<url value='url_img'><img>HandPointerImage</img></url></p>\n"
			"<p><b>This is bold text.</b></p>\n"
			"<p><i>This is italic text.</i></p>\n"
			"<p><t/><i><b>This is bold and italic text.</b></i></p>\n"
			"<p><i><b><s><u>This is bold and italic and under and strike text.</u></s></b></i></p>\n"
			"<p float='left'><img width='48' height='48'>HandPointerImage</img>text1 texttext2 text3 text4 texttext5 "
			"texttexttexttext6 text7 text8 texttext9 text10 texttext11 text12</p>\n"
			"<p float='right' align='right'><img width='48' height='48'>HandPointerImage</img>text1 texttext2 text3 "
			"text4 texttext5 texttexttexttext6 text7 text8 texttext9 text10 texttext11 text12</p>");

		hyperText->updateContent();
	}

	void DemoKeeper::destroyScene()
	{
		const std::string& category = MyGUI::WidgetManager::getInstance().getCategoryName();
		MyGUI::FactoryManager::getInstance().unregisterFactory<MyGUI::HyperTextBox>(category);
		MyGUI::FactoryManager::getInstance().unregisterFactory<MyGUI::ScrollViewPanel>(category);
		MyGUI::FactoryManager::getInstance().unregisterFactory<MyGUI::StackPanel>(category);
		MyGUI::FactoryManager::getInstance().unregisterFactory<MyGUI::WrapPanel>(category);
	}

	void DemoKeeper::OnClickUrl(MyGUI::HyperTextBox* _sender, std::string_view _url)
	{
	}

} // namespace demo

MYGUI_APP(demo::DemoKeeper)