]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
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")
23 #include "wx/control.h"
24 #include "wx/textctrl.h"
26 class wxMacTextControl
;
29 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
31 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
37 wxTextCtrl(wxWindow
*parent
,
39 const wxString
& value
= wxEmptyString
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
43 const wxValidator
& validator
= wxDefaultValidator
,
44 const wxString
& name
= wxTextCtrlNameStr
)
47 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
52 bool Create(wxWindow
*parent
,
54 const wxString
& value
= wxEmptyString
,
55 const wxPoint
& pos
= wxDefaultPosition
,
56 const wxSize
& size
= wxDefaultSize
,
58 const wxValidator
& validator
= wxDefaultValidator
,
59 const wxString
& name
= wxTextCtrlNameStr
);
63 virtual wxString
GetValue() const;
64 virtual void SetValue(const wxString
& value
);
66 virtual int GetLineLength(long lineNo
) const;
67 virtual wxString
GetLineText(long lineNo
) const;
68 virtual int GetNumberOfLines() const;
70 virtual bool IsModified() const;
71 virtual bool IsEditable() const;
73 // If the return values from and to are the same, there is no selection.
74 virtual void GetSelection(long* from
, long* to
) const;
81 virtual void Replace(long from
, long to
, const wxString
& value
);
82 virtual void Remove(long from
, long to
);
84 // load the controls contents from the file
85 virtual bool LoadFile(const wxString
& file
);
87 // sets/clears the dirty flag
88 virtual void MarkDirty();
89 virtual void DiscardEdits();
91 // set the max number of characters which may be entered
92 // in a single line text control
93 virtual void SetMaxLength(unsigned long len
);
95 // text control under some platforms supports the text styles: these
96 // methods apply the given text style to the given selection or to
97 // set/get the style which will be used for all appended text
98 virtual bool SetFont( const wxFont
&font
);
99 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
100 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
102 // writing text inserts it at the current position;
103 // appending always inserts it at the end
104 virtual void WriteText(const wxString
& text
);
105 virtual void AppendText(const wxString
& text
);
107 // translate between the position (which is just an index into the textctrl
108 // considering all its contents as a single strings) and (x, y) coordinates
109 // which represent column and line.
110 virtual long XYToPosition(long x
, long y
) const;
111 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
113 virtual void ShowPosition(long pos
);
115 // Clipboard operations
118 virtual void Paste();
120 virtual bool CanCopy() const;
121 virtual bool CanCut() const;
122 virtual bool CanPaste() const;
128 virtual bool CanUndo() const;
129 virtual bool CanRedo() const;
132 virtual void SetInsertionPoint(long pos
);
133 virtual void SetInsertionPointEnd();
134 virtual long GetInsertionPoint() const;
135 virtual wxTextPos
GetLastPosition() const;
137 virtual void SetSelection(long from
, long to
);
138 virtual void SetEditable(bool editable
);
142 virtual void Command(wxCommandEvent
& event
);
144 virtual bool AcceptsFocus() const;
147 void OnDropFiles(wxDropFilesEvent
& event
);
148 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
150 void OnCut(wxCommandEvent
& event
);
151 void OnCopy(wxCommandEvent
& event
);
152 void OnPaste(wxCommandEvent
& event
);
153 void OnUndo(wxCommandEvent
& event
);
154 void OnRedo(wxCommandEvent
& event
);
155 void OnDelete(wxCommandEvent
& event
);
156 void OnSelectAll(wxCommandEvent
& event
);
158 void OnUpdateCut(wxUpdateUIEvent
& event
);
159 void OnUpdateCopy(wxUpdateUIEvent
& event
);
160 void OnUpdatePaste(wxUpdateUIEvent
& event
);
161 void OnUpdateUndo(wxUpdateUIEvent
& event
);
162 void OnUpdateRedo(wxUpdateUIEvent
& event
);
163 void OnUpdateDelete(wxUpdateUIEvent
& event
);
164 void OnUpdateSelectAll(wxUpdateUIEvent
& event
);
166 void OnEraseBackground(wxEraseEvent
& event
);
167 void OnContextMenu(wxContextMenuEvent
& event
);
169 virtual bool MacCanFocus() const
172 virtual bool MacSetupCursor( const wxPoint
& pt
);
174 virtual void MacVisibilityChanged();
175 virtual void MacEnabledStateChanged();
176 virtual void MacSuperChangedPosition();
178 #ifndef __WXMAC_OSX__
179 virtual void MacControlUserPaneDrawProc(wxInt16 part
);
180 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
);
181 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
);
182 virtual void MacControlUserPaneIdleProc();
183 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
);
184 virtual void MacControlUserPaneActivateProc(bool activating
);
185 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
);
186 virtual void MacControlUserPaneBackgroundProc(void* info
);
189 wxMacTextControl
* GetPeer() const
190 { return (wxMacTextControl
*) m_peer
; }
193 // common part of all ctors
196 virtual wxSize
DoGetBestSize() const;
200 // flag is set to true when the user edits the controls contents
203 // need to make this public because of the current implementation via callbacks
204 unsigned long m_maxLength
;
206 bool GetTriggerOnSetValue() const
208 return m_triggerOnSetValue
;
211 void SetTriggerOnSetValue(bool trigger
)
213 m_triggerOnSetValue
= trigger
;
216 bool m_triggerOnSetValue
;
219 wxMenu
*m_privateContextMenu
;
221 DECLARE_EVENT_TABLE()
224 #endif // _WX_TEXTCTRL_H_