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