Upstream tarball 20080414
[amule.git] / src / amuleDlg.h
blobd831747904fb8580fbe290aa72fb521b7ccd46ad
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 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;
58 #define MP_RESTORE 4001
59 #define MP_CONNECT 4002
60 #define MP_DISCONNECT 4003
61 #define MP_EXIT 4004
64 #define DEFAULT_SIZE_X 800
65 #define DEFAULT_SIZE_Y 600
68 enum ClientSkinEnum {
69 Client_Green_Smiley = 0,
70 Client_Red_Smiley,
71 Client_Yellow_Smiley,
72 Client_Grey_Smiley,
73 Client_White_Smiley,
74 Client_ExtendedProtocol_Smiley,
75 Client_SecIdent_Smiley,
76 Client_BadGuy_Smiley,
77 Client_CreditsGrey_Smiley,
78 Client_CreditsYellow_Smiley,
79 Client_Upload_Smiley,
80 Client_Friend_Smiley,
81 Client_eMule_Smiley,
82 Client_mlDonkey_Smiley,
83 Client_eDonkeyHybrid_Smiley,
84 Client_aMule_Smiley,
85 Client_lphant_Smiley,
86 Client_Shareaza_Smiley,
87 Client_xMule_Smiley,
88 Client_Unknown,
89 Client_InvalidRating_Smiley,
90 Client_PoorRating_Smiley,
91 Client_FairRating_Smiley,
92 Client_GoodRating_Smiley,
93 Client_ExcellentRating_Smiley,
94 Client_CommentOnly_Smiley,
95 Client_Encryption_Smiley,
96 // Add items here.
97 CLIENT_SKIN_SIZE
101 // CamuleDlg Dialogfeld
102 class CamuleDlg : public wxFrame
104 public:
105 CamuleDlg(
106 wxWindow *pParent = NULL,
107 const wxString &title = wxEmptyString,
108 wxPoint where = wxDefaultPosition,
109 wxSize dlg_size = wxSize(DEFAULT_SIZE_X,DEFAULT_SIZE_Y));
110 ~CamuleDlg();
112 void AddLogLine(bool addtostatusbar, const wxString& line);
113 void AddServerMessageLine(wxString& message);
114 void ResetLog(int id);
116 void ShowUserCount(const wxString& info = wxEmptyString);
117 void ShowConnectionState();
118 void ShowTransferRate();
120 bool StatisticsWindowActive()
121 { return (m_activewnd == (wxWindow*)m_statisticswnd); }
123 /* Returns the active dialog. Needed to check what to redraw. */
124 enum DialogType {
125 DT_TRANSFER_WND,
126 DT_NETWORKS_WND,
127 DT_SEARCH_WND,
128 DT_SHARED_WND,
129 DT_CHAT_WND,
130 DT_STATS_WND,
131 DT_KAD_WND // this one is still unused
133 DialogType GetActiveDialog()
134 { return m_nActiveDialog; }
135 void SetActiveDialog(DialogType type, wxWindow* dlg);
138 * Helper function for deciding if a certian dlg is visible.
140 * @return True if the dialog is visible to the user, false otherwise.
142 bool IsDialogVisible( DialogType dlg )
144 return m_nActiveDialog == dlg && m_is_safe_state /* && !IsIconized() */;
147 void ShowED2KLinksHandler( bool show );
149 void DlgShutDown();
150 void OnClose(wxCloseEvent& evt);
151 void OnBnConnect(wxCommandEvent& evt);
153 void DoIconize(bool iconize);
155 bool SafeState() { return m_is_safe_state; }
157 void LaunchUrl(const wxString &url);
159 //! These are the currently known web-search providers
160 enum WebSearch {
161 WS_FILEHASH
163 // websearch function
164 wxString GenWebSearchUrl( const wxString &filename, WebSearch provider );
166 void CreateSystray();
167 void RemoveSystray();
169 void StartGuiTimer() { gui_timer->Start(100); }
170 void StopGuiTimer() { gui_timer->Stop(); }
173 * This function ensures that _all_ list widgets are properly sorted.
175 void InitSort();
177 void SetMessageBlink(bool state) { m_BlinkMessages = state; }
178 void Create_Toolbar(bool orientation);
180 #ifdef ENABLE_IP2COUNTRY
181 CIP2Country* m_IP2Country;
182 #endif
183 wxWindow* m_activewnd;
184 CTransferWnd* m_transferwnd;
185 CServerWnd* m_serverwnd;
186 CSharedFilesWnd* m_sharedfileswnd;
187 CSearchDlg* m_searchwnd;
188 CChatWnd* m_chatwnd;
189 CStatisticsDlg* m_statisticswnd;
190 CKadDlg* m_kademliawnd;
191 //! Pointer to the current preference dialog, if any.
192 PrefsUnifiedDlg* m_prefsDialog;
194 int m_srv_split_pos;
196 wxImageList m_imagelist;
197 wxImageList m_tblist;
199 protected:
200 void OnToolBarButton(wxCommandEvent& ev);
201 void OnAboutButton(wxCommandEvent& ev);
202 void OnPrefButton(wxCommandEvent& ev);
203 #ifndef CLIENT_GUI
204 void OnImportButton(wxCommandEvent& ev);
205 #endif
206 void OnMinimize(wxIconizeEvent& evt);
207 void OnBnClickedFast(wxCommandEvent& evt);
208 void OnBnStatusText(wxCommandEvent& evt);
209 void OnGUITimer(wxTimerEvent& evt);
210 void OnMainGUISizeChange(wxSizeEvent& evt);
211 void OnExit(wxCommandEvent& evt);
213 private:
214 //! Specifies if the prefs-dialog was shown before minimizing.
215 bool m_prefsVisible;
216 wxToolBar *m_wndToolbar;
217 wxTimer *gui_timer;
218 CMuleTrayIcon *m_wndTaskbarNotifier;
219 DialogType m_nActiveDialog;
220 bool m_is_safe_state;
221 bool m_BlinkMessages;
222 int m_CurrentBlinkBitmap;
223 uint32 m_last_iconizing;
224 wxFileName m_skinFileName;
225 std::vector<wxString> m_clientSkinNames;
227 WX_DECLARE_STRING_HASH_MAP(wxZipEntry*, ZipCatalog);
228 ZipCatalog::iterator it;
229 wxZipEntry *entry;
230 ZipCatalog cat;
232 bool LoadGUIPrefs(
233 bool override_pos,
234 bool override_size);
235 bool SaveGUIPrefs();
237 void UpdateTrayIcon(int percent);
239 void Apply_Clients_Skin();
240 void Apply_Toolbar_Skin(wxToolBar *wndToolbar);
241 bool Check_and_Init_Skin();
242 void Add_Skin_Icon(
243 const wxString &iconName,
244 const wxBitmap &stdIcon,
245 bool useSkins);
246 void ToogleED2KLinksHandler();
247 void SetMessagesTool();
248 void OnKeyPressed(wxKeyEvent& evt);
250 DECLARE_EVENT_TABLE()
253 #endif
255 // File_checked_for_headers