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