]>
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 | ||
a0e55920 | 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 | ||
ce2f50e3 VZ |
146 | // tell the control to ignore next text changed signal |
147 | void IgnoreNextTextUpdate(); | |
148 | ||
149 | // should we ignore the changed signal? always resets the flag | |
150 | bool IgnoreTextUpdate(); | |
151 | ||
9d522606 RD |
152 | static wxVisualAttributes |
153 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
7d8268a1 | 154 | |
f68586e5 VZ |
155 | protected: |
156 | virtual wxSize DoGetBestSize() const; | |
157 | ||
01041145 VZ |
158 | // common part of all ctors |
159 | void Init(); | |
160 | ||
17808a75 VZ |
161 | // overridden wxWindow methods |
162 | virtual void DoFreeze(); | |
163 | virtual void DoThaw(); | |
164 | ||
9cd6d737 VZ |
165 | // get the vertical adjustment, if any, NULL otherwise |
166 | GtkAdjustment *GetVAdj() const; | |
167 | ||
168 | // scroll the control by the given number of pixels, return true if the | |
169 | // scroll position changed | |
170 | bool DoScroll(GtkAdjustment *adj, int diff); | |
171 | ||
9d522606 RD |
172 | // Widgets that use the style->base colour for the BG colour should |
173 | // override this and return true. | |
174 | virtual bool UseGTKStyleBase() const { return true; } | |
175 | ||
ee2ec18e | 176 | virtual void DoSetValue(const wxString &value, int flags = 0); |
55410bb4 | 177 | virtual wxString DoGetValue() const; |
f6519b40 | 178 | |
a1b82138 | 179 | private: |
01041145 VZ |
180 | // change the font for everything in this control |
181 | void ChangeFontGlobally(); | |
182 | ||
903f689b | 183 | GtkWidget *m_text; |
2830bf19 | 184 | GtkWidget *m_vScrollbar; |
ce2f50e3 VZ |
185 | |
186 | bool m_modified:1; | |
187 | bool m_vScrollbarVisible:1; | |
188 | bool m_updateFont:1; | |
189 | bool m_ignoreNextUpdate:1; | |
a1b82138 VZ |
190 | |
191 | DECLARE_EVENT_TABLE() | |
777105f2 | 192 | DECLARE_DYNAMIC_CLASS(wxTextCtrl) |
c801d85f KB |
193 | }; |
194 | ||
195 | #endif // __GTKTEXTCTRLH__ | |
196 |