File: TextBox.cpp

package info (click to toggle)
bullet 3.24%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 15,164 kB
  • sloc: cpp: 246,331; lisp: 12,017; ansic: 11,175; python: 630; makefile: 136; sh: 75
file content (73 lines) | stat: -rw-r--r-- 1,955 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
#include "UnitTest.h"
#include "Gwen/Controls/TextBox.h"

using namespace Gwen;

class TextBox : public GUnit
{
public:
	GWEN_CONTROL_INLINE(TextBox, GUnit)
	{
		{
			Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
			label->SetText("");
			label->SetPos(10, 10);
			label->onTextChanged.Add(this, &ThisClass::OnEdit);
			label->onReturnPressed.Add(this, &ThisClass::OnSubmit);
		}

		{
			Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
			label->SetText("Normal Everyday Label");
			label->SetPos(10, 10 + 25);
		}

		{
			Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
			label->SetText("Select All Text On Focus");
			label->SetPos(10, 10 + 25 * 2);
			label->SetSelectAllOnFocus(true);
		}

		{
			Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
			label->SetText(L"Different Coloured Text, for some reason");
			label->SetTextColor(Gwen::Color(255, 0, 255, 255));
			label->SetPos(10, 10 + 25 * 3);
		}

		{
			Gwen::Controls::TextBoxNumeric* label = new Gwen::Controls::TextBoxNumeric(this);
			label->SetText(L"2004");
			label->SetTextColor(Gwen::Color(255, 0, 255, 255));
			label->SetPos(10, 10 + 25 * 4);
		}

		{
			m_Font.facename = L"Impact";
			m_Font.size = 50;

			Gwen::Controls::TextBox* label = new Gwen::Controls::TextBox(this);
			label->SetText(L"Different Font");
			label->SetPos(10, 10 + 25 * 5);
			label->SetFont(&m_Font);
			label->SetSize(200, 55);
		}
	}

	void OnEdit(Gwen::Controls::Base* pControl)
	{
		Gwen::Controls::TextBox* textbox = (Gwen::Controls::TextBox*)(pControl);
		UnitPrint(Utility::Format(L"Textbox Edit: [%s]\n", textbox->GetText().c_str()));
	}

	void OnSubmit(Gwen::Controls::Base* pControl)
	{
		Gwen::Controls::TextBox* textbox = (Gwen::Controls::TextBox*)(pControl);
		UnitPrint(Utility::Format(L"Textbox Submit: [%s]\n", textbox->GetText().c_str()));
	}

	Gwen::Font m_Font;
};

DEFINE_UNIT_TEST(TextBox, L"TextBox");