cmCursesStringWidget.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #ifndef __cmCursesStringWidget_h
  14. #define __cmCursesStringWidget_h
  15. #include "cmCursesWidget.h"
  16. class cmCursesMainForm;
  17. /** \class cmCursesStringWidget
  18. * \brief A simple entry widget.
  19. *
  20. * cmCursesStringWdiget is a simple text entry widget.
  21. */
  22. class cmCursesStringWidget : public cmCursesWidget
  23. {
  24. public:
  25. cmCursesStringWidget(int width, int height, int left, int top);
  26. /**
  27. * Handle user input. Called by the container of this widget
  28. * when this widget has focus. Returns true if the input was
  29. * handled.
  30. */
  31. virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w);
  32. /**
  33. * Set/Get the string.
  34. */
  35. void SetString(const char* value);
  36. const char* GetString();
  37. virtual const char* GetValue();
  38. /**
  39. * Set/Get InEdit flag. Can be used to tell the widget to leave
  40. * edit mode (in case of a resize for example).
  41. */
  42. void SetInEdit(bool inedit)
  43. { m_InEdit = inedit; }
  44. bool GetInEdit()
  45. { return m_InEdit; }
  46. /**
  47. * This method is called when different keys are pressed. The
  48. * subclass can have a special implementation handler for this.
  49. */
  50. virtual void OnTab(cmCursesMainForm* fm, WINDOW* w);
  51. virtual void OnReturn(cmCursesMainForm* fm, WINDOW* w);
  52. virtual void OnType(int& key, cmCursesMainForm* fm, WINDOW* w);
  53. /**
  54. * If there are any, print the widget specific commands
  55. * in the toolbar and return true. Otherwise, return false
  56. * and the parent widget will print.
  57. */
  58. virtual bool PrintKeys();
  59. protected:
  60. cmCursesStringWidget(const cmCursesStringWidget& from);
  61. void operator=(const cmCursesStringWidget&);
  62. // true if the widget is in edit mode
  63. bool m_InEdit;
  64. char* m_OriginalString;
  65. bool m_Done;
  66. };
  67. #endif // __cmCursesStringWidget_h