power.h 2.7 KB

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