]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/textctrl.h
wxUSE_NEW_GRID is no longer used
[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
7c41ac7b 8// Licence: wxWindows licence
c801d85f
KB
9/////////////////////////////////////////////////////////////////////////////
10
c801d85f
KB
11#ifndef __GTKTEXTCTRLH__
12#define __GTKTEXTCTRLH__
13
ab7ce33c 14#if defined(__GNUG__) && !defined(__APPLE__)
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
a1b82138
VZ
68 // clears the dirty flag
69 virtual void DiscardEdits();
70
d7eee191
VZ
71 virtual void SetMaxLength(unsigned long len);
72
a1b82138
VZ
73 // writing text inserts it at the current position, appending always
74 // inserts it at the end
75 virtual void WriteText(const wxString& text);
76 virtual void AppendText(const wxString& text);
77
17665a2b
VZ
78 // apply text attribute to the range of text (only works with richedit
79 // controls)
80 virtual bool SetStyle(long start, long end, const wxTextAttr& style);
81
a1b82138
VZ
82 // translate between the position (which is just an index in the text ctrl
83 // considering all its contents as a single strings) and (x, y) coordinates
84 // which represent column and line.
85 virtual long XYToPosition(long x, long y) const;
0efe5ba7 86 virtual bool PositionToXY(long pos, long *x, long *y) const;
a1b82138
VZ
87
88 virtual void ShowPosition(long pos);
89
90 // Clipboard operations
91 virtual void Copy();
92 virtual void Cut();
93 virtual void Paste();
7c41ac7b 94
ca8b28f2
JS
95 // Undo/redo
96 virtual void Undo();
97 virtual void Redo();
98
99 virtual bool CanUndo() const;
100 virtual bool CanRedo() const;
101
a1b82138
VZ
102 // Insertion point
103 virtual void SetInsertionPoint(long pos);
104 virtual void SetInsertionPointEnd();
105 virtual long GetInsertionPoint() const;
106 virtual long GetLastPosition() const;
107
108 virtual void SetSelection(long from, long to);
109 virtual void SetEditable(bool editable);
ca8b28f2 110
6b0d8a01 111 virtual bool Enable( bool enable = TRUE );
68df5777 112
a1b82138
VZ
113 // Implementation from now on
114 void OnDropFiles( wxDropFilesEvent &event );
c801d85f 115 void OnChar( wxKeyEvent &event );
7c41ac7b 116
e702ff0f
JS
117 void OnCut(wxCommandEvent& event);
118 void OnCopy(wxCommandEvent& event);
119 void OnPaste(wxCommandEvent& event);
120 void OnUndo(wxCommandEvent& event);
121 void OnRedo(wxCommandEvent& event);
122
123 void OnUpdateCut(wxUpdateUIEvent& event);
124 void OnUpdateCopy(wxUpdateUIEvent& event);
125 void OnUpdatePaste(wxUpdateUIEvent& event);
126 void OnUpdateUndo(wxUpdateUIEvent& event);
127 void OnUpdateRedo(wxUpdateUIEvent& event);
128
17665a2b
VZ
129 bool SetFont(const wxFont& font);
130 bool SetForegroundColour(const wxColour& colour);
131 bool SetBackgroundColour(const wxColour& colour);
68dda785 132
2830bf19 133 GtkWidget* GetConnectWidget();
b4071e91 134 bool IsOwnGtkWindow( GdkWindow *window );
58614078 135 void ApplyWidgetStyle();
2830bf19 136 void CalculateScrollbar();
65045edd 137 void OnInternalIdle();
01041145 138 void UpdateFontIfNeeded();
a1b82138 139
0efe5ba7
VZ
140 void SetModified() { m_modified = TRUE; }
141
0cc7251e
VZ
142 // GTK+ textctrl is so dumb that you need to freeze/thaw it manually to
143 // avoid horrible flicker/scrolling back and forth
144 virtual void Freeze();
145 virtual void Thaw();
146
9cd6d737
VZ
147 // textctrl specific scrolling
148 virtual bool ScrollLines(int lines);
149 virtual bool ScrollPages(int pages);
150
ce2f50e3
VZ
151 // implementation only from now on
152
fdca68a6
JS
153 // wxGTK-specific: called recursively by Enable,
154 // to give widgets an oppprtunity to correct their colours after they
155 // have been changed by Enable
156 virtual void OnParentEnable( bool enable ) ;
157
ce2f50e3
VZ
158 // tell the control to ignore next text changed signal
159 void IgnoreNextTextUpdate();
160
161 // should we ignore the changed signal? always resets the flag
162 bool IgnoreTextUpdate();
163
f68586e5
VZ
164protected:
165 virtual wxSize DoGetBestSize() const;
166
01041145
VZ
167 // common part of all ctors
168 void Init();
169
9cd6d737
VZ
170 // get the vertical adjustment, if any, NULL otherwise
171 GtkAdjustment *GetVAdj() const;
172
173 // scroll the control by the given number of pixels, return true if the
174 // scroll position changed
175 bool DoScroll(GtkAdjustment *adj, int diff);
176
a1b82138 177private:
01041145
VZ
178 // change the font for everything in this control
179 void ChangeFontGlobally();
180
903f689b 181 GtkWidget *m_text;
2830bf19 182 GtkWidget *m_vScrollbar;
ce2f50e3
VZ
183
184 bool m_modified:1;
185 bool m_vScrollbarVisible:1;
186 bool m_updateFont:1;
187 bool m_ignoreNextUpdate:1;
a1b82138
VZ
188
189 DECLARE_EVENT_TABLE()
190 DECLARE_DYNAMIC_CLASS(wxTextCtrl);
c801d85f
KB
191};
192
193#endif // __GTKTEXTCTRLH__
194