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