cmCursesStringWidget.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 __cmCursesStringWidget_h
  11. #define __cmCursesStringWidget_h
  12. #include "cmCursesWidget.h"
  13. class cmCursesMainForm;
  14. /** \class cmCursesStringWidget
  15. * \brief A simple entry widget.
  16. *
  17. * cmCursesStringWdiget is a simple text entry widget.
  18. */
  19. class cmCursesStringWidget : public cmCursesWidget
  20. {
  21. public:
  22. cmCursesStringWidget(int width, int height, int left, int top);
  23. /**
  24. * Handle user input. Called by the container of this widget
  25. * when this widget has focus. Returns true if the input was
  26. * handled.
  27. */
  28. virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w);
  29. /**
  30. * Set/Get the string.
  31. */
  32. void SetString(const char* value);
  33. const char* GetString();
  34. virtual const char* GetValue();
  35. /**
  36. * Set/Get InEdit flag. Can be used to tell the widget to leave
  37. * edit mode (in case of a resize for example).
  38. */
  39. void SetInEdit(bool inedit) { this->InEdit = inedit; }
  40. bool GetInEdit() { return this->InEdit; }
  41. /**
  42. * This method is called when different keys are pressed. The
  43. * subclass can have a special implementation handler for this.
  44. */
  45. virtual void OnTab(cmCursesMainForm* fm, WINDOW* w);
  46. virtual void OnReturn(cmCursesMainForm* fm, WINDOW* w);
  47. virtual void OnType(int& key, cmCursesMainForm* fm, WINDOW* w);
  48. /**
  49. * If there are any, print the widget specific commands
  50. * in the toolbar and return true. Otherwise, return false
  51. * and the parent widget will print.
  52. */
  53. virtual bool PrintKeys();
  54. protected:
  55. cmCursesStringWidget(const cmCursesStringWidget& from);
  56. void operator=(const cmCursesStringWidget&);
  57. // true if the widget is in edit mode
  58. bool InEdit;
  59. char* OriginalString;
  60. bool Done;
  61. };
  62. #endif // __cmCursesStringWidget_h