2 // This file is part of the aMule Project.
4 // Copyright (c) 2004-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Original author: Emilio Sandoz
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
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.
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
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"
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
)
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
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)
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
)
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_CHOICE(IDC_LANGUAGE
, PrefsUnifiedDlg::OnLanguageChoice
)
126 EVT_CLOSE(PrefsUnifiedDlg::OnClose
)
132 * Creates an command-event for the given checkbox.
134 * This can be used enforce logical constraints by passing by
135 * sending a check-box event for each checkbox, when transfering
136 * to the UI. However, it should also be used for checkboxes that
137 * have no side-effects other than enabling/disabling other
138 * widgets in the preferences dialogs.
140 void SendCheckBoxEvent(wxWindow
* parent
, int id
)
142 wxCheckBox
* widget
= CastByID(id
, parent
, wxCheckBox
);
143 wxCHECK_RET(widget
, wxT("Invalid widget in CreateEvent"));
145 wxCommandEvent
evt(wxEVT_COMMAND_CHECKBOX_CLICKED
, id
);
146 evt
.SetInt(widget
->IsChecked() ? 1 : 0);
148 parent
->GetEventHandler()->ProcessEvent(evt
);
154 * This struct provides a general way to represent config-tabs.
158 //! The title of the page, used on the listctrl.
160 //! Function pointer to the wxDesigner function creating the dialog.
161 wxSizer
* (*m_function
)(wxWindow
*, bool, bool );
162 //! The index of the image used on the list.
169 { wxTRANSLATE("General"), PreferencesGeneralTab
, 13 },
170 { wxTRANSLATE("Connection"), PreferencesConnectionTab
, 14 },
171 { wxTRANSLATE("Directories"), PreferencesDirectoriesTab
, 17 },
172 { wxTRANSLATE("Servers"), PreferencesServerTab
, 15 },
173 { wxTRANSLATE("Files"), PreferencesFilesTab
, 16 },
174 { wxTRANSLATE("Security"), PreferencesSecurityTab
, 22 },
175 { wxTRANSLATE("Interface"), PreferencesGuiTweaksTab
, 19 },
176 { wxTRANSLATE("Statistics"), PreferencesStatisticsTab
, 10 },
177 { wxTRANSLATE("Proxy"), PreferencesProxyTab
, 24 },
178 { wxTRANSLATE("Filters"), PreferencesFilteringTab
, 23 },
179 { wxTRANSLATE("Remote Controls"), PreferencesRemoteControlsTab
, 11 },
180 { wxTRANSLATE("Online Signature"), PreferencesOnlineSigTab
, 21 },
181 { wxTRANSLATE("Advanced"), PreferencesaMuleTweaksTab
, 12 },
182 { wxTRANSLATE("Events"), PreferencesEventsTab
, 5 }
184 ,{ wxTRANSLATE("Debugging"), PreferencesDebug
, 25 }
189 PrefsUnifiedDlg::PrefsUnifiedDlg(wxWindow
*parent
)
191 wxDialog(parent
, -1, _("Preferences"),
192 wxDefaultPosition
, wxDefaultSize
,
193 wxDEFAULT_DIALOG_STYLE
|wxRESIZE_BORDER
)
195 preferencesDlgTop(this, false);
197 m_PrefsIcons
= CastChild(ID_PREFSLISTCTRL
, wxListCtrl
);
198 wxImageList
*icon_list
= new wxImageList(16, 16);
199 m_PrefsIcons
->AssignImageList(icon_list
, wxIMAGE_LIST_SMALL
);
201 // Add the single column used
202 m_PrefsIcons
->InsertColumn(
203 0, wxEmptyString
, wxLIST_FORMAT_LEFT
,
204 m_PrefsIcons
->GetSize().GetWidth()-5);
206 // Temp variables for finding the smallest height and width needed
210 // Add each page to the page-list
211 for (unsigned int i
= 0; i
< itemsof(pages
); ++i
) {
212 // Add the icon and label associated with the page
213 icon_list
->Add(amuleSpecial(pages
[i
].m_imageidx
));
214 m_PrefsIcons
->InsertItem(i
, wxGetTranslation(pages
[i
].m_title
), i
);
217 // Set list-width so that there aren't any scrollers
218 m_PrefsIcons
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
219 m_PrefsIcons
->SetMinSize(wxSize(m_PrefsIcons
->GetColumnWidth(0) + 10, -1));
220 m_PrefsIcons
->SetMaxSize(wxSize(m_PrefsIcons
->GetColumnWidth(0) + 10, -1));
222 // Now add the pages and calculate the minimum size
223 wxPanel
* DefaultWidget
= NULL
;
224 for (unsigned int i
= 0; i
< itemsof(pages
); ++i
) {
225 // Create a container widget and the contents of the page
226 wxPanel
* Widget
= new wxPanel(this, -1);
227 // Widget is stored as user data in the list control
228 m_PrefsIcons
->SetItemPtrData(i
, (wxUIntPtr
) Widget
);
229 pages
[i
].m_function(Widget
, true, true);
231 DefaultWidget
= Widget
;
234 // Add it to the sizer
235 prefs_sizer
->Add(Widget
, 0, wxGROW
|wxEXPAND
);
237 if (pages
[i
].m_function
== PreferencesGeneralTab
) {
238 // This must be done now or pages won't Fit();
240 CastChild(IDC_BROWSERTABS
, wxCheckBox
)->Enable(false);
241 #endif /* __WXMSW__ */
242 CastChild(IDC_PREVIEW_NOTE
, wxStaticText
)->SetLabel(_("The following variables will be substituted:\n %PARTFILE - full path to the file\n %PARTNAME - file name only"));
243 } else if (pages
[i
].m_function
== PreferencesEventsTab
) {
245 #define USEREVENTS_REPLACE_VAR(VAR, DESC, CODE) + wxString(wxT("\n %") VAR wxT(" - ")) + wxGetTranslation(DESC)
246 #define USEREVENTS_EVENT(ID, NAME, VARS) case CUserEvents::ID: CreateEventPanels(idx, wxEmptyString VARS, Widget); break;
248 wxListCtrl
*list
= CastChild(IDC_EVENTLIST
, wxListCtrl
);
249 list
->InsertColumn(0, wxEmptyString
);
250 for (unsigned int idx
= 0; idx
< CUserEvents::GetCount(); ++idx
) {
251 long lidx
= list
->InsertItem(idx
,
252 wxGetTranslation(CUserEvents::GetDisplayName(
253 static_cast<enum CUserEvents::EventType
>(idx
))));
255 list
->SetItemData(lidx
,
256 USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
);
258 USEREVENTS_EVENTLIST()
262 list
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
264 else if (pages
[i
].m_function
== PreferencesServerTab
) {
265 m_IndexServerTab
= i
;
266 m_ServerWidget
= Widget
;
268 else if (pages
[i
].m_function
== PreferencesaMuleTweaksTab
) {
269 wxStaticText
*txt
= CastChild(IDC_AMULE_TWEAKS_WARNING
, wxStaticText
);
270 // Do not wrap this line, Windows _() can't handle wrapped strings
271 txt
->SetLabel(_("Do not change these setting unless you know\nwhat you are doing, otherwise you can easily\nmake things worse for yourself.\n\naMule will run fine without adjusting any of\nthese settings."));
274 else if (pages
[i
].m_function
== PreferencesDebug
) {
275 int count
= theLogger
.GetDebugCategoryCount();
276 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
278 for ( int j
= 0; j
< count
; j
++ ) {
279 list
->Append( theLogger
.GetDebugCategory( j
).GetName() );
284 // Align and resize the page
288 // Find the greatest sizes
289 wxSize size
= prefs_sizer
->GetSize();
290 if (size
.GetWidth() > width
) {
291 width
= size
.GetWidth();
294 if (size
.GetHeight() > height
) {
295 height
= size
.GetHeight();
299 prefs_sizer
->Detach(Widget
);
303 // Default to the General tab
304 m_CurrentPanel
= DefaultWidget
;
305 prefs_sizer
->Add(DefaultWidget
, 0, wxGROW
|wxEXPAND
);
306 m_CurrentPanel
->Show( true );
308 // Select the first item
309 m_PrefsIcons
->SetItemState(0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
311 // We now have the needed minimum height and width
312 prefs_sizer
->SetMinSize(width
, height
);
314 // Don't show server prefs if ED2K is disabled
315 m_ServerTabVisible
= true;
316 EnableServerTab(thePrefs::GetNetworkED2K());
318 // Store some often used pointers
319 m_ShareSelector
= CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
);
320 m_buttonColor
= CastChild(IDC_COLOR_BUTTON
, wxButton
);
321 m_choiceColor
= CastChild(IDC_COLORSELECTOR
, wxChoice
);
323 // Connect the Cfgs with their widgets
324 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
325 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
326 // Checking for failures
327 if ( !it
->second
->ConnectToWidget(it
->first
, this) ) {
328 AddLogLineNS(CFormat(_("Failed to connect Cfg to widget with the ID %d and key %s"))
329 % it
->first
% it
->second
->GetKey());
334 // It must not be resized to something smaller than what it currently is
335 wxSize size
= GetClientSize();
336 SetSizeHints(size
.GetWidth(), size
.GetHeight());
339 FindWindow(IDC_VERTTOOLBAR
)->Enable(false);
342 // Position the dialog.
347 void PrefsUnifiedDlg::EnableServerTab(bool enable
)
349 if (enable
&& !m_ServerTabVisible
) {
350 // turn server widget on
351 m_PrefsIcons
->InsertItem(m_IndexServerTab
, wxGetTranslation(pages
[m_IndexServerTab
].m_title
), m_IndexServerTab
);
352 m_PrefsIcons
->SetItemPtrData(m_IndexServerTab
, (wxUIntPtr
) m_ServerWidget
);
353 m_ServerTabVisible
= true;
354 } else if (!enable
&& m_ServerTabVisible
) {
355 // turn server widget off
356 m_PrefsIcons
->DeleteItem(m_IndexServerTab
);
357 m_ServerTabVisible
= false;
362 Cfg_Base
* PrefsUnifiedDlg::GetCfg(int id
)
364 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.find( id
);
366 if ( it
!= thePrefs::s_CfgList
.end() ) {
374 bool PrefsUnifiedDlg::TransferToWindow()
376 // Connect the Cfgs with their widgets
377 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
378 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
379 // Checking for failures
380 if ( !it
->second
->TransferToWindow() ) {
381 AddLogLineNS(CFormat(_("Failed to transfer data from Cfg to Widget with the ID %d and key %s"))
382 % it
->first
% it
->second
->GetKey());
386 m_ShareSelector
->SetSharedDirectories(&theApp
->glob_prefs
->shareddir_list
);
388 for ( int i
= 0; i
< cntStatColors
; i
++ ) {
389 thePrefs::s_colors
[i
] = CMuleColour(CStatisticsDlg::acrStat
[i
]).GetULong();
390 thePrefs::s_colors_ref
[i
] = CMuleColour(CStatisticsDlg::acrStat
[i
]).GetULong();
395 OnTCPClientPortChange(e
);
397 // Proxy tab initialization
398 if (!CastChild(ID_PROXY_ENABLE_PROXY
, wxCheckBox
)->IsChecked()) {
399 FindWindow(ID_PROXY_TYPE
)->Enable(false);
400 FindWindow(ID_PROXY_NAME
)->Enable(false);
401 FindWindow(ID_PROXY_PORT
)->Enable(false);
403 if (!CastChild(ID_PROXY_ENABLE_PASSWORD
, wxCheckBox
)->IsChecked()) {
404 FindWindow(ID_PROXY_USER
)->Enable(false);
405 FindWindow(ID_PROXY_PASSWORD
)->Enable(false);
407 // This option from the proxy tab is currently unused
408 FindWindow(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
)->Enable(false);
410 // Enable/Disable some controls
411 FindWindow( IDC_MINDISKSPACE
)->Enable( thePrefs::IsCheckDiskspaceEnabled() );
412 FindWindow( IDC_OSDIR
)->Enable( thePrefs::IsOnlineSignatureEnabled() );
413 FindWindow( IDC_OSUPDATE
)->Enable( thePrefs::IsOnlineSignatureEnabled() );
414 FindWindow( IDC_UDPPORT
)->Enable( thePrefs::s_UDPEnable
);
415 FindWindow( IDC_SERVERRETRIES
)->Enable( thePrefs::DeadServer() );
416 FindWindow( IDC_STARTNEXTFILE_SAME
)->Enable(thePrefs::StartNextFile());
419 FindWindow(IDC_ENABLETRAYICON
)->Enable(false);
420 FindWindow(IDC_MINTRAY
)->Enable(false);
422 FindWindow(IDC_MINTRAY
)->Enable(thePrefs::UseTrayIcon());
425 if (!CastChild(IDC_MSGFILTER
, wxCheckBox
)->IsChecked()) {
426 FindWindow(IDC_MSGFILTER_ALL
)->Enable(false);
427 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(false);
428 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(false);
429 FindWindow(IDC_MSGFILTER_WORD
)->Enable(false);
430 FindWindow(IDC_MSGWORD
)->Enable(false);
431 } else if (CastChild(IDC_MSGFILTER_ALL
, wxCheckBox
)->IsChecked()) {
432 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(false);
433 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(false);
434 FindWindow(IDC_MSGFILTER_WORD
)->Enable(false);
435 FindWindow(IDC_MSGWORD
)->Enable(false);
438 FindWindow(IDC_MSGWORD
)->Enable(CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
439 FindWindow(IDC_COMMENTWORD
)->Enable(CastChild(IDC_FILTERCOMMENTS
, wxCheckBox
)->IsChecked());
442 // Disable dirpickers unless it's a localhost connection
443 if (!theApp
->m_connect
->IsConnectedToLocalHost()) {
444 FindWindow(IDC_SELINCDIR
)->Enable(false);
445 FindWindow(IDC_SELTEMPDIR
)->Enable(false);
449 // Protocol obfuscation
450 ::SendCheckBoxEvent(this, IDC_SUPPORT_PO
);
451 ::SendCheckBoxEvent(this, IDC_ENABLE_PO_OUTGOING
);
452 ::SendCheckBoxEvent(this, IDC_ENFORCE_PO_INCOMING
);
454 // Show rates on title
455 FindWindow(IDC_RATESBEFORETITLE
)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
456 FindWindow(IDC_RATESAFTERTITLE
)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
457 CastChild(IDC_SHOWRATEONTITLE
, wxCheckBox
)->SetValue(thePrefs::GetShowRatesOnTitle() != 0);
458 CastChild(IDC_RATESBEFORETITLE
, wxRadioButton
)->SetValue(thePrefs::GetShowRatesOnTitle() == 2);
459 CastChild(IDC_RATESAFTERTITLE
, wxRadioButton
)->SetValue(thePrefs::GetShowRatesOnTitle() != 2);
463 FindWindow(IDC_UPNP_ENABLED
)->Enable(false);
464 FindWindow(IDC_UPNPTCPPORT
)->Enable(false);
465 thePrefs::SetUPnPEnabled(false);
466 // TODO: grey out "UPnP TCP Port", "Webserver UPnP TCP Port"
467 FindWindow(IDC_UPNP_WEBSERVER_ENABLED
)->Enable(false);
468 FindWindow(IDC_WEBUPNPTCPPORT
)->Enable(false);
469 thePrefs::SetUPnPWebServerEnabled(false);
470 FindWindow(IDC_UPNP_EC_ENABLED
)->Enable(false);
471 thePrefs::SetUPnPECEnabled(false);
475 // Set debugging toggles
476 int count
= theLogger
.GetDebugCategoryCount();
477 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
479 for ( int i
= 0; i
< count
; i
++ ) {
480 list
->Check( i
, theLogger
.GetDebugCategory( i
).IsEnabled() );
488 bool PrefsUnifiedDlg::TransferFromWindow()
490 // Connect the Cfgs with their widgets
491 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
492 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
493 // Checking for failures
494 if ( !it
->second
->TransferFromWindow() ) {
495 AddLogLineNS(CFormat(_("Failed to transfer data from Widget to Cfg with the ID %d and key %s"))
496 % it
->first
% it
->second
->GetKey());
500 theApp
->glob_prefs
->shareddir_list
.clear();
501 m_ShareSelector
->GetSharedDirectories(&theApp
->glob_prefs
->shareddir_list
);
503 for ( int i
= 0; i
< cntStatColors
; i
++ ) {
504 if ( thePrefs::s_colors
[i
] != thePrefs::s_colors_ref
[i
] ) {
505 CStatisticsDlg::acrStat
[i
] = thePrefs::s_colors
[i
];
506 theApp
->amuledlg
->m_statisticswnd
->ApplyStatsColor(i
);
509 theApp
->amuledlg
->m_kademliawnd
->SetGraphColors();
513 // Get debugging toggles
514 int count
= theLogger
.GetDebugCategoryCount();
515 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
517 for ( int i
= 0; i
< count
; i
++ ) {
518 theLogger
.SetEnabled( theLogger
.GetDebugCategory( i
).GetType(), list
->IsChecked( i
) );
522 thePrefs::SetShowRatesOnTitle(CastChild(IDC_SHOWRATEONTITLE
, wxCheckBox
)->GetValue() ? (CastChild(IDC_RATESBEFORETITLE
, wxRadioButton
)->GetValue() ? 2 : 1) : 0);
525 // Send preferences to core.
526 theApp
->glob_prefs
->SendToRemote();
533 bool PrefsUnifiedDlg::CfgChanged(int ID
)
535 Cfg_Base
* cfg
= GetCfg(ID
);
538 return cfg
->HasChanged();
545 void PrefsUnifiedDlg::OnOk(wxCommandEvent
& WXUNUSED(event
))
547 TransferFromWindow();
549 bool restart_needed
= false;
550 wxString restart_needed_msg
= _("aMule must be restarted to enable these changes:\n\n");
552 // do sanity checking, special processing, and user notifications here
553 thePrefs::CheckUlDlRatio();
555 if (CfgChanged(IDC_PORT
)) {
556 restart_needed
= true;
557 restart_needed_msg
+= _("- TCP port changed.\n");
560 if (CfgChanged(IDC_UDPPORT
)) {
561 restart_needed
= true;
562 restart_needed_msg
+= _("- UDP port changed.\n");
565 if (CfgChanged(IDC_EXT_CONN_TCP_PORT
)) {
566 restart_needed
= true;
567 restart_needed_msg
+= _("- External connect port changed.\n");
569 if (CfgChanged(IDC_EXT_CONN_ACCEPT
)) {
570 restart_needed
= true;
571 restart_needed_msg
+= _("- External connect acceptance changed.\n");
573 if (CfgChanged(IDC_EXT_CONN_IP
)) {
574 restart_needed
= true;
575 restart_needed_msg
+= _("- External connect interface changed.\n");
578 // Force port checking
579 thePrefs::SetPort(thePrefs::GetPort());
581 if ((CPath::GetFileSize(theApp
->ConfigDir
+ wxT("addresses.dat")) == 0) &&
582 CastChild(IDC_AUTOSERVER
, wxCheckBox
)->IsChecked() ) {
583 thePrefs::UnsetAutoServerStart();
584 wxMessageBox(_("Your Auto-update server list is empty.\n'Auto-update server list at startup' will be disabled."),
585 _("Message"), wxOK
| wxICON_INFORMATION
, this);
588 if (thePrefs::AcceptExternalConnections() && thePrefs::ECPassword().IsEmpty()) {
589 thePrefs::EnableExternalConnections( false );
591 wxMessageBox( _("You have enabled external connections but have not specified a password.\nExternal connections cannot be enabled unless a valid password is specified."));
594 // save the preferences on ok
595 theApp
->glob_prefs
->Save();
597 if (CfgChanged(IDC_FED2KLH
) && theApp
->amuledlg
->GetActiveDialog() != CamuleDlg::DT_SEARCH_WND
) {
598 theApp
->amuledlg
->ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
601 if (CfgChanged(IDC_LANGUAGE
)) {
602 restart_needed
= true;
603 restart_needed_msg
+= _("- Language changed.\n");
606 if (CfgChanged(IDC_TEMPFILES
)) {
607 restart_needed
= true;
608 restart_needed_msg
+= _("- Temp folder changed.\n");
611 if (CfgChanged(IDC_NETWORKED2K
) && thePrefs::GetNetworkED2K()) {
612 restart_needed
= true;
613 restart_needed_msg
+= _("- ED2K network enabled.\n");
616 if (CfgChanged(IDC_INCFILES
) || CfgChanged(IDC_TEMPFILES
) || m_ShareSelector
->HasChanged
) {
617 theApp
->sharedfiles
->Reload();
620 if (CfgChanged(IDC_OSDIR
) || CfgChanged(IDC_ONLINESIG
)) {
621 wxTextCtrl
* widget
= CastChild( IDC_OSDIR
, wxTextCtrl
);
623 // Build the filenames for the two OS files
624 theApp
->SetOSFiles( widget
->GetValue() );
627 if (CfgChanged(IDC_IPFCLIENTS
) && thePrefs::IsFilteringClients()) {
628 theApp
->clientlist
->FilterQueues();
631 if (CfgChanged(IDC_IPFSERVERS
) && thePrefs::IsFilteringServers()) {
632 theApp
->serverlist
->FilterServers();
635 if (CfgChanged(ID_IPFILTERLEVEL
)) {
636 theApp
->ipfilter
->Reload();
639 if (thePrefs::GetShowRatesOnTitle()) {
640 // This avoids a 5 seconds delay to show the title
641 theApp
->amuledlg
->ShowTransferRate();
643 // This resets the title
644 theApp
->amuledlg
->SetTitle(theApp
->m_FrameTitle
);
647 if (CfgChanged(IDC_EXTCATINFO
)) {
648 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
651 // Changes related to the statistics-dlg
652 if (CfgChanged(IDC_SLIDER
)) {
653 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
654 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
657 if ( CfgChanged(IDC_SLIDER3
) ) {
658 theApp
->amuledlg
->m_statisticswnd
->ResetAveragingTime();
661 if (CfgChanged(IDC_DOWNLOAD_CAP
)) {
662 theApp
->amuledlg
->m_statisticswnd
->SetARange( true, thePrefs::GetMaxGraphDownloadRate() );
665 if (CfgChanged(IDC_UPLOAD_CAP
)) {
666 theApp
->amuledlg
->m_statisticswnd
->SetARange( false, thePrefs::GetMaxGraphUploadRate() );
669 if (CfgChanged(IDC_SKIN
)) {
670 theApp
->amuledlg
->Create_Toolbar(thePrefs::VerticalToolbar());
673 if (!thePrefs::GetNetworkED2K() && theApp
->IsConnectedED2K()) {
674 theApp
->DisconnectED2K();
677 if (!thePrefs::GetNetworkKademlia() && theApp
->IsConnectedKad()) {
681 if (!thePrefs::GetNetworkED2K() && !thePrefs::GetNetworkKademlia()) {
683 _("Both eD2k and Kad network are disabled.\nYou won't be able to connect until you enable at least one of them."));
686 if (thePrefs::GetNetworkKademlia() && thePrefs::IsUDPDisabled()) {
687 wxMessageBox(_("Kad will not start if your UDP port is disabled.\nEnable UDP port or disable Kad."),
688 _("Message"), wxOK
| wxICON_INFORMATION
, this);
691 if (CfgChanged(IDC_NETWORKKAD
) || CfgChanged(IDC_NETWORKED2K
)) {
692 theApp
->amuledlg
->DoNetworkRearrange();
695 if (restart_needed
) {
696 wxMessageBox(restart_needed_msg
+ _("\nYou MUST restart aMule now.\nIf you do not restart now, don't complain if anything bad happens.\n"),
697 _("WARNING"), wxOK
| wxICON_EXCLAMATION
, this);
704 void PrefsUnifiedDlg::OnClose(wxCloseEvent
& event
)
708 // Try to keep the window alive when possible
709 if (event
.CanVeto()) {
712 if (theApp
->amuledlg
) {
713 theApp
->amuledlg
->m_prefsDialog
= NULL
;
716 // Un-Connect the Cfgs
717 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
718 for (; it
!= thePrefs::s_CfgList
.end(); ++it
) {
719 // Checking for failures
720 it
->second
->ConnectToWidget( 0 );
728 void PrefsUnifiedDlg::OnCancel(wxCommandEvent
& WXUNUSED(event
))
731 // restore state of server tab if necessary
732 EnableServerTab(thePrefs::GetNetworkED2K());
736 void PrefsUnifiedDlg::OnCheckBoxChange(wxCommandEvent
& event
)
738 bool value
= event
.IsChecked();
739 int id
= event
.GetId();
741 // Check if this checkbox is one of the User Events checkboxes
742 if (id
>= USEREVENTS_FIRST_ID
&&
743 id
< USEREVENTS_FIRST_ID
+
744 (int)CUserEvents::GetCount() * USEREVENTS_IDS_PER_EVENT
) {
745 // The corresponding text control always has
746 // an ID one greater than the checkbox
747 FindWindow(id
+ 1)->Enable(value
);
753 FindWindow( IDC_UDPPORT
)->Enable(value
);
756 case IDC_CHECKDISKSPACE
:
757 FindWindow( IDC_MINDISKSPACE
)->Enable(value
);
761 FindWindow( IDC_OSDIR
)->Enable(value
);;
762 FindWindow(IDC_OSUPDATE
)->Enable(value
);
766 FindWindow( IDC_SERVERRETRIES
)->Enable(value
);;
770 if ((CPath::GetFileSize(theApp
->ConfigDir
+ wxT("addresses.dat")) == 0) &&
771 CastChild(event
.GetId(), wxCheckBox
)->IsChecked() ) {
772 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."),
773 _("Message"), wxOK
| wxICON_INFORMATION
);
774 CastChild(event
.GetId(), wxCheckBox
)->SetValue(false);
779 // Toogle All filter options
780 FindWindow(IDC_MSGFILTER_ALL
)->Enable(value
);
781 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(value
);
782 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(value
);
783 FindWindow(IDC_MSGFILTER_WORD
)->Enable(value
);
785 FindWindow(IDC_MSGWORD
)->Enable(
786 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
788 FindWindow(IDC_MSGWORD
)->Enable(false);
792 case IDC_MSGFILTER_ALL
:
793 // Toogle filtering by data.
794 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(!value
);
795 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(!value
);
796 FindWindow(IDC_MSGFILTER_WORD
)->Enable(!value
);
798 FindWindow(IDC_MSGWORD
)->Enable(
799 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
801 FindWindow(IDC_MSGWORD
)->Enable(false);
805 case IDC_MSGFILTER_WORD
:
806 // Toogle filter word list.
807 FindWindow(IDC_MSGWORD
)->Enable(value
);
810 case IDC_FILTERCOMMENTS
:
811 FindWindow(IDC_COMMENTWORD
)->Enable(value
);
814 case ID_PROXY_ENABLE_PROXY
:
815 FindWindow(ID_PROXY_TYPE
)->Enable(value
);
816 FindWindow(ID_PROXY_NAME
)->Enable(value
);
817 FindWindow(ID_PROXY_PORT
)->Enable(value
);
820 case ID_PROXY_ENABLE_PASSWORD
:
821 FindWindow(ID_PROXY_USER
)->Enable(value
);
822 FindWindow(ID_PROXY_PASSWORD
)->Enable(value
);
825 case IDC_STARTNEXTFILE
:
826 FindWindow(IDC_STARTNEXTFILE_SAME
)->Enable(value
);
829 case IDC_ENABLETRAYICON
:
830 FindWindow(IDC_MINTRAY
)->Enable(value
);
832 theApp
->amuledlg
->CreateSystray();
834 theApp
->amuledlg
->RemoveSystray();
836 thePrefs::SetUseTrayIcon(value
);
839 case ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
:
842 case IDC_VERTTOOLBAR
:
843 theApp
->amuledlg
->Create_Toolbar(value
);
844 // Update the first tool (conn button)
845 theApp
->amuledlg
->ShowConnectionState();
848 case IDC_ENFORCE_PO_INCOMING
:
849 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(!value
);
852 case IDC_ENABLE_PO_OUTGOING
:
853 FindWindow(IDC_SUPPORT_PO
)->Enable(!value
);
854 FindWindow(IDC_ENFORCE_PO_INCOMING
)->Enable(value
);
858 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(value
);
861 case IDC_SHOWRATEONTITLE
:
862 FindWindow(IDC_RATESBEFORETITLE
)->Enable(value
);
863 FindWindow(IDC_RATESAFTERTITLE
)->Enable(value
);
866 case IDC_NETWORKED2K
: {
867 EnableServerTab(value
);
869 OnTCPClientPortChange(e
);
879 void PrefsUnifiedDlg::OnButtonColorChange(wxCommandEvent
& WXUNUSED(event
))
881 int index
= m_choiceColor
->GetSelection();
882 wxColour col
= wxGetColourFromUser( this, CMuleColour(thePrefs::s_colors
[index
]) );
884 m_buttonColor
->SetBackgroundColour( col
);
885 thePrefs::s_colors
[index
] = CMuleColour(col
).GetULong();
890 void PrefsUnifiedDlg::OnColorCategorySelected(wxCommandEvent
& WXUNUSED(evt
))
892 m_buttonColor
->SetBackgroundColour(CMuleColour(thePrefs::s_colors
[ m_choiceColor
->GetSelection() ] ) );
896 void PrefsUnifiedDlg::OnButtonDir(wxCommandEvent
& event
)
901 switch ( event
.GetId() ) {
904 type
= _("Temporary files");
909 type
= _("Incoming files");
914 type
= _("Online Signatures");
919 // type = _("Skins directory");
927 type
= CFormat(_("Choose a folder for %s")) % type
;
928 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
929 wxString dir
= widget
->GetValue();
930 wxString str
= wxDirSelector(
933 wxDefaultPosition
, this);
934 if (!str
.IsEmpty()) {
935 widget
->SetValue(str
);
940 void PrefsUnifiedDlg::OnButtonBrowseApplication(wxCommandEvent
& event
)
944 switch ( event
.GetId() ) {
946 id
= IDC_VIDEOPLAYER
;
947 title
= _("Browse for videoplayer");
950 id
= IDC_BROWSERSELF
;
951 title
= _("Select browser");
957 wxString wildcard
= CFormat(_("Executable%s"))
959 % wxT(" (*.exe)|*.exe");
964 wxString str
= wxFileSelector( title
, wxEmptyString
, wxEmptyString
,
965 wxEmptyString
, wildcard
, 0, this );
967 if ( !str
.IsEmpty() ) {
968 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
969 widget
->SetValue( str
);
974 void PrefsUnifiedDlg::OnButtonEditAddr(wxCommandEvent
& WXUNUSED(evt
))
976 wxString
fullpath( theApp
->ConfigDir
+ wxT("addresses.dat") );
978 EditServerListDlg
* test
= new EditServerListDlg(this, _("Edit server list"),
979 _("Add here URL's to download server.met files.\nOnly one url on each line."),
987 void PrefsUnifiedDlg::OnButtonIPFilterReload(wxCommandEvent
& WXUNUSED(event
))
989 theApp
->ipfilter
->Reload();
993 void PrefsUnifiedDlg::OnButtonIPFilterUpdate(wxCommandEvent
& WXUNUSED(event
))
995 theApp
->ipfilter
->Update( CastChild( IDC_IPFILTERURL
, wxTextCtrl
)->GetValue() );
999 void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent
& event
)
1001 prefs_sizer
->Detach( m_CurrentPanel
);
1002 m_CurrentPanel
->Show( false );
1004 m_CurrentPanel
= (wxPanel
*) m_PrefsIcons
->GetItemData(event
.GetIndex());
1005 if (pages
[event
.GetIndex()].m_function
== PreferencesDirectoriesTab
) {
1006 CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
)->Init();
1009 prefs_sizer
->Add( m_CurrentPanel
, 0, wxGROW
|wxEXPAND
);
1010 m_CurrentPanel
->Show( true );
1018 void PrefsUnifiedDlg::OnToolTipDelayChange(wxSpinEvent
& event
)
1020 wxToolTip::SetDelay( event
.GetPosition() * 1000 );
1024 void PrefsUnifiedDlg::OnInitDialog( wxInitDialogEvent
& WXUNUSED(evt
) )
1026 // This function exists solely to avoid automatic transfer-to-widget calls
1030 void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent
& event
)
1035 switch ( event
.GetId() ) {
1037 id
= IDC_SLIDERINFO
;
1038 label
= CFormat(wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event
.GetPosition())) % event
.GetPosition();
1039 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(event
.GetPosition());
1040 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(event
.GetPosition());
1044 id
= IDC_SLIDERINFO3
;
1045 label
= CFormat(wxPLURAL("Time for average graph: %d minute", "Time for average graph: %d minutes", event
.GetPosition())) % event
.GetPosition();
1046 theApp
->m_statistics
->SetAverageMinutes(event
.GetPosition());
1050 id
= IDC_SLIDERINFO4
;
1051 label
= CFormat(_("Connections Graph Scale: %d")) % event
.GetPosition();
1052 theApp
->amuledlg
->m_statisticswnd
->GetConnScope()->SetRanges(0, event
.GetPosition());
1056 id
= IDC_SLIDERINFO2
;
1057 label
= CFormat(wxPLURAL("Update delay : %d second", "Update delay : %d seconds", event
.GetPosition())) % event
.GetPosition();
1060 case IDC_FILEBUFFERSIZE
:
1061 id
= IDC_FILEBUFFERSIZE_STATIC
;
1062 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1063 label
= CFormat(wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event
.GetPosition() * 15000)) % (event
.GetPosition() * 15000);
1067 id
= IDC_QUEUESIZE_STATIC
;
1068 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1069 label
= CFormat(wxPLURAL("Upload Queue Size: %d client", "Upload Queue Size: %d clients", event
.GetPosition() * 100)) % (event
.GetPosition() * 100);
1072 case IDC_SERVERKEEPALIVE
:
1073 id
= IDC_SERVERKEEPALIVE_LABEL
;
1075 if ( event
.GetPosition() ) {
1076 label
= CFormat(wxPLURAL("Server connection refresh interval: %d minute", "Server connection refresh interval: %d minutes", event
.GetPosition())) % event
.GetPosition();
1078 label
= _("Server connection refresh interval: Disabled");
1086 wxStaticText
* widget
= CastChild( id
, wxStaticText
);
1089 widget
->SetLabel( label
);
1090 widget
->GetParent()->Layout();
1095 void PrefsUnifiedDlg::OnRateLimitChanged( wxSpinEvent
& event
)
1097 // Here we do immediate sanity checking of the up/down ratio,
1098 // so that the user can see if his choice is illegal
1100 // We only do checks if the rate is limited
1101 if ( event
.GetPosition() != (int)UNLIMITED
) {
1102 wxSpinCtrl
* dlrate
= CastChild( IDC_MAXDOWN
, wxSpinCtrl
);
1104 if ( event
.GetPosition() < 4 ) {
1105 if ( ( event
.GetPosition() * 3 < dlrate
->GetValue() ) ||
1106 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1107 dlrate
->SetValue( event
.GetPosition() * 3 );
1109 } else if ( event
.GetPosition() < 10 ) {
1110 if ( ( event
.GetPosition() * 4 < dlrate
->GetValue() ) ||
1111 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1112 dlrate
->SetValue( event
.GetPosition() * 4 );
1119 void PrefsUnifiedDlg::OnTCPClientPortChange(wxSpinEvent
& WXUNUSED(event
))
1121 CastChild(ID_TEXT_CLIENT_UDP_PORT
, wxStaticText
)->SetLabel(
1122 m_ServerTabVisible
? (wxString() << (CastChild(IDC_PORT
, wxSpinCtrl
)->GetValue() + 3))
1123 : wxString(_("disabled")));
1126 void PrefsUnifiedDlg::OnUserEventSelected(wxListEvent
& event
)
1128 for (unsigned int i
= 0; i
< CUserEvents::GetCount(); ++i
) {
1129 IDC_PREFS_EVENTS_PAGE
->Hide(i
+1);
1132 IDC_PREFS_EVENTS_PAGE
->Show((event
.GetData() - USEREVENTS_FIRST_ID
) / USEREVENTS_IDS_PER_EVENT
+ 1, true);
1134 IDC_PREFS_EVENTS_PAGE
->Layout();
1139 void PrefsUnifiedDlg::OnLanguageChoice(wxCommandEvent
&evt
)
1141 thePrefs::GetCfgLang()->UpdateChoice(evt
.GetSelection());
1144 void PrefsUnifiedDlg::CreateEventPanels(const int idx
, const wxString
& vars
, wxWindow
* parent
)
1146 wxStaticBox
*item8
= new wxStaticBox( parent
, -1, CFormat(_("Execute command on `%s' event")) % wxGetTranslation(CUserEvents::GetDisplayName(static_cast<enum CUserEvents::EventType
>(idx
))) );
1147 wxStaticBoxSizer
*item7
= new wxStaticBoxSizer( item8
, wxVERTICAL
);
1149 wxCheckBox
*item9
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 1, _("Enable command execution on core"), wxDefaultPosition
, wxDefaultSize
, 0 );
1150 item7
->Add( item9
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1152 wxFlexGridSizer
*item10
= new wxFlexGridSizer( 3, 0, 0 );
1153 item10
->AddGrowableCol( 2 );
1155 item10
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1157 wxStaticText
*item11
= new wxStaticText( parent
, -1, _("Core command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1158 item10
->Add( item11
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1160 wxTextCtrl
*item12
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 2, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1161 item12
->Enable(CUserEvents::IsCoreCommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1162 item10
->Add( item12
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1164 item7
->Add( item10
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1166 wxCheckBox
*item14
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 3, _("Enable command execution on GUI"), wxDefaultPosition
, wxDefaultSize
, 0 );
1167 item7
->Add( item14
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1169 wxFlexGridSizer
*item15
= new wxFlexGridSizer( 3, 0, 0 );
1170 item15
->AddGrowableCol( 2 );
1172 item15
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1174 wxStaticText
*item16
= new wxStaticText( parent
, -1, _("GUI command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1175 item15
->Add( item16
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1177 wxTextCtrl
*item17
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 4, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1178 item17
->Enable(CUserEvents::IsGUICommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1179 item15
->Add( item17
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1181 item7
->Add( item15
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1183 wxStaticText
*item13
= new wxStaticText( parent
, -1, _("The following variables will be replaced:") + vars
, wxDefaultPosition
, wxDefaultSize
, 0 );
1184 item7
->Add( item13
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1186 IDC_PREFS_EVENTS_PAGE
->Add(item7
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
1188 IDC_PREFS_EVENTS_PAGE
->Layout();
1189 IDC_PREFS_EVENTS_PAGE
->Hide(idx
+ 1);
1191 // File_checked_for_headers