1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/include/wx/power.h
3 // Purpose: functions and classes for system power management
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
17 // ----------------------------------------------------------------------------
18 // power management constants
19 // ----------------------------------------------------------------------------
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
37 // ----------------------------------------------------------------------------
38 // wxPowerEvent is generated when the system online status changes
39 // ----------------------------------------------------------------------------
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
47 #define wxHAS_POWER_EVENTS
49 class WXDLLIMPEXP_BASE wxPowerEvent
: public wxEvent
52 wxPowerEvent(wxEventType evtType
) : wxEvent(wxID_NONE
, evtType
)
57 // Veto the operation (only makes sense with EVT_POWER_SUSPENDING)
58 void Veto() { m_veto
= true; }
60 bool IsVetoed() const { return m_veto
; }
63 // default copy ctor, assignment operator and dtor are ok
65 virtual wxEvent
*Clone() const { return new wxPowerEvent(*this); }
71 BEGIN_DECLARE_EVENT_TYPES()
72 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE
, wxEVT_POWER_SUSPENDING
, 406)
73 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE
, wxEVT_POWER_SUSPENDED
, 407)
74 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE
, wxEVT_POWER_SUSPEND_CANCEL
, 408)
75 DECLARE_EXPORTED_EVENT_TYPE(WXDLLIMPEXP_BASE
, wxEVT_POWER_RESUME
, 444)
76 END_DECLARE_EVENT_TYPES()
78 typedef void (wxEvtHandler::*wxPowerEventFunction
)(wxPowerEvent
&);
80 #define wxPowerEventHandler(func) \
81 (wxObjectEventFunction)(wxEventFunction) \
82 wxStaticCastEvent(wxPowerEventFunction, &func)
84 #define EVT_POWER_SUSPENDING(func) \
85 wx__DECLARE_EVT0(wxEVT_POWER_SUSPENDING, wxPowerEventHandler(func))
86 #define EVT_POWER_SUSPENDED(func) \
87 wx__DECLARE_EVT0(wxEVT_POWER_SUSPENDED, wxPowerEventHandler(func))
88 #define EVT_POWER_SUSPEND_CANCEL(func) \
89 wx__DECLARE_EVT0(wxEVT_POWER_SUSPEND_CANCEL, wxPowerEventHandler(func))
90 #define EVT_POWER_RESUME(func) \
91 wx__DECLARE_EVT0(wxEVT_POWER_RESUME, wxPowerEventHandler(func))
93 #else // no support for power events
94 #undef wxHAS_POWER_EVENTS
95 #endif // support for power events/no support
97 // ----------------------------------------------------------------------------
98 // power management functions
99 // ----------------------------------------------------------------------------
101 // return the current system power state: online or offline
102 WXDLLIMPEXP_BASE wxPowerType
wxGetPowerType();
104 // return approximate battery state
105 WXDLLIMPEXP_BASE wxBatteryState
wxGetBatteryState();
107 #endif // _WX_POWER_H_