]> git.saurik.com Git - wxWidgets.git/blame - utils/screenshotgen/src/autocapture.h
Removed dummy wxFont == operator implementation (IIRC was needed to compile with...
[wxWidgets.git] / utils / screenshotgen / src / autocapture.h
CommitLineData
0d5eda9c
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: autocapture.h
3// Purpose: Defines the AutoCaptureMechanism class
4// Author: Utensil Candel (UtensilCandel@@gmail.com)
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
f978831f
BP
9#ifndef _AUTOCAPTURE_H_
10#define _AUTOCAPTURE_H_
0d5eda9c 11
0d5eda9c
FM
12#include <vector>
13#include <ctime>
14
f978831f
BP
15#include <wx/notebook.h>
16
0d5eda9c 17
6cd1aa9d 18// TODO: document what these flags mean
0d5eda9c
FM
19enum AdjustFlags
20{
21 AJ_Normal = 0,
22 AJ_RegionAdjust = 1 << 0,
23 AJ_Dropdown = 1 << 1,
24 AJ_TurnPage = 1 << 2,
25 AJ_Union = 1 << 3,
26 AJ_UnionEnd = 1 << 4
27};
28
4bae10bd
FM
29
30// ----------------------------------------------------------------------------
31// class AutoCaptureMechanism
32// ----------------------------------------------------------------------------
33
0d5eda9c
FM
34class AutoCaptureMechanism
35{
36public:
6cd1aa9d 37 AutoCaptureMechanism(wxNotebook *notebook,
0d5eda9c
FM
38 wxString directory = wxT("screenshots"),
39 int border = 5)
40 : m_notebook(notebook), m_dir(directory), m_border(border) {}
60a2264d 41
0d5eda9c
FM
42 ~AutoCaptureMechanism(){}
43
44 /*
45 If wxRTTI can't get the name correctly, specify name;
46 If wxWindow::GetScreenRect doesn't get the rect correctly, set flag to AJ_RegionAdjust
47 */
48 void RegisterControl(wxWindow * ctrl, wxString name = wxT(""),
49 int flag = AJ_Normal)
50 {
51 m_controlList.push_back(Control(ctrl, name, flag));
52 }
53
54 void RegisterControl(wxWindow * ctrl, int flag)
55 {
56 RegisterControl(ctrl, wxT(""), flag);
57 }
58
59 void RegisterPageTurn()
60 {
61 m_controlList.push_back(Control(0, wxT(""), AJ_TurnPage));
62 }
63
6cd1aa9d 64 // capture all controls of the associated notebook
60a2264d 65 void CaptureAll();
0d5eda9c 66
6cd1aa9d 67 // take a screenshot only of the given rect
101adcd5
FM
68 // delay is only useful for Mac, for fixing a delay bug
69 static wxBitmap Capture(wxRect rect, int delay = 0);
70 static wxBitmap Capture(int x, int y, int width, int height, int delay = 0);
6cd1aa9d 71
101adcd5 72 static void Delay(int seconds);
6cd1aa9d 73
101adcd5
FM
74
75private: // internal utils
0d5eda9c
FM
76 struct Control
77 {
78 Control() {}
79
80 Control(wxWindow * _ctrl, wxString _name, int _flag)
81 : ctrl(_ctrl), name(_name), flag(_flag) {}
82
83 wxWindow * ctrl;
84 wxString name;
85 int flag;
86 };
87
4bae10bd 88 wxBitmap Capture(Control & ctrl);
0d5eda9c 89
6cd1aa9d
FM
90 // if AJ_RegionAdjust is specified, the following line will use the label
91 // trick to adjust the region position and size
0d5eda9c 92 wxRect GetRect(wxWindow* ctrl, int flag);
4bae10bd 93
6cd1aa9d 94 // put the control back after the label trick(Using reparent/resizer approach)
0d5eda9c
FM
95 void PutBack(wxWindow * ctrl);
96
4bae10bd 97 wxBitmap Union(wxBitmap pic1, wxBitmap pic2);
0d5eda9c 98
4bae10bd 99 void Save(wxBitmap screenshot, wxString fileName);
0d5eda9c 100
4bae10bd
FM
101 typedef std::vector<Control> ControlList;
102 ControlList m_controlList;
0d5eda9c 103
4bae10bd
FM
104 // here we introduce the dependency on wxNotebook.
105 // The assumption of this whole class is that the gui has the following top-down structure
106 // wxNotebook wxPanel wxSizer wxControls
107 wxNotebook* m_notebook;
0d5eda9c 108
4bae10bd 109 wxFlexGridSizer* m_grid;
0d5eda9c 110
4bae10bd
FM
111 wxString m_dir;
112 int m_border;
0d5eda9c
FM
113};
114
f978831f 115#endif // _AUTOCAPTURE_H_
0d5eda9c
FM
116
117