]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTextCtrl class
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
15 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "textctrl.h"
19 #include "wx/control.h"
21 WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr
;
22 WXDLLEXPORT_DATA(extern const char*) wxEmptyString
;
24 // Single-line text item
25 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
27 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
34 inline wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
35 const wxString
& value
= wxEmptyString
,
36 const wxPoint
& pos
= wxDefaultPosition
,
37 const wxSize
& size
= wxDefaultSize
, long style
= 0,
38 const wxValidator
& validator
= wxDefaultValidator
,
39 const wxString
& name
= wxTextCtrlNameStr
)
41 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
44 bool Create(wxWindow
*parent
, wxWindowID id
,
45 const wxString
& value
= wxEmptyString
,
46 const wxPoint
& pos
= wxDefaultPosition
,
47 const wxSize
& size
= wxDefaultSize
, long style
= 0,
48 const wxValidator
& validator
= wxDefaultValidator
,
49 const wxString
& name
= wxTextCtrlNameStr
);
53 virtual wxString
GetValue() const ;
54 virtual void SetValue(const wxString
& value
);
56 virtual int GetLineLength(long lineNo
) const;
57 virtual wxString
GetLineText(long lineNo
) const;
58 virtual int GetNumberOfLines() const;
60 virtual bool IsModified() const;
61 virtual bool IsEditable() const;
63 // If the return values from and to are the same, there is no selection.
64 virtual void GetSelection(long* from
, long* to
) const;
72 virtual void Replace(long from
, long to
, const wxString
& value
);
73 virtual void Remove(long from
, long to
);
75 // load the controls contents from the file
76 virtual bool LoadFile(const wxString
& file
);
78 // clears the dirty flag
79 virtual void DiscardEdits();
81 // set the max number of characters which may be entered in a single line
83 virtual void SetMaxLength(unsigned long len
) ;
85 // text control under some platforms supports the text styles: these
86 // methods allow to apply the given text style to the given selection or to
87 // set/get the style which will be used for all appended text
88 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
89 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
91 // writing text inserts it at the current position, appending always
92 // inserts it at the end
93 virtual void WriteText(const wxString
& text
);
94 virtual void AppendText(const wxString
& text
);
96 // translate between the position (which is just an index in the text ctrl
97 // considering all its contents as a single strings) and (x, y) coordinates
98 // which represent column and line.
99 virtual long XYToPosition(long x
, long y
) const;
100 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
102 virtual void ShowPosition(long pos
);
104 // Clipboard operations
107 virtual void Paste();
109 virtual bool CanCopy() const;
110 virtual bool CanCut() const;
111 virtual bool CanPaste() const;
117 virtual bool CanUndo() const;
118 virtual bool CanRedo() const;
121 virtual void SetInsertionPoint(long pos
);
122 virtual void SetInsertionPointEnd();
123 virtual long GetInsertionPoint() const;
124 virtual long GetLastPosition() const;
126 virtual void SetSelection(long from
, long to
);
127 virtual void SetEditable(bool editable
);
129 // Implementation from now on
130 // --------------------------
134 virtual void Command(wxCommandEvent
& event
);
136 virtual bool AcceptsFocus() const;
139 void OnDropFiles(wxDropFilesEvent
& event
);
140 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
142 void OnCut(wxCommandEvent
& event
);
143 void OnCopy(wxCommandEvent
& event
);
144 void OnPaste(wxCommandEvent
& event
);
145 void OnUndo(wxCommandEvent
& event
);
146 void OnRedo(wxCommandEvent
& event
);
148 void OnUpdateCut(wxUpdateUIEvent
& event
);
149 void OnUpdateCopy(wxUpdateUIEvent
& event
);
150 void OnUpdatePaste(wxUpdateUIEvent
& event
);
151 void OnUpdateUndo(wxUpdateUIEvent
& event
);
152 void OnUpdateRedo(wxUpdateUIEvent
& event
);
154 virtual bool MacCanFocus() const { return true ; }
155 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
157 virtual void MacSuperShown( bool show
) ;
158 virtual bool Show(bool show
= TRUE
) ;
161 virtual wxSize
DoGetBestSize() const;
164 // one of the following objects is used for representation, the other one is NULL
169 unsigned long m_maxLength
;
171 DECLARE_EVENT_TABLE()