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