cmCursesWidget.h 1.7 KB

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