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