]> git.saurik.com Git - wxWidgets.git/blame - src/msw/power.cpp
Remove support for Gnome printing from wxGTK.
[wxWidgets.git] / src / msw / power.cpp
CommitLineData
3032b7b5
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/msw/power.cpp
3// Purpose: power management functions for MSW
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 2006-05-27
3032b7b5
VZ
7// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8// Licence: wxWindows licence
9///////////////////////////////////////////////////////////////////////////////
10
11// ============================================================================
12// declarations
13// ============================================================================
14
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19// for compilers that support precompilation, includes "wx.h".
20#include "wx/wxprec.h"
21
22#ifdef __BORLANDC__
23 #pragma hdrstop
24#endif
25
26#ifndef WX_PRECOMP
27#endif //WX_PRECOMP
28
29#include "wx/power.h"
7325e21c 30#include "wx/msw/private.h"
3032b7b5 31
a8e89343
JS
32#if !defined(__WINCE_STANDARDSDK__)
33
dbc74bcc
WS
34#ifdef __WXWINCE__
35 typedef SYSTEM_POWER_STATUS_EX SYSTEM_POWER_STATUS;
36 BOOL GetSystemPowerStatus(SYSTEM_POWER_STATUS *status)
37 {
38 return GetSystemPowerStatusEx(status, TRUE);
39 }
40#endif
41
3032b7b5
VZ
42// ----------------------------------------------------------------------------
43// helper functions
44// ----------------------------------------------------------------------------
45
46static inline bool wxGetPowerStatus(SYSTEM_POWER_STATUS *sps)
47{
48 if ( !::GetSystemPowerStatus(sps) )
49 {
9a83f860 50 wxLogLastError(wxT("GetSystemPowerStatus()"));
3032b7b5
VZ
51 return false;
52 }
53
54 return true;
55}
56
a8e89343
JS
57#endif
58
3032b7b5
VZ
59// ============================================================================
60// implementation
61// ============================================================================
62
63wxPowerType wxGetPowerType()
64{
a8e89343 65#if !defined(__WINCE_STANDARDSDK__)
3032b7b5
VZ
66 SYSTEM_POWER_STATUS sps;
67 if ( wxGetPowerStatus(&sps) )
68 {
69 switch ( sps.ACLineStatus )
70 {
71 case 0:
72 return wxPOWER_BATTERY;
73
74 case 1:
75 return wxPOWER_SOCKET;
76
77 default:
9a83f860 78 wxLogDebug(wxT("Unknown ACLineStatus=%u"), sps.ACLineStatus);
3032b7b5
VZ
79 case 255:
80 break;
81 }
82 }
a8e89343 83#endif
3032b7b5
VZ
84
85 return wxPOWER_UNKNOWN;
86}
87
88wxBatteryState wxGetBatteryState()
89{
a8e89343 90#if !defined(__WINCE_STANDARDSDK__)
3032b7b5
VZ
91 SYSTEM_POWER_STATUS sps;
92 if ( wxGetPowerStatus(&sps) )
93 {
94 // there can be other bits set in the flag field ("charging" and "no
95 // battery"), extract only those which we need here
96 switch ( sps.BatteryFlag & 7 )
97 {
98 case 1:
99 return wxBATTERY_NORMAL_STATE;
100
101 case 2:
102 return wxBATTERY_LOW_STATE;
103
104 case 3:
105 return wxBATTERY_CRITICAL_STATE;
106 }
107 }
a8e89343 108#endif
3032b7b5
VZ
109
110 return wxBATTERY_UNKNOWN_STATE;
111}