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
);
57 /** Reloads the list of shared files. */
62 * Adds the specified file to the list, updating filecount and more.
64 * @param file The new file to be shown.
66 * Note that the item is inserted in sorted order.
68 void ShowFile(CKnownFile
* file
);
71 * Removes a file from the list.
73 * @param toremove The file to be removed.
75 void RemoveFile(CKnownFile
* toremove
);
78 * Updates a file on the list.
80 * @param toupdate The file to be updated.
82 void UpdateItem(CKnownFile
* toupdate
);
85 * Updates the number of shared files displayed above the list.
87 void ShowFilesCount();
90 /// Return old column order.
91 wxString
GetOldColumnOrder() const;
95 * Adds the specified file to the list.
97 * If 'batch' is true, the item will be inserted last,
98 * and the files-count will not be updated, nor is
99 * the list checked for dupes.
101 void DoShowFile(CKnownFile
* file
, bool batch
);
104 * Draws the graph of file-part availability.
106 * @param file The file to make a graph over.
107 * @param dc The wcDC to draw on.
108 * @param rect The drawing area.
110 * This function draws a barspan showing the availability of the parts of
111 * a file, for both Part-files and Known-files. Availability for Part-files
112 * is determined using the currently known sources, while availability for
113 * Known-files is determined using the sources requesting that file.
115 void DrawAvailabilityBar( CKnownFile
* file
, wxDC
* dc
, const wxRect
& rect
) const;
118 * Overloaded function needed to do custom drawing of the items.
120 virtual void OnDrawItem(int item
, wxDC
* dc
, const wxRect
& rect
, const wxRect
& rectHL
, bool highlighted
);
124 * @see CMuleListCtrl::GetTTSText
126 virtual wxString
GetTTSText(unsigned item
) const;
132 * @see wxListCtrl::SortItems
134 static int wxCALLBACK
SortProc(wxUIntPtr item1
, wxUIntPtr item2
, long sortData
);
137 * Function that specifies which columns have alternate sorting.
139 * @see CMuleListCtrl::AltSortAllowed
141 virtual bool AltSortAllowed(unsigned column
) const;
145 * Event-handler for right-clicks on the list-items.
147 void OnRightClick(wxListEvent
& event
);
150 * Event-handler for right-clicks on the list-items.
152 void OnGetFeedback(wxCommandEvent
& event
);
155 * Event-handler for the Set Priority menu items.
157 void OnSetPriority( wxCommandEvent
& event
);
160 * Event-handler for the Auto-Priority menu item.
162 void OnSetPriorityAuto( wxCommandEvent
& event
);
165 * Event-handler for the Create ED2K/Magnet URI items.
167 void OnCreateURI( wxCommandEvent
& event
);
170 * Event handler for get-razorback stats menu item
172 void OnGetRazorStats( wxCommandEvent
& evt
);
175 * Event-handler for the Edit Comment menu item.
177 void OnEditComment( wxCommandEvent
& event
);
180 * Event-handler for the Rename menu item.
182 void OnRename( wxCommandEvent
& event
);
185 * Checks for renaming via F2.
187 void OnKeyPressed( wxKeyEvent
& event
);
190 * Adds links in a collection to transfers
192 void OnAddCollection( wxCommandEvent
& WXUNUSED(evt
) );
194 //! Pointer used to ensure that the menu isn't displayed twice.
198 DECLARE_EVENT_TABLE()
202 // File_checked_for_headers