Fixed build with Ubuntu Disco
[amule.git] / src / MuleNotebook.h
blobe69322e78266b31b04435cf600b88da5e407769a
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2004-2011 Angel Vidal ( kry@amule.org )
5 // Copyright (c) 2004-2011 aMule Team ( admin@amule.org / http://www.amule.org )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 #ifndef MULENOTEBOOK_H
27 #define MULENOTEBOOK_H
29 #include <wx/notebook.h>
31 #define MULE_NEEDS_DELETEPAGE_WORKAROUND wxCHECK_VERSION(3,0,2)
34 DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MULENOTEBOOK_PAGE_CLOSING, -1)
35 DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MULENOTEBOOK_ALL_PAGES_CLOSED, -1)
37 #if MULE_NEEDS_DELETEPAGE_WORKAROUND
38 DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MULENOTEBOOK_DELETE_PAGE, -1)
40 #define EVT_MULENOTEBOOK_DELETE_PAGE(id, fn) \
41 DECLARE_EVENT_TABLE_ENTRY( \
42 wxEVT_COMMAND_MULENOTEBOOK_DELETE_PAGE, \
43 id, \
44 -1, \
45 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
46 NULL \
48 #endif // MULE_NEEDS_DELETEPAGE_WORKAROUND
50 #define EVT_MULENOTEBOOK_PAGE_CLOSING(id, fn) \
51 DECLARE_EVENT_TABLE_ENTRY( \
52 wxEVT_COMMAND_MULENOTEBOOK_PAGE_CLOSING, \
53 id, \
54 -1, \
55 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
56 NULL \
58 #define EVT_MULENOTEBOOK_ALL_PAGES_CLOSED(id, fn) \
59 DECLARE_EVENT_TABLE_ENTRY( \
60 wxEVT_COMMAND_MULENOTEBOOK_ALL_PAGES_CLOSED, \
61 id, \
62 -1, \
63 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
64 NULL \
68 class wxWindow;
71 /**
72 * This is an NoteBook control which adds additional features above what is
73 * provided by the wxNoteBook widget. Currently it includes:
74 * - Use of images on the tabs for closing the pages.
75 * - A popup-menu for closing one or more pages.
76 * - Events triggered when pages are closed.
78 class CMuleNotebook : public wxNotebook
80 public:
81 /**
82 * Constructor.
84 * @see wxNotebook::wxNotebook
86 CMuleNotebook( wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("notebook") );
88 /**
89 * Destructor.
91 virtual ~CMuleNotebook();
93 /**
94 * Deletes the page and triggers an event.
96 * @param nPage The page to be removed.
98 virtual bool DeletePage(int nPage);
101 * Deletes and triggers and event for every page.
103 virtual bool DeleteAllPages();
107 * Enables or disables the displaying of a popup-menu.
109 * @param enabled The new setting.
111 void EnablePopup( bool enable );
114 * Sets an external widget to handle the popup-event.
116 * @param widget The widget which would recieve the event or NULL to disable.
118 * Setting the handler to a non-NULL pointer means that upon right-clicks, a
119 * right click event will be sent to that widget, so that it can create a
120 * popup-menu. The coordinates will be fixed to fit onto the specified widget,
121 * so no mapping is needed.
123 void SetPopupHandler( wxWindow* widget );
125 #if MULE_NEEDS_DELETEPAGE_WORKAROUND
126 private:
127 // Internal handler. Workaround for wxWidgets Tab-Crash bug.
128 void OnDeletePage(wxBookCtrlEvent& evt);
129 #endif // MULE_NEEDS_DELETEPAGE_WORKAROUND
131 protected:
133 * Event handler for left or middle mouse button to press or release (for closing pages)
135 void OnMouseButton(wxMouseEvent &event);
138 * Event handler for mouse motion (for highlighting the 'x')
140 void OnMouseMotion(wxMouseEvent &event);
143 * Event-handler for right-clicks that takes care of displaying the popup-menu.
145 void OnRMButton(wxMouseEvent& event);
148 * Event-handler fo the Close item on the popup-menu.
150 void OnPopupClose(wxCommandEvent& evt);
153 * Event-handler fo the CloseAll item on the popup-menu.
155 void OnPopupCloseAll(wxCommandEvent& evt);
158 * Event-handler fo the CloseOthers item on the popup-menu.
160 void OnPopupCloseOthers(wxCommandEvent& evt);
162 //! Keeps track of the popup-menu being enabled or not.
163 bool m_popup_enable;
165 //! The pointer to the widget which would recieve right-click events or NULL.
166 wxWindow* m_popup_widget;
168 DECLARE_EVENT_TABLE()
171 #ifdef __WINDOWS__
172 #define MULE_NOTEBOOK_TAB_HEIGHT 26
173 #else
174 #define MULE_NOTEBOOK_TAB_HEIGHT 40
175 #endif
177 #endif
178 // File_checked_for_headers