1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/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 class WXDLLIMPEXP_CORE wxTextCtrl
: public wxTextCtrlBase
31 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
37 wxTextCtrl(wxWindow
*parent
,
39 const wxString
& value
= wxEmptyString
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
43 const wxValidator
& validator
= wxDefaultValidator
,
44 const wxString
& name
= wxTextCtrlNameStr
)
47 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
50 virtual ~wxTextCtrl() wxNOEXCEPT
;
52 bool Create(wxWindow
*parent
,
54 const wxString
& value
= wxEmptyString
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
58 const wxValidator
& validator
= wxDefaultValidator
,
59 const wxString
& name
= wxTextCtrlNameStr
);
64 virtual int GetLineLength(long lineNo
) const;
65 virtual wxString
GetLineText(long lineNo
) const;
66 virtual int GetNumberOfLines() const;
68 virtual bool IsModified() const;
74 // sets/clears the dirty flag
75 virtual void MarkDirty();
76 virtual void DiscardEdits();
78 // set the grayed out hint text
79 virtual bool SetHint(const wxString
& hint
);
80 virtual wxString
GetHint() const;
82 // text control under some platforms supports the text styles: these
83 // methods apply the given text style to the given selection or to
84 // set/get the style which will be used for all appended text
85 virtual bool SetFont( const wxFont
&font
);
86 virtual bool GetStyle(long position
, wxTextAttr
& style
);
87 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
88 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
90 // translate between the position (which is just an index into the textctrl
91 // considering all its contents as a single strings) and (x, y) coordinates
92 // which represent column and line.
93 virtual long XYToPosition(long x
, long y
) const;
94 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
96 virtual void ShowPosition(long pos
);
98 // overrides so that we can send text updated events
101 virtual void Paste();
105 virtual void Command(wxCommandEvent
& event
);
107 virtual bool AcceptsFocus() const;
110 void OnDropFiles(wxDropFilesEvent
& event
);
111 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
112 void OnKeyDown(wxKeyEvent
& event
); // Process clipboard shortcuts
114 void OnCut(wxCommandEvent
& event
);
115 void OnCopy(wxCommandEvent
& event
);
116 void OnPaste(wxCommandEvent
& event
);
117 void OnUndo(wxCommandEvent
& event
);
118 void OnRedo(wxCommandEvent
& event
);
119 void OnDelete(wxCommandEvent
& event
);
120 void OnSelectAll(wxCommandEvent
& event
);
122 void OnUpdateCut(wxUpdateUIEvent
& event
);
123 void OnUpdateCopy(wxUpdateUIEvent
& event
);
124 void OnUpdatePaste(wxUpdateUIEvent
& event
);
125 void OnUpdateUndo(wxUpdateUIEvent
& event
);
126 void OnUpdateRedo(wxUpdateUIEvent
& event
);
127 void OnUpdateDelete(wxUpdateUIEvent
& event
);
128 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
130 void OnContextMenu(wxContextMenuEvent
& event
);
132 virtual bool MacSetupCursor( const wxPoint
& pt
);
134 virtual void MacVisibilityChanged();
135 virtual void MacSuperChangedPosition();
136 virtual void MacCheckSpelling(bool check
);
139 // common part of all ctors
142 virtual wxSize
DoGetBestSize() const;
144 // flag is set to true when the user edits the controls contents
147 virtual void EnableTextChangedEvents(bool WXUNUSED(enable
))
149 // nothing to do here as the events are never generated when we change
150 // the controls value programmatically anyhow
154 wxMenu
*m_privateContextMenu
;
155 wxString m_hintString
;
157 DECLARE_EVENT_TABLE()
160 #endif // _WX_TEXTCTRL_H_