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