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-08-17 17:36:51 +00:00
|
|
|
#include "BOINCGUIApp.h"
|
2006-07-05 21:36:56 +00:00
|
|
|
#include "sg_DlgPreferences.h"
|
|
|
|
#include "sg_SkinClass.h"
|
2006-09-14 16:02:55 +00:00
|
|
|
#include "sg_StaticLine.h"
|
2006-07-05 21:36:56 +00:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
ID_OPENBUTTON = 10001,
|
|
|
|
ID_SAVEBUTTON = 10002,
|
2006-09-14 16:02:55 +00:00
|
|
|
ID_SAVESKINBUTTON = 10003,
|
|
|
|
ID_CANCELBUTTON = 10004,
|
|
|
|
ID_CLEARBUTTON = 10005,
|
|
|
|
ID_SKINPICKERCMBBOX = 10006,
|
|
|
|
ID_DOWORKONLYBGNCMBBOX = 10007,
|
|
|
|
ID_DOCONNECTONLYBGNCMBBOX = 10008,
|
2006-07-05 21:36:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( CDlgPreferences,wxDialog)
|
2006-08-10 19:32:47 +00:00
|
|
|
EVT_PAINT(CDlgPreferences::OnPaint)
|
2006-07-05 21:36:56 +00:00
|
|
|
EVT_COMBOBOX(-1,CDlgPreferences::OnCmbSelected)
|
|
|
|
EVT_BUTTON(-1,CDlgPreferences::OnBtnClick)
|
|
|
|
EVT_ERASE_BACKGROUND(CDlgPreferences::OnEraseBackground)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
// end events
|
|
|
|
|
|
|
|
CDlgPreferences::CDlgPreferences(wxWindow* parent, wxString dirPref,wxWindowID id,const wxString& title,const wxPoint& pos,const wxSize& size,long style,const wxString& name)
|
|
|
|
{
|
2006-08-10 19:32:47 +00:00
|
|
|
m_SkinDirPrefix = dirPref;
|
|
|
|
m_skinNames.Add(wxT("default"));
|
|
|
|
Create(parent,id,title,pos,size,style,name);
|
2006-07-05 21:36:56 +00:00
|
|
|
|
2006-08-10 19:32:47 +00:00
|
|
|
if((pos==wxDefaultPosition)&&(size==wxDefaultSize)){
|
2006-08-17 17:36:51 +00:00
|
|
|
SetSize(0,0,416,403);
|
2006-08-10 19:32:47 +00:00
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
|
2006-08-10 19:32:47 +00:00
|
|
|
if((pos!=wxDefaultPosition)&&(size==wxDefaultSize)){
|
2006-08-17 17:36:51 +00:00
|
|
|
SetSize(416,403);
|
2006-08-10 19:32:47 +00:00
|
|
|
}
|
2006-08-17 17:36:51 +00:00
|
|
|
//
|
|
|
|
m_PrefIndicator = wxT("");
|
2006-08-10 19:32:47 +00:00
|
|
|
initBefore();
|
|
|
|
// load images from skin file
|
|
|
|
LoadSkinImages();
|
|
|
|
//Create dialog
|
|
|
|
CreateDialog();
|
|
|
|
initAfter();
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
|
|
|
CDlgPreferences::~CDlgPreferences()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-24 22:10:28 +00:00
|
|
|
void CDlgPreferences::CreateDialog()
|
2006-07-05 21:36:56 +00:00
|
|
|
{
|
2006-08-17 17:36:51 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxASSERT(pDoc);
|
2006-08-18 21:45:17 +00:00
|
|
|
|
|
|
|
// populate values from prefs
|
|
|
|
if(pDoc->rpc.get_global_prefs_override_struct(m_prefs) == 0){
|
|
|
|
m_PrefIndicator = wxT("Using local preferences");
|
|
|
|
}else{
|
|
|
|
m_PrefIndicator = wxT("Using global preferences");
|
|
|
|
m_prefs = pDoc->state.global_prefs;
|
|
|
|
}
|
|
|
|
|
2006-07-05 21:36:56 +00:00
|
|
|
SetBackgroundColour(appSkin->GetAppBgCol());
|
2006-09-14 16:02:55 +00:00
|
|
|
|
|
|
|
cmbSkinPicker=new wxComboBox(this,ID_SKINPICKERCMBBOX,wxT(""),wxPoint(206,37),wxSize(140,21),m_skinNames,wxNO_BORDER | wxCB_READONLY);
|
|
|
|
cmbSkinPicker->SetValue(m_SkinName);
|
|
|
|
|
|
|
|
wxToolTip *ttSaveSkin = new wxToolTip(wxT("Change skin"));
|
2006-09-15 16:47:04 +00:00
|
|
|
btnSaveSkin=new wxBitmapButton(this,ID_SAVESKINBUTTON,*btmpSave,wxPoint(187,82),wxSize(57,16),wxNO_BORDER);
|
|
|
|
btnSaveSkin->SetBitmapSelected(*btmpSaveClick);
|
2006-09-14 16:02:55 +00:00
|
|
|
btnSaveSkin->SetToolTip(ttSaveSkin);
|
|
|
|
|
|
|
|
lnMyTop = new CStaticLine(this,wxPoint(16,113),wxSize(378,1));
|
|
|
|
lnMyTop->SetLineColor(appSkin->GetStaticLineCol());
|
|
|
|
|
2006-08-17 17:36:51 +00:00
|
|
|
wxString itmsHourIntervals[]={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")};
|
2006-07-11 23:19:53 +00:00
|
|
|
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbDWBtwnBgn=new wxComboBox(this,ID_DOWORKONLYBGNCMBBOX,wxT(""),wxPoint(206,155),wxSize(75,21),24,itmsHourIntervals,wxNO_BORDER | wxCB_READONLY);
|
2006-08-17 17:36:51 +00:00
|
|
|
//
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbDWBtwnEnd=new wxComboBox(this,-1,wxT(""),wxPoint(307,155),wxSize(75,21),24,itmsHourIntervals,wxNO_BORDER | wxCB_READONLY);
|
2006-08-17 17:36:51 +00:00
|
|
|
//
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbCTIBtwnBgn=new wxComboBox(this,ID_DOCONNECTONLYBGNCMBBOX,wxT(""),wxPoint(206,190),wxSize(75,21),24,itmsHourIntervals,wxNO_BORDER | wxCB_READONLY);
|
2006-08-17 17:36:51 +00:00
|
|
|
//
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbCTIBtwnEnd=new wxComboBox(this,-1,wxT(""),wxPoint(307,190),wxSize(75,21),24,itmsHourIntervals,wxNO_BORDER | wxCB_READONLY);
|
2006-08-17 17:36:51 +00:00
|
|
|
//
|
|
|
|
wxString userValMaxUsed;
|
|
|
|
if(m_prefs.disk_max_used_gb < 1){
|
|
|
|
userValMaxUsed.Printf(_("%d MB"),(int)(0.1*1000));
|
|
|
|
}else{
|
|
|
|
userValMaxUsed.Printf(_("%4.2f GB"),m_prefs.disk_max_used_gb);
|
|
|
|
}
|
2006-08-18 21:45:17 +00:00
|
|
|
wxString itmsUseNoMoreGB[]={wxT("100MB"),wxT("200MB"),wxT("500MB"),wxT("1GB"),wxT("2GB"),wxT("5GB")};
|
|
|
|
int itmUseNoMore = 6;
|
|
|
|
if(!this->CheckIfInArray(itmsUseNoMoreGB,userValMaxUsed,itmUseNoMore)){
|
|
|
|
wxString itmsUseNoMoreGBU[]={wxT("100MB"),wxT("200MB"),wxT("500MB"),wxT("1GB"),wxT("2GB"),wxT("5GB"),userValMaxUsed};
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbUseNoMoreGB=new wxComboBox(this,-1,wxT(""),wxPoint(206,225),wxSize(75,21),itmUseNoMore+1,itmsUseNoMoreGBU,wxNO_BORDER | wxCB_READONLY);
|
2006-08-18 21:45:17 +00:00
|
|
|
}else{
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbUseNoMoreGB=new wxComboBox(this,-1,wxT(""),wxPoint(206,225),wxSize(75,21),itmUseNoMore,itmsUseNoMoreGB,wxNO_BORDER | wxCB_READONLY);
|
2006-08-18 21:45:17 +00:00
|
|
|
}
|
2006-08-17 17:36:51 +00:00
|
|
|
cmbUseNoMoreGB->SetValue(userValMaxUsed);
|
|
|
|
//
|
2006-07-05 21:36:56 +00:00
|
|
|
wxString itmsDWWCInUse[]={wxT("Yes"),wxT("No")};
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbDWWCInUse=new wxComboBox(this,-1,wxT(""),wxPoint(206,260),wxSize(45,21),2,itmsDWWCInUse,wxNO_BORDER | wxCB_READONLY);
|
2006-08-17 17:36:51 +00:00
|
|
|
if(m_prefs.run_if_user_active){
|
|
|
|
cmbDWWCInUse->SetValue(wxT("Yes"));
|
|
|
|
}else{
|
|
|
|
cmbDWWCInUse->SetValue(wxT("No"));
|
|
|
|
}
|
|
|
|
//
|
|
|
|
wxString userValIdleFor;
|
|
|
|
userValIdleFor.Printf(_("%d"),(int)m_prefs.idle_time_to_run);
|
|
|
|
wxString itmsDWACIdleFor[]={wxString("1"),wxString("5"),wxString("10"),wxString("15"),wxString("30"),wxString("60")};
|
2006-08-18 21:45:17 +00:00
|
|
|
int itmIdlCnt = 6;
|
|
|
|
if(!this->CheckIfInArray(itmsDWACIdleFor,userValIdleFor,itmIdlCnt)){
|
|
|
|
wxString itmsDWACIdleForU[]={wxString("1"),wxString("5"),wxString("10"),wxString("15"),wxString("30"),wxString("60"),userValIdleFor};
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbDWACIdleFor=new wxComboBox(this,-1,wxT(""),wxPoint(206,295),wxSize(75,21),itmIdlCnt+1,itmsDWACIdleForU,wxNO_BORDER | wxCB_READONLY);
|
2006-08-18 21:45:17 +00:00
|
|
|
}else{
|
2006-09-14 16:02:55 +00:00
|
|
|
cmbDWACIdleFor=new wxComboBox(this,-1,wxT(""),wxPoint(206,295),wxSize(75,21),itmIdlCnt,itmsDWACIdleFor,wxNO_BORDER | wxCB_READONLY);
|
2006-08-17 17:36:51 +00:00
|
|
|
}
|
|
|
|
cmbDWACIdleFor->SetValue(userValIdleFor);
|
2006-07-05 21:36:56 +00:00
|
|
|
// Btn Save and Cancel
|
2006-09-14 16:02:55 +00:00
|
|
|
wxToolTip *ttSave = new wxToolTip(wxT("Save preferences locally and close window"));
|
2006-09-15 16:47:04 +00:00
|
|
|
btnSave=new wxBitmapButton(this,ID_SAVEBUTTON,*btmpSave,wxPoint(120,340),wxSize(57,16),wxNO_BORDER);
|
|
|
|
btnSave->SetBitmapSelected(*btmpSaveClick);
|
2006-08-10 19:32:47 +00:00
|
|
|
btnSave->SetToolTip(ttSave);
|
|
|
|
|
2006-09-14 16:02:55 +00:00
|
|
|
wxToolTip *ttCancel = new wxToolTip(wxT("Cancel changes and close window"));
|
2006-09-15 16:47:04 +00:00
|
|
|
btnCancel=new wxBitmapButton(this,ID_CANCELBUTTON,*btmpCancel,wxPoint(187,340),wxSize(57,16),wxNO_BORDER);
|
|
|
|
btnCancel->SetBitmapSelected(*btmpCancelClick);
|
2006-08-10 19:32:47 +00:00
|
|
|
btnCancel->SetToolTip(ttCancel);
|
|
|
|
|
2006-09-14 16:02:55 +00:00
|
|
|
wxToolTip *ttClear = new wxToolTip(wxT("Clear local preferences and use preferences from the web"));
|
2006-09-15 16:47:04 +00:00
|
|
|
btnClear=new wxBitmapButton(this,ID_CLEARBUTTON,*btmpClear,wxPoint(254,340),wxSize(57,16),wxNO_BORDER);
|
|
|
|
btnClear->SetBitmapSelected(*btmpClearClick);
|
2006-08-10 19:32:47 +00:00
|
|
|
btnClear->SetToolTip(ttClear);
|
2006-08-17 17:36:51 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
ReadSettings(m_prefs);
|
2006-08-10 19:32:47 +00:00
|
|
|
|
2006-07-05 21:36:56 +00:00
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
void CDlgPreferences::LoadSkinImages(){
|
2006-09-15 16:47:04 +00:00
|
|
|
btmpDlgBg=appSkin->GetDlgPrefBg();
|
|
|
|
btmpSave= appSkin->GetBtnSave();
|
|
|
|
btmpSaveClick= appSkin->GetBtnSaveClick();
|
|
|
|
btmpCancel= appSkin->GetBtnCancel();
|
|
|
|
btmpCancelClick= appSkin->GetBtnCancelClick();
|
|
|
|
btmpClear= appSkin->GetBtnClear();
|
|
|
|
btmpClearClick= appSkin->GetBtnClearClick();
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
2006-09-15 16:47:04 +00:00
|
|
|
void CDlgPreferences::VwXDrawBackImg(wxEraseEvent& event,wxWindow *win,wxBitmap* bitMap,int opz){
|
2006-07-05 21:36:56 +00:00
|
|
|
event.Skip(false);wxDC *dc;
|
|
|
|
dc=event.GetDC();
|
|
|
|
dc->SetBackground(wxBrush(win->GetBackgroundColour(),wxSOLID));
|
|
|
|
dc->Clear();
|
|
|
|
switch (opz) {
|
|
|
|
case 0:{
|
2006-09-15 16:47:04 +00:00
|
|
|
dc->DrawBitmap(*bitMap, 0, 0);
|
2006-07-05 21:36:56 +00:00
|
|
|
break;}
|
|
|
|
case 1:{
|
|
|
|
wxRect rec=win->GetClientRect();
|
2006-09-15 16:47:04 +00:00
|
|
|
rec.SetLeft((rec.GetWidth()-bitMap->GetWidth()) / 2);
|
|
|
|
rec.SetTop ((rec.GetHeight()-bitMap->GetHeight()) / 2);
|
|
|
|
dc->DrawBitmap(*bitMap,rec.GetLeft(),rec.GetTop(),0);
|
2006-07-05 21:36:56 +00:00
|
|
|
break;}
|
|
|
|
case 2:{
|
|
|
|
wxRect rec=win->GetClientRect();
|
2006-09-15 16:47:04 +00:00
|
|
|
for(int y=0;y < rec.GetHeight();y+=bitMap->GetHeight()){
|
|
|
|
for(int x=0;x < rec.GetWidth();x+=bitMap->GetWidth()){
|
|
|
|
dc->DrawBitmap(*bitMap,x,y,0);
|
2006-07-05 21:36:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
void CDlgPreferences::OnEraseBackground(wxEraseEvent& event){
|
|
|
|
wxObject *m_wxWin = event.GetEventObject();
|
2006-09-15 16:47:04 +00:00
|
|
|
if(m_wxWin==this){event.Skip(true);VwXDrawBackImg(event,this,btmpDlgBg,0);VwXEvOnEraseBackground(event) ;return;}
|
2006-07-05 21:36:56 +00:00
|
|
|
event.Skip(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDlgPreferences::OnBtnClick(wxCommandEvent& event){ //init function
|
|
|
|
int btnID = event.GetId();
|
|
|
|
if(btnID==ID_SAVEBUTTON){
|
2006-08-18 21:45:17 +00:00
|
|
|
WriteSettings();
|
2006-07-24 22:10:28 +00:00
|
|
|
EndModal(wxID_OK);
|
2006-09-14 16:02:55 +00:00
|
|
|
} else if(btnID==ID_SAVESKINBUTTON){
|
|
|
|
EndModal(wxID_OK);
|
|
|
|
} else if(btnID==ID_CLEARBUTTON){
|
2006-08-18 21:45:17 +00:00
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
std::string emptyS = "";
|
|
|
|
pDoc->rpc.set_global_prefs_override(emptyS);
|
|
|
|
// possible re read of global prefs to client
|
|
|
|
EndModal(wxID_CANCEL);
|
2006-07-05 21:36:56 +00:00
|
|
|
}else{
|
|
|
|
//wxMessageBox("OnBtnClick - btnCancel");
|
|
|
|
EndModal(wxID_CANCEL);
|
|
|
|
}
|
|
|
|
} //end function
|
|
|
|
|
|
|
|
void CDlgPreferences::OnCmbSelected(wxCommandEvent& event){ //init function
|
|
|
|
int cmbID = event.GetId();
|
|
|
|
if(cmbID==ID_SKINPICKERCMBBOX){
|
|
|
|
m_SkinName = event.GetString();
|
|
|
|
}
|
|
|
|
} //end function
|
|
|
|
|
2006-07-21 08:23:26 +00:00
|
|
|
void CDlgPreferences::VwXEvOnEraseBackground(wxEraseEvent& WXUNUSED(event)){ //init function
|
2006-07-05 21:36:56 +00:00
|
|
|
//[29b]Code event VwX...Don't modify[29b]//
|
|
|
|
//add your code here
|
|
|
|
|
|
|
|
} //end function
|
|
|
|
|
|
|
|
void CDlgPreferences::initBefore(){
|
2006-07-24 22:10:28 +00:00
|
|
|
//get skin class
|
|
|
|
appSkin = SkinClass::Instance();
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
wxString separator = '\\';
|
|
|
|
#else
|
|
|
|
wxString separator = '/';
|
|
|
|
#endif
|
|
|
|
wxString currentDir = wxGetCwd();
|
|
|
|
wxString currentSkinsDir = currentDir + separator +appSkin->GetSkinsFolder();
|
|
|
|
if(wxDir::Exists(currentSkinsDir)) {
|
|
|
|
// get the names of all directories in skins dir
|
|
|
|
DirTraverserSkins skinTraverser(m_skinNames);
|
|
|
|
wxDir skinsDir(currentSkinsDir);
|
|
|
|
skinsDir.Traverse(skinTraverser);
|
|
|
|
}
|
2006-07-26 15:14:01 +00:00
|
|
|
//finally set the name of the current skin
|
|
|
|
m_SkinName = appSkin->GetSkinName();
|
2006-08-17 17:36:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CDlgPreferences::CheckIfInArray(wxString valArray[],wxString value,int size){
|
|
|
|
|
|
|
|
for(int x=0; x<size; x++){
|
2006-08-18 21:45:17 +00:00
|
|
|
wxString val = valArray[x];
|
|
|
|
if(valArray[x] == value){
|
|
|
|
return true;
|
|
|
|
break;
|
|
|
|
}
|
2006-08-17 17:36:51 +00:00
|
|
|
}
|
2006-08-18 21:45:17 +00:00
|
|
|
return false;
|
2006-08-17 17:36:51 +00:00
|
|
|
}
|
2006-08-18 21:45:17 +00:00
|
|
|
void CDlgPreferences::WriteSettings(){
|
2006-08-17 17:36:51 +00:00
|
|
|
|
|
|
|
CMainDocument* pDoc = wxGetApp().GetDocument();
|
|
|
|
wxASSERT(pDoc);
|
|
|
|
m_prefs = pDoc->state.global_prefs;
|
|
|
|
|
2006-08-18 21:45:17 +00:00
|
|
|
int dwBtwnIntB = ConvertToNumber(cmbDWBtwnBgn->GetValue());
|
|
|
|
int dwBtwnIntE = ConvertToNumber(cmbDWBtwnEnd->GetValue());
|
|
|
|
int ctiBtwnIntB = ConvertToNumber(cmbCTIBtwnBgn->GetValue());
|
|
|
|
int ctiBtwnIntE = ConvertToNumber(cmbCTIBtwnEnd->GetValue());
|
|
|
|
|
|
|
|
m_prefs.start_hour = dwBtwnIntB;
|
|
|
|
m_prefs.end_hour = dwBtwnIntE;
|
|
|
|
m_prefs.net_start_hour = ctiBtwnIntB;
|
|
|
|
m_prefs.net_end_hour = ctiBtwnIntE;
|
|
|
|
// Use No More Than GB
|
|
|
|
wxString useNoMoreGB = cmbUseNoMoreGB->GetValue();
|
|
|
|
wxString useNoMoreGBNum = useNoMoreGB.Mid(0,useNoMoreGB.Length()-2);
|
|
|
|
wxString valGBMB = useNoMoreGB.Mid(useNoMoreGB.Length()-2);
|
|
|
|
double dblUseNoMoreGB = 0;
|
|
|
|
if(valGBMB == wxString("GB")){
|
|
|
|
if(useNoMoreGBNum.ToDouble(&dblUseNoMoreGB)){
|
|
|
|
m_prefs.disk_max_used_gb = dblUseNoMoreGB;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
if(useNoMoreGBNum.ToDouble(&dblUseNoMoreGB)){
|
|
|
|
m_prefs.disk_max_used_gb = dblUseNoMoreGB/1000;
|
2006-08-17 17:36:51 +00:00
|
|
|
}
|
|
|
|
}
|
2006-08-18 21:45:17 +00:00
|
|
|
//Do Work While Comp In Use
|
|
|
|
wxString doWorkWhileInUse = cmbDWWCInUse->GetValue();
|
|
|
|
if(doWorkWhileInUse == wxString("Yes")){
|
|
|
|
m_prefs.run_if_user_active = true;
|
|
|
|
}else{
|
|
|
|
m_prefs.run_if_user_active = false;
|
|
|
|
}
|
|
|
|
// Do work after connection idle
|
|
|
|
wxString doWorkConnIdleFor = cmbDWACIdleFor->GetValue();
|
|
|
|
double dblDoWorkConnIdleFor = 0;
|
|
|
|
if(doWorkConnIdleFor.ToDouble(&dblDoWorkConnIdleFor)){
|
|
|
|
m_prefs.idle_time_to_run = dblDoWorkConnIdleFor;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
pDoc->rpc.set_global_prefs_override_struct(m_prefs);
|
|
|
|
pDoc->rpc.read_global_prefs_override();
|
2006-07-05 21:36:56 +00:00
|
|
|
|
|
|
|
}
|
2006-08-17 17:36:51 +00:00
|
|
|
void CDlgPreferences::ReadSettings(GLOBAL_PREFS prefs){
|
|
|
|
wxString hoursStrVal[]={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")};
|
2006-07-05 21:36:56 +00:00
|
|
|
|
2006-08-17 17:36:51 +00:00
|
|
|
cmbDWBtwnBgn->SetValue(hoursStrVal[prefs.start_hour]);
|
|
|
|
//
|
|
|
|
cmbDWBtwnEnd->SetValue(hoursStrVal[prefs.end_hour]);
|
|
|
|
//
|
|
|
|
cmbCTIBtwnBgn->SetValue(hoursStrVal[prefs.net_start_hour]);
|
|
|
|
//
|
|
|
|
cmbCTIBtwnEnd->SetValue(hoursStrVal[prefs.net_end_hour]);
|
|
|
|
//
|
|
|
|
|
|
|
|
}
|
|
|
|
int CDlgPreferences::ConvertToNumber(wxString num){
|
|
|
|
wxString hoursStrVal[]={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")};
|
|
|
|
|
2006-08-18 21:45:17 +00:00
|
|
|
for(int ind = 0; ind < 24; ind++){
|
2006-08-17 17:36:51 +00:00
|
|
|
if(hoursStrVal[ind] == num){
|
|
|
|
return ind;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
void CDlgPreferences::initAfter(){
|
|
|
|
//add your code here
|
|
|
|
Centre();
|
|
|
|
}
|
|
|
|
|
2006-08-10 19:32:47 +00:00
|
|
|
void CDlgPreferences::OnPaint(wxPaintEvent& WXUNUSED(event))
|
|
|
|
{
|
|
|
|
wxPaintDC dc(this);
|
2006-09-14 16:02:55 +00:00
|
|
|
dc.SetFont(wxFont(16,74,90,90,0,wxT("Arial")));
|
|
|
|
dc.DrawText(wxT("Skin"), wxPoint(16,10));
|
|
|
|
dc.SetFont(wxFont(9,74,90,90,0,wxT("Arial")));
|
|
|
|
dc.DrawText(wxT("Skin XML file:"), wxPoint(133,40));
|
|
|
|
dc.SetFont(wxFont(16,74,90,90,0,wxT("Arial")));
|
|
|
|
dc.DrawText(wxT("Preferences"), wxPoint(16,122));
|
2006-08-17 17:36:51 +00:00
|
|
|
dc.SetFont(wxFont(8,74,90,90,0,wxT("Arial")));
|
2006-09-14 16:02:55 +00:00
|
|
|
dc.DrawText(m_PrefIndicator, wxPoint(272,128));
|
2006-08-10 19:32:47 +00:00
|
|
|
dc.SetFont(wxFont(9,74,90,90,0,wxT("Arial")));
|
2006-09-14 16:02:55 +00:00
|
|
|
dc.DrawText(wxT("Do work only between:"), wxPoint(82,158));
|
|
|
|
dc.DrawText(wxT("and"), wxPoint(284,158));
|
|
|
|
dc.DrawText(wxT("Connect to internet only between:"), wxPoint(24,193));
|
|
|
|
dc.DrawText(wxT("and"), wxPoint(284,193));
|
|
|
|
dc.DrawText(wxT("Use no more than:"), wxPoint(103,228));
|
|
|
|
dc.DrawText(wxT("Do work while computer is in use?"), wxPoint(16,263));
|
|
|
|
dc.DrawText(wxT("Do work after computer is idle for:"), wxPoint(22,298));
|
|
|
|
dc.DrawText(wxT("minutes"), wxPoint(284,298));
|
2006-08-10 19:32:47 +00:00
|
|
|
}
|
2006-07-05 21:36:56 +00:00
|
|
|
//[evtFunc]end your code
|
2006-07-24 22:10:28 +00:00
|
|
|
wxDirTraverseResult DirTraverserSkins::OnFile(const wxString& filename)
|
|
|
|
{
|
|
|
|
return wxDIR_CONTINUE;
|
|
|
|
}
|
|
|
|
wxDirTraverseResult DirTraverserSkins::OnDir(const wxString& dirname)
|
|
|
|
{
|
|
|
|
#ifdef __WXMSW__
|
|
|
|
char separator = '\\';
|
|
|
|
#else
|
|
|
|
char separator = '/';
|
|
|
|
#endif
|
|
|
|
|
|
|
|
wxString skinName = dirname.AfterLast(separator);
|
|
|
|
if(skinName != wxT("default")){
|
|
|
|
m_skins.Add(skinName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return wxDIR_IGNORE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|