]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/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 // Single-line text item
24 class WXDLLEXPORT wxTextCtrl
: public wxTextCtrlBase
26 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
33 inline wxTextCtrl(wxWindow
*parent
, wxWindowID id
,
34 const wxString
& value
= wxEmptyString
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
, long style
= 0,
37 const wxValidator
& validator
= wxDefaultValidator
,
38 const wxString
& name
= wxTextCtrlNameStr
)
40 Create(parent
, id
, value
, pos
, size
, style
, validator
, name
);
43 bool Create(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 virtual wxString
GetValue() const ;
53 virtual void SetValue(const wxString
& value
);
55 virtual int GetLineLength(long lineNo
) const;
56 virtual wxString
GetLineText(long lineNo
) const;
57 virtual int GetNumberOfLines() const;
59 virtual bool IsModified() const;
60 virtual bool IsEditable() const;
62 // If the return values from and to are the same, there is no selection.
63 virtual void GetSelection(long* from
, long* to
) const;
71 virtual void Replace(long from
, long to
, const wxString
& value
);
72 virtual void Remove(long from
, long to
);
74 // load the controls contents from the file
75 virtual bool LoadFile(const wxString
& file
);
77 // clears the dirty flag
78 virtual void DiscardEdits();
80 // set the max number of characters which may be entered in a single line
82 virtual void SetMaxLength(unsigned long len
) ;
84 // text control under some platforms supports the text styles: these
85 // methods allow to apply the given text style to the given selection or to
86 // set/get the style which will be used for all appended text
87 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
88 virtual bool SetDefaultStyle(const wxTextAttr
& style
);
90 // writing text inserts it at the current position, appending always
91 // inserts it at the end
92 virtual void WriteText(const wxString
& text
);
93 virtual void AppendText(const wxString
& text
);
95 // translate between the position (which is just an index in the text ctrl
96 // considering all its contents as a single strings) and (x, y) coordinates
97 // which represent column and line.
98 virtual long XYToPosition(long x
, long y
) const;
99 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
101 virtual void ShowPosition(long pos
);
103 // Clipboard operations
106 virtual void Paste();
108 virtual bool CanCopy() const;
109 virtual bool CanCut() const;
110 virtual bool CanPaste() const;
116 virtual bool CanUndo() const;
117 virtual bool CanRedo() const;
120 virtual void SetInsertionPoint(long pos
);
121 virtual void SetInsertionPointEnd();
122 virtual long GetInsertionPoint() const;
123 virtual long GetLastPosition() const;
125 virtual void SetSelection(long from
, long to
);
126 virtual void SetEditable(bool editable
);
128 // Implementation from now on
129 // --------------------------
133 virtual void Command(wxCommandEvent
& event
);
135 virtual bool AcceptsFocus() const;
138 void OnDropFiles(wxDropFilesEvent
& event
);
139 void OnChar(wxKeyEvent
& event
); // Process 'enter' if required
141 void OnCut(wxCommandEvent
& event
);
142 void OnCopy(wxCommandEvent
& event
);
143 void OnPaste(wxCommandEvent
& event
);
144 void OnUndo(wxCommandEvent
& event
);
145 void OnRedo(wxCommandEvent
& event
);
147 void OnUpdateCut(wxUpdateUIEvent
& event
);
148 void OnUpdateCopy(wxUpdateUIEvent
& event
);
149 void OnUpdatePaste(wxUpdateUIEvent
& event
);
150 void OnUpdateUndo(wxUpdateUIEvent
& event
);
151 void OnUpdateRedo(wxUpdateUIEvent
& event
);
153 virtual bool MacCanFocus() const { return true ; }
154 virtual bool MacSetupCursor( const wxPoint
& pt
) ;
156 virtual void MacSuperShown( bool show
) ;
157 virtual bool Show(bool show
= TRUE
) ;
160 virtual wxSize
DoGetBestSize() const;
163 // one of the following objects is used for representation, the other one is NULL
168 unsigned long m_maxLength
;
170 DECLARE_EVENT_TABLE()