srchctrl.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: srchctrl.h
  3. // Purpose: interface of wxSearchCtrl
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxSearchCtrl
  9. A search control is a composite control with a search button, a text
  10. control, and a cancel button.
  11. @beginStyleTable
  12. @style{wxTE_PROCESS_ENTER}
  13. The control will generate the event @c wxEVT_TEXT_ENTER
  14. (otherwise pressing Enter key is either processed internally by the
  15. control or used for navigation between dialog controls).
  16. @style{wxTE_PROCESS_TAB}
  17. The control will receive @c wxEVT_CHAR events for TAB pressed -
  18. normally, TAB is used for passing to the next control in a dialog
  19. instead. For the control created with this style, you can still use
  20. Ctrl-Enter to pass to the next control from the keyboard.
  21. @style{wxTE_NOHIDESEL}
  22. By default, the Windows text control doesn't show the selection
  23. when it doesn't have focus - use this style to force it to always
  24. show it. It doesn't do anything under other platforms.
  25. @style{wxTE_LEFT}
  26. The text in the control will be left-justified (default).
  27. @style{wxTE_CENTRE}
  28. The text in the control will be centered (currently wxMSW and
  29. wxGTK2 only).
  30. @style{wxTE_RIGHT}
  31. The text in the control will be right-justified (currently wxMSW
  32. and wxGTK2 only).
  33. @style{wxTE_CAPITALIZE}
  34. On PocketPC and Smartphone, causes the first letter to be
  35. capitalized.
  36. @endStyleTable
  37. @beginEventEmissionTable{wxCommandEvent}
  38. To retrieve actual search queries, use EVT_TEXT and EVT_TEXT_ENTER events,
  39. just as you would with wxTextCtrl.
  40. @event{EVT_SEARCHCTRL_SEARCH_BTN(id, func)}
  41. Respond to a @c wxEVT_SEARCHCTRL_SEARCH_BTN event, generated when the
  42. search button is clicked. Note that this does not initiate a search on
  43. its own, you need to perform the appropriate action in your event
  44. handler. You may use @code event.GetString() @endcode to retrieve the
  45. string to search for in the event handler code.
  46. @event{EVT_SEARCHCTRL_CANCEL_BTN(id, func)}
  47. Respond to a @c wxEVT_SEARCHCTRL_CANCEL_BTN event, generated when the
  48. cancel button is clicked.
  49. @endEventTable
  50. @library{wxcore}
  51. @category{ctrl}
  52. @appearance{searchctrl}
  53. @see wxTextCtrl::Create, wxValidator
  54. */
  55. class wxSearchCtrl : public wxTextCtrl
  56. {
  57. public:
  58. /**
  59. Default constructor
  60. */
  61. wxSearchCtrl();
  62. /**
  63. Constructor, creating and showing a text control.
  64. @param parent
  65. Parent window. Should not be @NULL.
  66. @param id
  67. Control identifier. A value of -1 denotes a default value.
  68. @param value
  69. Default text value.
  70. @param pos
  71. Text control position.
  72. @param size
  73. Text control size.
  74. @param style
  75. Window style. See wxSearchCtrl.
  76. @param validator
  77. Window validator.
  78. @param name
  79. Window name.
  80. @see wxTextCtrl::Create, wxValidator
  81. */
  82. wxSearchCtrl(wxWindow* parent, wxWindowID id,
  83. const wxString& value = wxEmptyString,
  84. const wxPoint& pos = wxDefaultPosition,
  85. const wxSize& size = wxDefaultSize,
  86. long style = 0,
  87. const wxValidator& validator = wxDefaultValidator,
  88. const wxString& name = wxSearchCtrlNameStr);
  89. /**
  90. Destructor, destroying the search control.
  91. */
  92. virtual ~wxSearchCtrl();
  93. bool Create(wxWindow* parent, wxWindowID id,
  94. const wxString& value = wxEmptyString,
  95. const wxPoint& pos = wxDefaultPosition,
  96. const wxSize& size = wxDefaultSize,
  97. long style = 0,
  98. const wxValidator& validator = wxDefaultValidator,
  99. const wxString& name = wxSearchCtrlNameStr);
  100. /**
  101. Returns a pointer to the search control's menu object or @NULL if there is no
  102. menu attached.
  103. */
  104. virtual wxMenu* GetMenu();
  105. /**
  106. Returns the search button visibility value.
  107. If there is a menu attached, the search button will be visible regardless of
  108. the search button visibility value.
  109. This always returns @false in Mac OS X v10.3
  110. */
  111. virtual bool IsSearchButtonVisible() const;
  112. /**
  113. Returns the cancel button's visibility state.
  114. */
  115. virtual bool IsCancelButtonVisible() const;
  116. /**
  117. Sets the search control's menu object.
  118. If there is already a menu associated with the search control it is deleted.
  119. @param menu
  120. Menu to attach to the search control.
  121. */
  122. virtual void SetMenu(wxMenu* menu);
  123. /**
  124. Shows or hides the cancel button.
  125. */
  126. virtual void ShowCancelButton(bool show);
  127. /**
  128. Sets the search button visibility value on the search control.
  129. If there is a menu attached, the search button will be visible regardless of
  130. the search button visibility value.
  131. This has no effect in Mac OS X v10.3
  132. */
  133. virtual void ShowSearchButton(bool show);
  134. /**
  135. Set the text to be displayed in the search control when the user has
  136. not yet typed anything in it.
  137. */
  138. void SetDescriptiveText(const wxString& text);
  139. /**
  140. Return the text displayed when there is not yet any user input.
  141. */
  142. wxString GetDescriptiveText() const;
  143. };
  144. wxEventType wxEVT_SEARCHCTRL_CANCEL_BTN;
  145. wxEventType wxEVT_SEARCHCTRL_SEARCH_BTN;