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