1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
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")
26 #include "wx/control.h"
27 #include "wx/textctrl.h"
29 // forward decl for wxListWidgetImpl implementation type.
30 class WXDLLIMPEXP_FWD_CORE wxTextWidgetImpl
;
32 class WXDLLIMPEXP_CORE wxTextCtrl
: public wxTextCtrlBase
34 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
40 wxTextCtrl(wxWindow
*parent
,
42 const wxString
& value
= wxEmptyString
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
,
46 const wxValidator
& validator
= wxDefaultValidator
,
47 const wxString
& name
= wxTextCtrlNameStr
)
50 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
53 virtual ~wxTextCtrl();
55 bool Create(wxWindow
*parent
,
57 const wxString
& value
= wxEmptyString
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
61 const wxValidator
& validator
= wxDefaultValidator
,
62 const wxString
& name
= wxTextCtrlNameStr
);
67 virtual int GetLineLength(long lineNo
) const;
68 virtual wxString
GetLineText(long lineNo
) const;
69 virtual int GetNumberOfLines() const;
71 virtual bool IsModified() const;
72 virtual bool IsEditable() const;
74 // If the return values from and to are the same, there is no selection.
75 virtual void GetSelection(long* from
, long* to
) const;
82 virtual void Remove(long from
, long to
);
84 // sets/clears the dirty flag
85 virtual void MarkDirty();
86 virtual void DiscardEdits();
88 // set the max number of characters which may be entered
89 // in a single line text control
90 virtual void SetMaxLength(unsigned long len
);
92 // text control under some platforms supports the text styles: these
93 // methods apply the given text style to the given selection or to
94 // set/get the style which will be used for all appended text
95 virtual bool SetFont( const wxFont
&font
);
96 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
97 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
99 // writing text inserts it at the current position;
100 // appending always inserts it at the end
101 virtual void WriteText(const wxString
& text
);
103 // translate between the position (which is just an index into the textctrl
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;
109 virtual void ShowPosition(long pos
);
111 // Clipboard operations
114 virtual void Paste();
116 virtual bool CanCopy() const;
117 virtual bool CanCut() const;
118 virtual bool CanPaste() const;
124 virtual bool CanUndo() const;
125 virtual bool CanRedo() const;
128 virtual void SetInsertionPoint(long pos
);
129 virtual void SetInsertionPointEnd();
130 virtual long GetInsertionPoint() const;
131 virtual wxTextPos
GetLastPosition() const;
133 virtual void SetSelection(long from
, long to
);
134 virtual void SetEditable(bool editable
);
138 virtual void Command(wxCommandEvent
& event
);
140 virtual bool AcceptsFocus() const;
143 void OnDropFiles(wxDropFilesEvent
& event
);
144 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
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
);
151 void OnDelete(wxCommandEvent
& event
);
152 void OnSelectAll(wxCommandEvent
& event
);
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
);
159 void OnUpdateDelete(wxUpdateUIEvent
& event
);
160 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
162 void OnContextMenu(wxContextMenuEvent
& event
);
164 virtual bool MacSetupCursor( const wxPoint
& pt
);
166 virtual void MacVisibilityChanged();
167 virtual void MacSuperChangedPosition();
168 virtual void MacCheckSpelling(bool check
);
170 wxTextWidgetImpl
* GetTextPeer() const;
172 // common part of all ctors
175 virtual wxSize
DoGetBestSize() const;
177 virtual wxString
DoGetValue() const;
181 // flag is set to true when the user edits the controls contents
184 // need to make this public because of the current implementation via callbacks
185 unsigned long m_maxLength
;
187 virtual void EnableTextChangedEvents(bool enable
)
189 m_triggerUpdateEvents
= enable
;
192 bool m_triggerUpdateEvents
;
195 wxMenu
*m_privateContextMenu
;
197 DECLARE_EVENT_TABLE()
200 #endif // _WX_TEXTCTRL_H_