]>
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;
49 virtual int GetLineLength(long lineNo
) const;
50 virtual wxString
GetLineText(long lineNo
) const;
51 virtual int GetNumberOfLines() const;
53 virtual bool IsModified() const;
54 virtual bool IsEditable() const;
56 virtual void GetSelection(long* from
, long* to
) const;
63 virtual void Replace(long from
, long to
, const wxString
& value
);
64 virtual void Remove(long from
, long to
);
66 // load the control's contents from the file
67 virtual bool DoLoadFile(const wxString
& file
, int fileType
);
69 // clears the dirty flag
70 virtual void MarkDirty();
71 virtual void DiscardEdits();
73 virtual void SetMaxLength(unsigned long len
);
75 // writing text inserts it at the current position, appending always
76 // inserts it at the end
77 virtual void WriteText(const wxString
& text
);
78 virtual void AppendText(const wxString
& text
);
81 // apply text attribute to the range of text (only works with richedit
83 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
84 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
85 virtual bool GetStyle(long position
, wxTextAttr
& style
);
86 #endif // wxUSE_RICHEDIT
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
,
97 wxTextCoord
*row
) const;
99 // Clipboard operations
102 virtual void Paste();
104 virtual bool CanCopy() const;
105 virtual bool CanCut() const;
106 virtual bool CanPaste() const;
112 virtual bool CanUndo() const;
113 virtual bool CanRedo() const;
116 virtual void SetInsertionPoint(long pos
);
117 virtual void SetInsertionPointEnd();
118 virtual long GetInsertionPoint() const;
119 virtual wxTextPos
GetLastPosition() const;
121 virtual void SetSelection(long from
, long to
);
122 virtual void SetEditable(bool editable
);
124 // Caret handling (Windows only)
126 bool ShowNativeCaret(bool show
= true);
127 bool HideNativeCaret() { return ShowNativeCaret(false); }
129 // Implementation from now on
130 // --------------------------
132 virtual void Command(wxCommandEvent
& event
);
133 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
136 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
138 int GetRichVersion() const { return m_verRichEdit
; }
139 bool IsRich() const { return m_verRichEdit
!= 0; }
141 // rich edit controls are not compatible with normal ones and wem ust set
142 // the colours for them otherwise
143 virtual bool SetBackgroundColour(const wxColour
& colour
);
144 virtual bool SetForegroundColour(const wxColour
& colour
);
145 #endif // wxUSE_RICHEDIT
147 virtual bool AcceptsFocus() const;
150 void OnDropFiles(wxDropFilesEvent
& event
);
151 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
153 void OnCut(wxCommandEvent
& event
);
154 void OnCopy(wxCommandEvent
& event
);
155 void OnPaste(wxCommandEvent
& event
);
156 void OnUndo(wxCommandEvent
& event
);
157 void OnRedo(wxCommandEvent
& event
);
158 void OnDelete(wxCommandEvent
& event
);
159 void OnSelectAll(wxCommandEvent
& event
);
161 void OnUpdateCut(wxUpdateUIEvent
& event
);
162 void OnUpdateCopy(wxUpdateUIEvent
& event
);
163 void OnUpdatePaste(wxUpdateUIEvent
& event
);
164 void OnUpdateUndo(wxUpdateUIEvent
& event
);
165 void OnUpdateRedo(wxUpdateUIEvent
& event
);
166 void OnUpdateDelete(wxUpdateUIEvent
& event
);
167 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
169 // Show a context menu for Rich Edit controls (the standard
170 // EDIT control has one already)
171 void OnRightClick(wxMouseEvent
& event
);
173 // be sure the caret remains invisible if the user
174 // called HideNativeCaret() before
175 void OnSetFocus(wxFocusEvent
& event
);
178 // common part of all ctors
181 virtual void DoSetValue(const wxString
& value
, int flags
= 0);
184 // intercept WM_GETDLGCODE
185 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
187 // call this to increase the size limit (will do nothing if the current
188 // limit is big enough)
190 // returns true if we increased the limit to allow entering more text,
191 // false if we hit the limit set by SetMaxLength() and so didn't change it
192 bool AdjustSpaceLimit();
194 #if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)
195 // replace the selection or the entire control contents with the given text
196 // in the specified encoding
197 bool StreamIn(const wxString
& value
, wxFontEncoding encoding
, bool selOnly
);
199 // get the contents of the control out as text in the given encoding
200 wxString
StreamOut(wxFontEncoding encoding
, bool selOnly
= false) const;
201 #endif // wxUSE_RICHEDIT
203 // replace the contents of the selection or of the entire control with the
205 void DoWriteText(const wxString
& text
, bool selectionOnly
= true);
207 // set the selection possibly without scrolling the caret into view
208 void DoSetSelection(long from
, long to
, bool scrollCaret
= true);
210 // return true if there is a non empty selection in the control
211 bool HasSelection() const;
213 // get the length of the line containing the character at the given
215 long GetLengthOfLineContainingPos(long pos
) const;
217 // send TEXT_UPDATED event, return true if it was handled, false otherwise
218 bool SendUpdateEvent();
220 // override some base class virtuals
221 virtual bool MSWShouldPreProcessMessage(WXMSG
* pMsg
);
222 virtual wxSize
DoGetBestSize() const;
224 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
227 // we're using RICHEDIT (and not simple EDIT) control if this field is not
228 // 0, it also gives the version of the RICHEDIT control being used (1, 2 or
231 #endif // wxUSE_RICHEDIT
233 // if true, SendUpdateEvent() will eat the next event (see comments in the
234 // code as to why this is needed)
235 bool m_suppressNextUpdate
;
238 DECLARE_EVENT_TABLE()
239 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl
)
241 wxMenu
* m_privateContextMenu
;
243 bool m_isNativeCaretShown
;