cmCursesWidget.cxx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. free_field(this->Field);
  22. this->Field = CM_NULLPTR;
  23. }
  24. }
  25. void cmCursesWidget::Move(int x, int y, bool isNewPage)
  26. {
  27. if (!this->Field) {
  28. return;
  29. }
  30. move_field(this->Field, y, x);
  31. if (isNewPage) {
  32. set_new_page(this->Field, TRUE);
  33. } else {
  34. set_new_page(this->Field, FALSE);
  35. }
  36. }
  37. void cmCursesWidget::SetValue(const std::string& value)
  38. {
  39. this->Value = value;
  40. set_field_buffer(this->Field, 0, const_cast<char*>(value.c_str()));
  41. }
  42. const char* cmCursesWidget::GetValue()
  43. {
  44. return this->Value.c_str();
  45. }