2016-09-27 22:01:08 +03:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
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));
|
2016-05-16 17:34:04 +03:00
|
|
|
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()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
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;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmCursesWidget::Move(int x, int y, bool isNewPage)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Field) {
|
2001-11-05 02:05:21 +03:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
|
2006-03-16 18:44:55 +03:00
|
|
|
move_field(this->Field, y, x);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (isNewPage) {
|
2006-03-16 18:44:55 +03:00
|
|
|
set_new_page(this->Field, TRUE);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-16 18:44:55 +03:00
|
|
|
set_new_page(this->Field, FALSE);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2001-11-05 02:05:21 +03:00
|
|
|
}
|
|
|
|
|
2014-02-22 04:05:55 +04: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;
|
2016-05-16 17:34:04 +03:00
|
|
|
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
|
|
|
}
|