]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
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 defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "textctrl.h"
19 #if wxUSE_SYSTEM_OPTIONS
20 // set this to true if you want to use the 'classic' mlte based implementation
21 // instead of the HIView based implementation in 10.3 and upwards, the former
22 // has more features (backgrounds etc.) but may show redraw artefacts and other
23 // problems depending on your usage, default is 'false'
24 #define wxMAC_TEXTCONTROL_USE_MLTE _T("mac.textcontrol-use-mlte")
27 #include "wx/control.h"
29 WXDLLEXPORT_DATA(extern const wxChar
*) wxTextCtrlNameStr
;
31 class wxMacTextControl
;
33 // Single-line text item
34 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
36 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
41 wxTextCtrl() { Init(); }
43 wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
44 const wxString
& value
= wxEmptyString
,
45 const wxPoint
& pos
= wxDefaultPosition
,
46 const wxSize
& size
= wxDefaultSize
, long style
= 0,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxTextCtrlNameStr
)
52 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
55 bool Create(wxWindow
*parent
, wxWindowID id
,
56 const wxString
& value
= wxEmptyString
,
57 const wxPoint
& pos
= wxDefaultPosition
,
58 const wxSize
& size
= wxDefaultSize
, long style
= 0,
59 const wxValidator
& validator
= wxDefaultValidator
,
60 const wxString
& name
= wxTextCtrlNameStr
);
64 virtual wxString
GetValue() const ;
65 virtual void SetValue(const wxString
& value
);
67 virtual int GetLineLength(long lineNo
) const;
68 virtual wxString
GetLineText(long lineNo
) const;
69 virtual int GetNumberOfLines() const;
71 virtual bool IsModified() const;
72 virtual bool IsEditable() const;
74 // If the return values from and to are the same, there is no selection.
75 virtual void GetSelection(long* from
, long* to
) const;
83 virtual void Replace(long from
, long to
, const wxString
& value
);
84 virtual void Remove(long from
, long to
);
86 // load the controls contents from the file
87 virtual bool LoadFile(const wxString
& file
);
89 // sets/clears the dirty flag
90 virtual void MarkDirty();
91 virtual void DiscardEdits();
93 // set the max number of characters which may be entered in a single line
95 virtual void SetMaxLength(unsigned long len
) ;
97 // text control under some platforms supports the text styles: these
98 // methods allow to apply the given text style to the given selection or to
99 // set/get the style which will be used for all appended text
100 virtual bool SetFont( const wxFont
&font
) ;
101 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
102 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
104 // writing text inserts it at the current position, appending always
105 // inserts it at the end
106 virtual void WriteText(const wxString
& text
);
107 virtual void AppendText(const wxString
& text
);
109 // translate between the position (which is just an index in the text ctrl
110 // considering all its contents as a single strings) and (x, y) coordinates
111 // which represent column and line.
112 virtual long XYToPosition(long x
, long y
) const;
113 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
115 virtual void ShowPosition(long pos
);
117 // Clipboard operations
120 virtual void Paste();
122 virtual bool CanCopy() const;
123 virtual bool CanCut() const;
124 virtual bool CanPaste() const;
130 virtual bool CanUndo() const;
131 virtual bool CanRedo() const;
134 virtual void SetInsertionPoint(long pos
);
135 virtual void SetInsertionPointEnd();
136 virtual long GetInsertionPoint() const;
137 virtual wxTextPos
GetLastPosition() const;
139 virtual void SetSelection(long from
, long to
);
140 virtual void SetEditable(bool editable
);
142 // Implementation from now on
143 // --------------------------
147 virtual void Command(wxCommandEvent
& event
);
149 virtual bool AcceptsFocus() const;
152 void OnDropFiles(wxDropFilesEvent
& event
);
153 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
155 void OnCut(wxCommandEvent
& event
);
156 void OnCopy(wxCommandEvent
& event
);
157 void OnPaste(wxCommandEvent
& event
);
158 void OnUndo(wxCommandEvent
& event
);
159 void OnRedo(wxCommandEvent
& event
);
161 void OnUpdateCut(wxUpdateUIEvent
& event
);
162 void OnUpdateCopy(wxUpdateUIEvent
& event
);
163 void OnUpdatePaste(wxUpdateUIEvent
& event
);
164 void OnUpdateUndo(wxUpdateUIEvent
& event
);
165 void OnUpdateRedo(wxUpdateUIEvent
& event
);
167 void OnEraseBackground(wxEraseEvent
& event
) ;
169 virtual bool MacCanFocus() const { return true ; }
170 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
172 virtual void MacVisibilityChanged() ;
173 virtual void MacEnabledStateChanged() ;
174 virtual void MacSuperChangedPosition() ;
175 #ifndef __WXMAC_OSX__
176 virtual void MacControlUserPaneDrawProc(wxInt16 part
) ;
177 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) ;
178 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) ;
179 virtual void MacControlUserPaneIdleProc() ;
180 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) ;
181 virtual void MacControlUserPaneActivateProc(bool activating
) ;
182 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) ;
183 virtual void MacControlUserPaneBackgroundProc(void* info
) ;
186 wxMacTextControl
* GetPeer() const { return (wxMacTextControl
*) m_peer
; }
188 // common part of all ctors
191 virtual wxSize
DoGetBestSize() const;
195 // flag is set to true when the user edits the controls contents
198 unsigned long m_maxLength
;
199 // need to make this public because of the current implementation via callbacks
201 DECLARE_EVENT_TABLE()