]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/textctrl.h
added default parameter values to the overloaded Show() and Enable() versions
[wxWidgets.git] / include / wx / gtk / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/textctrl.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id: $Id$
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef __GTKTEXTCTRLH__
12 #define __GTKTEXTCTRLH__
13
14 #ifdef __GNUG__
15 #pragma interface "textctrl.h"
16 #endif
17
18 //-----------------------------------------------------------------------------
19 // wxTextCtrl
20 //-----------------------------------------------------------------------------
21
22 class wxTextCtrl: public wxTextCtrlBase
23 {
24 public:
25 wxTextCtrl() { Init(); }
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);
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
68 // clears the dirty flag
69 virtual void DiscardEdits();
70
71 virtual void SetMaxLength(unsigned long len);
72
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
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
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;
86 virtual bool PositionToXY(long pos, long *x, long *y) const;
87
88 virtual void ShowPosition(long pos);
89
90 // Clipboard operations
91 virtual void Copy();
92 virtual void Cut();
93 virtual void Paste();
94
95 // Undo/redo
96 virtual void Undo();
97 virtual void Redo();
98
99 virtual bool CanUndo() const;
100 virtual bool CanRedo() const;
101
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);
110
111 virtual bool Enable( bool enable = TRUE );
112
113 // Implementation from now on
114 void OnDropFiles( wxDropFilesEvent &event );
115 void OnChar( wxKeyEvent &event );
116
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
129 bool SetFont(const wxFont& font);
130 bool SetForegroundColour(const wxColour& colour);
131 bool SetBackgroundColour(const wxColour& colour);
132
133 GtkWidget* GetConnectWidget();
134 bool IsOwnGtkWindow( GdkWindow *window );
135 void ApplyWidgetStyle();
136 void CalculateScrollbar();
137 void OnInternalIdle();
138 void UpdateFontIfNeeded();
139
140 void SetModified() { m_modified = TRUE; }
141
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
147 // textctrl specific scrolling
148 virtual bool ScrollLines(int lines);
149 virtual bool ScrollPages(int pages);
150
151 // implementation only from now on
152
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
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
164 protected:
165 virtual wxSize DoGetBestSize() const;
166
167 // common part of all ctors
168 void Init();
169
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
177 private:
178 // change the font for everything in this control
179 void ChangeFontGlobally();
180
181 GtkWidget *m_text;
182 GtkWidget *m_vScrollbar;
183
184 bool m_modified:1;
185 bool m_vScrollbarVisible:1;
186 bool m_updateFont:1;
187 bool m_ignoreNextUpdate:1;
188
189 DECLARE_EVENT_TABLE()
190 DECLARE_DYNAMIC_CLASS(wxTextCtrl);
191 };
192
193 #endif // __GTKTEXTCTRLH__
194