other cleanup; adjusted english in the UI
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56121 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -25,43 +25,15 @@
|
||||
|
||||
#include <wx/dir.h>
|
||||
#include <wx/aboutdlg.h>
|
||||
#include <wx/msgdlg.h>
|
||||
#include <wx/dcscreen.h>
|
||||
#include <wx/filesys.h>
|
||||
#include <wx/utils.h>
|
||||
|
||||
#include "screenshot_main.h"
|
||||
#include "ctrlmaskout.h"
|
||||
#include "autocapture.h"
|
||||
|
||||
/*
|
||||
// Global helper functions
|
||||
enum wxBuildInfoFormat
|
||||
{
|
||||
short_f,
|
||||
long_f
|
||||
};
|
||||
|
||||
wxString wxbuildinfo(wxBuildInfoFormat format)
|
||||
{
|
||||
wxString wxbuild(wxVERSION_STRING);
|
||||
|
||||
if (format == long_f )
|
||||
{
|
||||
#if defined(__WXMSW__)
|
||||
wxbuild << _T("-Windows");
|
||||
#elif defined(__WXMAC__)
|
||||
wxbuild << _T("-Mac");
|
||||
#elif defined(__UNIX__)
|
||||
wxbuild << _T("-Linux");
|
||||
#endif
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
wxbuild << _T("-Unicode build");
|
||||
#else
|
||||
wxbuild << _T("-ANSI build");
|
||||
#endif // wxUSE_UNICODE
|
||||
}
|
||||
|
||||
return wxbuild;
|
||||
}*/
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// ScreenshotFrame
|
||||
@@ -75,11 +47,10 @@ ScreenshotFrame::ScreenshotFrame(wxFrame *frame)
|
||||
#endif
|
||||
{
|
||||
#if wxUSE_STATUSBAR
|
||||
statusBar->SetStatusText(_("Hello wxWidgets user!"), 0);
|
||||
// statusBar->SetStatusText(wxbuildinfo(short_f), 1);
|
||||
statusBar->SetStatusText(_("Welcome to the Automatic Screenshot Generator!"), 0);
|
||||
#endif
|
||||
|
||||
// We will hold one during the whole life time of the main frame
|
||||
// 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
|
||||
@@ -102,9 +73,8 @@ ScreenshotFrame::~ScreenshotFrame()
|
||||
/*
|
||||
Do some further customization on some controls generated by wxFormBuilder.
|
||||
|
||||
Some controls can only be generated by wxFormBuilder without further
|
||||
customization, e.g. unable to load a richtext file in a wxRichtextCtrl
|
||||
during initialization.
|
||||
wxFormBuilder does not allow customizations on some controls;
|
||||
e.g. you cannot load a richtext file in a wxRichtextCtrl during initialization.
|
||||
|
||||
Those customizations will be done here.
|
||||
*/
|
||||
@@ -120,12 +90,9 @@ void ScreenshotFrame::InitFBControls()
|
||||
|
||||
// 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
|
||||
@@ -137,7 +104,13 @@ void ScreenshotFrame::InitFBControls()
|
||||
|
||||
// Load richtext.xml into wxRichtextCtrl
|
||||
m_richText1->LoadFile(_T("richtext.xml"));
|
||||
m_richText1->ShowPosition(335);
|
||||
//m_richText1->ShowPosition(335);
|
||||
|
||||
// select first page in the main notebook ctrl
|
||||
m_notebook1->ChangeSelection(0);
|
||||
|
||||
// set minimum size hints
|
||||
GetSizer()->SetSizeHints(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -161,21 +134,11 @@ void ScreenshotFrame::OnSeeScreenshots(wxCommandEvent& WXUNUSED(event))
|
||||
wxString defaultDir = m_maskout->GetDefaultDirectory();
|
||||
|
||||
// Check if defaultDir already existed
|
||||
if(!wxDirExists(defaultDir))
|
||||
if (!wxDirExists(defaultDir))
|
||||
wxMkdir(defaultDir);
|
||||
|
||||
// Use the native file browser to open defaultDir
|
||||
#if defined(__WXMSW__)
|
||||
wxExecute(_T("explorer ") + defaultDir);
|
||||
#elif defined(__UNIX__) // nautilus is the GNOME file browser but works also for KDE
|
||||
wxExecute(_T("nautilus ") + defaultDir);
|
||||
#elif defined(_WXMAC_)
|
||||
wxExecute(_T("open ") + defaultDir);
|
||||
#else
|
||||
wxMessageBox(_("Sorry, not Implemeted for this platform yet! Please open subdirectory \"")
|
||||
+ defaultDir
|
||||
+ _("\" manually.") );
|
||||
#endif
|
||||
wxLaunchDefaultBrowser(wxFileSystem::FileNameToURL(defaultDir));
|
||||
}
|
||||
|
||||
void ScreenshotFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -199,6 +162,11 @@ void ScreenshotFrame::OnCaptureFullScreen(wxCommandEvent& WXUNUSED(event))
|
||||
dcScreen.GetSize(&screenWidth, &screenHeight);
|
||||
|
||||
m_maskout->Capture(0, 0, screenWidth, screenHeight, _T("fullscreen"));
|
||||
|
||||
// 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))
|
||||
@@ -260,7 +228,7 @@ wxNotebookEvent& event
|
||||
#endif
|
||||
)
|
||||
{
|
||||
if(!capturingRect)
|
||||
if (!capturingRect)
|
||||
{
|
||||
event.Skip();
|
||||
return;
|
||||
@@ -277,31 +245,35 @@ wxNotebookEvent& event
|
||||
|
||||
void ScreenshotFrame::OnCaptureAllControls(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString dir = wxT("screenshots");
|
||||
wxString dir = m_maskout->GetDefaultDirectoryAbsPath();
|
||||
|
||||
// check if there are other screenshots taken before
|
||||
if (wxFileName::DirExists(dir))
|
||||
{
|
||||
int choice = wxMessageBox(_("It seems that you have already generated some screenshots.\nClick YES to delete them all(recommended), NO to preserve them\nCANCEL to cancel this auto-capture(so you can save them elsewhere)."),
|
||||
_("Do you want to delete the existing screenshots?"),
|
||||
int choice = wxMessageBox(_("It seems that you have already generated some screenshots.\nClick YES to delete them all (recommended) or NO to preserve them.\nClick CANCEL to cancel this auto-capture operation."),
|
||||
_("Delete existing screenshots?"),
|
||||
wxYES_NO|wxCANCEL|wxICON_QUESTION, this);
|
||||
switch(choice)
|
||||
{
|
||||
case wxYES :
|
||||
case wxYES:
|
||||
{
|
||||
wxArrayString files;
|
||||
wxDir::GetAllFiles(dir, &files, wxT("*.png"), wxDIR_FILES);
|
||||
|
||||
// remove all PNG files from the screenshots folder
|
||||
int n = files.GetCount();
|
||||
for (int i = 0; i < n; ++i)
|
||||
wxRemoveFile(files[i]);
|
||||
}
|
||||
break;
|
||||
|
||||
case wxNO : break;
|
||||
case wxCANCEL : return;
|
||||
case wxNO: break;
|
||||
case wxCANCEL: return;
|
||||
}
|
||||
}
|
||||
|
||||
// proceed with the automatic screenshot capture
|
||||
|
||||
this->Maximize();
|
||||
|
||||
AutoCaptureMechanism auto_cap(m_notebook1);
|
||||
@@ -363,6 +335,6 @@ void ScreenshotFrame::OnCaptureAllControls(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
auto_cap.CaptureAll();
|
||||
|
||||
wxMessageBox(_("All screenshots are generated successfully.\nSelect \"File->See screenshots\" to see them."),
|
||||
_("Success"), wxOK, this);
|
||||
wxMessageBox(_("All screenshots were generated successfully in the folder:\n ") + dir,
|
||||
_("Success"), wxOK|wxICON_INFORMATION, this);
|
||||
}
|
||||
|
Reference in New Issue
Block a user