]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/textctrl.h
Wrappers for *ToText
[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
91 // Clipboard operations
92 virtual void Copy();
93 virtual void Cut();
94 virtual void Paste();
7c41ac7b 95
ca8b28f2
JS
96 // Undo/redo
97 virtual void Undo();
98 virtual void Redo();
99
100 virtual bool CanUndo() const;
101 virtual bool CanRedo() const;
102
a1b82138
VZ
103 // Insertion point
104 virtual void SetInsertionPoint(long pos);
105 virtual void SetInsertionPointEnd();
106 virtual long GetInsertionPoint() const;
107 virtual long GetLastPosition() const;
108
109 virtual void SetSelection(long from, long to);
110 virtual void SetEditable(bool editable);
ca8b28f2 111
6b0d8a01 112 virtual bool Enable( bool enable = TRUE );
68df5777 113
a1b82138
VZ
114 // Implementation from now on
115 void OnDropFiles( wxDropFilesEvent &event );
c801d85f 116 void OnChar( wxKeyEvent &event );
7c41ac7b 117
e702ff0f
JS
118 void OnCut(wxCommandEvent& event);
119 void OnCopy(wxCommandEvent& event);
120 void OnPaste(wxCommandEvent& event);
121 void OnUndo(wxCommandEvent& event);
122 void OnRedo(wxCommandEvent& event);
123
124 void OnUpdateCut(wxUpdateUIEvent& event);
125 void OnUpdateCopy(wxUpdateUIEvent& event);
126 void OnUpdatePaste(wxUpdateUIEvent& event);
127 void OnUpdateUndo(wxUpdateUIEvent& event);
128 void OnUpdateRedo(wxUpdateUIEvent& event);
129
17665a2b
VZ
130 bool SetFont(const wxFont& font);
131 bool SetForegroundColour(const wxColour& colour);
132 bool SetBackgroundColour(const wxColour& colour);
68dda785 133
2830bf19 134 GtkWidget* GetConnectWidget();
b4071e91 135 bool IsOwnGtkWindow( GdkWindow *window );
f40fdaa3 136 void DoApplyWidgetStyle(GtkRcStyle *style);
2830bf19 137 void CalculateScrollbar();
65045edd 138 void OnInternalIdle();
01041145 139 void UpdateFontIfNeeded();
a1b82138 140
0efe5ba7
VZ
141 void SetModified() { m_modified = TRUE; }
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();
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);
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()
198 DECLARE_DYNAMIC_CLASS(wxTextCtrl);
c801d85f
KB
199};
200
201#endif // __GTKTEXTCTRLH__
202