cmCursesWidget.h 2.2 KB

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