]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/textctrl.h
Work on streams of all sorts. More to come.
[wxWidgets.git] / include / wx / gtk1 / 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
12 #ifndef __GTKTEXTCTRLH__
13 #define __GTKTEXTCTRLH__
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/object.h"
21 #include "wx/string.h"
22 #include "wx/control.h"
23
24 #if wxUSE_STD_IOSTREAM
25
26 #if wxUSE_IOSTREAMH
27 #include <iostream.h>
28 #else
29 #include <iostream>
30 #endif
31
32 #endif
33
34 //-----------------------------------------------------------------------------
35 // classes
36 //-----------------------------------------------------------------------------
37
38 class wxTextCtrl;
39
40 //-----------------------------------------------------------------------------
41 // global data
42 //-----------------------------------------------------------------------------
43
44 extern const char *wxTextCtrlNameStr;
45
46 //-----------------------------------------------------------------------------
47 // wxTextCtrl
48 //-----------------------------------------------------------------------------
49
50 #if wxUSE_STD_IOSTREAM
51 class wxTextCtrl: public wxControl, public streambuf
52 #else
53 class wxTextCtrl: public wxControl
54 #endif
55 {
56 DECLARE_EVENT_TABLE()
57 DECLARE_DYNAMIC_CLASS(wxTextCtrl);
58
59 public:
60 wxTextCtrl();
61 wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value = "",
62 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
63 int style = 0, const wxValidator& validator = wxDefaultValidator,
64 const wxString &name = wxTextCtrlNameStr );
65 bool Create( wxWindow *parent, wxWindowID id, const wxString &value = "",
66 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
67 int style = 0, const wxValidator& validator = wxDefaultValidator,
68 const wxString &name = wxTextCtrlNameStr );
69 wxString GetValue() const;
70 void SetValue( const wxString &value );
71 void WriteText( const wxString &text );
72 void AppendText( const wxString &text );
73
74 bool LoadFile( const wxString &file );
75 bool SaveFile( const wxString &file );
76 bool IsModified() const { return m_modified; }
77 void SetModified() { m_modified = TRUE; }
78 void DiscardEdits() { m_modified = FALSE; }
79 wxString GetLineText( long lineNo ) const;
80 void OnDropFiles( wxDropFilesEvent &event );
81 long PositionToXY( long pos, long *x, long *y ) const;
82 long XYToPosition( long x, long y ) const;
83 int GetLineLength(long lineNo) const;
84 int GetNumberOfLines() const;
85 virtual void SetInsertionPoint( long pos );
86 virtual void SetInsertionPointEnd();
87 virtual void SetEditable( bool editable );
88 virtual void SetSelection( long from, long to );
89 void ShowPosition( long pos );
90 virtual long GetInsertionPoint() const;
91 virtual long GetLastPosition() const;
92 virtual void Remove( long from, long to );
93 virtual void Replace( long from, long to, const wxString &value );
94 void Cut();
95 void Copy();
96 void Paste();
97 void Clear();
98
99 virtual bool CanCopy() const;
100 virtual bool CanCut() const;
101 virtual bool CanPaste() const;
102
103 // Undo/redo
104 virtual void Undo();
105 virtual void Redo();
106
107 virtual bool CanUndo() const;
108 virtual bool CanRedo() const;
109
110 // If the return values from and to are the same, there is no
111 // selection.
112 virtual void GetSelection(long* from, long* to) const;
113 virtual bool IsEditable() const ;
114
115 void OnChar( wxKeyEvent &event );
116
117 void OnCut(wxCommandEvent& event);
118 void OnCopy(wxCommandEvent& event);
119 void OnPaste(wxCommandEvent& event);
120 void OnUndo(wxCommandEvent& event);
121 void OnRedo(wxCommandEvent& event);
122
123 void OnUpdateCut(wxUpdateUIEvent& event);
124 void OnUpdateCopy(wxUpdateUIEvent& event);
125 void OnUpdatePaste(wxUpdateUIEvent& event);
126 void OnUpdateUndo(wxUpdateUIEvent& event);
127 void OnUpdateRedo(wxUpdateUIEvent& event);
128
129 #if wxUSE_STD_IOSTREAM
130 int overflow(int i);
131 int sync();
132 int underflow();
133 #endif
134
135 wxTextCtrl& operator<<(const wxString& s);
136 wxTextCtrl& operator<<(int i);
137 wxTextCtrl& operator<<(long i);
138 wxTextCtrl& operator<<(float f);
139 wxTextCtrl& operator<<(double d);
140 wxTextCtrl& operator<<(const char c);
141
142 bool SetFont( const wxFont &font );
143 bool SetForegroundColour(const wxColour &colour);
144 bool SetBackgroundColour(const wxColour &colour);
145
146 // implementation
147
148 GtkWidget* GetConnectWidget();
149 bool IsOwnGtkWindow( GdkWindow *window );
150 void ApplyWidgetStyle();
151 void CalculateScrollbar();
152
153 private:
154
155 bool m_modified;
156 GtkWidget *m_text;
157 GtkWidget *m_vScrollbar;
158 bool m_vScrollbarVisible;
159 };
160
161 #endif // __GTKTEXTCTRLH__
162
163