]>
Commit | Line | Data |
---|---|---|
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 | #else | |
33 | ||
34 | #define NO_TEXT_WINDOW_STREAM | |
35 | ||
36 | #endif | |
37 | ||
38 | //----------------------------------------------------------------------------- | |
39 | // classes | |
40 | //----------------------------------------------------------------------------- | |
41 | ||
42 | class wxTextCtrl; | |
43 | ||
44 | //----------------------------------------------------------------------------- | |
45 | // global data | |
46 | //----------------------------------------------------------------------------- | |
47 | ||
48 | extern const char *wxTextCtrlNameStr; | |
49 | ||
50 | //----------------------------------------------------------------------------- | |
51 | // wxTextCtrl | |
52 | //----------------------------------------------------------------------------- | |
53 | ||
54 | #ifndef NO_TEXT_WINDOW_STREAM | |
55 | class wxTextCtrl: public wxControl, public streambuf | |
56 | #else | |
57 | class wxTextCtrl: public wxControl | |
58 | #endif | |
59 | { | |
60 | DECLARE_EVENT_TABLE() | |
61 | DECLARE_DYNAMIC_CLASS(wxTextCtrl); | |
62 | ||
63 | public: | |
64 | wxTextCtrl(); | |
65 | wxTextCtrl( 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 | bool Create( wxWindow *parent, wxWindowID id, const wxString &value = "", | |
70 | const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, | |
71 | int style = 0, const wxValidator& validator = wxDefaultValidator, | |
72 | const wxString &name = wxTextCtrlNameStr ); | |
73 | wxString GetValue() const; | |
74 | void SetValue( const wxString &value ); | |
75 | void WriteText( const wxString &text ); | |
76 | void AppendText( const wxString &text ); | |
77 | ||
78 | bool LoadFile( const wxString &file ); | |
79 | bool SaveFile( const wxString &file ); | |
80 | bool IsModified() const { return m_modified; } | |
81 | void SetModified() { m_modified = TRUE; } | |
82 | void DiscardEdits() { m_modified = FALSE; } | |
83 | wxString GetLineText( long lineNo ) const; | |
84 | void OnDropFiles( wxDropFilesEvent &event ); | |
85 | long PositionToXY( long pos, long *x, long *y ) const; | |
86 | long XYToPosition( long x, long y ) const; | |
87 | int GetLineLength(long lineNo) const; | |
88 | int GetNumberOfLines() const; | |
89 | virtual void SetInsertionPoint( long pos ); | |
90 | virtual void SetInsertionPointEnd(); | |
91 | virtual void SetEditable( bool editable ); | |
92 | virtual void SetSelection( long from, long to ); | |
93 | void ShowPosition( long pos ); | |
94 | virtual long GetInsertionPoint() const; | |
95 | virtual long GetLastPosition() const; | |
96 | virtual void Remove( long from, long to ); | |
97 | virtual void Replace( long from, long to, const wxString &value ); | |
98 | void Cut(); | |
99 | void Copy(); | |
100 | void Paste(); | |
101 | void Clear(); | |
102 | ||
103 | void OnChar( wxKeyEvent &event ); | |
104 | ||
105 | #ifndef NO_TEXT_WINDOW_STREAM | |
106 | int overflow(int i); | |
107 | int sync(); | |
108 | int underflow(); | |
109 | ||
110 | wxTextCtrl& operator<<(const wxString& s); | |
111 | wxTextCtrl& operator<<(int i); | |
112 | wxTextCtrl& operator<<(long i); | |
113 | wxTextCtrl& operator<<(float f); | |
114 | wxTextCtrl& operator<<(double d); | |
115 | wxTextCtrl& operator<<(const char c); | |
116 | #endif | |
117 | ||
118 | void SetFont( const wxFont &font ); | |
119 | void SetForegroundColour(const wxColour &colour); | |
120 | void SetBackgroundColour(const wxColour &colour); | |
121 | ||
122 | // implementation | |
123 | ||
124 | GtkWidget* GetConnectWidget(); | |
125 | bool IsOwnGtkWindow( GdkWindow *window ); | |
126 | void ApplyWidgetStyle(); | |
127 | void CalculateScrollbar(); | |
128 | ||
129 | private: | |
130 | ||
131 | bool m_modified; | |
132 | GtkWidget *m_text; | |
133 | GtkWidget *m_vScrollbar; | |
134 | bool m_vScrollbarVisible; | |
135 | }; | |
136 | ||
137 | #endif // __GTKTEXTCTRLH__ | |
138 | ||
139 |