]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/textctrl.h
wxMSWUniv wxWindowMSW vs. wxWindow fix.
[wxWidgets.git] / include / wx / gtk / textctrl.h
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
6b0d8a01 2// Name: wx/gtk/textctrl.h
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
5// Created: 01/02/97
7c41ac7b 6// Id: $Id$
371a5b4e 7// Copyright: (c) 1998 Robert Roebling
65571936 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
c801d85f
KB
11#ifndef __GTKTEXTCTRLH__
12#define __GTKTEXTCTRLH__
13
12028905 14#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
bf3e0fbd 15 #pragma interface "textctrl.h"
f5abe911
RR
16#endif
17
c801d85f 18//-----------------------------------------------------------------------------
a1b82138 19// wxTextCtrl
c801d85f
KB
20//-----------------------------------------------------------------------------
21
a1b82138 22class wxTextCtrl: public wxTextCtrlBase
c801d85f 23{
a1b82138 24public:
01041145 25 wxTextCtrl() { Init(); }
13111b2a
VZ
26 wxTextCtrl(wxWindow *parent,
27 wxWindowID id,
28 const wxString &value = wxEmptyString,
29 const wxPoint &pos = wxDefaultPosition,
30 const wxSize &size = wxDefaultSize,
31 long style = 0,
32 const wxValidator& validator = wxDefaultValidator,
33 const wxString &name = wxTextCtrlNameStr);
34
35 bool Create(wxWindow *parent,
36 wxWindowID id,
37 const wxString &value = wxEmptyString,
38 const wxPoint &pos = wxDefaultPosition,
39 const wxSize &size = wxDefaultSize,
40 long style = 0,
41 const wxValidator& validator = wxDefaultValidator,
42 const wxString &name = wxTextCtrlNameStr);
a1b82138
VZ
43
44 // implement base class pure virtuals
45 // ----------------------------------
46
47 virtual wxString GetValue() const;
48 virtual void SetValue(const wxString& value);
49
50 virtual int GetLineLength(long lineNo) const;
51 virtual wxString GetLineText(long lineNo) const;
52 virtual int GetNumberOfLines() const;
53
54 virtual bool IsModified() const;
55 virtual bool IsEditable() const;
56
57 // If the return values from and to are the same, there is no selection.
58 virtual void GetSelection(long* from, long* to) const;
59
60 // operations
61 // ----------
62
63 // editing
64 virtual void Clear();
65 virtual void Replace(long from, long to, const wxString& value);
66 virtual void Remove(long from, long to);
67
3a9fa0d6
VZ
68 // sets/clears the dirty flag
69 virtual void MarkDirty();
a1b82138
VZ
70 virtual void DiscardEdits();
71
d7eee191
VZ
72 virtual void SetMaxLength(unsigned long len);
73
a1b82138
VZ
74 // writing text inserts it at the current position, appending always
75 // inserts it at the end
76 virtual void WriteText(const wxString& text);
77 virtual void AppendText(const wxString& text);
78
17665a2b
VZ
79 // apply text attribute to the range of text (only works with richedit
80 // controls)
81 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
82
a1b82138
VZ
83 // translate between the position (which is just an index in the text ctrl
84 // considering all its contents as a single strings) and (x, y) coordinates
85 // which represent column and line.
86 virtual long XYToPosition(long x, long y) const;
0efe5ba7 87 virtual bool PositionToXY(long pos, long *x, long *y) const;
a1b82138
VZ
88
89 virtual void ShowPosition(long pos);
90
c04ec496
VZ
91#ifdef __WXGTK20__
92 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt, long *pos) const;
4aae4a08
RD
93 virtual wxTextCtrlHitTestResult HitTest(const wxPoint& pt,
94 wxTextCoord *col,
95 wxTextCoord *row) const
96 {
97 return wxTextCtrlBase::HitTest(pt, col, row);
98 }
c04ec496
VZ
99#endif // __WXGTK20__
100
a1b82138
VZ
101 // Clipboard operations
102 virtual void Copy();
103 virtual void Cut();
104 virtual void Paste();
7c41ac7b 105
ca8b28f2
JS
106 // Undo/redo
107 virtual void Undo();
108 virtual void Redo();
109
110 virtual bool CanUndo() const;
111 virtual bool CanRedo() const;
112
a1b82138
VZ
113 // Insertion point
114 virtual void SetInsertionPoint(long pos);
115 virtual void SetInsertionPointEnd();
116 virtual long GetInsertionPoint() const;
117 virtual long GetLastPosition() const;
118
119 virtual void SetSelection(long from, long to);
120 virtual void SetEditable(bool editable);
ca8b28f2 121
6b0d8a01 122 virtual bool Enable( bool enable = TRUE );
68df5777 123
a1b82138
VZ
124 // Implementation from now on
125 void OnDropFiles( wxDropFilesEvent &event );
c801d85f 126 void OnChar( wxKeyEvent &event );
7c41ac7b 127
e702ff0f
JS
128 void OnCut(wxCommandEvent& event);
129 void OnCopy(wxCommandEvent& event);
130 void OnPaste(wxCommandEvent& event);
131 void OnUndo(wxCommandEvent& event);
132 void OnRedo(wxCommandEvent& event);
133
134 void OnUpdateCut(wxUpdateUIEvent& event);
135 void OnUpdateCopy(wxUpdateUIEvent& event);
136 void OnUpdatePaste(wxUpdateUIEvent& event);
137 void OnUpdateUndo(wxUpdateUIEvent& event);
138 void OnUpdateRedo(wxUpdateUIEvent& event);
139
17665a2b
VZ
140 bool SetFont(const wxFont& font);
141 bool SetForegroundColour(const wxColour& colour);
142 bool SetBackgroundColour(const wxColour& colour);
68dda785 143
2830bf19 144 GtkWidget* GetConnectWidget();
b4071e91 145 bool IsOwnGtkWindow( GdkWindow *window );
f40fdaa3 146 void DoApplyWidgetStyle(GtkRcStyle *style);
2830bf19 147 void CalculateScrollbar();
65045edd 148 void OnInternalIdle();
c04ec496
VZ
149
150#ifdef __WXGTK20__
151 void SetUpdateFont(bool WXUNUSED(update)) { }
152#else // !__WXGTK20__
153 void SetUpdateFont(bool update) { m_updateFont = update; }
01041145 154 void UpdateFontIfNeeded();
c04ec496 155#endif // __WXGTK20__/!__WXGTK20__
a1b82138 156
0efe5ba7
VZ
157 void SetModified() { m_modified = TRUE; }
158
0cc7251e
VZ
159 // GTK+ textctrl is so dumb that you need to freeze/thaw it manually to
160 // avoid horrible flicker/scrolling back and forth
161 virtual void Freeze();
162 virtual void Thaw();
41b81aed 163
9cd6d737
VZ
164 // textctrl specific scrolling
165 virtual bool ScrollLines(int lines);
166 virtual bool ScrollPages(int pages);
167
ce2f50e3
VZ
168 // implementation only from now on
169
fdca68a6
JS
170 // wxGTK-specific: called recursively by Enable,
171 // to give widgets an oppprtunity to correct their colours after they
172 // have been changed by Enable
173 virtual void OnParentEnable( bool enable ) ;
174
ce2f50e3
VZ
175 // tell the control to ignore next text changed signal
176 void IgnoreNextTextUpdate();
177
178 // should we ignore the changed signal? always resets the flag
179 bool IgnoreTextUpdate();
180
9d522606
RD
181 static wxVisualAttributes
182 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
183
f68586e5
VZ
184protected:
185 virtual wxSize DoGetBestSize() const;
186
01041145
VZ
187 // common part of all ctors
188 void Init();
189
9cd6d737
VZ
190 // get the vertical adjustment, if any, NULL otherwise
191 GtkAdjustment *GetVAdj() const;
192
193 // scroll the control by the given number of pixels, return true if the
194 // scroll position changed
195 bool DoScroll(GtkAdjustment *adj, int diff);
196
9d522606
RD
197 // Widgets that use the style->base colour for the BG colour should
198 // override this and return true.
199 virtual bool UseGTKStyleBase() const { return true; }
200
41b81aed
RR
201#ifdef __WXGTK20__
202 // has the control been frozen by Freeze()?
203 bool IsFrozen() const { return m_frozenness > 0; }
204#endif
205
a1b82138 206private:
01041145
VZ
207 // change the font for everything in this control
208 void ChangeFontGlobally();
209
903f689b 210 GtkWidget *m_text;
2830bf19 211 GtkWidget *m_vScrollbar;
ce2f50e3
VZ
212
213 bool m_modified:1;
214 bool m_vScrollbarVisible:1;
c04ec496 215#ifndef __WXGTK20__
ce2f50e3 216 bool m_updateFont:1;
c04ec496 217#endif // !__WXGTK20__
ce2f50e3 218 bool m_ignoreNextUpdate:1;
a1b82138 219
41b81aed
RR
220#ifdef __WXGTK20__
221 // Our text buffer. Convenient, and holds the buffer while using
222 // a dummy one when m_frozenness > 0
223 GtkTextBuffer *m_buffer;
224
225 // number of calls to Freeze() minus number of calls to Thaw()
226 unsigned int m_frozenness;
227#endif
228
a1b82138
VZ
229 DECLARE_EVENT_TABLE()
230 DECLARE_DYNAMIC_CLASS(wxTextCtrl);
c801d85f
KB
231};
232
233#endif // __GTKTEXTCTRLH__
234