cmCursesWidget.cxx 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. cmCursesWidget::cmCursesWidget(int width, int height, int left, int top)
  12. {
  13. this->Field = new_field(height, width, top, left, 0, 0);
  14. set_field_userptr(this->Field, reinterpret_cast<char*>(this));
  15. field_opts_off(this->Field, O_AUTOSKIP);
  16. this->Page = 0;
  17. }
  18. cmCursesWidget::~cmCursesWidget()
  19. {
  20. if (this->Field)
  21. {
  22. free_field(this->Field);
  23. this->Field = 0;
  24. }
  25. }
  26. void cmCursesWidget::Move(int x, int y, bool isNewPage)
  27. {
  28. if (!this->Field)
  29. {
  30. return;
  31. }
  32. move_field(this->Field, y, x);
  33. if (isNewPage)
  34. {
  35. set_new_page(this->Field, TRUE);
  36. }
  37. else
  38. {
  39. set_new_page(this->Field, FALSE);
  40. }
  41. }
  42. void cmCursesWidget::SetValue(const std::string& value)
  43. {
  44. this->Value = value;
  45. set_field_buffer(this->Field, 0, value.c_str());
  46. }
  47. const char* cmCursesWidget::GetValue()
  48. {
  49. return this->Value.c_str();
  50. }