]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/textctrl.h
Cured last focus bug (I hope); some wxMotif mods
[wxWidgets.git] / include / wx / motif / textctrl.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: textctrl.h
3 // Purpose: wxTextCtrl class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_TEXTCTRL_H_
13 #define _WX_TEXTCTRL_H_
14
15 #ifdef __GNUG__
16 #pragma interface "textctrl.h"
17 #endif
18
19 #include "wx/control.h"
20
21 #if wxUSE_IOSTREAMH
22 #include <iostream.h>
23 #else
24 #include <iostream>
25 #endif
26
27 WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr;
28 WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
29
30 // Single-line text item
31 class WXDLLEXPORT wxTextCtrl: public wxControl
32
33 // TODO Some platforms/compilers don't like inheritance from streambuf.
34
35 #if (defined(__BORLANDC__) && !defined(__WIN32__)) || defined(__MWERKS__)
36 #define NO_TEXT_WINDOW_STREAM
37 #endif
38
39 #ifndef NO_TEXT_WINDOW_STREAM
40 , public streambuf
41 #endif
42
43 {
44 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
45
46 public:
47 // creation
48 // --------
49 wxTextCtrl();
50 inline wxTextCtrl(wxWindow *parent, wxWindowID id,
51 const wxString& value = wxEmptyString,
52 const wxPoint& pos = wxDefaultPosition,
53 const wxSize& size = wxDefaultSize, long style = 0,
54 const wxValidator& validator = wxDefaultValidator,
55 const wxString& name = wxTextCtrlNameStr)
56 #ifndef NO_TEXT_WINDOW_STREAM
57 :streambuf()
58 #endif
59 {
60 Create(parent, id, value, pos, size, style, validator, name);
61 }
62
63 bool Create(wxWindow *parent, wxWindowID id,
64 const wxString& value = wxEmptyString,
65 const wxPoint& pos = wxDefaultPosition,
66 const wxSize& size = wxDefaultSize, long style = 0,
67 const wxValidator& validator = wxDefaultValidator,
68 const wxString& name = wxTextCtrlNameStr);
69
70 // accessors
71 // ---------
72 virtual wxString GetValue() const ;
73 virtual void SetValue(const wxString& value);
74
75 virtual int GetLineLength(long lineNo) const;
76 virtual wxString GetLineText(long lineNo) const;
77 virtual int GetNumberOfLines() const;
78
79 // operations
80 // ----------
81
82 // Clipboard operations
83 virtual void Copy();
84 virtual void Cut();
85 virtual void Paste();
86
87 virtual void SetInsertionPoint(long pos);
88 virtual void SetInsertionPointEnd();
89 virtual long GetInsertionPoint() const ;
90 virtual long GetLastPosition() const ;
91 virtual void Replace(long from, long to, const wxString& value);
92 virtual void Remove(long from, long to);
93 virtual void SetSelection(long from, long to);
94 virtual void SetEditable(bool editable);
95
96 // streambuf implementation
97 #ifndef NO_TEXT_WINDOW_STREAM
98 int overflow(int i);
99 int sync();
100 int underflow();
101 #endif
102
103 wxTextCtrl& operator<<(const wxString& s);
104 wxTextCtrl& operator<<(int i);
105 wxTextCtrl& operator<<(long i);
106 wxTextCtrl& operator<<(float f);
107 wxTextCtrl& operator<<(double d);
108 wxTextCtrl& operator<<(const char c);
109
110 virtual bool LoadFile(const wxString& file);
111 virtual bool SaveFile(const wxString& file);
112 virtual void WriteText(const wxString& text);
113 virtual void AppendText(const wxString& text);
114 virtual void DiscardEdits();
115 virtual bool IsModified() const;
116
117 virtual long XYToPosition(long x, long y) const ;
118 virtual void PositionToXY(long pos, long *x, long *y) const ;
119 virtual void ShowPosition(long pos);
120 virtual void Clear();
121
122 // callbacks
123 // ---------
124 void OnDropFiles(wxDropFilesEvent& event);
125 void OnChar(wxKeyEvent& event);
126 // void OnEraseBackground(wxEraseEvent& event);
127
128 virtual void Command(wxCommandEvent& event);
129
130 // Implementation
131 virtual void ChangeFont(bool keepOriginalSize = TRUE);
132 virtual void ChangeBackgroundColour();
133 virtual void ChangeForegroundColour();
134 inline void SetModified(bool mod) { m_modified = mod; }
135 virtual WXWidget GetTopWidget() const;
136
137 protected:
138 wxString m_fileName;
139 public:
140 // Motif-specific
141 void* m_tempCallbackStruct;
142 bool m_modified;
143 wxString m_value; // Required for password text controls
144 bool m_processedDefault; // Did we call wxTextCtrl::OnChar?
145 // If so, generate a command event.
146 DECLARE_EVENT_TABLE()
147 };
148
149 #endif
150 // _WX_TEXTCTRL_H_