]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/textctrl.h
made wxTLW::SetIcon() non-virtual, it was already implemented in terms of
[wxWidgets.git] / include / wx / mac / carbon / textctrl.h
CommitLineData
8cf73271 1/////////////////////////////////////////////////////////////////////////////
717a7072 2// Name: wx/mac/carbon/textctrl.h
8cf73271
SC
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
65571936 9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_TEXTCTRL_H_
13#define _WX_TEXTCTRL_H_
14
823c4e96 15#if wxUSE_SYSTEM_OPTIONS
717a7072
DS
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'.
a02d6c7b 20 #define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte")
823c4e96
SC
21#endif
22
8cf73271 23#include "wx/control.h"
717a7072 24#include "wx/textctrl.h"
8cf73271 25
717a7072 26class wxMacTextControl;
8cf73271 27
5ca0d812 28
8cf73271
SC
29class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
30{
31 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
7d8268a1 32
8cf73271 33public:
717a7072
DS
34 wxTextCtrl()
35 { Init(); }
36
37 wxTextCtrl(wxWindow *parent,
38 wxWindowID id,
39 const wxString& value = wxEmptyString,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 long style = 0,
43 const wxValidator& validator = wxDefaultValidator,
44 const wxString& name = wxTextCtrlNameStr)
a02d6c7b
DS
45 {
46 Init();
47 Create(parent, id, value, pos, size, style, validator, name);
48 }
8cf73271 49
d3c7fc99 50 virtual ~wxTextCtrl();
7d8268a1 51
717a7072
DS
52 bool Create(wxWindow *parent,
53 wxWindowID id,
54 const wxString& value = wxEmptyString,
55 const wxPoint& pos = wxDefaultPosition,
56 const wxSize& size = wxDefaultSize,
57 long style = 0,
58 const wxValidator& validator = wxDefaultValidator,
59 const wxString& name = wxTextCtrlNameStr);
7d8268a1 60
a02d6c7b
DS
61 // accessors
62 // ---------
717a7072 63 virtual wxString GetValue() const;
f6519b40 64
a02d6c7b
DS
65 virtual int GetLineLength(long lineNo) const;
66 virtual wxString GetLineText(long lineNo) const;
67 virtual int GetNumberOfLines() const;
8cf73271 68
a02d6c7b
DS
69 virtual bool IsModified() const;
70 virtual bool IsEditable() const;
8cf73271 71
a02d6c7b
DS
72 // If the return values from and to are the same, there is no selection.
73 virtual void GetSelection(long* from, long* to) const;
8cf73271 74
a02d6c7b
DS
75 // operations
76 // ----------
8cf73271 77
a02d6c7b 78 // editing
a02d6c7b
DS
79 virtual void Clear();
80 virtual void Replace(long from, long to, const wxString& value);
81 virtual void Remove(long from, long to);
8cf73271 82
a02d6c7b
DS
83 // sets/clears the dirty flag
84 virtual void MarkDirty();
85 virtual void DiscardEdits();
8cf73271 86
a02d6c7b
DS
87 // set the max number of characters which may be entered
88 // in a single line text control
717a7072 89 virtual void SetMaxLength(unsigned long len);
8cf73271 90
a02d6c7b 91 // text control under some platforms supports the text styles: these
717a7072 92 // methods apply the given text style to the given selection or to
a02d6c7b 93 // set/get the style which will be used for all appended text
717a7072 94 virtual bool SetFont( const wxFont &font );
a02d6c7b
DS
95 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
96 virtual bool SetDefaultStyle(const wxTextAttr& style);
8cf73271 97
a02d6c7b
DS
98 // writing text inserts it at the current position;
99 // appending always inserts it at the end
100 virtual void WriteText(const wxString& text);
101 virtual void AppendText(const wxString& text);
8cf73271 102
717a7072 103 // translate between the position (which is just an index into the textctrl
a02d6c7b
DS
104 // considering all its contents as a single strings) and (x, y) coordinates
105 // which represent column and line.
106 virtual long XYToPosition(long x, long y) const;
107 virtual bool PositionToXY(long pos, long *x, long *y) const;
8cf73271 108
a02d6c7b 109 virtual void ShowPosition(long pos);
8cf73271 110
a02d6c7b
DS
111 // Clipboard operations
112 virtual void Copy();
113 virtual void Cut();
114 virtual void Paste();
7d8268a1 115
a02d6c7b
DS
116 virtual bool CanCopy() const;
117 virtual bool CanCut() const;
118 virtual bool CanPaste() const;
8cf73271 119
a02d6c7b
DS
120 // Undo/redo
121 virtual void Undo();
122 virtual void Redo();
8cf73271 123
a02d6c7b
DS
124 virtual bool CanUndo() const;
125 virtual bool CanRedo() const;
8cf73271 126
a02d6c7b
DS
127 // Insertion point
128 virtual void SetInsertionPoint(long pos);
129 virtual void SetInsertionPointEnd();
130 virtual long GetInsertionPoint() const;
131 virtual wxTextPos GetLastPosition() const;
8cf73271 132
a02d6c7b
DS
133 virtual void SetSelection(long from, long to);
134 virtual void SetEditable(bool editable);
8cf73271
SC
135
136 // Implementation
137 // --------------
138 virtual void Command(wxCommandEvent& event);
139
140 virtual bool AcceptsFocus() const;
141
142 // callbacks
143 void OnDropFiles(wxDropFilesEvent& event);
144 void OnChar(wxKeyEvent& event); // Process 'enter' if required
145
146 void OnCut(wxCommandEvent& event);
147 void OnCopy(wxCommandEvent& event);
148 void OnPaste(wxCommandEvent& event);
149 void OnUndo(wxCommandEvent& event);
150 void OnRedo(wxCommandEvent& event);
03e4ffc3
SC
151 void OnDelete(wxCommandEvent& event);
152 void OnSelectAll(wxCommandEvent& event);
717a7072 153
8cf73271
SC
154 void OnUpdateCut(wxUpdateUIEvent& event);
155 void OnUpdateCopy(wxUpdateUIEvent& event);
156 void OnUpdatePaste(wxUpdateUIEvent& event);
157 void OnUpdateUndo(wxUpdateUIEvent& event);
158 void OnUpdateRedo(wxUpdateUIEvent& event);
03e4ffc3
SC
159 void OnUpdateDelete(wxUpdateUIEvent& event);
160 void OnUpdateSelectAll(wxUpdateUIEvent& event);
7d8268a1 161
717a7072 162 void OnEraseBackground(wxEraseEvent& event);
03e4ffc3 163 void OnContextMenu(wxContextMenuEvent& event);
8cf73271 164
717a7072
DS
165 virtual bool MacCanFocus() const
166 { return true; }
a02d6c7b 167
717a7072 168 virtual bool MacSetupCursor( const wxPoint& pt );
8cf73271 169
717a7072
DS
170 virtual void MacVisibilityChanged();
171 virtual void MacEnabledStateChanged();
172 virtual void MacSuperChangedPosition();
6df87058 173 virtual void MacCheckSpelling(bool check);
a02d6c7b 174
20b69855 175#ifndef __WXMAC_OSX__
717a7072
DS
176 virtual void MacControlUserPaneDrawProc(wxInt16 part);
177 virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y);
178 virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc);
179 virtual void MacControlUserPaneIdleProc();
180 virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers);
181 virtual void MacControlUserPaneActivateProc(bool activating);
182 virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action);
183 virtual void MacControlUserPaneBackgroundProc(void* info);
20b69855 184#endif
8cf73271 185
717a7072
DS
186 wxMacTextControl * GetPeer() const
187 { return (wxMacTextControl*) m_peer; }
ee2ec18e 188
8cf73271
SC
189protected:
190 // common part of all ctors
191 void Init();
192
a02d6c7b 193 virtual wxSize DoGetBestSize() const;
8cf73271 194
3f7f284d
RD
195 virtual void CreatePeer(const wxString& str, const wxPoint& pos, const wxSize& size, long style );
196
ee2ec18e
VZ
197 virtual void DoSetValue(const wxString& value, int flags = 0);
198
717a7072 199 bool m_editable;
8cf73271 200
a02d6c7b
DS
201 // flag is set to true when the user edits the controls contents
202 bool m_dirty;
8cf73271 203
4f305456 204 // need to make this public because of the current implementation via callbacks
717a7072 205 unsigned long m_maxLength;
ee2ec18e
VZ
206
207 bool GetTriggerOnSetValue() const
208 {
209 return m_triggerOnSetValue;
51478cd6 210 }
ee2ec18e
VZ
211
212 void SetTriggerOnSetValue(bool trigger)
213 {
214 m_triggerOnSetValue = trigger;
51478cd6 215 }
ee2ec18e 216
51478cd6 217 bool m_triggerOnSetValue ;
a02d6c7b 218
4f305456 219private :
03e4ffc3
SC
220 wxMenu *m_privateContextMenu;
221
8cf73271
SC
222 DECLARE_EVENT_TABLE()
223};
224
717a7072 225#endif // _WX_TEXTCTRL_H_