]> git.saurik.com Git - wxWidgets.git/blob - include/wx/palmos/textctrl.h
remove extra ';'
[wxWidgets.git] / include / wx / palmos / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by:
6 // Created: 10/13/04
7 // RCS-ID: $Id$
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
15 class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
16 {
17 public:
18 // creation
19 // --------
20
21 wxTextCtrl() { Init(); }
22 wxTextCtrl(wxWindow *parent, wxWindowID id,
23 const wxString& value = wxEmptyString,
24 const wxPoint& pos = wxDefaultPosition,
25 const wxSize& size = wxDefaultSize,
26 long style = 0,
27 const wxValidator& validator = wxDefaultValidator,
28 const wxString& name = wxTextCtrlNameStr)
29 {
30 Init();
31
32 Create(parent, id, value, pos, size, style, validator, name);
33 }
34 virtual ~wxTextCtrl();
35
36 bool Create(wxWindow *parent, wxWindowID id,
37 const wxString& value = wxEmptyString,
38 const wxPoint& pos = wxDefaultPosition,
39 const wxSize& size = wxDefaultSize,
40 long style = 0,
41 const wxValidator& validator = wxDefaultValidator,
42 const wxString& name = wxTextCtrlNameStr);
43
44 // implement base class pure virtuals
45 // ----------------------------------
46
47 virtual wxString GetValue() const;
48
49 virtual int GetLineLength(long lineNo) const;
50 virtual wxString GetLineText(long lineNo) const;
51 virtual int GetNumberOfLines() const;
52
53 virtual bool IsModified() const;
54 virtual bool IsEditable() const;
55
56 virtual void GetSelection(long* from, long* to) const;
57
58 // operations
59 // ----------
60
61 // editing
62 virtual void Clear();
63 virtual void Replace(long from, long to, const wxString& value);
64 virtual void Remove(long from, long to);
65
66 // load the control's contents from the file
67 virtual bool DoLoadFile(const wxString& file, int fileType);
68
69 // clears the dirty flag
70 virtual void MarkDirty();
71 virtual void DiscardEdits();
72
73 virtual void SetMaxLength(unsigned long len);
74
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);
79
80 #if wxUSE_RICHEDIT
81 // apply text attribute to the range of text (only works with richedit
82 // controls)
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
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,
96 wxTextCoord *col,
97 wxTextCoord *row) const;
98
99 // Clipboard operations
100 virtual void Copy();
101 virtual void Cut();
102 virtual void Paste();
103
104 virtual bool CanCopy() const;
105 virtual bool CanCut() const;
106 virtual bool CanPaste() const;
107
108 // Undo/redo
109 virtual void Undo();
110 virtual void Redo();
111
112 virtual bool CanUndo() const;
113 virtual bool CanRedo() const;
114
115 // Insertion point
116 virtual void SetInsertionPoint(long pos);
117 virtual void SetInsertionPointEnd();
118 virtual long GetInsertionPoint() const;
119 virtual wxTextPos GetLastPosition() const;
120
121 virtual void SetSelection(long from, long to);
122 virtual void SetEditable(bool editable);
123
124 // Caret handling (Windows only)
125
126 bool ShowNativeCaret(bool show = true);
127 bool HideNativeCaret() { return ShowNativeCaret(false); }
128
129 // Implementation from now on
130 // --------------------------
131
132 virtual void Command(wxCommandEvent& event);
133 virtual bool MSWCommand(WXUINT param, WXWORD id);
134
135 #if wxUSE_RICHEDIT
136 virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
137
138 int GetRichVersion() const { return m_verRichEdit; }
139 bool IsRich() const { return m_verRichEdit != 0; }
140
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
146
147 virtual bool AcceptsFocus() const;
148
149 // callbacks
150 void OnDropFiles(wxDropFilesEvent& event);
151 void OnChar(wxKeyEvent& event); // Process 'enter' if required
152
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);
160
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);
168
169 // Show a context menu for Rich Edit controls (the standard
170 // EDIT control has one already)
171 void OnRightClick(wxMouseEvent& event);
172
173 // be sure the caret remains invisible if the user
174 // called HideNativeCaret() before
175 void OnSetFocus(wxFocusEvent& event);
176
177 protected:
178 // common part of all ctors
179 void Init();
180
181 virtual void DoSetValue(const wxString& value, int flags = 0);
182
183
184 // intercept WM_GETDLGCODE
185 virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
186
187 // call this to increase the size limit (will do nothing if the current
188 // limit is big enough)
189 //
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();
193
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);
198
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
202
203 // replace the contents of the selection or of the entire control with the
204 // given text
205 void DoWriteText(const wxString& text, bool selectionOnly = true);
206
207 // set the selection possibly without scrolling the caret into view
208 void DoSetSelection(long from, long to, bool scrollCaret = true);
209
210 // return true if there is a non empty selection in the control
211 bool HasSelection() const;
212
213 // get the length of the line containing the character at the given
214 // position
215 long GetLengthOfLineContainingPos(long pos) const;
216
217 // send TEXT_UPDATED event, return true if it was handled, false otherwise
218 bool SendUpdateEvent();
219
220 // override some base class virtuals
221 virtual bool MSWShouldPreProcessMessage(WXMSG* pMsg);
222 virtual wxSize DoGetBestSize() const;
223
224 virtual WXDWORD MSWGetStyle(long style, WXDWORD *exstyle) const;
225
226 #if wxUSE_RICHEDIT
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
229 // 3 so far)
230 int m_verRichEdit;
231 #endif // wxUSE_RICHEDIT
232
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;
236
237 private:
238 DECLARE_EVENT_TABLE()
239 DECLARE_DYNAMIC_CLASS_NO_COPY(wxTextCtrl)
240
241 wxMenu* m_privateContextMenu;
242
243 bool m_isNativeCaretShown;
244 };
245
246 #endif
247 // _WX_TEXTCTRL_H_