1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Defines the AutoCaptureMechanism class
4 // Author: Utensil Candel (UtensilCandel@@gmail.com)
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
12 #include <wx/notebook.h>
13 #include <wx/settings.h>
17 // Global helper functions. to take screenshot for a rect region
18 wxBitmap
Capture(wxRect rect
);
19 wxBitmap
Capture(int x
, int y
, int width
, int height
);
24 AJ_RegionAdjust
= 1 << 0,
32 // ----------------------------------------------------------------------------
33 // class AutoCaptureMechanism
34 // ----------------------------------------------------------------------------
36 class AutoCaptureMechanism
39 AutoCaptureMechanism(wxNotebook
* notebook
,
40 wxString directory
= wxT("screenshots"),
42 : m_notebook(notebook
), m_dir(directory
), m_border(border
) {}
44 ~AutoCaptureMechanism(){}
47 If wxRTTI can't get the name correctly, specify name;
48 If wxWindow::GetScreenRect doesn't get the rect correctly, set flag to AJ_RegionAdjust
50 void RegisterControl(wxWindow
* ctrl
, wxString name
= wxT(""),
53 m_controlList
.push_back(Control(ctrl
, name
, flag
));
56 void RegisterControl(wxWindow
* ctrl
, int flag
)
58 RegisterControl(ctrl
, wxT(""), flag
);
61 void RegisterPageTurn()
63 m_controlList
.push_back(Control(0, wxT(""), AJ_TurnPage
));
68 protected: // internal utils
73 Control(wxWindow
* _ctrl
, wxString _name
, int _flag
)
74 : ctrl(_ctrl
), name(_name
), flag(_flag
) {}
81 wxBitmap
Capture(Control
& ctrl
);
83 //if AJ_RegionAdjust is specified, the following line will use the label trick to adjust
84 //the region position and size
85 wxRect
GetRect(wxWindow
* ctrl
, int flag
);
87 //put the control back after the label trick(Using reparent/resizer approach)
88 void PutBack(wxWindow
* ctrl
);
90 wxBitmap
Union(wxBitmap pic1
, wxBitmap pic2
);
92 void Save(wxBitmap screenshot
, wxString fileName
);
95 typedef std::vector
<Control
> ControlList
;
96 ControlList m_controlList
;
98 // here we introduce the dependency on wxNotebook.
99 // The assumption of this whole class is that the gui has the following top-down structure
100 // wxNotebook wxPanel wxSizer wxControls
101 wxNotebook
* m_notebook
;
103 wxFlexGridSizer
* m_grid
;