home *** CD-ROM | disk | FTP | other *** search
/ Clickx 47 / Clickx 47.iso / assets / software / sswitchxp152.exe / source / SpeedswitchXP / SpeedswitchXPOptions.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2006-07-13  |  6.4 KB  |  225 lines

  1. /*
  2.    SpeedswitchXP V1.5
  3.    - Windows XP CPU Frequency Control for Notebooks -
  4.  
  5.    Copyright(c) 2002-2005 Christian Diefer
  6.  
  7.    This program is free software; you can redistribute it and/or modify
  8.    it under the terms of the GNU General Public License version 2 as 
  9.    published by the Free Software Foundation.
  10.    
  11.    This program is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.    GNU General Public License for more details.
  15.    
  16.    You should have received a copy of the GNU General Public License
  17.    along with this program; if not, write to the Free Software
  18.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. #define _UNICODE
  22.  
  23. #include "stdafx.h"
  24. #include "TOptions.h"
  25. #include "SpeedswitchXP.h"
  26. #include "SpeedswitchXPOptions.h"
  27. #include "GeneralOptions.h"
  28. #include "UserOptions.h"
  29. #include "MachOptions.h"
  30. #include "CPUOptions.h"
  31. #include "uxtheme.h"
  32.  
  33. CGeneralOptions genOpt;
  34. CUserOptions userOpt;
  35. CMachOptions machOpt;
  36. CCPUOptions cpuOpt;
  37.  
  38. // CSpeedswitchXPOptions dialog
  39.  
  40. IMPLEMENT_DYNAMIC(CSpeedswitchXPOptions, CDialog)
  41. CSpeedswitchXPOptions::CSpeedswitchXPOptions(CWnd* pParent /*=NULL*/)
  42.     : CDialog(CSpeedswitchXPOptions::IDD, pParent)
  43. { }
  44.  
  45. CSpeedswitchXPOptions::~CSpeedswitchXPOptions()
  46. { }
  47.  
  48. void CSpeedswitchXPOptions::DoDataExchange(CDataExchange* pDX)
  49. {
  50.   CDialog::DoDataExchange(pDX);
  51.   DDX_Control(pDX, IDC_TAB1, tabCtrl);
  52. }
  53.  
  54.  
  55. BEGIN_MESSAGE_MAP(CSpeedswitchXPOptions, CDialog)
  56.   ON_NOTIFY(TCN_SELCHANGE, IDC_TAB1, OnTcnSelchangeTab1)
  57. END_MESSAGE_MAP()
  58.  
  59.  
  60. BOOL CSpeedswitchXPOptions::OnInitDialog()
  61. {
  62.   log( _T("OnInitDialog von Options") );
  63.     CDialog::OnInitDialog();
  64.  
  65.     TC_ITEM TabCtrlItem;
  66.     TabCtrlItem.mask = TCIF_TEXT;
  67.  
  68.   static WCHAR t[256];
  69.   CString s1;
  70.  
  71.   s1.LoadStringW( IDS_OPT1 );
  72.   _tcscpy_s( t, s1 );
  73.  
  74.     TabCtrlItem.pszText = t;
  75.     tabCtrl.InsertItem( 0, &TabCtrlItem );
  76.  
  77.   s1.LoadStringW( IDS_OPT2 );
  78.   _tcscpy_s( t, s1 );
  79.  
  80.     TabCtrlItem.pszText = t;
  81.     tabCtrl.InsertItem( 1, &TabCtrlItem );
  82.  
  83.   s1.LoadStringW( IDS_OPT3 );
  84.   _tcscpy_s( t, s1 );
  85.  
  86.     TabCtrlItem.pszText = t;
  87.   tabCtrl.InsertItem( 2, &TabCtrlItem );
  88.   
  89.   s1.LoadStringW( IDS_OPT4 );
  90.   _tcscpy_s( t, s1 );
  91.  
  92.     TabCtrlItem.pszText = t;
  93.   tabCtrl.InsertItem( 3, &TabCtrlItem );
  94.  
  95.   tabs[0] = &genOpt;
  96.   tabs[1] = &userOpt;
  97.   tabs[2] = &machOpt;
  98.   tabs[3] = &cpuOpt;
  99.  
  100.   genOpt.Create( IDD_GENERALOPT, this );
  101.   userOpt.Create( IDD_USEROPT, this );
  102.   machOpt.Create( IDD_MACHOPT, this );
  103.   cpuOpt.Create( IDD_CPUOPT, this );
  104.  
  105.   genOpt.ShowWindow( SW_SHOW );
  106.   userOpt.ShowWindow( SW_HIDE );
  107.   machOpt.ShowWindow( SW_HIDE );
  108.   cpuOpt.ShowWindow( SW_HIDE );
  109.  
  110.   // calculate overlay window position and size
  111.   for( int i=0; i<4; i++ )
  112.   {
  113.     RECT rect;
  114.  
  115.     tabs[i]->GetClientRect( &rect );
  116.     TabCtrl_AdjustRect( tabCtrl, 0, &rect );
  117.     tabCtrl.ClientToScreen( &rect );
  118.     ScreenToClient( &rect );
  119.     tabs[i]->SetWindowPos( &wndTop,
  120.                            rect.left,
  121.                            rect.top,
  122.                            rect.right - rect.left,
  123.                            rect.bottom - rect.top + 22,
  124.                            (i ? SWP_HIDEWINDOW : SWP_SHOWWINDOW) );
  125.  
  126.     EnableThemeDialogTexture( tabs[i]->m_hWnd, ETDT_ENABLETAB );
  127.   }
  128.  
  129.   genOpt.UpdateData( FALSE );
  130.   userOpt.UpdateData( FALSE );
  131.   machOpt.UpdateData( FALSE );
  132.   cpuOpt.UpdateData( FALSE );
  133.  
  134.   log( _T("OnInitDialog von Options zuende") );
  135.  
  136.   return TRUE;
  137. }
  138.  
  139. // CSpeedswitchXPOptions message handlers
  140.  
  141. void CSpeedswitchXPOptions::OnTcnSelchangeTab1( NMHDR *pNMHDR, LRESULT *pResult )
  142. {
  143.   int i = tabCtrl.GetCurSel();
  144.  
  145.   for( int x=0; x<4; x++ )
  146.     tabs[x]->ShowWindow( x==i ? SW_SHOW : SW_HIDE );
  147.  
  148.   *pResult = 0;
  149. }
  150.  
  151. void CSpeedswitchXPOptions::OnOK()
  152. {
  153.   UpdateData();
  154.   genOpt.UpdateData();
  155.   userOpt.UpdateData();
  156.   machOpt.UpdateData();
  157.   cpuOpt.UpdateData();
  158.   cpuOpt.applyChanges( cpuOpt.m_iCStateConfig );
  159.  
  160.   CDialog::OnOK();
  161. }
  162.  
  163. void CSpeedswitchXPOptions::setVars( TOptions& options )
  164. {
  165.   genOpt.m_bAutostart = options.autoStart;
  166.   genOpt.m_bDebugmode = options.debugMode;
  167.   genOpt.m_bMinimizeOnClose = options.minimizeOnClose;
  168.   genOpt.m_bCheckStatus = options.checkStatus;
  169.   genOpt.m_iCheckInterval = options.checkInterval;
  170.   genOpt.m_bReactivate = options.reactivate;
  171.   genOpt.m_bReadCPUSpeed = options.readCPUSpeed;
  172.   genOpt.m_iSpeedMethod = options.speedMethod;
  173.   genOpt.m_bReadCPULoad = options.readCPULoad;
  174.   genOpt.m_bShowDiagram = options.showDiagram;
  175.   genOpt.m_iCPUInterval = options.cpuInterval;
  176.   genOpt.m_iSpeedScaling = options.freqScaling-1;
  177.   genOpt.m_bShowBattery = options.showBattery;
  178.   genOpt.m_iBatteryIndicator = options.batteryIndicator;
  179.   genOpt.m_iBattMethod = options.batteryMethod;
  180.   genOpt.m_bChargeIndicator = options.chargeIndicator;
  181.   genOpt.m_bSpeedIcon = options.speedIcon;
  182.   genOpt.m_bLoadIcon = options.loadIcon;
  183.   genOpt.m_iIconColor1 = options.iconColor1;
  184.   genOpt.m_iIconColor2 = options.iconColor2;
  185.   genOpt.m_bIconTransparent = options.iconTransparent;
  186.  
  187.   userOpt.setVars();
  188.   machOpt.setVars();
  189.   cpuOpt.setVars();
  190.   power = cpu = FALSE;
  191. }
  192.  
  193. void CSpeedswitchXPOptions::getVars( TOptions& options )
  194. {
  195.   options.autoStart = genOpt.m_bAutostart;
  196.   options.debugMode = genOpt.m_bDebugmode;
  197.   options.minimizeOnClose = genOpt.m_bMinimizeOnClose;
  198.   options.checkStatus = genOpt.m_bCheckStatus;
  199.   options.checkInterval = genOpt.m_iCheckInterval;
  200.   options.reactivate = genOpt.m_bReactivate;
  201.   options.readCPUSpeed = genOpt.m_bReadCPUSpeed;
  202.   options.speedMethod = genOpt.m_iSpeedMethod;
  203.   options.readCPULoad = genOpt.m_bReadCPULoad;
  204.   options.showDiagram = genOpt.m_bShowDiagram;
  205.   options.cpuInterval = genOpt.m_iCPUInterval;
  206.   options.freqScaling = genOpt.m_iSpeedScaling+1;
  207.   options.showBattery = genOpt.m_bShowBattery;
  208.   options.batteryIndicator = genOpt.m_iBatteryIndicator;
  209.   options.batteryMethod = genOpt.m_iBattMethod;
  210.   options.chargeIndicator = genOpt.m_bChargeIndicator;
  211.   options.speedIcon = genOpt.m_bSpeedIcon;
  212.   options.loadIcon = genOpt.m_bLoadIcon;
  213.  
  214.   options.iconColor1 = genOpt.m_iIconColor1;
  215.   options.iconColor2 = genOpt.m_iIconColor2;
  216.   options.iconTransparent = genOpt.m_bIconTransparent;
  217.  
  218.   userOpt.getVars();
  219.   machOpt.getVars();
  220.   cpuOpt.getVars();
  221.  
  222.   power = userOpt.power || machOpt.power;
  223.   cpu = cpuOpt.cpu;
  224. }
  225.