]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: textctrl.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
5 | // Created: 01/02/97 | |
7c41ac7b | 6 | // Id: $Id$ |
c801d85f | 7 | // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem |
7c41ac7b | 8 | // Licence: wxWindows licence |
c801d85f KB |
9 | ///////////////////////////////////////////////////////////////////////////// |
10 | ||
c801d85f KB |
11 | #ifndef __GTKTEXTCTRLH__ |
12 | #define __GTKTEXTCTRLH__ | |
13 | ||
14 | #ifdef __GNUG__ | |
bf3e0fbd | 15 | #pragma interface "textctrl.h" |
f5abe911 RR |
16 | #endif |
17 | ||
c801d85f KB |
18 | //----------------------------------------------------------------------------- |
19 | // classes | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
22 | class wxTextCtrl; | |
23 | ||
24 | //----------------------------------------------------------------------------- | |
a1b82138 | 25 | // wxTextCtrl |
c801d85f KB |
26 | //----------------------------------------------------------------------------- |
27 | ||
a1b82138 | 28 | class wxTextCtrl: public wxTextCtrlBase |
c801d85f | 29 | { |
a1b82138 | 30 | public: |
01041145 | 31 | wxTextCtrl() { Init(); } |
13111b2a VZ |
32 | wxTextCtrl(wxWindow *parent, |
33 | wxWindowID id, | |
34 | const wxString &value = wxEmptyString, | |
35 | const wxPoint &pos = wxDefaultPosition, | |
36 | const wxSize &size = wxDefaultSize, | |
37 | long style = 0, | |
38 | const wxValidator& validator = wxDefaultValidator, | |
39 | const wxString &name = wxTextCtrlNameStr); | |
40 | ||
41 | bool Create(wxWindow *parent, | |
42 | wxWindowID id, | |
43 | const wxString &value = wxEmptyString, | |
44 | const wxPoint &pos = wxDefaultPosition, | |
45 | const wxSize &size = wxDefaultSize, | |
46 | long style = 0, | |
47 | const wxValidator& validator = wxDefaultValidator, | |
48 | const wxString &name = wxTextCtrlNameStr); | |
a1b82138 VZ |
49 | |
50 | // implement base class pure virtuals | |
51 | // ---------------------------------- | |
52 | ||
53 | virtual wxString GetValue() const; | |
54 | virtual void SetValue(const wxString& value); | |
55 | ||
56 | virtual int GetLineLength(long lineNo) const; | |
57 | virtual wxString GetLineText(long lineNo) const; | |
58 | virtual int GetNumberOfLines() const; | |
59 | ||
60 | virtual bool IsModified() const; | |
61 | virtual bool IsEditable() const; | |
62 | ||
63 | // If the return values from and to are the same, there is no selection. | |
64 | virtual void GetSelection(long* from, long* to) const; | |
65 | ||
66 | // operations | |
67 | // ---------- | |
68 | ||
69 | // editing | |
70 | virtual void Clear(); | |
71 | virtual void Replace(long from, long to, const wxString& value); | |
72 | virtual void Remove(long from, long to); | |
73 | ||
a1b82138 VZ |
74 | // clears the dirty flag |
75 | virtual void DiscardEdits(); | |
76 | ||
77 | // writing text inserts it at the current position, appending always | |
78 | // inserts it at the end | |
79 | virtual void WriteText(const wxString& text); | |
80 | virtual void AppendText(const wxString& text); | |
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; | |
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 | virtual bool CanCopy() const; |
96 | virtual bool CanCut() const; | |
97 | virtual bool CanPaste() const; | |
98 | ||
99 | // Undo/redo | |
100 | virtual void Undo(); | |
101 | virtual void Redo(); | |
102 | ||
103 | virtual bool CanUndo() const; | |
104 | virtual bool CanRedo() const; | |
105 | ||
a1b82138 VZ |
106 | // Insertion point |
107 | virtual void SetInsertionPoint(long pos); | |
108 | virtual void SetInsertionPointEnd(); | |
109 | virtual long GetInsertionPoint() const; | |
110 | virtual long GetLastPosition() const; | |
111 | ||
112 | virtual void SetSelection(long from, long to); | |
113 | virtual void SetEditable(bool editable); | |
ca8b28f2 | 114 | |
68df5777 RR |
115 | virtual bool Enable( bool enable ); |
116 | ||
a1b82138 VZ |
117 | // Implementation from now on |
118 | void OnDropFiles( wxDropFilesEvent &event ); | |
c801d85f | 119 | void OnChar( wxKeyEvent &event ); |
7c41ac7b | 120 | |
e702ff0f JS |
121 | void OnCut(wxCommandEvent& event); |
122 | void OnCopy(wxCommandEvent& event); | |
123 | void OnPaste(wxCommandEvent& event); | |
124 | void OnUndo(wxCommandEvent& event); | |
125 | void OnRedo(wxCommandEvent& event); | |
126 | ||
127 | void OnUpdateCut(wxUpdateUIEvent& event); | |
128 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
129 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
130 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
131 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
132 | ||
f03fc89f | 133 | bool SetFont( const wxFont &font ); |
f03fc89f | 134 | bool SetBackgroundColour(const wxColour &colour); |
68dda785 | 135 | |
2830bf19 | 136 | GtkWidget* GetConnectWidget(); |
b4071e91 | 137 | bool IsOwnGtkWindow( GdkWindow *window ); |
58614078 | 138 | void ApplyWidgetStyle(); |
2830bf19 | 139 | void CalculateScrollbar(); |
65045edd | 140 | void OnInternalIdle(); |
01041145 | 141 | void UpdateFontIfNeeded(); |
a1b82138 | 142 | |
0efe5ba7 VZ |
143 | void SetModified() { m_modified = TRUE; } |
144 | ||
fdca68a6 JS |
145 | // wxGTK-specific: called recursively by Enable, |
146 | // to give widgets an oppprtunity to correct their colours after they | |
147 | // have been changed by Enable | |
148 | virtual void OnParentEnable( bool enable ) ; | |
149 | ||
f68586e5 VZ |
150 | protected: |
151 | virtual wxSize DoGetBestSize() const; | |
152 | ||
01041145 VZ |
153 | // common part of all ctors |
154 | void Init(); | |
155 | ||
a1b82138 | 156 | private: |
01041145 VZ |
157 | // change the font for everything in this control |
158 | void ChangeFontGlobally(); | |
159 | ||
903f689b RR |
160 | bool m_modified; |
161 | GtkWidget *m_text; | |
2830bf19 RR |
162 | GtkWidget *m_vScrollbar; |
163 | bool m_vScrollbarVisible; | |
01041145 | 164 | bool m_updateFont; |
a1b82138 VZ |
165 | |
166 | DECLARE_EVENT_TABLE() | |
167 | DECLARE_DYNAMIC_CLASS(wxTextCtrl); | |
c801d85f KB |
168 | }; |
169 | ||
170 | #endif // __GTKTEXTCTRLH__ | |
171 |