Upstream tarball 20080609
[amule.git] / src / PrefsUnifiedDlg.cpp
blob6beadf5738637e793e272c68bda819c4a68956e9
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_PREFS_CANCEL_TOP, PrefsUnifiedDlg::OnCancel)
92 // Browse buttons
93 // EVT_BUTTON(IDC_SELSKIN, PrefsUnifiedDlg::OnButtonDir)
94 EVT_BUTTON(IDC_BROWSEV, PrefsUnifiedDlg::OnButtonBrowseApplication)
95 EVT_BUTTON(IDC_SELTEMPDIR, PrefsUnifiedDlg::OnButtonDir)
96 EVT_BUTTON(IDC_SELINCDIR, PrefsUnifiedDlg::OnButtonDir)
97 EVT_BUTTON(IDC_SELOSDIR, PrefsUnifiedDlg::OnButtonDir)
98 EVT_BUTTON(IDC_SELBROWSER, PrefsUnifiedDlg::OnButtonBrowseApplication)
100 EVT_SPINCTRL(IDC_TOOLTIPDELAY, PrefsUnifiedDlg::OnToolTipDelayChange)
102 EVT_BUTTON(IDC_EDITADR, PrefsUnifiedDlg::OnButtonEditAddr)
103 EVT_BUTTON(IDC_IPFRELOAD, PrefsUnifiedDlg::OnButtonIPFilterReload)
104 EVT_BUTTON(IDC_COLOR_BUTTON, PrefsUnifiedDlg::OnButtonColorChange)
105 EVT_BUTTON(IDC_IPFILTERUPDATE, PrefsUnifiedDlg::OnButtonIPFilterUpdate)
106 EVT_CHOICE(IDC_COLORSELECTOR, PrefsUnifiedDlg::OnColorCategorySelected)
107 EVT_CHOICE(IDC_BROWSER, PrefsUnifiedDlg::OnBrowserChange)
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->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;
162 //! The actual widget. To be set later.
163 wxPanel* m_widget;
167 PrefsPage pages[] =
169 { wxTRANSLATE("General"), PreferencesGeneralTab, 13, NULL },
170 { wxTRANSLATE("Connection"), PreferencesConnectionTab, 14, NULL },
171 { wxTRANSLATE("Proxy"), PreferencesProxyTab, 24, NULL },
172 { wxTRANSLATE("Message Filter"), PreferencesMessagesTab, 23, NULL },
173 { wxTRANSLATE("Remote Controls"), PreferencesRemoteControlsTab, 11, NULL },
174 { wxTRANSLATE("Online Signature"), PreferencesOnlineSigTab, 21, NULL },
175 { wxTRANSLATE("Server"), PreferencesServerTab, 15, NULL },
176 { wxTRANSLATE("Files"), PreferencesFilesTab, 16, NULL },
177 { wxTRANSLATE("Directories"), PreferencesDirectoriesTab, 17, NULL },
178 { wxTRANSLATE("Statistics"), PreferencesStatisticsTab, 10, NULL },
179 { wxTRANSLATE("Security"), PreferencesSecurityTab, 22, NULL },
180 { wxTRANSLATE("Gui Tweaks"), PreferencesGuiTweaksTab, 19, NULL },
181 { wxTRANSLATE("Core Tweaks"), PreferencesaMuleTweaksTab, 12, NULL },
182 { wxTRANSLATE("Events"), PreferencesEventsTab, 5, NULL }
183 #ifdef __DEBUG__
184 ,{ wxTRANSLATE("Debugging"), PreferencesDebug, 25, NULL }
185 #endif
189 PrefsUnifiedDlg::PrefsUnifiedDlg(wxWindow *parent)
191 wxDialog(parent, -1, _("Preferences"),
192 wxDefaultPosition, wxDefaultSize,
193 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
195 preferencesDlgTop(this, false);
197 wxListCtrl *PrefsIcons = CastChild(ID_PREFSLISTCTRL, wxListCtrl);
198 wxImageList *icon_list = new wxImageList(16, 16);
199 PrefsIcons->AssignImageList(icon_list, wxIMAGE_LIST_SMALL);
201 // Add the single column used
202 PrefsIcons->InsertColumn(
203 0, wxEmptyString, wxLIST_FORMAT_LEFT,
204 PrefsIcons->GetSize().GetWidth()-5);
206 // Temp variables for finding the smallest height and width needed
207 int width = 0;
208 int height = 0;
210 // Add each page to the page-list
211 for (unsigned int i = 0; i < itemsof(pages); ++i) {
212 // Add the icon and label assosiated with the page
213 icon_list->Add(amuleSpecial(pages[i].m_imageidx));
214 PrefsIcons->InsertItem(i, wxGetTranslation(pages[i].m_title), i);
217 // Set list-width so that there arn't any scrollers
218 PrefsIcons->SetColumnWidth(0, wxLIST_AUTOSIZE);
219 PrefsIcons->SetMinSize(wxSize(PrefsIcons->GetColumnWidth(0) + 10, -1));
220 PrefsIcons->SetMaxSize(wxSize(PrefsIcons->GetColumnWidth(0) + 10, -1));
222 // Now add the pages and calculate the minimum size
223 for (unsigned int i = 0; i < itemsof(pages); ++i) {
224 // Create a container widget and the contents of the page
225 pages[i].m_widget = new wxPanel(this, -1);
226 pages[i].m_function(pages[i].m_widget, true, true);
228 // Add it to the sizer
229 prefs_sizer->Add(pages[i].m_widget, 0, wxGROW|wxEXPAND);
231 if (pages[i].m_function == PreferencesGeneralTab) {
232 // This must be done now or pages won't Fit();
233 #ifdef __WXMSW__
234 CastChild(IDC_BROWSERTABS, wxCheckBox)->Enable(false);
235 wxChoice *browserCheck = CastChild(IDC_BROWSER, wxChoice);
236 browserCheck->Clear();
237 browserCheck->Append(_("System default"));
238 browserCheck->Append(_("User Defined"));
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, pages[i].m_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 #ifdef __DEBUG__
262 else if (pages[i].m_function == PreferencesDebug) {
263 int count = CLogger::GetDebugCategoryCount();
264 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
266 for ( int j = 0; j < count; j++ ) {
267 list->Append( CLogger::GetDebugCategory( j ).GetName() );
270 #endif
272 // Align and resize the page
273 Fit();
274 Layout();
276 // Find the greatest sizes
277 wxSize size = prefs_sizer->GetSize();
278 if (size.GetWidth() > width) {
279 width = size.GetWidth();
282 if (size.GetHeight() > height) {
283 height = size.GetHeight();
286 // Hide it for now
287 prefs_sizer->Detach(pages[i].m_widget);
288 pages[i].m_widget->Show(false);
291 // Default to the General tab
292 m_CurrentPanel = pages[0].m_widget;
293 prefs_sizer->Add(pages[0].m_widget, 0, wxGROW|wxEXPAND);
294 m_CurrentPanel->Show( true );
296 // Select the first item
297 PrefsIcons->SetItemState(0, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
299 // We now have the needed minimum height and width
300 prefs_sizer->SetMinSize(width, height);
302 // Store some often used pointers
303 m_ShareSelector = CastChild(IDC_SHARESELECTOR, CDirectoryTreeCtrl);
304 m_buttonColor = CastChild(IDC_COLOR_BUTTON, wxButton);
305 m_choiceColor = CastChild(IDC_COLORSELECTOR, wxChoice);
307 // Connect the Cfgs with their widgets
308 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
309 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
310 // Checking for failures
311 if ( !it->second->ConnectToWidget(it->first, this) ) {
312 printf("Failed to connect Cfg to widget with the ID %d and key %s\n",
313 it->first, (const char *)unicode2char(it->second->GetKey()));
316 Fit();
318 // It must not be resized to something smaller than what it currently is
319 wxSize size = GetClientSize();
320 SetSizeHints(size.GetWidth(), size.GetHeight());
322 #ifdef __WXMSW__
323 FindWindow(IDC_VERTTOOLBAR)->Enable(false);
324 #endif
326 // Position the dialog.
327 Center();
331 Cfg_Base* PrefsUnifiedDlg::GetCfg(int id)
333 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.find( id );
335 if ( it != thePrefs::s_CfgList.end() ) {
336 return it->second;
339 return NULL;
343 bool PrefsUnifiedDlg::TransferToWindow()
345 // Connect the Cfgs with their widgets
346 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
347 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
348 // Checking for failures
349 if ( !it->second->TransferToWindow() ) {
350 printf("Failed to transfer data from Cfg to Widget with the ID %d and key %s\n",
351 it->first, (const char *)unicode2char(it->second->GetKey()));
355 m_ShareSelector->SetSharedDirectories(&theApp->glob_prefs->shareddir_list);
357 for ( int i = 0; i < cntStatColors; i++ ) {
358 thePrefs::s_colors[i] = CStatisticsDlg::acrStat[i];
359 thePrefs::s_colors_ref[i] = CStatisticsDlg::acrStat[i];
362 // Connection tab
363 wxSpinEvent e;
364 OnTCPClientPortChange(e);
366 // Proxy tab initialization
367 if (!CastChild(ID_PROXY_ENABLE_PROXY, wxCheckBox)->IsChecked()) {
368 FindWindow(ID_PROXY_TYPE)->Enable(false);
369 FindWindow(ID_PROXY_NAME)->Enable(false);
370 FindWindow(ID_PROXY_PORT)->Enable(false);
372 if (!CastChild(ID_PROXY_ENABLE_PASSWORD, wxCheckBox)->IsChecked()) {
373 FindWindow(ID_PROXY_USER)->Enable(false);
374 FindWindow(ID_PROXY_PASSWORD)->Enable(false);
376 // This option from the proxy tab is currently unused
377 FindWindow(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY)->Enable(false);
379 // Enable/Disable some controls
380 bool customBrowser =
381 CastChild(IDC_BROWSER, wxChoice)->GetSelection() ==
382 (int)CastChild(IDC_BROWSER, wxChoice)->GetCount() - 1;
383 FindWindow( IDC_BROWSERSELF )->Enable( customBrowser );
384 FindWindow( IDC_SELBROWSER )->Enable( customBrowser );
385 #ifndef __WXMSW__
386 FindWindow( IDC_BROWSERTABS )->Enable( !customBrowser );
387 #endif
388 FindWindow( IDC_MINDISKSPACE )->Enable( thePrefs::IsCheckDiskspaceEnabled() );
389 FindWindow( IDC_SKIN )->Enable( thePrefs::UseSkins() );
390 FindWindow( IDC_OSDIR )->Enable( thePrefs::IsOnlineSignatureEnabled() );
391 FindWindow( IDC_OSUPDATE )->Enable( thePrefs::IsOnlineSignatureEnabled() );
392 FindWindow( IDC_UDPPORT )->Enable( !thePrefs::s_UDPDisable );
393 FindWindow( IDC_SERVERRETRIES )->Enable( thePrefs::DeadServer() );
394 FindWindow( IDC_STARTNEXTFILE_SAME )->Enable(thePrefs::StartNextFile());
396 #ifdef __WXMAC__
397 FindWindow(IDC_ENABLETRAYICON)->Enable(false);
398 FindWindow(IDC_MINTRAY)->Enable(false);
399 #else
400 FindWindow(IDC_MINTRAY)->Enable(thePrefs::UseTrayIcon());
401 #endif
403 if (!CastChild(IDC_MSGFILTER, wxCheckBox)->IsChecked()) {
404 FindWindow(IDC_MSGFILTER_ALL)->Enable(false);
405 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(false);
406 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(false);
407 FindWindow(IDC_MSGFILTER_WORD)->Enable(false);
408 FindWindow(IDC_MSGWORD)->Enable(false);
409 } else if (CastChild(IDC_MSGFILTER_ALL, wxCheckBox)->IsChecked()) {
410 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(false);
411 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(false);
412 FindWindow(IDC_MSGFILTER_WORD)->Enable(false);
413 FindWindow(IDC_MSGWORD)->Enable(false);
416 FindWindow(IDC_MSGWORD)->Enable(CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
417 FindWindow(IDC_COMMENTWORD)->Enable(CastChild(IDC_FILTERCOMMENTS, wxCheckBox)->IsChecked());
419 // Protocol obfuscation
420 ::SendCheckBoxEvent(this, IDC_SUPPORT_PO);
421 ::SendCheckBoxEvent(this, IDC_ENABLE_PO_OUTGOING);
422 ::SendCheckBoxEvent(this, IDC_ENFORCE_PO_INCOMING);
424 #ifdef __DEBUG__
425 // Set debugging toggles
426 int count = CLogger::GetDebugCategoryCount();
427 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
429 for ( int i = 0; i < count; i++ ) {
430 list->Check( i, CLogger::GetDebugCategory( i ).IsEnabled() );
432 #endif
434 return true;
438 bool PrefsUnifiedDlg::TransferFromWindow()
440 // Connect the Cfgs with their widgets
441 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
442 for ( ; it != thePrefs::s_CfgList.end(); ++it ) {
443 // Checking for failures
444 if ( !it->second->TransferFromWindow() ) {
445 printf("Failed to transfer data from Widget to Cfg with the ID %d and key %s\n",
446 it->first, (const char *)unicode2char(it->second->GetKey()));
450 theApp->glob_prefs->shareddir_list.clear();
451 m_ShareSelector->GetSharedDirectories(&theApp->glob_prefs->shareddir_list);
453 for ( int i = 0; i < cntStatColors; i++ ) {
454 if ( thePrefs::s_colors[i] != thePrefs::s_colors_ref[i] ) {
455 CStatisticsDlg::acrStat[i] = thePrefs::s_colors[i];
456 theApp->amuledlg->m_statisticswnd->ApplyStatsColor(i);
459 theApp->amuledlg->m_kademliawnd->SetGraphColors();
462 #ifdef __DEBUG__
463 // Get debugging toggles
464 int count = CLogger::GetDebugCategoryCount();
465 wxCheckListBox* list = CastChild( ID_DEBUGCATS, wxCheckListBox );
467 for ( int i = 0; i < count; i++ ) {
468 CLogger::SetEnabled( CLogger::GetDebugCategory( i ).GetType(), list->IsChecked( i ) );
470 #endif
472 #ifdef CLIENT_GUI
473 // Send preferences to core.
474 theApp->glob_prefs->SendToRemote();
475 #endif
477 return true;
481 bool PrefsUnifiedDlg::CfgChanged(int ID)
483 Cfg_Base* cfg = GetCfg(ID);
485 if ( cfg ) {
486 return cfg->HasChanged();
489 return false;
493 void PrefsUnifiedDlg::OnOk(wxCommandEvent& WXUNUSED(event))
495 TransferFromWindow();
497 bool restart_needed = false;
498 wxString restart_needed_msg = _("aMule must be restarted to enable these changes:\n\n");
500 // do sanity checking, special processing, and user notifications here
501 thePrefs::CheckUlDlRatio();
503 if (CfgChanged(IDC_PORT)) {
504 restart_needed = true;
505 restart_needed_msg += _("- TCP port changed.\n");
508 if (CfgChanged(IDC_UDPPORT)) {
509 restart_needed = true;
510 restart_needed_msg += _("- UDP port changed.\n");
513 // Force port checking
514 thePrefs::SetPort(thePrefs::GetPort());
516 if ((CPath::GetFileSize(theApp->ConfigDir + wxT("addresses.dat")) == 0) &&
517 CastChild(IDC_AUTOSERVER, wxCheckBox)->IsChecked() ) {
518 thePrefs::UnsetAutoServerStart();
519 wxMessageBox(wxString::wxString( _("Your Auto-update server list is empty.\n'Auto-update server list at startup will be disabled.")),
520 _("Message"), wxOK | wxICON_INFORMATION, this);
523 if (thePrefs::AcceptExternalConnections() && thePrefs::ECPassword().IsEmpty()) {
524 thePrefs::EnableExternalConnections( false );
526 wxMessageBox( _("You have enabled external connections but have not specified a password.\nExternal connections cannot be enabled unless a valid password is specified."));
529 // save the preferences on ok
530 theApp->glob_prefs->Save();
532 if (CfgChanged(IDC_FED2KLH) && theApp->amuledlg->GetActiveDialog() != CamuleDlg::DT_SEARCH_WND) {
533 theApp->amuledlg->ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
536 if (CfgChanged(IDC_LANGUAGE)) {
537 restart_needed = true;
538 restart_needed_msg += _("- Language changed.\n");
541 if (CfgChanged(IDC_TEMPFILES)) {
542 restart_needed = true;
543 restart_needed_msg += _("- Temp folder changed.\n");
546 if (CfgChanged(IDC_INCFILES) || CfgChanged(IDC_TEMPFILES) || m_ShareSelector->HasChanged ) {
547 theApp->sharedfiles->Reload();
550 if (CfgChanged(IDC_OSDIR) || CfgChanged(IDC_ONLINESIG)) {
551 wxTextCtrl* widget = CastChild( IDC_OSDIR, wxTextCtrl );
553 // Build the filenames for the two OS files
554 theApp->SetOSFiles( widget->GetValue() );
557 if (CfgChanged(IDC_IPFCLIENTS) || CfgChanged(IDC_IPFSERVERS) || CfgChanged(ID_IPFILTERLEVEL)) {
558 if (thePrefs::IsFilteringClients()) {
559 theApp->clientlist->FilterQueues();
561 if (thePrefs::IsFilteringServers()) {
562 theApp->serverlist->FilterServers();
566 if (thePrefs::GetShowRatesOnTitle()) {
567 // This avoids a 5 seconds delay to show the title
568 theApp->amuledlg->SetTitle(theApp->m_FrameTitle + wxT(" -- ") + _("Up: 0.0 | Down: 0.0"));
569 } else {
570 // This resets the title
571 theApp->amuledlg->SetTitle(theApp->m_FrameTitle);
574 if (CfgChanged(IDC_EXTCATINFO)) {
575 theApp->amuledlg->m_transferwnd->UpdateCatTabTitles();
578 // Changes related to the statistics-dlg
579 if (CfgChanged(IDC_SLIDER)) {
580 theApp->amuledlg->m_statisticswnd->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
581 theApp->amuledlg->m_kademliawnd->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
584 if ( CfgChanged(IDC_SLIDER3) ) {
585 theApp->amuledlg->m_statisticswnd->ResetAveragingTime();
588 if (CfgChanged(IDC_DOWNLOAD_CAP)) {
589 theApp->amuledlg->m_statisticswnd->SetARange( true, thePrefs::GetMaxGraphDownloadRate() );
592 if (CfgChanged(IDC_UPLOAD_CAP)) {
593 theApp->amuledlg->m_statisticswnd->SetARange( false, thePrefs::GetMaxGraphUploadRate() );
596 if (CfgChanged(IDC_SKIN) || CfgChanged(IDC_USESKINFILES)) {
597 theApp->amuledlg->Create_Toolbar(thePrefs::VerticalToolbar());
600 if (!thePrefs::GetNetworkED2K() && theApp->IsConnectedED2K()) {
601 theApp->DisconnectED2K();
604 if (!thePrefs::GetNetworkKademlia() && theApp->IsConnectedKad()) {
605 theApp->StopKad();
608 if (!thePrefs::GetNetworkED2K() && !thePrefs::GetNetworkKademlia()) {
609 wxMessageBox(wxString::wxString(
610 _("Both eD2k and Kad network are disabled.\nYou won't be able to connect until you enable at least one of them.")));
613 if (thePrefs::GetNetworkKademlia() && thePrefs::IsUDPDisabled()) {
614 wxMessageBox(_("Kad will not start if your UDP port is disabled.\nEnable UDP port or disable Kad."),
615 _("Message"), wxOK | wxICON_INFORMATION, this);
618 if (CfgChanged(IDC_NETWORKKAD) || CfgChanged(IDC_NETWORKED2K)) {
619 theApp->amuledlg->DoNetworkRearrange();
622 if (restart_needed) {
623 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);
626 Show(false);
630 void PrefsUnifiedDlg::OnClose(wxCloseEvent& event)
632 Show(false);
634 // Try to keep the window alive when possible
635 if (event.CanVeto()) {
636 event.Veto();
637 } else {
638 if (theApp->amuledlg) {
639 theApp->amuledlg->m_prefsDialog = NULL;
642 // Un-Connect the Cfgs
643 thePrefs::CFGMap::iterator it = thePrefs::s_CfgList.begin();
644 for (; it != thePrefs::s_CfgList.end(); ++it) {
645 // Checking for failures
646 it->second->ConnectToWidget( 0 );
649 Destroy();
654 void PrefsUnifiedDlg::OnCancel(wxCommandEvent& WXUNUSED(event))
656 Show(false);
660 void PrefsUnifiedDlg::OnCheckBoxChange(wxCommandEvent& event)
662 bool value = event.IsChecked();
663 int id = event.GetId();
665 // Check if this checkbox is one of the User Events checkboxes
666 if (id >= USEREVENTS_FIRST_ID &&
667 id < USEREVENTS_FIRST_ID +
668 (int)CUserEvents::GetCount() * USEREVENTS_IDS_PER_EVENT) {
669 // The corresponding text control always has
670 // an ID one greater than the checkbox
671 FindWindow(id + 1)->Enable(value);
672 return;
675 switch ( id ) {
676 case IDC_UDPDISABLE:
677 // UDP is disable rather than enable, so we flip the value
678 FindWindow( IDC_UDPPORT )->Enable(!value);
679 break;
681 case IDC_CHECKDISKSPACE:
682 FindWindow( IDC_MINDISKSPACE )->Enable(value);
683 break;
685 case IDC_USESKINFILES:
686 FindWindow( IDC_SKIN )->Enable(value);;
687 break;
689 case IDC_ONLINESIG:
690 FindWindow( IDC_OSDIR )->Enable(value);;
691 FindWindow(IDC_OSUPDATE)->Enable(value);
692 break;
694 case IDC_REMOVEDEAD:
695 FindWindow( IDC_SERVERRETRIES )->Enable(value);;
696 break;
698 case IDC_AUTOSERVER:
699 if ((CPath::GetFileSize(theApp->ConfigDir + wxT("addresses.dat")) == 0) &&
700 CastChild(event.GetId(), wxCheckBox)->IsChecked() ) {
701 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.")),
702 _("Message"), wxOK | wxICON_INFORMATION);
703 CastChild(event.GetId(), wxCheckBox)->SetValue(false);
705 break;
707 case IDC_MSGFILTER:
708 // Toogle All filter options
709 FindWindow(IDC_MSGFILTER_ALL)->Enable(value);
710 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(value);
711 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(value);
712 FindWindow(IDC_MSGFILTER_WORD)->Enable(value);
713 if (value) {
714 FindWindow(IDC_MSGWORD)->Enable(
715 CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
716 } else {
717 FindWindow(IDC_MSGWORD)->Enable(false);
719 break;
721 case IDC_MSGFILTER_ALL:
722 // Toogle filtering by data.
723 FindWindow(IDC_MSGFILTER_NONSECURE)->Enable(!value);
724 FindWindow(IDC_MSGFILTER_NONFRIENDS)->Enable(!value);
725 FindWindow(IDC_MSGFILTER_WORD)->Enable(!value);
726 if (!value) {
727 FindWindow(IDC_MSGWORD)->Enable(
728 CastChild(IDC_MSGFILTER_WORD, wxCheckBox)->IsChecked());
729 } else {
730 FindWindow(IDC_MSGWORD)->Enable(false);
732 break;
734 case IDC_MSGFILTER_WORD:
735 // Toogle filter word list.
736 FindWindow(IDC_MSGWORD)->Enable(value);
737 break;
739 case IDC_FILTERCOMMENTS:
740 FindWindow(IDC_COMMENTWORD)->Enable(value);
741 break;
743 case ID_PROXY_ENABLE_PROXY:
744 FindWindow(ID_PROXY_TYPE)->Enable(value);
745 FindWindow(ID_PROXY_NAME)->Enable(value);
746 FindWindow(ID_PROXY_PORT)->Enable(value);
747 break;
749 case ID_PROXY_ENABLE_PASSWORD:
750 FindWindow(ID_PROXY_USER)->Enable(value);
751 FindWindow(ID_PROXY_PASSWORD)->Enable(value);
752 break;
754 case IDC_STARTNEXTFILE:
755 FindWindow(IDC_STARTNEXTFILE_SAME)->Enable(value);
756 break;
758 case IDC_ENABLETRAYICON:
759 FindWindow(IDC_MINTRAY)->Enable(value);
760 if (value) {
761 theApp->amuledlg->CreateSystray();
762 } else {
763 theApp->amuledlg->RemoveSystray();
765 thePrefs::SetUseTrayIcon(value);
766 break;
768 case ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY:
769 break;
770 case IDC_VERTTOOLBAR:
771 theApp->amuledlg->Create_Toolbar(value);
772 // Update the first tool (conn button)
773 theApp->amuledlg->ShowConnectionState();
774 break;
776 case IDC_ENFORCE_PO_INCOMING:
777 FindWindow(IDC_ENABLE_PO_OUTGOING)->Enable(!value);
778 break;
780 case IDC_ENABLE_PO_OUTGOING:
781 FindWindow(IDC_SUPPORT_PO)->Enable(!value);
782 FindWindow(IDC_ENFORCE_PO_INCOMING)->Enable(value);
783 break;
785 case IDC_SUPPORT_PO:
786 FindWindow(IDC_ENABLE_PO_OUTGOING)->Enable(value);
787 break;
789 default:
790 break;
795 void PrefsUnifiedDlg::OnButtonColorChange(wxCommandEvent& WXUNUSED(event))
797 int index = m_choiceColor->GetSelection();
798 wxColour col = WxColourFromCr( thePrefs::s_colors[index] );
799 col = wxGetColourFromUser( this, col );
800 if ( col.Ok() ) {
801 m_buttonColor->SetBackgroundColour( col );
802 thePrefs::s_colors[index] = CrFromWxColour(col);
807 void PrefsUnifiedDlg::OnColorCategorySelected(wxCommandEvent& WXUNUSED(evt))
809 m_buttonColor->SetBackgroundColour(
810 WxColourFromCr( thePrefs::s_colors[ m_choiceColor->GetSelection() ] ) );
814 void PrefsUnifiedDlg::OnBrowserChange( wxCommandEvent& evt )
816 wxTextCtrl* textctrl = CastChild( IDC_BROWSERSELF, wxTextCtrl );
817 wxButton* btn = CastChild( IDC_SELBROWSER, wxButton );
818 bool enable =
819 evt.GetSelection() ==
820 (int)CastChild( IDC_BROWSER, wxChoice )->GetCount() - 1;
822 if (textctrl) {
823 textctrl->Enable( enable );
825 if (btn) {
826 btn->Enable( enable );
828 #ifndef __WXMSW__
829 FindWindow( IDC_BROWSERTABS )->Enable( !enable );
830 #endif
834 void PrefsUnifiedDlg::OnButtonDir(wxCommandEvent& event)
836 wxString type;
838 int id = 0;
839 switch ( event.GetId() ) {
840 case IDC_SELTEMPDIR:
841 id = IDC_TEMPFILES;
842 type = _("Temporary files");
843 break;
845 case IDC_SELINCDIR:
846 id = IDC_INCFILES;
847 type = _("Incoming files");
848 break;
850 case IDC_SELOSDIR:
851 id = IDC_OSDIR;
852 type = _("Online Signatures");
853 break;
855 // case IDC_SELSKIN:
856 // id = IDC_SKIN;
857 // type = _("Skins directory");
858 // break;
860 default:
861 wxASSERT(false);
862 return;
865 type = CFormat(_("Choose a folder for %s")) % type;
866 wxTextCtrl* widget = CastChild( id, wxTextCtrl );
867 wxString dir = widget->GetValue();
868 wxString str = wxDirSelector(
869 type, dir,
870 wxDD_DEFAULT_STYLE,
871 wxDefaultPosition, this);
872 if (!str.IsEmpty()) {
873 widget->SetValue(str);
878 void PrefsUnifiedDlg::OnButtonBrowseApplication(wxCommandEvent& event)
880 wxString title;
881 int id = 0;
882 switch ( event.GetId() ) {
883 case IDC_BROWSEV:
884 id = IDC_VIDEOPLAYER;
885 title = _("Browse for videoplayer");
886 break;
887 case IDC_SELBROWSER:
888 id = IDC_BROWSERSELF;
889 title = _("Select browser");
890 break;
891 default:
892 wxASSERT( false );
893 return;
895 wxString wildcard = CFormat(_("Executable%s"))
896 #ifdef __WINDOWS__
897 % wxT(" (*.exe)|*.exe");
898 #else
899 % wxT("|*");
900 #endif
902 wxString str = wxFileSelector( title, wxEmptyString, wxEmptyString,
903 wxEmptyString, wildcard, 0, this );
905 if ( !str.IsEmpty() ) {
906 wxTextCtrl* widget = CastChild( id, wxTextCtrl );
907 widget->SetValue( str );
912 void PrefsUnifiedDlg::OnButtonEditAddr(wxCommandEvent& WXUNUSED(evt))
914 wxString fullpath( theApp->ConfigDir + wxT("addresses.dat") );
916 EditServerListDlg* test = new EditServerListDlg(this, _("Edit server list"),
917 _("Add here URL's to download server.met files.\nOnly one url on each line."),
918 fullpath );
920 test->ShowModal();
921 delete test;
925 void PrefsUnifiedDlg::OnButtonIPFilterReload(wxCommandEvent& WXUNUSED(event))
927 theApp->ipfilter->Reload();
931 void PrefsUnifiedDlg::OnButtonIPFilterUpdate(wxCommandEvent& WXUNUSED(event))
933 theApp->ipfilter->Update( CastChild( IDC_IPFILTERURL, wxTextCtrl )->GetValue() );
937 void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent& event)
939 prefs_sizer->Detach( m_CurrentPanel );
940 m_CurrentPanel->Show( false );
942 m_CurrentPanel = pages[ event.GetIndex() ].m_widget;
944 prefs_sizer->Add( m_CurrentPanel, 0, wxGROW|wxEXPAND );
945 m_CurrentPanel->Show( true );
947 Layout();
949 event.Skip();
953 void PrefsUnifiedDlg::OnToolTipDelayChange(wxSpinEvent& event)
955 wxToolTip::SetDelay( event.GetPosition() * 1000 );
959 void PrefsUnifiedDlg::OnInitDialog( wxInitDialogEvent& WXUNUSED(evt) )
961 // This function exists solely to avoid automatic transfer-to-widget calls
965 void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent& event )
967 int id = 0;
968 wxString label;
970 switch ( event.GetId() ) {
971 case IDC_SLIDER:
972 id = IDC_SLIDERINFO;
973 label = wxString::Format( wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event.GetPosition()), event.GetPosition() );
974 theApp->amuledlg->m_statisticswnd->SetUpdatePeriod(event.GetPosition());
975 theApp->amuledlg->m_kademliawnd->SetUpdatePeriod(event.GetPosition());
976 break;
978 case IDC_SLIDER3:
979 id = IDC_SLIDERINFO3;
980 label = wxString::Format( wxPLURAL("Time for average graph: %d minute", "Time for average graph: %d minutes", event.GetPosition()), event.GetPosition() );
981 theApp->m_statistics->SetAverageMinutes(event.GetPosition());
982 break;
984 case IDC_SLIDER4:
985 id = IDC_SLIDERINFO4;
986 label = wxString::Format( _("Connections Graph Scale: %d"), event.GetPosition() );
987 theApp->amuledlg->m_statisticswnd->GetConnScope()->SetRanges(0,event.GetPosition());
988 break;
990 case IDC_SLIDER2:
991 id = IDC_SLIDERINFO2;
992 label = wxString::Format( wxPLURAL("Update delay : %d second", "Update delay : %d seconds", event.GetPosition()), event.GetPosition() );
993 break;
995 case IDC_FILEBUFFERSIZE:
996 id = IDC_FILEBUFFERSIZE_STATIC;
997 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
998 label = wxString::Format( wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event.GetPosition() * 15000), event.GetPosition() * 15000 );
999 break;
1001 case IDC_QUEUESIZE:
1002 id = IDC_QUEUESIZE_STATIC;
1003 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1004 label = wxString::Format( wxPLURAL("Upload Queue Size: %d client", "Upload Queue Size: %d clients", event.GetPosition() * 100), event.GetPosition() * 100 );
1005 break;
1007 case IDC_SERVERKEEPALIVE:
1008 id = IDC_SERVERKEEPALIVE_LABEL;
1010 if ( event.GetPosition() ) {
1011 label = wxString::Format( wxPLURAL("Server connection refresh interval: %d minute", "Server connection refresh interval: %d minutes", event.GetPosition()), event.GetPosition() );
1012 } else {
1013 label = wxString::Format( _("Server connection refresh interval: Disabled") );
1015 break;
1017 default:
1018 return;
1021 wxStaticText* widget = CastChild( id, wxStaticText );
1023 if (widget) {
1024 widget->SetLabel( label );
1025 widget->GetParent()->Layout();
1030 void PrefsUnifiedDlg::OnRateLimitChanged( wxSpinEvent& event )
1032 // Here we do immediate sainity checking of the up/down ratio,
1033 // so that the user can see if his choice is illegal
1035 // We only do checks if the rate is limited
1036 if ( event.GetPosition() != (int)UNLIMITED ) {
1037 wxSpinCtrl* dlrate = CastChild( IDC_MAXDOWN, wxSpinCtrl );
1039 if ( event.GetPosition() < 4 ) {
1040 if ( ( event.GetPosition() * 3 < dlrate->GetValue() ) ||
1041 ( dlrate->GetValue() == (int)UNLIMITED ) ) {
1042 dlrate->SetValue( event.GetPosition() * 3 );
1044 } else if ( event.GetPosition() < 10 ) {
1045 if ( ( event.GetPosition() * 4 < dlrate->GetValue() ) ||
1046 ( dlrate->GetValue() == (int)UNLIMITED ) ) {
1047 dlrate->SetValue( event.GetPosition() * 4 );
1054 void PrefsUnifiedDlg::OnTCPClientPortChange(wxSpinEvent& WXUNUSED(event))
1056 int port = CastChild(IDC_PORT, wxSpinCtrl)->GetValue();
1057 wxString txt;
1058 txt << wxT("UDP port for extended server requests (TCP+3):") << port + 3;
1059 CastChild(ID_TEXT_CLIENT_UDP_PORT, wxStaticText)->SetLabel(txt);
1062 void PrefsUnifiedDlg::OnUserEventSelected(wxListEvent& event)
1064 for (unsigned int i = 0; i < CUserEvents::GetCount(); ++i) {
1065 IDC_PREFS_EVENTS_PAGE->Hide(i + 2);
1068 IDC_PREFS_EVENTS_PAGE->Show((event.GetData() - USEREVENTS_FIRST_ID) / USEREVENTS_IDS_PER_EVENT + 2, true);
1070 IDC_PREFS_EVENTS_PAGE->Layout();
1072 event.Skip();
1075 void PrefsUnifiedDlg::CreateEventPanels(const int idx, const wxString& vars, wxWindow* parent)
1077 wxStaticBox *item8 = new wxStaticBox( parent, -1, CFormat(_("Execute command on `%s' event")) % wxGetTranslation(CUserEvents::GetDisplayName(static_cast<enum CUserEvents::EventType>(idx))) );
1078 wxStaticBoxSizer *item7 = new wxStaticBoxSizer( item8, wxVERTICAL );
1080 wxCheckBox *item9 = new wxCheckBox( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 1, _("Enable command execution on core"), wxDefaultPosition, wxDefaultSize, 0 );
1081 item7->Add( item9, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
1083 wxFlexGridSizer *item10 = new wxFlexGridSizer( 3, 0, 0 );
1084 item10->AddGrowableCol( 2 );
1086 item10->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 0 );
1088 wxStaticText *item11 = new wxStaticText( parent, -1, _("Core command:"), wxDefaultPosition, wxDefaultSize, 0 );
1089 item10->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
1091 wxTextCtrl *item12 = new wxTextCtrl( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 2, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
1092 item12->Enable(CUserEvents::IsCoreCommandEnabled(static_cast<enum CUserEvents::EventType>(idx)));
1093 item10->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1095 item7->Add( item10, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
1097 wxCheckBox *item14 = new wxCheckBox( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 3, _("Enable command execution on GUI"), wxDefaultPosition, wxDefaultSize, 0 );
1098 item7->Add( item14, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
1100 wxFlexGridSizer *item15 = new wxFlexGridSizer( 3, 0, 0 );
1101 item15->AddGrowableCol( 2 );
1103 item15->Add( 20, 20, 0, wxALIGN_CENTER|wxALL, 0 );
1105 wxStaticText *item16 = new wxStaticText( parent, -1, _("GUI command:"), wxDefaultPosition, wxDefaultSize, 0 );
1106 item15->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
1108 wxTextCtrl *item17 = new wxTextCtrl( parent, USEREVENTS_FIRST_ID + idx * USEREVENTS_IDS_PER_EVENT + 4, wxT(""), wxDefaultPosition, wxDefaultSize, 0 );
1109 item17->Enable(CUserEvents::IsGUICommandEnabled(static_cast<enum CUserEvents::EventType>(idx)));
1110 item15->Add( item17, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1112 item7->Add( item15, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
1114 wxStaticText *item13 = new wxStaticText( parent, -1, _("The following variables will be replaced:") + vars, wxDefaultPosition, wxDefaultSize, 0 );
1115 item7->Add( item13, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1117 IDC_PREFS_EVENTS_PAGE->Add(item7, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5);
1119 IDC_PREFS_EVENTS_PAGE->Layout();
1120 IDC_PREFS_EVENTS_PAGE->Hide(idx + 2);
1122 // File_checked_for_headers