Upstream tarball 9408
[amule.git] / src / amuleDlg.h
blob112d8a7daad065728710e028c38f97ff7244112a
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-2008 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 AMULEDLG_H
27 #define AMULEDLG_H
30 #include <wx/archive.h>
31 #include <wx/filename.h>
32 #include <wx/frame.h> // Needed for wxFrame
33 #include <wx/imaglist.h>
34 #include <wx/timer.h>
35 #include <wx/wfstream.h>
36 #include <wx/zipstrm.h>
38 #include "Types.h" // Needed for uint32
41 class wxTimerEvent;
42 class wxTextCtrl;
44 class CIP2Country;
45 class CTransferWnd;
46 class CServerWnd;
47 class CSharedFilesWnd;
48 class CSearchDlg;
49 class CChatWnd;
50 class CStatisticsDlg;
51 class CKadDlg;
52 class PrefsUnifiedDlg;
55 class CMuleTrayIcon;
57 struct PageType {
58 wxWindow* page;
59 wxString name;
62 #define MP_RESTORE 4001
63 #define MP_CONNECT 4002
64 #define MP_DISCONNECT 4003
65 #define MP_EXIT 4004
68 #define DEFAULT_SIZE_X 800
69 #define DEFAULT_SIZE_Y 600
72 enum ClientSkinEnum {
73 Client_Green_Smiley = 0,
74 Client_Red_Smiley,
75 Client_Yellow_Smiley,
76 Client_Grey_Smiley,
77 Client_White_Smiley,
78 Client_ExtendedProtocol_Smiley,
79 Client_SecIdent_Smiley,
80 Client_BadGuy_Smiley,
81 Client_CreditsGrey_Smiley,
82 Client_CreditsYellow_Smiley,
83 Client_Upload_Smiley,
84 Client_Friend_Smiley,
85 Client_eMule_Smiley,
86 Client_mlDonkey_Smiley,
87 Client_eDonkeyHybrid_Smiley,
88 Client_aMule_Smiley,
89 Client_lphant_Smiley,
90 Client_Shareaza_Smiley,
91 Client_xMule_Smiley,
92 Client_Unknown,
93 Client_InvalidRating_Smiley,
94 Client_PoorRating_Smiley,
95 Client_FairRating_Smiley,
96 Client_GoodRating_Smiley,
97 Client_ExcellentRating_Smiley,
98 Client_CommentOnly_Smiley,
99 Client_Encryption_Smiley,
100 // Add items here.
101 CLIENT_SKIN_SIZE
105 // CamuleDlg Dialogfeld
106 class CamuleDlg : public wxFrame
108 public:
109 CamuleDlg(
110 wxWindow *pParent = NULL,
111 const wxString &title = wxEmptyString,
112 wxPoint where = wxDefaultPosition,
113 wxSize dlg_size = wxSize(DEFAULT_SIZE_X,DEFAULT_SIZE_Y));
114 ~CamuleDlg();
116 void AddLogLine(const wxString& line);
117 void AddServerMessageLine(wxString& message);
118 void ResetLog(int id);
120 void ShowUserCount(const wxString& info = wxEmptyString);
121 void ShowConnectionState(bool skinChanged = false);
122 void ShowTransferRate();
124 bool StatisticsWindowActive()
125 { return (m_activewnd == (wxWindow*)m_statisticswnd); }
127 /* Returns the active dialog. Needed to check what to redraw. */
128 enum DialogType {
129 DT_TRANSFER_WND,
130 DT_NETWORKS_WND,
131 DT_SEARCH_WND,
132 DT_SHARED_WND,
133 DT_CHAT_WND,
134 DT_STATS_WND,
135 DT_KAD_WND // this one is still unused
137 DialogType GetActiveDialog()
138 { return m_nActiveDialog; }
139 void SetActiveDialog(DialogType type, wxWindow* dlg);
142 * Helper function for deciding if a certian dlg is visible.
144 * @return True if the dialog is visible to the user, false otherwise.
146 bool IsDialogVisible( DialogType dlg )
148 return m_nActiveDialog == dlg && m_is_safe_state /* && !IsIconized() */;
151 void ShowED2KLinksHandler( bool show );
153 void DlgShutDown();
154 void OnClose(wxCloseEvent& evt);
155 void OnBnConnect(wxCommandEvent& evt);
157 void DoIconize(bool iconize);
159 bool SafeState() { return m_is_safe_state; }
161 void LaunchUrl(const wxString &url);
163 //! These are the currently known web-search providers
164 enum WebSearch {
165 WS_FILEHASH
167 // websearch function
168 wxString GenWebSearchUrl( const wxString &filename, WebSearch provider );
170 void CreateSystray();
171 void RemoveSystray();
173 void StartGuiTimer() { gui_timer->Start(100); }
174 void StopGuiTimer() { gui_timer->Stop(); }
177 * This function ensures that _all_ list widgets are properly sorted.
179 void InitSort();
181 void SetMessageBlink(bool state) { m_BlinkMessages = state; }
182 void Create_Toolbar(bool orientation);
184 void DoNetworkRearrange();
186 CIP2Country* m_IP2Country;
187 void IP2CountryDownloadFinished(uint32 result);
188 void EnableIP2Country();
190 wxWindow* m_activewnd;
191 CTransferWnd* m_transferwnd;
192 CServerWnd* m_serverwnd;
193 CSharedFilesWnd* m_sharedfileswnd;
194 CSearchDlg* m_searchwnd;
195 CChatWnd* m_chatwnd;
196 CStatisticsDlg* m_statisticswnd;
197 CKadDlg* m_kademliawnd;
198 //! Pointer to the current preference dialog, if any.
199 PrefsUnifiedDlg* m_prefsDialog;
201 int m_srv_split_pos;
203 wxImageList m_imagelist;
204 wxImageList m_tblist;
206 protected:
207 void OnToolBarButton(wxCommandEvent& ev);
208 void OnAboutButton(wxCommandEvent& ev);
209 void OnPrefButton(wxCommandEvent& ev);
210 #ifndef CLIENT_GUI
211 void OnImportButton(wxCommandEvent& ev);
212 #endif
213 void OnMinimize(wxIconizeEvent& evt);
214 void OnBnClickedFast(wxCommandEvent& evt);
215 void OnGUITimer(wxTimerEvent& evt);
216 void OnMainGUISizeChange(wxSizeEvent& evt);
217 void OnExit(wxCommandEvent& evt);
219 private:
220 //! Specifies if the prefs-dialog was shown before minimizing.
221 bool m_prefsVisible;
222 wxToolBar *m_wndToolbar;
223 wxTimer *gui_timer;
224 CMuleTrayIcon *m_wndTaskbarNotifier;
225 bool m_TrayIcon;
226 DialogType m_nActiveDialog;
227 bool m_is_safe_state;
228 bool m_BlinkMessages;
229 int m_CurrentBlinkBitmap;
230 uint32 m_last_iconizing;
231 wxFileName m_skinFileName;
232 std::vector<wxString> m_clientSkinNames;
233 bool m_GeoIPavailable;
235 WX_DECLARE_STRING_HASH_MAP(wxZipEntry*, ZipCatalog);
236 ZipCatalog::iterator it;
237 wxZipEntry *entry;
238 ZipCatalog cat;
240 PageType m_logpages[4];
241 PageType m_networkpages[2];
243 bool LoadGUIPrefs(bool override_pos, bool override_size);
244 bool SaveGUIPrefs();
246 void UpdateTrayIcon(int percent);
248 void Apply_Clients_Skin();
249 void Apply_Toolbar_Skin(wxToolBar *wndToolbar);
250 bool Check_and_Init_Skin();
251 void Add_Skin_Icon(const wxString &iconName, const wxBitmap &stdIcon, bool useSkins);
252 void ToogleED2KLinksHandler();
253 void SetMessagesTool();
254 void OnKeyPressed(wxKeyEvent& evt);
256 DECLARE_EVENT_TABLE()
259 #endif
261 // File_checked_for_headers