CMake/Source/CursesDialog/cmCursesWidget.cxx

56 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"
2016-09-01 22:55:09 +03:00
#include <cmConfigure.h>
2001-11-05 02:05:21 +03:00
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);
2006-03-16 18:44:55 +03:00
this->Page = 0;
2001-11-05 02:05:21 +03:00
}
cmCursesWidget::~cmCursesWidget()
{
if (this->Field) {
2006-03-16 18:44:55 +03:00
free_field(this->Field);
2016-06-27 23:44:16 +03:00
this->Field = CM_NULLPTR;
}
2001-11-05 02:05:21 +03:00
}
void cmCursesWidget::Move(int x, int y, bool isNewPage)
{
if (!this->Field) {
2001-11-05 02:05:21 +03:00
return;
}
2001-11-05 02:05:21 +03:00
2006-03-16 18:44:55 +03:00
move_field(this->Field, y, x);
if (isNewPage) {
2006-03-16 18:44:55 +03:00
set_new_page(this->Field, TRUE);
} 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 std::string& value)
2001-11-05 02:05:21 +03:00
{
2006-03-16 18:44:55 +03:00
this->Value = value;
set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
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
}