]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/textctrl.h
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef __GTKTEXTCTRLH__
12 #define __GTKTEXTCTRLH__
14 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
15 #pragma interface "textctrl.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 class wxTextCtrl
: public wxTextCtrlBase
25 wxTextCtrl() { Init(); }
26 wxTextCtrl(wxWindow
*parent
,
28 const wxString
&value
= wxEmptyString
,
29 const wxPoint
&pos
= wxDefaultPosition
,
30 const wxSize
&size
= wxDefaultSize
,
32 const wxValidator
& validator
= wxDefaultValidator
,
33 const wxString
&name
= wxTextCtrlNameStr
);
37 bool Create(wxWindow
*parent
,
39 const wxString
&value
= wxEmptyString
,
40 const wxPoint
&pos
= wxDefaultPosition
,
41 const wxSize
&size
= wxDefaultSize
,
43 const wxValidator
& validator
= wxDefaultValidator
,
44 const wxString
&name
= wxTextCtrlNameStr
);
46 // implement base class pure virtuals
47 // ----------------------------------
49 virtual wxString
GetValue() const;
50 virtual void SetValue(const wxString
& value
);
52 virtual int GetLineLength(long lineNo
) const;
53 virtual wxString
GetLineText(long lineNo
) const;
54 virtual int GetNumberOfLines() const;
56 virtual bool IsModified() const;
57 virtual bool IsEditable() const;
59 // If the return values from and to are the same, there is no selection.
60 virtual void GetSelection(long* from
, long* to
) const;
67 virtual void Replace(long from
, long to
, const wxString
& value
);
68 virtual void Remove(long from
, long to
);
70 // sets/clears the dirty flag
71 virtual void MarkDirty();
72 virtual void DiscardEdits();
74 virtual void SetMaxLength(unsigned long len
);
76 // writing text inserts it at the current position, appending always
77 // inserts it at the end
78 virtual void WriteText(const wxString
& text
);
79 virtual void AppendText(const wxString
& text
);
81 // apply text attribute to the range of text (only works with richedit
83 virtual bool SetStyle(long start
, long end
, const wxTextAttr
& style
);
85 // translate between the position (which is just an index in the text ctrl
86 // considering all its contents as a single strings) and (x, y) coordinates
87 // which represent column and line.
88 virtual long XYToPosition(long x
, long y
) const;
89 virtual bool PositionToXY(long pos
, long *x
, long *y
) const;
91 virtual void ShowPosition(long pos
);
94 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
, long *pos
) const;
95 virtual wxTextCtrlHitTestResult
HitTest(const wxPoint
& pt
,
97 wxTextCoord
*row
) const
99 return wxTextCtrlBase::HitTest(pt
, col
, row
);
101 #endif // __WXGTK20__
103 // Clipboard operations
106 virtual void Paste();
112 virtual bool CanUndo() const;
113 virtual bool CanRedo() const;
116 virtual void SetInsertionPoint(long pos
);
117 virtual void SetInsertionPointEnd();
118 virtual long GetInsertionPoint() const;
119 virtual wxTextPos
GetLastPosition() const;
121 virtual void SetSelection(long from
, long to
);
122 virtual void SetEditable(bool editable
);
124 virtual bool Enable( bool enable
= true );
126 // Implementation from now on
127 void OnDropFiles( wxDropFilesEvent
&event
);
128 void OnChar( wxKeyEvent
&event
);
130 void OnCut(wxCommandEvent
& event
);
131 void OnCopy(wxCommandEvent
& event
);
132 void OnPaste(wxCommandEvent
& event
);
133 void OnUndo(wxCommandEvent
& event
);
134 void OnRedo(wxCommandEvent
& event
);
136 void OnUpdateCut(wxUpdateUIEvent
& event
);
137 void OnUpdateCopy(wxUpdateUIEvent
& event
);
138 void OnUpdatePaste(wxUpdateUIEvent
& event
);
139 void OnUpdateUndo(wxUpdateUIEvent
& event
);
140 void OnUpdateRedo(wxUpdateUIEvent
& event
);
142 bool SetFont(const wxFont
& font
);
143 bool SetForegroundColour(const wxColour
& colour
);
144 bool SetBackgroundColour(const wxColour
& colour
);
146 GtkWidget
* GetConnectWidget();
147 bool IsOwnGtkWindow( GdkWindow
*window
);
148 void DoApplyWidgetStyle(GtkRcStyle
*style
);
149 void CalculateScrollbar();
150 void OnInternalIdle();
153 void SetUpdateFont(bool WXUNUSED(update
)) { }
154 #else // !__WXGTK20__
155 void SetUpdateFont(bool update
) { m_updateFont
= update
; }
156 void UpdateFontIfNeeded();
157 #endif // __WXGTK20__/!__WXGTK20__
159 void SetModified() { m_modified
= true; }
161 // GTK+ textctrl is so dumb that you need to freeze/thaw it manually to
162 // avoid horrible flicker/scrolling back and forth
163 virtual void Freeze();
166 // textctrl specific scrolling
167 virtual bool ScrollLines(int lines
);
168 virtual bool ScrollPages(int pages
);
170 // implementation only from now on
172 // wxGTK-specific: called recursively by Enable,
173 // to give widgets an oppprtunity to correct their colours after they
174 // have been changed by Enable
175 virtual void OnParentEnable( bool enable
) ;
177 // tell the control to ignore next text changed signal
178 void IgnoreNextTextUpdate();
180 // should we ignore the changed signal? always resets the flag
181 bool IgnoreTextUpdate();
183 static wxVisualAttributes
184 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
187 virtual wxSize
DoGetBestSize() const;
189 // common part of all ctors
192 // get the vertical adjustment, if any, NULL otherwise
193 GtkAdjustment
*GetVAdj() const;
195 // scroll the control by the given number of pixels, return true if the
196 // scroll position changed
197 bool DoScroll(GtkAdjustment
*adj
, int diff
);
199 // Widgets that use the style->base colour for the BG colour should
200 // override this and return true.
201 virtual bool UseGTKStyleBase() const { return true; }
204 // has the control been frozen by Freeze()?
205 bool IsFrozen() const { return m_frozenness
> 0; }
209 // change the font for everything in this control
210 void ChangeFontGlobally();
213 GtkWidget
*m_vScrollbar
;
216 bool m_vScrollbarVisible
:1;
219 #endif // !__WXGTK20__
220 bool m_ignoreNextUpdate
:1;
223 // Our text buffer. Convenient, and holds the buffer while using
224 // a dummy one when m_frozenness > 0
225 GtkTextBuffer
*m_buffer
;
227 // number of calls to Freeze() minus number of calls to Thaw()
228 unsigned int m_frozenness
;
231 void OnUrlMouseEvent(wxMouseEvent
&);
232 GdkCursor
*m_gdkHandCursor
;
233 GdkCursor
*m_gdkXTermCursor
;
236 DECLARE_EVENT_TABLE()
237 DECLARE_DYNAMIC_CLASS(wxTextCtrl
)
240 #endif // __GTKTEXTCTRLH__