]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKTEXTCTRLH__
12 #define __GTKTEXTCTRLH__
15 #pragma interface "textctrl.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 class wxTextCtrl
: public wxTextCtrlBase
31 wxTextCtrl() { Init(); }
32 wxTextCtrl(wxWindow
*parent
,
34 const wxString
&value
= wxEmptyString
,
35 const wxPoint
&pos
= wxDefaultPosition
,
36 const wxSize
&size
= wxDefaultSize
,
38 const wxValidator
& validator
= wxDefaultValidator
,
39 const wxString
&name
= wxTextCtrlNameStr
);
41 bool Create(wxWindow
*parent
,
43 const wxString
&value
= wxEmptyString
,
44 const wxPoint
&pos
= wxDefaultPosition
,
45 const wxSize
&size
= wxDefaultSize
,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
&name
= wxTextCtrlNameStr
);
50 // implement base class pure virtuals
51 // ----------------------------------
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;
71 virtual void Replace(long from
, long to
, const wxString
& value
);
72 virtual void Remove(long from
, long to
);
74 // clears the dirty flag
75 virtual void DiscardEdits();
77 // writing text inserts it at the current position, appending always
78 // inserts it at the end
79 virtual void WriteText(const wxString
& text
);
80 virtual void AppendText(const wxString
& text
);
82 // apply text attribute to the range of text (only works with richedit
84 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
86 // translate between the position (which is just an index in the text ctrl
87 // considering all its contents as a single strings) and (x, y) coordinates
88 // which represent column and line.
89 virtual long XYToPosition(long x
, long y
) const;
90 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
92 virtual void ShowPosition(long pos
);
94 // Clipboard operations
99 virtual bool CanCopy() const;
100 virtual bool CanCut() const;
101 virtual bool CanPaste() const;
107 virtual bool CanUndo() const;
108 virtual bool CanRedo() const;
111 virtual void SetInsertionPoint(long pos
);
112 virtual void SetInsertionPointEnd();
113 virtual long GetInsertionPoint() const;
114 virtual long GetLastPosition() const;
116 virtual void SetSelection(long from
, long to
);
117 virtual void SetEditable(bool editable
);
119 virtual bool Enable( bool enable
);
121 // Implementation from now on
122 void OnDropFiles( wxDropFilesEvent
&event
);
123 void OnChar( wxKeyEvent
&event
);
125 void OnCut(wxCommandEvent
& event
);
126 void OnCopy(wxCommandEvent
& event
);
127 void OnPaste(wxCommandEvent
& event
);
128 void OnUndo(wxCommandEvent
& event
);
129 void OnRedo(wxCommandEvent
& event
);
131 void OnUpdateCut(wxUpdateUIEvent
& event
);
132 void OnUpdateCopy(wxUpdateUIEvent
& event
);
133 void OnUpdatePaste(wxUpdateUIEvent
& event
);
134 void OnUpdateUndo(wxUpdateUIEvent
& event
);
135 void OnUpdateRedo(wxUpdateUIEvent
& event
);
137 bool SetFont(const wxFont
& font
);
138 bool SetForegroundColour(const wxColour
& colour
);
139 bool SetBackgroundColour(const wxColour
& colour
);
141 GtkWidget
* GetConnectWidget();
142 bool IsOwnGtkWindow( GdkWindow
*window
);
143 void ApplyWidgetStyle();
144 void CalculateScrollbar();
145 void OnInternalIdle();
146 void UpdateFontIfNeeded();
148 void SetModified() { m_modified
= TRUE
; }
150 // wxGTK-specific: called recursively by Enable,
151 // to give widgets an oppprtunity to correct their colours after they
152 // have been changed by Enable
153 virtual void OnParentEnable( bool enable
) ;
156 virtual wxSize
DoGetBestSize() const;
158 // common part of all ctors
162 // change the font for everything in this control
163 void ChangeFontGlobally();
167 GtkWidget
*m_vScrollbar
;
168 bool m_vScrollbarVisible
;
171 DECLARE_EVENT_TABLE()
172 DECLARE_DYNAMIC_CLASS(wxTextCtrl
);
175 #endif // __GTKTEXTCTRLH__