CMake/Source/CursesDialog/cmCursesWidget.cxx

59 lines
1.4 KiB
C++
Raw Normal View History

/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
2002-01-21 23:30:43 +03:00
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
2002-01-21 23:30:43 +03: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-05 02:05:21 +03:00
#include "cmCursesWidget.h"
cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
{
2006-03-16 18:44:55 +03:00
this->Field = new_field(height, width, top, left, 0, 0);
set_field_userptr(this->Field, reinterpret_cast<char*>(this));
field_opts_off(this->Field, O_AUTOSKIP);
this->Page = 0;
2001-11-05 02:05:21 +03:00
}
cmCursesWidget::~cmCursesWidget()
{
2006-03-16 18:44:55 +03:00
if (this->Field)
2001-11-05 02:05:21 +03:00
{
2006-03-16 18:44:55 +03:00
free_field(this->Field);
this->Field = 0;
2001-11-05 02:05:21 +03:00
}
}
void cmCursesWidget::Move(int x, int y, bool isNewPage)
{
2006-03-16 18:44:55 +03:00
if (!this->Field)
2001-11-05 02:05:21 +03:00
{
return;
}
2006-03-16 18:44:55 +03:00
move_field(this->Field, y, x);
2001-11-05 02:05:21 +03:00
if (isNewPage)
{
2006-03-16 18:44:55 +03:00
set_new_page(this->Field, TRUE);
2001-11-05 02:05:21 +03:00
}
else
{
2006-03-16 18:44:55 +03:00
set_new_page(this->Field, FALSE);
2001-11-05 02:05:21 +03:00
}
}
void cmCursesWidget::SetValue(const char* value)
{
2006-03-16 18:44:55 +03:00
this->Value = value;
set_field_buffer(this->Field, 0, value);
2001-11-05 02:05:21 +03:00
}
const char* cmCursesWidget::GetValue()
{
2006-03-16 18:44:55 +03:00
return this->Value.c_str();
2001-11-05 02:05:21 +03:00
}