1//
2// This file is part of the aMule Project.
3//
4// Copyright (c) 2004-2011 aMule Team ( admin@amule.org / http://www.amule.org )
5//
6// Any parts of this program derived from the xMule, lMule or eMule project,
7// or contributed by third-party developers are copyrighted by their
8// respective authors.
9//
10// This program is free software; you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation; either version 2 of the License, or
13// (at your option) any later version.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18// GNU General Public License for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
23//
24
25#ifndef MULETEXTCTRL_H
26#define MULETEXTCTRL_H
27
28#include <wx/textctrl.h>
29
30
31class wxCommandEvent;
32class wxMouseEvent;
33
34
35/**
36 * This class is a slightly improved wxTextCtrl that supports the traditional
37 * popup-menu usually provided by text-ctrls. It provides the following options:
38 *  - Cut
39 *  - Copy
40 *  - Paste
41 *  - Clear
42 *  - Select All
43 *
44 * Other than that, it acts exactly like an ordinary wxTextCtrl.
45 */
46class CMuleTextCtrl : public wxTextCtrl
47{
48public:
49	/**
50	 * Constructor is identical to the wxTextCtrl one.
51	 */
52	CMuleTextCtrl(wxWindow* parent, wxWindowID id, const wxString& value = wxEmptyString, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTextCtrlNameStr);
53
54	/**
55	 * Destructor, which currently does nothing.
56	 */
57	virtual ~CMuleTextCtrl() {};
58
59#ifdef __WXMAC__
60	/**
61	 * Hack to fix fonts getting reset when Clear() is called.
62	 */
63	virtual void Clear();
64#endif
65
66protected:
67	/**
68	 * This function takes care of creating the popup-menu.
69	 *
70	 * Please note that by using the RIGHT_DOWN event, I'm disabling the second
71	 * type of selection that the wxTextCtrl supports. However, I frankly only
72	 * noticed that second selection type while implementing this, so I doubth
73	 * that anyone will be missing it ...
74	 */
75	void OnRightDown( wxMouseEvent& evt );
76
77	/**
78	 * This function takes care of pasting text.
79	 *
80	 * Pleaes note that it is only needed because wxMenu disallows enabling and
81	 * disabling of items that use the predefined wxID_PASTE id. This is the
82	 * only one of the already provided commands we need to override, since the
83	 * others already work just fine.
84	 */
85	void OnPaste( wxCommandEvent& evt );
86
87	/**
88	 * This functions takes care of selecting all text.
89	 */
90	void OnSelAll( wxCommandEvent& evt );
91
92	/**
93	 * This functions takes care of clearing the text.
94	 */
95	void OnClear( wxCommandEvent& evt );
96
97
98	DECLARE_EVENT_TABLE()
99};
100
101#endif
102
103// File_checked_for_headers
104