cmCursesWidget.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmCursesWidget_h
  4. #define cmCursesWidget_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include "cmCursesStandardIncludes.h"
  7. #include "cmStateTypes.h"
  8. #include <string>
  9. class cmCursesMainForm;
  10. class cmCursesWidget
  11. {
  12. CM_DISABLE_COPY(cmCursesWidget)
  13. public:
  14. cmCursesWidget(int width, int height, int left, int top);
  15. virtual ~cmCursesWidget();
  16. /**
  17. * Handle user input. Called by the container of this widget
  18. * when this widget has focus. Returns true if the input was
  19. * handled
  20. */
  21. virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w) = 0;
  22. /**
  23. * Change the position of the widget. Set isNewPage to true
  24. * if this widget marks the beginning of a new page.
  25. */
  26. virtual void Move(int x, int y, bool isNewPage);
  27. /**
  28. * Set/Get the value (setting the value also changes the contents
  29. * of the field buffer).
  30. */
  31. virtual void SetValue(const std::string& value);
  32. virtual const char* GetValue();
  33. /**
  34. * Get the type of the widget (STRING, PATH etc...)
  35. */
  36. cmStateEnums::CacheEntryType GetType() { return this->Type; }
  37. /**
  38. * If there are any, print the widget specific commands
  39. * in the toolbar and return true. Otherwise, return false
  40. * and the parent widget will print.
  41. */
  42. virtual bool PrintKeys() { return false; }
  43. /**
  44. * Set/Get the page this widget is in.
  45. */
  46. void SetPage(int page) { this->Page = page; }
  47. int GetPage() { return this->Page; }
  48. friend class cmCursesMainForm;
  49. protected:
  50. cmStateEnums::CacheEntryType Type;
  51. std::string Value;
  52. FIELD* Field;
  53. // The page in the main form this widget is in
  54. int Page;
  55. };
  56. #endif // cmCursesWidget_h