| 1 |
#include "search_ctrl_wrapper.h" |
| 2 |
#include "allocator_mgr.h" |
| 3 |
#include "bool_property.h" |
| 4 |
#include "wxgui_defs.h" |
| 5 |
#include <wx/textctrl.h> |
| 6 |
|
| 7 |
SearchCtrlWrapper::SearchCtrlWrapper() |
| 8 |
: wxcWidget(ID_WXSEARCHCTRL) |
| 9 |
{ |
| 10 |
PREPEND_STYLE(wxTE_PROCESS_ENTER, true); |
| 11 |
PREPEND_STYLE(wxTE_PROCESS_TAB, false); |
| 12 |
PREPEND_STYLE(wxTE_NOHIDESEL, false); |
| 13 |
PREPEND_STYLE(wxTE_LEFT, false); |
| 14 |
PREPEND_STYLE(wxTE_CENTRE, false); |
| 15 |
PREPEND_STYLE(wxTE_RIGHT, false); |
| 16 |
PREPEND_STYLE(wxTE_CAPITALIZE, false); |
| 17 |
|
| 18 |
SetPropertyString(_("Common Settings"), "wxSearchCtrl"); |
| 19 |
AddProperty(new StringProperty(PROP_VALUE, wxT(""), _("Default text value."))); |
| 20 |
AddProperty(new BoolProperty(PROP_SHOW_CANCEL_BTN, false, _("Show the 'Cancel' button"))); |
| 21 |
AddProperty(new BoolProperty(PROP_SHOW_SEARCH_BTN, true, _("Show the 'Search' button"))); |
| 22 |
|
| 23 |
RegisterEventCommand(wxT("wxEVT_COMMAND_TEXT_UPDATED"), |
| 24 |
_("Respond to a wxEVT_COMMAND_TEXT_UPDATED event, generated when the text changes.\nNotice " |
| 25 |
"that this event will be sent when the text controls contents changes\n - whether this is " |
| 26 |
"due to user input or comes from the program itself\n(for example, if SetValue() is " |
| 27 |
"called); see ChangeValue() for a function which does not send this event.")); |
| 28 |
RegisterEventCommand(wxT("wxEVT_COMMAND_TEXT_ENTER"), |
| 29 |
_("Respond to a wxEVT_COMMAND_TEXT_ENTER event, generated when enter is pressed in a text " |
| 30 |
"control\n(which must have wxTE_PROCESS_ENTER style for this event to be generated).")); |
| 31 |
RegisterEventCommand(wxT("wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN"), |
| 32 |
_("Respond to a wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN event\ngenerated when the search button " |
| 33 |
"is clicked. Note that this does not initiate a search.")); |
| 34 |
RegisterEventCommand( |
| 35 |
wxT("wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN"), |
| 36 |
_("Respond to a wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN event, generated when the cancel button is clicked.")); |
| 37 |
|
| 38 |
m_namePattern = wxT("m_searchCtrl"); |
| 39 |
SetName(GenerateName()); |
| 40 |
} |
| 41 |
|
| 42 |
SearchCtrlWrapper::~SearchCtrlWrapper() {} |
| 43 |
|
| 44 |
wxcWidget* SearchCtrlWrapper::Clone() const { return new SearchCtrlWrapper(); } |
| 45 |
|
| 46 |
wxString SearchCtrlWrapper::CppCtorCode() const |
| 47 |
{ |
| 48 |
|
| 49 |
wxString cpp; |
| 50 |
cpp << CPPStandardWxCtorWithValue(wxT("0")); |
| 51 |
cpp << GetName() << wxT("->ShowSearchButton(") << PropertyBool(PROP_SHOW_SEARCH_BTN) << wxT(");\n"); |
| 52 |
cpp << GetName() << wxT("->ShowCancelButton(") << PropertyBool(PROP_SHOW_CANCEL_BTN) << wxT(");\n"); |
| 53 |
|
| 54 |
return cpp; |
| 55 |
} |
| 56 |
|
| 57 |
void SearchCtrlWrapper::GetIncludeFile(wxArrayString& headers) const { headers.Add(wxT("#include <wx/srchctrl.h>")); } |
| 58 |
|
| 59 |
wxString SearchCtrlWrapper::GetWxClassName() const { return wxT("wxSearchCtrl"); } |
| 60 |
|
| 61 |
void SearchCtrlWrapper::ToXRC(wxString& text, XRC_TYPE type) const |
| 62 |
{ |
| 63 |
text << XRCPrefix() << XRCSize() << XRCStyle() << XRCCommonAttributes() << XRCValue() << wxT("<cancelbtn>") |
| 64 |
<< PropertyString(PROP_SHOW_CANCEL_BTN) << wxT("</cancelbtn>") << wxT("<searchbtn>") |
| 65 |
<< PropertyString(PROP_SHOW_SEARCH_BTN) << wxT("</searchbtn>") << XRCSuffix(); |
| 66 |
} |