]>
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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "textctrl.h"
19 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
25 wxTextCtrl() { Init(); }
26 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
27 const wxString
& value
= wxEmptyString
,
28 const wxPoint
& pos
= wxDefaultPosition
,
29 const wxSize
& size
= wxDefaultSize
,
31 const wxValidator
& validator
= wxDefaultValidator
,
32 const wxString
& name
= wxTextCtrlNameStr
)
36 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
40 bool Create(wxWindow
*parent
, wxWindowID id
,
41 const wxString
& value
= wxEmptyString
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxTextCtrlNameStr
);
48 // implement base class pure virtuals
49 // ----------------------------------
51 virtual wxString
GetValue() const;
52 virtual void SetValue(const wxString
& value
);
54 virtual int GetLineLength(long lineNo
) const;
55 virtual wxString
GetLineText(long lineNo
) const;
56 virtual int GetNumberOfLines() const;
58 virtual bool IsModified() const;
59 virtual bool IsEditable() const;
61 virtual void GetSelection(long* from
, long* to
) const;
68 virtual void Replace(long from
, long to
, const wxString
& value
);
69 virtual void Remove(long from
, long to
);
71 // load the controls contents from the file
72 virtual bool LoadFile(const wxString
& file
);
74 // clears the dirty flag
75 virtual void MarkDirty();
76 virtual void DiscardEdits();
78 virtual void SetMaxLength(unsigned long len
);
80 // writing text inserts it at the current position, appending always
81 // inserts it at the end
82 virtual void WriteText(const wxString
& text
);
83 virtual void AppendText(const wxString
& text
);
86 // apply text attribute to the range of text (only works with richedit
88 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
89 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
90 virtual bool GetStyle(long position
, wxTextAttr
& style
);
91 #endif // wxUSE_RICHEDIT
93 // translate between the position (which is just an index in the text ctrl
94 // considering all its contents as a single strings) and (x, y) coordinates
95 // which represent column and line.
96 virtual long XYToPosition(long x
, long y
) const;
97 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
99 virtual void ShowPosition(long pos
);
100 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
102 wxTextCoord
*row
) const;
104 // Clipboard operations
107 virtual void Paste();
109 virtual bool CanCopy() const;
110 virtual bool CanCut() const;
111 virtual bool CanPaste() const;
117 virtual bool CanUndo() const;
118 virtual bool CanRedo() const;
121 virtual void SetInsertionPoint(long pos
);
122 virtual void SetInsertionPointEnd();
123 virtual long GetInsertionPoint() const;
124 virtual wxTextPos
GetLastPosition() const;
126 virtual void SetSelection(long from
, long to
);
127 virtual void SetEditable(bool editable
);
129 // Caret handling (Windows only)
131 bool ShowNativeCaret(bool show
= true);
132 bool HideNativeCaret() { return ShowNativeCaret(false); }
134 // Implementation from now on
135 // --------------------------
137 virtual void Command(wxCommandEvent
& event
);
138 virtual bool MSWCommand(WXUINT param
, WXWORD id
);
141 virtual bool MSWOnNotify(int idCtrl
, WXLPARAM lParam
, WXLPARAM
*result
);
143 int GetRichVersion() const { return m_verRichEdit
; }
144 bool IsRich() const { return m_verRichEdit
!= 0; }
146 // rich edit controls are not compatible with normal ones and wem ust set
147 // the colours for them otherwise
148 virtual bool SetBackgroundColour(const wxColour
& colour
);
149 virtual bool SetForegroundColour(const wxColour
& colour
);
150 #endif // wxUSE_RICHEDIT
152 virtual bool AcceptsFocus() const;
155 void OnDropFiles(wxDropFilesEvent
& event
);
156 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
158 void OnCut(wxCommandEvent
& event
);
159 void OnCopy(wxCommandEvent
& event
);
160 void OnPaste(wxCommandEvent
& event
);
161 void OnUndo(wxCommandEvent
& event
);
162 void OnRedo(wxCommandEvent
& event
);
163 void OnDelete(wxCommandEvent
& event
);
164 void OnSelectAll(wxCommandEvent
& event
);
166 void OnUpdateCut(wxUpdateUIEvent
& event
);
167 void OnUpdateCopy(wxUpdateUIEvent
& event
);
168 void OnUpdatePaste(wxUpdateUIEvent
& event
);
169 void OnUpdateUndo(wxUpdateUIEvent
& event
);
170 void OnUpdateRedo(wxUpdateUIEvent
& event
);
171 void OnUpdateDelete(wxUpdateUIEvent
& event
);
172 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
174 // Show a context menu for Rich Edit controls (the standard
175 // EDIT control has one already)
176 void OnRightClick(wxMouseEvent
& event
);
178 // be sure the caret remains invisible if the user
179 // called HideNativeCaret() before
180 void OnSetFocus(wxFocusEvent
& event
);
183 // common part of all ctors
186 // intercept WM_GETDLGCODE
187 virtual WXLRESULT
MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
);
189 // call this to increase the size limit (will do nothing if the current
190 // limit is big enough)
192 // returns true if we increased the limit to allow entering more text,
193 // false if we hit the limit set by SetMaxLength() and so didn't change it
194 bool AdjustSpaceLimit();
196 #if wxUSE_RICHEDIT && (!wxUSE_UNICODE || wxUSE_UNICODE_MSLU)
197 // replace the selection or the entire control contents with the given text
198 // in the specified encoding
199 bool StreamIn(const wxString
& value
, wxFontEncoding encoding
, bool selOnly
);
201 // get the contents of the control out as text in the given encoding
202 wxString
StreamOut(wxFontEncoding encoding
, bool selOnly
= false) const;
203 #endif // wxUSE_RICHEDIT
205 // replace the contents of the selection or of the entire control with the
207 void DoWriteText(const wxString
& text
, bool selectionOnly
= true);
209 // set the selection possibly without scrolling the caret into view
210 void DoSetSelection(long from
, long to
, bool scrollCaret
= true);
212 // return true if there is a non empty selection in the control
213 bool HasSelection() const;
215 // get the length of the line containing the character at the given
217 long GetLengthOfLineContainingPos(long pos
) const;
219 // send TEXT_UPDATED event, return true if it was handled, false otherwise
220 bool SendUpdateEvent();
222 // override some base class virtuals
223 virtual bool MSWShouldPreProcessMessage(WXMSG
* pMsg
);
224 virtual wxSize
DoGetBestSize() const;
226 virtual WXDWORD
MSWGetStyle(long style
, WXDWORD
*exstyle
) const;
229 // we're using RICHEDIT (and not simple EDIT) control if this field is not
230 // 0, it also gives the version of the RICHEDIT control being used (1, 2 or
233 #endif // wxUSE_RICHEDIT
235 // if true, SendUpdateEvent() will eat the next event (see comments in the
236 // code as to why this is needed)
237 bool m_suppressNextUpdate
;
240 DECLARE_EVENT_TABLE()
241 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl
)
243 wxMenu
* m_privateContextMenu
;
245 bool m_isNativeCaretShown
;