2009-09-28 11:43:28 -04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2002-01-21 15:30:43 -05:00
|
|
|
|
2009-09-28 11:43:28 -04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2002-01-21 15:30:43 -05:00
|
|
|
|
2009-09-28 11:43:28 -04:00
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
2001-11-04 18:05:21 -05:00
|
|
|
#include "cmCursesBoolWidget.h"
|
2001-12-13 13:28:41 -05:00
|
|
|
#include "cmCursesMainForm.h"
|
2001-11-04 18:05:21 -05:00
|
|
|
|
2012-08-13 13:42:58 -04:00
|
|
|
cmCursesBoolWidget::cmCursesBoolWidget(int width, int height,
|
2002-10-23 18:03:27 -04:00
|
|
|
int left, int top) :
|
2001-11-04 18:05:21 -05:00
|
|
|
cmCursesWidget(width, height, left, top)
|
|
|
|
{
|
2006-03-16 10:44:55 -05:00
|
|
|
this->Type = cmCacheManager::BOOL;
|
|
|
|
set_field_fore(this->Field, A_NORMAL);
|
|
|
|
set_field_back(this->Field, A_STANDOUT);
|
|
|
|
field_opts_off(this->Field, O_STATIC);
|
2001-11-04 18:05:21 -05:00
|
|
|
this->SetValueAsBool(false);
|
|
|
|
}
|
|
|
|
|
2002-06-18 17:20:07 -04:00
|
|
|
bool cmCursesBoolWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w)
|
2001-11-04 18:05:21 -05:00
|
|
|
{
|
2001-12-13 13:28:41 -05:00
|
|
|
|
2001-11-04 18:05:21 -05:00
|
|
|
// 10 == enter
|
2001-11-05 22:10:52 -05:00
|
|
|
if (key == 10 || key == KEY_ENTER)
|
2001-11-04 18:05:21 -05:00
|
|
|
{
|
|
|
|
if (this->GetValueAsBool())
|
|
|
|
{
|
|
|
|
this->SetValueAsBool(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->SetValueAsBool(true);
|
|
|
|
}
|
|
|
|
|
2012-08-13 13:42:58 -04:00
|
|
|
touchwin(w);
|
|
|
|
wrefresh(w);
|
2001-11-04 18:05:21 -05:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-13 13:42:58 -04:00
|
|
|
|
2001-11-04 18:05:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCursesBoolWidget::SetValueAsBool(bool value)
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
this->SetValue("ON");
|
|
|
|
}
|
|
|
|
else
|
2012-08-13 13:42:58 -04:00
|
|
|
{
|
2001-11-04 18:05:21 -05:00
|
|
|
this->SetValue("OFF");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCursesBoolWidget::GetValueAsBool()
|
|
|
|
{
|
2006-03-16 10:44:55 -05:00
|
|
|
if (this->Value == "ON")
|
2001-11-04 18:05:21 -05:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
2012-08-13 13:42:58 -04:00
|
|
|
{
|
2001-11-04 18:05:21 -05:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|