cmCursesWidget.cxx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCursesWidget.h"
  11. #include <cmConfigure.h>
  12. cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
  13. {
  14. this->Field = new_field(height, width, top, left, 0, 0);
  15. set_field_userptr(this->Field, reinterpret_cast<char*>(this));
  16. field_opts_off(this->Field, O_AUTOSKIP);
  17. this->Page = 0;
  18. }
  19. cmCursesWidget::~cmCursesWidget()
  20. {
  21. if (this->Field) {
  22. free_field(this->Field);
  23. this->Field = CM_NULLPTR;
  24. }
  25. }
  26. void cmCursesWidget::Move(int x, int y, bool isNewPage)
  27. {
  28. if (!this->Field) {
  29. return;
  30. }
  31. move_field(this->Field, y, x);
  32. if (isNewPage) {
  33. set_new_page(this->Field, TRUE);
  34. } else {
  35. set_new_page(this->Field, FALSE);
  36. }
  37. }
  38. void cmCursesWidget::SetValue(const std::string& value)
  39. {
  40. this->Value = value;
  41. set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
  42. }
  43. const char* cmCursesWidget::GetValue()
  44. {
  45. return this->Value.c_str();
  46. }