]>
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 #include "wx/control.h"
21 WXDLLEXPORT_DATA(extern const wxChar
*) wxTextCtrlNameStr
;
23 class wxMacTextControl
;
25 // Single-line text item
26 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
28 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
33 wxTextCtrl() { Init(); }
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
)
44 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
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
);
56 virtual wxString
GetValue() const ;
57 virtual void SetValue(const wxString
& value
);
59 virtual int GetLineLength(long lineNo
) const;
60 virtual wxString
GetLineText(long lineNo
) const;
61 virtual int GetNumberOfLines() const;
63 virtual bool IsModified() const;
64 virtual bool IsEditable() const;
66 // If the return values from and to are the same, there is no selection.
67 virtual void GetSelection(long* from
, long* to
) const;
75 virtual void Replace(long from
, long to
, const wxString
& value
);
76 virtual void Remove(long from
, long to
);
78 // load the controls contents from the file
79 virtual bool LoadFile(const wxString
& file
);
81 // sets/clears the dirty flag
82 virtual void MarkDirty();
83 virtual void DiscardEdits();
85 // set the max number of characters which may be entered in a single line
87 virtual void SetMaxLength(unsigned long len
) ;
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
);
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
);
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;
107 virtual void ShowPosition(long pos
);
109 // Clipboard operations
112 virtual void Paste();
114 virtual bool CanCopy() const;
115 virtual bool CanCut() const;
116 virtual bool CanPaste() const;
122 virtual bool CanUndo() const;
123 virtual bool CanRedo() const;
126 virtual void SetInsertionPoint(long pos
);
127 virtual void SetInsertionPointEnd();
128 virtual long GetInsertionPoint() const;
129 virtual wxTextPos
GetLastPosition() const;
131 virtual void SetSelection(long from
, long to
);
132 virtual void SetEditable(bool editable
);
134 // Implementation from now on
135 // --------------------------
139 virtual void Command(wxCommandEvent
& event
);
141 virtual bool AcceptsFocus() const;
144 void OnDropFiles(wxDropFilesEvent
& event
);
145 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
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
);
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
);
159 void OnEraseBackground(wxEraseEvent
& event
) ;
161 virtual bool MacCanFocus() const { return true ; }
162 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
164 virtual void MacVisibilityChanged() ;
165 virtual void MacEnabledStateChanged() ;
166 virtual void MacSuperChangedPosition() ;
167 #ifndef __WXMAC_OSX__
168 virtual void MacControlUserPaneDrawProc(wxInt16 part
) ;
169 virtual wxInt16
MacControlUserPaneHitTestProc(wxInt16 x
, wxInt16 y
) ;
170 virtual wxInt16
MacControlUserPaneTrackingProc(wxInt16 x
, wxInt16 y
, void* actionProc
) ;
171 virtual void MacControlUserPaneIdleProc() ;
172 virtual wxInt16
MacControlUserPaneKeyDownProc(wxInt16 keyCode
, wxInt16 charCode
, wxInt16 modifiers
) ;
173 virtual void MacControlUserPaneActivateProc(bool activating
) ;
174 virtual wxInt16
MacControlUserPaneFocusProc(wxInt16 action
) ;
175 virtual void MacControlUserPaneBackgroundProc(void* info
) ;
178 wxMacTextControl
* GetPeer() const { return (wxMacTextControl
*) m_peer
; }
180 // common part of all ctors
183 virtual wxSize
DoGetBestSize() const;
187 // flag is set to true when the user edits the controls contents
190 unsigned long m_maxLength
;
191 // need to make this public because of the current implementation via callbacks
193 DECLARE_EVENT_TABLE()