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