1 /////////////////////////////////////////////////////////////////////////////
 
   3 // Purpose:     SWIG interface for wxSearchCtrl
 
   9 // Copyright:   (c) 2006 by Total Control Software
 
  10 // Licence:     wxWindows license
 
  11 /////////////////////////////////////////////////////////////////////////////
 
  15 //---------------------------------------------------------------------------
 
  18 MAKE_CONST_WXSTRING(SearchCtrlNameStr);
 
  22 #if !defined(wxUSE_SEARCHCTRL) || !wxUSE_SEARCHCTRL
 
  23 // define a dummy class for builds that don't have wxSearchCtrl
 
  26     wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN,
 
  27     wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN
 
  30 class wxSearchCtrl : public wxTextCtrl
 
  33     wxSearchCtrl() { wxPyRaiseNotImplemented(); }
 
  34     wxSearchCtrl(wxWindow*, wxWindowID,
 
  41     { wxPyRaiseNotImplemented(); }
 
  43     bool Create( wxWindow*, wxWindowID,
 
  49                  const wxString& name) {}
 
  51     virtual void SetMenu( wxMenu* ) {}
 
  52     virtual wxMenu* GetMenu() { return NULL; }
 
  54     // get/set search options
 
  55     // ----------------------
 
  56     virtual void ShowSearchButton( bool ) {}
 
  57     virtual bool IsSearchButtonVisible() const { return false; }
 
  59     virtual void ShowCancelButton( bool ) {}
 
  60     virtual bool IsCancelButtonVisible() const { return false; }
 
  67 // Now define the class for SWIG
 
  69 MustHaveApp(wxSearchCtrl);
 
  71 "A search control is a composite of a `wx.TextCtrl` with optional
 
  72 bitmap buttons and a drop-down menu.  Controls like this can typically
 
  73 be found on a toolbar of applications that support some form of search
 
  74 functionality.  On the Mac this control is implemented using the
 
  75 native HISearchField control, on the other platforms a generic control
 
  76 is used, although that may change in the future as more platforms
 
  77 introduce native search widgets.
 
  79 If you wish to use a drop-down menu with your wx.SearchCtrl then you
 
  80 will need to manage its content and handle the menu events yourself,
 
  81 but this is an easy thing to do.  Simply build the menu, pass it to
 
  82 `SetMenu`, and also bind a handler for a range of EVT_MENU events.
 
  83 This gives you the flexibility to use the drop-down menu however you
 
  84 wish, such as for a history of searches, or as a way to select
 
  85 different kinds of searches.  The ToolBar.py sample in the demo shows
 
  88 Since the control derives from `wx.TextCtrl` it is convenient to use
 
  89 the styles and events designed for `wx.TextCtrl`.  For example you can
 
  90 use the ``wx.TE_PROCESS_ENTER`` style and catch the
 
  91 ``wx.EVT_TEXT_ENTER`` event to know when the user has pressed the
 
  92 Enter key in the control and wishes to start a search.
 
  97     =========================    =========================================
 
  98     EVT_SEARCHCTRL_SEARCH_BTN    Sent when the search icon is clicked
 
  99     EVT_SEARCHCTRL_CANCEL_BTN    Sent when the cancel icon is clicked
 
 100     EVT_TEXT                     Sent when the text changes
 
 101     EVT_TEXT_ENTER               Sent when the RETURN/ENTER key is pressed 
 
 102                                  in the search control and the control has
 
 103                                  the wx.TE_PROCESS_ENTER style flag set.
 
 104     =========================    =========================================
 
 108 class wxSearchCtrl : public wxTextCtrl
 
 111     %pythonAppend wxSearchCtrl         "self._setOORInfo(self)";
 
 112     %pythonAppend wxSearchCtrl()       "";
 
 114     wxSearchCtrl(wxWindow *parent, wxWindowID id=-1,
 
 115                  const wxString& value = wxEmptyString,
 
 116                  const wxPoint& pos = wxDefaultPosition,
 
 117                  const wxSize& size = wxDefaultSize,
 
 119                  const wxValidator& validator = wxDefaultValidator,
 
 120                  const wxString& name = wxPySearchCtrlNameStr);
 
 124         "Precreate a wx.SearchCtrl for 2-phase creation.", "",
 
 127     bool Create(wxWindow *parent, wxWindowID id=-1,
 
 128                 const wxString& value = wxEmptyString,
 
 129                 const wxPoint& pos = wxDefaultPosition,
 
 130                 const wxSize& size = wxDefaultSize,
 
 132                 const wxValidator& validator = wxDefaultValidator,
 
 133                 const wxString& name = wxPySearchCtrlNameStr);
 
 137         virtual void , SetMenu( wxMenu* menu ),
 
 138         "Sets the search control's menu object. If there is already a menu
 
 139 associated with the search control it is deleted.", "");
 
 142         virtual wxMenu* , GetMenu(),
 
 143         "Returns a pointer to the search control's menu object or None if there
 
 144 is no menu attached.", "");
 
 149         virtual void , ShowSearchButton( bool show ),
 
 150         "Sets the search button visibility value on the search control. If
 
 151 there is a menu attached, the search button will be visible regardless
 
 152 of the search button visibility value.  This has no effect in Mac OS X
 
 156         virtual bool , IsSearchButtonVisible() const,
 
 157         "Returns the search button visibility value. If there is a menu
 
 158 attached, the search button will be visible regardless of the search
 
 159 button visibility value.  This always returns false in Mac OS X v10.3", "");
 
 162         virtual void , ShowCancelButton( bool show ),
 
 163         "Shows or hides the cancel button.", "");
 
 166         virtual bool , IsCancelButtonVisible() const,
 
 167         "Indicates whether the cancel button is visible. ", "");
 
 170     DocStr(SetSearchBitmap,
 
 171            "Sets the bitmap to use for the search button.  This currently does not
 
 172 work on the Mac.", "");
 
 173     DocStr(SetSearchMenuBitmap,
 
 174            "Sets the bitmap to use for the search button when there is a drop-down
 
 175 menu associated with the search control.  This currently does not work
 
 177     DocStr(SetCancelBitmap,
 
 178            "Sets the bitmap to use for the cancel button.  This currently does not
 
 179 work on the Mac.", "");
 
 183         void SetSearchBitmap( const wxBitmap& ) {}
 
 184         void SetSearchMenuBitmap( const wxBitmap& ) {}
 
 185         void SetCancelBitmap( const wxBitmap& ) {}
 
 188     void SetSearchBitmap( const wxBitmap& bitmap );
 
 189     void SetSearchMenuBitmap( const wxBitmap& bitmap );
 
 190     void SetCancelBitmap( const wxBitmap& bitmap );
 
 194     %property(Menu, GetMenu, SetMenu);
 
 195     %property(SearchButtonVisible, IsSearchButtonVisible, ShowSearchButton);
 
 196     %property(CancelButtonVisible, IsCancelButtonVisible, ShowCancelButton);
 
 202 %constant wxEventType wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN;
 
 203 %constant wxEventType wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN;
 
 206     EVT_SEARCHCTRL_CANCEL_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN, 1)
 
 207     EVT_SEARCHCTRL_SEARCH_BTN = wx.PyEventBinder( wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN, 1)
 
 210 //---------------------------------------------------------------------------