screenshotgen_screenshot_app.o \
screenshotgen_screenshot_main.o \
screenshotgen_guiframe.o \
- screenshotgen_ctrlmaskout.o \
screenshotgen_customcombo.o \
screenshotgen_autocapture.o \
$(__screenshotgen___win32rc)
screenshotgen_guiframe.o: $(srcdir)/guiframe.cpp
$(CXXC) -c -o $@ $(SCREENSHOTGEN_CXXFLAGS) $(srcdir)/guiframe.cpp
-screenshotgen_ctrlmaskout.o: $(srcdir)/ctrlmaskout.cpp
- $(CXXC) -c -o $@ $(SCREENSHOTGEN_CXXFLAGS) $(srcdir)/ctrlmaskout.cpp
-
screenshotgen_customcombo.o: $(srcdir)/customcombo.cpp
$(CXXC) -c -o $@ $(SCREENSHOTGEN_CXXFLAGS) $(srcdir)/customcombo.cpp
+++ /dev/null
-/* XPM */
-static const char * play_xpm[] = {
-"20 20 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ..... ",
-" ...... ",
-" ....... ",
-" ........ ",
-" ......... ",
-" .......... ",
-" ........... ",
-" ............ ",
-" ............ ",
-" ........... ",
-" .......... ",
-" ......... ",
-" ........ ",
-" ....... ",
-" ...... ",
-" ..... ",
-" ",
-" "};
+++ /dev/null
-/* XPM */
-static const char * stop_xpm[] = {
-"20 20 2 1",
-" c None",
-". c #000000",
-" ",
-" ",
-" ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" .............. ",
-" ",
-" ",
-" "};
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: ctrlmaskout.cpp
-// Purpose: Implement CtrlMaskOut class
-// Author: Utensil Candel (UtensilCandel@@gmail.com)
-// RCS-ID: $Id$
-// Licence: wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-
-// For compilers that support precompilation, includes "wx/wx.h".
-#include "wx/wxprec.h"
-
-#ifdef __BORLANDC__
-#pragma hdrstop
-#endif
-
-// for all others, include the necessary headers wxWidgets headers)
-#ifndef WX_PRECOMP
-#include "wx/wx.h"
-#endif
-
-#include "ctrlmaskout.h"
-
-#ifdef __WXMAC__ // See CreateMask()
-#include <wx/minifram.h>
-#include <cstdlib>
-#endif
-
-// use a set to make sure the same control won't be inserted twice
-#include "wx/hashset.h"
-WX_DECLARE_HASH_SET(wxWindow*, wxPointerHash, wxPointerEqual, CtrlSet);
-
-
-// It's copied from src/aui/framemanager.cpp and modified, a failed attempt to
-// visualize the process of taking the screenshot when wxTopLevelWindow::CanSetTransparent
-// returns false. see CtrlMaskOut::CreateMask for more info
-// now it shows nothing and does nothing
-/////////////////////////////////////////////////////////////////////////////
-
-class wxPseudoTransparentFrame : public wxFrame
-{
-public:
- wxPseudoTransparentFrame(wxWindow* parent = NULL,
- wxWindowID id = wxID_ANY,
- const wxString& title = wxEmptyString,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxDEFAULT_FRAME_STYLE,
- const wxString &name = wxT("frame"))
- : wxFrame(parent, id, title, pos, size, style | wxFRAME_SHAPED, name)
- {
- m_lastWidth=0;
- m_lastHeight=0;
- }
-
- virtual bool SetTransparent(wxByte alpha)
- {
- return true;
- }
-
- void OnPaint(wxPaintEvent& WXUNUSED(event)){}
-
- virtual void SetSize(const wxRect& rect){}
- virtual void SetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO){}
- virtual void SetSize(int width, int height){}
- virtual void SetSize(const wxSize& size){}
-
- virtual bool Show(bool show = true){ return true;}
-
- void OnSize(wxSizeEvent& event)
- {
-// // We sometimes get surplus size events
-// if ((event.GetSize().GetWidth() == m_lastWidth) &&
-// (event.GetSize().GetHeight() == m_lastHeight))
-// {
-// event.Skip();
-// return;
-// }
-//
-// Show(false);
-//
-// GetParent()->Update();
-//
-// Show(true);
-//
-//
-// m_lastWidth = event.GetSize().GetWidth();
-// m_lastHeight = event.GetSize().GetHeight();
- }
-
-private:
- int m_lastWidth,m_lastHeight;
-
- DECLARE_DYNAMIC_CLASS(wxPseudoTransparentFrame)
- DECLARE_EVENT_TABLE()
-};
-
-IMPLEMENT_DYNAMIC_CLASS(wxPseudoTransparentFrame, wxFrame)
-
-BEGIN_EVENT_TABLE(wxPseudoTransparentFrame, wxFrame)
- EVT_PAINT(wxPseudoTransparentFrame::OnPaint)
- EVT_SIZE(wxPseudoTransparentFrame::OnSize)
-END_EVENT_TABLE()
-
-
-
-// ----------------------------------------------------------------------------
-// CtrlMaskOut
-// ----------------------------------------------------------------------------
-
-CtrlMaskOut::CtrlMaskOut()
- : m_defaultDir(_T("screenshots")),
- m_controlName(_T("")),
- m_currentRect(0, 0, 0, 0),
- m_inflateBorder(5),
- m_mask(NULL),
- m_isTiming(false)
-{
-}
-
-CtrlMaskOut::~CtrlMaskOut()
-{
- if (m_mask != NULL)
- {
- m_mask->Destroy();
- m_mask = NULL;
- }
-}
-
-void CtrlMaskOut::OnLeftButtonDown(wxMouseEvent& event)
-{
- if (m_isTiming) event.Skip();
-
- // Start draging at the left-top corner.
- wxWindow * thePanel = (wxWindow *)event.GetEventObject();
- m_currentRect.SetPosition(thePanel->ClientToScreen(event.GetPosition()));
- m_currentRect.SetSize(wxSize(1, 1));
-
- // Create a transparent mask to visulize the process of specifying a rect region..
- CreateMask(thePanel);
-}
-
-void CtrlMaskOut::OnMouseMoving(wxMouseEvent& event)
-{
- if (!event.Dragging())
- {
- event.Skip();
- return;
- }
-
- wxWindow * thePanel = (wxWindow *)event.GetEventObject();
-
- // Determine the current rect region
- m_currentRect.SetBottomRight(thePanel->ClientToScreen(event.GetPosition()) - wxPoint(5, 5));
- // /Because Mac can't get the left btn up event fired if we don't minus wxPoint(5, 5),
- // /May fix it by making the panel handle this event later
- // /This is the current trick
- // /See also line 200 in CreateMask
-
- // Visualize the current rect region
- m_mask->SetSize(m_currentRect);
-}
-
-void CtrlMaskOut::OnLeftButtonUp(wxMouseEvent& event)
-{
- if (m_mask == NULL)// Which means it's not after specifying a rect region
- {
- event.Skip();
- return;
- }
-
- DestroyMask();
-
- // End dragging at the right-bottom corner.
- wxWindow * thePanel = (wxWindow *)event.GetEventObject();
- m_currentRect.SetRightBottom(thePanel->ClientToScreen(event.GetPosition()));
-
- if (event.ControlDown())
- {
- m_isTiming = true;
- (new wxTimer(this))->Start(3000, wxTIMER_ONE_SHOT);
- this->Connect(wxEVT_TIMER, wxTimerEventHandler( CtrlMaskOut::OnTimingFinished ), NULL, this);
- }
- else
- {
- // The final rect region is determined.
- DetermineCtrlNameAndRect();
-
- Capture(m_currentRect, m_controlName);
- }
-}
-
-void CtrlMaskOut::OnTimingFinished(wxTimerEvent& event)
-{
- // The final rect region is determined.
- DetermineCtrlNameAndRect();
-
- Capture(m_currentRect, m_controlName);
-
- m_isTiming = false;
- this->Disconnect(wxEVT_TIMER, wxTimerEventHandler( CtrlMaskOut::OnTimingFinished ), NULL, this);
-}
-
-void CtrlMaskOut::Capture(int x, int y, int width, int height, wxString fileName)
-{
- // Somehow wxScreenDC.Blit() doesn't work under Mac for now. Here is a trick.
-#ifdef __WXMAC__
-
- // wxExecute(_T("screencapture -x ") + tempfile, wxEXEC_SYNC);
-
- system("screencapture -x /tmp/wx_screen_capture.png");
-
- wxBitmap fullscreen;
-
- do
- {
- fullscreen = wxBitmap(_T("/tmp/wx_screen_capture.png"), wxBITMAP_TYPE_PNG);
- }
- while(!fullscreen.IsOk());
-
- wxBitmap screenshot = fullscreen.GetSubBitmap(wxRect(x,y,width,height));
-
- #else // Under other paltforms, take a real screenshot
-
- // Create a DC for the whole screen area
- wxScreenDC dcScreen;
-
- // Create a Bitmap that will later on hold the screenshot image
- // Note that the Bitmap must have a size big enough to hold the screenshot
- // -1 means using the current default colour depth
- wxBitmap screenshot(width, height, -1);
-
- // Create a memory DC that will be used for actually taking the screenshot
- wxMemoryDC memDC;
- // Tell the memory DC to use our Bitmap
- // all drawing action on the memory DC will go to the Bitmap now
- memDC.SelectObject(screenshot);
- // Blit (in this case copy) the actual screen on the memory DC
- // and thus the Bitmap
- memDC.Blit( 0, // Copy to this X coordinate
- 0, // Copy to this Y coordinate
- width, // Copy this width
- height, // Copy this height
- &dcScreen, // From where do we copy?
- x, // What's the X offset in the original DC?
- y // What's the Y offset in the original DC?
- );
- // Select the Bitmap out of the memory DC by selecting a new
- // uninitialized Bitmap
- memDC.SelectObject(wxNullBitmap);
-
-#endif // #ifdef __WXMAC__
-
- // Check if m_defaultDir already existed
- if (!wxDirExists(m_defaultDir))
- wxMkdir(m_defaultDir);
-
- // Our Bitmap now has the screenshot, so let's save it as an png
- // The filename itself is without extension.
- screenshot.SaveFile(m_defaultDir + wxFileName::GetPathSeparator() +
- fileName + _T(".png"), wxBITMAP_TYPE_PNG);
-}
-
-void CtrlMaskOut::Capture(wxRect rect, wxString fileName)
-{
- wxPoint origin = rect.GetPosition();
- Capture(origin.x, origin.y, rect.GetWidth(), rect.GetHeight(), fileName);
-}
-
-void CtrlMaskOut::DetermineCtrlNameAndRect()
-{
- // Detect windows using (n-1)*(n-1) points
- const int n = 5;
-
- wxPoint pt0 = m_currentRect.GetPosition();
-
- int dx = m_currentRect.GetWidth() / n;
- int dy = m_currentRect.GetHeight() / n;
-
- wxPoint pt;
- wxWindow * ctrl;
- wxString ctrlName;
- wxRect ctrlSize;
-
- CtrlSet ctrls;
-
- int i, j;
- for (i = 1; i <= n - 1; ++i)
- {
- for (j = 1; j <= n - 1; ++j)
- {
- pt = wxPoint(pt0.x + i * dx, pt0.y + j * dy);
- ctrls.insert(wxFindWindowAtPoint(pt));
- }
- }
-
- // Store the manual specified rect region, we might need it
- wxRect backup = m_currentRect;
-
- // Reset the control region and control name
- m_currentRect = wxRect(0, 0, 0, 0);
- m_controlName = _T("");
-
- for (CtrlSet::iterator it = ctrls.begin(); it != ctrls.end(); ++it )
- {
- ctrl = *it;
- if (ctrl == NULL)
- // which means no control was detected.
- // This seldom happens, but without dealing with it, it will CRASH the program
- {
- static int count = 0;
- ++count;
- m_controlName = _T("nothing_");
- m_controlName << count;
- m_currentRect = backup;
- return;
- }
- ctrlName = ctrl->GetClassInfo()->GetClassName();
-
- if (ctrlName != _T("wxPanel")) // Avoid detecting "wxPanel", which is only the backgroud
- {
- // Get a rect region to contain every window detected by unioning one by one.
- m_currentRect.Union(ctrl->GetScreenRect());
-
- // Get the name of the control, cut off "wx" and change them into lowercase.
- // e.g. wxButton will have a filename of "button" and be saved as "button.png"
- ctrlName.StartsWith(_T("wx"), &ctrlName);
- ctrlName.MakeLower();
-
- if (m_controlName.IsEmpty() || m_controlName == ctrlName)
- {
- m_controlName = ctrlName;
- }
- else // more than one types of controls are in the region selected
- {
- m_controlName += _T("_");
- m_controlName += ctrlName;
- }
- }
- }
-
- if (m_controlName.IsEmpty() && backup.GetHeight() > 15 && backup.GetWidth() > 15)
- // which means no control other than the wxPanel was detected.
- // if the size of the specified rect(backup) is smaller than 15x15,
- // then it could be just an accident
- {
- static int count = 0;
- ++count;
- m_controlName = _T("unknown_");
- m_controlName << count;
- m_currentRect = backup;
- return;
- }
-
- // Increase its border so that it looks nicer.
- m_currentRect.Inflate(m_inflateBorder);
-}
-
-void CtrlMaskOut::CreateMask(wxWindow* parent)
-{
- if (m_mask != NULL)
- m_mask->Destroy();
-
- // Make a frame to visualize the process of specifying the rect region.
-#if defined(__WXMSW__) || defined(__WXGTK__)
- m_mask = new wxFrame(parent, wxID_ANY, wxEmptyString,
- m_currentRect.GetPosition(), m_currentRect.GetSize(),
- wxFRAME_TOOL_WINDOW |
- wxFRAME_FLOAT_ON_PARENT |
- wxFRAME_NO_TASKBAR);
-// wxNO_BORDER);
-// with the border, it looks better under windows
-
- m_mask->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_ACTIVECAPTION));
-
-#elif defined(__WXMAC__)
- // Using a miniframe with float and tool styles keeps the parent
- // frame activated and highlighted as such...
- m_mask = new wxMiniFrame(parent, wxID_ANY, wxEmptyString,
- m_currentRect.GetPosition(), m_currentRect.GetSize(),
- wxFRAME_FLOAT_ON_PARENT
- | wxFRAME_TOOL_WINDOW );
-
- // Can't set the bg colour of a Frame in wxMac
- wxPanel* p = new wxPanel(m_mask);
-
- // The default wxSYS_COLOUR_ACTIVECAPTION colour is a light silver
- // color that is really hard to see, especially transparent.
- // Until a better system color is decided upon we'll just use
- // blue.
- p->SetBackgroundColour(*wxBLUE);
-
- // So that even if the cursor run into the mask, the events are still correctly processed.
- p->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonDown ), NULL, this);
- p->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonUp ), NULL, this);
- p->Connect( wxEVT_MOTION, wxMouseEventHandler( CtrlMaskOut::OnMouseMoving ), NULL, this);
-#endif
-
- // If the platform doesn't support SetTransparent()
- // we will use a dummy mask(which does and shows nothing)
- // /this is the current trick, shall make it visible later
- if (!m_mask->CanSetTransparent())
- {
- m_mask->Destroy();
-
- m_mask = new wxPseudoTransparentFrame(parent,
- wxID_ANY,
- wxEmptyString,
- wxDefaultPosition,
- wxSize(1,1),
- wxFRAME_TOOL_WINDOW |
- wxFRAME_FLOAT_ON_PARENT |
- wxFRAME_NO_TASKBAR
- );
-
- }
-
- m_mask->SetTransparent(100); // Full value is 255
- m_mask->Show(true);
-
- // So that even if the cursor run into the mask, the events are still correctly processed.
- m_mask->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonDown ), NULL, this);
- m_mask->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonUp ), NULL, this);
- m_mask->Connect( wxEVT_MOTION, wxMouseEventHandler( CtrlMaskOut::OnMouseMoving ), NULL, this);
-}
-
-void CtrlMaskOut::DestroyMask()
-{
- m_mask->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonDown ), NULL, this);
- m_mask->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonUp ), NULL, this);
- m_mask->Disconnect( wxEVT_MOTION, wxMouseEventHandler( CtrlMaskOut::OnMouseMoving ), NULL, this);
- wxWindow * parent = m_mask->GetParent();
-// m_mask->Destroy();
- delete m_mask;
-
- parent->Update();
- m_mask = NULL;
-}
-
+++ /dev/null
-/////////////////////////////////////////////////////////////////////////////
-// Name: ctrlmaskout.h
-// Purpose: Defines the CtrlMaskOut class
-// Author: Utensil Candel (UtensilCandel@@gmail.com)
-// RCS-ID: $Id$
-// Licence: wxWindows license
-/////////////////////////////////////////////////////////////////////////////
-
-#ifndef _CTRLMASKOUT_H_
-#define _CTRLMASKOUT_H_
-
-#include "wx/filename.h"
-
-
-// ----------------------------------------------------------------------------
-// class CtrlMaskOut
-// ----------------------------------------------------------------------------
-
-class CtrlMaskOut : public wxEvtHandler
-{
-public:
- CtrlMaskOut();
- ~CtrlMaskOut();
-
-public:
- void OnLeftButtonDown(wxMouseEvent& event);
- void OnLeftButtonUp(wxMouseEvent& event);
- void OnMouseMoving(wxMouseEvent& event);
-
- void Capture(wxRect rect, wxString fileName);
- void Capture(int x, int y, int width, int height, wxString fileName);
-
- wxString GetDefaultDirectory() const
- { return m_defaultDir; }
- wxString GetDefaultDirectoryAbsPath() const
- {
- wxFileName output = wxFileName::DirName(GetDefaultDirectory());
- output.MakeAbsolute();
- return output.GetFullPath();
- }
-
-private:
- // Helper functions
- void CreateMask(wxWindow* parent);
- void DestroyMask();
- void DetermineCtrlNameAndRect();
-
- void OnTimingFinished(wxTimerEvent& event);
-
-
- // Data members
- wxString m_defaultDir;
-
- wxString m_controlName;
- wxRect m_currentRect;
- wxCoord m_inflateBorder;
-
- wxFrame * m_mask;
-
- bool m_isTiming;
-};
-
-#endif // _CTRLMASKOUT_H_
-
-
#include "guiframe.h"
-#include "bitmaps/play.xpm"
-#include "bitmaps/stop.xpm"
-
-
///////////////////////////////////////////////////////////////////////////
GUIFrame::GUIFrame( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style )
//Drop-down Controls
AddPanel_5();
+ m_notebook1->ChangeSelection(0);
+
bSizer0->Add( m_notebook1, 1, wxEXPAND | wxALL, 0 );
this->SetSizer( bSizer0 );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( GUIFrame::OnClose ) );
-
- m_notebook1->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( GUIFrame::OnNotebookPageChanged ), NULL, this );
- m_notebook1->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, wxNotebookEventHandler( GUIFrame::OnNotebookPageChanging ), NULL, this );
}
void GUIFrame::AddMenuBar()
m_menuCapFullScreen = new wxMenuItem( captureMenu, idMenuCapFullScreen, wxString( _("&Full Screen") ) + wxT('\t') + wxT("Ctrl+Alt+F"), _("Takes a screenshot of the entire screen."), wxITEM_NORMAL );
captureMenu->Append( m_menuCapFullScreen );
- m_menuCapRect = new wxMenuItem( captureMenu, idMenuCapRect, wxString( _("Regions<Begin>") ) + wxT('\t') + wxT("Ctrl+Alt+R"), _("Manually specify rectangular regions for the screenshots."), wxITEM_NORMAL );
- captureMenu->Append( m_menuCapRect );
-
- m_menuEndCapRect = new wxMenuItem( captureMenu, idMenuEndCapRect, wxString( _("Regions<End>") ) + wxT('\t') + wxT("Ctrl+Alt+E"), _("Stop manually generating screenshots."), wxITEM_NORMAL );
- captureMenu->Append( m_menuEndCapRect );
- m_menuEndCapRect->Enable( false );
-
wxMenuItem* m_menuCapAll;
m_menuCapAll = new wxMenuItem( captureMenu, idMenuCapAll, wxString( _("Capture All") ) + wxT('\t') + wxT("Ctrl+Alt+A"), _("Takes screenshots for all controls automatically."), wxITEM_NORMAL );
captureMenu->Append( m_menuCapAll );
this->Connect( m_menuSeeScr->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnSeeScreenshots ) );
this->Connect( m_menuFileQuit->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnQuit ) );
this->Connect( m_menuCapFullScreen->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnCaptureFullScreen ) );
- this->Connect( m_menuCapRect->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnCaptureRect ) );
- this->Connect( m_menuEndCapRect->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnEndCaptureRect ) );
this->Connect( m_menuCapAll->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnCaptureAllControls ) );
this->Connect( m_menuHelpAbout->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnAbout ) );
}
m_checkBox2->SetToolTip( _("wxCheckBox") );
fgSizer1->Add( m_checkBox2, 0, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL, 20 );
+ /*
+ NB: under wxGTK for the radio button "unchecked" to be unchecked, it's
+ important to put the wxRB_GROUP style on the first wxRadioButton
+ (the one "checked") and no flags on the second one.
+ */
m_radioBtn1 = new wxRadioButton( m_panel1, wxID_ANY, _("Checked"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP );
m_radioBtn1->SetValue( true );
m_radioBtn1->SetToolTip( _("wxRadioButton") );
fgSizer1->Add( m_spinBtn1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 20 );
m_scrollBar1 = new wxScrollBar( m_panel1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSB_HORIZONTAL );
+ m_scrollBar1->SetScrollbar(50, 1, 100, 1);
m_scrollBar1->SetToolTip( _("wxScrollBar") );
fgSizer1->Add( m_scrollBar1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 20 );
wxString m_checkList1Choices[] = { _("wxCheckListBox"), _("Item1"), _("Item2") };
int m_checkList1NChoices = sizeof( m_checkList1Choices ) / sizeof( wxString );
m_checkList1 = new wxCheckListBox( m_panel2, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_checkList1NChoices, m_checkList1Choices, 0 );
+ m_checkList1->Check(0);
fgSizer2->Add( m_checkList1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 20 );
m_listBox1 = new wxListBox( m_panel2, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
fgSizer2->Add( m_staticBox1, 1, wxALL|wxALIGN_CENTER_VERTICAL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 20 );
m_treeCtrl1 = new wxTreeCtrl( m_panel2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTR_DEFAULT_STYLE|wxSUNKEN_BORDER );
+ wxTreeItemId root = m_treeCtrl1->AddRoot(_("wxTreeCtrl"));
+ m_treeCtrl1->AppendItem(root, _("Node1"));
+ wxTreeItemId node2 = m_treeCtrl1->AppendItem(root, _("Node2"));
+ m_treeCtrl1->AppendItem(node2, _("Node3"));
+ m_treeCtrl1->ExpandAll();
fgSizer2->Add( m_treeCtrl1, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 20 );
m_listCtrl1 = new wxListCtrl( m_panel2, wxID_ANY, wxDefaultPosition, wxSize(220,120), wxLC_REPORT|wxSUNKEN_BORDER );
+ m_listCtrl1->InsertColumn(0, "Names");
+ m_listCtrl1->InsertColumn(1, "Values");
+ for(long index = 0; index < 5; index++) {
+ m_listCtrl1->InsertItem( index, wxString::Format(_("Item%d"),index));
+ m_listCtrl1->SetItem(index, 1, wxString::Format("%d", index));
+ }
m_listCtrl1->SetToolTip( _("wxListCtrl") );
fgSizer2->Add( m_listCtrl1, 1, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxEXPAND, 20 );
bSizer2->Add( m_textCtrl2, 0, wxBOTTOM|wxRIGHT|wxLEFT, 20 );
m_richText1 = new wxRichTextCtrl( m_panel3, wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( -1,-1 ), 0|wxVSCROLL|wxHSCROLL|wxNO_BORDER|wxWANTS_CHARS );
+ m_richText1->LoadFile(_T("richtext.xml"));
m_richText1->SetToolTip( _("wxRichTextCtrl") );
m_richText1->SetMinSize( wxSize( 200,200 ) );
bSizer2->Add( m_richText1, 0, wxALL, 20 );
fgSizer5->Add( m_fontPicker1, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 20 );
m_filePicker1 = new wxFilePickerCtrl( m_panel4, wxID_ANY, wxEmptyString, _("Select a file"), wxT("*.*"), wxDefaultPosition, wxDefaultSize, wxFLP_DEFAULT_STYLE, wxDefaultValidator, wxT("_FilePickerCtrl") );
+ #if defined(__WXMSW__)
+ const wxString a_file = "C:\\Windows\\explorer.exe";
+ #else
+ const wxString a_file = "/bin/bash";
+ #endif
+ m_filePicker1->SetPath(a_file);
m_filePicker1->SetToolTip( _("wxFilePickerCtrl") );
fgSizer5->Add( m_filePicker1, 0, wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxALL, 20 );
fgSizer5->Add( m_genericDirCtrl1, 1, wxEXPAND|wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 20 );
m_dirPicker1 = new wxDirPickerCtrl( m_panel4, wxID_ANY, wxEmptyString, _("Select a folder"), wxDefaultPosition, wxDefaultSize, wxDIRP_DEFAULT_STYLE, wxDefaultValidator, wxT("_DirPickerCtrl") );
+ #if defined(__WXMSW__)
+ const wxString a_dir = "C:\\Windows";
+ #else
+ const wxString a_dir = "/home";
+ #endif
+ m_dirPicker1->SetPath(a_dir);
m_dirPicker1->SetToolTip( _("wxDirPickerCtrl") );
fgSizer5->Add( m_dirPicker1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 20 );
m_comboBox1->Append( _("Item2") );
m_comboBox1->Append( _("Item3") );
m_comboBox1->Append( _("Item4") );
+ m_comboBox1->Select(0);
+ // To look better under gtk
+ #ifdef __WXGTK__
+ m_comboBox1->Delete(4);
+ #endif
fgSizer4->Add( m_comboBox1, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 20 );
fgSizer4->Add( 0, 120, 1, wxEXPAND, 5 );
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnSeeScreenshots ) );
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnQuit ) );
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnCaptureFullScreen ) );
- this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnCaptureRect ) );
- this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnEndCaptureRect ) );
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnCaptureAllControls ) );
this->Disconnect( wxID_ANY, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( GUIFrame::OnAbout ) );
- m_notebook1->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( GUIFrame::OnNotebookPageChanged ), NULL, this );
- m_notebook1->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, wxNotebookEventHandler( GUIFrame::OnNotebookPageChanging ), NULL, this );
}
enum
{
idMenuCapFullScreen = 1000,
- idMenuCapRect,
- idMenuEndCapRect,
- idMenuCapAll,
+ idMenuCapAll
};
wxMenuBar* mbar;
wxMenu* fileMenu;
wxMenu* captureMenu;
- wxMenuItem* m_menuCapRect;
- wxMenuItem* m_menuEndCapRect;
wxMenu* helpMenu;
wxStatusBar* statusBar;
virtual void OnSeeScreenshots( wxCommandEvent& event ){ event.Skip(); }
virtual void OnQuit( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCaptureFullScreen( wxCommandEvent& event ){ event.Skip(); }
- virtual void OnCaptureRect( wxCommandEvent& event ){ event.Skip(); }
- virtual void OnEndCaptureRect( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCaptureAllControls( wxCommandEvent& event ){ event.Skip(); }
virtual void OnAbout( wxCommandEvent& event ){ event.Skip(); }
- virtual void OnNotebookPageChanged( wxNotebookEvent& event ){ event.Skip(); }
- virtual void OnNotebookPageChanging( wxNotebookEvent& event ){ event.Skip(); }
private:
void AddMenuBar();
$(OBJS)\screenshotgen_screenshot_app.obj \
$(OBJS)\screenshotgen_screenshot_main.obj \
$(OBJS)\screenshotgen_guiframe.obj \
- $(OBJS)\screenshotgen_ctrlmaskout.obj \
$(OBJS)\screenshotgen_customcombo.obj \
$(OBJS)\screenshotgen_autocapture.obj
$(OBJS)\screenshotgen_guiframe.obj: .\guiframe.cpp
$(CXX) -q -c -P -o$@ $(SCREENSHOTGEN_CXXFLAGS) .\guiframe.cpp
-$(OBJS)\screenshotgen_ctrlmaskout.obj: .\ctrlmaskout.cpp
- $(CXX) -q -c -P -o$@ $(SCREENSHOTGEN_CXXFLAGS) .\ctrlmaskout.cpp
-
$(OBJS)\screenshotgen_customcombo.obj: .\customcombo.cpp
$(CXX) -q -c -P -o$@ $(SCREENSHOTGEN_CXXFLAGS) .\customcombo.cpp
$(OBJS)\screenshotgen_screenshot_app.o \
$(OBJS)\screenshotgen_screenshot_main.o \
$(OBJS)\screenshotgen_guiframe.o \
- $(OBJS)\screenshotgen_ctrlmaskout.o \
$(OBJS)\screenshotgen_customcombo.o \
$(OBJS)\screenshotgen_autocapture.o \
$(OBJS)\screenshotgen_screenshotgen_rc.o
$(OBJS)\screenshotgen_guiframe.o: ./guiframe.cpp
$(CXX) -c -o $@ $(SCREENSHOTGEN_CXXFLAGS) $(CPPDEPS) $<
-$(OBJS)\screenshotgen_ctrlmaskout.o: ./ctrlmaskout.cpp
- $(CXX) -c -o $@ $(SCREENSHOTGEN_CXXFLAGS) $(CPPDEPS) $<
-
$(OBJS)\screenshotgen_customcombo.o: ./customcombo.cpp
$(CXX) -c -o $@ $(SCREENSHOTGEN_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\screenshotgen_screenshot_app.obj \
$(OBJS)\screenshotgen_screenshot_main.obj \
$(OBJS)\screenshotgen_guiframe.obj \
- $(OBJS)\screenshotgen_ctrlmaskout.obj \
$(OBJS)\screenshotgen_customcombo.obj \
$(OBJS)\screenshotgen_autocapture.obj \
$(OBJS)\screenshotgen_screenshotgen.res
$(OBJS)\screenshotgen_guiframe.obj: .\guiframe.cpp
$(CXX) /c /nologo /TP /Fo$@ $(SCREENSHOTGEN_CXXFLAGS) .\guiframe.cpp
-$(OBJS)\screenshotgen_ctrlmaskout.obj: .\ctrlmaskout.cpp
- $(CXX) /c /nologo /TP /Fo$@ $(SCREENSHOTGEN_CXXFLAGS) .\ctrlmaskout.cpp
-
$(OBJS)\screenshotgen_customcombo.obj: .\customcombo.cpp
$(CXX) /c /nologo /TP /Fo$@ $(SCREENSHOTGEN_CXXFLAGS) .\customcombo.cpp
$(OBJS)\screenshotgen_screenshot_app.obj &
$(OBJS)\screenshotgen_screenshot_main.obj &
$(OBJS)\screenshotgen_guiframe.obj &
- $(OBJS)\screenshotgen_ctrlmaskout.obj &
$(OBJS)\screenshotgen_customcombo.obj &
$(OBJS)\screenshotgen_autocapture.obj
$(OBJS)\screenshotgen_guiframe.obj : .AUTODEPEND .\guiframe.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(SCREENSHOTGEN_CXXFLAGS) $<
-$(OBJS)\screenshotgen_ctrlmaskout.obj : .AUTODEPEND .\ctrlmaskout.cpp
- $(CXX) -bt=nt -zq -fo=$^@ $(SCREENSHOTGEN_CXXFLAGS) $<
-
$(OBJS)\screenshotgen_customcombo.obj : .AUTODEPEND .\customcombo.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(SCREENSHOTGEN_CXXFLAGS) $<
#include "wx/dir.h"
#include "screenshot_main.h"
-#include "ctrlmaskout.h"
#include "autocapture.h"
-#include "bitmaps/play.xpm"
-#include "bitmaps/stop.xpm"
-
-
// ----------------------------------------------------------------------------
// ScreenshotFrame
// ----------------------------------------------------------------------------
statusBar->SetStatusText(_("Welcome to the Automatic Screenshot Generator!"), 0);
#endif
- // We will hold one ctrlmaskout during the whole life time of the main frame
- m_maskout = new CtrlMaskOut();
-
- // At the begining, we are not specifying the rect region
- capturingRect = false;
-
- // Do some further customization on some controls generated by wxFormBuilder
- InitFBControls();
-}
-
-ScreenshotFrame::~ScreenshotFrame()
-{
- delete m_maskout;
-}
-
-/*
- Do some further customization on some controls.
-
- NB: under wxGTK for the radio button "unchecked" to be unchecked, it's
- important to put the wxRB_GROUP style on the first wxRadioButton
- (the one "checked") and no flags on the second one.
-*/
-void ScreenshotFrame::InitFBControls()
-{
- m_scrollBar1->SetScrollbar(50, 1, 100, 1);
-
- // Do the default selection for wxComboBox
- m_comboBox1->Select(0);
-
- // To look better under gtk
-#ifdef __WXGTK__
- m_comboBox1->Delete(4);
-#endif
-
- // Add a root and some nodes for wxTreeCtrl
- wxTreeItemId root = m_treeCtrl1->AddRoot(_("wxTreeCtrl"));
- m_treeCtrl1->AppendItem(root, _("Node1"));
- wxTreeItemId node2 = m_treeCtrl1->AppendItem(root, _("Node2"));
- m_treeCtrl1->AppendItem(node2, _("Node3"));
- m_treeCtrl1->ExpandAll();
-
- // Add items into wxListCtrl
- m_listCtrl1->InsertColumn(0, "Names");
- m_listCtrl1->InsertColumn(1, "Values");
- for(long index = 0; index < 5; index++) {
- m_listCtrl1->InsertItem( index, wxString::Format(_("Item%d"),index));
- m_listCtrl1->SetItem(index, 1, wxString::Format("%d", index));
- }
-
- // Init file and dir pickers
- wxString file, dir;
-#if defined(__WXMSW__)
- file = "C:\\Windows\\explorer.exe";
- dir = "C:\\Windows";
-#else
- file = "/bin/bash";
- dir = "/home";
-#endif
- m_filePicker1->SetPath(file);
- m_dirPicker1->SetPath(dir);
-
- // Check the first item in wxCheckListBox
- m_checkList1->Check(0);
-
- // Load richtext.xml into wxRichtextCtrl
- m_richText1->LoadFile(_T("richtext.xml"));
- //m_richText1->ShowPosition(335);
-
- // select first page in the main notebook ctrl
- m_notebook1->ChangeSelection(0);
-
// set minimum size hints
GetSizer()->SetSizeHints(this);
-
- // add bitmaps to the menus
- m_menuCapRect->SetBitmap( wxIcon(play_xpm) );
- m_menuEndCapRect->SetBitmap( wxIcon(stop_xpm) );
}
-
-
// ----------------------------------------------------------------------------
// ScreenshotFrame - event handlers
// ----------------------------------------------------------------------------
void ScreenshotFrame::OnSeeScreenshots(wxCommandEvent& WXUNUSED(event))
{
- wxFileName defaultDir = wxFileName::DirName(m_maskout->GetDefaultDirectory());
+ wxFileName defaultDir = wxFileName::DirName(GetDefaultDirectory());
defaultDir.MakeAbsolute();
// Check if defaultDir already existed
wxCoord screenWidth, screenHeight;
dcScreen.GetSize(&screenWidth, &screenHeight);
- m_maskout->Capture(0, 0, screenWidth, screenHeight, _T("fullscreen"));
+ const wxString fullscreen_filename = GetDefaultDirectoryAbsPath() + _T("fullscreen.png");
- // Inform the user
- wxMessageBox(_("A screenshot of the entire screen was saved as:\n\n ") +
- m_maskout->GetDefaultDirectoryAbsPath() + wxFileName::GetPathSeparator() + "fullscreen.png",
- _("Full screen capture"), wxICON_INFORMATION|wxOK, this);
-}
-
-void ScreenshotFrame::OnCaptureRect(wxCommandEvent& WXUNUSED(event))
-{
- capturingRect = true;
- wxMenuBar * menubar = this->GetMenuBar();
- menubar->FindItem(idMenuCapRect)->Enable(false);
- menubar->FindItem(idMenuEndCapRect)->Enable(true);
-
- wxWindow * thePage = m_notebook1->GetPage(m_notebook1->GetSelection());
+ wxBitmap fullscreen = AutoCaptureMechanism::Capture(0, 0, screenWidth, screenHeight);
- thePage->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonDown ), NULL, m_maskout);
- thePage->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonUp ), NULL, m_maskout);
- thePage->Connect( wxEVT_MOTION, wxMouseEventHandler( CtrlMaskOut::OnMouseMoving ), NULL, m_maskout);
-}
-
-void ScreenshotFrame::OnEndCaptureRect(wxCommandEvent& WXUNUSED(event))
-{
- capturingRect = false;
- wxMenuBar * menubar = this->GetMenuBar();
- menubar->FindItem(idMenuCapRect)->Enable(true);
- menubar->FindItem(idMenuEndCapRect)->Enable(false);
+ fullscreen.SaveFile(fullscreen_filename, wxBITMAP_TYPE_PNG);
- wxWindow * thePage = m_notebook1->GetPage(m_notebook1->GetSelection());
-
- thePage->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonDown ), NULL, m_maskout);
- thePage->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonUp ), NULL, m_maskout);
- thePage->Disconnect( wxEVT_MOTION, wxMouseEventHandler( CtrlMaskOut::OnMouseMoving ), NULL, m_maskout);
-}
-
-void ScreenshotFrame::OnNotebookPageChanging(wxNotebookEvent& event)
-{
- if (!capturingRect)
- {
- event.Skip();
- return;
- }
-
- wxWindow * thePage = m_notebook1->GetPage(event.GetOldSelection());
-
- thePage->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonDown ), NULL, m_maskout);
- thePage->Disconnect( wxEVT_LEFT_UP, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonUp ), NULL, m_maskout);
- thePage->Disconnect( wxEVT_MOTION, wxMouseEventHandler( CtrlMaskOut::OnMouseMoving ), NULL, m_maskout);
-
- event.Skip();
-}
-
-void ScreenshotFrame::OnNotebookPageChanged(wxNotebookEvent& event)
-{
- if (!capturingRect)
- {
- event.Skip();
- return;
- }
-
- wxWindow *thePage = m_notebook1->GetPage(event.GetSelection());
-
- thePage->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonDown ), NULL, m_maskout);
- thePage->Connect( wxEVT_LEFT_UP, wxMouseEventHandler( CtrlMaskOut::OnLeftButtonUp ), NULL, m_maskout);
- thePage->Connect( wxEVT_MOTION, wxMouseEventHandler( CtrlMaskOut::OnMouseMoving ), NULL, m_maskout);
-
- event.Skip();
+ wxMessageBox(_("A screenshot of the entire screen was saved as:\n\n ")
+ + fullscreen_filename,
+ _("Full screen capture"), wxICON_INFORMATION|wxOK, this);
}
void ScreenshotFrame::OnCaptureAllControls(wxCommandEvent& WXUNUSED(event))
{
- wxString dir = m_maskout->GetDefaultDirectoryAbsPath();
+ wxString dir = GetDefaultDirectoryAbsPath();
// check if there are other screenshots taken before
if (wxFileName::DirExists(dir))
#include "guiframe.h"
-class CtrlMaskOut;
-
-
class ScreenshotFrame : public GUIFrame
{
public:
ScreenshotFrame(wxFrame *frame);
- ~ScreenshotFrame();
+ ~ScreenshotFrame() {}
protected: // event handlers
virtual void OnSeeScreenshots( wxCommandEvent& event);
virtual void OnCaptureFullScreen( wxCommandEvent& event );
- virtual void OnCaptureRect( wxCommandEvent& event );
- virtual void OnEndCaptureRect( wxCommandEvent& event );
virtual void OnCaptureAllControls( wxCommandEvent& event );
- virtual void OnNotebookPageChanged( wxNotebookEvent& event );
- virtual void OnNotebookPageChanging( wxNotebookEvent& event );
private:
- // Helper functions
- void InitFBControls();
- // Data members
- bool capturingRect;
- CtrlMaskOut * m_maskout;
+ // Before a config class is written, these two functions are placed here.
+ // It's only a transition and they wil be removed soon
+ wxString GetDefaultDirectory() const { return _T("screenshots"); }
+
+ wxString GetDefaultDirectoryAbsPath() const
+ {
+ wxFileName output = wxFileName::DirName(GetDefaultDirectory());
+ output.MakeAbsolute();
+ return output.GetFullPath();
+ }
};
#endif // _SCREENSHOT_MAIN_H_
screenshot_app.cpp
screenshot_main.cpp
guiframe.cpp
- ctrlmaskout.cpp
customcombo.cpp
autocapture.cpp
</sources>
screenshot_app.h
screenshot_main.h
guiframe.h
- ctrlmaskout.h
customcombo.h
autocapture.h
</headers>
# End Source File
# Begin Source File
-SOURCE=.\ctrlmaskout.cpp
-# End Source File
-# Begin Source File
-
SOURCE=.\customcombo.cpp
# End Source File
# Begin Source File
# End Source File
# Begin Source File
-SOURCE=.\ctrlmaskout.h
-# End Source File
-# Begin Source File
-
SOURCE=.\customcombo.h
# End Source File
# Begin Source File
<File
RelativePath=".\autocapture.cpp">
</File>
- <File
- RelativePath=".\ctrlmaskout.cpp">
- </File>
<File
RelativePath=".\customcombo.cpp">
</File>
<File
RelativePath=".\autocapture.h">
</File>
- <File
- RelativePath=".\ctrlmaskout.h">
- </File>
<File
RelativePath=".\customcombo.h">
</File>
RelativePath=".\autocapture.cpp"
>
</File>
- <File
- RelativePath=".\ctrlmaskout.cpp"
- >
- </File>
<File
RelativePath=".\customcombo.cpp"
>
RelativePath=".\autocapture.h"
>
</File>
- <File
- RelativePath=".\ctrlmaskout.h"
- >
- </File>
<File
RelativePath=".\customcombo.h"
>
RelativePath=".\autocapture.cpp"\r
>\r
</File>\r
- <File\r
- RelativePath=".\ctrlmaskout.cpp"\r
- >\r
- </File>\r
<File\r
RelativePath=".\customcombo.cpp"\r
>\r
RelativePath=".\autocapture.h"\r
>\r
</File>\r
- <File\r
- RelativePath=".\ctrlmaskout.h"\r
- >\r
- </File>\r
<File\r
RelativePath=".\customcombo.h"\r
>\r