2002-01-21 20:30:43 +00:00
|
|
|
/*=========================================================================
|
|
|
|
|
2002-10-23 22:03:27 +00:00
|
|
|
Program: CMake - Cross-Platform Makefile Generator
|
2002-01-21 20:30:43 +00:00
|
|
|
Module: $RCSfile$
|
|
|
|
Language: C++
|
|
|
|
Date: $Date$
|
|
|
|
Version: $Revision$
|
|
|
|
|
2002-10-23 22:03:27 +00:00
|
|
|
Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
|
2002-01-21 20:30:43 +00:00
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
2001-11-04 23:05:21 +00:00
|
|
|
#include "cmCursesBoolWidget.h"
|
2001-12-13 18:28:41 +00:00
|
|
|
#include "cmCursesMainForm.h"
|
2001-11-04 23:05:21 +00:00
|
|
|
|
|
|
|
cmCursesBoolWidget::cmCursesBoolWidget(int width, int height,
|
2002-10-23 22:03:27 +00:00
|
|
|
int left, int top) :
|
2001-11-04 23:05:21 +00:00
|
|
|
cmCursesWidget(width, height, left, top)
|
|
|
|
{
|
|
|
|
m_Type = cmCacheManager::BOOL;
|
|
|
|
set_field_fore(m_Field, A_NORMAL);
|
|
|
|
set_field_back(m_Field, A_STANDOUT);
|
|
|
|
field_opts_off(m_Field, O_STATIC);
|
|
|
|
this->SetValueAsBool(false);
|
|
|
|
}
|
|
|
|
|
2002-06-18 21:20:07 +00:00
|
|
|
bool cmCursesBoolWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w)
|
2001-11-04 23:05:21 +00:00
|
|
|
{
|
2001-12-13 18:28:41 +00:00
|
|
|
|
2001-11-04 23:05:21 +00:00
|
|
|
// 10 == enter
|
2001-11-06 03:10:52 +00:00
|
|
|
if (key == 10 || key == KEY_ENTER)
|
2001-11-04 23:05:21 +00:00
|
|
|
{
|
|
|
|
if (this->GetValueAsBool())
|
|
|
|
{
|
|
|
|
this->SetValueAsBool(false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->SetValueAsBool(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
touchwin(w);
|
|
|
|
wrefresh(w);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmCursesBoolWidget::SetValueAsBool(bool value)
|
|
|
|
{
|
|
|
|
if (value)
|
|
|
|
{
|
|
|
|
this->SetValue("ON");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->SetValue("OFF");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCursesBoolWidget::GetValueAsBool()
|
|
|
|
{
|
|
|
|
if (m_Value == "ON")
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|