cmake/Source/CursesDialog/cmCursesWidget.cxx

45 lines
1.0 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCursesWidget.h"
cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
{
this->Field = new_field(height, width, top, left, 0, 0);
set_field_userptr(this->Field, reinterpret_cast<char*>(this));
2016-07-09 11:21:54 +02:00
field_opts_off(this->Field, O_AUTOSKIP);
this->Page = 0;
}
cmCursesWidget::~cmCursesWidget()
{
2016-07-09 11:21:54 +02:00
if (this->Field) {
free_field(this->Field);
2018-01-26 17:06:56 +01:00
this->Field = nullptr;
2016-07-09 11:21:54 +02:00
}
}
void cmCursesWidget::Move(int x, int y, bool isNewPage)
{
2016-07-09 11:21:54 +02:00
if (!this->Field) {
return;
2016-07-09 11:21:54 +02:00
}
move_field(this->Field, y, x);
2016-07-09 11:21:54 +02:00
if (isNewPage) {
2017-04-14 19:02:05 +02:00
set_new_page(this->Field, true);
2016-07-09 11:21:54 +02:00
} else {
2017-04-14 19:02:05 +02:00
set_new_page(this->Field, false);
2016-07-09 11:21:54 +02:00
}
}
2015-04-27 22:25:09 +02:00
void cmCursesWidget::SetValue(const std::string& value)
{
this->Value = value;
2016-07-09 11:21:54 +02:00
set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
}
const char* cmCursesWidget::GetValue()
{
return this->Value.c_str();
}