added wxPowerEvent; moved power functions stubs to common/powercmn.cpp

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@39359 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2006-05-27 14:09:40 +00:00
parent 9fa1b6aad4
commit 355debca06
37 changed files with 2660 additions and 277 deletions

120
samples/power/power.cpp Normal file
View File

@@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////////////
// Name: power.cpp
// Purpose: wxWidgets power management sample
// Author: Vadim Zeitlin
// Created: 2006-05-27
// RCS-ID: $Id$
// Copyright: (C) 2006 Vadim Zeitlin <vadim@wxwindows.org>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/frame.h"
#endif
#include "wx/textctrl.h"
#include "wx/msgdlg.h"
#include "wx/power.h"
#if !defined(__WXMSW__) && !defined(__WXPM__)
#include "../sample.xpm"
#endif
// ----------------------------------------------------------------------------
// main frame class
// ----------------------------------------------------------------------------
class MyFrame : public wxFrame
{
public:
MyFrame()
: wxFrame(NULL, wxID_ANY, _T("wxWidgets Power Management Sample"),
wxDefaultPosition, wxSize(500, 200))
{
wxTextCtrl *text = new wxTextCtrl(this, wxID_ANY, _T(""),
wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY);
m_logOld = wxLog::SetActiveTarget(new wxLogTextCtrl(text));
SetIcon(wxICON(sample));
Show();
}
virtual ~MyFrame()
{
delete wxLog::SetActiveTarget(m_logOld);
}
private:
void OnSuspending(wxPowerEvent& event)
{
wxLogMessage(_T("System suspend starting..."));
if ( wxMessageBox(_T("Veto suspend?"), _T("Please answer"),
wxYES_NO, this) == wxYES )
{
event.Veto();
wxLogMessage(_T("Vetoed suspend."));
}
}
void OnSuspended(wxPowerEvent& WXUNUSED(event))
{
wxLogMessage(_T("System is going to suspend."));
}
void OnSuspendCancel(wxPowerEvent& WXUNUSED(event))
{
wxLogMessage(_T("System suspend was cancelled."));
}
void OnResume(wxPowerEvent& WXUNUSED(event))
{
wxLogMessage(_T("System resumed from suspend."));
}
wxLog *m_logOld;
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_POWER_SUSPENDING(MyFrame::OnSuspending)
EVT_POWER_SUSPENDED(MyFrame::OnSuspended)
EVT_POWER_SUSPEND_CANCEL(MyFrame::OnSuspendCancel)
EVT_POWER_RESUME(MyFrame::OnResume)
END_EVENT_TABLE()
// ----------------------------------------------------------------------------
// main application class
// ----------------------------------------------------------------------------
class MyApp : public wxApp
{
public:
virtual bool OnInit()
{
new MyFrame;
return true;
}
};
IMPLEMENT_APP(MyApp)