]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/textctrl.h
Augmented version to b5
[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 #include "wx/ioswrap.h"
21
22 // TODO Some platforms/compilers don't like inheritance from streambuf.
23 #if (defined(__BORLANDC__) && !defined(__WIN32__)) || defined(__MWERKS__)
24 #define NO_TEXT_WINDOW_STREAM
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 #ifndef NO_TEXT_WINDOW_STREAM
33 , public streambuf
34 #endif
35 {
36 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
37
38 public:
39 // creation
40 // --------
41 wxTextCtrl();
42 wxTextCtrl(wxWindow *parent,
43 wxWindowID id,
44 const wxString& value = wxEmptyString,
45 const wxPoint& pos = wxDefaultPosition,
46 const wxSize& size = wxDefaultSize,
47 long style = 0,
48 const wxValidator& validator = wxDefaultValidator,
49 const wxString& name = wxTextCtrlNameStr)
50 #ifndef NO_TEXT_WINDOW_STREAM
51 : streambuf()
52 #endif
53 {
54 Create(parent, id, value, pos, size, style, validator, name);
55 }
56
57 bool Create(wxWindow *parent, wxWindowID id,
58 const wxString& value = wxEmptyString,
59 const wxPoint& pos = wxDefaultPosition,
60 const wxSize& size = wxDefaultSize, long style = 0,
61 const wxValidator& validator = wxDefaultValidator,
62 const wxString& name = wxTextCtrlNameStr);
63
64 // accessors
65 // ---------
66 virtual wxString GetValue() const;
67 virtual void SetValue(const wxString& value);
68
69 virtual int GetLineLength(long lineNo) const;
70 virtual wxString GetLineText(long lineNo) const;
71 virtual int GetNumberOfLines() const;
72
73 // operations
74 // ----------
75
76 // Clipboard operations
77 virtual void Copy();
78 virtual void Cut();
79 virtual void Paste();
80 virtual bool CanCopy() const;
81 virtual bool CanCut() const;
82 virtual bool CanPaste() const;
83
84 // Undo/redo
85 virtual void Undo();
86 virtual void Redo();
87
88 virtual bool CanUndo() const;
89 virtual bool CanRedo() const;
90
91 virtual void SetInsertionPoint(long pos);
92 virtual void SetInsertionPointEnd();
93 virtual long GetInsertionPoint() const;
94 virtual long GetLastPosition() const;
95 virtual void Replace(long from, long to, const wxString& value);
96 virtual void Remove(long from, long to);
97 virtual void SetSelection(long from, long to);
98 virtual void SetEditable(bool editable);
99 // If the return values from and to are the same, there is no
100 // selection.
101 virtual void GetSelection(long* from, long* to) const;
102 virtual bool IsEditable() const ;
103
104 // streambuf implementation
105 #ifndef NO_TEXT_WINDOW_STREAM
106 int overflow(int i);
107 int sync();
108 int underflow();
109 #endif
110
111 wxTextCtrl& operator<<(const wxString& s);
112 wxTextCtrl& operator<<(int i);
113 wxTextCtrl& operator<<(long i);
114 wxTextCtrl& operator<<(float f);
115 wxTextCtrl& operator<<(double d);
116 wxTextCtrl& operator<<(const char c);
117
118 virtual bool LoadFile(const wxString& file);
119 virtual bool SaveFile(const wxString& file);
120 virtual void WriteText(const wxString& text);
121 virtual void AppendText(const wxString& text);
122 virtual void DiscardEdits();
123 virtual bool IsModified() const;
124
125 virtual long XYToPosition(long x, long y) const;
126 virtual void PositionToXY(long pos, long *x, long *y) const;
127 virtual void ShowPosition(long pos);
128 virtual void Clear();
129
130 // callbacks
131 // ---------
132 void OnDropFiles(wxDropFilesEvent& event);
133 void OnChar(wxKeyEvent& event);
134 // void OnEraseBackground(wxEraseEvent& event);
135
136 void OnCut(wxCommandEvent& event);
137 void OnCopy(wxCommandEvent& event);
138 void OnPaste(wxCommandEvent& event);
139 void OnUndo(wxCommandEvent& event);
140 void OnRedo(wxCommandEvent& event);
141
142 void OnUpdateCut(wxUpdateUIEvent& event);
143 void OnUpdateCopy(wxUpdateUIEvent& event);
144 void OnUpdatePaste(wxUpdateUIEvent& event);
145 void OnUpdateUndo(wxUpdateUIEvent& event);
146 void OnUpdateRedo(wxUpdateUIEvent& event);
147
148 virtual void Command(wxCommandEvent& event);
149
150 // implementation from here to the end
151 // -----------------------------------
152 virtual void ChangeFont(bool keepOriginalSize = TRUE);
153 virtual void ChangeBackgroundColour();
154 virtual void ChangeForegroundColour();
155 void SetModified(bool mod) { m_modified = mod; }
156 virtual WXWidget GetTopWidget() const;
157
158 // send the CHAR and TEXT_UPDATED events
159 void DoSendEvents(void /* XmTextVerifyCallbackStruct */ *cbs,
160 long keycode);
161
162 protected:
163 wxString m_fileName;
164
165 public:
166 // Motif-specific
167 void* m_tempCallbackStruct;
168 bool m_modified;
169 wxString m_value; // Required for password text controls
170
171 // Did we call wxTextCtrl::OnChar? If so, generate a command event.
172 bool m_processedDefault;
173
174 private:
175 DECLARE_EVENT_TABLE()
176 };
177
178 #endif
179 // _WX_TEXTCTRL_H_