home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2005 March / PCpro_2005_03.ISO / files / systools / speedswitchxp / sswitchxp14.exe / Typical / MachOptions.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2005-01-14  |  6.1 KB  |  157 lines

  1. /*
  2.    SpeedswitchXP V1.4
  3.    - Windows XP CPU Frequency Control for Notebooks -
  4.  
  5.    Copyright(c) 2002-2004 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. #include "stdafx.h"
  22. #include "SpeedswitchXP.h"
  23. #include "MachOptions.h"
  24. #include "speedswitch.h"
  25.  
  26. #define TOOLTIP_ID 1
  27.  
  28. // CMachOptions dialog
  29.  
  30. IMPLEMENT_DYNAMIC(CMachOptions, CDialog)
  31. CMachOptions::CMachOptions(CWnd* pParent /*=NULL*/)
  32.     : CDialog(CMachOptions::IDD, pParent)
  33.   , m_iMinSleepAC(0)
  34.   , m_iMinSleepDC(0)
  35.   , m_iRedLatSleepAC(0)
  36.   , m_iRedLatSleepDC(0)
  37.   , m_iDozeTimeoutAC(0)
  38.   , m_iDozeTimeoutDC(0)
  39.   , m_iDozeS4TimeoutAC(0)
  40.   , m_iDozeS4TimeoutDC(0)
  41.   , m_iMinThrottleAC(0)
  42.   , m_iMinThrottleDC(0)
  43. { }
  44.  
  45. CMachOptions::~CMachOptions()
  46. { }
  47.  
  48. void CMachOptions::DoDataExchange(CDataExchange* pDX)
  49. {
  50.   CDialog::DoDataExchange(pDX);
  51.   DDX_CBIndex(pDX, IDC_COMBO3, m_iMinSleepAC);
  52.   DDX_CBIndex(pDX, IDC_COMBO4, m_iMinSleepDC);
  53.   DDX_CBIndex(pDX, IDC_COMBO7, m_iRedLatSleepAC);
  54.   DDX_CBIndex(pDX, IDC_COMBO8, m_iRedLatSleepDC);
  55.   DDX_Text(pDX, IDC_EDIT1, m_iDozeTimeoutAC);
  56.   DDX_Text(pDX, IDC_EDIT2, m_iDozeTimeoutDC);
  57.   DDX_Text(pDX, IDC_EDIT3, m_iDozeS4TimeoutAC);
  58.   DDX_Text(pDX, IDC_EDIT7, m_iDozeS4TimeoutDC);
  59.   DDX_Text(pDX, IDC_EDIT11, m_iMinThrottleAC);
  60.   DDX_Text(pDX, IDC_EDIT12, m_iMinThrottleDC);
  61. }
  62.  
  63. BOOL CMachOptions::OnInitDialog()
  64. {
  65.     CDialog::OnInitDialog();
  66.  
  67.   addToolTip( 0, IDC_COMBO3, "Minimum system power state (lowest Sx value) to enter on a system sleep action" );
  68.   addToolTip( 1, IDC_COMBO4, "Minimum system power state (lowest Sx value) to enter on a system sleep action" );
  69.  
  70.   addToolTip( 2, IDC_COMBO7, "Maximum system power state (highest Sx value) to enter on a system sleep action when there are outstanding latency requirements" );
  71.   addToolTip( 3, IDC_COMBO8, "Maximum system power state (highest Sx value) to enter on a system sleep action when there are outstanding latency requirements" );
  72.  
  73.   addToolTip( 4, IDC_EDIT1, "Time to wait between leaving the system working state and entering the standby sleeping state" );
  74.   addToolTip( 5, IDC_EDIT2, "Time to wait between leaving the system working state and entering the standby sleeping state" );
  75.  
  76.   addToolTip( 6, IDC_EDIT3, "Time to wait between entering the suspend state and entering the hibernate sleeping state" );
  77.   addToolTip( 7, IDC_EDIT7, "Time to wait between entering the suspend state and entering the hibernate sleeping state" );
  78.  
  79.   addToolTip( 8, IDC_EDIT11, "Minimum throttle setting allowed before being overthrottled. Thermal conditions would be the only reason for going below the minimum setting." );
  80.   addToolTip( 9, IDC_EDIT12, "Minimum throttle setting allowed before being overthrottled. Thermal conditions would be the only reason for going below the minimum setting." );
  81.  
  82.   return TRUE;
  83. }
  84.  
  85. BOOL CMachOptions::PreTranslateMessage( MSG* pMsg ) 
  86. {
  87.   for( int i=0; i<10; i++ )
  88.     m_tToolTip[i].RelayEvent( pMsg );
  89.  
  90.   return CDialog::PreTranslateMessage( pMsg );
  91. }
  92.  
  93. BEGIN_MESSAGE_MAP(CMachOptions, CDialog)
  94. END_MESSAGE_MAP()
  95.  
  96.  
  97. // CMachOptions message handlers
  98. void CMachOptions::setVars()
  99. {
  100.   m_iMinSleepAC = internalPolicy.mach.MinSleepAc;
  101.   m_iMinSleepDC = internalPolicy.mach.MinSleepDc;
  102.   m_iRedLatSleepAC = internalPolicy.mach.ReducedLatencySleepAc;
  103.   m_iRedLatSleepDC = internalPolicy.mach.ReducedLatencySleepDc;
  104.   m_iDozeTimeoutAC = internalPolicy.mach.DozeTimeoutAc;
  105.   m_iDozeTimeoutDC = internalPolicy.mach.DozeTimeoutDc;
  106.   m_iDozeS4TimeoutAC = internalPolicy.mach.DozeS4TimeoutAc;
  107.   m_iDozeS4TimeoutDC = internalPolicy.mach.DozeS4TimeoutDc;
  108.   m_iMinThrottleAC = internalPolicy.mach.MinThrottleAc;
  109.   m_iMinThrottleDC = internalPolicy.mach.MinThrottleDc;
  110. }
  111.  
  112. void CMachOptions::getVars()
  113. {
  114.   if( m_iMinThrottleAC<0 || m_iMinThrottleAC>100 )
  115.     m_iMinThrottleAC = internalPolicy.mach.MinThrottleAc;
  116.  
  117.   if( m_iMinThrottleDC<0 || m_iMinThrottleDC>100 )
  118.     m_iMinThrottleDC = internalPolicy.mach.MinThrottleDc;
  119.  
  120.   if( m_iMinSleepAC != internalPolicy.mach.MinSleepAc
  121.   ||  m_iMinSleepDC != internalPolicy.mach.MinSleepDc
  122.   ||  m_iRedLatSleepAC != internalPolicy.mach.ReducedLatencySleepAc
  123.   ||  m_iRedLatSleepDC != internalPolicy.mach.ReducedLatencySleepDc
  124.   ||  m_iDozeTimeoutAC != internalPolicy.mach.DozeTimeoutAc
  125.   ||  m_iDozeTimeoutDC != internalPolicy.mach.DozeTimeoutDc
  126.   ||  m_iDozeS4TimeoutAC != internalPolicy.mach.DozeS4TimeoutAc
  127.   ||  m_iDozeS4TimeoutDC != internalPolicy.mach.DozeS4TimeoutDc
  128.   ||  m_iMinThrottleAC != internalPolicy.mach.MinThrottleAc
  129.   ||  m_iMinThrottleDC != internalPolicy.mach.MinThrottleDc )
  130.     power = TRUE;
  131.   else
  132.   {
  133.     power = FALSE;
  134.     return;
  135.   }
  136.  
  137.   internalPolicy.mach.MinSleepAc = (SYSTEM_POWER_STATE)m_iMinSleepAC;
  138.   internalPolicy.mach.MinSleepDc = (SYSTEM_POWER_STATE)m_iMinSleepDC;
  139.   internalPolicy.mach.ReducedLatencySleepAc = (SYSTEM_POWER_STATE)m_iRedLatSleepAC;
  140.   internalPolicy.mach.ReducedLatencySleepDc = (SYSTEM_POWER_STATE)m_iRedLatSleepDC;
  141.   internalPolicy.mach.DozeTimeoutAc = m_iDozeTimeoutAC;
  142.   internalPolicy.mach.DozeTimeoutDc = m_iDozeTimeoutDC;
  143.   internalPolicy.mach.DozeS4TimeoutAc = m_iDozeS4TimeoutAC;
  144.   internalPolicy.mach.DozeS4TimeoutDc = m_iDozeS4TimeoutDC;
  145.   internalPolicy.mach.MinThrottleAc = m_iMinThrottleAC;
  146.   internalPolicy.mach.MinThrottleDc = m_iMinThrottleDC;
  147. }
  148.  
  149. void CMachOptions::addToolTip( int no, int id, char* str )
  150. {
  151.   CWnd* wnd = GetDlgItem( id );
  152.   CRect rect; 
  153.   wnd->GetClientRect( rect );
  154.   m_tToolTip[no].Create( wnd );
  155.   m_tToolTip[no].AddTool( wnd, str, rect, TOOLTIP_ID );
  156. }
  157.