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-2008 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 SERVERLISTCTRL_H
27 #define SERVERLISTCTRL_H
29 #include "MuleListCtrl.h" // Needed for CMuleListCtrl
31 #define COLUMN_SERVER_NAME 0
32 #define COLUMN_SERVER_ADDR 1
33 #define COLUMN_SERVER_PORT 2
34 #define COLUMN_SERVER_DESC 3
35 #define COLUMN_SERVER_PING 4
36 #define COLUMN_SERVER_USERS 5
37 #define COLUMN_SERVER_FILES 6
38 #define COLUMN_SERVER_PRIO 7
39 #define COLUMN_SERVER_FAILS 8
40 #define COLUMN_SERVER_STATIC 9
41 #define COLUMN_SERVER_VERSION 10
42 #define COLUMN_SERVER_TCPFLAGS 11
43 #define COLUMN_SERVER_UDPFLAGS 12
52 * The CServerListCtrl is used to display the list of servers which the user
53 * can connect to and which we request sources from. It is a permanently sorted
54 * list in that it always ensure that the items are sorted in the correct order.
56 class CServerListCtrl
: public CMuleListCtrl
62 * @see CMuleListCtrl::CMuleListCtrl
66 wxWindowID winid
= -1,
67 const wxPoint
&pos
= wxDefaultPosition
,
68 const wxSize
&size
= wxDefaultSize
,
69 long style
= wxLC_ICON
,
70 const wxValidator
& validator
= wxDefaultValidator
,
71 const wxString
&name
= wxT("mulelistctrl") );
76 virtual ~CServerListCtrl();
80 * Adds a server to the list.
82 * @param A pointer to the new server.
84 * Internally this function calls RefreshServer and ShowServerCount, with
85 * the result that it is legal to add servers already in the list, though
88 void AddServer( CServer
* toadd
);
91 * Removes a server from the displayed list.
93 void RemoveServer(CServer
* server
);
96 * Removes all servers with the specified state.
98 * @param state All items with this state will be removed, default being all.
100 void RemoveAllServers(int state
= wxLIST_STATE_DONTCARE
);
104 * Updates the displayed information on a server.
106 * @param server The server to be updated.
108 * This function will not only update the displayed information, it will also
109 * reposition the item should it be nescecarry to enforce the current sorting.
110 * Also note that this function does not require that the server actually is
111 * on the list already, since AddServer makes use of it, but this should
112 * generally be avoided, since it will result in the server-count getting
113 * skewed until the next AddServer call.
115 void RefreshServer( CServer
* server
);
118 * Sets the highlighting of the specified server.
120 * @param server The server to have its highlighting set.
121 * @param highlight The new highlighting state.
123 * Please note that only _one_ item is allowed to be highlighted at any
124 * one time, so calling this function while another item is already
125 * highlighted will result in the old item not being highlighted any more.
127 void HighlightServer( const CServer
* server
, bool highlight
);
132 * This function updates the server-count in the server-wnd.
134 void ShowServerCount();
137 /// Return old column order.
138 wxString
GetOldColumnOrder() const;
143 * Event-handler for handling item activation (connect).
145 void OnItemActivated( wxListEvent
& event
);
148 * Event-handler for displaying the popup-menu.
150 void OnItemRightClicked( wxListEvent
& event
);
153 * Event-handler for priority changes.
155 void OnPriorityChange( wxCommandEvent
& event
);
158 * Event-handler for static changes.
160 void OnStaticChange( wxCommandEvent
& event
);
163 * Event-handler for server connections.
165 void OnConnectToServer( wxCommandEvent
& event
);
168 * Event-handler for copying server-urls to the clipboard.
170 void OnGetED2kURL( wxCommandEvent
& event
);
173 * Event-handler for server removal.
175 void OnRemoveServers( wxCommandEvent
& event
);
178 * Event-handler for deleting servers when the delete-key is pressed.
180 void OnKeyPressed( wxKeyEvent
& event
);
185 * @see wxListCtrl::SortItems
187 static int wxCALLBACK
SortProc(wxUIntPtr item1
, wxUIntPtr item2
, long sortData
);
190 //! Used to keep track of the last high-lighted item.
191 const CServer
* m_connected
;
194 DECLARE_EVENT_TABLE()
198 // File_checked_for_headers