cmCursesWidget.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #ifndef cmCursesWidget_h
  11. #define cmCursesWidget_h
  12. #include <cmConfigure.h> // IWYU pragma: keep
  13. #include "cmCursesStandardIncludes.h"
  14. #include "cmState.h"
  15. #include <string>
  16. class cmCursesMainForm;
  17. class cmCursesWidget
  18. {
  19. public:
  20. cmCursesWidget(int width, int height, int left, int top);
  21. virtual ~cmCursesWidget();
  22. /**
  23. * Handle user input. Called by the container of this widget
  24. * when this widget has focus. Returns true if the input was
  25. * handled
  26. */
  27. virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) = 0;
  28. /**
  29. * Change the position of the widget. Set isNewPage to true
  30. * if this widget marks the beginning of a new page.
  31. */
  32. virtual void Move(int x, int y, bool isNewPage);
  33. /**
  34. * Set/Get the value (setting the value also changes the contents
  35. * of the field buffer).
  36. */
  37. virtual void SetValue(const std::string& value);
  38. virtual const char* GetValue();
  39. /**
  40. * Get the type of the widget (STRING, PATH etc...)
  41. */
  42. cmState::CacheEntryType GetType() { return this->Type; }
  43. /**
  44. * If there are any, print the widget specific commands
  45. * in the toolbar and return true. Otherwise, return false
  46. * and the parent widget will print.
  47. */
  48. virtual bool PrintKeys() { return false; }
  49. /**
  50. * Set/Get the page this widget is in.
  51. */
  52. void SetPage(int page) { this->Page = page; }
  53. int GetPage() { return this->Page; }
  54. friend class cmCursesMainForm;
  55. protected:
  56. cmCursesWidget(const cmCursesWidget& from);
  57. void operator=(const cmCursesWidget&);
  58. cmState::CacheEntryType Type;
  59. std::string Value;
  60. FIELD* Field;
  61. // The page in the main form this widget is in
  62. int Page;
  63. };
  64. #endif // cmCursesWidget_h