]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/textctrl.h
windows emit wxCreateWindowEvent
[wxWidgets.git] / include / wx / gtk / textctrl.h
CommitLineData
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
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
4bf78aae 24#if wxUSE_STD_IOSTREAM
f5abe911 25
47d67540 26#if wxUSE_IOSTREAMH
c801d85f
KB
27#include <iostream.h>
28#else
29#include <iostream>
30#endif
31
f5abe911
RR
32#else
33
34#define NO_TEXT_WINDOW_STREAM
35
36#endif
37
c801d85f
KB
38//-----------------------------------------------------------------------------
39// classes
40//-----------------------------------------------------------------------------
41
42class wxTextCtrl;
43
44//-----------------------------------------------------------------------------
45// global data
46//-----------------------------------------------------------------------------
47
48extern const char *wxTextCtrlNameStr;
49
50//-----------------------------------------------------------------------------
51// wxTextCtrl
52//-----------------------------------------------------------------------------
53
f5abe911 54#ifndef NO_TEXT_WINDOW_STREAM
c801d85f 55class wxTextCtrl: public wxControl, public streambuf
f5abe911
RR
56#else
57class wxTextCtrl: public wxControl
58#endif
c801d85f 59{
7c41ac7b 60 DECLARE_EVENT_TABLE()
c801d85f
KB
61 DECLARE_DYNAMIC_CLASS(wxTextCtrl);
62
903f689b 63 public:
7c41ac7b
VZ
64 wxTextCtrl();
65 wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value = "",
debe6624 66 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
6de97a3b
RR
67 int style = 0, const wxValidator& validator = wxDefaultValidator,
68 const wxString &name = wxTextCtrlNameStr );
debe6624
JS
69 bool Create( wxWindow *parent, wxWindowID id, const wxString &value = "",
70 const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
6de97a3b
RR
71 int style = 0, const wxValidator& validator = wxDefaultValidator,
72 const wxString &name = wxTextCtrlNameStr );
7c41ac7b 73 wxString GetValue() const;
c801d85f
KB
74 void SetValue( const wxString &value );
75 void WriteText( const wxString &text );
a6e21573 76 void AppendText( const wxString &text );
7c41ac7b 77
c801d85f
KB
78 bool LoadFile( const wxString &file );
79 bool SaveFile( const wxString &file );
7c41ac7b
VZ
80 bool IsModified() const { return m_modified; }
81 void SetModified() { m_modified = TRUE; }
82 void DiscardEdits() { m_modified = FALSE; }
debe6624 83 wxString GetLineText( long lineNo ) const;
c801d85f 84 void OnDropFiles( wxDropFilesEvent &event );
debe6624 85 long PositionToXY( long pos, long *x, long *y ) const;
a81258be
RR
86 long XYToPosition( long x, long y ) const;
87 int GetLineLength(long lineNo) const;
88 int GetNumberOfLines() const;
debe6624 89 virtual void SetInsertionPoint( long pos );
7c41ac7b 90 virtual void SetInsertionPointEnd();
debe6624
JS
91 virtual void SetEditable( bool editable );
92 virtual void SetSelection( long from, long to );
93 void ShowPosition( long pos );
7c41ac7b
VZ
94 virtual long GetInsertionPoint() const;
95 virtual long GetLastPosition() const;
debe6624
JS
96 virtual void Remove( long from, long to );
97 virtual void Replace( long from, long to, const wxString &value );
7c41ac7b
VZ
98 void Cut();
99 void Copy();
100 void Paste();
03f38c58 101 void Clear();
7c41ac7b 102
ca8b28f2
JS
103 virtual bool CanCopy() const;
104 virtual bool CanCut() const;
105 virtual bool CanPaste() const;
106
107 // Undo/redo
108 virtual void Undo();
109 virtual void Redo();
110
111 virtual bool CanUndo() const;
112 virtual bool CanRedo() const;
113
114 // If the return values from and to are the same, there is no
115 // selection.
116 virtual void GetSelection(long* from, long* to) const;
117 virtual bool IsEditable() const ;
118
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
f5abe911 133#ifndef NO_TEXT_WINDOW_STREAM
c801d85f 134 int overflow(int i);
7c41ac7b
VZ
135 int sync();
136 int underflow();
c801d85f
KB
137
138 wxTextCtrl& operator<<(const wxString& s);
debe6624
JS
139 wxTextCtrl& operator<<(int i);
140 wxTextCtrl& operator<<(long i);
141 wxTextCtrl& operator<<(float f);
142 wxTextCtrl& operator<<(double d);
c801d85f 143 wxTextCtrl& operator<<(const char c);
f5abe911 144#endif
c801d85f 145
f03fc89f
VZ
146 bool SetFont( const wxFont &font );
147 bool SetForegroundColour(const wxColour &colour);
148 bool SetBackgroundColour(const wxColour &colour);
68dda785 149
868a2826
RR
150 // implementation
151
2830bf19 152 GtkWidget* GetConnectWidget();
b4071e91 153 bool IsOwnGtkWindow( GdkWindow *window );
58614078 154 void ApplyWidgetStyle();
2830bf19 155 void CalculateScrollbar();
e3e65dac 156
903f689b
RR
157 private:
158
159 bool m_modified;
160 GtkWidget *m_text;
2830bf19
RR
161 GtkWidget *m_vScrollbar;
162 bool m_vScrollbarVisible;
c801d85f
KB
163};
164
165#endif // __GTKTEXTCTRLH__
166
167