Upstream tarball 10002
[amule.git] / src / MuleTextCtrl.h
blob4c847347e2ad1186c01ed285751e8e7122c98de3
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2004-2008 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.
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
25 #ifndef MULETEXTCTRL_H
26 #define MULETEXTCTRL_H
28 #include <wx/textctrl.h>
31 class wxCommandEvent;
32 class wxMouseEvent;
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
44 * Other than that, it acts exactly like an ordinary wxTextCtrl.
46 class CMuleTextCtrl : public wxTextCtrl
48 public:
49 /**
50 * Constructor is identical to the wxTextCtrl one.
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);
54 /**
55 * Destructor, which currently does nothing.
57 virtual ~CMuleTextCtrl() {};
59 #ifdef __WXMAC__
60 /**
61 * Hack to fix fonts getting reset when Clear() is called.
63 virtual void Clear();
64 #endif
66 protected:
67 /**
68 * This function takes care of creating the popup-menu.
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 ...
75 void OnRightDown( wxMouseEvent& evt );
77 /**
78 * This function takes care of pasting text.
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.
85 void OnPaste( wxCommandEvent& evt );
87 /**
88 * This functions takes care of selecting all text.
90 void OnSelAll( wxCommandEvent& evt );
92 /**
93 * This functions takes care of clearing the text.
94 */
95 void OnClear( wxCommandEvent& evt );
98 DECLARE_EVENT_TABLE()
101 #endif
103 // File_checked_for_headers