cmCursesWidget.h 1.8 KB

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