]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/classic/textctrl.h
Added DoLoadFile, DoSaveFile to wxTextCtrlBase
[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 virtual ~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 // sets/clears the dirty flag
73 virtual void MarkDirty();
74 virtual void DiscardEdits();
75
76 // set the max number of characters which may be entered in a single line
77 // text control
78 virtual void SetMaxLength(unsigned long len) ;
79
80 // text control under some platforms supports the text styles: these
81 // methods allow to apply the given text style to the given selection or to
82 // set/get the style which will be used for all appended text
83 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
84 virtual bool SetDefaultStyle(const wxTextAttr& style);
85
86 // writing text inserts it at the current position, appending always
87 // inserts it at the end
88 virtual void WriteText(const wxString& text);
89 virtual void AppendText(const wxString& text);
90
91 // translate between the position (which is just an index in the text ctrl
92 // considering all its contents as a single strings) and (x, y) coordinates
93 // which represent column and line.
94 virtual long XYToPosition(long x, long y) const;
95 virtual bool PositionToXY(long pos, long *x, long *y) const;
96
97 virtual void ShowPosition(long pos);
98
99 // Clipboard operations
100 virtual void Copy();
101 virtual void Cut();
102 virtual void Paste();
103
104 virtual bool CanCopy() const;
105 virtual bool CanCut() const;
106 virtual bool CanPaste() const;
107
108 // Undo/redo
109 virtual void Undo();
110 virtual void Redo();
111
112 virtual bool CanUndo() const;
113 virtual bool CanRedo() const;
114
115 // Insertion point
116 virtual void SetInsertionPoint(long pos);
117 virtual void SetInsertionPointEnd();
118 virtual long GetInsertionPoint() const;
119 virtual wxTextPos GetLastPosition() const;
120
121 virtual void SetSelection(long from, long to);
122 virtual void SetEditable(bool editable);
123
124 // Implementation from now on
125 // --------------------------
126
127 // Implementation
128 // --------------
129 virtual void Command(wxCommandEvent& event);
130
131 virtual bool AcceptsFocus() const;
132
133 // callbacks
134 void OnDropFiles(wxDropFilesEvent& event);
135 void OnChar(wxKeyEvent& event); // Process 'enter' if required
136
137 void OnCut(wxCommandEvent& event);
138 void OnCopy(wxCommandEvent& event);
139 void OnPaste(wxCommandEvent& event);
140 void OnUndo(wxCommandEvent& event);
141 void OnRedo(wxCommandEvent& event);
142
143 void OnUpdateCut(wxUpdateUIEvent& event);
144 void OnUpdateCopy(wxUpdateUIEvent& event);
145 void OnUpdatePaste(wxUpdateUIEvent& event);
146 void OnUpdateUndo(wxUpdateUIEvent& event);
147 void OnUpdateRedo(wxUpdateUIEvent& event);
148
149 virtual bool MacCanFocus() const { return true ; }
150 virtual bool MacSetupCursor( const wxPoint& pt ) ;
151
152 virtual void MacSuperShown( bool show ) ;
153 virtual bool Show(bool show = true) ;
154
155 protected:
156 // common part of all ctors
157 void Init();
158
159 virtual wxSize DoGetBestSize() const;
160
161 bool m_editable ;
162
163 // flag is set to true when the user edits the controls contents
164 bool m_dirty;
165
166 // one of the following objects is used for representation, the other one is NULL
167 void* m_macTE ;
168 void* m_macTXN ;
169 void* m_macTXNvars ;
170 bool m_macUsesTXN ;
171 unsigned long m_maxLength ;
172
173 DECLARE_EVENT_TABLE()
174 };
175
176 #endif
177 // _WX_TEXTCTRL_H_