]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/srchctrl.h | |
3 | // Purpose: wxSearchCtrlBase class | |
4 | // Author: Vince Harron | |
5 | // Created: 2006-02-18 | |
6 | // Copyright: (c) Vince Harron | |
7 | // Licence: wxWindows licence | |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
10 | #ifndef _WX_SEARCHCTRL_H_BASE_ | |
11 | #define _WX_SEARCHCTRL_H_BASE_ | |
12 | ||
13 | #include "wx/defs.h" | |
14 | ||
15 | #if wxUSE_SEARCHCTRL | |
16 | ||
17 | #include "wx/textctrl.h" | |
18 | ||
19 | #if !defined(__WXUNIVERSAL__) && defined(__WXMAC__) | |
20 | // search control was introduced in Mac OS X 10.3 Panther | |
21 | #define wxUSE_NATIVE_SEARCH_CONTROL 1 | |
22 | ||
23 | #define wxSearchCtrlBaseBaseClass wxTextCtrl | |
24 | #else | |
25 | // no native version, use the generic one | |
26 | #define wxUSE_NATIVE_SEARCH_CONTROL 0 | |
27 | ||
28 | #include "wx/compositewin.h" | |
29 | #include "wx/containr.h" | |
30 | ||
31 | class WXDLLIMPEXP_CORE wxSearchCtrlBaseBaseClass | |
32 | : public wxCompositeWindow< wxNavigationEnabled<wxControl> >, | |
33 | public wxTextCtrlIface | |
34 | { | |
35 | }; | |
36 | #endif | |
37 | ||
38 | // ---------------------------------------------------------------------------- | |
39 | // constants | |
40 | // ---------------------------------------------------------------------------- | |
41 | ||
42 | extern WXDLLIMPEXP_DATA_CORE(const char) wxSearchCtrlNameStr[]; | |
43 | ||
44 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCHCTRL_CANCEL_BTN, wxCommandEvent); | |
45 | wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SEARCHCTRL_SEARCH_BTN, wxCommandEvent); | |
46 | ||
47 | // ---------------------------------------------------------------------------- | |
48 | // a search ctrl is a text control with a search button and a cancel button | |
49 | // it is based on the MacOSX 10.3 control HISearchFieldCreate | |
50 | // ---------------------------------------------------------------------------- | |
51 | ||
52 | class WXDLLIMPEXP_CORE wxSearchCtrlBase : public wxSearchCtrlBaseBaseClass | |
53 | { | |
54 | public: | |
55 | wxSearchCtrlBase() { } | |
56 | virtual ~wxSearchCtrlBase() { } | |
57 | ||
58 | // search control | |
59 | #if wxUSE_MENUS | |
60 | virtual void SetMenu(wxMenu *menu) = 0; | |
61 | virtual wxMenu *GetMenu() = 0; | |
62 | #endif // wxUSE_MENUS | |
63 | ||
64 | // get/set options | |
65 | virtual void ShowSearchButton( bool show ) = 0; | |
66 | virtual bool IsSearchButtonVisible() const = 0; | |
67 | ||
68 | virtual void ShowCancelButton( bool show ) = 0; | |
69 | virtual bool IsCancelButtonVisible() const = 0; | |
70 | ||
71 | private: | |
72 | // implement wxTextEntry pure virtual method | |
73 | virtual wxWindow *GetEditableWindow() { return this; } | |
74 | }; | |
75 | ||
76 | ||
77 | // include the platform-dependent class implementation | |
78 | #if wxUSE_NATIVE_SEARCH_CONTROL | |
79 | #if defined(__WXMAC__) | |
80 | #include "wx/osx/srchctrl.h" | |
81 | #endif | |
82 | #else | |
83 | #include "wx/generic/srchctlg.h" | |
84 | #endif | |
85 | ||
86 | // ---------------------------------------------------------------------------- | |
87 | // macros for handling search events | |
88 | // ---------------------------------------------------------------------------- | |
89 | ||
90 | #define EVT_SEARCHCTRL_CANCEL_BTN(id, fn) \ | |
91 | wx__DECLARE_EVT1(wxEVT_SEARCHCTRL_CANCEL_BTN, id, wxCommandEventHandler(fn)) | |
92 | ||
93 | #define EVT_SEARCHCTRL_SEARCH_BTN(id, fn) \ | |
94 | wx__DECLARE_EVT1(wxEVT_SEARCHCTRL_SEARCH_BTN, id, wxCommandEventHandler(fn)) | |
95 | ||
96 | // old wxEVT_COMMAND_* constants | |
97 | #define wxEVT_COMMAND_SEARCHCTRL_CANCEL_BTN wxEVT_SEARCHCTRL_CANCEL_BTN | |
98 | #define wxEVT_COMMAND_SEARCHCTRL_SEARCH_BTN wxEVT_SEARCHCTRL_SEARCH_BTN | |
99 | ||
100 | #endif // wxUSE_SEARCHCTRL | |
101 | ||
102 | #endif // _WX_SEARCHCTRL_H_BASE_ |