2006-07-20 19:33:08 +00:00
// Berkeley Open Infrastructure for Network Computing
// http://boinc.berkeley.edu
// Copyright (C) 2005 University of California
//
// This is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
// See the GNU Lesser General Public License for more details.
//
// To view the GNU Lesser General Public License visit
// http://www.gnu.org/copyleft/lesser.html
// or write to the Free Software Foundation, Inc.,
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# if defined(__GNUG__) && !defined(__APPLE__)
# pragma implementation "sg_DlgPreferences.h"
# endif
2006-07-05 21:36:56 +00:00
2006-07-20 19:33:08 +00:00
# include "stdwx.h"
2006-10-20 15:00:14 +00:00
# include "diagnostics.h"
2007-02-21 17:06:11 +00:00
# include "str_util.h"
2006-10-20 15:00:14 +00:00
# include "mfile.h"
# include "miofile.h"
# include "parse.h"
# include "error_numbers.h"
2006-10-25 14:09:47 +00:00
# include "Events.h"
2006-08-17 17:36:51 +00:00
# include "BOINCGUIApp.h"
2006-10-20 15:00:14 +00:00
# include "SkinManager.h"
# include "MainDocument.h"
2006-12-30 00:50:04 +00:00
# include "hyperlink.h"
2006-10-28 09:02:46 +00:00
# include "sg_CustomControls.h"
2006-10-23 06:48:48 +00:00
# include "sg_DlgPreferences.h"
2006-07-05 21:36:56 +00:00
2006-11-06 13:45:50 +00:00
# ifdef __WXMAC__
# define TINY_FONT 12
# define SMALL_FONT 12
# define MEDIUM_FONT 14
# define LARGE_FONT 16
# else
# define TINY_FONT 8
# define SMALL_FONT 9
# define MEDIUM_FONT 12
# define LARGE_FONT 16
# endif
2006-10-25 14:09:47 +00:00
2006-10-27 10:26:56 +00:00
////@begin includes
////@end includes
////@begin XPM images
////@end XPM images
// Useful arrays used as templates for arrays created at runtime.
//
int iTimeOfDayArraySize = 24 ;
wxString astrTimeOfDayStrings [ ] = {
wxT ( " 0:00 " ) ,
wxT ( " 1:00 " ) ,
wxT ( " 2:00 " ) ,
wxT ( " 3:00 " ) ,
wxT ( " 4:00 " ) ,
wxT ( " 5:00 " ) ,
wxT ( " 6:00 " ) ,
wxT ( " 7:00 " ) ,
wxT ( " 8:00 " ) ,
wxT ( " 9:00 " ) ,
wxT ( " 10:00 " ) ,
wxT ( " 11:00 " ) ,
wxT ( " 12:00 " ) ,
wxT ( " 13:00 " ) ,
wxT ( " 14:00 " ) ,
wxT ( " 15:00 " ) ,
wxT ( " 16:00 " ) ,
wxT ( " 17:00 " ) ,
wxT ( " 18:00 " ) ,
wxT ( " 19:00 " ) ,
wxT ( " 20:00 " ) ,
wxT ( " 21:00 " ) ,
wxT ( " 22:00 " ) ,
wxT ( " 23:00 " ) ,
wxT ( " 24:00 " )
} ;
2006-11-07 01:22:28 +00:00
int iDiskUsageArraySize = 10 ;
2006-10-27 10:26:56 +00:00
wxString astrDiskUsageStrings [ ] = {
_ ( " 100 MB " ) ,
_ ( " 200 MB " ) ,
_ ( " 500 MB " ) ,
_ ( " 1 GB " ) ,
_ ( " 2 GB " ) ,
2006-11-07 01:22:28 +00:00
_ ( " 5 GB " ) ,
_ ( " 10 GB " ) ,
_ ( " 20 GB " ) ,
_ ( " 50 GB " ) ,
_ ( " 100 GB " )
2006-10-27 10:26:56 +00:00
} ;
// Used for sorting disk usage values
static int CompareDiskUsage ( const wxString & strFirst , const wxString & strSecond ) {
long lFirstValue ;
long lSecondValue ;
// Is first measured in GB and second measured in MB?
if ( ( strFirst . Find ( wxT ( " GB " ) ) ! = - 1 ) & & ( strSecond . Find ( wxT ( " MB " ) ) ! = - 1 ) ) return 1 ;
// Is first measured in MB and second measured in GB?
if ( ( strFirst . Find ( wxT ( " MB " ) ) ! = - 1 ) & & ( strSecond . Find ( wxT ( " GB " ) ) ! = - 1 ) ) return - 1 ;
// Convert to numbers
strFirst . ToLong ( & lFirstValue ) ;
strSecond . ToLong ( & lSecondValue ) ;
// Is lFirstValue larger than lSecondValue?
if ( lFirstValue > lSecondValue ) return 1 ;
// Is lFirstValue less than lSecondValue?
if ( lFirstValue < lSecondValue ) return - 1 ;
// they must be equal
return 0 ;
}
int iCPUUsageArraySize = 10 ;
wxString astrCPUUsageStrings [ ] = {
_ ( " 10% " ) ,
_ ( " 20% " ) ,
_ ( " 30% " ) ,
_ ( " 40% " ) ,
_ ( " 50% " ) ,
_ ( " 60% " ) ,
_ ( " 70% " ) ,
_ ( " 80% " ) ,
_ ( " 90% " ) ,
_ ( " 100% " )
} ;
// Used for sorting cpu usage values
static int CompareCPUUsage ( const wxString & strFirst , const wxString & strSecond ) {
long lFirstValue ;
long lSecondValue ;
// Convert to numbers
strFirst . ToLong ( & lFirstValue ) ;
strSecond . ToLong ( & lSecondValue ) ;
// Is lFirstValue larger than lSecondValue?
if ( lFirstValue > lSecondValue ) return 1 ;
// Is lFirstValue less than lSecondValue?
if ( lFirstValue < lSecondValue ) return - 1 ;
// they must be equal
return 0 ;
}
2006-11-27 03:37:03 +00:00
int iWorkWhenIdleArraySize = 7 ;
2006-10-27 10:26:56 +00:00
wxString astrWorkWhenIdleStrings [ ] = {
_ ( " 1 " ) ,
2006-11-27 04:54:05 +00:00
_ ( " 3 " ) ,
2006-10-27 10:26:56 +00:00
_ ( " 5 " ) ,
_ ( " 10 " ) ,
_ ( " 15 " ) ,
_ ( " 30 " ) ,
_ ( " 60 " )
} ;
// Used for sorting work when idle values
static int CompareWorkWhenIdle ( const wxString & strFirst , const wxString & strSecond ) {
long lFirstValue ;
long lSecondValue ;
// Convert to numbers
strFirst . ToLong ( & lFirstValue ) ;
strSecond . ToLong ( & lSecondValue ) ;
// Is lFirstValue larger than lSecondValue?
if ( lFirstValue > lSecondValue ) return 1 ;
// Is lFirstValue less than lSecondValue?
if ( lFirstValue < lSecondValue ) return - 1 ;
// they must be equal
return 0 ;
}
2006-11-06 13:45:50 +00:00
/*!
* CPanelPreferences type definition
*/
2006-11-06 23:12:56 +00:00
IMPLEMENT_DYNAMIC_CLASS ( CPanelPreferences , wxPanel )
2006-11-06 13:45:50 +00:00
/*!
* CPanelPreferences event table definition
*/
BEGIN_EVENT_TABLE ( CPanelPreferences , wxPanel )
////@begin CPanelPreferences event table entries
EVT_ERASE_BACKGROUND ( CPanelPreferences : : OnEraseBackground )
EVT_CHECKBOX ( ID_CUSTOMIZEPREFERENCES , CPanelPreferences : : OnCustomizePreferencesClick )
2006-11-15 11:32:52 +00:00
EVT_COMBOBOX ( ID_WORKBETWEENBEGIN , CPanelPreferences : : OnWorkBetweenBeginSelected )
EVT_COMBOBOX ( ID_CONNECTBETWEENBEGIN , CPanelPreferences : : OnConnectBetweenBeginSelected )
2007-01-06 05:14:26 +00:00
EVT_BUTTON ( ID_SIMPLE_HELP , CPanelPreferences : : OnButtonHelp )
2006-11-06 13:45:50 +00:00
////@end CPanelPreferences event table entries
END_EVENT_TABLE ( )
/*!
* CPanelPreferences constructors
*/
CPanelPreferences : : CPanelPreferences ( )
{
}
CPanelPreferences : : CPanelPreferences ( wxWindow * parent ) :
2006-11-17 06:41:15 +00:00
wxPanel ( parent , wxID_ANY , wxDefaultPosition , wxDefaultSize , wxNO_BORDER )
2006-11-06 13:45:50 +00:00
{
Create ( ) ;
}
/*!
* CPanelPreferences creator
*/
bool CPanelPreferences : : Create ( )
{
////@begin CPanelPreferences member initialisation
2006-10-27 10:26:56 +00:00
m_SkinSelectorCtrl = NULL ;
2006-10-27 23:34:24 +00:00
m_CustomizePreferencesCtrl = NULL ;
2006-10-27 10:26:56 +00:00
m_WorkBetweenBeginCtrl = NULL ;
m_WorkBetweenEndCtrl = NULL ;
m_ConnectBetweenBeginCtrl = NULL ;
m_ConnectBetweenEndCtrl = NULL ;
m_MaxDiskUsageCtrl = NULL ;
m_MaxCPUUsageCtrl = NULL ;
m_WorkWhileOnBatteryCtrl = NULL ;
m_WorkWhenIdleCtrl = NULL ;
2006-11-06 13:45:50 +00:00
////@end CPanelPreferences member initialisation
2006-10-28 09:02:46 +00:00
2006-10-25 14:09:47 +00:00
CreateControls ( ) ;
2006-11-06 13:45:50 +00:00
2006-10-27 10:26:56 +00:00
ReadPreferenceSettings ( ) ;
ReadSkinSettings ( ) ;
2006-10-25 14:09:47 +00:00
2006-12-09 02:35:06 +00:00
GetSizer ( ) - > Fit ( this ) ;
GetSizer ( ) - > SetSizeHints ( this ) ;
2006-10-27 10:26:56 +00:00
return true ;
}
2006-10-25 14:09:47 +00:00
2006-10-27 10:26:56 +00:00
/*!
2006-11-06 13:45:50 +00:00
* Control creation for CPanelPreferences
2006-10-27 10:26:56 +00:00
*/
2006-10-25 14:09:47 +00:00
2006-11-06 13:45:50 +00:00
void CPanelPreferences : : CreateControls ( )
2006-10-27 10:26:56 +00:00
{
CSkinSimple * pSkinSimple = wxGetApp ( ) . GetSkinManager ( ) - > GetSimple ( ) ;
2006-10-25 14:09:47 +00:00
2006-10-27 10:26:56 +00:00
wxASSERT ( pSkinSimple ) ;
wxASSERT ( wxDynamicCast ( pSkinSimple , CSkinSimple ) ) ;
2006-11-06 13:45:50 +00:00
CPanelPreferences * itemDialog1 = this ;
2006-10-27 10:26:56 +00:00
wxBoxSizer * itemBoxSizer2 = new wxBoxSizer ( wxVERTICAL ) ;
itemDialog1 - > SetSizer ( itemBoxSizer2 ) ;
wxFlexGridSizer * itemFlexGridSizer3 = new wxFlexGridSizer ( 1 , 1 , 0 , 0 ) ;
itemBoxSizer2 - > Add ( itemFlexGridSizer3 , 0 , wxGROW | wxALL , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText4 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Skin " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-11-06 13:45:50 +00:00
itemStaticText4 - > SetFont ( wxFont ( LARGE_FONT , wxSWISS , wxNORMAL , wxBOLD , false , _T ( " Arial " ) ) ) ;
2006-10-27 10:26:56 +00:00
itemFlexGridSizer3 - > Add ( itemStaticText4 , 0 , wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
wxBoxSizer * itemBoxSizer5 = new wxBoxSizer ( wxHORIZONTAL ) ;
2006-10-27 23:34:24 +00:00
itemBoxSizer2 - > Add ( itemBoxSizer5 , 0 , wxALIGN_LEFT | wxLEFT | wxBOTTOM , 20 ) ;
2006-10-27 10:26:56 +00:00
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText6 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Skin: " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-11-06 13:45:50 +00:00
itemStaticText6 - > SetFont ( wxFont ( TINY_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-27 10:26:56 +00:00
itemBoxSizer5 - > Add ( itemStaticText6 , 0 , wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT | wxADJUST_MINSIZE , 5 ) ;
2006-10-27 23:34:24 +00:00
wxString * m_SkinSelectorCtrlStrings = NULL ;
2006-12-09 02:35:06 +00:00
m_SkinSelectorCtrl = new wxComboBox ( itemDialog1 , ID_SKINSELECTOR , _T ( " " ) , wxDefaultPosition , wxSize ( - 1 , - 1 ) , 0 , m_SkinSelectorCtrlStrings , wxCB_READONLY ) ;
2006-10-27 10:26:56 +00:00
itemBoxSizer5 - > Add ( m_SkinSelectorCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxLEFT | wxRIGHT , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticLine * itemStaticLine8 = new CTransparentStaticLine ( itemDialog1 , wxID_ANY , wxDefaultPosition , wxSize ( 300 , 1 ) , wxLI_HORIZONTAL | wxNO_BORDER ) ;
2006-10-27 23:34:24 +00:00
itemStaticLine8 - > SetLineColor ( pSkinSimple - > GetStaticLineColor ( ) ) ;
itemBoxSizer2 - > Add ( itemStaticLine8 , 0 , wxALIGN_CENTER_HORIZONTAL | wxLEFT | wxRIGHT , 20 ) ;
wxFlexGridSizer * itemFlexGridSizer9 = new wxFlexGridSizer ( 1 , 1 , 0 , 0 ) ;
itemFlexGridSizer9 - > AddGrowableCol ( 0 ) ;
itemBoxSizer2 - > Add ( itemFlexGridSizer9 , 0 , wxGROW | wxALL , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText10 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Preferences " ) , wxDefaultPosition , wxDefaultSize , wxALIGN_LEFT ) ;
2006-11-06 13:45:50 +00:00
itemStaticText10 - > SetFont ( wxFont ( LARGE_FONT , wxSWISS , wxNORMAL , wxBOLD , false , _T ( " Arial " ) ) ) ;
2006-10-27 23:34:24 +00:00
itemFlexGridSizer9 - > Add ( itemStaticText10 , 0 , wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
wxBoxSizer * itemBoxSizer11 = new wxBoxSizer ( wxVERTICAL ) ;
itemBoxSizer2 - > Add ( itemBoxSizer11 , 0 , wxALIGN_CENTER_HORIZONTAL | wxLEFT , 20 ) ;
wxBoxSizer * itemBoxSizer12 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemBoxSizer11 - > Add ( itemBoxSizer12 , 0 , wxALIGN_LEFT | wxALL , 0 ) ;
2007-01-05 19:46:10 +00:00
m_CustomizePreferencesCtrl = new wxCheckBox ( itemDialog1 , ID_CUSTOMIZEPREFERENCES , wxT ( " " ) , wxDefaultPosition , wxDefaultSize , wxCHK_2STATE ) ;
2006-10-27 23:34:24 +00:00
m_CustomizePreferencesCtrl - > SetValue ( false ) ;
itemBoxSizer12 - > Add ( m_CustomizePreferencesCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2006-11-15 11:32:52 +00:00
CTransparentStaticTextAssociate * itemStaticText14 = new CTransparentStaticTextAssociate (
itemDialog1 ,
wxID_ANY ,
_ ( " I want to customize my preferences for this computer only. " ) ,
wxDefaultPosition ,
wxDefaultSize ,
0
) ;
2006-11-06 13:45:50 +00:00
itemStaticText14 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-29 00:24:26 +00:00
itemStaticText14 - > AssociateWindow ( m_CustomizePreferencesCtrl ) ;
2006-10-28 09:02:46 +00:00
itemBoxSizer12 - > Add ( itemStaticText14 , 0 , wxALIGN_CENTER_VERTICAL | wxRIGHT | wxTOP | wxBOTTOM , 5 ) ;
CTransparentStaticText * itemStaticText15 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Customized Preferences " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-11-06 13:45:50 +00:00
itemStaticText15 - > SetFont ( wxFont ( MEDIUM_FONT , wxSWISS , wxNORMAL , wxBOLD , false , _T ( " Arial " ) ) ) ;
2006-10-28 09:02:46 +00:00
itemBoxSizer11 - > Add ( itemStaticText15 , 0 , wxALIGN_LEFT | wxALL | wxADJUST_MINSIZE , 5 ) ;
2006-10-27 23:34:24 +00:00
wxFlexGridSizer * itemFlexGridSizer15 = new wxFlexGridSizer ( 7 , 2 , 0 , 0 ) ;
itemFlexGridSizer15 - > AddGrowableRow ( 0 ) ;
itemFlexGridSizer15 - > AddGrowableRow ( 1 ) ;
itemFlexGridSizer15 - > AddGrowableRow ( 2 ) ;
itemFlexGridSizer15 - > AddGrowableRow ( 3 ) ;
itemFlexGridSizer15 - > AddGrowableRow ( 4 ) ;
itemFlexGridSizer15 - > AddGrowableRow ( 5 ) ;
itemFlexGridSizer15 - > AddGrowableRow ( 6 ) ;
itemFlexGridSizer15 - > AddGrowableCol ( 0 ) ;
itemFlexGridSizer15 - > AddGrowableCol ( 1 ) ;
2006-10-28 09:02:46 +00:00
itemBoxSizer11 - > Add ( itemFlexGridSizer15 , 0 , wxALIGN_CENTER_HORIZONTAL | wxALL , 0 ) ;
2006-10-27 23:34:24 +00:00
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText16 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Do work only between: " ) , wxDefaultPosition , wxDefaultSize , wxALIGN_RIGHT ) ;
2006-11-06 13:45:50 +00:00
itemStaticText16 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-28 09:02:46 +00:00
itemStaticText16 - > Wrap ( 250 ) ;
2006-10-27 23:34:24 +00:00
itemFlexGridSizer15 - > Add ( itemStaticText16 , 0 , wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
wxBoxSizer * itemBoxSizer17 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemFlexGridSizer15 - > Add ( itemBoxSizer17 , 0 , wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL , 0 ) ;
wxString * m_WorkBetweenBeginCtrlStrings = NULL ;
2006-12-12 01:08:16 +00:00
m_WorkBetweenBeginCtrl = new wxComboBox ( itemDialog1 , ID_WORKBETWEENBEGIN , _T ( " " ) , wxDefaultPosition , wxDefaultSize , 0 , m_WorkBetweenBeginCtrlStrings , wxCB_READONLY ) ;
2006-10-27 23:34:24 +00:00
m_WorkBetweenBeginCtrl - > Enable ( false ) ;
itemBoxSizer17 - > Add ( m_WorkBetweenBeginCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText19 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " and " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-11-06 13:45:50 +00:00
itemStaticText19 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-27 23:34:24 +00:00
itemBoxSizer17 - > Add ( itemStaticText19 , 0 , wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
wxString * m_WorkBetweenEndCtrlStrings = NULL ;
2006-12-12 01:08:16 +00:00
m_WorkBetweenEndCtrl = new wxComboBox ( itemDialog1 , ID_WORKBETWEENEND , _T ( " " ) , wxDefaultPosition , wxDefaultSize , 0 , m_WorkBetweenEndCtrlStrings , wxCB_READONLY ) ;
2006-10-27 23:34:24 +00:00
m_WorkBetweenEndCtrl - > Enable ( false ) ;
itemBoxSizer17 - > Add ( m_WorkBetweenEndCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxRIGHT | wxTOP | wxBOTTOM , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText21 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Connect to internet only between: " ) , wxDefaultPosition , wxDefaultSize , wxALIGN_RIGHT ) ;
2006-11-06 13:45:50 +00:00
itemStaticText21 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-28 09:02:46 +00:00
itemStaticText21 - > Wrap ( 250 ) ;
2006-10-27 23:34:24 +00:00
itemFlexGridSizer15 - > Add ( itemStaticText21 , 0 , wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
wxBoxSizer * itemBoxSizer22 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemFlexGridSizer15 - > Add ( itemBoxSizer22 , 0 , wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL | wxALL , 0 ) ;
wxString * m_ConnectBetweenBeginCtrlStrings = NULL ;
2006-12-12 01:08:16 +00:00
m_ConnectBetweenBeginCtrl = new wxComboBox ( itemDialog1 , ID_CONNECTBETWEENBEGIN , _T ( " " ) , wxDefaultPosition , wxDefaultSize , 0 , m_ConnectBetweenBeginCtrlStrings , wxCB_READONLY ) ;
2006-10-27 23:34:24 +00:00
m_ConnectBetweenBeginCtrl - > Enable ( false ) ;
itemBoxSizer22 - > Add ( m_ConnectBetweenBeginCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText24 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " and " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-11-06 13:45:50 +00:00
itemStaticText24 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-27 23:34:24 +00:00
itemBoxSizer22 - > Add ( itemStaticText24 , 0 , wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
wxString * m_ConnectBetweenEndCtrlStrings = NULL ;
2006-12-12 01:08:16 +00:00
m_ConnectBetweenEndCtrl = new wxComboBox ( itemDialog1 , ID_CONNECTBETWEENEND , _T ( " " ) , wxDefaultPosition , wxDefaultSize , 0 , m_ConnectBetweenEndCtrlStrings , wxCB_READONLY ) ;
2006-10-27 23:34:24 +00:00
m_ConnectBetweenEndCtrl - > Enable ( false ) ;
itemBoxSizer22 - > Add ( m_ConnectBetweenEndCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxRIGHT | wxTOP | wxBOTTOM , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText26 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Use no more than: " ) , wxDefaultPosition , wxDefaultSize , wxALIGN_RIGHT ) ;
2006-11-06 13:45:50 +00:00
itemStaticText26 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-28 09:02:46 +00:00
itemStaticText26 - > Wrap ( 250 ) ;
2006-10-27 23:34:24 +00:00
itemFlexGridSizer15 - > Add ( itemStaticText26 , 0 , wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
wxBoxSizer * itemBoxSizer27 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemFlexGridSizer15 - > Add ( itemBoxSizer27 , 0 , wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL , 0 ) ;
wxString * m_MaxDiskUsageCtrlStrings = NULL ;
2006-12-09 02:35:06 +00:00
m_MaxDiskUsageCtrl = new wxComboBox ( itemDialog1 , ID_MAXDISKUSAGE , _T ( " " ) , wxDefaultPosition , wxSize ( - 1 , - 1 ) , 0 , m_MaxDiskUsageCtrlStrings , wxCB_READONLY ) ;
2006-10-27 23:34:24 +00:00
m_MaxDiskUsageCtrl - > Enable ( false ) ;
itemBoxSizer27 - > Add ( m_MaxDiskUsageCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText29 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " of disk space " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-11-06 13:45:50 +00:00
itemStaticText29 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-27 23:34:24 +00:00
itemBoxSizer27 - > Add ( itemStaticText29 , 0 , wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText30 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Use no more than: " ) , wxDefaultPosition , wxDefaultSize , wxALIGN_RIGHT ) ;
2006-11-06 13:45:50 +00:00
itemStaticText30 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-28 09:02:46 +00:00
itemStaticText30 - > Wrap ( 250 ) ;
2006-10-27 23:34:24 +00:00
itemFlexGridSizer15 - > Add ( itemStaticText30 , 0 , wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-10-27 23:34:24 +00:00
wxBoxSizer * itemBoxSizer31 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemFlexGridSizer15 - > Add ( itemBoxSizer31 , 0 , wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL , 0 ) ;
2006-10-27 10:26:56 +00:00
2006-10-27 23:34:24 +00:00
wxString * m_MaxCPUUsageCtrlStrings = NULL ;
2006-12-12 01:08:16 +00:00
m_MaxCPUUsageCtrl = new wxComboBox ( itemDialog1 , ID_MAXCPUUSAGE , _T ( " " ) , wxDefaultPosition , wxDefaultSize , 0 , m_MaxCPUUsageCtrlStrings , wxCB_READONLY ) ;
2006-10-27 23:34:24 +00:00
m_MaxCPUUsageCtrl - > Enable ( false ) ;
itemBoxSizer31 - > Add ( m_MaxCPUUsageCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText33 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " of the processor " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-11-06 13:45:50 +00:00
itemStaticText33 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-27 23:34:24 +00:00
itemBoxSizer31 - > Add ( itemStaticText33 , 0 , wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText37 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Do work while on battery? " ) , wxDefaultPosition , wxDefaultSize , wxALIGN_RIGHT ) ;
2006-11-06 13:45:50 +00:00
itemStaticText37 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-28 09:02:46 +00:00
itemStaticText37 - > Wrap ( 250 ) ;
2006-10-27 23:34:24 +00:00
itemFlexGridSizer15 - > Add ( itemStaticText37 , 0 , wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-10-27 23:34:24 +00:00
wxBoxSizer * itemBoxSizer38 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemFlexGridSizer15 - > Add ( itemBoxSizer38 , 0 , wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL , 0 ) ;
2006-10-27 10:26:56 +00:00
m_WorkWhileOnBatteryCtrl = new wxCheckBox ( itemDialog1 , ID_WORKWHILEONBATTERY , _T ( " " ) , wxDefaultPosition , wxDefaultSize , wxCHK_2STATE ) ;
2006-10-27 23:34:24 +00:00
m_WorkWhileOnBatteryCtrl - > SetValue ( false ) ;
m_WorkWhileOnBatteryCtrl - > Enable ( false ) ;
itemBoxSizer38 - > Add ( m_WorkWhileOnBatteryCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText40 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " Do work after idle for: " ) , wxDefaultPosition , wxDefaultSize , wxALIGN_RIGHT ) ;
2006-11-06 13:45:50 +00:00
itemStaticText40 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-28 09:02:46 +00:00
itemStaticText40 - > Wrap ( 250 ) ;
2006-10-27 23:34:24 +00:00
itemFlexGridSizer15 - > Add ( itemStaticText40 , 0 , wxALIGN_RIGHT | wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-10-27 23:34:24 +00:00
wxBoxSizer * itemBoxSizer41 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemFlexGridSizer15 - > Add ( itemBoxSizer41 , 0 , wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL , 0 ) ;
2006-10-27 10:26:56 +00:00
2006-10-27 23:34:24 +00:00
wxString * m_WorkWhenIdleCtrlStrings = NULL ;
2006-12-09 02:35:06 +00:00
m_WorkWhenIdleCtrl = new wxComboBox ( itemDialog1 , ID_WORKWHENIDLE , _T ( " " ) , wxDefaultPosition , wxSize ( - 1 , - 1 ) , 0 , m_WorkWhenIdleCtrlStrings , wxCB_READONLY ) ;
2006-10-27 23:34:24 +00:00
m_WorkWhenIdleCtrl - > Enable ( false ) ;
itemBoxSizer41 - > Add ( m_WorkWhenIdleCtrl , 0 , wxALIGN_CENTER_VERTICAL | wxTOP | wxBOTTOM , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-10-28 09:02:46 +00:00
CTransparentStaticText * itemStaticText43 = new CTransparentStaticText ( itemDialog1 , wxID_ANY , _ ( " minutes " ) , wxDefaultPosition , wxDefaultSize , 0 ) ;
2006-11-06 13:45:50 +00:00
itemStaticText43 - > SetFont ( wxFont ( SMALL_FONT , wxSWISS , wxNORMAL , wxNORMAL , false , _T ( " Arial " ) ) ) ;
2006-10-27 23:34:24 +00:00
itemBoxSizer41 - > Add ( itemStaticText43 , 0 , wxALIGN_CENTER_VERTICAL | wxALL | wxADJUST_MINSIZE , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-10-27 23:34:24 +00:00
wxBoxSizer * itemBoxSizer44 = new wxBoxSizer ( wxHORIZONTAL ) ;
itemBoxSizer2 - > Add ( itemBoxSizer44 , 0 , wxALIGN_RIGHT | wxALL , 5 ) ;
2006-10-27 10:26:56 +00:00
2007-01-05 23:31:38 +00:00
wxBitmapButton * itemBitmapButton44 = new wxBitmapButton (
itemDialog1 ,
wxID_OK ,
* pSkinSimple - > GetSaveButton ( ) - > GetBitmap ( ) ,
wxDefaultPosition ,
wxSize (
( * pSkinSimple - > GetSaveButton ( ) - > GetBitmap ( ) ) . GetWidth ( ) ,
( * pSkinSimple - > GetSaveButton ( ) - > GetBitmap ( ) ) . GetHeight ( )
) ,
wxBU_AUTODRAW
) ;
2006-10-31 16:35:21 +00:00
if ( pSkinSimple - > GetSaveButton ( ) - > GetBitmapClicked ( ) ! = NULL ) {
itemBitmapButton44 - > SetBitmapSelected ( * pSkinSimple - > GetSaveButton ( ) - > GetBitmapClicked ( ) ) ;
}
2006-10-27 23:34:24 +00:00
itemBoxSizer44 - > Add ( itemBitmapButton44 , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2006-10-27 10:26:56 +00:00
2007-01-05 23:31:38 +00:00
wxBitmapButton * itemBitmapButton45 = new wxBitmapButton (
itemDialog1 ,
wxID_CANCEL ,
* pSkinSimple - > GetCancelButton ( ) - > GetBitmap ( ) ,
wxDefaultPosition ,
wxSize (
( * pSkinSimple - > GetCancelButton ( ) - > GetBitmap ( ) ) . GetWidth ( ) ,
( * pSkinSimple - > GetCancelButton ( ) - > GetBitmap ( ) ) . GetHeight ( )
) ,
wxBU_AUTODRAW
) ;
2006-10-31 16:35:21 +00:00
if ( pSkinSimple - > GetCancelButton ( ) - > GetBitmapClicked ( ) ! = NULL ) {
itemBitmapButton45 - > SetBitmapSelected ( * pSkinSimple - > GetCancelButton ( ) - > GetBitmapClicked ( ) ) ;
}
2006-10-27 23:34:24 +00:00
itemBoxSizer44 - > Add ( itemBitmapButton45 , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2006-10-27 10:26:56 +00:00
2006-12-22 04:25:36 +00:00
# ifndef __WXMSW__
2007-01-06 05:14:26 +00:00
# ifdef __WXMAC__
wxBitmapButton * itemButton46 = new wxBitmapButton (
this ,
ID_SIMPLE_HELP ,
* pSkinSimple - > GetHelpButton ( ) - > GetBitmap ( ) ,
wxDefaultPosition ,
wxSize (
( * pSkinSimple - > GetHelpButton ( ) - > GetBitmap ( ) ) . GetWidth ( ) ,
( * pSkinSimple - > GetHelpButton ( ) - > GetBitmap ( ) ) . GetHeight ( )
) ,
wxBU_AUTODRAW
) ;
if ( pSkinSimple - > GetHelpButton ( ) - > GetBitmapClicked ( ) ! = NULL ) {
itemButton46 - > SetBitmapSelected ( * pSkinSimple - > GetHelpButton ( ) - > GetBitmapClicked ( ) ) ;
}
# ifdef wxUSE_TOOLTIPS
2007-01-06 05:46:26 +00:00
itemButton46 - > SetToolTip ( new wxToolTip ( _ ( " Get help with BOINC " ) ) ) ;
2007-01-06 05:14:26 +00:00
# endif
2007-01-06 05:46:26 +00:00
itemBoxSizer44 - > Add ( itemButton46 , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2007-01-06 05:14:26 +00:00
# else
wxContextHelpButton * itemButton45 = new wxContextHelpButton ( this ) ;
2007-01-06 05:46:26 +00:00
itemBoxSizer44 - > Add ( itemButton45 , 0 , wxALIGN_CENTER_VERTICAL | wxALL , 5 ) ;
2007-01-06 05:14:26 +00:00
# endif
2006-12-22 04:25:36 +00:00
# endif
2006-10-27 10:26:56 +00:00
// Set validators
2006-10-27 23:34:24 +00:00
m_SkinSelectorCtrl - > SetValidator ( wxGenericValidator ( & m_strSkinSelector ) ) ;
m_CustomizePreferencesCtrl - > SetValidator ( wxGenericValidator ( & m_bCustomizedPreferences ) ) ;
m_WorkBetweenBeginCtrl - > SetValidator ( wxGenericValidator ( & m_strWorkBetweenBegin ) ) ;
m_WorkBetweenEndCtrl - > SetValidator ( wxGenericValidator ( & m_strWorkBetweenEnd ) ) ;
m_ConnectBetweenBeginCtrl - > SetValidator ( wxGenericValidator ( & m_strConnectBetweenBegin ) ) ;
m_ConnectBetweenEndCtrl - > SetValidator ( wxGenericValidator ( & m_strConnectBetweenEnd ) ) ;
m_MaxDiskUsageCtrl - > SetValidator ( wxGenericValidator ( & m_strMaxDiskUsage ) ) ;
m_MaxCPUUsageCtrl - > SetValidator ( wxGenericValidator ( & m_strMaxCPUUsage ) ) ;
m_WorkWhileOnBatteryCtrl - > SetValidator ( wxGenericValidator ( & m_bWorkWhileOnBattery ) ) ;
m_WorkWhenIdleCtrl - > SetValidator ( wxGenericValidator ( & m_strWorkWhenIdle ) ) ;
2006-11-06 13:45:50 +00:00
////@end CPanelPreferences content construction
2006-07-05 21:36:56 +00:00
}
2006-10-27 10:26:56 +00:00
/*!
2006-10-27 23:34:24 +00:00
* wxEVT_COMMAND_CHECKBOX_CLICKED event handler for ID_CUSTOMIZEPREFERENCES
2006-10-27 10:26:56 +00:00
*/
2006-10-25 14:09:47 +00:00
2006-11-15 11:32:52 +00:00
void CPanelPreferences : : OnCustomizePreferencesClick ( wxCommandEvent & /*event*/ ) {
UpdateControlStates ( ) ;
}
/*!
* wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_WORKBETWEENBEGIN
*/
void CPanelPreferences : : OnWorkBetweenBeginSelected ( wxCommandEvent & /*event*/ ) {
UpdateControlStates ( ) ;
}
/*!
* wxEVT_COMMAND_COMBOBOX_SELECTED event handler for ID_CONNECTBETWEENBEGIN
*/
void CPanelPreferences : : OnConnectBetweenBeginSelected ( wxCommandEvent & /*event*/ ) {
UpdateControlStates ( ) ;
2006-10-27 10:26:56 +00:00
}
2006-10-25 14:09:47 +00:00
2007-01-06 05:14:26 +00:00
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for ID_SIMPLE_HELP
*/
void CPanelPreferences : : OnButtonHelp ( wxCommandEvent & WXUNUSED ( event ) ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CPanelPreferences::OnHelp - Function Begin " ) ) ;
std : : string url ;
url = wxGetApp ( ) . GetSkinManager ( ) - > GetAdvanced ( ) - > GetCompanyWebsite ( ) . mb_str ( ) ;
canonicalize_master_url ( url ) ;
wxString wxurl ;
wxurl . Printf ( wxT ( " %smanager_links.php?target=simple " ) , url . c_str ( ) ) ;
wxHyperLink : : ExecuteLink ( wxurl ) ;
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CPanelPreferences::OnHelp - Function End " ) ) ;
}
2006-10-27 10:26:56 +00:00
/*!
* wxEVT_ERASE_BACKGROUND event handler for ID_DLGPREFERENCES
*/
2006-11-06 13:45:50 +00:00
void CPanelPreferences : : OnEraseBackground ( wxEraseEvent & event ) {
2006-10-27 10:26:56 +00:00
CSkinSimple * pSkinSimple = wxGetApp ( ) . GetSkinManager ( ) - > GetSimple ( ) ;
2006-10-23 06:48:48 +00:00
wxASSERT ( pSkinSimple ) ;
wxASSERT ( wxDynamicCast ( pSkinSimple , CSkinSimple ) ) ;
2006-10-29 11:44:38 +00:00
wxMemoryDC memDC ;
wxCoord w , h , x , y ;
2006-10-31 06:43:37 +00:00
// Get the desired background bitmap
2006-11-14 10:12:24 +00:00
wxBitmap bmp ( * pSkinSimple - > GetDialogBackgroundImage ( ) - > GetBitmap ( ) ) ;
2006-10-31 06:43:37 +00:00
// Dialog dimensions
wxSize sz = GetClientSize ( ) ;
// Create a buffered device context to reduce flicker
wxBufferedDC dc ( event . GetDC ( ) , sz , wxBUFFER_CLIENT_AREA ) ;
// bitmap dimensions
w = bmp . GetWidth ( ) ;
h = bmp . GetHeight ( ) ;
2006-10-27 23:34:24 +00:00
// Fill the dialog with a magenta color so people can detect when something
// is wrong
2006-10-31 06:43:37 +00:00
dc . SetBrush ( wxBrush ( wxColour ( 255 , 0 , 255 ) ) ) ;
dc . SetPen ( wxPen ( wxColour ( 255 , 0 , 255 ) ) ) ;
dc . DrawRectangle ( 0 , 0 , sz . GetWidth ( ) , sz . GetHeight ( ) ) ;
2006-10-27 23:34:24 +00:00
2006-10-29 11:44:38 +00:00
// Is the bitmap smaller than the window?
if ( ( w < sz . x ) | | ( h < sz . y ) ) {
2006-10-31 18:53:05 +00:00
// Check to see if they need to be rescaled to fit in the window
wxImage img = bmp . ConvertToImage ( ) ;
img . Rescale ( ( int ) sz . x , ( int ) sz . y ) ;
2006-10-29 11:44:38 +00:00
// Draw our cool background (centered)
2006-10-31 18:53:05 +00:00
dc . DrawBitmap ( wxBitmap ( img ) , 0 , 0 ) ;
2006-10-29 11:44:38 +00:00
} else {
// Snag the center of the bitmap and use it
// for the background image
x = wxMax ( 0 , ( w - sz . x ) / 2 ) ;
y = wxMax ( 0 , ( h - sz . y ) / 2 ) ;
// Select the desired bitmap into the memory DC so we can take
// the center chunk of it.
memDC . SelectObject ( bmp ) ;
// Draw the center chunk on the window
2006-10-31 06:43:37 +00:00
dc . Blit ( 0 , 0 , w , h , & memDC , x , y , wxCOPY ) ;
2006-10-29 11:44:38 +00:00
// Drop the bitmap
memDC . SelectObject ( wxNullBitmap ) ;
}
2006-07-05 21:36:56 +00:00
}
2006-09-15 20:15:44 +00:00
2006-10-25 14:09:47 +00:00
2006-11-06 13:45:50 +00:00
void CPanelPreferences : : OnOK ( ) {
2006-11-16 23:32:48 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
2006-11-06 13:45:50 +00:00
TransferDataFromWindow ( ) ;
2006-11-16 23:32:48 +00:00
SaveSkinSettings ( ) ;
2006-11-06 13:45:50 +00:00
if ( m_bCustomizedPreferences ) {
SavePreferenceSettings ( ) ;
} else {
ClearPreferenceSettings ( ) ;
}
2006-11-16 23:32:48 +00:00
pDoc - > rpc . set_global_prefs_override_struct ( global_preferences_override , global_preferences_mask ) ;
pDoc - > rpc . read_global_prefs_override ( ) ;
2006-11-06 13:45:50 +00:00
}
2006-11-15 11:32:52 +00:00
bool CPanelPreferences : : UpdateControlStates ( ) {
if ( m_CustomizePreferencesCtrl - > IsChecked ( ) ) {
2006-10-27 23:34:24 +00:00
m_WorkBetweenBeginCtrl - > Enable ( ) ;
m_WorkBetweenEndCtrl - > Enable ( ) ;
m_ConnectBetweenBeginCtrl - > Enable ( ) ;
m_ConnectBetweenEndCtrl - > Enable ( ) ;
m_MaxDiskUsageCtrl - > Enable ( ) ;
m_MaxCPUUsageCtrl - > Enable ( ) ;
m_WorkWhileOnBatteryCtrl - > Enable ( ) ;
m_WorkWhenIdleCtrl - > Enable ( ) ;
2006-11-15 11:32:52 +00:00
if ( m_WorkBetweenBeginCtrl - > GetValue ( ) = = _ ( " Anytime " ) ) {
m_WorkBetweenEndCtrl - > Disable ( ) ;
}
if ( m_ConnectBetweenBeginCtrl - > GetValue ( ) = = _ ( " Anytime " ) ) {
m_ConnectBetweenEndCtrl - > Disable ( ) ;
}
2006-10-27 23:34:24 +00:00
} else {
m_WorkBetweenBeginCtrl - > Disable ( ) ;
m_WorkBetweenEndCtrl - > Disable ( ) ;
m_ConnectBetweenBeginCtrl - > Disable ( ) ;
m_ConnectBetweenEndCtrl - > Disable ( ) ;
m_MaxDiskUsageCtrl - > Disable ( ) ;
m_MaxCPUUsageCtrl - > Disable ( ) ;
m_WorkWhileOnBatteryCtrl - > Disable ( ) ;
m_WorkWhenIdleCtrl - > Disable ( ) ;
}
return true ;
}
2006-11-06 13:45:50 +00:00
bool CPanelPreferences : : ClearPreferenceSettings ( ) {
2006-11-16 23:32:48 +00:00
global_preferences_mask . start_hour = false ;
global_preferences_mask . end_hour = false ;
global_preferences_mask . net_start_hour = false ;
global_preferences_mask . net_end_hour = false ;
global_preferences_mask . disk_max_used_gb = false ;
global_preferences_mask . cpu_usage_limit = false ;
global_preferences_mask . run_if_user_active = false ;
global_preferences_mask . run_on_batteries = false ;
global_preferences_mask . idle_time_to_run = false ;
2006-10-27 10:26:56 +00:00
return true ;
}
2006-11-06 13:45:50 +00:00
bool CPanelPreferences : : ReadPreferenceSettings ( ) {
2006-10-27 10:26:56 +00:00
CMainDocument * pDoc = wxGetApp ( ) . GetDocument ( ) ;
2006-11-07 09:10:21 +00:00
GLOBAL_PREFS display_global_preferences ;
2006-11-07 01:22:28 +00:00
double dTempValue1 = 0.0 ;
double dTempValue2 = 0.0 ;
2006-11-27 03:53:43 +00:00
int retval ;
unsigned int i ;
2006-10-27 10:26:56 +00:00
wxASSERT ( pDoc ) ;
wxASSERT ( wxDynamicCast ( pDoc , CMainDocument ) ) ;
// Populate values and arrays from preferences
2006-11-27 03:53:43 +00:00
global_preferences_override = pDoc - > state . global_prefs ;
retval = pDoc - > rpc . get_global_prefs_override_struct ( global_preferences_override , global_preferences_mask ) ;
if ( ! retval & & global_preferences_mask . are_simple_prefs_set ( ) ) {
2006-10-27 23:34:24 +00:00
m_bCustomizedPreferences = true ;
2006-10-27 10:26:56 +00:00
} else {
2006-10-27 23:34:24 +00:00
m_bCustomizedPreferences = false ;
2006-10-27 10:26:56 +00:00
}
2006-11-27 03:53:43 +00:00
// Allow this structure to be modified for display purposes
display_global_preferences = global_preferences_override ;
2006-10-27 10:26:56 +00:00
// Do work only between:
// Start:
2006-11-15 11:32:52 +00:00
wxArrayString aWorkBetweenBegin = wxArrayString ( iTimeOfDayArraySize , astrTimeOfDayStrings ) ;
aWorkBetweenBegin . Insert ( _ ( " Anytime " ) , 0 ) ;
m_WorkBetweenBeginCtrl - > Append ( aWorkBetweenBegin ) ;
2007-03-15 23:39:22 +00:00
if ( display_global_preferences . time_prefs . start_hour = = display_global_preferences . time_prefs . end_hour ) {
2006-11-15 11:32:52 +00:00
m_strWorkBetweenBegin = _ ( " Anytime " ) ;
} else {
2007-03-15 23:39:22 +00:00
m_strWorkBetweenBegin = astrTimeOfDayStrings [ display_global_preferences . time_prefs . start_hour ] ;
2006-11-15 11:32:52 +00:00
}
2006-10-27 10:26:56 +00:00
// End:
m_WorkBetweenEndCtrl - > Append ( wxArrayString ( iTimeOfDayArraySize , astrTimeOfDayStrings ) ) ;
2007-03-15 23:39:22 +00:00
m_strWorkBetweenEnd = astrTimeOfDayStrings [ display_global_preferences . time_prefs . end_hour ] ;
2006-10-27 10:26:56 +00:00
// Connect to internet only between:
// Start:
2006-11-15 11:32:52 +00:00
wxArrayString aConnectBetweenBegin = wxArrayString ( iTimeOfDayArraySize , astrTimeOfDayStrings ) ;
aConnectBetweenBegin . Insert ( _ ( " Anytime " ) , 0 ) ;
m_ConnectBetweenBeginCtrl - > Append ( aConnectBetweenBegin ) ;
2007-03-15 23:39:22 +00:00
if ( display_global_preferences . time_prefs . net_start_hour = = display_global_preferences . time_prefs . net_end_hour ) {
2006-11-15 11:32:52 +00:00
m_strConnectBetweenBegin = _ ( " Anytime " ) ;
} else {
2007-03-15 23:39:22 +00:00
m_strConnectBetweenBegin = astrTimeOfDayStrings [ display_global_preferences . time_prefs . net_start_hour ] ;
2006-11-15 11:32:52 +00:00
}
2006-10-27 10:26:56 +00:00
// End:
m_ConnectBetweenEndCtrl - > Append ( wxArrayString ( iTimeOfDayArraySize , astrTimeOfDayStrings ) ) ;
2007-03-15 23:39:22 +00:00
m_strConnectBetweenEnd = astrTimeOfDayStrings [ display_global_preferences . time_prefs . net_end_hour ] ;
2006-10-27 10:26:56 +00:00
// Use no more than %s of disk space
wxArrayString aDiskUsage = wxArrayString ( iDiskUsageArraySize , astrDiskUsageStrings ) ;
wxString strDiskUsage = wxEmptyString ;
int iDiskUsageIndex = iDiskUsageArraySize ;
2006-11-07 09:10:21 +00:00
if ( display_global_preferences . disk_max_used_gb > 0 ) {
if ( display_global_preferences . disk_max_used_gb < 1 ) {
strDiskUsage . Printf ( _ ( " %d MB " ) , ( int ) ( display_global_preferences . disk_max_used_gb * 1000 ) ) ;
2006-10-27 10:26:56 +00:00
} else {
2006-11-07 09:10:21 +00:00
strDiskUsage . Printf ( _ ( " %4.2f GB " ) , display_global_preferences . disk_max_used_gb ) ;
2006-10-27 10:26:56 +00:00
}
// Null out strDiskUsage if it is a duplicate
for ( i = 0 ; i < aDiskUsage . Count ( ) ; i + + ) {
2006-11-07 01:22:28 +00:00
strDiskUsage . ToDouble ( & dTempValue1 ) ;
if ( strDiskUsage . Find ( wxT ( " MB " ) ) ! = - 1 ) {
dTempValue1 / = 1000 ;
}
aDiskUsage [ i ] . ToDouble ( & dTempValue2 ) ;
if ( aDiskUsage [ i ] . Find ( wxT ( " MB " ) ) ! = - 1 ) {
dTempValue2 / = 1000 ;
}
if ( ( strDiskUsage = = aDiskUsage [ i ] ) | | ( dTempValue1 = = dTempValue2 ) ) {
2006-10-27 10:26:56 +00:00
strDiskUsage = wxEmptyString ;
2006-11-07 01:22:28 +00:00
// Store this value so we know what to set the selection too in the
// combo box.
2006-10-27 10:26:56 +00:00
iDiskUsageIndex = i ;
break ;
2006-10-25 14:09:47 +00:00
}
2006-10-27 10:26:56 +00:00
}
2006-10-25 14:09:47 +00:00
}
2006-10-27 10:26:56 +00:00
if ( ! strDiskUsage . IsEmpty ( ) ) {
aDiskUsage . Add ( strDiskUsage ) ;
aDiskUsage . Sort ( CompareDiskUsage ) ;
}
2006-10-25 14:09:47 +00:00
2006-10-27 10:26:56 +00:00
m_MaxDiskUsageCtrl - > Append ( aDiskUsage ) ;
if ( ! strDiskUsage . IsEmpty ( ) ) {
m_strMaxDiskUsage = strDiskUsage ;
} else {
m_strMaxDiskUsage = astrDiskUsageStrings [ iDiskUsageIndex ] ;
}
2006-10-23 06:48:48 +00:00
2006-10-27 10:26:56 +00:00
// Use no more than %s of the processor
wxArrayString aCPUUsage = wxArrayString ( iCPUUsageArraySize , astrCPUUsageStrings ) ;
wxString strCPUUsage = wxEmptyString ;
int iCPUUsageIndex = iCPUUsageArraySize - 4 ;
2006-11-07 09:10:21 +00:00
if ( display_global_preferences . cpu_usage_limit > 0 ) {
strCPUUsage . Printf ( _ ( " %d%% " ) , ( int ) display_global_preferences . cpu_usage_limit ) ;
2006-10-27 10:26:56 +00:00
// Null out strCPUUsage if it is a duplicate
for ( i = 0 ; i < aCPUUsage . Count ( ) ; i + + ) {
2006-11-07 01:22:28 +00:00
strCPUUsage . ToDouble ( & dTempValue1 ) ;
aCPUUsage [ i ] . ToDouble ( & dTempValue2 ) ;
if ( ( strCPUUsage = = aCPUUsage [ i ] ) | | ( dTempValue1 = = dTempValue2 ) ) {
2006-10-27 10:26:56 +00:00
strCPUUsage = wxEmptyString ;
2006-11-07 01:22:28 +00:00
// Store this value so we know what to set the selection too in the
// combo box.
2006-10-27 10:26:56 +00:00
iCPUUsageIndex = i ;
break ;
}
}
}
2006-10-23 06:48:48 +00:00
2006-10-27 10:26:56 +00:00
if ( ! strCPUUsage . IsEmpty ( ) ) {
aCPUUsage . Add ( strCPUUsage ) ;
aCPUUsage . Sort ( CompareCPUUsage ) ;
}
m_MaxCPUUsageCtrl - > Append ( aCPUUsage ) ;
if ( ! strCPUUsage . IsEmpty ( ) ) {
m_strMaxCPUUsage = strCPUUsage ;
} else {
m_strMaxCPUUsage = astrCPUUsageStrings [ iCPUUsageIndex ] ;
}
// Do work while computer is on battery?
2006-11-07 09:10:21 +00:00
m_bWorkWhileOnBattery = display_global_preferences . run_on_batteries ;
2006-10-27 10:26:56 +00:00
// Do work after computer is idle for:
wxArrayString aWorkWhenIdle = wxArrayString ( iWorkWhenIdleArraySize , astrWorkWhenIdleStrings ) ;
wxString strWorkWhenIdle = wxEmptyString ;
int iWorkWhenIdleIndex = 2 ;
2006-12-08 04:23:02 +00:00
aWorkWhenIdle . Insert ( _ ( " 0 (Run Always) " ) , 0 ) ;
if ( display_global_preferences . idle_time_to_run > 0 ) {
2006-11-07 09:10:21 +00:00
strWorkWhenIdle . Printf ( _ ( " %d " ) , ( int ) display_global_preferences . idle_time_to_run ) ;
2006-10-27 10:26:56 +00:00
// Null out strWorkWhenIdle if it is a duplicate
for ( i = 0 ; i < aWorkWhenIdle . Count ( ) ; i + + ) {
2006-11-07 01:22:28 +00:00
strWorkWhenIdle . ToDouble ( & dTempValue1 ) ;
aWorkWhenIdle [ i ] . ToDouble ( & dTempValue2 ) ;
if ( ( strWorkWhenIdle = = aWorkWhenIdle [ i ] ) | | ( dTempValue1 = = dTempValue2 ) ) {
2006-10-27 10:26:56 +00:00
strWorkWhenIdle = wxEmptyString ;
2006-11-07 01:22:28 +00:00
// Store this value so we know what to set the selection too in the
// combo box.
2006-10-27 10:26:56 +00:00
iWorkWhenIdleIndex = i ;
break ;
}
}
}
if ( ! strWorkWhenIdle . IsEmpty ( ) ) {
aWorkWhenIdle . Add ( strWorkWhenIdle ) ;
aWorkWhenIdle . Sort ( CompareWorkWhenIdle ) ;
}
m_WorkWhenIdleCtrl - > Append ( aWorkWhenIdle ) ;
2006-12-08 04:23:02 +00:00
if ( display_global_preferences . run_if_user_active ) {
// run_if_user_active and idle_time_to_run were merged into a single combo
// box. 0 = run if active.
m_strWorkWhenIdle = aWorkWhenIdle [ 0 ] ;
} else {
if ( strWorkWhenIdle . IsEmpty ( ) ) {
m_strWorkWhenIdle = aWorkWhenIdle [ iWorkWhenIdleIndex ] ;
} else {
m_strWorkWhenIdle = strWorkWhenIdle ;
}
}
2006-10-27 10:26:56 +00:00
2006-10-27 23:34:24 +00:00
// Now make sure the UI is in sync with the settings
2006-11-15 11:32:52 +00:00
TransferDataToWindow ( ) ;
UpdateControlStates ( ) ;
2006-10-27 23:34:24 +00:00
2006-10-27 10:26:56 +00:00
return true ;
2006-07-05 21:36:56 +00:00
}
2006-10-25 14:09:47 +00:00
2006-11-06 13:45:50 +00:00
bool CPanelPreferences : : ReadSkinSettings ( ) {
2006-10-25 14:09:47 +00:00
CSkinManager * pSkinManager = wxGetApp ( ) . GetSkinManager ( ) ;
wxASSERT ( pSkinManager ) ;
wxASSERT ( wxDynamicCast ( pSkinManager , CSkinManager ) ) ;
2006-10-27 10:26:56 +00:00
// Setup the values for all the skins, and then set the default.
m_SkinSelectorCtrl - > Append ( pSkinManager - > GetCurrentSkins ( ) ) ;
m_SkinSelectorCtrl - > SetValue ( pSkinManager - > GetSelectedSkin ( ) ) ;
2006-10-25 14:09:47 +00:00
2006-10-27 10:26:56 +00:00
return true ;
2006-08-17 17:36:51 +00:00
}
2006-10-25 14:09:47 +00:00
2006-08-17 17:36:51 +00:00
2006-11-06 13:45:50 +00:00
bool CPanelPreferences : : SavePreferenceSettings ( ) {
2006-10-27 10:26:56 +00:00
// Do work only between:
2006-11-15 11:32:52 +00:00
if ( _ ( " Anytime " ) = = m_strWorkBetweenBegin ) {
2007-03-15 23:39:22 +00:00
global_preferences_override . time_prefs . start_hour = 0 ;
global_preferences_override . time_prefs . end_hour = 0 ;
2006-11-15 11:32:52 +00:00
} else {
2007-03-15 23:39:22 +00:00
m_strWorkBetweenBegin . ToLong ( ( long * ) & global_preferences_override . time_prefs . start_hour ) ;
m_strWorkBetweenEnd . ToLong ( ( long * ) & global_preferences_override . time_prefs . end_hour ) ;
2006-11-15 11:32:52 +00:00
}
2006-11-07 20:29:20 +00:00
global_preferences_mask . start_hour = true ;
2006-11-15 11:32:52 +00:00
global_preferences_mask . end_hour = true ;
2006-10-27 10:26:56 +00:00
// Connect to internet only between:
2006-11-15 11:32:52 +00:00
if ( _ ( " Anytime " ) = = m_strConnectBetweenBegin ) {
2007-03-15 23:39:22 +00:00
global_preferences_override . time_prefs . net_start_hour = 0 ;
global_preferences_override . time_prefs . net_end_hour = 0 ;
2006-11-15 11:32:52 +00:00
} else {
2007-03-15 23:39:22 +00:00
m_strConnectBetweenBegin . ToLong ( ( long * ) & global_preferences_override . time_prefs . net_start_hour ) ;
m_strConnectBetweenEnd . ToLong ( ( long * ) & global_preferences_override . time_prefs . net_end_hour ) ;
2006-11-15 11:32:52 +00:00
}
2006-11-07 20:29:20 +00:00
global_preferences_mask . net_start_hour = true ;
global_preferences_mask . net_end_hour = true ;
2006-10-27 10:26:56 +00:00
// Use no more than %s of disk space
2006-11-07 20:29:20 +00:00
m_strMaxDiskUsage . ToDouble ( ( double * ) & global_preferences_override . disk_max_used_gb ) ;
2006-11-07 01:22:28 +00:00
if ( m_strMaxDiskUsage . Find ( wxT ( " MB " ) ) ! = - 1 ) {
2006-11-07 20:29:20 +00:00
global_preferences_override . disk_max_used_gb / = 1000 ;
2006-10-27 10:26:56 +00:00
}
2006-11-07 20:29:20 +00:00
global_preferences_mask . disk_max_used_gb = true ;
2006-10-27 10:26:56 +00:00
// Use no more than %s of the processor
2006-11-07 20:29:20 +00:00
m_strMaxCPUUsage . ToDouble ( ( double * ) & global_preferences_override . cpu_usage_limit ) ;
global_preferences_mask . cpu_usage_limit = true ;
2006-10-27 10:26:56 +00:00
// Do work while computer is on battery?
2006-11-07 20:29:20 +00:00
global_preferences_override . run_on_batteries = m_bWorkWhileOnBattery ;
global_preferences_mask . run_on_batteries = true ;
2006-10-27 10:26:56 +00:00
// Do work after computer is idle for:
2006-11-07 20:29:20 +00:00
m_strWorkWhenIdle . ToDouble ( ( double * ) & global_preferences_override . idle_time_to_run ) ;
2006-12-08 04:23:02 +00:00
if ( 0 = = global_preferences_override . idle_time_to_run ) {
global_preferences_override . run_if_user_active = true ;
global_preferences_mask . run_if_user_active = true ;
} else {
global_preferences_mask . idle_time_to_run = true ;
}
2006-10-27 10:26:56 +00:00
return true ;
2006-07-05 21:36:56 +00:00
}
2006-10-25 14:09:47 +00:00
2006-07-05 21:36:56 +00:00
2006-11-06 13:45:50 +00:00
bool CPanelPreferences : : SaveSkinSettings ( ) {
2006-10-27 10:26:56 +00:00
CSkinManager * pSkinManager = wxGetApp ( ) . GetSkinManager ( ) ;
wxLocale * pLocale = wxGetApp ( ) . GetLocale ( ) ;
2006-08-17 17:36:51 +00:00
2006-10-27 10:26:56 +00:00
wxASSERT ( pSkinManager ) ;
wxASSERT ( pLocale ) ;
wxASSERT ( wxDynamicCast ( pSkinManager , CSkinManager ) ) ;
2006-10-25 14:09:47 +00:00
2006-10-27 10:26:56 +00:00
pSkinManager - > ReloadSkin ( pLocale , m_strSkinSelector ) ;
2006-07-05 21:36:56 +00:00
2006-10-27 10:26:56 +00:00
return true ;
2006-08-10 19:32:47 +00:00
}
2006-07-24 22:10:28 +00:00
2006-11-17 06:41:15 +00:00
/*!
* CDlgPreferences type definition
*/
IMPLEMENT_DYNAMIC_CLASS ( CDlgPreferences , wxDialog )
/*!
* CDlgPreferences event table definition
*/
BEGIN_EVENT_TABLE ( CDlgPreferences , wxDialog )
////@begin CDlgPreferences event table entries
2006-12-30 00:50:04 +00:00
EVT_HELP ( wxID_ANY , CDlgPreferences : : OnHelp )
2006-11-17 06:41:15 +00:00
EVT_BUTTON ( wxID_OK , CDlgPreferences : : OnOK )
////@end CDlgPreferences event table entries
END_EVENT_TABLE ( )
/*!
* CDlgPreferences constructors
*/
CDlgPreferences : : CDlgPreferences ( )
{
}
CDlgPreferences : : CDlgPreferences ( wxWindow * parent , wxWindowID id , const wxString & caption , const wxPoint & pos , const wxSize & size , long style )
{
Create ( parent , id , caption , pos , size , style ) ;
}
/*!
* CDlgPreferences creator
*/
bool CDlgPreferences : : Create ( wxWindow * parent , wxWindowID id , const wxString & caption , const wxPoint & pos , const wxSize & size , long style )
{
wxString strCaption = caption ;
if ( strCaption . IsEmpty ( ) ) {
strCaption = _ ( " BOINC Manager - Preferences " ) ;
}
2006-12-22 04:25:36 +00:00
SetExtraStyle ( GetExtraStyle ( ) | wxDIALOG_EX_CONTEXTHELP | wxWS_EX_BLOCK_EVENTS ) ;
wxDialog : : Create ( parent , id , strCaption , pos , size , style ) ;
2006-11-17 06:41:15 +00:00
Freeze ( ) ;
2006-12-22 09:55:46 +00:00
SetForegroundColour ( * wxBLACK ) ;
# ifdef __WXDEBUG__
SetBackgroundColour ( wxColour ( 255 , 0 , 255 ) ) ;
# endif
SetBackgroundStyle ( wxBG_STYLE_CUSTOM ) ;
2006-11-17 06:41:15 +00:00
m_pBackgroundPanel = new CPanelPreferences ( this ) ;
wxBoxSizer * itemBoxSizer = new wxBoxSizer ( wxVERTICAL ) ;
SetSizer ( itemBoxSizer ) ;
itemBoxSizer - > Add ( m_pBackgroundPanel , 0 , wxGROW , 0 ) ;
GetSizer ( ) - > Fit ( this ) ;
GetSizer ( ) - > SetSizeHints ( this ) ;
Centre ( ) ;
Thaw ( ) ;
return true ;
}
2006-12-30 00:50:04 +00:00
/*!
* wxEVT_HELP event handler for ID_DLGPREFERENCES
*/
void CDlgPreferences : : OnHelp ( wxHelpEvent & event ) {
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CDlgPreferences::OnHelp - Function Begin " ) ) ;
if ( IsShown ( ) ) {
std : : string url ;
url = wxGetApp ( ) . GetSkinManager ( ) - > GetAdvanced ( ) - > GetCompanyWebsite ( ) . mb_str ( ) ;
canonicalize_master_url ( url ) ;
wxString wxurl ;
wxurl . Printf ( wxT ( " %smanager_links.php?target=simple_preferences&controlid=%d " ) , url . c_str ( ) , event . GetId ( ) ) ;
wxHyperLink : : ExecuteLink ( wxurl ) ;
}
wxLogTrace ( wxT ( " Function Start/End " ) , wxT ( " CDlgPreferences::OnHelp - Function End " ) ) ;
}
2006-11-17 06:41:15 +00:00
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void CDlgPreferences : : OnOK ( wxCommandEvent & event ) {
2007-01-19 14:30:18 +00:00
# if wxCHECK_VERSION(2,8,0)
// event.skip();
# else
2006-11-17 06:41:15 +00:00
wxDialog : : OnOK ( event ) ;
2007-01-19 14:30:18 +00:00
# endif
2006-11-17 06:41:15 +00:00
m_pBackgroundPanel - > OnOK ( ) ;
EndModal ( wxID_OK ) ;
}