1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/wince/textctrlce.h
3 // Purpose: wxTextCtrl implementation for smart phones driven by WinCE
4 // Author: Wlodzimierz ABX Skiba
8 // Copyright: (c) Wlodzimierz Skiba
9 // License: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TEXTCTRLCE_H_
13 #define _WX_TEXTCTRLCE_H_
15 #include "wx/dynarray.h"
17 class WXDLLEXPORT wxTextCtrl
;
18 WX_DEFINE_EXPORTED_ARRAY_PTR(wxTextCtrl
*, wxArrayTextSpins
);
20 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
26 wxTextCtrl() { Init(); }
27 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
28 const wxString
& value
= wxEmptyString
,
29 const wxPoint
& pos
= wxDefaultPosition
,
30 const wxSize
& size
= wxDefaultSize
,
32 const wxValidator
& validator
= wxDefaultValidator
,
33 const wxString
& name
= wxTextCtrlNameStr
)
37 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
39 virtual ~wxTextCtrl();
41 bool Create(wxWindow
*parent
, wxWindowID id
,
42 const wxString
& value
= wxEmptyString
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
46 const wxValidator
& validator
= wxDefaultValidator
,
47 const wxString
& name
= wxTextCtrlNameStr
);
49 // implement base class pure virtuals
50 // ----------------------------------
52 virtual wxString
GetValue() const;
53 virtual void SetValue(const wxString
& value
);
55 virtual wxString
GetRange(long from
, long to
) const;
57 virtual int GetLineLength(long lineNo
) const;
58 virtual wxString
GetLineText(long lineNo
) const;
59 virtual int GetNumberOfLines() const;
61 virtual bool IsModified() const;
62 virtual bool IsEditable() const;
64 virtual void GetSelection(long* from
, long* to
) const;
71 virtual void Replace(long from
, long to
, const wxString
& value
);
72 virtual void Remove(long from
, long to
);
74 // load the controls contents from the file
75 virtual bool LoadFile(const wxString
& file
);
77 // clears the dirty flag
78 virtual void MarkDirty();
79 virtual void DiscardEdits();
81 virtual void SetMaxLength(unsigned long len
);
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
);
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;
94 virtual void ShowPosition(long pos
);
95 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
, long *pos
) const;
96 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
98 wxTextCoord
*row
) const
100 return wxTextCtrlBase::HitTest(pt
, col
, row
);
103 // Clipboard operations
106 virtual void Paste();
108 virtual bool CanCopy() const;
109 virtual bool CanCut() const;
110 virtual bool CanPaste() const;
116 virtual bool CanUndo() const;
117 virtual bool CanRedo() const;
120 virtual void SetInsertionPoint(long pos
);
121 virtual void SetInsertionPointEnd();
122 virtual long GetInsertionPoint() const;
123 virtual wxTextPos
GetLastPosition() const;
125 virtual void SetSelection(long from
, long to
);
126 virtual void SetEditable(bool editable
);
128 // Caret handling (Windows only)
130 bool ShowNativeCaret(bool show
= true);
131 bool HideNativeCaret() { return ShowNativeCaret(false); }
133 // Implementation from now on
134 // --------------------------
136 virtual void Command(wxCommandEvent
& event
);
137 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
139 virtual void AdoptAttributesFromHWND();
141 virtual bool AcceptsFocus() const;
144 void OnDropFiles(wxDropFilesEvent
& event
);
145 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
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
);
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
);
163 // Show a context menu for Rich Edit controls (the standard
164 // EDIT control has one already)
165 void OnRightClick(wxMouseEvent
& event
);
167 // be sure the caret remains invisible if the user
168 // called HideNativeCaret() before
169 void OnSetFocus(wxFocusEvent
& event
);
171 // get the subclassed window proc of the buddy
172 WXFARPROC
GetBuddyWndProc() const { return m_wndProcBuddy
; }
174 // intercept WM_GETDLGCODE
175 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
178 // common part of all ctors
181 // call this to increase the size limit (will do nothing if the current
182 // limit is big enough)
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();
188 // replace the contents of the selection or of the entire control with the
190 void DoWriteText(const wxString
& text
, bool selectionOnly
= true);
192 // set the selection possibly without scrolling the caret into view
193 void DoSetSelection(long from
, long to
, bool scrollCaret
= true);
195 // return true if there is a non empty selection in the control
196 bool HasSelection() const;
198 // get the length of the line containing the character at the given
200 long GetLengthOfLineContainingPos(long pos
) const;
202 // send TEXT_UPDATED event, return true if it was handled, false otherwise
203 bool SendUpdateEvent();
205 // override some base class virtuals
206 virtual void DoMoveWindow(int x
, int y
, int width
, int height
);
207 virtual wxSize
DoGetBestSize() const;
209 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
211 // if true, SendUpdateEvent() will eat the next event (see comments in the
212 // code as to why this is needed)
213 bool m_suppressNextUpdate
;
215 // all existing wxTextCtrl - this allows to find the one corresponding to
216 // the given buddy window in GetSpinTextCtrl()
217 static wxArrayTextSpins ms_allTextSpins
;
221 // the data for the "buddy" list
223 WXFARPROC m_wndProcBuddy
;
226 DECLARE_EVENT_TABLE()
227 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl
)
229 bool m_isNativeCaretShown
;
232 #endif // _WX_TEXTCTRLCE_H_