]>
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: |
7c41ac7b VZ |
31 | wxTextCtrl(); |
32 | wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value = "", | |
debe6624 | 33 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, |
6de97a3b RR |
34 | int style = 0, const wxValidator& validator = wxDefaultValidator, |
35 | const wxString &name = wxTextCtrlNameStr ); | |
debe6624 JS |
36 | bool Create( wxWindow *parent, wxWindowID id, const wxString &value = "", |
37 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, | |
6de97a3b RR |
38 | int style = 0, const wxValidator& validator = wxDefaultValidator, |
39 | const wxString &name = wxTextCtrlNameStr ); | |
a1b82138 VZ |
40 | |
41 | // implement base class pure virtuals | |
42 | // ---------------------------------- | |
43 | ||
44 | virtual wxString GetValue() const; | |
45 | virtual void SetValue(const wxString& value); | |
46 | ||
47 | virtual int GetLineLength(long lineNo) const; | |
48 | virtual wxString GetLineText(long lineNo) const; | |
49 | virtual int GetNumberOfLines() const; | |
50 | ||
51 | virtual bool IsModified() const; | |
52 | virtual bool IsEditable() const; | |
53 | ||
54 | // If the return values from and to are the same, there is no selection. | |
55 | virtual void GetSelection(long* from, long* to) const; | |
56 | ||
57 | // operations | |
58 | // ---------- | |
59 | ||
60 | // editing | |
61 | virtual void Clear(); | |
62 | virtual void Replace(long from, long to, const wxString& value); | |
63 | virtual void Remove(long from, long to); | |
64 | ||
a1b82138 VZ |
65 | // clears the dirty flag |
66 | virtual void DiscardEdits(); | |
67 | ||
68 | // writing text inserts it at the current position, appending always | |
69 | // inserts it at the end | |
70 | virtual void WriteText(const wxString& text); | |
71 | virtual void AppendText(const wxString& text); | |
72 | ||
73 | // translate between the position (which is just an index in the text ctrl | |
74 | // considering all its contents as a single strings) and (x, y) coordinates | |
75 | // which represent column and line. | |
76 | virtual long XYToPosition(long x, long y) const; | |
0efe5ba7 | 77 | virtual bool PositionToXY(long pos, long *x, long *y) const; |
a1b82138 VZ |
78 | |
79 | virtual void ShowPosition(long pos); | |
80 | ||
81 | // Clipboard operations | |
82 | virtual void Copy(); | |
83 | virtual void Cut(); | |
84 | virtual void Paste(); | |
7c41ac7b | 85 | |
ca8b28f2 JS |
86 | virtual bool CanCopy() const; |
87 | virtual bool CanCut() const; | |
88 | virtual bool CanPaste() const; | |
89 | ||
90 | // Undo/redo | |
91 | virtual void Undo(); | |
92 | virtual void Redo(); | |
93 | ||
94 | virtual bool CanUndo() const; | |
95 | virtual bool CanRedo() const; | |
96 | ||
a1b82138 VZ |
97 | // Insertion point |
98 | virtual void SetInsertionPoint(long pos); | |
99 | virtual void SetInsertionPointEnd(); | |
100 | virtual long GetInsertionPoint() const; | |
101 | virtual long GetLastPosition() const; | |
102 | ||
103 | virtual void SetSelection(long from, long to); | |
104 | virtual void SetEditable(bool editable); | |
ca8b28f2 | 105 | |
a1b82138 VZ |
106 | // Implementation from now on |
107 | void OnDropFiles( wxDropFilesEvent &event ); | |
c801d85f | 108 | void OnChar( wxKeyEvent &event ); |
7c41ac7b | 109 | |
e702ff0f JS |
110 | void OnCut(wxCommandEvent& event); |
111 | void OnCopy(wxCommandEvent& event); | |
112 | void OnPaste(wxCommandEvent& event); | |
113 | void OnUndo(wxCommandEvent& event); | |
114 | void OnRedo(wxCommandEvent& event); | |
115 | ||
116 | void OnUpdateCut(wxUpdateUIEvent& event); | |
117 | void OnUpdateCopy(wxUpdateUIEvent& event); | |
118 | void OnUpdatePaste(wxUpdateUIEvent& event); | |
119 | void OnUpdateUndo(wxUpdateUIEvent& event); | |
120 | void OnUpdateRedo(wxUpdateUIEvent& event); | |
121 | ||
f03fc89f VZ |
122 | bool SetFont( const wxFont &font ); |
123 | bool SetForegroundColour(const wxColour &colour); | |
124 | bool SetBackgroundColour(const wxColour &colour); | |
68dda785 | 125 | |
2830bf19 | 126 | GtkWidget* GetConnectWidget(); |
b4071e91 | 127 | bool IsOwnGtkWindow( GdkWindow *window ); |
58614078 | 128 | void ApplyWidgetStyle(); |
2830bf19 | 129 | void CalculateScrollbar(); |
a1b82138 | 130 | |
0efe5ba7 VZ |
131 | void SetModified() { m_modified = TRUE; } |
132 | ||
a1b82138 | 133 | private: |
903f689b RR |
134 | bool m_modified; |
135 | GtkWidget *m_text; | |
2830bf19 RR |
136 | GtkWidget *m_vScrollbar; |
137 | bool m_vScrollbarVisible; | |
a1b82138 VZ |
138 | |
139 | DECLARE_EVENT_TABLE() | |
140 | DECLARE_DYNAMIC_CLASS(wxTextCtrl); | |
c801d85f KB |
141 | }; |
142 | ||
143 | #endif // __GTKTEXTCTRLH__ | |
144 |