]> git.saurik.com Git - wxWidgets.git/blame - include/wx/osx/textctrl.h
moving down for non-precomp build
[wxWidgets.git] / include / wx / osx / textctrl.h
CommitLineData
6762286d
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/mac/carbon/textctrl.h
3// Purpose: wxTextCtrl class
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_TEXTCTRL_H_
13#define _WX_TEXTCTRL_H_
14
15#if wxUSE_SYSTEM_OPTIONS
16 // set this to 'true' if you want to use the 'classic' MLTE-based implementation
17 // instead of the HIView-based implementation in 10.3 and upwards, the former
18 // has more features (backgrounds etc.), but may show redraw artefacts and other
19 // problems depending on your usage; hence, the default is 'false'.
20 #define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte")
21 // set this to 'true' if you want editable text controls to have spell checking turned
22 // on by default, you can change this setting individually on a control using MacCheckSpelling
23 #define wxMAC_TEXTCONTROL_USE_SPELL_CHECKER wxT("mac.textcontrol-use-spell-checker")
5c6eb3a8 24#endif
6762286d
SC
25
26#include "wx/control.h"
27#include "wx/textctrl.h"
28
29// forward decl for wxListWidgetImpl implementation type.
30class WXDLLIMPEXP_FWD_CORE wxTextWidgetImpl;
31
32class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
33{
34 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
35
36public:
37 wxTextCtrl()
38 { Init(); }
39
40 wxTextCtrl(wxWindow *parent,
41 wxWindowID id,
42 const wxString& value = wxEmptyString,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = 0,
46 const wxValidator& validator = wxDefaultValidator,
47 const wxString& name = wxTextCtrlNameStr)
48 {
49 Init();
50 Create(parent, id, value, pos, size, style, validator, name);
51 }
52
53 virtual ~wxTextCtrl();
54
55 bool Create(wxWindow *parent,
56 wxWindowID id,
57 const wxString& value = wxEmptyString,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 long style = 0,
61 const wxValidator& validator = wxDefaultValidator,
62 const wxString& name = wxTextCtrlNameStr);
63
64 // accessors
65 // ---------
6762286d
SC
66
67 virtual int GetLineLength(long lineNo) const;
68 virtual wxString GetLineText(long lineNo) const;
69 virtual int GetNumberOfLines() const;
70
71 virtual bool IsModified() const;
72 virtual bool IsEditable() const;
73
74 // If the return values from and to are the same, there is no selection.
75 virtual void GetSelection(long* from, long* to) const;
76
77 // operations
78 // ----------
79
80 // editing
81 virtual void Clear();
82 virtual void Replace(long from, long to, const wxString& value);
83 virtual void Remove(long from, long to);
84
85 // sets/clears the dirty flag
86 virtual void MarkDirty();
87 virtual void DiscardEdits();
88
89 // set the max number of characters which may be entered
90 // in a single line text control
91 virtual void SetMaxLength(unsigned long len);
92
93 // text control under some platforms supports the text styles: these
94 // methods apply the given text style to the given selection or to
95 // set/get the style which will be used for all appended text
96 virtual bool SetFont( const wxFont &font );
97 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
98 virtual bool SetDefaultStyle(const wxTextAttr& style);
99
100 // writing text inserts it at the current position;
101 // appending always inserts it at the end
102 virtual void WriteText(const wxString& text);
103 virtual void AppendText(const wxString& text);
104
105 // translate between the position (which is just an index into the textctrl
106 // considering all its contents as a single strings) and (x, y) coordinates
107 // which represent column and line.
108 virtual long XYToPosition(long x, long y) const;
109 virtual bool PositionToXY(long pos, long *x, long *y) const;
110
111 virtual void ShowPosition(long pos);
112
113 // Clipboard operations
114 virtual void Copy();
115 virtual void Cut();
116 virtual void Paste();
117
118 virtual bool CanCopy() const;
119 virtual bool CanCut() const;
120 virtual bool CanPaste() const;
121
122 // Undo/redo
123 virtual void Undo();
124 virtual void Redo();
125
126 virtual bool CanUndo() const;
127 virtual bool CanRedo() const;
128
129 // Insertion point
130 virtual void SetInsertionPoint(long pos);
131 virtual void SetInsertionPointEnd();
132 virtual long GetInsertionPoint() const;
133 virtual wxTextPos GetLastPosition() const;
134
135 virtual void SetSelection(long from, long to);
136 virtual void SetEditable(bool editable);
137
138 // Implementation
139 // --------------
140 virtual void Command(wxCommandEvent& event);
141
142 virtual bool AcceptsFocus() const;
143
144 // callbacks
145 void OnDropFiles(wxDropFilesEvent& event);
146 void OnChar(wxKeyEvent& event); // Process 'enter' if required
147
148 void OnCut(wxCommandEvent& event);
149 void OnCopy(wxCommandEvent& event);
150 void OnPaste(wxCommandEvent& event);
151 void OnUndo(wxCommandEvent& event);
152 void OnRedo(wxCommandEvent& event);
153 void OnDelete(wxCommandEvent& event);
154 void OnSelectAll(wxCommandEvent& event);
155
156 void OnUpdateCut(wxUpdateUIEvent& event);
157 void OnUpdateCopy(wxUpdateUIEvent& event);
158 void OnUpdatePaste(wxUpdateUIEvent& event);
159 void OnUpdateUndo(wxUpdateUIEvent& event);
160 void OnUpdateRedo(wxUpdateUIEvent& event);
161 void OnUpdateDelete(wxUpdateUIEvent& event);
162 void OnUpdateSelectAll(wxUpdateUIEvent& event);
163
164 void OnContextMenu(wxContextMenuEvent& event);
165
166 virtual bool MacSetupCursor( const wxPoint& pt );
167
168 virtual void MacVisibilityChanged();
169 virtual void MacSuperChangedPosition();
170 virtual void MacCheckSpelling(bool check);
171
172 wxTextWidgetImpl * GetTextPeer() const;
173protected:
174 // common part of all ctors
175 void Init();
176
177 virtual wxSize DoGetBestSize() const;
178
179 virtual void DoSetValue(const wxString& value, int flags = 0);
33b3ade5 180 virtual wxString DoGetValue() const;
6762286d
SC
181
182 bool m_editable;
183
184 // flag is set to true when the user edits the controls contents
185 bool m_dirty;
186
187 // need to make this public because of the current implementation via callbacks
188 unsigned long m_maxLength;
189
190 bool GetTriggerOnSetValue() const
191 {
192 return m_triggerOnSetValue;
193 }
194
195 void SetTriggerOnSetValue(bool trigger)
196 {
197 m_triggerOnSetValue = trigger;
198 }
199
200 bool m_triggerOnSetValue ;
201
202private :
203 wxMenu *m_privateContextMenu;
204
205 DECLARE_EVENT_TABLE()
206};
207
208#endif // _WX_TEXTCTRL_H_