2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: srchctrl.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxSearchCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxSearchCtrl
|
2008-03-08 09:43:31 -05:00
|
|
|
|
|
|
|
A search control is a composite control with a search button, a text
|
2008-03-08 08:52:38 -05:00
|
|
|
control, and a cancel button.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxTE_PROCESS_TAB}
|
2011-01-06 14:52:14 -05:00
|
|
|
The control will receive @c wxEVT_CHAR events for TAB pressed -
|
2008-03-08 08:52:38 -05:00
|
|
|
normally, TAB is used for passing to the next control in a dialog
|
|
|
|
instead. For the control created with this style, you can still use
|
|
|
|
Ctrl-Enter to pass to the next control from the keyboard.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxTE_NOHIDESEL}
|
2008-03-08 08:52:38 -05:00
|
|
|
By default, the Windows text control doesn't show the selection
|
|
|
|
when it doesn't have focus - use this style to force it to always
|
|
|
|
show it. It doesn't do anything under other platforms.
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxTE_LEFT}
|
2008-03-08 08:52:38 -05:00
|
|
|
The text in the control will be left-justified (default).
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxTE_CENTRE}
|
2008-03-08 08:52:38 -05:00
|
|
|
The text in the control will be centered (currently wxMSW and
|
|
|
|
wxGTK2 only).
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxTE_RIGHT}
|
2008-03-08 08:52:38 -05:00
|
|
|
The text in the control will be right-justified (currently wxMSW
|
|
|
|
and wxGTK2 only).
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxTE_CAPITALIZE}
|
2008-03-08 08:52:38 -05:00
|
|
|
On PocketPC and Smartphone, causes the first letter to be
|
|
|
|
capitalized.
|
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxCommandEvent}
|
2018-01-29 20:01:40 -05:00
|
|
|
To react to the changes in the control contents, use wxEVT_TEXT event, just
|
2018-01-29 19:42:06 -05:00
|
|
|
as you would do with wxTextCtrl. However it is recommended to use
|
2018-01-29 20:01:40 -05:00
|
|
|
wxEVT_SEARCH to actually start searching to avoid doing it too soon, while
|
|
|
|
the user is still typing (note that wxEVT_SEARCH is also triggered by
|
|
|
|
pressing Enter in the control).
|
|
|
|
@event{EVT_SEARCH(id, func)}
|
|
|
|
Respond to a @c wxEVT_SEARCH event, generated when the
|
2010-07-11 06:44:18 -04:00
|
|
|
search button is clicked. Note that this does not initiate a search on
|
|
|
|
its own, you need to perform the appropriate action in your event
|
|
|
|
handler. You may use @code event.GetString() @endcode to retrieve the
|
|
|
|
string to search for in the event handler code.
|
2018-01-29 20:01:40 -05:00
|
|
|
@event{EVT_SEARCH_CANCEL(id, func)}
|
|
|
|
Respond to a @c wxEVT_SEARCH_CANCEL event, generated when the
|
2008-10-05 07:24:00 -04:00
|
|
|
cancel button is clicked.
|
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxcore}
|
2008-10-05 07:24:00 -04:00
|
|
|
@category{ctrl}
|
2012-11-03 14:32:50 -04:00
|
|
|
@appearance{searchctrl}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2018-01-29 19:42:06 -05:00
|
|
|
@see wxTextCtrl
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxSearchCtrl : public wxTextCtrl
|
|
|
|
{
|
|
|
|
public:
|
2008-05-29 10:10:52 -04:00
|
|
|
/**
|
|
|
|
Default constructor
|
|
|
|
*/
|
|
|
|
wxSearchCtrl();
|
2008-10-05 07:24:00 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
Constructor, creating and showing a text control.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param parent
|
2008-03-09 08:33:59 -04:00
|
|
|
Parent window. Should not be @NULL.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param id
|
2008-03-09 08:33:59 -04:00
|
|
|
Control identifier. A value of -1 denotes a default value.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param value
|
2008-03-09 08:33:59 -04:00
|
|
|
Default text value.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param pos
|
2008-03-09 08:33:59 -04:00
|
|
|
Text control position.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param size
|
2008-03-09 08:33:59 -04:00
|
|
|
Text control size.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param style
|
2008-03-09 08:33:59 -04:00
|
|
|
Window style. See wxSearchCtrl.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param validator
|
2008-03-09 08:33:59 -04:00
|
|
|
Window validator.
|
2008-03-08 09:43:31 -05:00
|
|
|
@param name
|
2008-03-09 08:33:59 -04:00
|
|
|
Window name.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see wxTextCtrl::Create, wxValidator
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxSearchCtrl(wxWindow* parent, wxWindowID id,
|
2008-11-13 16:32:53 -05:00
|
|
|
const wxString& value = wxEmptyString,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxSearchCtrlNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor, destroying the search control.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxSearchCtrl();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2011-10-29 17:34:49 -04:00
|
|
|
bool Create(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxSearchCtrlNameStr);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Returns a pointer to the search control's menu object or @NULL if there is no
|
2008-03-08 08:52:38 -05:00
|
|
|
menu attached.
|
|
|
|
*/
|
|
|
|
virtual wxMenu* GetMenu();
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Returns the search button visibility value.
|
2008-03-08 08:52:38 -05:00
|
|
|
If there is a menu attached, the search button will be visible regardless of
|
2008-10-05 07:24:00 -04:00
|
|
|
the search button visibility value.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual bool IsSearchButtonVisible() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2011-10-29 17:34:49 -04:00
|
|
|
/**
|
|
|
|
Returns the cancel button's visibility state.
|
|
|
|
*/
|
|
|
|
virtual bool IsCancelButtonVisible() const;
|
2019-01-30 11:28:08 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
2008-10-05 07:24:00 -04:00
|
|
|
Sets the search control's menu object.
|
|
|
|
If there is already a menu associated with the search control it is deleted.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-08 09:43:31 -05:00
|
|
|
@param menu
|
2008-03-09 08:33:59 -04:00
|
|
|
Menu to attach to the search control.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual void SetMenu(wxMenu* menu);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Shows or hides the cancel button.
|
|
|
|
*/
|
|
|
|
virtual void ShowCancelButton(bool show);
|
|
|
|
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Sets the search button visibility value on the search control.
|
2008-03-08 08:52:38 -05:00
|
|
|
If there is a menu attached, the search button will be visible regardless of
|
2008-10-05 07:24:00 -04:00
|
|
|
the search button visibility value.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
virtual void ShowSearchButton(bool show);
|
2011-10-29 17:34:49 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
Set the text to be displayed in the search control when the user has
|
|
|
|
not yet typed anything in it.
|
|
|
|
*/
|
|
|
|
void SetDescriptiveText(const wxString& text);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Return the text displayed when there is not yet any user input.
|
|
|
|
*/
|
|
|
|
wxString GetDescriptiveText() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2011-10-29 17:34:49 -04:00
|
|
|
|
2018-01-29 20:01:40 -05:00
|
|
|
wxEventType wxEVT_SEARCH_CANCEL;
|
|
|
|
wxEventType wxEVT_SEARCH;
|