Use wxFileName for path manipulation
[amule.git] / src / MuleNotebook.h
blob9685eb64a0ff33fb0cbe8db6c09afb5746cc2da1
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>
32 DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MULENOTEBOOK_PAGE_CLOSING, -1)
33 DECLARE_LOCAL_EVENT_TYPE(wxEVT_COMMAND_MULENOTEBOOK_ALL_PAGES_CLOSED, -1)
35 #define EVT_MULENOTEBOOK_PAGE_CLOSING(id, fn) \
36 DECLARE_EVENT_TABLE_ENTRY( \
37 wxEVT_COMMAND_MULENOTEBOOK_PAGE_CLOSING, \
38 id, \
39 -1, \
40 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
41 NULL \
43 #define EVT_MULENOTEBOOK_ALL_PAGES_CLOSED(id, fn) \
44 DECLARE_EVENT_TABLE_ENTRY( \
45 wxEVT_COMMAND_MULENOTEBOOK_ALL_PAGES_CLOSED, \
46 id, \
47 -1, \
48 (wxObjectEventFunction)(wxEventFunction)(wxNotebookEventFunction) &fn, \
49 NULL \
53 class wxWindow;
56 /**
57 * This is an NoteBook control which adds additional features above what is
58 * provided by the wxNoteBook widget. Currently it includes:
59 * - Use of images on the tabs for closing the pages.
60 * - A popup-menu for closing one or more pages.
61 * - Events triggered when pages are closed.
63 class CMuleNotebook : public wxNotebook
65 public:
66 /**
67 * Constructor.
69 * @see wxNotebook::wxNotebook
71 CMuleNotebook( wxWindow *parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = 0, const wxString& name = wxT("notebook") );
73 /**
74 * Destructor.
76 virtual ~CMuleNotebook();
78 /**
79 * Deletes the page and triggers an event.
81 * @param nPage The page to be removed.
83 virtual bool DeletePage(int nPage);
85 /**
86 * Deletes and triggers and event for every page.
88 virtual bool DeleteAllPages();
91 /**
92 * Enables or disables the displaying of a popup-menu.
94 * @param enabled The new setting.
96 void EnablePopup( bool enable );
98 /**
99 * Sets an external widget to handle the popup-event.
101 * @param widget The widget which would recieve the event or NULL to disable.
103 * Setting the handler to a non-NULL pointer means that upon right-clicks, a
104 * right click event will be sent to that widget, so that it can create a
105 * popup-menu. The coordinates will be fixed to fit onto the specified widget,
106 * so no mapping is needed.
108 void SetPopupHandler( wxWindow* widget );
110 protected:
112 * Event handler for left mouse button release (for closing pages)
114 void OnMouseLeftRelease(wxMouseEvent &event);
117 * Event handler for mouse motion (for highlighting the 'x')
119 void OnMouseMotion(wxMouseEvent &event);
122 * Event-handler for right-clicks that takes care of displaying the popup-menu.
124 void OnRMButton(wxMouseEvent& event);
127 * Event-handler fo the Close item on the popup-menu.
129 void OnPopupClose(wxCommandEvent& evt);
132 * Event-handler fo the CloseAll item on the popup-menu.
134 void OnPopupCloseAll(wxCommandEvent& evt);
137 * Event-handler fo the CloseOthers item on the popup-menu.
139 void OnPopupCloseOthers(wxCommandEvent& evt);
141 //! Keeps track of the popup-menu being enabled or not.
142 bool m_popup_enable;
144 //! The pointer to the widget which would recieve right-click events or NULL.
145 wxWindow* m_popup_widget;
147 DECLARE_EVENT_TABLE()
150 #ifdef __WINDOWS__
151 #define MULE_NOTEBOOK_TAB_HEIGHT 26
152 #else
153 #define MULE_NOTEBOOK_TAB_HEIGHT 40
154 #endif
156 #endif
157 // File_checked_for_headers