Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / include / wx / osx / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/osx/textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_TEXTCTRL_H_
12 #define _WX_TEXTCTRL_H_
13
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")
23 #endif
24
25 #include "wx/control.h"
26 #include "wx/textctrl.h"
27
28 class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
29 {
30 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
31
32 public:
33 wxTextCtrl()
34 { Init(); }
35
36 wxTextCtrl(wxWindow *parent,
37 wxWindowID id,
38 const wxString& value = wxEmptyString,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = 0,
42 const wxValidator& validator = wxDefaultValidator,
43 const wxString& name = wxTextCtrlNameStr)
44 {
45 Init();
46 Create(parent, id, value, pos, size, style, validator, name);
47 }
48
49 virtual ~wxTextCtrl();
50
51 bool Create(wxWindow *parent,
52 wxWindowID id,
53 const wxString& value = wxEmptyString,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = 0,
57 const wxValidator& validator = wxDefaultValidator,
58 const wxString& name = wxTextCtrlNameStr);
59
60 // accessors
61 // ---------
62
63 virtual int GetLineLength(long lineNo) const;
64 virtual wxString GetLineText(long lineNo) const;
65 virtual int GetNumberOfLines() const;
66
67 virtual bool IsModified() const;
68
69 // operations
70 // ----------
71
72
73 // sets/clears the dirty flag
74 virtual void MarkDirty();
75 virtual void DiscardEdits();
76
77 // set the grayed out hint text
78 virtual bool SetHint(const wxString& hint);
79 virtual wxString GetHint() const;
80
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);
88
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;
94
95 virtual void ShowPosition(long pos);
96
97 // overrides so that we can send text updated events
98 virtual void Copy();
99 virtual void Cut();
100 virtual void Paste();
101
102 // Implementation
103 // --------------
104 virtual void Command(wxCommandEvent& event);
105
106 virtual bool AcceptsFocus() const;
107
108 // callbacks
109 void OnDropFiles(wxDropFilesEvent& event);
110 void OnChar(wxKeyEvent& event); // Process 'enter' if required
111 void OnKeyDown(wxKeyEvent& event); // Process clipboard shortcuts
112
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);
120
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);
128
129 void OnContextMenu(wxContextMenuEvent& event);
130
131 virtual bool MacSetupCursor( const wxPoint& pt );
132
133 virtual void MacVisibilityChanged();
134 virtual void MacSuperChangedPosition();
135 virtual void MacCheckSpelling(bool check);
136
137 protected:
138 // common part of all ctors
139 void Init();
140
141 virtual wxSize DoGetBestSize() const;
142
143 // flag is set to true when the user edits the controls contents
144 bool m_dirty;
145
146 virtual void EnableTextChangedEvents(bool WXUNUSED(enable))
147 {
148 // nothing to do here as the events are never generated when we change
149 // the controls value programmatically anyhow
150 }
151
152 private :
153 wxMenu *m_privateContextMenu;
154 wxString m_hintString;
155
156 DECLARE_EVENT_TABLE()
157 };
158
159 #endif // _WX_TEXTCTRL_H_