1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: Stefan Csomor
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_TEXTCTRL_H_
12 #define _WX_TEXTCTRL_H_
14 #if wxUSE_SYSTEM_OPTIONS
15 // set this to 'true' if you want to use the 'classic' MLTE-based implementation
16 // instead of the HIView-based implementation in 10.3 and upwards, the former
17 // has more features (backgrounds etc.), but may show redraw artefacts and other
18 // problems depending on your usage; hence, the default is 'false'.
19 #define wxMAC_TEXTCONTROL_USE_MLTE wxT("mac.textcontrol-use-mlte")
20 // set this to 'true' if you want editable text controls to have spell checking turned
21 // on by default, you can change this setting individually on a control using MacCheckSpelling
22 #define wxMAC_TEXTCONTROL_USE_SPELL_CHECKER wxT("mac.textcontrol-use-spell-checker")
25 #include "wx/control.h"
26 #include "wx/textctrl.h"
28 class WXDLLIMPEXP_CORE wxTextCtrl
: public wxTextCtrlBase
30 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
36 wxTextCtrl(wxWindow
*parent
,
38 const wxString
& value
= wxEmptyString
,
39 const wxPoint
& pos
= wxDefaultPosition
,
40 const wxSize
& size
= wxDefaultSize
,
42 const wxValidator
& validator
= wxDefaultValidator
,
43 const wxString
& name
= wxTextCtrlNameStr
)
46 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
49 virtual ~wxTextCtrl();
51 bool Create(wxWindow
*parent
,
53 const wxString
& value
= wxEmptyString
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
57 const wxValidator
& validator
= wxDefaultValidator
,
58 const wxString
& name
= wxTextCtrlNameStr
);
63 virtual int GetLineLength(long lineNo
) const;
64 virtual wxString
GetLineText(long lineNo
) const;
65 virtual int GetNumberOfLines() const;
67 virtual bool IsModified() const;
73 // sets/clears the dirty flag
74 virtual void MarkDirty();
75 virtual void DiscardEdits();
77 // set the grayed out hint text
78 virtual bool SetHint(const wxString
& hint
);
79 virtual wxString
GetHint() const;
81 // text control under some platforms supports the text styles: these
82 // methods apply the given text style to the given selection or to
83 // set/get the style which will be used for all appended text
84 virtual bool SetFont( const wxFont
&font
);
85 virtual bool GetStyle(long position
, wxTextAttr
& style
);
86 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
87 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
89 // translate between the position (which is just an index into the textctrl
90 // considering all its contents as a single strings) and (x, y) coordinates
91 // which represent column and line.
92 virtual long XYToPosition(long x
, long y
) const;
93 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
95 virtual void ShowPosition(long pos
);
97 // overrides so that we can send text updated events
100 virtual void Paste();
104 virtual void Command(wxCommandEvent
& event
);
106 virtual bool AcceptsFocus() const;
109 void OnDropFiles(wxDropFilesEvent
& event
);
110 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
111 void OnKeyDown(wxKeyEvent
& event
); // Process clipboard shortcuts
113 void OnCut(wxCommandEvent
& event
);
114 void OnCopy(wxCommandEvent
& event
);
115 void OnPaste(wxCommandEvent
& event
);
116 void OnUndo(wxCommandEvent
& event
);
117 void OnRedo(wxCommandEvent
& event
);
118 void OnDelete(wxCommandEvent
& event
);
119 void OnSelectAll(wxCommandEvent
& event
);
121 void OnUpdateCut(wxUpdateUIEvent
& event
);
122 void OnUpdateCopy(wxUpdateUIEvent
& event
);
123 void OnUpdatePaste(wxUpdateUIEvent
& event
);
124 void OnUpdateUndo(wxUpdateUIEvent
& event
);
125 void OnUpdateRedo(wxUpdateUIEvent
& event
);
126 void OnUpdateDelete(wxUpdateUIEvent
& event
);
127 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
129 void OnContextMenu(wxContextMenuEvent
& event
);
131 virtual bool MacSetupCursor( const wxPoint
& pt
);
133 virtual void MacVisibilityChanged();
134 virtual void MacSuperChangedPosition();
135 virtual void MacCheckSpelling(bool check
);
138 // common part of all ctors
141 virtual wxSize
DoGetBestSize() const;
143 // flag is set to true when the user edits the controls contents
146 virtual void EnableTextChangedEvents(bool WXUNUSED(enable
))
148 // nothing to do here as the events are never generated when we change
149 // the controls value programmatically anyhow
153 wxMenu
*m_privateContextMenu
;
154 wxString m_hintString
;
156 DECLARE_EVENT_TABLE()
159 #endif // _WX_TEXTCTRL_H_