]> git.saurik.com Git - wxWidgets.git/blame - include/wx/mac/carbon/textctrl.h
more extra semicolons removed (patch 1303724)
[wxWidgets.git] / include / wx / mac / carbon / textctrl.h
CommitLineData
8cf73271
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: 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
65571936 9// Licence: wxWindows licence
8cf73271
SC
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_TEXTCTRL_H_
13#define _WX_TEXTCTRL_H_
14
823c4e96
SC
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, default is 'false'
20 #define wxMAC_TEXTCONTROL_USE_MLTE _T("mac.textcontrol-use-mlte")
21#endif
22
8cf73271
SC
23#include "wx/control.h"
24
25WXDLLEXPORT_DATA(extern const wxChar*) wxTextCtrlNameStr;
26
5ca0d812
SC
27class wxMacTextControl ;
28
8cf73271
SC
29// Single-line text item
30class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
31{
32 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
7d8268a1 33
8cf73271
SC
34public:
35 // creation
36 // --------
37 wxTextCtrl() { Init(); }
38 ~wxTextCtrl();
39 wxTextCtrl(wxWindow *parent, wxWindowID id,
40 const wxString& value = wxEmptyString,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize, long style = 0,
43 const wxValidator& validator = wxDefaultValidator,
44 const wxString& name = wxTextCtrlNameStr)
45 {
46 Init();
47
48 Create(parent, id, value, pos, size, style, validator, name);
49 }
7d8268a1 50
8cf73271
SC
51 bool Create(wxWindow *parent, wxWindowID id,
52 const wxString& value = wxEmptyString,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize, long style = 0,
55 const wxValidator& validator = wxDefaultValidator,
56 const wxString& name = wxTextCtrlNameStr);
7d8268a1 57
8cf73271
SC
58 // accessors
59 // ---------
60 virtual wxString GetValue() const ;
61 virtual void SetValue(const wxString& value);
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 virtual bool IsEditable() const;
69
70 // If the return values from and to are the same, there is no selection.
71 virtual void GetSelection(long* from, long* to) const;
72
73 // operations
74 // ----------
75
76 // editing
77
78 virtual void Clear();
79 virtual void Replace(long from, long to, const wxString& value);
80 virtual void Remove(long from, long to);
81
82 // load the controls contents from the file
83 virtual bool LoadFile(const wxString& file);
84
85 // sets/clears the dirty flag
86 virtual void MarkDirty();
87 virtual void DiscardEdits();
88
89 // set the max number of characters which may be entered in a single line
90 // text control
91 virtual void SetMaxLength(unsigned long len) ;
92
93 // text control under some platforms supports the text styles: these
94 // methods allow to apply the given text style to the given selection or to
95 // set/get the style which will be used for all appended text
4f305456 96 virtual bool SetFont( const wxFont &font ) ;
8cf73271
SC
97 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
98 virtual bool SetDefaultStyle(const wxTextAttr& style);
99
100 // writing text inserts it at the current position, appending always
101 // inserts it at the end
102 virtual void WriteText(const wxString& text);
103 virtual void AppendText(const wxString& text);
104
105 // translate between the position (which is just an index in the text ctrl
106 // considering all its contents as a single strings) and (x, y) coordinates
107 // which represent column and line.
108 virtual long XYToPosition(long x, long y) const;
109 virtual bool PositionToXY(long pos, long *x, long *y) const;
110
111 virtual void ShowPosition(long pos);
112
113 // Clipboard operations
114 virtual void Copy();
115 virtual void Cut();
116 virtual void Paste();
7d8268a1 117
8cf73271
SC
118 virtual bool CanCopy() const;
119 virtual bool CanCut() const;
120 virtual bool CanPaste() const;
121
122 // Undo/redo
123 virtual void Undo();
124 virtual void Redo();
125
126 virtual bool CanUndo() const;
127 virtual bool CanRedo() const;
128
129 // Insertion point
130 virtual void SetInsertionPoint(long pos);
131 virtual void SetInsertionPointEnd();
132 virtual long GetInsertionPoint() const;
7d8268a1 133 virtual wxTextPos GetLastPosition() const;
8cf73271
SC
134
135 virtual void SetSelection(long from, long to);
136 virtual void SetEditable(bool editable);
137
138 // Implementation from now on
139 // --------------------------
140
141 // Implementation
142 // --------------
143 virtual void Command(wxCommandEvent& event);
144
145 virtual bool AcceptsFocus() const;
146
147 // callbacks
148 void OnDropFiles(wxDropFilesEvent& event);
149 void OnChar(wxKeyEvent& event); // Process 'enter' if required
150
151 void OnCut(wxCommandEvent& event);
152 void OnCopy(wxCommandEvent& event);
153 void OnPaste(wxCommandEvent& event);
154 void OnUndo(wxCommandEvent& event);
155 void OnRedo(wxCommandEvent& event);
03e4ffc3
SC
156 void OnDelete(wxCommandEvent& event);
157 void OnSelectAll(wxCommandEvent& event);
158
8cf73271
SC
159 void OnUpdateCut(wxUpdateUIEvent& event);
160 void OnUpdateCopy(wxUpdateUIEvent& event);
161 void OnUpdatePaste(wxUpdateUIEvent& event);
162 void OnUpdateUndo(wxUpdateUIEvent& event);
163 void OnUpdateRedo(wxUpdateUIEvent& event);
03e4ffc3
SC
164 void OnUpdateDelete(wxUpdateUIEvent& event);
165 void OnUpdateSelectAll(wxUpdateUIEvent& event);
7d8268a1 166
7ea087b7 167 void OnEraseBackground(wxEraseEvent& event) ;
03e4ffc3 168 void OnContextMenu(wxContextMenuEvent& event);
8cf73271 169
4f305456 170 virtual bool MacCanFocus() const { return true ; }
8cf73271
SC
171 virtual bool MacSetupCursor( const wxPoint& pt ) ;
172
4f305456
SC
173 virtual void MacVisibilityChanged() ;
174 virtual void MacEnabledStateChanged() ;
89a66f11 175 virtual void MacSuperChangedPosition() ;
20b69855 176#ifndef __WXMAC_OSX__
4f305456
SC
177 virtual void MacControlUserPaneDrawProc(wxInt16 part) ;
178 virtual wxInt16 MacControlUserPaneHitTestProc(wxInt16 x, wxInt16 y) ;
179 virtual wxInt16 MacControlUserPaneTrackingProc(wxInt16 x, wxInt16 y, void* actionProc) ;
180 virtual void MacControlUserPaneIdleProc() ;
181 virtual wxInt16 MacControlUserPaneKeyDownProc(wxInt16 keyCode, wxInt16 charCode, wxInt16 modifiers) ;
182 virtual void MacControlUserPaneActivateProc(bool activating) ;
183 virtual wxInt16 MacControlUserPaneFocusProc(wxInt16 action) ;
184 virtual void MacControlUserPaneBackgroundProc(void* info) ;
20b69855 185#endif
8cf73271 186
5ca0d812 187 wxMacTextControl* GetPeer() const { return (wxMacTextControl*) m_peer ; }
8cf73271
SC
188protected:
189 // common part of all ctors
190 void Init();
191
6d4c54a7 192 virtual wxSize DoGetBestSize() const;
8cf73271
SC
193
194 bool m_editable ;
195
196 // flag is set to true when the user edits the controls contents
197 bool m_dirty;
198
8cf73271 199 unsigned long m_maxLength ;
4f305456 200 // need to make this public because of the current implementation via callbacks
4f305456 201private :
03e4ffc3
SC
202 wxMenu *m_privateContextMenu;
203
8cf73271
SC
204 DECLARE_EVENT_TABLE()
205};
206
207#endif
208 // _WX_TEXTCTRL_H_