]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/screenshotgen/src/screenshot_main.cpp
Fix a crash in wxExecute() in wxMSW too.
[wxWidgets.git] / utils / screenshotgen / src / screenshot_main.cpp
index 0970262c1a9071d61866a156232bb933a55918a7..9dd085e648546b8c30799ac6f8cd27e7ad173bb7 100644 (file)
@@ -3,7 +3,7 @@
 // Purpose:     Implements the window containing all controls.
 // Author:      Utensil Candel (UtensilCandel@@gmail.com)
 // RCS-ID:      $Id$
-// Licence:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx/wx.h".
@@ -54,15 +54,12 @@ void ScreenshotFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 
 void ScreenshotFrame::OnSeeScreenshots(wxCommandEvent& WXUNUSED(event))
 {
-    wxFileName defaultDir = wxFileName::DirName(GetDefaultDirectory());
-    defaultDir.MakeAbsolute();
+    wxString defaultDir = AutoCaptureMechanism::GetDefaultDirectoryAbsPath();
 
-    // Check if defaultDir already existed
-    if (!defaultDir.DirExists())
-        defaultDir.Mkdir();
-
-    // Use the native file browser to open defaultDir
-    wxLaunchDefaultBrowser(defaultDir.GetFullPath());
+    if (wxFileName::DirExists(defaultDir))
+        wxLaunchDefaultBrowser(defaultDir);
+    else
+        wxMessageBox(_("There isn't any screenshots yet."));
 }
 
 void ScreenshotFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
@@ -71,7 +68,7 @@ void ScreenshotFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
     info.SetName(_("Automatic Screenshot Generator"));
     info.SetVersion(_("1.0"));
     info.SetDescription(_("This utility automatically creates screenshots of wxWidgets controls for use in wxWidgets documentation."));
-    info.SetCopyright(_T("(C) 2008 Utensil Candel"));
+    info.SetCopyright(wxT("(C) 2008 Utensil Candel"));
 
     wxAboutBox(info);
 }
@@ -85,27 +82,28 @@ void ScreenshotFrame::OnCaptureFullScreen(wxCommandEvent& WXUNUSED(event))
     wxCoord screenWidth, screenHeight;
     dcScreen.GetSize(&screenWidth, &screenHeight);
 
-    const wxString fullscreen_filename = GetDefaultDirectoryAbsPath() + _T("fullscreen.png");
-
-    wxBitmap fullscreen = AutoCaptureMechanism::Capture(0, 0, screenWidth, screenHeight);
+    wxBitmap fullscreen(1, 1);
+    AutoCaptureMechanism::Capture(&fullscreen, 0, 0, screenWidth, screenHeight);
 
-    fullscreen.SaveFile(fullscreen_filename, wxBITMAP_TYPE_PNG);
+    AutoCaptureMechanism::Save(&fullscreen, wxT("fullscreen"));
 
     wxMessageBox(_("A screenshot of the entire screen was saved as:\n\n  ")
-                + fullscreen_filename,
+                + AutoCaptureMechanism::GetDefaultDirectoryAbsPath() + wxT("fullscreen.png"),
                  _("Full screen capture"), wxICON_INFORMATION|wxOK, this);
 }
 
 void ScreenshotFrame::OnCaptureAllControls(wxCommandEvent& WXUNUSED(event))
 {
-    wxString dir = GetDefaultDirectoryAbsPath();
+    wxString dir = AutoCaptureMechanism::GetDefaultDirectoryAbsPath();
 
     // check if there are other screenshots taken before
     if (wxFileName::DirExists(dir))
     {
-        int choice = wxMessageBox(_("It seems that you have already generated some screenshots.\n\nClick YES to delete them all (recommended) or NO to preserve them.\nClick CANCEL to cancel this auto-capture operation."),
-                            _("Delete existing screenshots?"),
-                            wxYES_NO|wxCANCEL|wxICON_QUESTION, this);
+        int choice = wxMessageBox(
+            _("It seems that you have already generated some screenshots.\n\nClick YES to delete them all (recommended) or NO to preserve them.\nClick CANCEL to cancel this auto-capture operation."),
+            _("Delete existing screenshots?"),
+            wxYES_NO | wxCANCEL | wxICON_QUESTION, this);
+
         switch(choice)
         {
             case wxYES: