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