Removed redundant wx<Control>NameStr declarations.
[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 #if defined(__GNUG__) && !defined(__APPLE__)
16 #pragma interface "textctrl.h"
17 #endif
18
19 WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
20
21 // Single-line text item
22 class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
23 {
24 DECLARE_DYNAMIC_CLASS(wxTextCtrl)
25
26 public:
27 // creation
28 // --------
29 wxTextCtrl();
30 wxTextCtrl(wxWindow *parent,
31 wxWindowID id,
32 const wxString& value = wxEmptyString,
33 const wxPoint& pos = wxDefaultPosition,
34 const wxSize& size = wxDefaultSize,
35 long style = 0,
36 const wxValidator& validator = wxDefaultValidator,
37 const wxString& name = wxTextCtrlNameStr)
38 {
39 Create(parent, id, value, pos, size, style, validator, name);
40 }
41
42 bool Create(wxWindow *parent, wxWindowID id,
43 const wxString& value = wxEmptyString,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize, long style = 0,
46 const wxValidator& validator = wxDefaultValidator,
47 const wxString& name = wxTextCtrlNameStr);
48
49 // accessors
50 // ---------
51 virtual wxString GetValue() const;
52 virtual void SetValue(const wxString& value);
53
54 virtual int GetLineLength(long lineNo) const;
55 virtual wxString GetLineText(long lineNo) const;
56 virtual int GetNumberOfLines() const;
57
58 // operations
59 // ----------
60
61 // Clipboard operations
62 virtual void Copy();
63 virtual void Cut();
64 virtual void Paste();
65 virtual bool CanCopy() const;
66 virtual bool CanCut() const;
67 virtual bool CanPaste() const;
68
69 // Undo/redo
70 virtual void Undo();
71 virtual void Redo();
72
73 virtual bool CanUndo() const;
74 virtual bool CanRedo() const;
75
76 virtual void SetInsertionPoint(long pos);
77 virtual void SetInsertionPointEnd();
78 virtual long GetInsertionPoint() const;
79 virtual long GetLastPosition() const;
80 virtual void Replace(long from, long to, const wxString& value);
81 virtual void Remove(long from, long to);
82 virtual void SetSelection(long from, long to);
83 virtual void SetEditable(bool editable);
84 // If the return values from and to are the same, there is no
85 // selection.
86 virtual void GetSelection(long* from, long* to) const;
87 virtual bool IsEditable() const ;
88
89 virtual void WriteText(const wxString& text);
90 virtual void AppendText(const wxString& text);
91 virtual void DiscardEdits();
92 virtual bool IsModified() const;
93
94 virtual long XYToPosition(long x, long y) const;
95 virtual bool PositionToXY(long pos, long *x, long *y) const;
96 virtual void ShowPosition(long pos);
97 virtual void Clear();
98
99 // callbacks
100 // ---------
101 void OnDropFiles(wxDropFilesEvent& event);
102 void OnChar(wxKeyEvent& event);
103 // void OnEraseBackground(wxEraseEvent& event);
104
105 void OnCut(wxCommandEvent& event);
106 void OnCopy(wxCommandEvent& event);
107 void OnPaste(wxCommandEvent& event);
108 void OnUndo(wxCommandEvent& event);
109 void OnRedo(wxCommandEvent& event);
110
111 void OnUpdateCut(wxUpdateUIEvent& event);
112 void OnUpdateCopy(wxUpdateUIEvent& event);
113 void OnUpdatePaste(wxUpdateUIEvent& event);
114 void OnUpdateUndo(wxUpdateUIEvent& event);
115 void OnUpdateRedo(wxUpdateUIEvent& event);
116
117 virtual void Command(wxCommandEvent& event);
118
119 // implementation from here to the end
120 // -----------------------------------
121 virtual void ChangeFont(bool keepOriginalSize = TRUE);
122 virtual void ChangeBackgroundColour();
123 virtual void ChangeForegroundColour();
124 void SetModified(bool mod) { m_modified = mod; }
125 virtual WXWidget GetTopWidget() const;
126
127 // send the CHAR and TEXT_UPDATED events
128 void DoSendEvents(void /* XmTextVerifyCallbackStruct */ *cbs,
129 long keycode);
130
131 protected:
132 wxString m_fileName;
133
134 virtual wxSize DoGetBestSize() const;
135 public:
136 // Motif-specific
137 void* m_tempCallbackStruct;
138 bool m_modified;
139 wxString m_value; // Required for password text controls
140
141 // Did we call wxTextCtrl::OnChar? If so, generate a command event.
142 bool m_processedDefault;
143
144 private:
145 DECLARE_EVENT_TABLE()
146 };
147
148 #endif
149 // _WX_TEXTCTRL_H_