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/VLayout.h"
23
#include "Nux/HLayout.h"
24
#include "Nux/WindowThread.h"
25
#include "Nux/TextEntry.h"
26
#include "nux_test_framework.h"
29
NuxTestFramework::NuxTestFramework(const char* program_name,
32
int program_life_span)
35
window_width_ = window_width;
36
window_height_ = window_height;
38
if (window_width_ < 100)
41
if (window_height_ < 100)
44
timeout_signal_ = NULL;
45
window_thread_ = NULL;
46
program_name_ = program_name;
47
program_life_span_ = program_life_span;
49
if (program_life_span_ > 0 && program_life_span_ < 1000)
51
// Minimum life span is 1 second.
52
program_life_span_ = 1000;
56
NuxTestFramework::~NuxTestFramework()
59
delete window_thread_;
62
void NuxTestFramework::Startup()
64
nux::NuxInitialize(0);
65
window_thread_ = nux::CreateGUIThread(program_name_.c_str(), window_width_, window_height_, NULL, NULL, NULL);
67
window_thread_->window_configuration.connect(sigc::mem_fun(this, &NuxTestFramework::WaitForConfigureEvent));
70
void NuxTestFramework::UserInterfaceSetup()
72
// nux::VLayout *MainVLayout = new nux::VLayout(NUX_TRACKER_LOCATION);
73
// nux::TextEntry *text_entry_0 = new nux::TextEntry(TEXT("0123456789abcdefghij"), NUX_TRACKER_LOCATION);
75
// MainVLayout->AddView(text_entry_0, 0, nux::eCenter, nux::eFull);
76
// MainVLayout->SetVerticalInternalMargin(10);
77
// MainVLayout->SetContentDistribution(nux::eStackCenter);
79
// nux::GetWindowThread()->SetLayout(MainVLayout);
80
// nux::ColorLayer background(nux::Color(0xFF4D4D4D));
81
// window_thread_->SetWindowBackgroundPaintLayer(&background);
84
void NuxTestFramework::Run()
86
if (window_thread_ == NULL)
89
if (program_life_span_ > 0)
91
timeout_signal_ = new nux::TimeOutSignal();
92
timeout_signal_->time_expires.connect(sigc::mem_fun(this, &NuxTestFramework::ProgramExitCall));
93
window_thread_->GetTimerHandler().AddTimerHandler(program_life_span_, timeout_signal_, NULL, NULL);
96
window_thread_->Run(NULL);
99
bool NuxTestFramework::ReadyToGo()
101
return window_thread_;
104
nux::WindowThread* NuxTestFramework::GetWindowThread()
106
return window_thread_;
109
void NuxTestFramework::ProgramExitCall(void *data)
112
window_thread_->ExitMainLoop();
115
void NuxTestFramework::WaitForConfigureEvent(int x, int y, int width, int height)
121
// int main(int argc, char **argv)
123
// NuxTestFramework test("Text Entry", 300, 300, 3000);
125
// test.UserInterfaceSetup();