Added papirus skin and minor debian fixes
[amule.git] / src / DownloadListCtrl.h
blob43e16f95462d883f6690a2746088f7cbc0f61902
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.
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 DOWNLOADLISTCTRL_H
27 #define DOWNLOADLISTCTRL_H
29 #include <map> // Needed for std::multimap
30 #include <wx/brush.h>
32 #include "Types.h" // Needed for uint8
33 #include "Constants.h" // Needed for DownloadItemType
34 #include "MuleListCtrl.h" // Needed for CMuleListCtrl
37 class CPartFile;
38 class wxBitmap;
39 class wxRect;
40 class wxDC;
42 struct FileCtrlItem_Struct;
44 /**
45 * This class is responsible for representing the download queue.
47 * The CDownlodListCtrl class is responsible for drawing files being downloaded.
48 * It is in many ways primary widget within the application, since it is here that
49 * users can inspect and manipulate their current downloads.
52 class CDownloadListCtrl : public CMuleListCtrl
54 public:
55 /**
56 * Constructor.
58 * @see CMuleListCtrl::CMuleListCtrl for documentation of parameters.
60 CDownloadListCtrl(
61 wxWindow *parent,
62 wxWindowID winid = -1,
63 const wxPoint &pos = wxDefaultPosition,
64 const wxSize &size = wxDefaultSize,
65 long style = wxLC_ICON,
66 const wxValidator& validator = wxDefaultValidator,
67 const wxString &name = wxT("downloadlistctrl") );
69 /**
70 * Destructor.
72 virtual ~CDownloadListCtrl();
75 /**
76 * Adds a file to the list, but it wont show unless it matches the current category.
78 * @param A valid pointer to a new partfile.
80 * Please note that duplicates wont be added.
82 void AddFile( CPartFile* file );
84 /**
85 * Removes the specified file from the list.
87 * @param file A valid pointer of the file to be removed.
89 * This function also removes any sources assosiated with the file.
91 void RemoveFile( CPartFile* file );
93 /**
94 * Shows or hides the sources of a specific file.
96 * @param file A valid pointer to the file to be shown/hidden.
97 * @param show Whenever or not to show the file.
99 * If the file is hidden, then its sources will also be hidden.
101 void ShowFile( CPartFile* file, bool show );
105 * Updates the state of the specified item, possibly causing a redrawing.
107 * @param toupdate The source or file to be updated.
109 * Calling this function with a file as the argument will ensure that the
110 * file is hidden/shown depending on its state and the currently selected
111 * category.
113 void UpdateItem(const void* toupdate);
116 * Returns the current category.
118 uint8 GetCategory() const;
121 * Changes the displayed category and updates the list of shown files.
123 * @param newCategory The new category to display.
125 void ChangeCategory( int newCategory );
129 * Clears all completed files from the list.
131 void ClearCompleted();
134 * Perform client update when item selection has changed.
136 void DoItemSelectionChanged();
138 protected:
139 /// Return old column order.
140 wxString GetOldColumnOrder() const;
142 private:
144 * Updates the displayed number representing the amount of files currently shown.
146 void ShowFilesCount( int diff );
150 * @see CMuleListCtrl::GetTTSText
152 virtual wxString GetTTSText(unsigned item) const;
156 * Overloaded function needed for custom drawing of items.
158 virtual void OnDrawItem( int item, wxDC* dc, const wxRect& rect, const wxRect& rectHL, bool highlighted );
161 * Draws a file item.
163 void DrawFileItem( wxDC* dc, int nColumn, const wxRect& rect, FileCtrlItem_Struct* item ) const;
166 * Draws the status (chunk) bar for a file.
168 void DrawFileStatusBar( const CPartFile* file, wxDC* dc, const wxRect& rect, bool bFlat ) const;
170 static int wxCALLBACK SortProc(wxUIntPtr item1, wxUIntPtr item2, long sortData);
171 static int Compare( const CPartFile* file1, const CPartFile* file2, long lParamSort );
173 // Event-handlers for files
174 void OnCancelFile( wxCommandEvent& event );
175 void OnSetPriority( wxCommandEvent& event );
176 void OnSwapSources( wxCommandEvent& event );
177 void OnSetCategory( wxCommandEvent& event );
178 void OnSetStatus( wxCommandEvent& event );
179 void OnClearCompleted( wxCommandEvent& event );
180 void OnGetLink( wxCommandEvent& event );
181 void OnGetFeedback( wxCommandEvent& event );
182 void OnViewFileInfo( wxCommandEvent& event );
183 void OnViewFileComments( wxCommandEvent& event );
184 void OnPreviewFile( wxCommandEvent& event );
186 // Misc event-handlers
187 void OnItemActivated( wxListEvent& event );
188 void OnMouseRightClick( wxListEvent& event );
189 void OnMouseMiddleClick( wxListEvent& event );
190 void OnKeyPressed( wxKeyEvent& event );
191 void OnItemSelectionChanged( wxListEvent& event );
194 * Executes the user-selected preview command on the specified file.
196 * @file The file to be previewed.
198 void PreviewFile(CPartFile* file);
201 * Show file detail dialog for item at index
203 void ShowFileDetailDialog(long index);
206 //! The type of list used to store items on the listctrl.
207 typedef std::multimap<const void*,FileCtrlItem_Struct*> ListItems;
208 //! Shortcut to the pair-type used on the list.
209 typedef ListItems::value_type ListItemsPair;
210 //! This pair is used when searching for equal-ranges.
211 typedef std::pair< ListItems::iterator, ListItems::iterator > ListIteratorPair;
213 //! This list contains everything shown on the list. Sources are only to
214 //! be found on this list if they are being displayed, whereas files can
215 //! always be found on this list, even if they are currently hidden.
216 ListItems m_ListItems;
219 //! Pointer to the current menu object, used to avoid multiple menus.
220 wxMenu* m_menu;
221 //! Cached brush object.
222 wxBrush m_hilightBrush;
223 //! Cached brush object.
224 wxBrush m_hilightUnfocusBrush;
226 //! The currently displayed category
227 uint8 m_category;
229 //! Flag if change of item selection is pending
230 bool m_ItemSelectionChangePending;
232 //! The number of displayed files
233 int m_filecount;
235 DECLARE_EVENT_TABLE()
239 #endif
240 // File_checked_for_headers