]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/textctrl.h
Tidy up the include guards for the various wxWebView header files.
[wxWidgets.git] / include / wx / palmos / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Yunhui Fu
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
15 class WXDLLIMPEXP_CORE wxTextCtrl : public wxTextCtrlBase
16 {
17 public:
18 // creation
19 // --------
20
21 wxTextCtrl() { Init(); }
22 wxTextCtrl(wxWindow *parent, wxWindowID id,
23 const wxString& value = wxEmptyString,
24 const wxPoint& pos = wxDefaultPosition,
25 const wxSize& size = wxDefaultSize,
26 long style = 0,
27 const wxValidator& validator = wxDefaultValidator,
28 const wxString& name = wxTextCtrlNameStr)
29 {
30 Init();
31
32 Create(parent, id, value, pos, size, style, validator, name);
33 }
34 virtual ~wxTextCtrl();
35
36 bool Create(wxWindow *parent, wxWindowID id,
37 const wxString& value = wxEmptyString,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 long style = 0,
41 const wxValidator& validator = wxDefaultValidator,
42 const wxString& name = wxTextCtrlNameStr);
43
44 // overridden wxTextEntry methods
45 // ------------------------------
46
47 virtual wxString GetValue() const;
48 virtual wxString GetRange(long from, long to) const;
49
50 virtual bool IsEmpty() const;
51
52 virtual int GetLineLength(long lineNo) const;
53 virtual wxString GetLineText(long lineNo) const;
54 virtual int GetNumberOfLines() const;
55
56 virtual void SetMaxLength(unsigned long len);
57
58 virtual void GetSelection(long *from, long *to) const;
59 //
60 // Operations
61 // ----------
62 //
63 virtual void Clear(void);
64 virtual void Replace( long lFrom
65 ,long lTo
66 ,const wxString& rsValue
67 );
68 virtual void Remove( long lFrom
69 ,long lTo
70 );
71
72 //virtual bool DoLoadFile(const wxString& rsFile, int fileType);
73
74 virtual void MarkDirty();
75 virtual void DiscardEdits(void);
76
77 virtual void WriteText(const wxString& rsText);
78 virtual void AppendText(const wxString& rsText);
79 virtual bool EmulateKeyPress(const wxKeyEvent& rEvent);
80
81 virtual void Copy(void);
82 virtual void Cut(void);
83 virtual void Paste(void);
84
85 virtual bool CanCopy(void) const;
86 virtual bool CanCut(void) const;
87 virtual bool CanPaste(void) const;
88
89 virtual void Undo(void);
90 virtual void Redo();
91
92 virtual bool CanUndo(void) const;
93 virtual bool CanRedo(void) const;
94
95 virtual void SetInsertionPoint(long lPos);
96 virtual void SetInsertionPointEnd(void);
97 virtual long GetInsertionPoint(void) const;
98 virtual wxTextPos GetLastPosition(void) const;
99
100 virtual void SetSelection( long lFrom
101 ,long lTo
102 );
103 virtual void SetEditable(bool bEditable);
104 virtual void SetWindowStyleFlag(long lStyle);
105
106 // implement base class pure virtuals
107 // ----------------------------------
108
109 virtual bool IsModified() const;
110 virtual bool IsEditable(void) const;
111
112 #if wxUSE_RICHEDIT
113 // apply text attribute to the range of text (only works with richedit
114 // controls)
115 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
116 virtual bool SetDefaultStyle(const wxTextAttr& style);
117 virtual bool GetStyle(long position, wxTextAttr& style);
118 #endif // wxUSE_RICHEDIT
119
120 // translate between the position (which is just an index in the text ctrl
121 // considering all its contents as a single strings) and (x, y) coordinates
122 // which represent column and line.
123 virtual long XYToPosition(long x, long y) const;
124 virtual bool PositionToXY(long pos, long *x, long *y) const;
125
126 virtual void ShowPosition(long pos);
127 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
128 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
129 wxTextCoord *col,
130 wxTextCoord *row) const
131 {
132 return wxTextCtrlBase::HitTest(pt, col, row);
133 }
134
135 // Caret handling (Windows only)
136 bool ShowNativeCaret(bool show = true);
137 bool HideNativeCaret() { return ShowNativeCaret(false); }
138
139 // Implementation from now on
140 // --------------------------
141
142 #if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
143 virtual void SetDropTarget(wxDropTarget *dropTarget);
144 #endif // wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT
145
146 virtual void Command(wxCommandEvent& event);
147
148 #if wxUSE_RICHEDIT
149
150 int GetRichVersion() const { return m_verRichEdit; }
151 bool IsRich() const { return m_verRichEdit != 0; }
152
153 // rich edit controls are not compatible with normal ones and wem ust set
154 // the colours for them otherwise
155 virtual bool SetBackgroundColour(const wxColour& colour);
156 virtual bool SetForegroundColour(const wxColour& colour);
157 #else
158 bool IsRich() const { return false; }
159 #endif // wxUSE_RICHEDIT
160
161 #if wxUSE_INKEDIT && wxUSE_RICHEDIT
162 bool IsInkEdit() const { return m_isInkEdit != 0; }
163 #else
164 bool IsInkEdit() const { return false; }
165 #endif
166
167 virtual void AdoptAttributesFromHWND();
168
169 virtual bool AcceptsFocusFromKeyboard() const;
170
171 // returns true if the platform should explicitly apply a theme border
172 virtual bool CanApplyThemeBorder() const;
173
174 // callbacks
175 void OnDropFiles(wxDropFilesEvent& event);
176 void OnChar(wxKeyEvent& event); // Process 'enter' if required
177
178 void OnCut(wxCommandEvent& event);
179 void OnCopy(wxCommandEvent& event);
180 void OnPaste(wxCommandEvent& event);
181 void OnUndo(wxCommandEvent& event);
182 void OnRedo(wxCommandEvent& event);
183 void OnDelete(wxCommandEvent& event);
184 void OnSelectAll(wxCommandEvent& event);
185
186 void OnUpdateCut(wxUpdateUIEvent& event);
187 void OnUpdateCopy(wxUpdateUIEvent& event);
188 void OnUpdatePaste(wxUpdateUIEvent& event);
189 void OnUpdateUndo(wxUpdateUIEvent& event);
190 void OnUpdateRedo(wxUpdateUIEvent& event);
191 void OnUpdateDelete(wxUpdateUIEvent& event);
192 void OnUpdateSelectAll(wxUpdateUIEvent& event);
193
194 // Show a context menu for Rich Edit controls (the standard
195 // EDIT control has one already)
196 void OnContextMenu(wxContextMenuEvent& event);
197
198 // be sure the caret remains invisible if the user
199 // called HideNativeCaret() before
200 void OnSetFocus(wxFocusEvent& event);
201
202 virtual wxVisualAttributes GetDefaultAttributes() const;
203
204 protected:
205 // common part of all ctors
206 void Init();
207
208 virtual bool DoLoadFile(const wxString& file, int fileType);
209
210 // creates the control of appropriate class (plain or rich edit) with the
211 // styles corresponding to m_windowStyle
212 //
213 // this is used by ctor/Create() and when we need to recreate the control
214 // later
215 bool MSWCreateText(const wxString& value,
216 const wxPoint& pos,
217 const wxSize& size);
218
219 virtual void DoSetValue(const wxString &value, int flags = 0);
220
221 // return true if this control has a user-set limit on amount of text (i.e.
222 // the limit is due to a previous call to SetMaxLength() and not built in)
223 bool HasSpaceLimit(unsigned int *len) const;
224
225 // call this to increase the size limit (will do nothing if the current
226 // limit is big enough)
227 //
228 // returns true if we increased the limit to allow entering more text,
229 // false if we hit the limit set by SetMaxLength() and so didn't change it
230 bool AdjustSpaceLimit();
231
232 #if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)
233 // replace the selection or the entire control contents with the given text
234 // in the specified encoding
235 bool StreamIn(const wxString& value, wxFontEncoding encoding, bool selOnly);
236
237 // get the contents of the control out as text in the given encoding
238 wxString StreamOut(wxFontEncoding encoding, bool selOnly = false) const;
239 #endif // wxUSE_RICHEDIT
240
241 // replace the contents of the selection or of the entire control with the
242 // given text
243 void DoWriteText(const wxString& text,
244 int flags = SetValue_SendEvent | SetValue_SelectionOnly);
245
246 // set the selection (possibly without scrolling the caret into view)
247 void DoSetSelection(long from, long to, int flags);
248
249 // get the length of the line containing the character at the given
250 // position
251 long GetLengthOfLineContainingPos(long pos) const;
252
253 // send TEXT_UPDATED event, return true if it was handled, false otherwise
254 bool SendUpdateEvent();
255
256 virtual wxSize DoGetBestSize() const;
257
258 #if wxUSE_RICHEDIT
259 // we're using RICHEDIT (and not simple EDIT) control if this field is not
260 // 0, it also gives the version of the RICHEDIT control being used (1, 2 or
261 // 3 so far)
262 int m_verRichEdit;
263 #endif // wxUSE_RICHEDIT
264
265 // number of EN_UPDATE events sent by Windows when we change the controls
266 // text ourselves: we want this to be exactly 1
267 int m_updatesCount;
268
269 private:
270 virtual void EnableTextChangedEvents(bool enable)
271 {
272 m_updatesCount = enable ? -1 : -2;
273 }
274
275 // implement wxTextEntry pure virtual: it implements all the operations for
276 // the simple EDIT controls
277 virtual WXHWND GetEditHWND() const { return m_hWnd; }
278
279 DECLARE_EVENT_TABLE()
280 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl)
281
282 wxMenu* m_privateContextMenu;
283
284 bool m_isNativeCaretShown;
285
286 #if wxUSE_INKEDIT && wxUSE_RICHEDIT
287 int m_isInkEdit;
288 #endif
289
290 };
291
292 #endif
293 // _WX_TEXTCTRL_H_