]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/classic/textctrl.h
non-pch universal build fix: combo.h should not include combobox.h
[wxWidgets.git] / include / wx / mac / classic / textctrl.h
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
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
15 #include "wx/control.h"
16
17 WXDLLEXPORT_DATA(extern const wxChar) wxTextCtrlNameStr[];
18
19 // Single-line text item
20 class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
21 {
22 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
23
24 public:
25 // creation
26 // --------
27 wxTextCtrl() { Init(); }
28 ~wxTextCtrl();
29 wxTextCtrl(wxWindow *parent, wxWindowID id,
30 const wxString& value = wxEmptyString,
31 const wxPoint& pos = wxDefaultPosition,
32 const wxSize& size = wxDefaultSize, long style = 0,
33 const wxValidator& validator = wxDefaultValidator,
34 const wxString& name = wxTextCtrlNameStr)
35 {
36 Init();
37
38 Create(parent, id, value, pos, size, style, validator, name);
39 }
40
41 bool Create(wxWindow *parent, wxWindowID id,
42 const wxString& value = wxEmptyString,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize, long style = 0,
45 const wxValidator& validator = wxDefaultValidator,
46 const wxString& name = wxTextCtrlNameStr);
47
48 // accessors
49 // ---------
50 virtual wxString GetValue() const ;
51 virtual void SetValue(const wxString& value);
52
53 virtual int GetLineLength(long lineNo) const;
54 virtual wxString GetLineText(long lineNo) const;
55 virtual int GetNumberOfLines() const;
56
57 virtual bool IsModified() const;
58 virtual bool IsEditable() const;
59
60 // If the return values from and to are the same, there is no selection.
61 virtual void GetSelection(long* from, long* to) const;
62
63 // operations
64 // ----------
65
66 // editing
67
68 virtual void Clear();
69 virtual void Replace(long from, long to, const wxString& value);
70 virtual void Remove(long from, long to);
71
72 // load the controls contents from the file
73 virtual bool LoadFile(const wxString& file);
74
75 // sets/clears the dirty flag
76 virtual void MarkDirty();
77 virtual void DiscardEdits();
78
79 // set the max number of characters which may be entered in a single line
80 // text control
81 virtual void SetMaxLength(unsigned long len) ;
82
83 // text control under some platforms supports the text styles: these
84 // methods allow to apply the given text style to the given selection or to
85 // set/get the style which will be used for all appended text
86 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
87 virtual bool SetDefaultStyle(const wxTextAttr& style);
88
89 // writing text inserts it at the current position, appending always
90 // inserts it at the end
91 virtual void WriteText(const wxString& text);
92 virtual void AppendText(const wxString& text);
93
94 // translate between the position (which is just an index in the text ctrl
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 // Clipboard operations
103 virtual void Copy();
104 virtual void Cut();
105 virtual void Paste();
106
107 virtual bool CanCopy() const;
108 virtual bool CanCut() const;
109 virtual bool CanPaste() const;
110
111 // Undo/redo
112 virtual void Undo();
113 virtual void Redo();
114
115 virtual bool CanUndo() const;
116 virtual bool CanRedo() const;
117
118 // Insertion point
119 virtual void SetInsertionPoint(long pos);
120 virtual void SetInsertionPointEnd();
121 virtual long GetInsertionPoint() const;
122 virtual wxTextPos GetLastPosition() const;
123
124 virtual void SetSelection(long from, long to);
125 virtual void SetEditable(bool editable);
126
127 // Implementation from now on
128 // --------------------------
129
130 // Implementation
131 // --------------
132 virtual void Command(wxCommandEvent& event);
133
134 virtual bool AcceptsFocus() const;
135
136 // callbacks
137 void OnDropFiles(wxDropFilesEvent& event);
138 void OnChar(wxKeyEvent& event); // Process 'enter' if required
139
140 void OnCut(wxCommandEvent& event);
141 void OnCopy(wxCommandEvent& event);
142 void OnPaste(wxCommandEvent& event);
143 void OnUndo(wxCommandEvent& event);
144 void OnRedo(wxCommandEvent& event);
145
146 void OnUpdateCut(wxUpdateUIEvent& event);
147 void OnUpdateCopy(wxUpdateUIEvent& event);
148 void OnUpdatePaste(wxUpdateUIEvent& event);
149 void OnUpdateUndo(wxUpdateUIEvent& event);
150 void OnUpdateRedo(wxUpdateUIEvent& event);
151
152 virtual bool MacCanFocus() const { return true ; }
153 virtual bool MacSetupCursor( const wxPoint& pt ) ;
154
155 virtual void MacSuperShown( bool show ) ;
156 virtual bool Show(bool show = true) ;
157
158 protected:
159 // common part of all ctors
160 void Init();
161
162 virtual wxSize DoGetBestSize() const;
163
164 bool m_editable ;
165
166 // flag is set to true when the user edits the controls contents
167 bool m_dirty;
168
169 // one of the following objects is used for representation, the other one is NULL
170 void* m_macTE ;
171 void* m_macTXN ;
172 void* m_macTXNvars ;
173 bool m_macUsesTXN ;
174 unsigned long m_maxLength ;
175
176 DECLARE_EVENT_TABLE()
177 };
178
179 #endif
180 // _WX_TEXTCTRL_H_