From ca063d002df131dfa4cdd0bc43235abad8574bcf Mon Sep 17 00:00:00 2001 From: Mark Watkins Date: Fri, 27 May 2011 14:13:16 +1000 Subject: [PATCH] Added Screenshot Capability --- GUIFrame.cpp | 9 ++++++++ GUIFrame.h | 2 ++ SleepyHead.depend | 14 +++++++----- SleepyHeadMain.cpp | 55 +++++++++++++++++++++++++++++++++++++++++++--- SleepyHeadMain.h | 4 ++++ WxWizFrame.fbp | 20 +++++++++++++++++ version.h | 14 ++++++------ 7 files changed, 103 insertions(+), 15 deletions(-) diff --git a/GUIFrame.cpp b/GUIFrame.cpp index 046da5d7..448906ea 100644 --- a/GUIFrame.cpp +++ b/GUIFrame.cpp @@ -54,6 +54,13 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons menubar->Append( ViewMenu, _("&View") ); + ToolsMenu = new wxMenu(); + wxMenuItem* ToolsMenuScreenshot; + ToolsMenuScreenshot = new wxMenuItem( ToolsMenu, wxID_ANY, wxString( _("Screenshot") ) , wxEmptyString, wxITEM_NORMAL ); + ToolsMenu->Append( ToolsMenuScreenshot ); + + menubar->Append( ToolsMenu, _("Tools") ); + HelpMenu = new wxMenu(); wxMenuItem* HelpMenuAbout; HelpMenuAbout = new wxMenuItem( HelpMenu, wxID_ANY, wxString( _("&About") ) , wxEmptyString, wxITEM_NORMAL ); @@ -78,6 +85,7 @@ GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, cons this->Connect( FileMenuExit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnQuit ) ); this->Connect( ViewMenuSummary->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewMenuSummary ) ); this->Connect( ViewMenuDaily->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewMenuDaily ) ); + this->Connect( ToolsMenuScreenshot->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnScreenshot ) ); this->Connect( HelpMenuAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnAbout ) ); } @@ -90,6 +98,7 @@ GUIFrame::~GUIFrame() this->Disconnect( wxID_QUIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnQuit ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewMenuSummary ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnViewMenuDaily ) ); + this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnScreenshot ) ); this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnAbout ) ); m_mgr.UnInit(); diff --git a/GUIFrame.h b/GUIFrame.h index 9c03abfe..e22c8194 100644 --- a/GUIFrame.h +++ b/GUIFrame.h @@ -44,6 +44,7 @@ class GUIFrame : public wxFrame wxMenuBar* menubar; wxMenu* FileMenu; wxMenu* ViewMenu; + wxMenu* ToolsMenu; wxMenu* HelpMenu; wxStatusBar* statusBar; @@ -54,6 +55,7 @@ class GUIFrame : public wxFrame virtual void OnQuit( wxCommandEvent& event ) { event.Skip(); } virtual void OnViewMenuSummary( wxCommandEvent& event ) { event.Skip(); } virtual void OnViewMenuDaily( wxCommandEvent& event ) { event.Skip(); } + virtual void OnScreenshot( wxCommandEvent& event ) { event.Skip(); } virtual void OnAbout( wxCommandEvent& event ) { event.Skip(); } diff --git a/SleepyHead.depend b/SleepyHead.depend index 00517d14..8c797dd2 100644 --- a/SleepyHead.depend +++ b/SleepyHead.depend @@ -7785,12 +7785,12 @@ "wx/progdlg.h" "wx/dialog.h" -1306390268 source:/home/mark/projects/git/sleepyhead/GUIFrame.cpp +1306463640 source:/home/mark/projects/git/sleepyhead/GUIFrame.cpp "wx/wxprec.h" "GUIFrame.h" -1306384009 /home/mark/projects/git/sleepyhead/GUIFrame.h +1306463640 /home/mark/projects/git/sleepyhead/GUIFrame.h @@ -7826,7 +7826,7 @@ 1305881106 /home/mark/projects/git/sleepyhead/SleepyHeadApp.h -1306414968 /home/mark/projects/git/sleepyhead/SleepyHeadMain.h +1306468775 /home/mark/projects/git/sleepyhead/SleepyHeadMain.h "SleepyHeadApp.h" "GUIFrame.h" "sleeplib/machine.h" @@ -7870,7 +7870,7 @@ -1306410340 /home/mark/projects/git/sleepyhead/version.h +1306469484 /home/mark/projects/git/sleepyhead/version.h 1306415077 /home/mark/projects/git/sleepyhead/libs/sleeplib/prs1_loader.h "machine.h" @@ -7887,13 +7887,17 @@ "preferences.h" "tinyxml/tinyxml.h" -1306414968 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp +1306469522 source:/home/mark/projects/git/sleepyhead/SleepyHeadMain.cpp "wx_pch.h" "version.h" + + + + "SleepyHeadMain.h" "sleeplib/profiles.h" diff --git a/SleepyHeadMain.cpp b/SleepyHeadMain.cpp index 64d67afd..869bf716 100644 --- a/SleepyHeadMain.cpp +++ b/SleepyHeadMain.cpp @@ -20,7 +20,10 @@ #include #include #include - +#include +#include +#include +#include #include "SleepyHeadMain.h" #include "sleeplib/profiles.h" //#include "graphs/sleepflagsgraph.h" @@ -57,11 +60,47 @@ wxString wxbuildinfo(wxbuildinfoformat format) return wxbuild; } - + + +void SleepyHeadFrame::DoScreenshot( wxCommandEvent &event ) +{ + wxRect r=GetRect(); + +#if defined(__UNIX__) + /*int cx, cy; + ClientToScreen(&cx,&cy); + int border_width = cx - r.x; + int title_bar_height = cy - r.y; + r.width += (border_width * 2); + r.height += title_bar_height + border_width; */ +#endif + int x=r.x; + int y=r.y; + int w=r.width; + int h=r.height; + + wxScreenDC sdc; + wxMemoryDC mdc; + + wxBitmap bmp(r.width, r.height,-1); + //wxBitMap *bmp=wxEmptyImage(r.width,r.height); + mdc.SelectObject(bmp); + + mdc.Blit((wxCoord)0, (wxCoord)0, (wxCoord)r.width, (wxCoord)r.height, &sdc, (wxCoord)r.x, (wxCoord)r.y); + + mdc.SelectObject(wxNullBitmap); + + wxString fileName = wxT("myImage.png"); + wxImage img=bmp.ConvertToImage(); + if (!img.SaveFile(fileName, wxBITMAP_TYPE_PNG)) { + wxLogError(wxT("Couldn't save screenshot ")+fileName); + } +} SleepyHeadFrame::SleepyHeadFrame(wxFrame *frame) : GUIFrame(frame) { + wxInitAllImageHandlers(); loader_progress=new wxProgressDialog(wxT("SleepyHead"),wxT("Please Wait..."),100,this, wxPD_APP_MODAL|wxPD_AUTO_HIDE|wxPD_SMOOTH); loader_progress->Hide(); wxString title=wxTheApp->GetAppName()+wxT(" v")+wxString(AutoVersion::FULLVERSION_STRING,wxConvUTF8); @@ -71,6 +110,9 @@ SleepyHeadFrame::SleepyHeadFrame(wxFrame *frame) wxCommandEvent dummy; OnViewMenuSummary(dummy); // Summary Page OnViewMenuDaily(dummy); // Daily Page + + this->Connect(wxID_ANY, wxEVT_DO_SCREENSHOT, wxCommandEventHandler(SleepyHeadFrame::DoScreenshot)); + //this->Connect(wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(SleepyHeadFrame::DoScreenshot)); #if wxUSE_STATUSBAR //statusBar->SetStatusText(_("Hello!"), 0); @@ -95,7 +137,13 @@ void SleepyHeadFrame::OnClose(wxCloseEvent &event) void SleepyHeadFrame::OnQuit(wxCommandEvent &event) { Destroy(); -} +} + +void SleepyHeadFrame::OnScreenshot(wxCommandEvent& event) +{ + wxCommandEvent MyEvent( wxEVT_DO_SCREENSHOT); + wxPostEvent(this, MyEvent); +} void SleepyHeadFrame::OnAbout(wxCommandEvent &event) { @@ -205,6 +253,7 @@ void Summary::RefreshData() if (machine->properties.find(wxT("SubModel"))!=machine->properties.end()) submodel=wxT("
\n ")+machine->properties[wxT("SubModel")]; html=html+wxT("")+machine->properties[wxT("Brand")]+wxT("
")+machine->properties[wxT("Model")]+wxT(" ")+machine->properties[wxT("ModelNumber")]+submodel+wxT("\n"); + //html=html+wxT("")+_("Serial")+wxT(" ")+machine->properties[wxT("Serial")]+wxT(""); html=html+wxT("  \n"); html=html+wxT("")+_("Indice Averages")+wxT("\n"); html=html+wxT("")+_("AHI")+wxT("")+wxString::Format(wxT("%0.2f"),ahi)+wxT("\n"); diff --git a/SleepyHeadMain.h b/SleepyHeadMain.h index 1d436968..dc28f29e 100644 --- a/SleepyHeadMain.h +++ b/SleepyHeadMain.h @@ -55,6 +55,8 @@ protected: list Data; }; + +const wxEventType wxEVT_DO_SCREENSHOT = wxNewEventType(); class SleepyHeadFrame: public GUIFrame { @@ -65,6 +67,8 @@ class SleepyHeadFrame: public GUIFrame virtual void OnClose(wxCloseEvent& event); virtual void OnQuit(wxCommandEvent& event); virtual void OnAbout(wxCommandEvent& event); + virtual void OnScreenshot(wxCommandEvent& event); + virtual void DoScreenshot(wxCommandEvent& event); virtual void OnImportSD(wxCommandEvent& event); virtual void OnViewMenuDaily(wxCommandEvent& event); virtual void OnViewMenuSummary(wxCommandEvent& event); diff --git a/WxWizFrame.fbp b/WxWizFrame.fbp index 8aba6aec..464660a5 100644 --- a/WxWizFrame.fbp +++ b/WxWizFrame.fbp @@ -286,6 +286,26 @@ + + Tools + ToolsMenu + protected + + + 0 + 1 + + wxID_ANY + wxITEM_NORMAL + Screenshot + ToolsMenuScreenshot + none + + + OnScreenshot + + + &Help HelpMenu diff --git a/version.h b/version.h index 6a09d9f4..8eb1bf7d 100644 --- a/version.h +++ b/version.h @@ -4,7 +4,7 @@ namespace AutoVersion{ //Date Version Types - static const char DATE[] = "26"; + static const char DATE[] = "27"; static const char MONTH[] = "05"; static const char YEAR[] = "2011"; static const char UBUNTU_VERSION_STYLE[] = "11.05"; @@ -16,14 +16,14 @@ namespace AutoVersion{ //Standard Version Type static const long MAJOR = 0; static const long MINOR = 7; - static const long BUILD = 1190; - static const long REVISION = 940; + static const long BUILD = 1244; + static const long REVISION = 1258; //Miscellaneous Version Types - static const long BUILDS_COUNT = 4690; - #define RC_FILEVERSION 0,7,1190,940 - #define RC_FILEVERSION_STRING "0, 7, 1190, 940\0" - static const char FULLVERSION_STRING[] = "0.7.1190.940"; + static const long BUILDS_COUNT = 4784; + #define RC_FILEVERSION 0,7,1244,1258 + #define RC_FILEVERSION_STRING "0, 7, 1244, 1258\0" + static const char FULLVERSION_STRING[] = "0.7.1244.1258"; //These values are to keep track of your versioning state, don't modify them. static const long BUILD_HISTORY = 62;