cmCursesWidget.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 "../cmCacheManager.h"
  13. #include "cmCursesStandardIncludes.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. cmCacheManager::CacheEntryType GetType()
  41. { return this->Type; }
  42. /**
  43. * If there are any, print the widget specific commands
  44. * in the toolbar and return true. Otherwise, return false
  45. * and the parent widget will print.
  46. */
  47. virtual bool PrintKeys()
  48. {
  49. return false;
  50. }
  51. /**
  52. * Set/Get the page this widget is in.
  53. */
  54. void SetPage(int page)
  55. {
  56. this->Page = page;
  57. }
  58. int GetPage()
  59. {
  60. return this->Page;
  61. }
  62. friend class cmCursesMainForm;
  63. protected:
  64. cmCursesWidget(const cmCursesWidget& from);
  65. void operator=(const cmCursesWidget&);
  66. cmCacheManager::CacheEntryType Type;
  67. std::string Value;
  68. FIELD* Field;
  69. // The page in the main form this widget is in
  70. int Page;
  71. };
  72. #endif // __cmCursesWidget_h