Upstream tarball 20080324
[amule.git] / src / PrefsUnifiedDlg.cpp
blob9f68df0a7fb5579143073de6dfe6c98ed2719878
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 "Color.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_UDPDISABLE, PrefsUnifiedDlg::OnCheckBoxChange)
72 EVT_CHECKBOX(IDC_CHECKDISKSPACE, PrefsUnifiedDlg::OnCheckBoxChange)
73 EVT_CHECKBOX(IDC_USESKINFILES, PrefsUnifiedDlg::OnCheckBoxChange)
74 EVT_CHECKBOX(IDC_ONLINESIG, PrefsUnifiedDlg::OnCheckBoxChange)
75 EVT_CHECKBOX(IDC_REMOVEDEAD, PrefsUnifiedDlg::OnCheckBoxChange)
76 EVT_CHECKBOX(IDC_AUTOSERVER, PrefsUnifiedDlg::OnCheckBoxChange)
77 EVT_CHECKBOX(IDC_AUTOIPFILTER, PrefsUnifiedDlg::OnCheckBoxChange)
78 EVT_CHECKBOX(IDC_MSGFILTER, PrefsUnifiedDlg::OnCheckBoxChange)
79 EVT_CHECKBOX(IDC_MSGFILTER_ALL, PrefsUnifiedDlg::OnCheckBoxChange)
80 EVT_CHECKBOX(IDC_MSGFILTER_WORD, PrefsUnifiedDlg::OnCheckBoxChange)
81 EVT_CHECKBOX(IDC_FILTERCOMMENTS, PrefsUnifiedDlg::OnCheckBoxChange)
82 EVT_CHECKBOX(IDC_STARTNEXTFILE, PrefsUnifiedDlg::OnCheckBoxChange)
83 EVT_CHECKBOX(IDC_ENABLETRAYICON, PrefsUnifiedDlg::OnCheckBoxChange)
84 EVT_CHECKBOX(IDC_VERTTOOLBAR, PrefsUnifiedDlg::OnCheckBoxChange)
85 EVT_CHECKBOX(IDC_SUPPORT_PO, PrefsUnifiedDlg::OnCheckBoxChange)
86 EVT_CHECKBOX(IDC_ENABLE_PO_OUTGOING, PrefsUnifiedDlg::OnCheckBoxChange)
87 EVT_CHECKBOX(IDC_ENFORCE_PO_INCOMING, PrefsUnifiedDlg::OnCheckBoxChange)
89 EVT_BUTTON(ID_PREFS_OK_TOP, PrefsUnifiedDlg::OnOk)
90 EVT_BUTTON(ID_OK, PrefsUnifiedDlg::OnOk)
92 EVT_BUTTON(ID_PREFS_CANCEL_TOP, PrefsUnifiedDlg::OnCancel)
94 // Browse buttons
95 // EVT_BUTTON(IDC_SELSKIN, PrefsUnifiedDlg::OnButtonDir)
96 EVT_BUTTON(IDC_BTN_BROWSE_WAV, PrefsUnifiedDlg::OnButtonBrowseWav)
97 EVT_BUTTON(IDC_BROWSEV, PrefsUnifiedDlg::OnButtonBrowseApplication)
98 EVT_BUTTON(IDC_SELTEMPDIR, PrefsUnifiedDlg::OnButtonDir)
99 EVT_BUTTON(IDC_SELINCDIR, PrefsUnifiedDlg::OnButtonDir)
100 EVT_BUTTON(IDC_SELOSDIR, PrefsUnifiedDlg::OnButtonDir)
101 EVT_BUTTON(IDC_SELBROWSER, PrefsUnifiedDlg::OnButtonBrowseApplication)
103 EVT_SPINCTRL(IDC_TOOLTIPDELAY, PrefsUnifiedDlg::OnToolTipDelayChange)
105 EVT_BUTTON(IDC_EDITADR, PrefsUnifiedDlg::OnButtonEditAddr)
106 EVT_BUTTON(IDC_IPFRELOAD, PrefsUnifiedDlg::OnButtonIPFilterReload)
107 EVT_BUTTON(IDC_COLOR_BUTTON, PrefsUnifiedDlg::OnButtonColorChange)
108 EVT_BUTTON(IDC_IPFILTERUPDATE, PrefsUnifiedDlg::OnButtonIPFilterUpdate)
109 EVT_CHOICE(IDC_COLORSELECTOR, PrefsUnifiedDlg::OnColorCategorySelected)
110 EVT_CHOICE(IDC_BROWSER, PrefsUnifiedDlg::OnBrowserChange)
111 EVT_LIST_ITEM_SELECTED(ID_PREFSLISTCTRL,PrefsUnifiedDlg::OnPrefsPageChange)
113 EVT_INIT_DIALOG(PrefsUnifiedDlg::OnInitDialog)
115 EVT_COMMAND_SCROLL(IDC_SLIDER, PrefsUnifiedDlg::OnScrollBarChange)
116 EVT_COMMAND_SCROLL(IDC_SLIDER3, PrefsUnifiedDlg::OnScrollBarChange)
117 EVT_COMMAND_SCROLL(IDC_SLIDER4, PrefsUnifiedDlg::OnScrollBarChange)
118 EVT_COMMAND_SCROLL(IDC_SLIDER2, PrefsUnifiedDlg::OnScrollBarChange)
119 EVT_COMMAND_SCROLL(IDC_FILEBUFFERSIZE, PrefsUnifiedDlg::OnScrollBarChange)
120 EVT_COMMAND_SCROLL(IDC_QUEUESIZE, PrefsUnifiedDlg::OnScrollBarChange)
121 EVT_COMMAND_SCROLL(IDC_SERVERKEEPALIVE, PrefsUnifiedDlg::OnScrollBarChange)
123 EVT_SPINCTRL(IDC_MAXUP, PrefsUnifiedDlg::OnRateLimitChanged)
125 EVT_LIST_ITEM_SELECTED(IDC_EVENTLIST, PrefsUnifiedDlg::OnUserEventSelected)
127 EVT_CLOSE(PrefsUnifiedDlg::OnClose)
129 END_EVENT_TABLE()
133 * Creates an command-event for the given checkbox.
135 * This can be used enforce logical constraints by passing by
136 * sending a check-box event for each checkbox, when transfering
137 * to the UI. However, it should also be used for checkboxes that
138 * have no side-effects other than enabling/disabling other
139 * widgets in the preferences dialogs.
141 void SendCheckBoxEvent(wxWindow* parent, int id)
143 wxCheckBox* widget = CastByID(id, parent, wxCheckBox);
144 wxCHECK_RET(widget, wxT("Invalid widget in CreateEvent"));
146 wxCommandEvent evt(wxEVT_COMMAND_CHECKBOX_CLICKED, id);
147 evt.SetInt(widget->IsChecked() ? 1 : 0);
149 parent->ProcessEvent(evt);
155 * This struct provides a general way to represent config-tabs.
157 struct PrefsPage
159 //! The title of the page, used on the listctrl.
160 wxString m_title;
161 //! Function pointer to the wxDesigner function creating the dialog.
162 wxSizer* (*m_function)(wxWindow*, bool, bool );
163 //! The index of the image used on the list.
164 int m_imageidx;
165 //! The actual widget. To be set later.
166 wxPanel* m_widget;
170 PrefsPage pages[] =
172 { wxTRANSLATE("General"), PreferencesGeneralTab, 13, NULL },
173 { wxTRANSLATE("Connection"), PreferencesConnectionTab, 14, NULL },
174 { wxTRANSLATE("Proxy"), PreferencesProxyTab, 24, NULL },
175 { wxTRANSLATE("Message Filter"), PreferencesMessagesTab, 23, NULL },
176 { wxTRANSLATE("Remote Controls"), PreferencesRemoteControlsTab, 11, NULL },
177 { wxTRANSLATE("Online Signature"), PreferencesOnlineSigTab, 21, NULL },
178 { wxTRANSLATE("Server"), PreferencesServerTab, 15, NULL },
179 { wxTRANSLATE("Files"), PreferencesFilesTab, 16, NULL },
180 { wxTRANSLATE("Directories"), PreferencesDirectoriesTab, 17, NULL },
181 { wxTRANSLATE("Statistics"), PreferencesStatisticsTab, 10, NULL },
182 { wxTRANSLATE("Security"), PreferencesSecurityTab, 22, NULL },
183 //Notications are disabled since they havent been implemented
184 //{ wxTRANSLATE("Notifications"), PreferencesNotifyTab, 18, NULL },
185 { wxTRANSLATE("Gui Tweaks"), PreferencesGuiTweaksTab, 19, NULL },
186 { wxTRANSLATE("Core Tweaks"), PreferencesaMuleTweaksTab, 12, NULL },
187 { wxTRANSLATE("Events"), PreferencesEventsTab, 5, NULL }
188 #ifdef __DEBUG__
189 ,{ wxTRANSLATE("Debugging"), PreferencesDebug, 25, NULL }
190 #endif
194 PrefsUnifiedDlg::PrefsUnifiedDlg(wxWindow *parent)
196 wxDialog(parent, -1, _("Preferences"),
197 wxDefaultPosition, wxDefaultSize,
198 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
200 preferencesDlgTop(this, false);
202 wxListCtrl *PrefsIcons = CastChild(ID_PREFSLISTCTRL, wxListCtrl);
203 wxImageList *icon_list = new wxImageList(16, 16);
204 PrefsIcons->AssignImageList(icon_list, wxIMAGE_LIST_SMALL);
206 // Add the single column used
207 PrefsIcons->InsertColumn(
208 0, wxEmptyString, wxLIST_FORMAT_LEFT,
209 PrefsIcons->GetSize().GetWidth()-5);
211 // Temp variables for finding the smallest height and width needed
212 int width = 0;
213 int height = 0;
215 // Add each page to the page-list
216 for (unsigned int i = 0; i < itemsof(pages); ++i) {
217 // Add the icon and label assosiated with the page
218 icon_list->Add(amuleSpecial(pages[i].m_imageidx));
219 PrefsIcons->InsertItem(i, wxGetTranslation(pages[i].m_title), i);
222 // Set list-width so that there arn't any scrollers
223 PrefsIcons->SetColumnWidth(0, wxLIST_AUTOSIZE);
224 PrefsIcons->SetMinSize(wxSize(PrefsIcons->GetColumnWidth(0) + 10, -1));
225 PrefsIcons->SetMaxSize(wxSize(PrefsIcons->GetColumnWidth(0) + 10, -1));
227 // Now add the pages and calculate the minimum size
228 for (unsigned int i = 0; i < itemsof(pages); ++i) {
229 // Create a container widget and the contents of the page
230 pages[i].m_widget = new wxPanel(this, -1);
231 pages[i].m_function(pages[i].m_widget, true, true);
233 // Add it to the sizer
234 prefs_sizer->Add(pages[i].m_widget, 0, wxGROW|wxEXPAND);
236 if (pages[i].m_function == PreferencesGeneralTab) {
237 // This must be done now or pages won't Fit();
238 #ifdef __WXMSW__
239 CastChild(IDC_BROWSERTABS, wxCheckBox)->Enable(false);
240 wxChoice *browserCheck = CastChild(IDC_BROWSER, wxChoice);
241 browserCheck->Clear();
242 browserCheck->Append(_("System default"));
243 browserCheck->Append(_("User Defined"));
244 #endif /* __WXMSW__ */
245 } else if (pages[i].m_function == PreferencesEventsTab) {
247 #define USEREVENTS_REPLACE_VAR(VAR, DESC, CODE) + wxString(wxT("\n %") VAR wxT(" - ")) + wxGetTranslation(DESC)
248 #define USEREVENTS_EVENT(ID, NAME, VARS) case CUserEvents::ID: CreateEventPanels(idx, wxEmptyString VARS, pages[i].m_widget); break;
250 wxListCtrl *list = CastChild(IDC_EVENTLIST, wxListCtrl);
251 list->InsertColumn(0, wxEmptyString);
252 for (unsigned int idx = 0; idx < CUserEvents::GetCount(); ++idx) {
253 long lidx = list->InsertItem(idx,
254 wxGetTranslation(CUserEvents::GetDisplayName(
255 static_cast<enum CUserEvents::EventType>(idx))));
256 if (lidx != -1) {
257 list->SetItemData(lidx,
258 USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT);
259 switch (idx) {
260 USEREVENTS_EVENTLIST()
264 list->SetColumnWidth(0, wxLIST_AUTOSIZE);
266 #ifdef __DEBUG__
267 else if (pages[i].m_function == PreferencesDebug) {
268 int count = CLogger::GetDebugCategoryCount();
269 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
271 for ( int j = 0; j < count; j++ ) {
272 list->Append( CLogger::GetDebugCategory( j ).GetName() );
275 #endif
277 // Align and resize the page
278 Fit();
279 Layout();
281 // Find the greatest sizes
282 wxSize size = prefs_sizer->GetSize();
283 if (size.GetWidth() > width) {
284 width = size.GetWidth();
287 if (size.GetHeight() > height) {
288 height = size.GetHeight();
291 // Hide it for now
292 prefs_sizer->Detach(pages[i].m_widget);
293 pages[i].m_widget->Show(false);
296 // Default to the General tab
297 m_CurrentPanel = pages[0].m_widget;
298 prefs_sizer->Add(pages[0].m_widget, 0, wxGROW|wxEXPAND);
299 m_CurrentPanel->Show( true );
301 // Select the first item
302 PrefsIcons->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
304 // We now have the needed minimum height and width
305 prefs_sizer->SetMinSize(width, height);
307 // Store some often used pointers
308 m_ShareSelector = CastChild(IDC_SHARESELECTOR, CDirectoryTreeCtrl);
309 m_buttonColor = CastChild(IDC_COLOR_BUTTON, wxButton);
310 m_choiceColor = CastChild(IDC_COLORSELECTOR, wxChoice);
312 // Connect the Cfgs with their widgets
313 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
314 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
315 // Checking for failures
316 if ( !it->second->ConnectToWidget(it->first, this) ) {
317 printf("Failed to connect Cfg to widget with the ID %d and key %s\n",
318 it->first, (const char *)unicode2char(it->second->GetKey()));
321 Fit();
323 // It must not be resized to something smaller than what it currently is
324 wxSize size = GetClientSize();
325 SetSizeHints(size.GetWidth(), size.GetHeight());
327 #ifdef __WXMSW__
328 FindWindow(IDC_VERTTOOLBAR)->Enable(false);
329 #endif
333 Cfg_Base* PrefsUnifiedDlg::GetCfg(int id)
335 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.find( id );
337 if ( it != thePrefs::s_CfgList.end() ) {
338 return it->second;
341 return NULL;
345 bool PrefsUnifiedDlg::TransferToWindow()
347 // Connect the Cfgs with their widgets
348 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
349 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
350 // Checking for failures
351 if ( !it->second->TransferToWindow() ) {
352 printf("Failed to transfer data from Cfg to Widget with the ID %d and key %s\n",
353 it->first, (const char *)unicode2char(it->second->GetKey()));
357 m_ShareSelector->SetSharedDirectories(&theApp->glob_prefs->shareddir_list);
359 for ( int i = 0; i < cntStatColors; i++ ) {
360 thePrefs::s_colors[i] = CStatisticsDlg::acrStat[i];
361 thePrefs::s_colors_ref[i] = CStatisticsDlg::acrStat[i];
364 // Connection tab
365 wxSpinEvent e;
366 OnTCPClientPortChange(e);
368 // Proxy tab initialization
369 if (!CastChild(ID_PROXY_ENABLE_PROXY, wxCheckBox)->IsChecked()) {
370 FindWindow(ID_PROXY_TYPE)->Enable(false);
371 FindWindow(ID_PROXY_NAME)->Enable(false);
372 FindWindow(ID_PROXY_PORT)->Enable(false);
374 if (!CastChild(ID_PROXY_ENABLE_PASSWORD, wxCheckBox)->IsChecked()) {
375 FindWindow(ID_PROXY_USER)->Enable(false);
376 FindWindow(ID_PROXY_PASSWORD)->Enable(false);
378 // This option from the proxy tab is currently unused
379 FindWindow(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY)->Enable(false);
381 // Enable/Disable some controls
382 bool customBrowser =
383 CastChild(IDC_BROWSER, wxChoice)->GetSelection() ==
384 (int)CastChild(IDC_BROWSER, wxChoice)->GetCount() - 1;
385 FindWindow( IDC_BROWSERSELF )->Enable( customBrowser );
386 FindWindow( IDC_SELBROWSER )->Enable( customBrowser );
387 #ifndef __WXMSW__
388 FindWindow( IDC_BROWSERTABS )->Enable( !customBrowser );
389 #endif
390 FindWindow( IDC_MINDISKSPACE )->Enable( thePrefs::IsCheckDiskspaceEnabled() );
391 FindWindow( IDC_SKIN )->Enable( thePrefs::UseSkins() );
392 FindWindow( IDC_OSDIR )->Enable( thePrefs::IsOnlineSignatureEnabled() );
393 FindWindow( IDC_OSUPDATE )->Enable( thePrefs::IsOnlineSignatureEnabled() );
394 FindWindow( IDC_UDPPORT )->Enable( !thePrefs::s_UDPDisable );
395 FindWindow( IDC_SERVERRETRIES )->Enable( thePrefs::DeadServer() );
396 FindWindow( IDC_STARTNEXTFILE_SAME )->Enable(thePrefs::StartNextFile());
398 #ifdef __WXMAC__
399 FindWindow(IDC_ENABLETRAYICON)->Enable(false);
400 FindWindow(IDC_MINTRAY)->Enable(false);
401 #else
402 FindWindow(IDC_MINTRAY)->Enable(thePrefs::UseTrayIcon());
403 #endif
405 if (!CastChild(IDC_MSGFILTER, wxCheckBox)->IsChecked()) {
406 FindWindow(IDC_MSGFILTER_ALL)->Enable(false);
407 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(false);
408 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(false);
409 FindWindow(IDC_MSGFILTER_WORD)->Enable(false);
410 FindWindow(IDC_MSGWORD)->Enable(false);
411 } else if (CastChild(IDC_MSGFILTER_ALL, wxCheckBox)->IsChecked()) {
412 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(false);
413 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(false);
414 FindWindow(IDC_MSGFILTER_WORD)->Enable(false);
415 FindWindow(IDC_MSGWORD)->Enable(false);
418 FindWindow(IDC_MSGWORD)->Enable(CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
419 FindWindow(IDC_COMMENTWORD)->Enable(CastChild(IDC_FILTERCOMMENTS, wxCheckBox)->IsChecked());
421 // Protocol obfuscation
422 ::SendCheckBoxEvent(this, IDC_SUPPORT_PO);
423 ::SendCheckBoxEvent(this, IDC_ENABLE_PO_OUTGOING);
424 ::SendCheckBoxEvent(this, IDC_ENFORCE_PO_INCOMING);
426 #ifdef __DEBUG__
427 // Set debugging toggles
428 int count = CLogger::GetDebugCategoryCount();
429 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
431 for ( int i = 0; i < count; i++ ) {
432 list->Check( i, CLogger::GetDebugCategory( i ).IsEnabled() );
434 #endif
436 return true;
440 bool PrefsUnifiedDlg::TransferFromWindow()
442 // Connect the Cfgs with their widgets
443 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
444 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
445 // Checking for failures
446 if ( !it->second->TransferFromWindow() ) {
447 printf("Failed to transfer data from Widget to Cfg with the ID %d and key %s\n",
448 it->first, (const char *)unicode2char(it->second->GetKey()));
452 theApp->glob_prefs->shareddir_list.clear();
453 m_ShareSelector->GetSharedDirectories(&theApp->glob_prefs->shareddir_list);
455 for ( int i = 0; i < cntStatColors; i++ ) {
456 if ( thePrefs::s_colors[i] != thePrefs::s_colors_ref[i] ) {
457 CStatisticsDlg::acrStat[i] = thePrefs::s_colors[i];
458 theApp->amuledlg->m_statisticswnd->ApplyStatsColor(i);
461 theApp->amuledlg->m_kademliawnd->SetGraphColors();
464 #ifdef __DEBUG__
465 // Get debugging toggles
466 int count = CLogger::GetDebugCategoryCount();
467 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
469 for ( int i = 0; i < count; i++ ) {
470 CLogger::SetEnabled( CLogger::GetDebugCategory( i ).GetType(), list->IsChecked( i ) );
472 #endif
474 #ifdef CLIENT_GUI
475 // Send preferences to core.
476 theApp->glob_prefs->SendToRemote();
477 #endif
479 return true;
483 bool PrefsUnifiedDlg::CfgChanged(int ID)
485 Cfg_Base* cfg = GetCfg(ID);
487 if ( cfg ) {
488 return cfg->HasChanged();
491 return false;
495 void PrefsUnifiedDlg::OnOk(wxCommandEvent& WXUNUSED(event))
497 TransferFromWindow();
499 bool restart_needed = false;
500 wxString restart_needed_msg = _("aMule must be restarted to enable these changes:\n\n");
502 // do sanity checking, special processing, and user notifications here
503 thePrefs::CheckUlDlRatio();
505 if (CfgChanged(IDC_PORT)) {
506 restart_needed = true;
507 restart_needed_msg += _("- TCP port changed.\n");
510 if (CfgChanged(IDC_UDPPORT)) {
511 restart_needed = true;
512 restart_needed_msg += _("- UDP port changed.\n");
515 // Force port checking
516 thePrefs::SetPort(thePrefs::GetPort());
518 if ((CPath::GetFileSize(theApp->ConfigDir + wxT("addresses.dat")) == 0) &&
519 CastChild(IDC_AUTOSERVER, wxCheckBox)->IsChecked() ) {
520 thePrefs::UnsetAutoServerStart();
521 wxMessageBox(wxString::wxString( _("Your Auto-update servers list is in blank.\n'Auto-update serverlist at startup' will be disabled.")),
522 _("Message"), wxOK | wxICON_INFORMATION, this);
525 if (thePrefs::AcceptExternalConnections() && thePrefs::ECPassword().IsEmpty()) {
526 thePrefs::EnableExternalConnections( false );
528 wxMessageBox( _("You have enabled external connections but have not specified a password.\nExternal connections cannot be enabled unless a valid password is specified."));
531 // save the preferences on ok
532 theApp->glob_prefs->Save();
534 if (CfgChanged(IDC_FED2KLH) && theApp->amuledlg->GetActiveDialog() != CamuleDlg::DT_SEARCH_WND) {
535 theApp->amuledlg->ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
538 if (CfgChanged(IDC_LANGUAGE)) {
539 restart_needed = true;
540 restart_needed_msg += _("- Language changed.\n");
543 if (CfgChanged(IDC_TEMPFILES)) {
544 restart_needed = true;
545 restart_needed_msg += _("- Temp folder changed.\n");
548 if (CfgChanged(IDC_INCFILES) || CfgChanged(IDC_TEMPFILES) || m_ShareSelector->HasChanged ) {
549 theApp->sharedfiles->Reload();
552 if (CfgChanged(IDC_OSDIR) || CfgChanged(IDC_ONLINESIG)) {
553 wxTextCtrl* widget = CastChild( IDC_OSDIR, wxTextCtrl );
555 // Build the filenames for the two OS files
556 theApp->SetOSFiles( widget->GetValue() );
559 if (CfgChanged(IDC_IPFCLIENTS) || CfgChanged(IDC_IPFSERVERS) || CfgChanged(ID_IPFILTERLEVEL)) {
560 if (thePrefs::IsFilteringClients()) {
561 theApp->clientlist->FilterQueues();
563 if (thePrefs::IsFilteringServers()) {
564 theApp->serverlist->FilterServers();
568 if (thePrefs::GetShowRatesOnTitle()) {
569 // This avoids a 5 seconds delay to show the title
570 theApp->amuledlg->SetTitle(theApp->m_FrameTitle + wxT(" -- ") + _("Up: 0.0 | Down: 0.0"));
571 } else {
572 // This resets the title
573 theApp->amuledlg->SetTitle(theApp->m_FrameTitle);
576 if (CfgChanged(IDC_EXTCATINFO)) {
577 theApp->amuledlg->m_transferwnd->UpdateCatTabTitles();
580 // Changes related to the statistics-dlg
581 if (CfgChanged(IDC_SLIDER)) {
582 theApp->amuledlg->m_statisticswnd->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
583 theApp->amuledlg->m_kademliawnd->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
586 if ( CfgChanged(IDC_SLIDER3) ) {
587 theApp->amuledlg->m_statisticswnd->ResetAveragingTime();
590 if (CfgChanged(IDC_DOWNLOAD_CAP)) {
591 theApp->amuledlg->m_statisticswnd->SetARange( true, thePrefs::GetMaxGraphDownloadRate() );
594 if (CfgChanged(IDC_UPLOAD_CAP)) {
595 theApp->amuledlg->m_statisticswnd->SetARange( false, thePrefs::GetMaxGraphUploadRate() );
598 if (CfgChanged(IDC_SKIN) || CfgChanged(IDC_USESKINFILES)) {
599 theApp->amuledlg->Create_Toolbar(thePrefs::VerticalToolbar());
602 if (!thePrefs::GetNetworkED2K() && theApp->IsConnectedED2K()) {
603 theApp->DisconnectED2K();
606 if (!thePrefs::GetNetworkKademlia() && theApp->IsConnectedKad()) {
607 theApp->StopKad();
610 if (!thePrefs::GetNetworkED2K() && !thePrefs::GetNetworkKademlia()) {
611 wxMessageBox(wxString::wxString(
612 _("Both ED2K and Kad network are disabled.\nYou won't be able to connect until you enable at least one of them.")));
615 if (thePrefs::GetNetworkKademlia() && thePrefs::IsUDPDisabled()) {
616 wxMessageBox(_("Kad will not start if your UDP port is disabled.\nEnable UDP port or disable Kad."),
617 _("Message"), wxOK | wxICON_INFORMATION, this);
620 if (restart_needed) {
621 wxMessageBox(restart_needed_msg + _("\nYou MUST restart aMule now.\nIf you do not restart now, don't complain if anything bad happens.\n"), _("WARNING"),wxICON_EXCLAMATION,this);
624 Show(false);
628 void PrefsUnifiedDlg::OnClose(wxCloseEvent& event)
630 Show(false);
632 // Try to keep the window alive when possible
633 if (event.CanVeto()) {
634 event.Veto();
635 } else {
636 if (theApp->amuledlg) {
637 theApp->amuledlg->m_prefsDialog = NULL;
640 // Un-Connect the Cfgs
641 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
642 for (; it != thePrefs::s_CfgList.end(); ++it) {
643 // Checking for failures
644 it->second->ConnectToWidget( 0 );
647 Destroy();
652 void PrefsUnifiedDlg::OnCancel(wxCommandEvent& WXUNUSED(event))
654 Show(false);
658 void PrefsUnifiedDlg::OnCheckBoxChange(wxCommandEvent& event)
660 bool value = event.IsChecked();
661 int id = event.GetId();
663 // Check if this checkbox is one of the User Events checkboxes
664 if (id >= USEREVENTS_FIRST_ID &&
665 id < USEREVENTS_FIRST_ID +
666 (int)CUserEvents::GetCount() * USEREVENTS_IDS_PER_EVENT) {
667 // The corresponding text control always has
668 // an ID one greater than the checkbox
669 FindWindow(id + 1)->Enable(value);
670 return;
673 switch ( id ) {
674 case IDC_UDPDISABLE:
675 // UDP is disable rather than enable, so we flip the value
676 FindWindow( IDC_UDPPORT )->Enable(!value);
677 break;
679 case IDC_CHECKDISKSPACE:
680 FindWindow( IDC_MINDISKSPACE )->Enable(value);
681 break;
683 case IDC_USESKINFILES:
684 FindWindow( IDC_SKIN )->Enable(value);;
685 break;
687 case IDC_ONLINESIG:
688 FindWindow( IDC_OSDIR )->Enable(value);;
689 FindWindow(IDC_OSUPDATE)->Enable(value);
690 break;
692 case IDC_REMOVEDEAD:
693 FindWindow( IDC_SERVERRETRIES )->Enable(value);;
694 break;
696 case IDC_AUTOSERVER:
697 if ((CPath::GetFileSize(theApp->ConfigDir + wxT("addresses.dat")) == 0) &&
698 CastChild(event.GetId(), wxCheckBox)->IsChecked() ) {
699 wxMessageBox(wxString::wxString( _("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.")),
700 _("Message"), wxOK | wxICON_INFORMATION);
701 CastChild(event.GetId(), wxCheckBox)->SetValue(false);
703 break;
705 case IDC_MSGFILTER:
706 // Toogle All filter options
707 FindWindow(IDC_MSGFILTER_ALL)->Enable(value);
708 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(value);
709 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(value);
710 FindWindow(IDC_MSGFILTER_WORD)->Enable(value);
711 if (value) {
712 FindWindow(IDC_MSGWORD)->Enable(
713 CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
714 } else {
715 FindWindow(IDC_MSGWORD)->Enable(false);
717 break;
719 case IDC_MSGFILTER_ALL:
720 // Toogle filtering by data.
721 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(!value);
722 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(!value);
723 FindWindow(IDC_MSGFILTER_WORD)->Enable(!value);
724 if (!value) {
725 FindWindow(IDC_MSGWORD)->Enable(
726 CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
727 } else {
728 FindWindow(IDC_MSGWORD)->Enable(false);
730 break;
732 case IDC_MSGFILTER_WORD:
733 // Toogle filter word list.
734 FindWindow(IDC_MSGWORD)->Enable(value);
735 break;
737 case IDC_FILTERCOMMENTS:
738 FindWindow(IDC_COMMENTWORD)->Enable(value);
739 break;
741 case ID_PROXY_ENABLE_PROXY:
742 FindWindow(ID_PROXY_TYPE)->Enable(value);
743 FindWindow(ID_PROXY_NAME)->Enable(value);
744 FindWindow(ID_PROXY_PORT)->Enable(value);
745 break;
747 case ID_PROXY_ENABLE_PASSWORD:
748 FindWindow(ID_PROXY_USER)->Enable(value);
749 FindWindow(ID_PROXY_PASSWORD)->Enable(value);
750 break;
752 case IDC_STARTNEXTFILE:
753 FindWindow(IDC_STARTNEXTFILE_SAME)->Enable(value);
754 break;
756 case IDC_ENABLETRAYICON:
757 FindWindow(IDC_MINTRAY)->Enable(value);
758 if (value) {
759 theApp->amuledlg->CreateSystray();
760 } else {
761 theApp->amuledlg->RemoveSystray();
763 thePrefs::SetUseTrayIcon(value);
764 break;
766 case ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY:
767 break;
768 case IDC_VERTTOOLBAR:
769 theApp->amuledlg->Create_Toolbar(value);
770 // Update the first tool (conn button)
771 theApp->amuledlg->ShowConnectionState();
772 break;
774 case IDC_ENFORCE_PO_INCOMING:
775 FindWindow(IDC_ENABLE_PO_OUTGOING)->Enable(!value);
776 break;
778 case IDC_ENABLE_PO_OUTGOING:
779 FindWindow(IDC_SUPPORT_PO)->Enable(!value);
780 FindWindow(IDC_ENFORCE_PO_INCOMING)->Enable(value);
781 break;
783 case IDC_SUPPORT_PO:
784 FindWindow(IDC_ENABLE_PO_OUTGOING)->Enable(value);
785 break;
787 default:
788 break;
793 void PrefsUnifiedDlg::OnButtonColorChange(wxCommandEvent& WXUNUSED(event))
795 int index = m_choiceColor->GetSelection();
796 wxColour col = WxColourFromCr( thePrefs::s_colors[index] );
797 col = wxGetColourFromUser( this, col );
798 if ( col.Ok() ) {
799 m_buttonColor->SetBackgroundColour( col );
800 thePrefs::s_colors[index] = CrFromWxColour(col);
805 void PrefsUnifiedDlg::OnColorCategorySelected(wxCommandEvent& WXUNUSED(evt))
807 m_buttonColor->SetBackgroundColour(
808 WxColourFromCr( thePrefs::s_colors[ m_choiceColor->GetSelection() ] ) );
812 void PrefsUnifiedDlg::OnBrowserChange( wxCommandEvent& evt )
814 wxTextCtrl* textctrl = CastChild( IDC_BROWSERSELF, wxTextCtrl );
815 wxButton* btn = CastChild( IDC_SELBROWSER, wxButton );
816 bool enable =
817 evt.GetSelection() ==
818 (int)CastChild( IDC_BROWSER, wxChoice )->GetCount() - 1;
820 if (textctrl) {
821 textctrl->Enable( enable );
823 if (btn) {
824 btn->Enable( enable );
826 #ifndef __WXMSW__
827 FindWindow( IDC_BROWSERTABS )->Enable( !enable );
828 #endif
832 void PrefsUnifiedDlg::OnButtonDir(wxCommandEvent& event)
834 wxString type;
836 int id = 0;
837 switch ( event.GetId() ) {
838 case IDC_SELTEMPDIR:
839 id = IDC_TEMPFILES;
840 type = _("Temporary files");
841 break;
843 case IDC_SELINCDIR:
844 id = IDC_INCFILES;
845 type = _("Incoming files");
846 break;
848 case IDC_SELOSDIR:
849 id = IDC_OSDIR;
850 type = _("Online Signatures");
851 break;
853 // case IDC_SELSKIN:
854 // id = IDC_SKIN;
855 // type = _("Skins directory");
856 // break;
858 default:
859 wxASSERT(false);
860 return;
863 type = CFormat(_("Choose a folder for %s")) % type;
864 wxTextCtrl* widget = CastChild( id, wxTextCtrl );
865 wxString dir = widget->GetValue();
866 wxString str = wxDirSelector(
867 type, dir,
868 wxDD_DEFAULT_STYLE,
869 wxDefaultPosition, this);
870 if (!str.IsEmpty()) {
871 widget->SetValue(str);
876 void PrefsUnifiedDlg::OnButtonBrowseWav(wxCommandEvent& WXUNUSED(evt))
878 wxString str = wxFileSelector(
879 _("Browse wav"), wxEmptyString, wxEmptyString,
880 wxT("*.wav"), _("File wav (*.wav)|*.wav||"), 0, this );
882 if ( !str.IsEmpty() ) {
883 wxTextCtrl* widget = CastChild( IDC_EDIT_TBN_WAVFILE, wxTextCtrl );
885 widget->SetValue( str );
890 void PrefsUnifiedDlg::OnButtonBrowseApplication(wxCommandEvent& event)
892 wxString title;
893 int id = 0;
894 switch ( event.GetId() ) {
895 case IDC_BROWSEV:
896 id = IDC_VIDEOPLAYER;
897 title = _("Browse for videoplayer");
898 break;
899 case IDC_SELBROWSER:
900 id = IDC_BROWSERSELF;
901 title = _("Select browser");
902 break;
903 default:
904 wxASSERT( false );
905 return;
907 wxString wildcard = CFormat(_("Executable%s"))
908 #ifdef __WINDOWS__
909 % wxT(" (*.exe)|*.exe");
910 #else
911 % wxT("|*");
912 #endif
914 wxString str = wxFileSelector( title, wxEmptyString, wxEmptyString,
915 wxEmptyString, wildcard, 0, this );
917 if ( !str.IsEmpty() ) {
918 wxTextCtrl* widget = CastChild( id, wxTextCtrl );
919 widget->SetValue( str );
924 void PrefsUnifiedDlg::OnButtonEditAddr(wxCommandEvent& WXUNUSED(evt))
926 wxString fullpath( theApp->ConfigDir + wxT("addresses.dat") );
928 EditServerListDlg* test = new EditServerListDlg(this, _("Edit Serverlist"),
929 _("Add here URL's to download server.met files.\nOnly one url on each line."),
930 fullpath );
932 test->ShowModal();
933 delete test;
937 void PrefsUnifiedDlg::OnButtonIPFilterReload(wxCommandEvent& WXUNUSED(event))
939 theApp->ipfilter->Reload();
943 void PrefsUnifiedDlg::OnButtonIPFilterUpdate(wxCommandEvent& WXUNUSED(event))
945 theApp->ipfilter->Update( CastChild( IDC_IPFILTERURL, wxTextCtrl )->GetValue() );
949 void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent& event)
951 prefs_sizer->Detach( m_CurrentPanel );
952 m_CurrentPanel->Show( false );
954 m_CurrentPanel = pages[ event.GetIndex() ].m_widget;
956 prefs_sizer->Add( m_CurrentPanel, 0, wxGROW|wxEXPAND );
957 m_CurrentPanel->Show( true );
959 Layout();
961 event.Skip();
965 void PrefsUnifiedDlg::OnToolTipDelayChange(wxSpinEvent& event)
967 wxToolTip::SetDelay( event.GetPosition() * 1000 );
971 void PrefsUnifiedDlg::OnInitDialog( wxInitDialogEvent& WXUNUSED(evt) )
973 // This function exists solely to avoid automatic transfer-to-widget calls
977 void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent& event )
979 int id = 0;
980 wxString label;
982 switch ( event.GetId() ) {
983 case IDC_SLIDER:
984 id = IDC_SLIDERINFO;
985 label = wxString::Format( wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event.GetPosition()), event.GetPosition() );
986 theApp->amuledlg->m_statisticswnd->SetUpdatePeriod(event.GetPosition());
987 theApp->amuledlg->m_kademliawnd->SetUpdatePeriod(event.GetPosition());
988 break;
990 case IDC_SLIDER3:
991 id = IDC_SLIDERINFO3;
992 label = wxString::Format( wxPLURAL("Time for average graph: %d minute", "Time for average graph: %d minutes", event.GetPosition()), event.GetPosition() );
993 theApp->m_statistics->SetAverageMinutes(event.GetPosition());
994 break;
996 case IDC_SLIDER4:
997 id = IDC_SLIDERINFO4;
998 label = wxString::Format( _("Connections Graph Scale: %d"), event.GetPosition() );
999 theApp->amuledlg->m_statisticswnd->GetConnScope()->SetRanges(0,event.GetPosition());
1000 break;
1002 case IDC_SLIDER2:
1003 id = IDC_SLIDERINFO2;
1004 label = wxString::Format( wxPLURAL("Update delay : %d second", "Update delay : %d seconds", event.GetPosition()), event.GetPosition() );
1005 break;
1007 case IDC_FILEBUFFERSIZE:
1008 id = IDC_FILEBUFFERSIZE_STATIC;
1009 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1010 label = wxString::Format( wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event.GetPosition() * 15000), event.GetPosition() * 15000 );
1011 break;
1013 case IDC_QUEUESIZE:
1014 id = IDC_QUEUESIZE_STATIC;
1015 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1016 label = wxString::Format( wxPLURAL("Upload Queue Size: %d client", "Upload Queue Size: %d clients", event.GetPosition() * 100), event.GetPosition() * 100 );
1017 break;
1019 case IDC_SERVERKEEPALIVE:
1020 id = IDC_SERVERKEEPALIVE_LABEL;
1022 if ( event.GetPosition() ) {
1023 label = wxString::Format( wxPLURAL("Server connection refresh interval: %d minute", "Server connection refresh interval: %d minutes", event.GetPosition()), event.GetPosition() );
1024 } else {
1025 label = wxString::Format( _("Server connection refresh interval: Disabled") );
1027 break;
1029 default:
1030 return;
1033 wxStaticText* widget = CastChild( id, wxStaticText );
1035 if (widget) {
1036 widget->SetLabel( label );
1037 widget->GetParent()->Layout();
1042 void PrefsUnifiedDlg::OnRateLimitChanged( wxSpinEvent& event )
1044 // Here we do immediate sainity checking of the up/down ratio,
1045 // so that the user can see if his choice is illegal
1047 // We only do checks if the rate is limited
1048 if ( event.GetPosition() != (int)UNLIMITED ) {
1049 wxSpinCtrl* dlrate = CastChild( IDC_MAXDOWN, wxSpinCtrl );
1051 if ( event.GetPosition() < 4 ) {
1052 if ( ( event.GetPosition() * 3 < dlrate->GetValue() ) ||
1053 ( dlrate->GetValue() == (int)UNLIMITED ) ) {
1054 dlrate->SetValue( event.GetPosition() * 3 );
1056 } else if ( event.GetPosition() < 10 ) {
1057 if ( ( event.GetPosition() * 4 < dlrate->GetValue() ) ||
1058 ( dlrate->GetValue() == (int)UNLIMITED ) ) {
1059 dlrate->SetValue( event.GetPosition() * 4 );
1066 void PrefsUnifiedDlg::OnTCPClientPortChange(wxSpinEvent& WXUNUSED(event))
1068 int port = CastChild(IDC_PORT, wxSpinCtrl)->GetValue();
1069 wxString txt;
1070 txt << wxT("UDP port for extended server requests (TCP+3):") << port + 3;
1071 CastChild(ID_TEXT_CLIENT_UDP_PORT, wxStaticText)->SetLabel(txt);
1074 void PrefsUnifiedDlg::OnUserEventSelected(wxListEvent& event)
1076 for (unsigned int i = 0; i < CUserEvents::GetCount(); ++i) {
1077 IDC_PREFS_EVENTS_PAGE->Hide(i + 2);
1080 IDC_PREFS_EVENTS_PAGE->Show((event.GetData() - USEREVENTS_FIRST_ID) / USEREVENTS_IDS_PER_EVENT + 2, true);
1082 IDC_PREFS_EVENTS_PAGE->Layout();
1084 event.Skip();
1087 void PrefsUnifiedDlg::CreateEventPanels(const int idx, const wxString& vars, wxWindow* parent)
1089 wxStaticBox *item8 = new wxStaticBox( parent, -1, CFormat(_("Execute command on `%s' event")) % wxGetTranslation(CUserEvents::GetDisplayName(static_cast<enum CUserEvents::EventType>(idx))) );
1090 wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxVERTICAL );
1092 wxCheckBox *item9 = new wxCheckBox( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 1, _("Enable command execution on core"), wxDefaultPosition, wxDefaultSize, 0 );
1093 item7->Add( item9, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
1095 wxFlexGridSizer *item10 = new wxFlexGridSizer( 3, 0, 0 );
1096 item10->AddGrowableCol( 2 );
1098 item10->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 0 );
1100 wxStaticText *item11 = new wxStaticText( parent, -1, _("Core command:"), wxDefaultPosition, wxDefaultSize, 0 );
1101 item10->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
1103 wxTextCtrl *item12 = new wxTextCtrl( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 2, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
1104 item12->Enable(CUserEvents::IsCoreCommandEnabled(static_cast<enum CUserEvents::EventType>(idx)));
1105 item10->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1107 item7->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
1109 wxCheckBox *item14 = new wxCheckBox( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 3, _("Enable command execution on GUI"), wxDefaultPosition, wxDefaultSize, 0 );
1110 item7->Add( item14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
1112 wxFlexGridSizer *item15 = new wxFlexGridSizer( 3, 0, 0 );
1113 item15->AddGrowableCol( 2 );
1115 item15->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 0 );
1117 wxStaticText *item16 = new wxStaticText( parent, -1, _("GUI command:"), wxDefaultPosition, wxDefaultSize, 0 );
1118 item15->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
1120 wxTextCtrl *item17 = new wxTextCtrl( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 4, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
1121 item17->Enable(CUserEvents::IsGUICommandEnabled(static_cast<enum CUserEvents::EventType>(idx)));
1122 item15->Add( item17, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1124 item7->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
1126 wxStaticText *item13 = new wxStaticText( parent, -1, _("The following variables will be replaced:") + vars, wxDefaultPosition, wxDefaultSize, 0 );
1127 item7->Add( item13, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1129 IDC_PREFS_EVENTS_PAGE->Add(item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1131 IDC_PREFS_EVENTS_PAGE->Layout();
1132 IDC_PREFS_EVENTS_PAGE->Hide(idx + 2);
1134 // File_checked_for_headers