Upstream tarball 10013
[amule.git] / src / SharedFilesCtrl.h
blob59c809511ca120cdbc2a74831481d17158576187
1 //
2 // This file is part of the aMule Project.
3 //
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 )
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.
20 //
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;
33 class CKnownFile;
34 class wxMenu;
37 /**
38 * This class represents the widget used to list shared files.
40 class CSharedFilesCtrl : public CMuleListCtrl
42 public:
43 /**
44 * Constructor.
46 * @see CMuleListCtrl::CMuleListCtrl
48 CSharedFilesCtrl(wxWindow* parent, int id, const wxPoint& pos, wxSize size, int flags);
50 /**
51 * Destructor.
53 ~CSharedFilesCtrl();
56 #ifndef CLIENT_GUI
57 /** Reloads the list of shared files. */
58 void ShowFileList();
59 #endif
61 /**
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);
70 /**
71 * Removes a file from the list.
73 * @param toremove The file to be removed.
75 void RemoveFile(CKnownFile* toremove);
77 /**
78 * Updates a file on the list.
80 * @param toupdate The file to be updated.
82 void UpdateItem(CKnownFile* toupdate);
84 /**
85 * Updates the number of shared files displayed above the list.
87 void ShowFilesCount();
89 protected:
90 /// Return old column order.
91 wxString GetOldColumnOrder() const;
93 private:
94 /**
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;
130 * Sorter-function.
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.
195 wxMenu* m_menu;
198 DECLARE_EVENT_TABLE()
201 #endif
202 // File_checked_for_headers