]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/srchctlg.h
replace wxGetMultipleChoices() with wxGetSelectedChoices() which allows to distinguis...
[wxWidgets.git] / include / wx / generic / srchctlg.h
CommitLineData
3f7f284d
RD
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/generic/srchctlg.h
3// Purpose: generic wxSearchCtrl class
4// Author: Vince Harron
3f7f284d 5// Created: 2006-02-19
8bc333d7 6// RCS-ID: $Id$
3f7f284d
RD
7// Copyright: Vince Harron
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_GENERIC_SEARCHCTRL_H_
12#define _WX_GENERIC_SEARCHCTRL_H_
13
14#if wxUSE_SEARCHCTRL
15
2efce8f1
RD
16#include "wx/bitmap.h"
17
b5dbe15d
VS
18class WXDLLIMPEXP_FWD_CORE wxSearchButton;
19class WXDLLIMPEXP_FWD_CORE wxSearchTextCtrl;
3f7f284d 20
3f7f284d
RD
21// ----------------------------------------------------------------------------
22// wxSearchCtrl is a combination of wxTextCtrl and wxSearchButton
23// ----------------------------------------------------------------------------
24
53a2db12 25class WXDLLIMPEXP_CORE wxSearchCtrl : public wxSearchCtrlBase
3f7f284d
RD
26{
27public:
28 // creation
29 // --------
30
31 wxSearchCtrl();
32 wxSearchCtrl(wxWindow *parent, wxWindowID id,
33 const wxString& value = wxEmptyString,
34 const wxPoint& pos = wxDefaultPosition,
35 const wxSize& size = wxDefaultSize,
36 long style = 0,
37 const wxValidator& validator = wxDefaultValidator,
38 const wxString& name = wxSearchCtrlNameStr);
39
8bc333d7 40 virtual ~wxSearchCtrl();
3f7f284d
RD
41
42 bool Create(wxWindow *parent, wxWindowID id,
43 const wxString& value = wxEmptyString,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxSearchCtrlNameStr);
49
cfddeb10 50#if wxUSE_MENUS
3f7f284d
RD
51 // get/set search button menu
52 // --------------------------
53 virtual void SetMenu( wxMenu* menu );
54 virtual wxMenu* GetMenu();
cfddeb10 55#endif // wxUSE_MENUS
8bc333d7 56
3f7f284d
RD
57 // get/set search options
58 // ----------------------
ec184e32
VZ
59 virtual void ShowSearchButton( bool show );
60 virtual bool IsSearchButtonVisible() const;
3f7f284d 61
ec184e32
VZ
62 virtual void ShowCancelButton( bool show );
63 virtual bool IsCancelButtonVisible() const;
3f7f284d 64
6646ca90
RD
65 // TODO: In 2.9 these should probably be virtual, and declared in the base class...
66 void SetDescriptiveText(const wxString& text);
67 wxString GetDescriptiveText() const;
6646ca90 68
3f7f284d
RD
69 // accessors
70 // ---------
71
3f7f284d
RD
72 virtual wxString GetRange(long from, long to) const;
73
74 virtual int GetLineLength(long lineNo) const;
75 virtual wxString GetLineText(long lineNo) const;
76 virtual int GetNumberOfLines() const;
77
78 virtual bool IsModified() const;
79 virtual bool IsEditable() const;
80
81 // more readable flag testing methods
82 virtual bool IsSingleLine() const;
83 virtual bool IsMultiLine() const;
84
85 // If the return values from and to are the same, there is no selection.
86 virtual void GetSelection(long* from, long* to) const;
87
88 virtual wxString GetStringSelection() const;
89
90 // operations
91 // ----------
92
93 // editing
94 virtual void Clear();
95 virtual void Replace(long from, long to, const wxString& value);
96 virtual void Remove(long from, long to);
97
98 // load/save the controls contents from/to the file
99 virtual bool LoadFile(const wxString& file);
100 virtual bool SaveFile(const wxString& file = wxEmptyString);
101
102 // sets/clears the dirty flag
103 virtual void MarkDirty();
104 virtual void DiscardEdits();
105
106 // set the max number of characters which may be entered in a single line
107 // text control
108 virtual void SetMaxLength(unsigned long WXUNUSED(len));
109
110 // writing text inserts it at the current position, appending always
111 // inserts it at the end
112 virtual void WriteText(const wxString& text);
113 virtual void AppendText(const wxString& text);
114
115 // insert the character which would have resulted from this key event,
116 // return true if anything has been inserted
117 virtual bool EmulateKeyPress(const wxKeyEvent& event);
118
119 // text control under some platforms supports the text styles: these
120 // methods allow to apply the given text style to the given selection or to
121 // set/get the style which will be used for all appended text
122 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
123 virtual bool GetStyle(long position, wxTextAttr& style);
124 virtual bool SetDefaultStyle(const wxTextAttr& style);
125 virtual const wxTextAttr& GetDefaultStyle() const;
126
127 // translate between the position (which is just an index in the text ctrl
128 // considering all its contents as a single strings) and (x, y) coordinates
129 // which represent column and line.
130 virtual long XYToPosition(long x, long y) const;
131 virtual bool PositionToXY(long pos, long *x, long *y) const;
132
133 virtual void ShowPosition(long pos);
134
135 // find the character at position given in pixels
136 //
137 // NB: pt is in device coords (not adjusted for the client area origin nor
138 // scrolling)
139 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
140 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
141 wxTextCoord *col,
142 wxTextCoord *row) const;
143
144 // Clipboard operations
145 virtual void Copy();
146 virtual void Cut();
147 virtual void Paste();
148
149 virtual bool CanCopy() const;
150 virtual bool CanCut() const;
151 virtual bool CanPaste() const;
152
153 // Undo/redo
154 virtual void Undo();
155 virtual void Redo();
156
157 virtual bool CanUndo() const;
158 virtual bool CanRedo() const;
159
160 // Insertion point
161 virtual void SetInsertionPoint(long pos);
162 virtual void SetInsertionPointEnd();
163 virtual long GetInsertionPoint() const;
164 virtual wxTextPos GetLastPosition() const;
165
166 virtual void SetSelection(long from, long to);
167 virtual void SelectAll();
168 virtual void SetEditable(bool editable);
169
170#if 0
171
172 // override streambuf method
173#if wxHAS_TEXT_WINDOW_STREAM
174 int overflow(int i);
175#endif // wxHAS_TEXT_WINDOW_STREAM
176
177 // stream-like insertion operators: these are always available, whether we
178 // were, or not, compiled with streambuf support
179 wxTextCtrl& operator<<(const wxString& s);
180 wxTextCtrl& operator<<(int i);
181 wxTextCtrl& operator<<(long i);
182 wxTextCtrl& operator<<(float f);
183 wxTextCtrl& operator<<(double d);
184 wxTextCtrl& operator<<(const wxChar c);
185#endif
186
187 // do the window-specific processing after processing the update event
188 virtual void DoUpdateWindowUI(wxUpdateUIEvent& event);
189
190 virtual bool ShouldInheritColours() const;
191
192 // wxWindow overrides
193 virtual bool SetFont(const wxFont& font);
194
195 // search control generic only
196 void SetSearchBitmap( const wxBitmap& bitmap );
3f7f284d 197 void SetCancelBitmap( const wxBitmap& bitmap );
cfddeb10
VZ
198#if wxUSE_MENUS
199 void SetSearchMenuBitmap( const wxBitmap& bitmap );
200#endif // wxUSE_MENUS
3f7f284d
RD
201
202protected:
0ec1179b 203 virtual void DoSetValue(const wxString& value, int flags);
135b23b2 204 virtual wxString DoGetValue() const;
135b23b2 205
0ec1179b
VZ
206 virtual bool DoLoadFile(const wxString& file, int fileType);
207 virtual bool DoSaveFile(const wxString& file, int fileType);
3f7f284d
RD
208
209 // override the base class virtuals involved into geometry calculations
210 virtual wxSize DoGetBestSize() const;
211 virtual void DoMoveWindow(int x, int y, int width, int height);
212 virtual void LayoutControls(int x, int y, int width, int height);
213
214 virtual void RecalcBitmaps();
215
216 void Init();
217
218 virtual wxBitmap RenderSearchBitmap( int x, int y, bool renderDrop );
219 virtual wxBitmap RenderCancelBitmap( int x, int y );
220
221 virtual void OnSearchButton( wxCommandEvent& event );
222
223 void OnSetFocus( wxFocusEvent& event );
af1f44f1 224 void OnSize( wxSizeEvent& event );
cfddeb10
VZ
225
226 bool HasMenu() const
227 {
228#if wxUSE_MENUS
229 return m_menu != NULL;
230#else // !wxUSE_MENUS
231 return false;
232#endif // wxUSE_MENUS/!wxUSE_MENUS
233 }
234
3f7f284d
RD
235private:
236 friend class wxSearchButton;
237
cfddeb10 238#if wxUSE_MENUS
3f7f284d 239 void PopupSearchMenu();
cfddeb10 240#endif // wxUSE_MENUS
3f7f284d
RD
241
242 // the subcontrols
243 wxSearchTextCtrl *m_text;
244 wxSearchButton *m_searchButton;
245 wxSearchButton *m_cancelButton;
cfddeb10 246#if wxUSE_MENUS
3f7f284d 247 wxMenu *m_menu;
cfddeb10 248#endif // wxUSE_MENUS
3f7f284d
RD
249
250 bool m_searchButtonVisible;
251 bool m_cancelButtonVisible;
252
253 bool m_searchBitmapUser;
3f7f284d 254 bool m_cancelBitmapUser;
cfddeb10
VZ
255#if wxUSE_MENUS
256 bool m_searchMenuBitmapUser;
257#endif // wxUSE_MENUS
258
3f7f284d 259 wxBitmap m_searchBitmap;
3f7f284d 260 wxBitmap m_cancelBitmap;
cfddeb10
VZ
261#if wxUSE_MENUS
262 wxBitmap m_searchMenuBitmap;
263#endif // wxUSE_MENUS
264
3f7f284d
RD
265private:
266 DECLARE_DYNAMIC_CLASS(wxSearchCtrl)
267
268 DECLARE_EVENT_TABLE()
269};
270
271#endif // wxUSE_SEARCHCTRL
272
273#endif // _WX_GENERIC_SEARCHCTRL_H_
274