]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: power.h | |
3 | // Purpose: interface of wxPowerEvent | |
4 | // Author: wxWidgets team | |
5 | // Licence: wxWindows licence | |
6 | ///////////////////////////////////////////////////////////////////////////// | |
7 | ||
8 | enum wxPowerType | |
9 | { | |
10 | wxPOWER_SOCKET, | |
11 | wxPOWER_BATTERY, | |
12 | wxPOWER_UNKNOWN | |
13 | }; | |
14 | ||
15 | enum wxBatteryState | |
16 | { | |
17 | wxBATTERY_NORMAL_STATE, // system is fully usable | |
18 | wxBATTERY_LOW_STATE, // start to worry | |
19 | wxBATTERY_CRITICAL_STATE, // save quickly | |
20 | wxBATTERY_SHUTDOWN_STATE, // too late | |
21 | wxBATTERY_UNKNOWN_STATE | |
22 | }; | |
23 | ||
24 | ||
25 | /** | |
26 | @class wxPowerEvent | |
27 | ||
28 | The power events are generated when the system power state changes, e.g. the | |
29 | system is suspended, hibernated, plugged into or unplugged from the wall socket | |
30 | and so on. wxPowerEvents are emitted by wxWindows. | |
31 | ||
32 | Notice that currently only suspend and resume events are generated and only | |
33 | under MS Windows platform. To avoid the need to change the code using this | |
34 | event later when these events are implemented on the other platforms please | |
35 | use the test <tt>ifdef wxHAS_POWER_EVENTS</tt> instead of directly testing for | |
36 | the platform in your code: this symbol will be defined for all platforms | |
37 | supporting the power events. | |
38 | ||
39 | @beginEventTable{wxPowerEvent} | |
40 | @event{EVT_POWER_SUSPENDING(func)} | |
41 | System is about to be suspended, this event can be vetoed to prevent | |
42 | suspend from taking place. | |
43 | @event{EVT_POWER_SUSPENDED(func)} | |
44 | System is about to suspend: normally the application should quickly | |
45 | (i.e. without user intervention) close all the open files and network | |
46 | connections here, possibly remembering them to reopen them later when | |
47 | the system is resumed. | |
48 | @event{EVT_POWER_SUSPEND_CANCEL(func)} | |
49 | System suspension was cancelled because some application vetoed it. | |
50 | @event{EVT_POWER_RESUME(func)} | |
51 | System resumed from suspend: normally the application should restore | |
52 | the state in which it had been before the suspension. | |
53 | @endEventTable | |
54 | ||
55 | @library{wxbase} | |
56 | @category{events} | |
57 | ||
58 | @see ::wxGetPowerType(), ::wxGetBatteryState() | |
59 | */ | |
60 | class wxPowerEvent : public wxEvent | |
61 | { | |
62 | public: | |
63 | wxPowerEvent(); | |
64 | wxPowerEvent(wxEventType evtType); | |
65 | ||
66 | /** | |
67 | Call this to prevent suspend from taking place in @c wxEVT_POWER_SUSPENDING | |
68 | handler (it is ignored for all the others). | |
69 | */ | |
70 | void Veto(); | |
71 | ||
72 | /** | |
73 | Returns whether Veto has been called. | |
74 | */ | |
75 | bool IsVetoed() const; | |
76 | }; | |
77 | ||
78 | wxEventType wxEVT_POWER_SUSPENDING; | |
79 | wxEventType wxEVT_POWER_SUSPENDED; | |
80 | wxEventType wxEVT_POWER_SUSPEND_CANCEL; | |
81 | wxEventType wxEVT_POWER_RESUME; | |
82 | ||
83 |