Upstream tarball 10137
[amule.git] / src / PrefsUnifiedDlg.cpp
blob75565b81d39a749d26066c686c26a99b48772d08
1 //
2 // This file is part of the aMule Project.
3 //
4 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Original author: Emilio Sandoz
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
27 #include "PrefsUnifiedDlg.h"
29 #include <common/Constants.h>
31 #include <wx/colordlg.h>
32 #include <wx/tooltip.h>
34 #include "amule.h" // Needed for theApp
35 #include "amuleDlg.h"
36 #include "MuleColour.h"
37 #include "EditServerListDlg.h"
38 #include "SharedFileList.h" // Needed for CSharedFileList
39 #include "StatisticsDlg.h" // Needed for graph parameters, colors
40 #include "IPFilter.h" // Needed for CIPFilter
41 #include "SearchList.h"
42 #include "ClientList.h"
43 #include "DirectoryTreeCtrl.h" // Needed for CDirectoryTreeCtrl
44 #include "Preferences.h"
45 #include "muuli_wdr.h"
46 #include "Logger.h"
47 #include <common/Format.h> // Needed for CFormat
48 #include "TransferWnd.h" // Needed for CTransferWnd::UpdateCatTabTitles()
49 #include "KadDlg.h" // Needed for CKadDlg
50 #include "OScopeCtrl.h" // Needed for OScopeCtrl
51 #include "ServerList.h"
52 #include "UserEvents.h"
54 BEGIN_EVENT_TABLE(PrefsUnifiedDlg,wxDialog)
55 // Events
56 #define USEREVENTS_EVENT(ID, NAME, VARS) \
57 EVT_CHECKBOX(USEREVENTS_FIRST_ID + CUserEvents::ID * USEREVENTS_IDS_PER_EVENT + 1, PrefsUnifiedDlg::OnCheckBoxChange) \
58 EVT_CHECKBOX(USEREVENTS_FIRST_ID + CUserEvents::ID * USEREVENTS_IDS_PER_EVENT + 3, PrefsUnifiedDlg::OnCheckBoxChange)
59 USEREVENTS_EVENTLIST()
60 #undef USEREVENTS_EVENT
62 // Proxy
63 EVT_CHECKBOX(ID_PROXY_ENABLE_PROXY, PrefsUnifiedDlg::OnCheckBoxChange)
64 EVT_CHECKBOX(ID_PROXY_ENABLE_PASSWORD, PrefsUnifiedDlg::OnCheckBoxChange)
65 // EVT_CHECKBOX(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY, PrefsUnifiedDlg::OnCheckBoxChange)
67 // Connection
68 EVT_SPINCTRL(IDC_PORT, PrefsUnifiedDlg::OnTCPClientPortChange)
70 // The rest. Organize it!
71 EVT_CHECKBOX(IDC_UDPENABLE, PrefsUnifiedDlg::OnCheckBoxChange)
72 EVT_CHECKBOX(IDC_CHECKDISKSPACE, PrefsUnifiedDlg::OnCheckBoxChange)
73 EVT_CHECKBOX(IDC_ONLINESIG, PrefsUnifiedDlg::OnCheckBoxChange)
74 EVT_CHECKBOX(IDC_REMOVEDEAD, PrefsUnifiedDlg::OnCheckBoxChange)
75 EVT_CHECKBOX(IDC_AUTOSERVER, PrefsUnifiedDlg::OnCheckBoxChange)
76 EVT_CHECKBOX(IDC_AUTOIPFILTER, PrefsUnifiedDlg::OnCheckBoxChange)
77 EVT_CHECKBOX(IDC_MSGFILTER, PrefsUnifiedDlg::OnCheckBoxChange)
78 EVT_CHECKBOX(IDC_MSGFILTER_ALL, PrefsUnifiedDlg::OnCheckBoxChange)
79 EVT_CHECKBOX(IDC_MSGFILTER_WORD, PrefsUnifiedDlg::OnCheckBoxChange)
80 EVT_CHECKBOX(IDC_FILTERCOMMENTS, PrefsUnifiedDlg::OnCheckBoxChange)
81 EVT_CHECKBOX(IDC_STARTNEXTFILE, PrefsUnifiedDlg::OnCheckBoxChange)
82 EVT_CHECKBOX(IDC_ENABLETRAYICON, PrefsUnifiedDlg::OnCheckBoxChange)
83 EVT_CHECKBOX(IDC_VERTTOOLBAR, PrefsUnifiedDlg::OnCheckBoxChange)
84 EVT_CHECKBOX(IDC_SUPPORT_PO, PrefsUnifiedDlg::OnCheckBoxChange)
85 EVT_CHECKBOX(IDC_ENABLE_PO_OUTGOING, PrefsUnifiedDlg::OnCheckBoxChange)
86 EVT_CHECKBOX(IDC_ENFORCE_PO_INCOMING, PrefsUnifiedDlg::OnCheckBoxChange)
87 EVT_CHECKBOX(IDC_SHOWRATEONTITLE, PrefsUnifiedDlg::OnCheckBoxChange)
88 EVT_CHECKBOX(IDC_NETWORKED2K, PrefsUnifiedDlg::OnCheckBoxChange)
90 EVT_BUTTON(ID_PREFS_OK_TOP, PrefsUnifiedDlg::OnOk)
91 EVT_BUTTON(ID_PREFS_CANCEL_TOP, PrefsUnifiedDlg::OnCancel)
93 // Browse buttons
94 // EVT_BUTTON(IDC_SELSKIN, PrefsUnifiedDlg::OnButtonDir)
95 EVT_BUTTON(IDC_BROWSEV, PrefsUnifiedDlg::OnButtonBrowseApplication)
96 EVT_BUTTON(IDC_SELTEMPDIR, PrefsUnifiedDlg::OnButtonDir)
97 EVT_BUTTON(IDC_SELINCDIR, PrefsUnifiedDlg::OnButtonDir)
98 EVT_BUTTON(IDC_SELOSDIR, PrefsUnifiedDlg::OnButtonDir)
99 EVT_BUTTON(IDC_SELBROWSER, PrefsUnifiedDlg::OnButtonBrowseApplication)
101 EVT_SPINCTRL(IDC_TOOLTIPDELAY, PrefsUnifiedDlg::OnToolTipDelayChange)
103 EVT_BUTTON(IDC_EDITADR, PrefsUnifiedDlg::OnButtonEditAddr)
104 EVT_BUTTON(IDC_IPFRELOAD, PrefsUnifiedDlg::OnButtonIPFilterReload)
105 EVT_BUTTON(IDC_COLOR_BUTTON, PrefsUnifiedDlg::OnButtonColorChange)
106 EVT_BUTTON(IDC_IPFILTERUPDATE, PrefsUnifiedDlg::OnButtonIPFilterUpdate)
107 EVT_CHOICE(IDC_COLORSELECTOR, PrefsUnifiedDlg::OnColorCategorySelected)
108 EVT_LIST_ITEM_SELECTED(ID_PREFSLISTCTRL,PrefsUnifiedDlg::OnPrefsPageChange)
110 EVT_INIT_DIALOG(PrefsUnifiedDlg::OnInitDialog)
112 EVT_COMMAND_SCROLL(IDC_SLIDER, PrefsUnifiedDlg::OnScrollBarChange)
113 EVT_COMMAND_SCROLL(IDC_SLIDER3, PrefsUnifiedDlg::OnScrollBarChange)
114 EVT_COMMAND_SCROLL(IDC_SLIDER4, PrefsUnifiedDlg::OnScrollBarChange)
115 EVT_COMMAND_SCROLL(IDC_SLIDER2, PrefsUnifiedDlg::OnScrollBarChange)
116 EVT_COMMAND_SCROLL(IDC_FILEBUFFERSIZE, PrefsUnifiedDlg::OnScrollBarChange)
117 EVT_COMMAND_SCROLL(IDC_QUEUESIZE, PrefsUnifiedDlg::OnScrollBarChange)
118 EVT_COMMAND_SCROLL(IDC_SERVERKEEPALIVE, PrefsUnifiedDlg::OnScrollBarChange)
120 EVT_SPINCTRL(IDC_MAXUP, PrefsUnifiedDlg::OnRateLimitChanged)
122 EVT_LIST_ITEM_SELECTED(IDC_EVENTLIST, PrefsUnifiedDlg::OnUserEventSelected)
124 EVT_CLOSE(PrefsUnifiedDlg::OnClose)
126 END_EVENT_TABLE()
130 * Creates an command-event for the given checkbox.
132 * This can be used enforce logical constraints by passing by
133 * sending a check-box event for each checkbox, when transfering
134 * to the UI. However, it should also be used for checkboxes that
135 * have no side-effects other than enabling/disabling other
136 * widgets in the preferences dialogs.
138 void SendCheckBoxEvent(wxWindow* parent, int id)
140 wxCheckBox* widget = CastByID(id, parent, wxCheckBox);
141 wxCHECK_RET(widget, wxT("Invalid widget in CreateEvent"));
143 wxCommandEvent evt(wxEVT_COMMAND_CHECKBOX_CLICKED, id);
144 evt.SetInt(widget->IsChecked() ? 1 : 0);
146 parent->GetEventHandler()->ProcessEvent(evt);
152 * This struct provides a general way to represent config-tabs.
154 struct PrefsPage
156 //! The title of the page, used on the listctrl.
157 wxString m_title;
158 //! Function pointer to the wxDesigner function creating the dialog.
159 wxSizer* (*m_function)(wxWindow*, bool, bool );
160 //! The index of the image used on the list.
161 int m_imageidx;
165 PrefsPage pages[] =
167 { wxTRANSLATE("General"), PreferencesGeneralTab, 13 },
168 { wxTRANSLATE("Connection"), PreferencesConnectionTab, 14 },
169 { wxTRANSLATE("Directories"), PreferencesDirectoriesTab, 17 },
170 { wxTRANSLATE("Servers"), PreferencesServerTab, 15 },
171 { wxTRANSLATE("Files"), PreferencesFilesTab, 16 },
172 { wxTRANSLATE("Security"), PreferencesSecurityTab, 22 },
173 { wxTRANSLATE("Interface"), PreferencesGuiTweaksTab, 19 },
174 { wxTRANSLATE("Statistics"), PreferencesStatisticsTab, 10 },
175 { wxTRANSLATE("Proxy"), PreferencesProxyTab, 24 },
176 { wxTRANSLATE("Filters"), PreferencesFilteringTab, 23 },
177 { wxTRANSLATE("Remote Controls"), PreferencesRemoteControlsTab, 11 },
178 { wxTRANSLATE("Online Signature"), PreferencesOnlineSigTab, 21 },
179 { wxTRANSLATE("Advanced"), PreferencesaMuleTweaksTab, 12 },
180 { wxTRANSLATE("Events"), PreferencesEventsTab, 5 }
181 #ifdef __DEBUG__
182 ,{ wxTRANSLATE("Debugging"), PreferencesDebug, 25 }
183 #endif
187 PrefsUnifiedDlg::PrefsUnifiedDlg(wxWindow *parent)
189 wxDialog(parent, -1, _("Preferences"),
190 wxDefaultPosition, wxDefaultSize,
191 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
193 preferencesDlgTop(this, false);
195 m_PrefsIcons = CastChild(ID_PREFSLISTCTRL, wxListCtrl);
196 wxImageList *icon_list = new wxImageList(16, 16);
197 m_PrefsIcons->AssignImageList(icon_list, wxIMAGE_LIST_SMALL);
199 // Add the single column used
200 m_PrefsIcons->InsertColumn(
201 0, wxEmptyString, wxLIST_FORMAT_LEFT,
202 m_PrefsIcons->GetSize().GetWidth()-5);
204 // Temp variables for finding the smallest height and width needed
205 int width = 0;
206 int height = 0;
208 // Add each page to the page-list
209 for (unsigned int i = 0; i < itemsof(pages); ++i) {
210 // Add the icon and label associated with the page
211 icon_list->Add(amuleSpecial(pages[i].m_imageidx));
212 m_PrefsIcons->InsertItem(i, wxGetTranslation(pages[i].m_title), i);
215 // Set list-width so that there aren't any scrollers
216 m_PrefsIcons->SetColumnWidth(0, wxLIST_AUTOSIZE);
217 m_PrefsIcons->SetMinSize(wxSize(m_PrefsIcons->GetColumnWidth(0) + 10, -1));
218 m_PrefsIcons->SetMaxSize(wxSize(m_PrefsIcons->GetColumnWidth(0) + 10, -1));
220 // Now add the pages and calculate the minimum size
221 wxPanel * DefaultWidget = NULL;
222 for (unsigned int i = 0; i < itemsof(pages); ++i) {
223 // Create a container widget and the contents of the page
224 wxPanel * Widget = new wxPanel(this, -1);
225 // Widget is stored as user data in the list control
226 m_PrefsIcons->SetItemPtrData(i, (wxUIntPtr) Widget);
227 pages[i].m_function(Widget, true, true);
228 if (i == 0) {
229 DefaultWidget = Widget;
232 // Add it to the sizer
233 prefs_sizer->Add(Widget, 0, wxGROW|wxEXPAND);
235 if (pages[i].m_function == PreferencesGeneralTab) {
236 // This must be done now or pages won't Fit();
237 #ifdef __WXMSW__
238 CastChild(IDC_BROWSERTABS, wxCheckBox)->Enable(false);
239 #endif /* __WXMSW__ */
240 } else if (pages[i].m_function == PreferencesEventsTab) {
242 #define USEREVENTS_REPLACE_VAR(VAR, DESC, CODE) + wxString(wxT("\n %") VAR wxT(" - ")) + wxGetTranslation(DESC)
243 #define USEREVENTS_EVENT(ID, NAME, VARS) case CUserEvents::ID: CreateEventPanels(idx, wxEmptyString VARS, Widget); break;
245 wxListCtrl *list = CastChild(IDC_EVENTLIST, wxListCtrl);
246 list->InsertColumn(0, wxEmptyString);
247 for (unsigned int idx = 0; idx < CUserEvents::GetCount(); ++idx) {
248 long lidx = list->InsertItem(idx,
249 wxGetTranslation(CUserEvents::GetDisplayName(
250 static_cast<enum CUserEvents::EventType>(idx))));
251 if (lidx != -1) {
252 list->SetItemData(lidx,
253 USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT);
254 switch (idx) {
255 USEREVENTS_EVENTLIST()
259 list->SetColumnWidth(0, wxLIST_AUTOSIZE);
261 else if (pages[i].m_function == PreferencesServerTab) {
262 m_IndexServerTab = i;
263 m_ServerWidget = Widget;
265 #ifdef __DEBUG__
266 else if (pages[i].m_function == PreferencesDebug) {
267 int count = theLogger.GetDebugCategoryCount();
268 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
270 for ( int j = 0; j < count; j++ ) {
271 list->Append( theLogger.GetDebugCategory( j ).GetName() );
274 #endif
276 // Align and resize the page
277 Fit();
278 Layout();
280 // Find the greatest sizes
281 wxSize size = prefs_sizer->GetSize();
282 if (size.GetWidth() > width) {
283 width = size.GetWidth();
286 if (size.GetHeight() > height) {
287 height = size.GetHeight();
290 // Hide it for now
291 prefs_sizer->Detach(Widget);
292 Widget->Show(false);
295 // Default to the General tab
296 m_CurrentPanel = DefaultWidget;
297 prefs_sizer->Add(DefaultWidget, 0, wxGROW|wxEXPAND);
298 m_CurrentPanel->Show( true );
300 // Select the first item
301 m_PrefsIcons->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
303 // We now have the needed minimum height and width
304 prefs_sizer->SetMinSize(width, height);
306 // Don't show server prefs if ED2K is disabled
307 m_ServerTabVisible = true;
308 EnableServerTab(thePrefs::GetNetworkED2K());
310 // Store some often used pointers
311 m_ShareSelector = CastChild(IDC_SHARESELECTOR, CDirectoryTreeCtrl);
312 m_buttonColor = CastChild(IDC_COLOR_BUTTON, wxButton);
313 m_choiceColor = CastChild(IDC_COLORSELECTOR, wxChoice);
315 // Connect the Cfgs with their widgets
316 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
317 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
318 // Checking for failures
319 if ( !it->second->ConnectToWidget(it->first, this) ) {
320 AddLogLineNS(CFormat(_("Failed to connect Cfg to widget with the ID %d and key %s"))
321 % it->first % it->second->GetKey());
324 Fit();
326 // It must not be resized to something smaller than what it currently is
327 wxSize size = GetClientSize();
328 SetSizeHints(size.GetWidth(), size.GetHeight());
330 #ifdef __WXMSW__
331 FindWindow(IDC_VERTTOOLBAR)->Enable(false);
332 #endif
334 // Position the dialog.
335 Center();
339 void PrefsUnifiedDlg::EnableServerTab(bool enable)
341 if (enable && !m_ServerTabVisible) {
342 // turn server widget on
343 m_PrefsIcons->InsertItem(m_IndexServerTab, wxGetTranslation(pages[m_IndexServerTab].m_title), m_IndexServerTab);
344 m_PrefsIcons->SetItemPtrData(m_IndexServerTab, (wxUIntPtr) m_ServerWidget);
345 m_ServerTabVisible = true;
346 } else if (!enable && m_ServerTabVisible) {
347 // turn server widget off
348 m_PrefsIcons->DeleteItem(m_IndexServerTab);
349 m_ServerTabVisible = false;
354 Cfg_Base* PrefsUnifiedDlg::GetCfg(int id)
356 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.find( id );
358 if ( it != thePrefs::s_CfgList.end() ) {
359 return it->second;
362 return NULL;
366 bool PrefsUnifiedDlg::TransferToWindow()
368 // Connect the Cfgs with their widgets
369 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
370 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
371 // Checking for failures
372 if ( !it->second->TransferToWindow() ) {
373 AddLogLineNS(CFormat(_("Failed to transfer data from Cfg to Widget with the ID %d and key %s"))
374 % it->first % it->second->GetKey());
378 m_ShareSelector->SetSharedDirectories(&theApp->glob_prefs->shareddir_list);
380 for ( int i = 0; i < cntStatColors; i++ ) {
381 thePrefs::s_colors[i] = CMuleColour(CStatisticsDlg::acrStat[i]).GetULong();
382 thePrefs::s_colors_ref[i] = CMuleColour(CStatisticsDlg::acrStat[i]).GetULong();
385 // Connection tab
386 wxSpinEvent e;
387 OnTCPClientPortChange(e);
389 // Proxy tab initialization
390 if (!CastChild(ID_PROXY_ENABLE_PROXY, wxCheckBox)->IsChecked()) {
391 FindWindow(ID_PROXY_TYPE)->Enable(false);
392 FindWindow(ID_PROXY_NAME)->Enable(false);
393 FindWindow(ID_PROXY_PORT)->Enable(false);
395 if (!CastChild(ID_PROXY_ENABLE_PASSWORD, wxCheckBox)->IsChecked()) {
396 FindWindow(ID_PROXY_USER)->Enable(false);
397 FindWindow(ID_PROXY_PASSWORD)->Enable(false);
399 // This option from the proxy tab is currently unused
400 FindWindow(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY)->Enable(false);
402 // Enable/Disable some controls
403 FindWindow( IDC_MINDISKSPACE )->Enable( thePrefs::IsCheckDiskspaceEnabled() );
404 FindWindow( IDC_OSDIR )->Enable( thePrefs::IsOnlineSignatureEnabled() );
405 FindWindow( IDC_OSUPDATE )->Enable( thePrefs::IsOnlineSignatureEnabled() );
406 FindWindow( IDC_UDPPORT )->Enable( thePrefs::s_UDPEnable );
407 FindWindow( IDC_SERVERRETRIES )->Enable( thePrefs::DeadServer() );
408 FindWindow( IDC_STARTNEXTFILE_SAME )->Enable(thePrefs::StartNextFile());
410 #ifdef __WXMAC__
411 FindWindow(IDC_ENABLETRAYICON)->Enable(false);
412 FindWindow(IDC_MINTRAY)->Enable(false);
413 #else
414 FindWindow(IDC_MINTRAY)->Enable(thePrefs::UseTrayIcon());
415 #endif
417 if (!CastChild(IDC_MSGFILTER, wxCheckBox)->IsChecked()) {
418 FindWindow(IDC_MSGFILTER_ALL)->Enable(false);
419 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(false);
420 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(false);
421 FindWindow(IDC_MSGFILTER_WORD)->Enable(false);
422 FindWindow(IDC_MSGWORD)->Enable(false);
423 } else if (CastChild(IDC_MSGFILTER_ALL, wxCheckBox)->IsChecked()) {
424 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(false);
425 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(false);
426 FindWindow(IDC_MSGFILTER_WORD)->Enable(false);
427 FindWindow(IDC_MSGWORD)->Enable(false);
430 FindWindow(IDC_MSGWORD)->Enable(CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
431 FindWindow(IDC_COMMENTWORD)->Enable(CastChild(IDC_FILTERCOMMENTS, wxCheckBox)->IsChecked());
433 #ifdef CLIENT_GUI
434 // Disable dirpickers unless it's a localhost connection
435 if (!theApp->m_connect->IsConnectedToLocalHost()) {
436 FindWindow(IDC_SELINCDIR)->Enable(false);
437 FindWindow(IDC_SELTEMPDIR)->Enable(false);
439 #endif
441 // Protocol obfuscation
442 ::SendCheckBoxEvent(this, IDC_SUPPORT_PO);
443 ::SendCheckBoxEvent(this, IDC_ENABLE_PO_OUTGOING);
444 ::SendCheckBoxEvent(this, IDC_ENFORCE_PO_INCOMING);
446 // Show rates on title
447 FindWindow(IDC_RATESBEFORETITLE)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
448 FindWindow(IDC_RATESAFTERTITLE)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
449 CastChild(IDC_SHOWRATEONTITLE, wxCheckBox)->SetValue(thePrefs::GetShowRatesOnTitle() != 0);
450 CastChild(IDC_RATESBEFORETITLE, wxRadioButton)->SetValue(thePrefs::GetShowRatesOnTitle() == 2);
451 CastChild(IDC_RATESAFTERTITLE, wxRadioButton)->SetValue(thePrefs::GetShowRatesOnTitle() != 2);
453 // UPNP
454 #ifndef ENABLE_UPNP
455 FindWindow(IDC_UPNP_ENABLED)->Enable(false);
456 FindWindow(IDC_UPNPTCPPORT)->Enable(false);
457 thePrefs::SetUPnPEnabled(false);
458 // TODO: grey out "UPnP TCP Port", "Webserver UPnP TCP Port"
459 FindWindow(IDC_UPNP_WEBSERVER_ENABLED)->Enable(false);
460 FindWindow(IDC_WEBUPNPTCPPORT)->Enable(false);
461 thePrefs::SetUPnPWebServerEnabled(false);
462 FindWindow(IDC_UPNP_EC_ENABLED)->Enable(false);
463 thePrefs::SetUPnPECEnabled(false);
464 #endif
466 #ifdef __DEBUG__
467 // Set debugging toggles
468 int count = theLogger.GetDebugCategoryCount();
469 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
471 for ( int i = 0; i < count; i++ ) {
472 list->Check( i, theLogger.GetDebugCategory( i ).IsEnabled() );
474 #endif
476 return true;
480 bool PrefsUnifiedDlg::TransferFromWindow()
482 // Connect the Cfgs with their widgets
483 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
484 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
485 // Checking for failures
486 if ( !it->second->TransferFromWindow() ) {
487 AddLogLineNS(CFormat(_("Failed to transfer data from Widget to Cfg with the ID %d and key %s"))
488 % it->first % it->second->GetKey());
492 theApp->glob_prefs->shareddir_list.clear();
493 m_ShareSelector->GetSharedDirectories(&theApp->glob_prefs->shareddir_list);
495 for ( int i = 0; i < cntStatColors; i++ ) {
496 if ( thePrefs::s_colors[i] != thePrefs::s_colors_ref[i] ) {
497 CStatisticsDlg::acrStat[i] = thePrefs::s_colors[i];
498 theApp->amuledlg->m_statisticswnd->ApplyStatsColor(i);
501 theApp->amuledlg->m_kademliawnd->SetGraphColors();
504 #ifdef __DEBUG__
505 // Get debugging toggles
506 int count = theLogger.GetDebugCategoryCount();
507 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
509 for ( int i = 0; i < count; i++ ) {
510 theLogger.SetEnabled( theLogger.GetDebugCategory( i ).GetType(), list->IsChecked( i ) );
512 #endif
514 thePrefs::SetShowRatesOnTitle(CastChild(IDC_SHOWRATEONTITLE, wxCheckBox)->GetValue() ? (CastChild(IDC_RATESBEFORETITLE, wxRadioButton)->GetValue() ? 2 : 1) : 0);
516 #ifdef CLIENT_GUI
517 // Send preferences to core.
518 theApp->glob_prefs->SendToRemote();
519 #endif
521 return true;
525 bool PrefsUnifiedDlg::CfgChanged(int ID)
527 Cfg_Base* cfg = GetCfg(ID);
529 if ( cfg ) {
530 return cfg->HasChanged();
533 return false;
537 void PrefsUnifiedDlg::OnOk(wxCommandEvent& WXUNUSED(event))
539 TransferFromWindow();
541 bool restart_needed = false;
542 wxString restart_needed_msg = _("aMule must be restarted to enable these changes:\n\n");
544 // do sanity checking, special processing, and user notifications here
545 thePrefs::CheckUlDlRatio();
547 if (CfgChanged(IDC_PORT)) {
548 restart_needed = true;
549 restart_needed_msg += _("- TCP port changed.\n");
552 if (CfgChanged(IDC_UDPPORT)) {
553 restart_needed = true;
554 restart_needed_msg += _("- UDP port changed.\n");
557 // Force port checking
558 thePrefs::SetPort(thePrefs::GetPort());
560 if ((CPath::GetFileSize(theApp->ConfigDir + wxT("addresses.dat")) == 0) &&
561 CastChild(IDC_AUTOSERVER, wxCheckBox)->IsChecked() ) {
562 thePrefs::UnsetAutoServerStart();
563 wxMessageBox(_("Your Auto-update server list is empty.\n'Auto-update server list at startup' will be disabled."),
564 _("Message"), wxOK | wxICON_INFORMATION, this);
567 if (thePrefs::AcceptExternalConnections() && thePrefs::ECPassword().IsEmpty()) {
568 thePrefs::EnableExternalConnections( false );
570 wxMessageBox( _("You have enabled external connections but have not specified a password.\nExternal connections cannot be enabled unless a valid password is specified."));
573 // save the preferences on ok
574 theApp->glob_prefs->Save();
576 if (CfgChanged(IDC_FED2KLH) && theApp->amuledlg->GetActiveDialog() != CamuleDlg::DT_SEARCH_WND) {
577 theApp->amuledlg->ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
580 if (CfgChanged(IDC_LANGUAGE)) {
581 restart_needed = true;
582 restart_needed_msg += _("- Language changed.\n");
585 if (CfgChanged(IDC_TEMPFILES)) {
586 restart_needed = true;
587 restart_needed_msg += _("- Temp folder changed.\n");
590 if (CfgChanged(IDC_NETWORKED2K) && thePrefs::GetNetworkED2K()) {
591 restart_needed = true;
592 restart_needed_msg += _("- ED2K network enabled.\n");
595 if (CfgChanged(IDC_INCFILES) || CfgChanged(IDC_TEMPFILES) || m_ShareSelector->HasChanged ) {
596 theApp->sharedfiles->Reload();
599 if (CfgChanged(IDC_OSDIR) || CfgChanged(IDC_ONLINESIG)) {
600 wxTextCtrl* widget = CastChild( IDC_OSDIR, wxTextCtrl );
602 // Build the filenames for the two OS files
603 theApp->SetOSFiles( widget->GetValue() );
606 if (CfgChanged(IDC_IPFCLIENTS) && thePrefs::IsFilteringClients()) {
607 theApp->clientlist->FilterQueues();
610 if (CfgChanged(IDC_IPFSERVERS) && thePrefs::IsFilteringServers()) {
611 theApp->serverlist->FilterServers();
614 if (CfgChanged(ID_IPFILTERLEVEL)) {
615 theApp->ipfilter->Reload();
618 if (thePrefs::GetShowRatesOnTitle()) {
619 // This avoids a 5 seconds delay to show the title
620 theApp->amuledlg->ShowTransferRate();
621 } else {
622 // This resets the title
623 theApp->amuledlg->SetTitle(theApp->m_FrameTitle);
626 if (CfgChanged(IDC_EXTCATINFO)) {
627 theApp->amuledlg->m_transferwnd->UpdateCatTabTitles();
630 // Changes related to the statistics-dlg
631 if (CfgChanged(IDC_SLIDER)) {
632 theApp->amuledlg->m_statisticswnd->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
633 theApp->amuledlg->m_kademliawnd->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
636 if ( CfgChanged(IDC_SLIDER3) ) {
637 theApp->amuledlg->m_statisticswnd->ResetAveragingTime();
640 if (CfgChanged(IDC_DOWNLOAD_CAP)) {
641 theApp->amuledlg->m_statisticswnd->SetARange( true, thePrefs::GetMaxGraphDownloadRate() );
644 if (CfgChanged(IDC_UPLOAD_CAP)) {
645 theApp->amuledlg->m_statisticswnd->SetARange( false, thePrefs::GetMaxGraphUploadRate() );
648 if (CfgChanged(IDC_SKIN)) {
649 theApp->amuledlg->Create_Toolbar(thePrefs::VerticalToolbar());
652 if (!thePrefs::GetNetworkED2K() && theApp->IsConnectedED2K()) {
653 theApp->DisconnectED2K();
656 if (!thePrefs::GetNetworkKademlia() && theApp->IsConnectedKad()) {
657 theApp->StopKad();
660 if (!thePrefs::GetNetworkED2K() && !thePrefs::GetNetworkKademlia()) {
661 wxMessageBox(
662 _("Both eD2k and Kad network are disabled.\nYou won't be able to connect until you enable at least one of them."));
665 if (thePrefs::GetNetworkKademlia() && thePrefs::IsUDPDisabled()) {
666 wxMessageBox(_("Kad will not start if your UDP port is disabled.\nEnable UDP port or disable Kad."),
667 _("Message"), wxOK | wxICON_INFORMATION, this);
670 if (CfgChanged(IDC_NETWORKKAD) || CfgChanged(IDC_NETWORKED2K)) {
671 theApp->amuledlg->DoNetworkRearrange();
674 if (restart_needed) {
675 wxMessageBox(restart_needed_msg + _("\nYou MUST restart aMule now.\nIf you do not restart now, don't complain if anything bad happens.\n"),
676 _("WARNING"), wxOK | wxICON_EXCLAMATION, this);
679 Show(false);
683 void PrefsUnifiedDlg::OnClose(wxCloseEvent& event)
685 Show(false);
687 // Try to keep the window alive when possible
688 if (event.CanVeto()) {
689 event.Veto();
690 } else {
691 if (theApp->amuledlg) {
692 theApp->amuledlg->m_prefsDialog = NULL;
695 // Un-Connect the Cfgs
696 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
697 for (; it != thePrefs::s_CfgList.end(); ++it) {
698 // Checking for failures
699 it->second->ConnectToWidget( 0 );
702 Destroy();
707 void PrefsUnifiedDlg::OnCancel(wxCommandEvent& WXUNUSED(event))
709 Show(false);
710 // restore state of server tab if necessary
711 EnableServerTab(thePrefs::GetNetworkED2K());
715 void PrefsUnifiedDlg::OnCheckBoxChange(wxCommandEvent& event)
717 bool value = event.IsChecked();
718 int id = event.GetId();
720 // Check if this checkbox is one of the User Events checkboxes
721 if (id >= USEREVENTS_FIRST_ID &&
722 id < USEREVENTS_FIRST_ID +
723 (int)CUserEvents::GetCount() * USEREVENTS_IDS_PER_EVENT) {
724 // The corresponding text control always has
725 // an ID one greater than the checkbox
726 FindWindow(id + 1)->Enable(value);
727 return;
730 switch ( id ) {
731 case IDC_UDPENABLE:
732 FindWindow( IDC_UDPPORT )->Enable(value);
733 break;
735 case IDC_CHECKDISKSPACE:
736 FindWindow( IDC_MINDISKSPACE )->Enable(value);
737 break;
739 case IDC_ONLINESIG:
740 FindWindow( IDC_OSDIR )->Enable(value);;
741 FindWindow(IDC_OSUPDATE)->Enable(value);
742 break;
744 case IDC_REMOVEDEAD:
745 FindWindow( IDC_SERVERRETRIES )->Enable(value);;
746 break;
748 case IDC_AUTOSERVER:
749 if ((CPath::GetFileSize(theApp->ConfigDir + wxT("addresses.dat")) == 0) &&
750 CastChild(event.GetId(), wxCheckBox)->IsChecked() ) {
751 wxMessageBox(_("Your Auto-update servers list is in blank.\nPlease fill in at least one URL to point to a valid server.met file.\nClick on the button \"List\" by this checkbox to enter an URL."),
752 _("Message"), wxOK | wxICON_INFORMATION);
753 CastChild(event.GetId(), wxCheckBox)->SetValue(false);
755 break;
757 case IDC_MSGFILTER:
758 // Toogle All filter options
759 FindWindow(IDC_MSGFILTER_ALL)->Enable(value);
760 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(value);
761 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(value);
762 FindWindow(IDC_MSGFILTER_WORD)->Enable(value);
763 if (value) {
764 FindWindow(IDC_MSGWORD)->Enable(
765 CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
766 } else {
767 FindWindow(IDC_MSGWORD)->Enable(false);
769 break;
771 case IDC_MSGFILTER_ALL:
772 // Toogle filtering by data.
773 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(!value);
774 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(!value);
775 FindWindow(IDC_MSGFILTER_WORD)->Enable(!value);
776 if (!value) {
777 FindWindow(IDC_MSGWORD)->Enable(
778 CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
779 } else {
780 FindWindow(IDC_MSGWORD)->Enable(false);
782 break;
784 case IDC_MSGFILTER_WORD:
785 // Toogle filter word list.
786 FindWindow(IDC_MSGWORD)->Enable(value);
787 break;
789 case IDC_FILTERCOMMENTS:
790 FindWindow(IDC_COMMENTWORD)->Enable(value);
791 break;
793 case ID_PROXY_ENABLE_PROXY:
794 FindWindow(ID_PROXY_TYPE)->Enable(value);
795 FindWindow(ID_PROXY_NAME)->Enable(value);
796 FindWindow(ID_PROXY_PORT)->Enable(value);
797 break;
799 case ID_PROXY_ENABLE_PASSWORD:
800 FindWindow(ID_PROXY_USER)->Enable(value);
801 FindWindow(ID_PROXY_PASSWORD)->Enable(value);
802 break;
804 case IDC_STARTNEXTFILE:
805 FindWindow(IDC_STARTNEXTFILE_SAME)->Enable(value);
806 break;
808 case IDC_ENABLETRAYICON:
809 FindWindow(IDC_MINTRAY)->Enable(value);
810 if (value) {
811 theApp->amuledlg->CreateSystray();
812 } else {
813 theApp->amuledlg->RemoveSystray();
815 thePrefs::SetUseTrayIcon(value);
816 break;
818 case ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY:
819 break;
821 case IDC_VERTTOOLBAR:
822 theApp->amuledlg->Create_Toolbar(value);
823 // Update the first tool (conn button)
824 theApp->amuledlg->ShowConnectionState();
825 break;
827 case IDC_ENFORCE_PO_INCOMING:
828 FindWindow(IDC_ENABLE_PO_OUTGOING)->Enable(!value);
829 break;
831 case IDC_ENABLE_PO_OUTGOING:
832 FindWindow(IDC_SUPPORT_PO)->Enable(!value);
833 FindWindow(IDC_ENFORCE_PO_INCOMING)->Enable(value);
834 break;
836 case IDC_SUPPORT_PO:
837 FindWindow(IDC_ENABLE_PO_OUTGOING)->Enable(value);
838 break;
840 case IDC_SHOWRATEONTITLE:
841 FindWindow(IDC_RATESBEFORETITLE)->Enable(value);
842 FindWindow(IDC_RATESAFTERTITLE)->Enable(value);
843 break;
845 case IDC_NETWORKED2K: {
846 EnableServerTab(value);
847 wxSpinEvent e;
848 OnTCPClientPortChange(e);
849 break;
852 default:
853 break;
858 void PrefsUnifiedDlg::OnButtonColorChange(wxCommandEvent& WXUNUSED(event))
860 int index = m_choiceColor->GetSelection();
861 wxColour col = wxGetColourFromUser( this, CMuleColour(thePrefs::s_colors[index]) );
862 if ( col.Ok() ) {
863 m_buttonColor->SetBackgroundColour( col );
864 thePrefs::s_colors[index] = CMuleColour(col).GetULong();
869 void PrefsUnifiedDlg::OnColorCategorySelected(wxCommandEvent& WXUNUSED(evt))
871 m_buttonColor->SetBackgroundColour(CMuleColour(thePrefs::s_colors[ m_choiceColor->GetSelection() ] ) );
875 void PrefsUnifiedDlg::OnButtonDir(wxCommandEvent& event)
877 wxString type;
879 int id = 0;
880 switch ( event.GetId() ) {
881 case IDC_SELTEMPDIR:
882 id = IDC_TEMPFILES;
883 type = _("Temporary files");
884 break;
886 case IDC_SELINCDIR:
887 id = IDC_INCFILES;
888 type = _("Incoming files");
889 break;
891 case IDC_SELOSDIR:
892 id = IDC_OSDIR;
893 type = _("Online Signatures");
894 break;
896 // case IDC_SELSKIN:
897 // id = IDC_SKIN;
898 // type = _("Skins directory");
899 // break;
901 default:
902 wxFAIL;
903 return;
906 type = CFormat(_("Choose a folder for %s")) % type;
907 wxTextCtrl* widget = CastChild( id, wxTextCtrl );
908 wxString dir = widget->GetValue();
909 wxString str = wxDirSelector(
910 type, dir,
911 wxDD_DEFAULT_STYLE,
912 wxDefaultPosition, this);
913 if (!str.IsEmpty()) {
914 widget->SetValue(str);
919 void PrefsUnifiedDlg::OnButtonBrowseApplication(wxCommandEvent& event)
921 wxString title;
922 int id = 0;
923 switch ( event.GetId() ) {
924 case IDC_BROWSEV:
925 id = IDC_VIDEOPLAYER;
926 title = _("Browse for videoplayer");
927 break;
928 case IDC_SELBROWSER:
929 id = IDC_BROWSERSELF;
930 title = _("Select browser");
931 break;
932 default:
933 wxFAIL;
934 return;
936 wxString wildcard = CFormat(_("Executable%s"))
937 #ifdef __WXMSW__
938 % wxT(" (*.exe)|*.exe");
939 #else
940 % wxT("|*");
941 #endif
943 wxString str = wxFileSelector( title, wxEmptyString, wxEmptyString,
944 wxEmptyString, wildcard, 0, this );
946 if ( !str.IsEmpty() ) {
947 wxTextCtrl* widget = CastChild( id, wxTextCtrl );
948 widget->SetValue( str );
953 void PrefsUnifiedDlg::OnButtonEditAddr(wxCommandEvent& WXUNUSED(evt))
955 wxString fullpath( theApp->ConfigDir + wxT("addresses.dat") );
957 EditServerListDlg* test = new EditServerListDlg(this, _("Edit server list"),
958 _("Add here URL's to download server.met files.\nOnly one url on each line."),
959 fullpath );
961 test->ShowModal();
962 delete test;
966 void PrefsUnifiedDlg::OnButtonIPFilterReload(wxCommandEvent& WXUNUSED(event))
968 theApp->ipfilter->Reload();
972 void PrefsUnifiedDlg::OnButtonIPFilterUpdate(wxCommandEvent& WXUNUSED(event))
974 theApp->ipfilter->Update( CastChild( IDC_IPFILTERURL, wxTextCtrl )->GetValue() );
978 void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent& event)
980 prefs_sizer->Detach( m_CurrentPanel );
981 m_CurrentPanel->Show( false );
983 m_CurrentPanel = (wxPanel *) m_PrefsIcons->GetItemData(event.GetIndex());
984 if (pages[event.GetIndex()].m_function == PreferencesDirectoriesTab) {
985 CastChild(IDC_SHARESELECTOR, CDirectoryTreeCtrl)->Init();
988 prefs_sizer->Add( m_CurrentPanel, 0, wxGROW|wxEXPAND );
989 m_CurrentPanel->Show( true );
991 Layout();
993 event.Skip();
997 void PrefsUnifiedDlg::OnToolTipDelayChange(wxSpinEvent& event)
999 wxToolTip::SetDelay( event.GetPosition() * 1000 );
1003 void PrefsUnifiedDlg::OnInitDialog( wxInitDialogEvent& WXUNUSED(evt) )
1005 // This function exists solely to avoid automatic transfer-to-widget calls
1009 void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent& event )
1011 int id = 0;
1012 wxString label;
1014 switch ( event.GetId() ) {
1015 case IDC_SLIDER:
1016 id = IDC_SLIDERINFO;
1017 label = wxString::Format( wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event.GetPosition()), event.GetPosition() );
1018 theApp->amuledlg->m_statisticswnd->SetUpdatePeriod(event.GetPosition());
1019 theApp->amuledlg->m_kademliawnd->SetUpdatePeriod(event.GetPosition());
1020 break;
1022 case IDC_SLIDER3:
1023 id = IDC_SLIDERINFO3;
1024 label = wxString::Format( wxPLURAL("Time for average graph: %d minute", "Time for average graph: %d minutes", event.GetPosition()), event.GetPosition() );
1025 theApp->m_statistics->SetAverageMinutes(event.GetPosition());
1026 break;
1028 case IDC_SLIDER4:
1029 id = IDC_SLIDERINFO4;
1030 label = wxString::Format( _("Connections Graph Scale: %d"), event.GetPosition() );
1031 theApp->amuledlg->m_statisticswnd->GetConnScope()->SetRanges(0,event.GetPosition());
1032 break;
1034 case IDC_SLIDER2:
1035 id = IDC_SLIDERINFO2;
1036 label = wxString::Format( wxPLURAL("Update delay : %d second", "Update delay : %d seconds", event.GetPosition()), event.GetPosition() );
1037 break;
1039 case IDC_FILEBUFFERSIZE:
1040 id = IDC_FILEBUFFERSIZE_STATIC;
1041 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1042 label = wxString::Format( wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event.GetPosition() * 15000), event.GetPosition() * 15000 );
1043 break;
1045 case IDC_QUEUESIZE:
1046 id = IDC_QUEUESIZE_STATIC;
1047 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1048 label = wxString::Format( wxPLURAL("Upload Queue Size: %d client", "Upload Queue Size: %d clients", event.GetPosition() * 100), event.GetPosition() * 100 );
1049 break;
1051 case IDC_SERVERKEEPALIVE:
1052 id = IDC_SERVERKEEPALIVE_LABEL;
1054 if ( event.GetPosition() ) {
1055 label = wxString::Format( wxPLURAL("Server connection refresh interval: %d minute", "Server connection refresh interval: %d minutes", event.GetPosition()), event.GetPosition() );
1056 } else {
1057 label = wxString::Format( _("Server connection refresh interval: Disabled") );
1059 break;
1061 default:
1062 return;
1065 wxStaticText* widget = CastChild( id, wxStaticText );
1067 if (widget) {
1068 widget->SetLabel( label );
1069 widget->GetParent()->Layout();
1074 void PrefsUnifiedDlg::OnRateLimitChanged( wxSpinEvent& event )
1076 // Here we do immediate sainity checking of the up/down ratio,
1077 // so that the user can see if his choice is illegal
1079 // We only do checks if the rate is limited
1080 if ( event.GetPosition() != (int)UNLIMITED ) {
1081 wxSpinCtrl* dlrate = CastChild( IDC_MAXDOWN, wxSpinCtrl );
1083 if ( event.GetPosition() < 4 ) {
1084 if ( ( event.GetPosition() * 3 < dlrate->GetValue() ) ||
1085 ( dlrate->GetValue() == (int)UNLIMITED ) ) {
1086 dlrate->SetValue( event.GetPosition() * 3 );
1088 } else if ( event.GetPosition() < 10 ) {
1089 if ( ( event.GetPosition() * 4 < dlrate->GetValue() ) ||
1090 ( dlrate->GetValue() == (int)UNLIMITED ) ) {
1091 dlrate->SetValue( event.GetPosition() * 4 );
1098 void PrefsUnifiedDlg::OnTCPClientPortChange(wxSpinEvent& WXUNUSED(event))
1100 CastChild(ID_TEXT_CLIENT_UDP_PORT, wxStaticText)->SetLabel(
1101 m_ServerTabVisible ? (wxString() << (CastChild(IDC_PORT, wxSpinCtrl)->GetValue() + 3))
1102 : wxString(_("disabled")));
1105 void PrefsUnifiedDlg::OnUserEventSelected(wxListEvent& event)
1107 for (unsigned int i = 0; i < CUserEvents::GetCount(); ++i) {
1108 IDC_PREFS_EVENTS_PAGE->Hide(i+1);
1111 IDC_PREFS_EVENTS_PAGE->Show((event.GetData() - USEREVENTS_FIRST_ID) / USEREVENTS_IDS_PER_EVENT + 1, true);
1113 IDC_PREFS_EVENTS_PAGE->Layout();
1115 event.Skip();
1118 void PrefsUnifiedDlg::CreateEventPanels(const int idx, const wxString& vars, wxWindow* parent)
1120 wxStaticBox *item8 = new wxStaticBox( parent, -1, CFormat(_("Execute command on `%s' event")) % wxGetTranslation(CUserEvents::GetDisplayName(static_cast<enum CUserEvents::EventType>(idx))) );
1121 wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxVERTICAL );
1123 wxCheckBox *item9 = new wxCheckBox( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 1, _("Enable command execution on core"), wxDefaultPosition, wxDefaultSize, 0 );
1124 item7->Add( item9, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
1126 wxFlexGridSizer *item10 = new wxFlexGridSizer( 3, 0, 0 );
1127 item10->AddGrowableCol( 2 );
1129 item10->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 0 );
1131 wxStaticText *item11 = new wxStaticText( parent, -1, _("Core command:"), wxDefaultPosition, wxDefaultSize, 0 );
1132 item10->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
1134 wxTextCtrl *item12 = new wxTextCtrl( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 2, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
1135 item12->Enable(CUserEvents::IsCoreCommandEnabled(static_cast<enum CUserEvents::EventType>(idx)));
1136 item10->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1138 item7->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
1140 wxCheckBox *item14 = new wxCheckBox( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 3, _("Enable command execution on GUI"), wxDefaultPosition, wxDefaultSize, 0 );
1141 item7->Add( item14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
1143 wxFlexGridSizer *item15 = new wxFlexGridSizer( 3, 0, 0 );
1144 item15->AddGrowableCol( 2 );
1146 item15->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 0 );
1148 wxStaticText *item16 = new wxStaticText( parent, -1, _("GUI command:"), wxDefaultPosition, wxDefaultSize, 0 );
1149 item15->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
1151 wxTextCtrl *item17 = new wxTextCtrl( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 4, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
1152 item17->Enable(CUserEvents::IsGUICommandEnabled(static_cast<enum CUserEvents::EventType>(idx)));
1153 item15->Add( item17, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1155 item7->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
1157 wxStaticText *item13 = new wxStaticText( parent, -1, _("The following variables will be replaced:") + vars, wxDefaultPosition, wxDefaultSize, 0 );
1158 item7->Add( item13, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1160 IDC_PREFS_EVENTS_PAGE->Add(item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1162 IDC_PREFS_EVENTS_PAGE->Layout();
1163 IDC_PREFS_EVENTS_PAGE->Hide(idx + 1);
1165 // File_checked_for_headers