]>
Commit | Line | Data |
---|---|---|
6762286d SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/mac/carbon/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") | |
5c6eb3a8 | 24 | #endif |
6762286d SC |
25 | |
26 | #include "wx/control.h" | |
27 | #include "wx/textctrl.h" | |
28 | ||
29 | // forward decl for wxListWidgetImpl implementation type. | |
30 | class WXDLLIMPEXP_FWD_CORE wxTextWidgetImpl; | |
31 | ||
32 | class WXDLLIMPEXP_CORE wxTextCtrl: public wxTextCtrlBase | |
33 | { | |
34 | DECLARE_DYNAMIC_CLASS(wxTextCtrl) | |
35 | ||
36 | public: | |
37 | wxTextCtrl() | |
38 | { Init(); } | |
39 | ||
40 | wxTextCtrl(wxWindow *parent, | |
41 | wxWindowID id, | |
42 | const wxString& value = wxEmptyString, | |
43 | const wxPoint& pos = wxDefaultPosition, | |
44 | const wxSize& size = wxDefaultSize, | |
45 | long style = 0, | |
46 | const wxValidator& validator = wxDefaultValidator, | |
47 | const wxString& name = wxTextCtrlNameStr) | |
48 | { | |
49 | Init(); | |
50 | Create(parent, id, value, pos, size, style, validator, name); | |
51 | } | |
52 | ||
53 | virtual ~wxTextCtrl(); | |
54 | ||
55 | bool Create(wxWindow *parent, | |
56 | wxWindowID id, | |
57 | const wxString& value = wxEmptyString, | |
58 | const wxPoint& pos = wxDefaultPosition, | |
59 | const wxSize& size = wxDefaultSize, | |
60 | long style = 0, | |
61 | const wxValidator& validator = wxDefaultValidator, | |
62 | const wxString& name = wxTextCtrlNameStr); | |
63 | ||
64 | // accessors | |
65 | // --------- | |
6762286d SC |
66 | |
67 | virtual int GetLineLength(long lineNo) const; | |
68 | virtual wxString GetLineText(long lineNo) const; | |
69 | virtual int GetNumberOfLines() const; | |
70 | ||
71 | virtual bool IsModified() const; | |
6762286d SC |
72 | |
73 | // operations | |
74 | // ---------- | |
75 | ||
6762286d SC |
76 | |
77 | // sets/clears the dirty flag | |
78 | virtual void MarkDirty(); | |
79 | virtual void DiscardEdits(); | |
80 | ||
81 | // set the max number of characters which may be entered | |
82 | // in a single line text control | |
83 | virtual void SetMaxLength(unsigned long len); | |
84 | ||
85 | // text control under some platforms supports the text styles: these | |
86 | // methods apply the given text style to the given selection or to | |
87 | // set/get the style which will be used for all appended text | |
88 | virtual bool SetFont( const wxFont &font ); | |
16671f22 | 89 | virtual bool GetStyle(long position, wxTextAttr& style); |
6762286d SC |
90 | virtual bool SetStyle(long start, long end, const wxTextAttr& style); |
91 | virtual bool SetDefaultStyle(const wxTextAttr& style); | |
92 | ||
6762286d SC |
93 | // translate between the position (which is just an index into the textctrl |
94 | // considering all its contents as a single strings) and (x, y) coordinates | |
95 | // which represent column and line. | |
96 | virtual long XYToPosition(long x, long y) const; | |
97 | virtual bool PositionToXY(long pos, long *x, long *y) const; | |
98 | ||
99 | virtual void ShowPosition(long pos); | |
100 | ||
c84030e0 | 101 | // overrides so that we can send text updated events |
6762286d SC |
102 | virtual void Cut(); |
103 | virtual void Paste(); | |
c84030e0 KO |
104 | |
105 | virtual void WriteText(const wxString& text); | |
106 | virtual void Clear(); | |
107 | virtual void Remove(long from, long to); | |
6762286d SC |
108 | |
109 | // Implementation | |
110 | // -------------- | |
111 | virtual void Command(wxCommandEvent& event); | |
112 | ||
113 | virtual bool AcceptsFocus() const; | |
114 | ||
115 | // callbacks | |
116 | void OnDropFiles(wxDropFilesEvent& event); | |
117 | void OnChar(wxKeyEvent& event); // Process 'enter' if required | |
5aa6ea93 | 118 | void OnKeyDown(wxKeyEvent& event); // Process clipboard shortcuts |
6762286d SC |
119 | |
120 | void OnCut(wxCommandEvent& event); | |
121 | void OnCopy(wxCommandEvent& event); | |
122 | void OnPaste(wxCommandEvent& event); | |
123 | void OnUndo(wxCommandEvent& event); | |
124 | void OnRedo(wxCommandEvent& event); | |
125 | void OnDelete(wxCommandEvent& event); | |
126 | void OnSelectAll(wxCommandEvent& event); | |
127 | ||
128 | void OnUpdateCut(wxUpdateUIEvent& event); | |
129 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
130 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
131 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
132 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
133 | void OnUpdateDelete(wxUpdateUIEvent& event); | |
134 | void OnUpdateSelectAll(wxUpdateUIEvent& event); | |
135 | ||
136 | void OnContextMenu(wxContextMenuEvent& event); | |
137 | ||
138 | virtual bool MacSetupCursor( const wxPoint& pt ); | |
139 | ||
140 | virtual void MacVisibilityChanged(); | |
141 | virtual void MacSuperChangedPosition(); | |
142 | virtual void MacCheckSpelling(bool check); | |
143 | ||
c84030e0 | 144 | virtual wxTextWidgetImpl * GetTextPeer() const; |
6762286d SC |
145 | protected: |
146 | // common part of all ctors | |
147 | void Init(); | |
148 | ||
149 | virtual wxSize DoGetBestSize() const; | |
150 | ||
6762286d SC |
151 | // flag is set to true when the user edits the controls contents |
152 | bool m_dirty; | |
153 | ||
d9d551f6 | 154 | virtual void EnableTextChangedEvents(bool enable) |
03647350 | 155 | { |
d9d551f6 | 156 | m_triggerUpdateEvents = enable; |
6762286d | 157 | } |
03647350 | 158 | |
d9d551f6 | 159 | bool m_triggerUpdateEvents ; |
6762286d SC |
160 | |
161 | private : | |
162 | wxMenu *m_privateContextMenu; | |
163 | ||
164 | DECLARE_EVENT_TABLE() | |
165 | }; | |
166 | ||
167 | #endif // _WX_TEXTCTRL_H_ |