]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/textctrl.h
b480306b089d1f40c93a2aae5dc3565fd0d28ec4
[wxWidgets.git] / include / wx / gtk / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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
16 #endif
17
18 //-----------------------------------------------------------------------------
19 // classes
20 //-----------------------------------------------------------------------------
21
22 class wxTextCtrl;
23
24 //-----------------------------------------------------------------------------
25 // wxTextCtrl
26 //-----------------------------------------------------------------------------
27
28 class wxTextCtrl: public wxTextCtrlBase
29 {
30 public:
31 wxTextCtrl();
32 wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value = "",
33 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
34 int style = 0, const wxValidator& validator = wxDefaultValidator,
35 const wxString &name = wxTextCtrlNameStr );
36 bool Create( wxWindow *parent, wxWindowID id, const wxString &value = "",
37 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
38 int style = 0, const wxValidator& validator = wxDefaultValidator,
39 const wxString &name = wxTextCtrlNameStr );
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
65 // load/save the controls contents from/to the file
66 virtual bool LoadFile(const wxString& file);
67 virtual bool SaveFile(const wxString& file);
68
69 // clears the dirty flag
70 virtual void DiscardEdits();
71
72 // writing text inserts it at the current position, appending always
73 // inserts it at the end
74 virtual void WriteText(const wxString& text);
75 virtual void AppendText(const wxString& text);
76
77 // translate between the position (which is just an index in the text ctrl
78 // considering all its contents as a single strings) and (x, y) coordinates
79 // which represent column and line.
80 virtual long XYToPosition(long x, long y) const;
81 virtual void PositionToXY(long pos, long *x, long *y) const;
82
83 virtual void ShowPosition(long pos);
84
85 // Clipboard operations
86 virtual void Copy();
87 virtual void Cut();
88 virtual void Paste();
89
90 virtual bool CanCopy() const;
91 virtual bool CanCut() const;
92 virtual bool CanPaste() const;
93
94 // Undo/redo
95 virtual void Undo();
96 virtual void Redo();
97
98 virtual bool CanUndo() const;
99 virtual bool CanRedo() const;
100
101 // Insertion point
102 virtual void SetInsertionPoint(long pos);
103 virtual void SetInsertionPointEnd();
104 virtual long GetInsertionPoint() const;
105 virtual long GetLastPosition() const;
106
107 virtual void SetSelection(long from, long to);
108 virtual void SetEditable(bool editable);
109
110 // Implementation from now on
111 void OnDropFiles( wxDropFilesEvent &event );
112 void OnChar( wxKeyEvent &event );
113
114 void OnCut(wxCommandEvent& event);
115 void OnCopy(wxCommandEvent& event);
116 void OnPaste(wxCommandEvent& event);
117 void OnUndo(wxCommandEvent& event);
118 void OnRedo(wxCommandEvent& event);
119
120 void OnUpdateCut(wxUpdateUIEvent& event);
121 void OnUpdateCopy(wxUpdateUIEvent& event);
122 void OnUpdatePaste(wxUpdateUIEvent& event);
123 void OnUpdateUndo(wxUpdateUIEvent& event);
124 void OnUpdateRedo(wxUpdateUIEvent& event);
125
126 bool SetFont( const wxFont &font );
127 bool SetForegroundColour(const wxColour &colour);
128 bool SetBackgroundColour(const wxColour &colour);
129
130 GtkWidget* GetConnectWidget();
131 bool IsOwnGtkWindow( GdkWindow *window );
132 void ApplyWidgetStyle();
133 void CalculateScrollbar();
134
135 private:
136 bool m_modified;
137 GtkWidget *m_text;
138 GtkWidget *m_vScrollbar;
139 bool m_vScrollbarVisible;
140
141 DECLARE_EVENT_TABLE()
142 DECLARE_DYNAMIC_CLASS(wxTextCtrl);
143 };
144
145 #endif // __GTKTEXTCTRLH__
146