]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/textctrl.h
further untangle generic and native GTK implementations of wxScrollHelper: use the...
[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
d3c7fc99 31 virtual ~wxTextCtrl();
9440c3d0 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;
a1b82138
VZ
46
47 virtual int GetLineLength(long lineNo) const;
48 virtual wxString GetLineText(long lineNo) const;
49 virtual int GetNumberOfLines() const;
50
51 virtual bool IsModified() const;
52 virtual bool IsEditable() const;
53
54 // If the return values from and to are the same, there is no selection.
55 virtual void GetSelection(long* from, long* to) const;
56
57 // operations
58 // ----------
59
60 // editing
61 virtual void Clear();
62 virtual void Replace(long from, long to, const wxString& value);
63 virtual void Remove(long from, long to);
64
3a9fa0d6
VZ
65 // sets/clears the dirty flag
66 virtual void MarkDirty();
a1b82138
VZ
67 virtual void DiscardEdits();
68
d7eee191
VZ
69 virtual void SetMaxLength(unsigned long len);
70
a1b82138
VZ
71 // writing text inserts it at the current position, appending always
72 // inserts it at the end
73 virtual void WriteText(const wxString& text);
74 virtual void AppendText(const wxString& text);
75
17665a2b
VZ
76 // apply text attribute to the range of text (only works with richedit
77 // controls)
78 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
79
a1b82138
VZ
80 // translate between the position (which is just an index in the text ctrl
81 // considering all its contents as a single strings) and (x, y) coordinates
82 // which represent column and line.
83 virtual long XYToPosition(long x, long y) const;
0efe5ba7 84 virtual bool PositionToXY(long pos, long *x, long *y) const;
a1b82138
VZ
85
86 virtual void ShowPosition(long pos);
87
88 // Clipboard operations
89 virtual void Copy();
90 virtual void Cut();
91 virtual void Paste();
7c41ac7b 92
ca8b28f2
JS
93 // Undo/redo
94 virtual void Undo();
95 virtual void Redo();
96
97 virtual bool CanUndo() const;
98 virtual bool CanRedo() const;
99
a1b82138
VZ
100 // Insertion point
101 virtual void SetInsertionPoint(long pos);
102 virtual void SetInsertionPointEnd();
103 virtual long GetInsertionPoint() const;
7d8268a1 104 virtual wxTextPos GetLastPosition() const;
a1b82138
VZ
105
106 virtual void SetSelection(long from, long to);
107 virtual void SetEditable(bool editable);
ca8b28f2 108
47a8a4d5 109 virtual void DoEnable( bool enable );
68df5777 110
a1b82138
VZ
111 // Implementation from now on
112 void OnDropFiles( wxDropFilesEvent &event );
c801d85f 113 void OnChar( wxKeyEvent &event );
7c41ac7b 114
e702ff0f
JS
115 void OnCut(wxCommandEvent& event);
116 void OnCopy(wxCommandEvent& event);
117 void OnPaste(wxCommandEvent& event);
118 void OnUndo(wxCommandEvent& event);
119 void OnRedo(wxCommandEvent& event);
120
121 void OnUpdateCut(wxUpdateUIEvent& event);
122 void OnUpdateCopy(wxUpdateUIEvent& event);
123 void OnUpdatePaste(wxUpdateUIEvent& event);
124 void OnUpdateUndo(wxUpdateUIEvent& event);
125 void OnUpdateRedo(wxUpdateUIEvent& event);
126
17665a2b
VZ
127 bool SetFont(const wxFont& font);
128 bool SetForegroundColour(const wxColour& colour);
129 bool SetBackgroundColour(const wxColour& colour);
68dda785 130
2830bf19 131 GtkWidget* GetConnectWidget();
b4071e91 132 bool IsOwnGtkWindow( GdkWindow *window );
f40fdaa3 133 void DoApplyWidgetStyle(GtkRcStyle *style);
2830bf19 134 void CalculateScrollbar();
65045edd 135 void OnInternalIdle();
c04ec496 136
c04ec496 137 void SetUpdateFont(bool update) { m_updateFont = update; }
01041145 138 void UpdateFontIfNeeded();
a1b82138 139
7d8268a1 140 void SetModified() { m_modified = true; }
0efe5ba7 141
9cd6d737
VZ
142 // textctrl specific scrolling
143 virtual bool ScrollLines(int lines);
144 virtual bool ScrollPages(int pages);
145
ce2f50e3
VZ
146 // implementation only from now on
147
fdca68a6
JS
148 // wxGTK-specific: called recursively by Enable,
149 // to give widgets an oppprtunity to correct their colours after they
150 // have been changed by Enable
47a8a4d5 151 virtual void OnEnabled( bool enabled ) ;
fdca68a6 152
ce2f50e3
VZ
153 // tell the control to ignore next text changed signal
154 void IgnoreNextTextUpdate();
155
156 // should we ignore the changed signal? always resets the flag
157 bool IgnoreTextUpdate();
158
9d522606
RD
159 static wxVisualAttributes
160 GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
7d8268a1 161
f68586e5
VZ
162protected:
163 virtual wxSize DoGetBestSize() const;
164
01041145
VZ
165 // common part of all ctors
166 void Init();
167
17808a75
VZ
168 // overridden wxWindow methods
169 virtual void DoFreeze();
170 virtual void DoThaw();
171
9cd6d737
VZ
172 // get the vertical adjustment, if any, NULL otherwise
173 GtkAdjustment *GetVAdj() const;
174
175 // scroll the control by the given number of pixels, return true if the
176 // scroll position changed
177 bool DoScroll(GtkAdjustment *adj, int diff);
178
9d522606
RD
179 // Widgets that use the style->base colour for the BG colour should
180 // override this and return true.
181 virtual bool UseGTKStyleBase() const { return true; }
182
ee2ec18e 183 virtual void DoSetValue(const wxString &value, int flags = 0);
f6519b40 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