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