1 // 2 // This file is part of the aMule Project. 3 // 4 // Copyright (c) 2003-2011 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. 10 // 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. 15 // 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 24 // 25 26 #ifndef SHAREDFILESCTRL_H 27 #define SHAREDFILESCTRL_H 28 29 #include "MuleListCtrl.h" // Needed for CMuleListCtrl 30 31 32 class CSharedFileList; 33 class CKnownFile; 34 class wxMenu; 35 36 37 /** 38 * This class represents the widget used to list shared files. 39 */ 40 class CSharedFilesCtrl : public CMuleListCtrl 41 { 42 public: 43 /** 44 * Constructor. 45 * 46 * @see CMuleListCtrl::CMuleListCtrl 47 */ 48 CSharedFilesCtrl(wxWindow* parent, int id, const wxPoint& pos, wxSize size, int flags); 49 50 /** 51 * Destructor. 52 */ 53 ~CSharedFilesCtrl(); 54 55 56 /** Reloads the list of shared files. */ 57 void ShowFileList(); 58 59 /** 60 * Adds the specified file to the list, updating filecount and more. 61 * 62 * @param file The new file to be shown. 63 * 64 * Note that the item is inserted in sorted order. 65 */ 66 void ShowFile(CKnownFile* file); 67 68 /** 69 * Removes a file from the list. 70 * 71 * @param toremove The file to be removed. 72 */ 73 void RemoveFile(CKnownFile* toremove); 74 75 /** 76 * Updates a file on the list. 77 * 78 * @param toupdate The file to be updated. 79 */ 80 void UpdateItem(CKnownFile* toupdate); 81 82 /** 83 * Updates the number of shared files displayed above the list. 84 */ 85 void ShowFilesCount(); 86 87 protected: 88 /// Return old column order. 89 wxString GetOldColumnOrder() const; 90 91 private: 92 /** 93 * Adds the specified file to the list. 94 * 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. 98 */ 99 void DoShowFile(CKnownFile* file, bool batch); 100 101 /** 102 * Draws the graph of file-part availability. 103 * 104 * @param file The file to make a graph over. 105 * @param dc The wcDC to draw on. 106 * @param rect The drawing area. 107 * 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. 112 */ 113 void DrawAvailabilityBar( CKnownFile* file, wxDC* dc, const wxRect& rect ) const; 114 115 /** 116 * Overloaded function needed to do custom drawing of the items. 117 */ 118 virtual void OnDrawItem(int item, wxDC* dc, const wxRect& rect, const wxRect& rectHL, bool highlighted); 119 120 121 /** 122 * @see CMuleListCtrl::GetTTSText 123 */ 124 virtual wxString GetTTSText(unsigned item) const; 125 126 127 /** 128 * Sorter-function. 129 * 130 * @see wxListCtrl::SortItems 131 */ 132 static int wxCALLBACK SortProc(wxUIntPtr item1, wxUIntPtr item2, long sortData); 133 134 /** 135 * Function that specifies which columns have alternate sorting. 136 * 137 * @see CMuleListCtrl::AltSortAllowed 138 */ 139 virtual bool AltSortAllowed(unsigned column) const; 140 141 142 /** 143 * Event-handler for right-clicks on the list-items. 144 */ 145 void OnRightClick(wxListEvent& event); 146 147 /** 148 * Event-handler for right-clicks on the list-items. 149 */ 150 void OnGetFeedback(wxCommandEvent& event); 151 152 /** 153 * Event-handler for the Set Priority menu items. 154 */ 155 void OnSetPriority( wxCommandEvent& event ); 156 157 /** 158 * Event-handler for the Auto-Priority menu item. 159 */ 160 void OnSetPriorityAuto( wxCommandEvent& event ); 161 162 /** 163 * Event-handler for the Create ED2K/Magnet URI items. 164 */ 165 void OnCreateURI( wxCommandEvent& event ); 166 167 /** 168 * Event-handler for the Edit Comment menu item. 169 */ 170 void OnEditComment( wxCommandEvent& event ); 171 172 /** 173 * Event-handler for the Rename menu item. 174 */ 175 void OnRename( wxCommandEvent& event ); 176 177 /** 178 * Checks for renaming via F2. 179 */ 180 void OnKeyPressed( wxKeyEvent& event ); 181 182 /** 183 * Adds links in a collection to transfers 184 */ 185 void OnAddCollection( wxCommandEvent& WXUNUSED(evt) ); 186 187 //! Pointer used to ensure that the menu isn't displayed twice. 188 wxMenu* m_menu; 189 190 191 DECLARE_EVENT_TABLE() 192 }; 193 194 #endif 195 // File_checked_for_headers 196