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 // Force port checking
566 thePrefs::SetPort(thePrefs::GetPort());
568 if ((CPath::GetFileSize(theApp
->ConfigDir
+ wxT("addresses.dat")) == 0) &&
569 CastChild(IDC_AUTOSERVER
, wxCheckBox
)->IsChecked() ) {
570 thePrefs::UnsetAutoServerStart();
571 wxMessageBox(_("Your Auto-update server list is empty.\n'Auto-update server list at startup' will be disabled."),
572 _("Message"), wxOK
| wxICON_INFORMATION
, this);
575 if (thePrefs::AcceptExternalConnections() && thePrefs::ECPassword().IsEmpty()) {
576 thePrefs::EnableExternalConnections( false );
578 wxMessageBox( _("You have enabled external connections but have not specified a password.\nExternal connections cannot be enabled unless a valid password is specified."));
581 // save the preferences on ok
582 theApp
->glob_prefs
->Save();
584 if (CfgChanged(IDC_FED2KLH
) && theApp
->amuledlg
->GetActiveDialog() != CamuleDlg::DT_SEARCH_WND
) {
585 theApp
->amuledlg
->ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
588 if (CfgChanged(IDC_LANGUAGE
)) {
589 restart_needed
= true;
590 restart_needed_msg
+= _("- Language changed.\n");
593 if (CfgChanged(IDC_TEMPFILES
)) {
594 restart_needed
= true;
595 restart_needed_msg
+= _("- Temp folder changed.\n");
598 if (CfgChanged(IDC_NETWORKED2K
) && thePrefs::GetNetworkED2K()) {
599 restart_needed
= true;
600 restart_needed_msg
+= _("- ED2K network enabled.\n");
603 if (CfgChanged(IDC_INCFILES
) || CfgChanged(IDC_TEMPFILES
) || m_ShareSelector
->HasChanged
) {
604 theApp
->sharedfiles
->Reload();
607 if (CfgChanged(IDC_OSDIR
) || CfgChanged(IDC_ONLINESIG
)) {
608 wxTextCtrl
* widget
= CastChild( IDC_OSDIR
, wxTextCtrl
);
610 // Build the filenames for the two OS files
611 theApp
->SetOSFiles( widget
->GetValue() );
614 if (CfgChanged(IDC_IPFCLIENTS
) && thePrefs::IsFilteringClients()) {
615 theApp
->clientlist
->FilterQueues();
618 if (CfgChanged(IDC_IPFSERVERS
) && thePrefs::IsFilteringServers()) {
619 theApp
->serverlist
->FilterServers();
622 if (CfgChanged(ID_IPFILTERLEVEL
)) {
623 theApp
->ipfilter
->Reload();
626 if (thePrefs::GetShowRatesOnTitle()) {
627 // This avoids a 5 seconds delay to show the title
628 theApp
->amuledlg
->ShowTransferRate();
630 // This resets the title
631 theApp
->amuledlg
->SetTitle(theApp
->m_FrameTitle
);
634 if (CfgChanged(IDC_EXTCATINFO
)) {
635 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
638 // Changes related to the statistics-dlg
639 if (CfgChanged(IDC_SLIDER
)) {
640 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
641 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
644 if ( CfgChanged(IDC_SLIDER3
) ) {
645 theApp
->amuledlg
->m_statisticswnd
->ResetAveragingTime();
648 if (CfgChanged(IDC_DOWNLOAD_CAP
)) {
649 theApp
->amuledlg
->m_statisticswnd
->SetARange( true, thePrefs::GetMaxGraphDownloadRate() );
652 if (CfgChanged(IDC_UPLOAD_CAP
)) {
653 theApp
->amuledlg
->m_statisticswnd
->SetARange( false, thePrefs::GetMaxGraphUploadRate() );
656 if (CfgChanged(IDC_SKIN
)) {
657 theApp
->amuledlg
->Create_Toolbar(thePrefs::VerticalToolbar());
660 if (!thePrefs::GetNetworkED2K() && theApp
->IsConnectedED2K()) {
661 theApp
->DisconnectED2K();
664 if (!thePrefs::GetNetworkKademlia() && theApp
->IsConnectedKad()) {
668 if (!thePrefs::GetNetworkED2K() && !thePrefs::GetNetworkKademlia()) {
670 _("Both eD2k and Kad network are disabled.\nYou won't be able to connect until you enable at least one of them."));
673 if (thePrefs::GetNetworkKademlia() && thePrefs::IsUDPDisabled()) {
674 wxMessageBox(_("Kad will not start if your UDP port is disabled.\nEnable UDP port or disable Kad."),
675 _("Message"), wxOK
| wxICON_INFORMATION
, this);
678 if (CfgChanged(IDC_NETWORKKAD
) || CfgChanged(IDC_NETWORKED2K
)) {
679 theApp
->amuledlg
->DoNetworkRearrange();
682 if (restart_needed
) {
683 wxMessageBox(restart_needed_msg
+ _("\nYou MUST restart aMule now.\nIf you do not restart now, don't complain if anything bad happens.\n"),
684 _("WARNING"), wxOK
| wxICON_EXCLAMATION
, this);
691 void PrefsUnifiedDlg::OnClose(wxCloseEvent
& event
)
695 // Try to keep the window alive when possible
696 if (event
.CanVeto()) {
699 if (theApp
->amuledlg
) {
700 theApp
->amuledlg
->m_prefsDialog
= NULL
;
703 // Un-Connect the Cfgs
704 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
705 for (; it
!= thePrefs::s_CfgList
.end(); ++it
) {
706 // Checking for failures
707 it
->second
->ConnectToWidget( 0 );
715 void PrefsUnifiedDlg::OnCancel(wxCommandEvent
& WXUNUSED(event
))
718 // restore state of server tab if necessary
719 EnableServerTab(thePrefs::GetNetworkED2K());
723 void PrefsUnifiedDlg::OnCheckBoxChange(wxCommandEvent
& event
)
725 bool value
= event
.IsChecked();
726 int id
= event
.GetId();
728 // Check if this checkbox is one of the User Events checkboxes
729 if (id
>= USEREVENTS_FIRST_ID
&&
730 id
< USEREVENTS_FIRST_ID
+
731 (int)CUserEvents::GetCount() * USEREVENTS_IDS_PER_EVENT
) {
732 // The corresponding text control always has
733 // an ID one greater than the checkbox
734 FindWindow(id
+ 1)->Enable(value
);
740 FindWindow( IDC_UDPPORT
)->Enable(value
);
743 case IDC_CHECKDISKSPACE
:
744 FindWindow( IDC_MINDISKSPACE
)->Enable(value
);
748 FindWindow( IDC_OSDIR
)->Enable(value
);;
749 FindWindow(IDC_OSUPDATE
)->Enable(value
);
753 FindWindow( IDC_SERVERRETRIES
)->Enable(value
);;
757 if ((CPath::GetFileSize(theApp
->ConfigDir
+ wxT("addresses.dat")) == 0) &&
758 CastChild(event
.GetId(), wxCheckBox
)->IsChecked() ) {
759 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."),
760 _("Message"), wxOK
| wxICON_INFORMATION
);
761 CastChild(event
.GetId(), wxCheckBox
)->SetValue(false);
766 // Toogle All filter options
767 FindWindow(IDC_MSGFILTER_ALL
)->Enable(value
);
768 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(value
);
769 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(value
);
770 FindWindow(IDC_MSGFILTER_WORD
)->Enable(value
);
772 FindWindow(IDC_MSGWORD
)->Enable(
773 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
775 FindWindow(IDC_MSGWORD
)->Enable(false);
779 case IDC_MSGFILTER_ALL
:
780 // Toogle filtering by data.
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_WORD
:
793 // Toogle filter word list.
794 FindWindow(IDC_MSGWORD
)->Enable(value
);
797 case IDC_FILTERCOMMENTS
:
798 FindWindow(IDC_COMMENTWORD
)->Enable(value
);
801 case ID_PROXY_ENABLE_PROXY
:
802 FindWindow(ID_PROXY_TYPE
)->Enable(value
);
803 FindWindow(ID_PROXY_NAME
)->Enable(value
);
804 FindWindow(ID_PROXY_PORT
)->Enable(value
);
807 case ID_PROXY_ENABLE_PASSWORD
:
808 FindWindow(ID_PROXY_USER
)->Enable(value
);
809 FindWindow(ID_PROXY_PASSWORD
)->Enable(value
);
812 case IDC_STARTNEXTFILE
:
813 FindWindow(IDC_STARTNEXTFILE_SAME
)->Enable(value
);
816 case IDC_ENABLETRAYICON
:
817 FindWindow(IDC_MINTRAY
)->Enable(value
);
819 theApp
->amuledlg
->CreateSystray();
821 theApp
->amuledlg
->RemoveSystray();
823 thePrefs::SetUseTrayIcon(value
);
826 case ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
:
829 case IDC_VERTTOOLBAR
:
830 theApp
->amuledlg
->Create_Toolbar(value
);
831 // Update the first tool (conn button)
832 theApp
->amuledlg
->ShowConnectionState();
835 case IDC_ENFORCE_PO_INCOMING
:
836 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(!value
);
839 case IDC_ENABLE_PO_OUTGOING
:
840 FindWindow(IDC_SUPPORT_PO
)->Enable(!value
);
841 FindWindow(IDC_ENFORCE_PO_INCOMING
)->Enable(value
);
845 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(value
);
848 case IDC_SHOWRATEONTITLE
:
849 FindWindow(IDC_RATESBEFORETITLE
)->Enable(value
);
850 FindWindow(IDC_RATESAFTERTITLE
)->Enable(value
);
853 case IDC_NETWORKED2K
: {
854 EnableServerTab(value
);
856 OnTCPClientPortChange(e
);
866 void PrefsUnifiedDlg::OnButtonColorChange(wxCommandEvent
& WXUNUSED(event
))
868 int index
= m_choiceColor
->GetSelection();
869 wxColour col
= wxGetColourFromUser( this, CMuleColour(thePrefs::s_colors
[index
]) );
871 m_buttonColor
->SetBackgroundColour( col
);
872 thePrefs::s_colors
[index
] = CMuleColour(col
).GetULong();
877 void PrefsUnifiedDlg::OnColorCategorySelected(wxCommandEvent
& WXUNUSED(evt
))
879 m_buttonColor
->SetBackgroundColour(CMuleColour(thePrefs::s_colors
[ m_choiceColor
->GetSelection() ] ) );
883 void PrefsUnifiedDlg::OnButtonDir(wxCommandEvent
& event
)
888 switch ( event
.GetId() ) {
891 type
= _("Temporary files");
896 type
= _("Incoming files");
901 type
= _("Online Signatures");
906 // type = _("Skins directory");
914 type
= CFormat(_("Choose a folder for %s")) % type
;
915 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
916 wxString dir
= widget
->GetValue();
917 wxString str
= wxDirSelector(
920 wxDefaultPosition
, this);
921 if (!str
.IsEmpty()) {
922 widget
->SetValue(str
);
927 void PrefsUnifiedDlg::OnButtonBrowseApplication(wxCommandEvent
& event
)
931 switch ( event
.GetId() ) {
933 id
= IDC_VIDEOPLAYER
;
934 title
= _("Browse for videoplayer");
937 id
= IDC_BROWSERSELF
;
938 title
= _("Select browser");
944 wxString wildcard
= CFormat(_("Executable%s"))
946 % wxT(" (*.exe)|*.exe");
951 wxString str
= wxFileSelector( title
, wxEmptyString
, wxEmptyString
,
952 wxEmptyString
, wildcard
, 0, this );
954 if ( !str
.IsEmpty() ) {
955 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
956 widget
->SetValue( str
);
961 void PrefsUnifiedDlg::OnButtonEditAddr(wxCommandEvent
& WXUNUSED(evt
))
963 wxString
fullpath( theApp
->ConfigDir
+ wxT("addresses.dat") );
965 EditServerListDlg
* test
= new EditServerListDlg(this, _("Edit server list"),
966 _("Add here URL's to download server.met files.\nOnly one url on each line."),
974 void PrefsUnifiedDlg::OnButtonIPFilterReload(wxCommandEvent
& WXUNUSED(event
))
976 theApp
->ipfilter
->Reload();
980 void PrefsUnifiedDlg::OnButtonIPFilterUpdate(wxCommandEvent
& WXUNUSED(event
))
982 theApp
->ipfilter
->Update( CastChild( IDC_IPFILTERURL
, wxTextCtrl
)->GetValue() );
986 void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent
& event
)
988 prefs_sizer
->Detach( m_CurrentPanel
);
989 m_CurrentPanel
->Show( false );
991 m_CurrentPanel
= (wxPanel
*) m_PrefsIcons
->GetItemData(event
.GetIndex());
992 if (pages
[event
.GetIndex()].m_function
== PreferencesDirectoriesTab
) {
993 CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
)->Init();
996 prefs_sizer
->Add( m_CurrentPanel
, 0, wxGROW
|wxEXPAND
);
997 m_CurrentPanel
->Show( true );
1005 void PrefsUnifiedDlg::OnToolTipDelayChange(wxSpinEvent
& event
)
1007 wxToolTip::SetDelay( event
.GetPosition() * 1000 );
1011 void PrefsUnifiedDlg::OnInitDialog( wxInitDialogEvent
& WXUNUSED(evt
) )
1013 // This function exists solely to avoid automatic transfer-to-widget calls
1017 void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent
& event
)
1022 switch ( event
.GetId() ) {
1024 id
= IDC_SLIDERINFO
;
1025 label
= CFormat(wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event
.GetPosition())) % event
.GetPosition();
1026 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(event
.GetPosition());
1027 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(event
.GetPosition());
1031 id
= IDC_SLIDERINFO3
;
1032 label
= CFormat(wxPLURAL("Time for average graph: %d minute", "Time for average graph: %d minutes", event
.GetPosition())) % event
.GetPosition();
1033 theApp
->m_statistics
->SetAverageMinutes(event
.GetPosition());
1037 id
= IDC_SLIDERINFO4
;
1038 label
= CFormat(_("Connections Graph Scale: %d")) % event
.GetPosition();
1039 theApp
->amuledlg
->m_statisticswnd
->GetConnScope()->SetRanges(0, event
.GetPosition());
1043 id
= IDC_SLIDERINFO2
;
1044 label
= CFormat(wxPLURAL("Update delay : %d second", "Update delay : %d seconds", event
.GetPosition())) % event
.GetPosition();
1047 case IDC_FILEBUFFERSIZE
:
1048 id
= IDC_FILEBUFFERSIZE_STATIC
;
1049 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1050 label
= CFormat(wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event
.GetPosition() * 15000)) % (event
.GetPosition() * 15000);
1054 id
= IDC_QUEUESIZE_STATIC
;
1055 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1056 label
= CFormat(wxPLURAL("Upload Queue Size: %d client", "Upload Queue Size: %d clients", event
.GetPosition() * 100)) % (event
.GetPosition() * 100);
1059 case IDC_SERVERKEEPALIVE
:
1060 id
= IDC_SERVERKEEPALIVE_LABEL
;
1062 if ( event
.GetPosition() ) {
1063 label
= CFormat(wxPLURAL("Server connection refresh interval: %d minute", "Server connection refresh interval: %d minutes", event
.GetPosition())) % event
.GetPosition();
1065 label
= _("Server connection refresh interval: Disabled");
1073 wxStaticText
* widget
= CastChild( id
, wxStaticText
);
1076 widget
->SetLabel( label
);
1077 widget
->GetParent()->Layout();
1082 void PrefsUnifiedDlg::OnRateLimitChanged( wxSpinEvent
& event
)
1084 // Here we do immediate sanity checking of the up/down ratio,
1085 // so that the user can see if his choice is illegal
1087 // We only do checks if the rate is limited
1088 if ( event
.GetPosition() != (int)UNLIMITED
) {
1089 wxSpinCtrl
* dlrate
= CastChild( IDC_MAXDOWN
, wxSpinCtrl
);
1091 if ( event
.GetPosition() < 4 ) {
1092 if ( ( event
.GetPosition() * 3 < dlrate
->GetValue() ) ||
1093 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1094 dlrate
->SetValue( event
.GetPosition() * 3 );
1096 } else if ( event
.GetPosition() < 10 ) {
1097 if ( ( event
.GetPosition() * 4 < dlrate
->GetValue() ) ||
1098 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1099 dlrate
->SetValue( event
.GetPosition() * 4 );
1106 void PrefsUnifiedDlg::OnTCPClientPortChange(wxSpinEvent
& WXUNUSED(event
))
1108 CastChild(ID_TEXT_CLIENT_UDP_PORT
, wxStaticText
)->SetLabel(
1109 m_ServerTabVisible
? (wxString() << (CastChild(IDC_PORT
, wxSpinCtrl
)->GetValue() + 3))
1110 : wxString(_("disabled")));
1113 void PrefsUnifiedDlg::OnUserEventSelected(wxListEvent
& event
)
1115 for (unsigned int i
= 0; i
< CUserEvents::GetCount(); ++i
) {
1116 IDC_PREFS_EVENTS_PAGE
->Hide(i
+1);
1119 IDC_PREFS_EVENTS_PAGE
->Show((event
.GetData() - USEREVENTS_FIRST_ID
) / USEREVENTS_IDS_PER_EVENT
+ 1, true);
1121 IDC_PREFS_EVENTS_PAGE
->Layout();
1126 void PrefsUnifiedDlg::OnLanguageChoice(wxCommandEvent
&evt
)
1128 thePrefs::GetCfgLang()->UpdateChoice(evt
.GetSelection());
1131 void PrefsUnifiedDlg::CreateEventPanels(const int idx
, const wxString
& vars
, wxWindow
* parent
)
1133 wxStaticBox
*item8
= new wxStaticBox( parent
, -1, CFormat(_("Execute command on `%s' event")) % wxGetTranslation(CUserEvents::GetDisplayName(static_cast<enum CUserEvents::EventType
>(idx
))) );
1134 wxStaticBoxSizer
*item7
= new wxStaticBoxSizer( item8
, wxVERTICAL
);
1136 wxCheckBox
*item9
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 1, _("Enable command execution on core"), wxDefaultPosition
, wxDefaultSize
, 0 );
1137 item7
->Add( item9
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1139 wxFlexGridSizer
*item10
= new wxFlexGridSizer( 3, 0, 0 );
1140 item10
->AddGrowableCol( 2 );
1142 item10
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1144 wxStaticText
*item11
= new wxStaticText( parent
, -1, _("Core command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1145 item10
->Add( item11
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1147 wxTextCtrl
*item12
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 2, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1148 item12
->Enable(CUserEvents::IsCoreCommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1149 item10
->Add( item12
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1151 item7
->Add( item10
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1153 wxCheckBox
*item14
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 3, _("Enable command execution on GUI"), wxDefaultPosition
, wxDefaultSize
, 0 );
1154 item7
->Add( item14
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1156 wxFlexGridSizer
*item15
= new wxFlexGridSizer( 3, 0, 0 );
1157 item15
->AddGrowableCol( 2 );
1159 item15
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1161 wxStaticText
*item16
= new wxStaticText( parent
, -1, _("GUI command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1162 item15
->Add( item16
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1164 wxTextCtrl
*item17
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 4, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1165 item17
->Enable(CUserEvents::IsGUICommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1166 item15
->Add( item17
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1168 item7
->Add( item15
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1170 wxStaticText
*item13
= new wxStaticText( parent
, -1, _("The following variables will be replaced:") + vars
, wxDefaultPosition
, wxDefaultSize
, 0 );
1171 item7
->Add( item13
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1173 IDC_PREFS_EVENTS_PAGE
->Add(item7
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
1175 IDC_PREFS_EVENTS_PAGE
->Layout();
1176 IDC_PREFS_EVENTS_PAGE
->Hide(idx
+ 1);
1178 // File_checked_for_headers