]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/wince/textctrlce.h
Correct harmless typos.
[wxWidgets.git] / include / wx / msw / wince / textctrlce.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/wince/textctrlce.h
3 // Purpose: wxTextCtrl implementation for smart phones driven by WinCE
4 // Author: Wlodzimierz ABX Skiba
5 // Modified by:
6 // Created: 30.08.2004
7 // RCS-ID: $Id$
8 // Copyright: (c) Wlodzimierz Skiba
9 // License: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRLCE_H_
13 #define _WX_TEXTCTRLCE_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "textctrlce.h"
17 #endif
18
19 #include "wx/dynarray.h"
20
21 class WXDLLEXPORT wxTextCtrl;
22 WX_DEFINE_EXPORTED_ARRAY_PTR(wxTextCtrl *, wxArrayTextSpins);
23
24 class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
25 {
26 public:
27 // creation
28 // --------
29
30 wxTextCtrl() { Init(); }
31 wxTextCtrl(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 = wxTextCtrlNameStr)
38 {
39 Init();
40
41 Create(parent, id, value, pos, size, style, validator, name);
42 }
43 ~wxTextCtrl();
44
45 bool Create(wxWindow *parent, wxWindowID id,
46 const wxString& value = wxEmptyString,
47 const wxPoint& pos = wxDefaultPosition,
48 const wxSize& size = wxDefaultSize,
49 long style = 0,
50 const wxValidator& validator = wxDefaultValidator,
51 const wxString& name = wxTextCtrlNameStr);
52
53 // implement base class pure virtuals
54 // ----------------------------------
55
56 virtual wxString GetValue() const;
57 virtual void SetValue(const wxString& value);
58
59 virtual wxString GetRange(long from, long to) const;
60
61 virtual int GetLineLength(long lineNo) const;
62 virtual wxString GetLineText(long lineNo) const;
63 virtual int GetNumberOfLines() const;
64
65 virtual bool IsModified() const;
66 virtual bool IsEditable() const;
67
68 virtual void GetSelection(long* from, long* to) const;
69
70 // operations
71 // ----------
72
73 // editing
74 virtual void Clear();
75 virtual void Replace(long from, long to, const wxString& value);
76 virtual void Remove(long from, long to);
77
78 // load the controls contents from the file
79 virtual bool LoadFile(const wxString& file);
80
81 // clears the dirty flag
82 virtual void MarkDirty();
83 virtual void DiscardEdits();
84
85 virtual void SetMaxLength(unsigned long len);
86
87 // writing text inserts it at the current position, appending always
88 // inserts it at the end
89 virtual void WriteText(const wxString& text);
90 virtual void AppendText(const wxString& text);
91
92 // translate between the position (which is just an index in the text ctrl
93 // considering all its contents as a single strings) and (x, y) coordinates
94 // which represent column and line.
95 virtual long XYToPosition(long x, long y) const;
96 virtual bool PositionToXY(long pos, long *x, long *y) const;
97
98 virtual void ShowPosition(long pos);
99 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
100 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
101 wxTextCoord *col,
102 wxTextCoord *row) const
103 {
104 return wxTextCtrlBase::HitTest(pt, col, row);
105 }
106
107 // Clipboard operations
108 virtual void Copy();
109 virtual void Cut();
110 virtual void Paste();
111
112 virtual bool CanCopy() const;
113 virtual bool CanCut() const;
114 virtual bool CanPaste() const;
115
116 // Undo/redo
117 virtual void Undo();
118 virtual void Redo();
119
120 virtual bool CanUndo() const;
121 virtual bool CanRedo() const;
122
123 // Insertion point
124 virtual void SetInsertionPoint(long pos);
125 virtual void SetInsertionPointEnd();
126 virtual long GetInsertionPoint() const;
127 virtual wxTextPos GetLastPosition() const;
128
129 virtual void SetSelection(long from, long to);
130 virtual void SetEditable(bool editable);
131
132 // Caret handling (Windows only)
133
134 bool ShowNativeCaret(bool show = true);
135 bool HideNativeCaret() { return ShowNativeCaret(false); }
136
137 // Implementation from now on
138 // --------------------------
139
140 virtual void Command(wxCommandEvent& event);
141 virtual bool MSWCommand(WXUINT param, WXWORD id);
142
143 virtual void AdoptAttributesFromHWND();
144
145 virtual bool AcceptsFocus() const;
146
147 // callbacks
148 void OnDropFiles(wxDropFilesEvent& event);
149 void OnChar(wxKeyEvent& event); // Process 'enter' if required
150
151 void OnCut(wxCommandEvent& event);
152 void OnCopy(wxCommandEvent& event);
153 void OnPaste(wxCommandEvent& event);
154 void OnUndo(wxCommandEvent& event);
155 void OnRedo(wxCommandEvent& event);
156 void OnDelete(wxCommandEvent& event);
157 void OnSelectAll(wxCommandEvent& event);
158
159 void OnUpdateCut(wxUpdateUIEvent& event);
160 void OnUpdateCopy(wxUpdateUIEvent& event);
161 void OnUpdatePaste(wxUpdateUIEvent& event);
162 void OnUpdateUndo(wxUpdateUIEvent& event);
163 void OnUpdateRedo(wxUpdateUIEvent& event);
164 void OnUpdateDelete(wxUpdateUIEvent& event);
165 void OnUpdateSelectAll(wxUpdateUIEvent& event);
166
167 // Show a context menu for Rich Edit controls (the standard
168 // EDIT control has one already)
169 void OnRightClick(wxMouseEvent& event);
170
171 // be sure the caret remains invisible if the user
172 // called HideNativeCaret() before
173 void OnSetFocus(wxFocusEvent& event);
174
175 // get the subclassed window proc of the buddy
176 WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
177
178 // intercept WM_GETDLGCODE
179 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
180
181 protected:
182 // common part of all ctors
183 void Init();
184
185 // call this to increase the size limit (will do nothing if the current
186 // limit is big enough)
187 //
188 // returns true if we increased the limit to allow entering more text,
189 // false if we hit the limit set by SetMaxLength() and so didn't change it
190 bool AdjustSpaceLimit();
191
192 // replace the contents of the selection or of the entire control with the
193 // given text
194 void DoWriteText(const wxString& text, bool selectionOnly = true);
195
196 // set the selection possibly without scrolling the caret into view
197 void DoSetSelection(long from, long to, bool scrollCaret = true);
198
199 // return true if there is a non empty selection in the control
200 bool HasSelection() const;
201
202 // get the length of the line containing the character at the given
203 // position
204 long GetLengthOfLineContainingPos(long pos) const;
205
206 // send TEXT_UPDATED event, return true if it was handled, false otherwise
207 bool SendUpdateEvent();
208
209 // override some base class virtuals
210 virtual void DoMoveWindow(int x, int y, int width, int height);
211 virtual wxSize DoGetBestSize() const;
212
213 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
214
215 // if true, SendUpdateEvent() will eat the next event (see comments in the
216 // code as to why this is needed)
217 bool m_suppressNextUpdate;
218
219 // all existing wxTextCtrl - this allows to find the one corresponding to
220 // the given buddy window in GetSpinTextCtrl()
221 static wxArrayTextSpins ms_allTextSpins;
222
223 protected:
224
225 // the data for the "buddy" list
226 WXHWND m_hwndBuddy;
227 WXFARPROC m_wndProcBuddy;
228
229 private:
230 DECLARE_EVENT_TABLE()
231 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl)
232
233 bool m_isNativeCaretShown;
234 };
235
236 #endif // _WX_TEXTCTRLCE_H_