2
* Copyright 2010 Inalogic Inc.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* version 3 along with this program. If not, see
15
* <http://www.gnu.org/licenses/>
17
* Authored by: Jay Taoko <jaytaoko@inalogic.com>
22
#include "Nux/HLayout.h"
23
#include "Nux/VLayout.h"
24
#include "Nux/WindowThread.h"
25
#include "Nux/RGBValuator.h"
26
#include "Nux/ProgramFramework/ProgramTemplate.h"
27
#include "Nux/TextEntry.h"
28
#include "ColorSphere.h"
31
#if defined(NUX_OS_WINDOWS)
32
#define PKGDATADIR "../../data/"
36
class TextEntryDemo: public ProgramTemplate
39
TextEntryDemo(const char* program_name, int window_width, int window_height, int program_life_span);
40
virtual ~TextEntryDemo();
42
virtual void UserInterfaceSetup();
44
nux::TextEntry* text_entry_;
45
nux::HLayout* layout_;
46
nux::RGBValuator* text_color_ui_;
47
nux::RGBValuator* text_selection_color_ui_;
48
nux::ColorSphere* color_sphere_;
51
TextEntryDemo::TextEntryDemo(const char* program_name,
54
int program_life_span)
55
: ProgramTemplate(program_name, window_width, window_height, program_life_span)
57
, text_color_ui_(NULL)
58
, text_selection_color_ui_(NULL)
64
TextEntryDemo::~TextEntryDemo()
68
void TextEntryDemo::UserInterfaceSetup()
70
nux::VLayout* main_layout = new nux::VLayout(NUX_TRACKER_LOCATION);
72
text_color_ui_ = new nux::RGBValuator(NUX_TRACKER_LOCATION);
73
text_selection_color_ui_ = new nux::RGBValuator(NUX_TRACKER_LOCATION);
74
color_sphere_ = new nux::ColorSphere(NUX_TRACKER_LOCATION);
76
// Create a vertical Layout
77
layout_ = new nux::HLayout(NUX_TRACKER_LOCATION);
78
text_entry_ = new nux::TextEntry("", NUX_TRACKER_LOCATION);
79
text_entry_->SetFontSize(32);
80
text_entry_->SetPasswordMode(true);
83
text_entry_->SetPasswordChar(&c);
88
nux::MINOR_POSITION_CENTER,
89
nux::MINOR_SIZE_MATCHCONTENT);
90
layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
94
//main_layout->AddView(GetAnimationTypeLayout(), 0, nux::MINOR_POSITION_START, nux::MINOR_SIZE_MATCHCONTENT);
95
main_layout->AddLayout(layout_, 0);
96
main_layout->AddView(text_color_ui_, 0, nux::MINOR_POSITION_LEFT, nux::MINOR_SIZE_MATCHCONTENT);
97
main_layout->AddView(color_sphere_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_MATCHCONTENT);
99
main_layout->SetPadding(4, 4);
100
main_layout->SetSpaceBetweenChildren(4);
102
nux::ColorLayer background(nux::Color(0xFF222222));
103
nux::GetWindowThread()->SetWindowBackgroundPaintLayer(&background);
105
nux::GetWindowThread()->SetLayout(main_layout);
108
TextEntryDemo* text_entry_demo = NULL;
110
int main(int argc, char **argv)
112
text_entry_demo = new TextEntryDemo("Text Entry Demo", 800, 300, 0);
113
text_entry_demo->Startup();
114
text_entry_demo->UserInterfaceSetup();
116
text_entry_demo->Run();
118
delete text_entry_demo;