CMake/Source/CursesDialog/cmCursesBoolWidget.cxx

80 lines
1.7 KiB
C++
Raw Normal View History

2002-01-21 20:30:43 +00:00
/*=========================================================================
Program: CMake - Cross-Platform Makefile Generator
2002-01-21 20:30:43 +00:00
Module: $RCSfile$
Language: C++
Date: $Date$
Version: $Revision$
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,
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);
}
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;
}
}