]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/screenshotgen/src/autocapture.h
Removed dummy wxFont == operator implementation (IIRC was needed to compile with...
[wxWidgets.git] / utils / screenshotgen / src / autocapture.h
index e07b43f19be4feda63ef98e2af8958432be51847..e0aed4d36e89c64423a7335322d8f940cd494838 100644 (file)
@@ -6,18 +6,16 @@
 // Licence:     wxWindows license
 /////////////////////////////////////////////////////////////////////////////
 
-#ifndef AUTOCAP_H
-#define AUTOCAP_H
+#ifndef _AUTOCAPTURE_H_
+#define _AUTOCAPTURE_H_
 
-#include <wx/notebook.h>
-#include <wx/settings.h>
 #include <vector>
 #include <ctime>
 
-// Global helper functions. to take screenshot for a rect region
-wxBitmap Capture(wxRect rect);
-wxBitmap Capture(int x, int y, int width, int height);
+#include <wx/notebook.h>
+
 
+// TODO: document what these flags mean
 enum AdjustFlags
 {
     AJ_Normal = 0,
@@ -36,10 +34,11 @@ enum AdjustFlags
 class AutoCaptureMechanism
 {
 public:
-    AutoCaptureMechanism(wxNotebook * notebook,
+    AutoCaptureMechanism(wxNotebook *notebook,
                          wxString directory = wxT("screenshots"),
                          int border = 5)
         : m_notebook(notebook), m_dir(directory), m_border(border) {}
+
     ~AutoCaptureMechanism(){}
 
     /*
@@ -62,36 +61,18 @@ public:
         m_controlList.push_back(Control(0, wxT(""), AJ_TurnPage));
     }
 
-    void CaptureAll()
-    {
-        m_notebook->SetSelection(0);
-        wxYield();
-
-        for(ControlList::iterator it = m_controlList.begin();
-            it != m_controlList.end();
-            ++it)
-        {
-            Control & ctrl = *it;
-
-            if(ctrl.flag == AJ_TurnPage) // Turn to next page
-            {
-                m_notebook->SetSelection(m_notebook->GetSelection() + 1);
-                wxYield();
-                continue;
-            }
-
-            wxBitmap screenshot = Capture(ctrl);
-
-            if(ctrl.flag & AJ_Union)
-            {
-                screenshot = Union(screenshot, Capture(*(++it)));
-            }
-
-            Save(screenshot, ctrl.name);
-        }
-    }
+    // capture all controls of the associated notebook
+    void CaptureAll();
+
+    // take a screenshot only of the given rect
+    // delay is only useful for Mac, for fixing a delay bug
+    static wxBitmap Capture(wxRect rect, int delay = 0);
+    static wxBitmap Capture(int x, int y, int width, int height, int delay = 0);
+
+    static void Delay(int seconds);
+
 
-protected:      // internal utils
+private:      // internal utils
     struct Control
     {
         Control() {}
@@ -106,18 +87,17 @@ protected:      // internal utils
 
     wxBitmap Capture(Control & ctrl);
 
-    //if AJ_RegionAdjust is specified, the following line will use the label trick to adjust
-    //the region position and size
+    // if AJ_RegionAdjust is specified, the following line will use the label
+    // trick to adjust the region position and size
     wxRect GetRect(wxWindow* ctrl, int flag);
 
-    //put the control back after the label trick(Using reparent/resizer approach)
+    // put the control back after the label trick(Using reparent/resizer approach)
     void PutBack(wxWindow * ctrl);
 
     wxBitmap Union(wxBitmap pic1, wxBitmap pic2);
 
     void Save(wxBitmap screenshot, wxString fileName);
 
-private:
     typedef std::vector<Control> ControlList;
     ControlList m_controlList;
 
@@ -132,6 +112,6 @@ private:
     int m_border;
 };
 
-#endif // AUTOCAP_H
+#endif // _AUTOCAPTURE_H_