]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
15 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
21 wxTextCtrl() { Init(); }
22 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
23 const wxString
& value
= wxEmptyString
,
24 const wxPoint
& pos
= wxDefaultPosition
,
25 const wxSize
& size
= wxDefaultSize
,
27 const wxValidator
& validator
= wxDefaultValidator
,
28 const wxString
& name
= wxTextCtrlNameStr
)
32 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
34 virtual ~wxTextCtrl();
36 bool Create(wxWindow
*parent
, wxWindowID id
,
37 const wxString
& value
= wxEmptyString
,
38 const wxPoint
& pos
= wxDefaultPosition
,
39 const wxSize
& size
= wxDefaultSize
,
41 const wxValidator
& validator
= wxDefaultValidator
,
42 const wxString
& name
= wxTextCtrlNameStr
);
44 // implement base class pure virtuals
45 // ----------------------------------
47 virtual wxString
GetValue() const;
48 virtual void SetValue(const wxString
& value
);
50 virtual int GetLineLength(long lineNo
) const;
51 virtual wxString
GetLineText(long lineNo
) const;
52 virtual int GetNumberOfLines() const;
54 virtual bool IsModified() const;
55 virtual bool IsEditable() const;
57 virtual void GetSelection(long* from
, long* to
) const;
64 virtual void Replace(long from
, long to
, const wxString
& value
);
65 virtual void Remove(long from
, long to
);
67 // load the control's contents from the file
68 virtual bool DoLoadFile(const wxString
& file
, int fileType
);
70 // clears the dirty flag
71 virtual void MarkDirty();
72 virtual void DiscardEdits();
74 virtual void SetMaxLength(unsigned long len
);
76 // writing text inserts it at the current position, appending always
77 // inserts it at the end
78 virtual void WriteText(const wxString
& text
);
79 virtual void AppendText(const wxString
& text
);
82 // apply text attribute to the range of text (only works with richedit
84 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
85 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
86 virtual bool GetStyle(long position
, wxTextAttr
& style
);
87 #endif // wxUSE_RICHEDIT
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;
95 virtual void ShowPosition(long pos
);
96 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
98 wxTextCoord
*row
) const;
100 // Clipboard operations
103 virtual void Paste();
105 virtual bool CanCopy() const;
106 virtual bool CanCut() const;
107 virtual bool CanPaste() const;
113 virtual bool CanUndo() const;
114 virtual bool CanRedo() const;
117 virtual void SetInsertionPoint(long pos
);
118 virtual void SetInsertionPointEnd();
119 virtual long GetInsertionPoint() const;
120 virtual wxTextPos
GetLastPosition() const;
122 virtual void SetSelection(long from
, long to
);
123 virtual void SetEditable(bool editable
);
125 // Caret handling (Windows only)
127 bool ShowNativeCaret(bool show
= true);
128 bool HideNativeCaret() { return ShowNativeCaret(false); }
130 // Implementation from now on
131 // --------------------------
133 virtual void Command(wxCommandEvent
& event
);
134 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
137 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
139 int GetRichVersion() const { return m_verRichEdit
; }
140 bool IsRich() const { return m_verRichEdit
!= 0; }
142 // rich edit controls are not compatible with normal ones and wem ust set
143 // the colours for them otherwise
144 virtual bool SetBackgroundColour(const wxColour
& colour
);
145 virtual bool SetForegroundColour(const wxColour
& colour
);
146 #endif // wxUSE_RICHEDIT
148 virtual bool AcceptsFocus() const;
151 void OnDropFiles(wxDropFilesEvent
& event
);
152 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
154 void OnCut(wxCommandEvent
& event
);
155 void OnCopy(wxCommandEvent
& event
);
156 void OnPaste(wxCommandEvent
& event
);
157 void OnUndo(wxCommandEvent
& event
);
158 void OnRedo(wxCommandEvent
& event
);
159 void OnDelete(wxCommandEvent
& event
);
160 void OnSelectAll(wxCommandEvent
& event
);
162 void OnUpdateCut(wxUpdateUIEvent
& event
);
163 void OnUpdateCopy(wxUpdateUIEvent
& event
);
164 void OnUpdatePaste(wxUpdateUIEvent
& event
);
165 void OnUpdateUndo(wxUpdateUIEvent
& event
);
166 void OnUpdateRedo(wxUpdateUIEvent
& event
);
167 void OnUpdateDelete(wxUpdateUIEvent
& event
);
168 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
170 // Show a context menu for Rich Edit controls (the standard
171 // EDIT control has one already)
172 void OnRightClick(wxMouseEvent
& event
);
174 // be sure the caret remains invisible if the user
175 // called HideNativeCaret() before
176 void OnSetFocus(wxFocusEvent
& event
);
179 // common part of all ctors
182 // intercept WM_GETDLGCODE
183 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
185 // call this to increase the size limit (will do nothing if the current
186 // limit is big enough)
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();
192 #if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)
193 // replace the selection or the entire control contents with the given text
194 // in the specified encoding
195 bool StreamIn(const wxString
& value
, wxFontEncoding encoding
, bool selOnly
);
197 // get the contents of the control out as text in the given encoding
198 wxString
StreamOut(wxFontEncoding encoding
, bool selOnly
= false) const;
199 #endif // wxUSE_RICHEDIT
201 // replace the contents of the selection or of the entire control with the
203 void DoWriteText(const wxString
& text
, bool selectionOnly
= true);
205 // set the selection possibly without scrolling the caret into view
206 void DoSetSelection(long from
, long to
, bool scrollCaret
= true);
208 // return true if there is a non empty selection in the control
209 bool HasSelection() const;
211 // get the length of the line containing the character at the given
213 long GetLengthOfLineContainingPos(long pos
) const;
215 // send TEXT_UPDATED event, return true if it was handled, false otherwise
216 bool SendUpdateEvent();
218 // override some base class virtuals
219 virtual bool MSWShouldPreProcessMessage(WXMSG
* pMsg
);
220 virtual wxSize
DoGetBestSize() const;
222 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
225 // we're using RICHEDIT (and not simple EDIT) control if this field is not
226 // 0, it also gives the version of the RICHEDIT control being used (1, 2 or
229 #endif // wxUSE_RICHEDIT
231 // if true, SendUpdateEvent() will eat the next event (see comments in the
232 // code as to why this is needed)
233 bool m_suppressNextUpdate
;
236 DECLARE_EVENT_TABLE()
237 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl
)
239 wxMenu
* m_privateContextMenu
;
241 bool m_isNativeCaretShown
;