~diegosarmentero/nuxplayground/nux-view-html-typos

« back to all changes in this revision

Viewing changes to src/text-input/text-input.cpp

  • Committer: Jay Taoko
  • Date: 2012-07-12 18:34:56 UTC
  • mfrom: (20.1.1 nuxp.timer-api)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: jay.taoko@canonical.com-20120712183456-ednq5vf65rixzlsx
* Added demo programs
* Added markdown script and syntax highlighting script
* Cleanup and fixes
* Added documentation folder

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2010 Inalogic Inc.
 
3
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>
 
16
 *
 
17
 * Authored by: Jay Taoko <jaytaoko@inalogic.com>
 
18
 *
 
19
 */
 
20
 
 
21
#include "Nux/Nux.h"
 
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"
 
29
 
 
30
 
 
31
#if defined(NUX_OS_WINDOWS)
 
32
  #define PKGDATADIR "../../data/"
 
33
#endif
 
34
 
 
35
 
 
36
class TextEntryDemo: public ProgramTemplate
 
37
{
 
38
public:
 
39
  TextEntryDemo(const char* program_name, int window_width, int window_height, int program_life_span);
 
40
  virtual ~TextEntryDemo();
 
41
 
 
42
  virtual void UserInterfaceSetup();
 
43
 
 
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_;
 
49
};
 
50
 
 
51
TextEntryDemo::TextEntryDemo(const char* program_name,
 
52
  int window_width,
 
53
  int window_height,
 
54
  int program_life_span)
 
55
  : ProgramTemplate(program_name, window_width, window_height, program_life_span)
 
56
  , text_entry_(NULL)
 
57
  , text_color_ui_(NULL)
 
58
  , text_selection_color_ui_(NULL)
 
59
  , color_sphere_(NULL)
 
60
{
 
61
 
 
62
}
 
63
 
 
64
TextEntryDemo::~TextEntryDemo()
 
65
{
 
66
}
 
67
 
 
68
void TextEntryDemo::UserInterfaceSetup()
 
69
{
 
70
  nux::VLayout* main_layout = new nux::VLayout(NUX_TRACKER_LOCATION);
 
71
 
 
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);
 
75
 
 
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);
 
81
 
 
82
  const char c = '*';
 
83
  text_entry_->SetPasswordChar(&c);
 
84
 
 
85
  layout_->AddView(
 
86
    text_entry_,
 
87
    1,
 
88
    nux::MINOR_POSITION_CENTER,
 
89
    nux::MINOR_SIZE_MATCHCONTENT);
 
90
  layout_->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
 
91
 
 
92
  
 
93
 
 
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);
 
98
 
 
99
  main_layout->SetPadding(4, 4);
 
100
  main_layout->SetSpaceBetweenChildren(4);
 
101
 
 
102
  nux::ColorLayer background(nux::Color(0xFF222222));
 
103
  nux::GetWindowThread()->SetWindowBackgroundPaintLayer(&background);
 
104
 
 
105
  nux::GetWindowThread()->SetLayout(main_layout);
 
106
}
 
107
 
 
108
TextEntryDemo* text_entry_demo = NULL;
 
109
 
 
110
int main(int argc, char **argv)
 
111
{
 
112
  text_entry_demo = new TextEntryDemo("Text Entry Demo", 800, 300, 0);
 
113
  text_entry_demo->Startup();
 
114
  text_entry_demo->UserInterfaceSetup();
 
115
 
 
116
  text_entry_demo->Run();
 
117
 
 
118
  delete text_entry_demo;
 
119
  return 0;
 
120
}