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