]> git.saurik.com Git - wxWidgets.git/blame - include/wx/power.h
add WXWIN_COMPATIBILITY_2_6 block around wxUsleep deprecation; put wxPlatform declara...
[wxWidgets.git] / include / wx / power.h
CommitLineData
355debca 1///////////////////////////////////////////////////////////////////////////////
01f242e2 2// Name: wx/power.h
355debca
VZ
3// Purpose: functions and classes for system power management
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 2006-05-27
7// RCS-ID: $Id$
8// Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_POWER_H_
13#define _WX_POWER_H_
14
15#include "wx/event.h"
16
17// ----------------------------------------------------------------------------
18// power management constants
19// ----------------------------------------------------------------------------
20
21enum wxPowerType
22{
23 wxPOWER_SOCKET,
24 wxPOWER_BATTERY,
25 wxPOWER_UNKNOWN
26};
27
28enum wxBatteryState
29{
30 wxBATTERY_NORMAL_STATE, // system is fully usable
31 wxBATTERY_LOW_STATE, // start to worry
32 wxBATTERY_CRITICAL_STATE, // save quickly
33 wxBATTERY_SHUTDOWN_STATE, // too late
34 wxBATTERY_UNKNOWN_STATE
35};
36
37// ----------------------------------------------------------------------------
38// wxPowerEvent is generated when the system online status changes
39// ----------------------------------------------------------------------------
40
41// currently the power events are only available under Windows, to avoid
42// compiling in the code for handling them which is never going to be invoked
43// under the other platforms, we define wxHAS_POWER_EVENTS symbol if this event
44// is available, it should be used to guard all code using wxPowerEvent
45#ifdef __WXMSW__
46
47#define wxHAS_POWER_EVENTS
48
49class WXDLLIMPEXP_BASE wxPowerEvent : public wxEvent
50{
51public:
d0960f6d
FM
52 wxPowerEvent() // just for use by wxRTTI
53 : m_veto(false) { }
54
355debca
VZ
55 wxPowerEvent(wxEventType evtType) : wxEvent(wxID_NONE, evtType)
56 {
57 m_veto = false;
58 }
59
60 // Veto the operation (only makes sense with EVT_POWER_SUSPENDING)
61 void Veto() { m_veto = true; }
62
63 bool IsVetoed() const { return m_veto; }
64
65
66 // default copy ctor, assignment operator and dtor are ok
67
68 virtual wxEvent *Clone() const { return new wxPowerEvent(*this); }
69
70private:
71 bool m_veto;
391e226e 72
d0960f6d 73 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxPowerEvent)
355debca
VZ
74};
75
c058cafa
VZ
76extern WXDLLIMPEXP_BASE const wxEventType wxEVT_POWER_SUSPENDING;
77extern WXDLLIMPEXP_BASE const wxEventType wxEVT_POWER_SUSPENDED;
78extern WXDLLIMPEXP_BASE const wxEventType wxEVT_POWER_SUSPEND_CANCEL;
79extern WXDLLIMPEXP_BASE const wxEventType wxEVT_POWER_RESUME;
355debca
VZ
80
81typedef void (wxEvtHandler::*wxPowerEventFunction)(wxPowerEvent&);
82
83#define wxPowerEventHandler(func) \
84 (wxObjectEventFunction)(wxEventFunction) \
85 wxStaticCastEvent(wxPowerEventFunction, &func)
86
87#define EVT_POWER_SUSPENDING(func) \
88 wx__DECLARE_EVT0(wxEVT_POWER_SUSPENDING, wxPowerEventHandler(func))
89#define EVT_POWER_SUSPENDED(func) \
90 wx__DECLARE_EVT0(wxEVT_POWER_SUSPENDED, wxPowerEventHandler(func))
91#define EVT_POWER_SUSPEND_CANCEL(func) \
92 wx__DECLARE_EVT0(wxEVT_POWER_SUSPEND_CANCEL, wxPowerEventHandler(func))
93#define EVT_POWER_RESUME(func) \
94 wx__DECLARE_EVT0(wxEVT_POWER_RESUME, wxPowerEventHandler(func))
95
96#else // no support for power events
97 #undef wxHAS_POWER_EVENTS
98#endif // support for power events/no support
99
100// ----------------------------------------------------------------------------
101// power management functions
102// ----------------------------------------------------------------------------
103
104// return the current system power state: online or offline
105WXDLLIMPEXP_BASE wxPowerType wxGetPowerType();
106
107// return approximate battery state
108WXDLLIMPEXP_BASE wxBatteryState wxGetBatteryState();
109
110#endif // _WX_POWER_H_