]> git.saurik.com Git - wxWidgets.git/blob - include/wx/osx/textctrl.h
Don't interpret '&' specially in wxTextWrapper.
[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 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
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")
24 #endif
25
26 #include "wx/control.h"
27 #include "wx/textctrl.h"
28
29 class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase
30 {
31 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
32
33 public:
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)
45 {
46 Init();
47 Create(parent, id, value, pos, size, style, validator, name);
48 }
49
50 virtual ~wxTextCtrl();
51
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);
60
61 // accessors
62 // ---------
63
64 virtual int GetLineLength(long lineNo) const;
65 virtual wxString GetLineText(long lineNo) const;
66 virtual int GetNumberOfLines() const;
67
68 virtual bool IsModified() const;
69
70 // operations
71 // ----------
72
73
74 // sets/clears the dirty flag
75 virtual void MarkDirty();
76 virtual void DiscardEdits();
77
78 // set the max number of characters which may be entered
79 // in a single line text control
80 virtual void SetMaxLength(unsigned long len);
81
82 // set the grayed out hint text
83 virtual bool SetHint(const wxString& hint);
84 virtual wxString GetHint() const;
85
86 // text control under some platforms supports the text styles: these
87 // methods apply the given text style to the given selection or to
88 // set/get the style which will be used for all appended text
89 virtual bool SetFont( const wxFont &font );
90 virtual bool GetStyle(long position, wxTextAttr& style);
91 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
92 virtual bool SetDefaultStyle(const wxTextAttr& style);
93
94 // translate between the position (which is just an index into the textctrl
95 // considering all its contents as a single strings) and (x, y) coordinates
96 // which represent column and line.
97 virtual long XYToPosition(long x, long y) const;
98 virtual bool PositionToXY(long pos, long *x, long *y) const;
99
100 virtual void ShowPosition(long pos);
101
102 // overrides so that we can send text updated events
103 virtual void Copy();
104 virtual void Cut();
105 virtual void Paste();
106
107 // Implementation
108 // --------------
109 virtual void Command(wxCommandEvent& event);
110
111 virtual bool AcceptsFocus() const;
112
113 // callbacks
114 void OnDropFiles(wxDropFilesEvent& event);
115 void OnChar(wxKeyEvent& event); // Process 'enter' if required
116 void OnKeyDown(wxKeyEvent& event); // Process clipboard shortcuts
117
118 void OnCut(wxCommandEvent& event);
119 void OnCopy(wxCommandEvent& event);
120 void OnPaste(wxCommandEvent& event);
121 void OnUndo(wxCommandEvent& event);
122 void OnRedo(wxCommandEvent& event);
123 void OnDelete(wxCommandEvent& event);
124 void OnSelectAll(wxCommandEvent& event);
125
126 void OnUpdateCut(wxUpdateUIEvent& event);
127 void OnUpdateCopy(wxUpdateUIEvent& event);
128 void OnUpdatePaste(wxUpdateUIEvent& event);
129 void OnUpdateUndo(wxUpdateUIEvent& event);
130 void OnUpdateRedo(wxUpdateUIEvent& event);
131 void OnUpdateDelete(wxUpdateUIEvent& event);
132 void OnUpdateSelectAll(wxUpdateUIEvent& event);
133
134 void OnContextMenu(wxContextMenuEvent& event);
135
136 virtual bool MacSetupCursor( const wxPoint& pt );
137
138 virtual void MacVisibilityChanged();
139 virtual void MacSuperChangedPosition();
140 virtual void MacCheckSpelling(bool check);
141
142 protected:
143 // common part of all ctors
144 void Init();
145
146 virtual wxSize DoGetBestSize() const;
147
148 // flag is set to true when the user edits the controls contents
149 bool m_dirty;
150
151 virtual void EnableTextChangedEvents(bool WXUNUSED(enable))
152 {
153 // nothing to do here as the events are never generated when we change
154 // the controls value programmatically anyhow
155 }
156
157 private :
158 wxMenu *m_privateContextMenu;
159 wxString m_hintString;
160
161 DECLARE_EVENT_TABLE()
162 };
163
164 #endif // _WX_TEXTCTRL_H_