X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/17ad109b8b14bc11b347530836d83c4e3df44050..fdb97de42b8a1491257566fb7bbd343916f1f2b8:/utils/screenshotgen/src/autocapture.h?ds=sidebyside diff --git a/utils/screenshotgen/src/autocapture.h b/utils/screenshotgen/src/autocapture.h index 4adf3936b8..20f16415e5 100644 --- a/utils/screenshotgen/src/autocapture.h +++ b/utils/screenshotgen/src/autocapture.h @@ -9,10 +9,16 @@ #ifndef _AUTOCAPTURE_H_ #define _AUTOCAPTURE_H_ +#include "wx/beforestd.h" #include -#include +#include "wx/afterstd.h" -#include +#include "wx/gdicmn.h" + +class wxBitmap; +class wxFlexGridSizer; +class wxWindow; +class wxNotebook; /** GlobalAdjustFlags works with AutoCaptureMechanism's constructor, to disbale/enable @@ -38,6 +44,9 @@ enum GlobalAdjustFlags /** Enable region adjustment for all controls. + + If AJ_DisableRegionAdjust and AJ_AlwaysRegionAdjust are both specified, current + implemetation will ignore AJ_DisableRegionAdjust. */ AJ_AlwaysRegionAdjust = 1 << 1, @@ -97,15 +106,14 @@ enum AdjustFlags AJ_TurnPage = 1 << 2, /** - This flag provides a functionality to union screenshots of different controls into - one image. - - It's especially useful to demonstrate different modes/states of a control, - e.g. the single-line/multi-line modes of a wxTextCtrl. + This flag provides a functionality to union screenshots of different modes/states of + a control into one image. e.g. the single-line/multi-line modes of a wxTextCtrl. For a series of controls to be unioned, you should specify AJ_Union for the first, and AJ_UnionEnd for the last. For the controls between them, you can either specify AJ_Union or not. + + The filename of the generated screenshot is the name of the first control in the series. */ AJ_Union = 1 << 3, @@ -208,11 +216,9 @@ public: */ AutoCaptureMechanism(wxNotebook *notebook, int flag = AJ_NormalAll, - int margin = 5) - : m_notebook(notebook), m_flag(flag), - m_margin(margin), m_grid(NULL) {} + int margin = 5); - ~AutoCaptureMechanism(){} + ~AutoCaptureMechanism() { } /** Register a control and perform specifid auto adjustments. @@ -236,7 +242,7 @@ public: Please read the document of enum AdjustFlags, and notice that this flag could be enabled/ disabled by global flag GlobalAdjustFlags. */ - void RegisterControl(wxWindow * ctrl, wxString name = _T(""), int flag = AJ_Normal) + void RegisterControl(wxWindow * ctrl, wxString name = wxT(""), int flag = AJ_Normal) { m_controlList.push_back(Control(ctrl, name, flag)); } @@ -250,7 +256,7 @@ public: */ void RegisterControl(wxWindow * ctrl, int flag) { - RegisterControl(ctrl, _T(""), flag); + RegisterControl(ctrl, wxT(""), flag); } /** @@ -261,7 +267,7 @@ public: */ void RegisterPageTurn() { - m_controlList.push_back(Control(0, _T(""), AJ_TurnPage)); + m_controlList.push_back(Control(0, wxT(""), AJ_TurnPage)); } /** @@ -275,31 +281,34 @@ public: /** Take a screenshot for the given region. - @param rect is the given rectangular region. - - @param delay is only useful for Mac, for fixing a delay bug. It seems that it didn't - fix the bug, so it might be removed soon. + @param bitmap + Bitmap to save the screenshot to. + @param rect + Given rectangular region. + @param delay + Only useful for Mac, for fixing a delay bug. It seems that it + didn't fix the bug, so it might be removed soon. */ - static wxBitmap Capture(wxRect rect, int delay = 0); + static bool Capture(wxBitmap* bitmap, wxRect rect, int delay = 0); /** Take a screenshot for the given region. - @see Capture(wxRect rect, int delay) + @see Capture(wxBitmap*,wxRect,int) */ - static wxBitmap Capture(int x, int y, int width, int height, int delay = 0); + static bool Capture(wxBitmap* bitmap, int x, int y, int width, int height, int delay = 0); /** Save the screenshot as the name of @a fileName in the default directory. @a fileName should be without ".png". */ - static void Save(wxBitmap screenshot, wxString fileName); + static void Save(wxBitmap* screenshot, const wxString& fileName); /** Set the default directory where the screenshots will be generated. */ - static void SetDefaultDirectory(wxString dir) { default_dir = dir; } + static void SetDefaultDirectory(const wxString& dir) { default_dir = dir; } /** Get the default directory where the screenshots will be generated. @@ -309,12 +318,7 @@ public: /** Get the absolute path of the default directory where the screenshots will be generated. */ - static wxString GetDefaultDirectoryAbsPath() - { - wxFileName output = wxFileName::DirName(GetDefaultDirectory()); - output.MakeAbsolute(); - return output.GetFullPath(); - } + static wxString GetDefaultDirectoryAbsPath(); private: @@ -347,7 +351,7 @@ private: /* Capture and auto adjust the control. Used by CaptureAll(). */ - wxBitmap Capture(Control & ctrl); + bool Capture(wxBitmap* bitmap, Control& ctrl); /* Get the correct rectangular region that the control occupies. Used by @@ -387,8 +391,11 @@ private: The gap is 20 pixels by default. Currently it isn't configurable. */ - static wxBitmap Union(wxBitmap pic1, wxBitmap pic2); + static bool Union(wxBitmap* top, wxBitmap* bottom, wxBitmap* result); + /* + Delay a few seconds without blocking GUI. + */ static void Delay(int seconds); /*