X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4bae10bdff8683fea70daf9f9b6c3fa559fe64cb..cfcc02a8a4f019e3846b73660209080602e44967:/utils/screenshotgen/src/autocapture.h diff --git a/utils/screenshotgen/src/autocapture.h b/utils/screenshotgen/src/autocapture.h index e07b43f19b..e0aed4d36e 100644 --- a/utils/screenshotgen/src/autocapture.h +++ b/utils/screenshotgen/src/autocapture.h @@ -6,18 +6,16 @@ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// -#ifndef AUTOCAP_H -#define AUTOCAP_H +#ifndef _AUTOCAPTURE_H_ +#define _AUTOCAPTURE_H_ -#include -#include #include #include -// 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 + +// 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 ControlList; ControlList m_controlList; @@ -132,6 +112,6 @@ private: int m_border; }; -#endif // AUTOCAP_H +#endif // _AUTOCAPTURE_H_