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"
53 #include "PlatformSpecific.h"
55 BEGIN_EVENT_TABLE(PrefsUnifiedDlg
,wxDialog
)
57 #define USEREVENTS_EVENT(ID, NAME, VARS) \
58 EVT_CHECKBOX(USEREVENTS_FIRST_ID + CUserEvents::ID * USEREVENTS_IDS_PER_EVENT + 1, PrefsUnifiedDlg::OnCheckBoxChange) \
59 EVT_CHECKBOX(USEREVENTS_FIRST_ID + CUserEvents::ID * USEREVENTS_IDS_PER_EVENT + 3, PrefsUnifiedDlg::OnCheckBoxChange)
60 USEREVENTS_EVENTLIST()
61 #undef USEREVENTS_EVENT
64 EVT_CHECKBOX(ID_PROXY_ENABLE_PROXY
, PrefsUnifiedDlg::OnCheckBoxChange
)
65 EVT_CHECKBOX(ID_PROXY_ENABLE_PASSWORD
, PrefsUnifiedDlg::OnCheckBoxChange
)
66 // EVT_CHECKBOX(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY, PrefsUnifiedDlg::OnCheckBoxChange)
69 EVT_SPINCTRL(IDC_PORT
, PrefsUnifiedDlg::OnTCPClientPortChange
)
71 // The rest. Organize it!
72 EVT_CHECKBOX(IDC_UDPENABLE
, PrefsUnifiedDlg::OnCheckBoxChange
)
73 EVT_CHECKBOX(IDC_CHECKDISKSPACE
, 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
)
88 EVT_CHECKBOX(IDC_SHOWRATEONTITLE
, PrefsUnifiedDlg::OnCheckBoxChange
)
89 EVT_CHECKBOX(IDC_NETWORKED2K
, PrefsUnifiedDlg::OnCheckBoxChange
)
91 EVT_BUTTON(ID_PREFS_OK_TOP
, PrefsUnifiedDlg::OnOk
)
92 EVT_BUTTON(ID_PREFS_CANCEL_TOP
, PrefsUnifiedDlg::OnCancel
)
95 // EVT_BUTTON(IDC_SELSKIN, PrefsUnifiedDlg::OnButtonDir)
96 EVT_BUTTON(IDC_BROWSEV
, PrefsUnifiedDlg::OnButtonBrowseApplication
)
97 EVT_BUTTON(IDC_SELTEMPDIR
, PrefsUnifiedDlg::OnButtonDir
)
98 EVT_BUTTON(IDC_SELINCDIR
, PrefsUnifiedDlg::OnButtonDir
)
99 EVT_BUTTON(IDC_SELOSDIR
, PrefsUnifiedDlg::OnButtonDir
)
100 EVT_BUTTON(IDC_SELBROWSER
, PrefsUnifiedDlg::OnButtonBrowseApplication
)
102 EVT_SPINCTRL(IDC_TOOLTIPDELAY
, PrefsUnifiedDlg::OnToolTipDelayChange
)
104 EVT_BUTTON(IDC_EDITADR
, PrefsUnifiedDlg::OnButtonEditAddr
)
105 EVT_BUTTON(IDC_IPFRELOAD
, PrefsUnifiedDlg::OnButtonIPFilterReload
)
106 EVT_BUTTON(IDC_COLOR_BUTTON
, PrefsUnifiedDlg::OnButtonColorChange
)
107 EVT_BUTTON(IDC_IPFILTERUPDATE
, PrefsUnifiedDlg::OnButtonIPFilterUpdate
)
108 EVT_CHOICE(IDC_COLORSELECTOR
, PrefsUnifiedDlg::OnColorCategorySelected
)
109 EVT_LIST_ITEM_SELECTED(ID_PREFSLISTCTRL
,PrefsUnifiedDlg::OnPrefsPageChange
)
111 EVT_INIT_DIALOG(PrefsUnifiedDlg::OnInitDialog
)
113 EVT_COMMAND_SCROLL(IDC_SLIDER
, PrefsUnifiedDlg::OnScrollBarChange
)
114 EVT_COMMAND_SCROLL(IDC_SLIDER3
, PrefsUnifiedDlg::OnScrollBarChange
)
115 EVT_COMMAND_SCROLL(IDC_SLIDER4
, PrefsUnifiedDlg::OnScrollBarChange
)
116 EVT_COMMAND_SCROLL(IDC_SLIDER2
, PrefsUnifiedDlg::OnScrollBarChange
)
117 EVT_COMMAND_SCROLL(IDC_FILEBUFFERSIZE
, PrefsUnifiedDlg::OnScrollBarChange
)
118 EVT_COMMAND_SCROLL(IDC_QUEUESIZE
, PrefsUnifiedDlg::OnScrollBarChange
)
119 EVT_COMMAND_SCROLL(IDC_SERVERKEEPALIVE
, PrefsUnifiedDlg::OnScrollBarChange
)
121 EVT_SPINCTRL(IDC_MAXUP
, PrefsUnifiedDlg::OnRateLimitChanged
)
123 EVT_LIST_ITEM_SELECTED(IDC_EVENTLIST
, PrefsUnifiedDlg::OnUserEventSelected
)
125 EVT_CHOICE(IDC_LANGUAGE
, PrefsUnifiedDlg::OnLanguageChoice
)
127 EVT_CLOSE(PrefsUnifiedDlg::OnClose
)
133 * Creates an command-event for the given checkbox.
135 * This can be used enforce logical constraints by passing by
136 * sending a check-box event for each checkbox, when transfering
137 * to the UI. However, it should also be used for checkboxes that
138 * have no side-effects other than enabling/disabling other
139 * widgets in the preferences dialogs.
141 void SendCheckBoxEvent(wxWindow
* parent
, int id
)
143 wxCheckBox
* widget
= CastByID(id
, parent
, wxCheckBox
);
144 wxCHECK_RET(widget
, wxT("Invalid widget in CreateEvent"));
146 wxCommandEvent
evt(wxEVT_COMMAND_CHECKBOX_CLICKED
, id
);
147 evt
.SetInt(widget
->IsChecked() ? 1 : 0);
149 parent
->GetEventHandler()->ProcessEvent(evt
);
155 * This struct provides a general way to represent config-tabs.
159 //! The title of the page, used on the listctrl.
161 //! Function pointer to the wxDesigner function creating the dialog.
162 wxSizer
* (*m_function
)(wxWindow
*, bool, bool );
163 //! The index of the image used on the list.
170 { wxTRANSLATE("General"), PreferencesGeneralTab
, 13 },
171 { wxTRANSLATE("Connection"), PreferencesConnectionTab
, 14 },
172 { wxTRANSLATE("Directories"), PreferencesDirectoriesTab
, 17 },
173 { wxTRANSLATE("Servers"), PreferencesServerTab
, 15 },
174 { wxTRANSLATE("Files"), PreferencesFilesTab
, 16 },
175 { wxTRANSLATE("Security"), PreferencesSecurityTab
, 22 },
176 { wxTRANSLATE("Interface"), PreferencesGuiTweaksTab
, 19 },
177 { wxTRANSLATE("Statistics"), PreferencesStatisticsTab
, 10 },
178 { wxTRANSLATE("Proxy"), PreferencesProxyTab
, 24 },
179 { wxTRANSLATE("Filters"), PreferencesFilteringTab
, 23 },
180 { wxTRANSLATE("Remote Controls"), PreferencesRemoteControlsTab
, 11 },
181 { wxTRANSLATE("Online Signature"), PreferencesOnlineSigTab
, 21 },
182 { wxTRANSLATE("Advanced"), PreferencesaMuleTweaksTab
, 12 },
183 { wxTRANSLATE("Events"), PreferencesEventsTab
, 5 }
185 ,{ wxTRANSLATE("Debugging"), PreferencesDebug
, 25 }
190 PrefsUnifiedDlg::PrefsUnifiedDlg(wxWindow
*parent
)
192 wxDialog(parent
, -1, _("Preferences"),
193 wxDefaultPosition
, wxDefaultSize
,
194 wxDEFAULT_DIALOG_STYLE
|wxRESIZE_BORDER
)
196 preferencesDlgTop(this, false);
198 m_PrefsIcons
= CastChild(ID_PREFSLISTCTRL
, wxListCtrl
);
199 wxImageList
*icon_list
= new wxImageList(16, 16);
200 m_PrefsIcons
->AssignImageList(icon_list
, wxIMAGE_LIST_SMALL
);
202 // Add the single column used
203 m_PrefsIcons
->InsertColumn(
204 0, wxEmptyString
, wxLIST_FORMAT_LEFT
,
205 m_PrefsIcons
->GetSize().GetWidth()-5);
207 // Temp variables for finding the smallest height and width needed
211 // Add each page to the page-list
212 for (unsigned int i
= 0; i
< itemsof(pages
); ++i
) {
213 // Add the icon and label associated with the page
214 icon_list
->Add(amuleSpecial(pages
[i
].m_imageidx
));
215 m_PrefsIcons
->InsertItem(i
, wxGetTranslation(pages
[i
].m_title
), i
);
218 // Set list-width so that there aren't any scrollers
219 m_PrefsIcons
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
220 m_PrefsIcons
->SetMinSize(wxSize(m_PrefsIcons
->GetColumnWidth(0) + 10, -1));
221 m_PrefsIcons
->SetMaxSize(wxSize(m_PrefsIcons
->GetColumnWidth(0) + 10, -1));
223 // Now add the pages and calculate the minimum size
224 wxPanel
* DefaultWidget
= NULL
;
225 for (unsigned int i
= 0; i
< itemsof(pages
); ++i
) {
226 // Create a container widget and the contents of the page
227 wxPanel
* Widget
= new wxPanel(this, -1);
228 // Widget is stored as user data in the list control
229 m_PrefsIcons
->SetItemPtrData(i
, (wxUIntPtr
) Widget
);
230 pages
[i
].m_function(Widget
, true, true);
232 DefaultWidget
= Widget
;
235 // Add it to the sizer
236 prefs_sizer
->Add(Widget
, 0, wxGROW
|wxEXPAND
);
238 if (pages
[i
].m_function
== PreferencesGeneralTab
) {
239 // This must be done now or pages won't Fit();
241 CastChild(IDC_BROWSERTABS
, wxCheckBox
)->Enable(false);
242 #endif /* __WXMSW__ */
243 CastChild(IDC_PREVIEW_NOTE
, wxStaticText
)->SetLabel(_("The following variables will be substituted:\n %PARTFILE - full path to the file\n %PARTNAME - file name only"));
244 } else if (pages
[i
].m_function
== PreferencesGuiTweaksTab
) {
245 #ifndef ENABLE_IP2COUNTRY
246 CastChild(IDC_SHOW_COUNTRY_FLAGS
, wxCheckBox
)->Enable(false);
247 thePrefs::SetGeoIPEnabled(false);
249 } else if (pages
[i
].m_function
== PreferencesEventsTab
) {
251 #define USEREVENTS_REPLACE_VAR(VAR, DESC, CODE) + wxString(wxT("\n %") VAR wxT(" - ")) + wxGetTranslation(DESC)
252 #define USEREVENTS_EVENT(ID, NAME, VARS) case CUserEvents::ID: CreateEventPanels(idx, wxEmptyString VARS, Widget); break;
254 wxListCtrl
*list
= CastChild(IDC_EVENTLIST
, wxListCtrl
);
255 list
->InsertColumn(0, wxEmptyString
);
256 for (unsigned int idx
= 0; idx
< CUserEvents::GetCount(); ++idx
) {
257 long lidx
= list
->InsertItem(idx
,
258 wxGetTranslation(CUserEvents::GetDisplayName(
259 static_cast<enum CUserEvents::EventType
>(idx
))));
261 list
->SetItemData(lidx
,
262 USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
);
264 USEREVENTS_EVENTLIST()
268 list
->SetColumnWidth(0, wxLIST_AUTOSIZE
);
270 else if (pages
[i
].m_function
== PreferencesServerTab
) {
271 m_IndexServerTab
= i
;
272 m_ServerWidget
= Widget
;
274 else if (pages
[i
].m_function
== PreferencesaMuleTweaksTab
) {
275 wxStaticText
*txt
= CastChild(IDC_AMULE_TWEAKS_WARNING
, wxStaticText
);
276 // Do not wrap this line, Windows _() can't handle wrapped strings
277 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."));
278 #if defined CLIENT_GUI || !PLATFORMSPECIFIC_CAN_PREVENT_SLEEP_MODE
279 CastChild(IDC_PREVENT_SLEEP
, wxCheckBox
)->Enable(false);
280 thePrefs::SetPreventSleepWhileDownloading(false);
284 else if (pages
[i
].m_function
== PreferencesDebug
) {
285 int count
= theLogger
.GetDebugCategoryCount();
286 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
288 for ( int j
= 0; j
< count
; j
++ ) {
289 list
->Append( theLogger
.GetDebugCategory( j
).GetName() );
294 // Align and resize the page
298 // Find the greatest sizes
299 wxSize size
= prefs_sizer
->GetSize();
300 if (size
.GetWidth() > width
) {
301 width
= size
.GetWidth();
304 if (size
.GetHeight() > height
) {
305 height
= size
.GetHeight();
309 prefs_sizer
->Detach(Widget
);
313 // Default to the General tab
314 m_CurrentPanel
= DefaultWidget
;
315 prefs_sizer
->Add(DefaultWidget
, 0, wxGROW
|wxEXPAND
);
316 m_CurrentPanel
->Show( true );
318 // Select the first item
319 m_PrefsIcons
->SetItemState(0, wxLIST_STATE_SELECTED
, wxLIST_STATE_SELECTED
);
321 // We now have the needed minimum height and width
322 prefs_sizer
->SetMinSize(width
, height
);
324 // Don't show server prefs if ED2K is disabled
325 m_ServerTabVisible
= true;
326 EnableServerTab(thePrefs::GetNetworkED2K());
328 // Store some often used pointers
329 m_ShareSelector
= CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
);
330 m_buttonColor
= CastChild(IDC_COLOR_BUTTON
, wxButton
);
331 m_choiceColor
= CastChild(IDC_COLORSELECTOR
, wxChoice
);
333 // Connect the Cfgs with their widgets
334 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
335 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
336 // Checking for failures
337 if ( !it
->second
->ConnectToWidget(it
->first
, this) ) {
338 AddLogLineNS(CFormat(_("Failed to connect Cfg to widget with the ID %d and key %s"))
339 % it
->first
% it
->second
->GetKey());
344 // It must not be resized to something smaller than what it currently is
345 wxSize size
= GetClientSize();
346 SetSizeHints(size
.GetWidth(), size
.GetHeight());
348 // Position the dialog.
353 void PrefsUnifiedDlg::EnableServerTab(bool enable
)
355 if (enable
&& !m_ServerTabVisible
) {
356 // turn server widget on
357 m_PrefsIcons
->InsertItem(m_IndexServerTab
, wxGetTranslation(pages
[m_IndexServerTab
].m_title
), m_IndexServerTab
);
358 m_PrefsIcons
->SetItemPtrData(m_IndexServerTab
, (wxUIntPtr
) m_ServerWidget
);
359 m_ServerTabVisible
= true;
360 } else if (!enable
&& m_ServerTabVisible
) {
361 // turn server widget off
362 m_PrefsIcons
->DeleteItem(m_IndexServerTab
);
363 m_ServerTabVisible
= false;
368 Cfg_Base
* PrefsUnifiedDlg::GetCfg(int id
)
370 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.find( id
);
372 if ( it
!= thePrefs::s_CfgList
.end() ) {
380 bool PrefsUnifiedDlg::TransferToWindow()
382 // Connect the Cfgs with their widgets
383 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
384 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
385 // Checking for failures
386 if ( !it
->second
->TransferToWindow() ) {
387 AddLogLineNS(CFormat(_("Failed to transfer data from Cfg to Widget with the ID %d and key %s"))
388 % it
->first
% it
->second
->GetKey());
392 m_ShareSelector
->SetSharedDirectories(&theApp
->glob_prefs
->shareddir_list
);
394 for ( int i
= 0; i
< cntStatColors
; i
++ ) {
395 thePrefs::s_colors
[i
] = CMuleColour(CStatisticsDlg::acrStat
[i
]).GetULong();
396 thePrefs::s_colors_ref
[i
] = CMuleColour(CStatisticsDlg::acrStat
[i
]).GetULong();
401 OnTCPClientPortChange(e
);
403 // Proxy tab initialization
404 if (!CastChild(ID_PROXY_ENABLE_PROXY
, wxCheckBox
)->IsChecked()) {
405 FindWindow(ID_PROXY_TYPE
)->Enable(false);
406 FindWindow(ID_PROXY_NAME
)->Enable(false);
407 FindWindow(ID_PROXY_PORT
)->Enable(false);
409 if (!CastChild(ID_PROXY_ENABLE_PASSWORD
, wxCheckBox
)->IsChecked()) {
410 FindWindow(ID_PROXY_USER
)->Enable(false);
411 FindWindow(ID_PROXY_PASSWORD
)->Enable(false);
413 // This option from the proxy tab is currently unused
414 FindWindow(ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
)->Enable(false);
416 // Enable/Disable some controls
417 FindWindow( IDC_MINDISKSPACE
)->Enable( thePrefs::IsCheckDiskspaceEnabled() );
418 FindWindow( IDC_OSDIR
)->Enable( thePrefs::IsOnlineSignatureEnabled() );
419 FindWindow( IDC_OSUPDATE
)->Enable( thePrefs::IsOnlineSignatureEnabled() );
420 FindWindow( IDC_UDPPORT
)->Enable( thePrefs::s_UDPEnable
);
421 FindWindow( IDC_SERVERRETRIES
)->Enable( thePrefs::DeadServer() );
422 FindWindow( IDC_STARTNEXTFILE_SAME
)->Enable(thePrefs::StartNextFile());
423 FindWindow( IDC_STARTNEXTFILE_ALPHA
)->Enable(thePrefs::StartNextFile());
426 FindWindow(IDC_ENABLETRAYICON
)->Enable(false);
427 FindWindow(IDC_MINTRAY
)->Enable(false);
429 FindWindow(IDC_MINTRAY
)->Enable(thePrefs::UseTrayIcon());
432 if (!CastChild(IDC_MSGFILTER
, wxCheckBox
)->IsChecked()) {
433 FindWindow(IDC_MSGFILTER_ALL
)->Enable(false);
434 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(false);
435 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(false);
436 FindWindow(IDC_MSGFILTER_WORD
)->Enable(false);
437 FindWindow(IDC_MSGWORD
)->Enable(false);
438 } else if (CastChild(IDC_MSGFILTER_ALL
, wxCheckBox
)->IsChecked()) {
439 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(false);
440 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(false);
441 FindWindow(IDC_MSGFILTER_WORD
)->Enable(false);
442 FindWindow(IDC_MSGWORD
)->Enable(false);
445 FindWindow(IDC_MSGWORD
)->Enable(CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
446 FindWindow(IDC_COMMENTWORD
)->Enable(CastChild(IDC_FILTERCOMMENTS
, wxCheckBox
)->IsChecked());
449 // Disable dirpickers unless it's a localhost connection
450 if (!theApp
->m_connect
->IsConnectedToLocalHost()) {
451 FindWindow(IDC_SELINCDIR
)->Enable(false);
452 FindWindow(IDC_SELTEMPDIR
)->Enable(false);
456 // Protocol obfuscation
457 ::SendCheckBoxEvent(this, IDC_SUPPORT_PO
);
458 ::SendCheckBoxEvent(this, IDC_ENABLE_PO_OUTGOING
);
459 ::SendCheckBoxEvent(this, IDC_ENFORCE_PO_INCOMING
);
461 // Show rates on title
462 FindWindow(IDC_RATESBEFORETITLE
)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
463 FindWindow(IDC_RATESAFTERTITLE
)->Enable(thePrefs::GetShowRatesOnTitle() != 0);
464 CastChild(IDC_SHOWRATEONTITLE
, wxCheckBox
)->SetValue(thePrefs::GetShowRatesOnTitle() != 0);
465 CastChild(IDC_RATESBEFORETITLE
, wxRadioButton
)->SetValue(thePrefs::GetShowRatesOnTitle() == 2);
466 CastChild(IDC_RATESAFTERTITLE
, wxRadioButton
)->SetValue(thePrefs::GetShowRatesOnTitle() != 2);
470 FindWindow(IDC_UPNP_ENABLED
)->Enable(false);
471 FindWindow(IDC_UPNPTCPPORT
)->Enable(false);
472 thePrefs::SetUPnPEnabled(false);
473 // TODO: grey out "UPnP TCP Port", "Webserver UPnP TCP Port"
474 FindWindow(IDC_UPNP_WEBSERVER_ENABLED
)->Enable(false);
475 FindWindow(IDC_WEBUPNPTCPPORT
)->Enable(false);
476 thePrefs::SetUPnPWebServerEnabled(false);
477 FindWindow(IDC_UPNP_EC_ENABLED
)->Enable(false);
478 thePrefs::SetUPnPECEnabled(false);
482 // Set debugging toggles
483 int count
= theLogger
.GetDebugCategoryCount();
484 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
486 for ( int i
= 0; i
< count
; i
++ ) {
487 list
->Check( i
, theLogger
.GetDebugCategory( i
).IsEnabled() );
495 bool PrefsUnifiedDlg::TransferFromWindow()
497 // Connect the Cfgs with their widgets
498 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
499 for ( ; it
!= thePrefs::s_CfgList
.end(); ++it
) {
500 // Checking for failures
501 if ( !it
->second
->TransferFromWindow() ) {
502 AddLogLineNS(CFormat(_("Failed to transfer data from Widget to Cfg with the ID %d and key %s"))
503 % it
->first
% it
->second
->GetKey());
507 theApp
->glob_prefs
->shareddir_list
.clear();
508 m_ShareSelector
->GetSharedDirectories(&theApp
->glob_prefs
->shareddir_list
);
510 for ( int i
= 0; i
< cntStatColors
; i
++ ) {
511 if ( thePrefs::s_colors
[i
] != thePrefs::s_colors_ref
[i
] ) {
512 CStatisticsDlg::acrStat
[i
] = thePrefs::s_colors
[i
];
513 theApp
->amuledlg
->m_statisticswnd
->ApplyStatsColor(i
);
516 theApp
->amuledlg
->m_kademliawnd
->SetGraphColors();
520 // Get debugging toggles
521 int count
= theLogger
.GetDebugCategoryCount();
522 wxCheckListBox
* list
= CastChild( ID_DEBUGCATS
, wxCheckListBox
);
524 for ( int i
= 0; i
< count
; i
++ ) {
525 theLogger
.SetEnabled( theLogger
.GetDebugCategory( i
).GetType(), list
->IsChecked( i
) );
529 thePrefs::SetShowRatesOnTitle(CastChild(IDC_SHOWRATEONTITLE
, wxCheckBox
)->GetValue() ? (CastChild(IDC_RATESBEFORETITLE
, wxRadioButton
)->GetValue() ? 2 : 1) : 0);
532 // Send preferences to core.
533 theApp
->glob_prefs
->SendToRemote();
540 bool PrefsUnifiedDlg::CfgChanged(int ID
)
542 Cfg_Base
* cfg
= GetCfg(ID
);
545 return cfg
->HasChanged();
552 void PrefsUnifiedDlg::OnOk(wxCommandEvent
& WXUNUSED(event
))
554 TransferFromWindow();
556 bool restart_needed
= false;
557 wxString restart_needed_msg
= _("aMule must be restarted to enable these changes:\n\n");
559 // do sanity checking, special processing, and user notifications here
560 thePrefs::CheckUlDlRatio();
562 if (CfgChanged(IDC_PORT
)) {
563 restart_needed
= true;
564 restart_needed_msg
+= _("- TCP port changed.\n");
567 if (CfgChanged(IDC_UDPPORT
)) {
568 restart_needed
= true;
569 restart_needed_msg
+= _("- UDP port changed.\n");
572 if (CfgChanged(IDC_EXT_CONN_TCP_PORT
)) {
573 restart_needed
= true;
574 restart_needed_msg
+= _("- External connect port changed.\n");
576 if (CfgChanged(IDC_EXT_CONN_ACCEPT
)) {
577 restart_needed
= true;
578 restart_needed_msg
+= _("- External connect acceptance changed.\n");
580 if (CfgChanged(IDC_EXT_CONN_IP
)) {
581 restart_needed
= true;
582 restart_needed_msg
+= _("- External connect interface changed.\n");
585 // Force port checking
586 thePrefs::SetPort(thePrefs::GetPort());
588 if ((CPath::GetFileSize(theApp
->ConfigDir
+ wxT("addresses.dat")) == 0) &&
589 CastChild(IDC_AUTOSERVER
, wxCheckBox
)->IsChecked() ) {
590 thePrefs::UnsetAutoServerStart();
591 wxMessageBox(_("Your Auto-update server list is empty.\n'Auto-update server list at startup' will be disabled."),
592 _("Message"), wxOK
| wxICON_INFORMATION
, this);
595 if (thePrefs::AcceptExternalConnections() && thePrefs::ECPassword().IsEmpty()) {
596 thePrefs::EnableExternalConnections( false );
598 wxMessageBox( _("You have enabled external connections but have not specified a password.\nExternal connections cannot be enabled unless a valid password is specified."));
601 // save the preferences on ok
602 theApp
->glob_prefs
->Save();
604 if (CfgChanged(IDC_FED2KLH
) && theApp
->amuledlg
->GetActiveDialog() != CamuleDlg::DT_SEARCH_WND
) {
605 theApp
->amuledlg
->ShowED2KLinksHandler( thePrefs::GetFED2KLH() );
608 if (CfgChanged(IDC_LANGUAGE
)) {
609 restart_needed
= true;
610 restart_needed_msg
+= _("- Language changed.\n");
613 if (CfgChanged(IDC_TEMPFILES
)) {
614 restart_needed
= true;
615 restart_needed_msg
+= _("- Temp folder changed.\n");
618 if (CfgChanged(IDC_NETWORKED2K
) && thePrefs::GetNetworkED2K()) {
619 restart_needed
= true;
620 restart_needed_msg
+= _("- ED2K network enabled.\n");
623 if (CfgChanged(IDC_INCFILES
) || CfgChanged(IDC_TEMPFILES
) || m_ShareSelector
->HasChanged
) {
624 theApp
->sharedfiles
->Reload();
627 if (CfgChanged(IDC_OSDIR
) || CfgChanged(IDC_ONLINESIG
)) {
628 wxTextCtrl
* widget
= CastChild( IDC_OSDIR
, wxTextCtrl
);
630 // Build the filenames for the two OS files
631 theApp
->SetOSFiles( widget
->GetValue() );
634 if (CfgChanged(IDC_IPFCLIENTS
) && thePrefs::IsFilteringClients()) {
635 theApp
->clientlist
->FilterQueues();
638 if (CfgChanged(IDC_IPFSERVERS
) && thePrefs::IsFilteringServers()) {
639 theApp
->serverlist
->FilterServers();
642 if (CfgChanged(ID_IPFILTERLEVEL
)) {
643 theApp
->ipfilter
->Reload();
646 if (thePrefs::GetShowRatesOnTitle()) {
647 // This avoids a 5 seconds delay to show the title
648 theApp
->amuledlg
->ShowTransferRate();
650 // This resets the title
651 theApp
->amuledlg
->SetTitle(theApp
->m_FrameTitle
);
654 if (CfgChanged(IDC_EXTCATINFO
)) {
655 theApp
->amuledlg
->m_transferwnd
->UpdateCatTabTitles();
658 // Changes related to the statistics-dlg
659 if (CfgChanged(IDC_SLIDER
)) {
660 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
661 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(thePrefs::GetTrafficOMeterInterval());
664 if ( CfgChanged(IDC_SLIDER3
) ) {
665 theApp
->amuledlg
->m_statisticswnd
->ResetAveragingTime();
668 if (CfgChanged(IDC_DOWNLOAD_CAP
)) {
669 theApp
->amuledlg
->m_statisticswnd
->SetARange( true, thePrefs::GetMaxGraphDownloadRate() );
672 if (CfgChanged(IDC_UPLOAD_CAP
)) {
673 theApp
->amuledlg
->m_statisticswnd
->SetARange( false, thePrefs::GetMaxGraphUploadRate() );
676 if (CfgChanged(IDC_SKIN
)) {
677 theApp
->amuledlg
->Create_Toolbar(thePrefs::VerticalToolbar());
680 if (!thePrefs::GetNetworkED2K() && theApp
->IsConnectedED2K()) {
681 theApp
->DisconnectED2K();
684 if (!thePrefs::GetNetworkKademlia() && theApp
->IsConnectedKad()) {
688 if (!thePrefs::GetNetworkED2K() && !thePrefs::GetNetworkKademlia()) {
690 _("Both eD2k and Kad network are disabled.\nYou won't be able to connect until you enable at least one of them."));
693 if (thePrefs::GetNetworkKademlia() && thePrefs::IsUDPDisabled()) {
694 wxMessageBox(_("Kad will not start if your UDP port is disabled.\nEnable UDP port or disable Kad."),
695 _("Message"), wxOK
| wxICON_INFORMATION
, this);
698 if (CfgChanged(IDC_NETWORKKAD
) || CfgChanged(IDC_NETWORKED2K
)) {
699 theApp
->amuledlg
->DoNetworkRearrange();
702 if (CfgChanged(IDC_SHOW_COUNTRY_FLAGS
)) {
703 theApp
->amuledlg
->EnableIP2Country();
706 if (restart_needed
) {
707 wxMessageBox(restart_needed_msg
+ _("\nYou MUST restart aMule now.\nIf you do not restart now, don't complain if anything bad happens.\n"),
708 _("WARNING"), wxOK
| wxICON_EXCLAMATION
, this);
715 void PrefsUnifiedDlg::OnClose(wxCloseEvent
& event
)
719 // Try to keep the window alive when possible
720 if (event
.CanVeto()) {
723 if (theApp
->amuledlg
) {
724 theApp
->amuledlg
->m_prefsDialog
= NULL
;
727 // Un-Connect the Cfgs
728 thePrefs::CFGMap::iterator it
= thePrefs::s_CfgList
.begin();
729 for (; it
!= thePrefs::s_CfgList
.end(); ++it
) {
730 // Checking for failures
731 it
->second
->ConnectToWidget( 0 );
739 void PrefsUnifiedDlg::OnCancel(wxCommandEvent
& WXUNUSED(event
))
742 // restore state of server tab if necessary
743 EnableServerTab(thePrefs::GetNetworkED2K());
747 void PrefsUnifiedDlg::OnCheckBoxChange(wxCommandEvent
& event
)
749 bool value
= event
.IsChecked();
750 int id
= event
.GetId();
752 // Check if this checkbox is one of the User Events checkboxes
753 if (id
>= USEREVENTS_FIRST_ID
&&
754 id
< USEREVENTS_FIRST_ID
+
755 (int)CUserEvents::GetCount() * USEREVENTS_IDS_PER_EVENT
) {
756 // The corresponding text control always has
757 // an ID one greater than the checkbox
758 FindWindow(id
+ 1)->Enable(value
);
764 FindWindow( IDC_UDPPORT
)->Enable(value
);
767 case IDC_CHECKDISKSPACE
:
768 FindWindow( IDC_MINDISKSPACE
)->Enable(value
);
772 FindWindow( IDC_OSDIR
)->Enable(value
);;
773 FindWindow(IDC_OSUPDATE
)->Enable(value
);
777 FindWindow( IDC_SERVERRETRIES
)->Enable(value
);;
781 if ((CPath::GetFileSize(theApp
->ConfigDir
+ wxT("addresses.dat")) == 0) &&
782 CastChild(event
.GetId(), wxCheckBox
)->IsChecked() ) {
783 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."),
784 _("Message"), wxOK
| wxICON_INFORMATION
);
785 CastChild(event
.GetId(), wxCheckBox
)->SetValue(false);
790 // Toogle All filter options
791 FindWindow(IDC_MSGFILTER_ALL
)->Enable(value
);
792 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(value
);
793 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(value
);
794 FindWindow(IDC_MSGFILTER_WORD
)->Enable(value
);
796 FindWindow(IDC_MSGWORD
)->Enable(
797 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
799 FindWindow(IDC_MSGWORD
)->Enable(false);
803 case IDC_MSGFILTER_ALL
:
804 // Toogle filtering by data.
805 FindWindow(IDC_MSGFILTER_NONSECURE
)->Enable(!value
);
806 FindWindow(IDC_MSGFILTER_NONFRIENDS
)->Enable(!value
);
807 FindWindow(IDC_MSGFILTER_WORD
)->Enable(!value
);
809 FindWindow(IDC_MSGWORD
)->Enable(
810 CastChild(IDC_MSGFILTER_WORD
, wxCheckBox
)->IsChecked());
812 FindWindow(IDC_MSGWORD
)->Enable(false);
816 case IDC_MSGFILTER_WORD
:
817 // Toogle filter word list.
818 FindWindow(IDC_MSGWORD
)->Enable(value
);
821 case IDC_FILTERCOMMENTS
:
822 FindWindow(IDC_COMMENTWORD
)->Enable(value
);
825 case ID_PROXY_ENABLE_PROXY
:
826 FindWindow(ID_PROXY_TYPE
)->Enable(value
);
827 FindWindow(ID_PROXY_NAME
)->Enable(value
);
828 FindWindow(ID_PROXY_PORT
)->Enable(value
);
831 case ID_PROXY_ENABLE_PASSWORD
:
832 FindWindow(ID_PROXY_USER
)->Enable(value
);
833 FindWindow(ID_PROXY_PASSWORD
)->Enable(value
);
836 case IDC_STARTNEXTFILE
:
837 FindWindow(IDC_STARTNEXTFILE_SAME
)->Enable(value
);
838 FindWindow(IDC_STARTNEXTFILE_ALPHA
)->Enable(value
);
841 case IDC_ENABLETRAYICON
:
842 FindWindow(IDC_MINTRAY
)->Enable(value
);
844 theApp
->amuledlg
->CreateSystray();
846 theApp
->amuledlg
->RemoveSystray();
848 thePrefs::SetUseTrayIcon(value
);
851 case ID_PROXY_AUTO_SERVER_CONNECT_WITHOUT_PROXY
:
854 case IDC_VERTTOOLBAR
:
855 theApp
->amuledlg
->Create_Toolbar(value
);
856 // Update the first tool (conn button)
857 theApp
->amuledlg
->ShowConnectionState();
858 theApp
->amuledlg
->Layout();
861 case IDC_ENFORCE_PO_INCOMING
:
862 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(!value
);
865 case IDC_ENABLE_PO_OUTGOING
:
866 FindWindow(IDC_SUPPORT_PO
)->Enable(!value
);
867 FindWindow(IDC_ENFORCE_PO_INCOMING
)->Enable(value
);
871 FindWindow(IDC_ENABLE_PO_OUTGOING
)->Enable(value
);
874 case IDC_SHOWRATEONTITLE
:
875 FindWindow(IDC_RATESBEFORETITLE
)->Enable(value
);
876 FindWindow(IDC_RATESAFTERTITLE
)->Enable(value
);
879 case IDC_NETWORKED2K
: {
880 EnableServerTab(value
);
882 OnTCPClientPortChange(e
);
892 void PrefsUnifiedDlg::OnButtonColorChange(wxCommandEvent
& WXUNUSED(event
))
894 int index
= m_choiceColor
->GetSelection();
895 wxColour col
= wxGetColourFromUser( this, CMuleColour(thePrefs::s_colors
[index
]) );
897 m_buttonColor
->SetBackgroundColour( col
);
898 thePrefs::s_colors
[index
] = CMuleColour(col
).GetULong();
903 void PrefsUnifiedDlg::OnColorCategorySelected(wxCommandEvent
& WXUNUSED(evt
))
905 m_buttonColor
->SetBackgroundColour(CMuleColour(thePrefs::s_colors
[ m_choiceColor
->GetSelection() ] ) );
909 void PrefsUnifiedDlg::OnButtonDir(wxCommandEvent
& event
)
914 switch ( event
.GetId() ) {
917 type
= _("Temporary files");
922 type
= _("Incoming files");
927 type
= _("Online Signatures");
932 // type = _("Skins directory");
940 type
= CFormat(_("Choose a folder for %s")) % type
;
941 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
942 wxString dir
= widget
->GetValue();
943 wxString str
= wxDirSelector(
946 wxDefaultPosition
, this);
947 if (!str
.IsEmpty()) {
948 widget
->SetValue(str
);
953 void PrefsUnifiedDlg::OnButtonBrowseApplication(wxCommandEvent
& event
)
957 switch ( event
.GetId() ) {
959 id
= IDC_VIDEOPLAYER
;
960 title
= _("Browse for videoplayer");
963 id
= IDC_BROWSERSELF
;
964 title
= _("Select browser");
970 wxString wildcard
= CFormat(_("Executable%s"))
972 % wxT(" (*.exe)|*.exe");
977 wxString str
= wxFileSelector( title
, wxEmptyString
, wxEmptyString
,
978 wxEmptyString
, wildcard
, 0, this );
980 if ( !str
.IsEmpty() ) {
981 wxTextCtrl
* widget
= CastChild( id
, wxTextCtrl
);
982 widget
->SetValue( str
);
987 void PrefsUnifiedDlg::OnButtonEditAddr(wxCommandEvent
& WXUNUSED(evt
))
989 wxString
fullpath( theApp
->ConfigDir
+ wxT("addresses.dat") );
991 EditServerListDlg
* test
= new EditServerListDlg(this, _("Edit server list"),
992 _("Add here URL's to download server.met files.\nOnly one url on each line."),
1000 void PrefsUnifiedDlg::OnButtonIPFilterReload(wxCommandEvent
& WXUNUSED(event
))
1002 theApp
->ipfilter
->Reload();
1006 void PrefsUnifiedDlg::OnButtonIPFilterUpdate(wxCommandEvent
& WXUNUSED(event
))
1008 theApp
->ipfilter
->Update( CastChild( IDC_IPFILTERURL
, wxTextCtrl
)->GetValue() );
1012 void PrefsUnifiedDlg::OnPrefsPageChange(wxListEvent
& event
)
1014 prefs_sizer
->Detach( m_CurrentPanel
);
1015 m_CurrentPanel
->Show( false );
1017 m_CurrentPanel
= (wxPanel
*) m_PrefsIcons
->GetItemData(event
.GetIndex());
1018 if (pages
[event
.GetIndex()].m_function
== PreferencesDirectoriesTab
) {
1019 CastChild(IDC_SHARESELECTOR
, CDirectoryTreeCtrl
)->Init();
1022 prefs_sizer
->Add( m_CurrentPanel
, 0, wxGROW
|wxEXPAND
);
1023 m_CurrentPanel
->Show( true );
1031 void PrefsUnifiedDlg::OnToolTipDelayChange(wxSpinEvent
& event
)
1033 wxToolTip::SetDelay( event
.GetPosition() * 1000 );
1037 void PrefsUnifiedDlg::OnInitDialog( wxInitDialogEvent
& WXUNUSED(evt
) )
1039 // This function exists solely to avoid automatic transfer-to-widget calls
1043 void PrefsUnifiedDlg::OnScrollBarChange( wxScrollEvent
& event
)
1048 switch ( event
.GetId() ) {
1050 id
= IDC_SLIDERINFO
;
1051 label
= CFormat(wxPLURAL("Update delay: %d second", "Update delay: %d seconds", event
.GetPosition())) % event
.GetPosition();
1052 theApp
->amuledlg
->m_statisticswnd
->SetUpdatePeriod(event
.GetPosition());
1053 theApp
->amuledlg
->m_kademliawnd
->SetUpdatePeriod(event
.GetPosition());
1057 id
= IDC_SLIDERINFO3
;
1058 label
= CFormat(wxPLURAL("Time for average graph: %d minute", "Time for average graph: %d minutes", event
.GetPosition())) % event
.GetPosition();
1059 theApp
->m_statistics
->SetAverageMinutes(event
.GetPosition());
1063 id
= IDC_SLIDERINFO4
;
1064 label
= CFormat(_("Connections Graph Scale: %d")) % event
.GetPosition();
1065 theApp
->amuledlg
->m_statisticswnd
->GetConnScope()->SetRanges(0, event
.GetPosition());
1069 id
= IDC_SLIDERINFO2
;
1070 label
= CFormat(wxPLURAL("Update delay : %d second", "Update delay : %d seconds", event
.GetPosition())) % event
.GetPosition();
1073 case IDC_FILEBUFFERSIZE
:
1074 id
= IDC_FILEBUFFERSIZE_STATIC
;
1075 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1076 label
= CFormat(wxPLURAL("File Buffer Size: %d byte", "File Buffer Size: %d bytes", event
.GetPosition() * 15000)) % (event
.GetPosition() * 15000);
1080 id
= IDC_QUEUESIZE_STATIC
;
1081 // Yes, it seems odd to add the singular form here, but other languages might need to know the number to select the appropriate translation
1082 label
= CFormat(wxPLURAL("Upload Queue Size: %d client", "Upload Queue Size: %d clients", event
.GetPosition() * 100)) % (event
.GetPosition() * 100);
1085 case IDC_SERVERKEEPALIVE
:
1086 id
= IDC_SERVERKEEPALIVE_LABEL
;
1088 if ( event
.GetPosition() ) {
1089 label
= CFormat(wxPLURAL("Server connection refresh interval: %d minute", "Server connection refresh interval: %d minutes", event
.GetPosition())) % event
.GetPosition();
1091 label
= _("Server connection refresh interval: Disabled");
1099 wxStaticText
* widget
= CastChild( id
, wxStaticText
);
1102 widget
->SetLabel( label
);
1103 widget
->GetParent()->Layout();
1108 void PrefsUnifiedDlg::OnRateLimitChanged( wxSpinEvent
& event
)
1110 // Here we do immediate sanity checking of the up/down ratio,
1111 // so that the user can see if his choice is illegal
1113 // We only do checks if the rate is limited
1114 if ( event
.GetPosition() != (int)UNLIMITED
) {
1115 wxSpinCtrl
* dlrate
= CastChild( IDC_MAXDOWN
, wxSpinCtrl
);
1117 if ( event
.GetPosition() < 4 ) {
1118 if ( ( event
.GetPosition() * 3 < dlrate
->GetValue() ) ||
1119 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1120 dlrate
->SetValue( event
.GetPosition() * 3 );
1122 } else if ( event
.GetPosition() < 10 ) {
1123 if ( ( event
.GetPosition() * 4 < dlrate
->GetValue() ) ||
1124 ( dlrate
->GetValue() == (int)UNLIMITED
) ) {
1125 dlrate
->SetValue( event
.GetPosition() * 4 );
1132 void PrefsUnifiedDlg::OnTCPClientPortChange(wxSpinEvent
& WXUNUSED(event
))
1134 CastChild(ID_TEXT_CLIENT_UDP_PORT
, wxStaticText
)->SetLabel(
1135 m_ServerTabVisible
? (wxString() << (CastChild(IDC_PORT
, wxSpinCtrl
)->GetValue() + 3))
1136 : wxString(_("disabled")));
1139 void PrefsUnifiedDlg::OnUserEventSelected(wxListEvent
& event
)
1141 for (unsigned int i
= 0; i
< CUserEvents::GetCount(); ++i
) {
1142 IDC_PREFS_EVENTS_PAGE
->Hide(i
+1);
1145 IDC_PREFS_EVENTS_PAGE
->Show((event
.GetData() - USEREVENTS_FIRST_ID
) / USEREVENTS_IDS_PER_EVENT
+ 1, true);
1147 IDC_PREFS_EVENTS_PAGE
->Layout();
1152 void PrefsUnifiedDlg::OnLanguageChoice(wxCommandEvent
&evt
)
1154 thePrefs::GetCfgLang()->UpdateChoice(evt
.GetSelection());
1157 void PrefsUnifiedDlg::CreateEventPanels(const int idx
, const wxString
& vars
, wxWindow
* parent
)
1159 wxStaticBox
*item8
= new wxStaticBox( parent
, -1, CFormat(_("Execute command on `%s' event")) % wxGetTranslation(CUserEvents::GetDisplayName(static_cast<enum CUserEvents::EventType
>(idx
))) );
1160 wxStaticBoxSizer
*item7
= new wxStaticBoxSizer( item8
, wxVERTICAL
);
1162 wxCheckBox
*item9
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 1, _("Enable command execution on core"), wxDefaultPosition
, wxDefaultSize
, 0 );
1163 item7
->Add( item9
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1165 wxFlexGridSizer
*item10
= new wxFlexGridSizer( 3, 0, 0 );
1166 item10
->AddGrowableCol( 2 );
1168 item10
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1170 wxStaticText
*item11
= new wxStaticText( parent
, -1, _("Core command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1171 item10
->Add( item11
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1173 wxTextCtrl
*item12
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 2, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1174 item12
->Enable(CUserEvents::IsCoreCommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1175 item10
->Add( item12
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1177 item7
->Add( item10
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1179 wxCheckBox
*item14
= new wxCheckBox( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 3, _("Enable command execution on GUI"), wxDefaultPosition
, wxDefaultSize
, 0 );
1180 item7
->Add( item14
, 0, wxALIGN_CENTER_VERTICAL
|wxLEFT
|wxRIGHT
, 5 );
1182 wxFlexGridSizer
*item15
= new wxFlexGridSizer( 3, 0, 0 );
1183 item15
->AddGrowableCol( 2 );
1185 item15
->Add( 20, 20, 0, wxALIGN_CENTER
|wxALL
, 0 );
1187 wxStaticText
*item16
= new wxStaticText( parent
, -1, _("GUI command:"), wxDefaultPosition
, wxDefaultSize
, 0 );
1188 item15
->Add( item16
, 0, wxALIGN_CENTER
|wxALL
, 5 );
1190 wxTextCtrl
*item17
= new wxTextCtrl( parent
, USEREVENTS_FIRST_ID
+ idx
* USEREVENTS_IDS_PER_EVENT
+ 4, wxT(""), wxDefaultPosition
, wxDefaultSize
, 0 );
1191 item17
->Enable(CUserEvents::IsGUICommandEnabled(static_cast<enum CUserEvents::EventType
>(idx
)));
1192 item15
->Add( item17
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1194 item7
->Add( item15
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 0 );
1196 wxStaticText
*item13
= new wxStaticText( parent
, -1, _("The following variables will be replaced:") + vars
, wxDefaultPosition
, wxDefaultSize
, 0 );
1197 item7
->Add( item13
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5 );
1199 IDC_PREFS_EVENTS_PAGE
->Add(item7
, 0, wxGROW
|wxALIGN_CENTER_VERTICAL
|wxALL
, 5);
1201 IDC_PREFS_EVENTS_PAGE
->Layout();
1202 IDC_PREFS_EVENTS_PAGE
->Hide(idx
+ 1);
1204 // File_checked_for_headers