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