2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2002 Merkur ( devs@emule-project.net / http://www.emule-project.net )
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
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 SHAREDFILESCTRL_H
27 #define SHAREDFILESCTRL_H
29 #include "MuleListCtrl.h" // Needed for CMuleListCtrl
32 class CSharedFileList
;
38 * This class represents the widget used to list shared files.
40 class CSharedFilesCtrl
: public CMuleListCtrl
46 * @see CMuleListCtrl::CMuleListCtrl
48 CSharedFilesCtrl(wxWindow
* parent
, int id
, const wxPoint
& pos
, wxSize size
, int flags
);
56 /** Reloads the list of shared files. */
60 * Adds the specified file to the list, updating filecount and more.
62 * @param file The new file to be shown.
64 * Note that the item is inserted in sorted order.
66 void ShowFile(CKnownFile
* file
);
69 * Removes a file from the list.
71 * @param toremove The file to be removed.
73 void RemoveFile(CKnownFile
* toremove
);
76 * Updates a file on the list.
78 * @param toupdate The file to be updated.
80 void UpdateItem(CKnownFile
* toupdate
);
83 * Updates the number of shared files displayed above the list.
85 void ShowFilesCount();
88 /// Return old column order.
89 wxString
GetOldColumnOrder() const;
93 * Adds the specified file to the list.
95 * If 'batch' is true, the item will be inserted last,
96 * and the files-count will not be updated, nor is
97 * the list checked for dupes.
99 void DoShowFile(CKnownFile
* file
, bool batch
);
102 * Draws the graph of file-part availability.
104 * @param file The file to make a graph over.
105 * @param dc The wcDC to draw on.
106 * @param rect The drawing area.
108 * This function draws a barspan showing the availability of the parts of
109 * a file, for both Part-files and Known-files. Availability for Part-files
110 * is determined using the currently known sources, while availability for
111 * Known-files is determined using the sources requesting that file.
113 void DrawAvailabilityBar( CKnownFile
* file
, wxDC
* dc
, const wxRect
& rect
) const;
116 * Overloaded function needed to do custom drawing of the items.
118 virtual void OnDrawItem(int item
, wxDC
* dc
, const wxRect
& rect
, const wxRect
& rectHL
, bool highlighted
);
122 * @see CMuleListCtrl::GetTTSText
124 virtual wxString
GetTTSText(unsigned item
) const;
130 * @see wxListCtrl::SortItems
132 static int wxCALLBACK
SortProc(wxUIntPtr item1
, wxUIntPtr item2
, long sortData
);
135 * Function that specifies which columns have alternate sorting.
137 * @see CMuleListCtrl::AltSortAllowed
139 virtual bool AltSortAllowed(unsigned column
) const;
143 * Event-handler for right-clicks on the list-items.
145 void OnRightClick(wxListEvent
& event
);
148 * Event-handler for right-clicks on the list-items.
150 void OnGetFeedback(wxCommandEvent
& event
);
153 * Event-handler for the Set Priority menu items.
155 void OnSetPriority( wxCommandEvent
& event
);
158 * Event-handler for the Auto-Priority menu item.
160 void OnSetPriorityAuto( wxCommandEvent
& event
);
163 * Event-handler for the Create ED2K/Magnet URI items.
165 void OnCreateURI( wxCommandEvent
& event
);
168 * Event-handler for the Edit Comment menu item.
170 void OnEditComment( wxCommandEvent
& event
);
173 * Event-handler for the Rename menu item.
175 void OnRename( wxCommandEvent
& event
);
178 * Checks for renaming via F2.
180 void OnKeyPressed( wxKeyEvent
& event
);
183 * Adds links in a collection to transfers
185 void OnAddCollection( wxCommandEvent
& WXUNUSED(evt
) );
187 //! Pointer used to ensure that the menu isn't displayed twice.
191 DECLARE_EVENT_TABLE()
195 // File_checked_for_headers