]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/screenshotgen/src/screenshot_main.cpp
support underlined text in wxCairoContext (Marcin's patch) (closes #9846)
[wxWidgets.git] / utils / screenshotgen / src / screenshot_main.cpp
index a2bc1e7d6dd273b1953ddb71a63fc09befa116f2..3555bed5c061a4a2c26c608361677c385fa1364d 100644 (file)
@@ -1,6 +1,6 @@
 /////////////////////////////////////////////////////////////////////////////
 // Name:        screenshot_main.cpp
-// Purpose:     Implement the Application Frame
+// Purpose:     Implements the window containing all controls.
 // Author:      Utensil Candel (UtensilCandel@@gmail.com)
 // RCS-ID:      $Id$
 // Licence:     wxWindows license
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
-    #pragma hdrstop
+#pragma hdrstop
 #endif
 
-// for all others, include the necessary headers
+// for all others, include the necessary headers wxWidgets headers)
 #ifndef WX_PRECOMP
-    #include <wx/filename.h>
-    #include <wx/dcbuffer.h>
-    #include <wx/colordlg.h>
-    #include <wx/fontdlg.h>
-    #include <wx/filedlg.h>
-    #include <wx/dirdlg.h>
+#include "wx/wx.h"
 #endif
 
-#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 "wx/aboutdlg.h"
+#include "wx/dir.h"
 
 #include "screenshot_main.h"
 #include "ctrlmaskout.h"
 // ScreenshotFrame
 // ----------------------------------------------------------------------------
 
-ScreenshotFrame::ScreenshotFrame(wxFrame *frame)
-#if SCREENSHOTGEN_USE_AUI
-: AuiGUIFrame(frame)
-#else
-: GUIFrame(frame)
-#endif
+ScreenshotFrame::ScreenshotFrame(wxFrame *frame) : GUIFrame(frame)
 {
 #if wxUSE_STATUSBAR
     statusBar->SetStatusText(_("Welcome to the Automatic Screenshot Generator!"), 0);
@@ -61,11 +47,6 @@ ScreenshotFrame::ScreenshotFrame(wxFrame *frame)
 
     // Do some further customization on some controls generated by wxFormBuilder
     InitFBControls();
-#if SCREENSHOTGEN_USE_AUI
-    // Somehow it will be very small after I move to Aui
-    SetSize(600, 600);
-    // Maximize(true);
-#endif
 }
 
 ScreenshotFrame::~ScreenshotFrame()
@@ -74,13 +55,7 @@ ScreenshotFrame::~ScreenshotFrame()
 }
 
 /*
-    Do some further customization on some controls generated by wxFormBuilder.
-
-    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.
-
+    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
@@ -88,7 +63,6 @@ ScreenshotFrame::~ScreenshotFrame()
 */
 void ScreenshotFrame::InitFBControls()
 {
-    // For some reason, wxFormBuilder does not set the scrollbar range
     m_scrollBar1->SetScrollbar(50, 1, 100, 1);
 
     // Do the default selection for wxComboBox
@@ -107,24 +81,24 @@ void ScreenshotFrame::InitFBControls()
     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->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->SetItem(index, 1, wxString::Format("%d", index));
+    }
 
-       // Init file and dir pickers
-       wxString file, dir;
+    // Init file and dir pickers
+    wxString file, dir;
 #if defined(__WXMSW__)
-       file = "C:\\Windows\\explorer.exe";
-       dir = "C:\\Windows";
+    file = "C:\\Windows\\explorer.exe";
+    dir = "C:\\Windows";
 #else
-       file = "/bin/bash";
-       dir = "/home";
+    file = "/bin/bash";
+    dir = "/home";
 #endif
-       m_filePicker1->SetPath(file);
-       m_dirPicker1->SetPath(dir);
+    m_filePicker1->SetPath(file);
+    m_dirPicker1->SetPath(dir);
 
     // Check the first item in wxCheckListBox
     m_checkList1->Check(0);
@@ -139,9 +113,9 @@ void ScreenshotFrame::InitFBControls()
     // set minimum size hints
     GetSizer()->SetSizeHints(this);
 
-       // add bitmaps to the menus
-       m_menuCapRect->SetBitmaps( wxIcon(play_xpm) );
-       m_menuEndCapRect->SetBitmaps( wxIcon(stop_xpm) );
+    // add bitmaps to the menus
+    m_menuCapRect->SetBitmap( wxIcon(play_xpm) );
+    m_menuEndCapRect->SetBitmap( wxIcon(stop_xpm) );
 }
 
 
@@ -162,14 +136,15 @@ void ScreenshotFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
 
 void ScreenshotFrame::OnSeeScreenshots(wxCommandEvent& WXUNUSED(event))
 {
-    wxString defaultDir = m_maskout->GetDefaultDirectory();
+    wxFileName defaultDir = wxFileName::DirName(m_maskout->GetDefaultDirectory());
+    defaultDir.MakeAbsolute();
 
     // Check if defaultDir already existed
-    if (!wxDirExists(defaultDir))
-        wxMkdir(defaultDir);
+    if (!defaultDir.DirExists())
+        defaultDir.Mkdir();
 
     // Use the native file browser to open defaultDir
-    wxLaunchDefaultBrowser(wxFileSystem::FileNameToURL(defaultDir));
+    wxLaunchDefaultBrowser(defaultDir.GetFullPath());
 }
 
 void ScreenshotFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
@@ -228,13 +203,7 @@ void ScreenshotFrame::OnEndCaptureRect(wxCommandEvent& WXUNUSED(event))
     thePage->Disconnect( wxEVT_MOTION, wxMouseEventHandler( CtrlMaskOut::OnMouseMoving ), NULL, m_maskout);
 }
 
-void ScreenshotFrame::OnNotebookPageChanging(
-#if SCREENSHOTGEN_USE_AUI
-wxAuiNotebookEvent& event
-#else
-wxNotebookEvent& event
-#endif
-)
+void ScreenshotFrame::OnNotebookPageChanging(wxNotebookEvent& event)
 {
     if (!capturingRect)
     {
@@ -251,13 +220,7 @@ wxNotebookEvent& event
     event.Skip();
 }
 
-void ScreenshotFrame::OnNotebookPageChanged(
-#if SCREENSHOTGEN_USE_AUI
-wxAuiNotebookEvent& event
-#else
-wxNotebookEvent& event
-#endif
-)
+void ScreenshotFrame::OnNotebookPageChanged(wxNotebookEvent& event)
 {
     if (!capturingRect)
     {
@@ -321,7 +284,7 @@ void ScreenshotFrame::OnCaptureAllControls(wxCommandEvent& WXUNUSED(event))
     auto_cap.RegisterControl(m_slider1);
     auto_cap.RegisterControl(m_toggleBtn1, AJ_Union);
     auto_cap.RegisterControl(m_toggleBtn2, AJ_UnionEnd);
-    auto_cap.RegisterControl(m_hyperlink1);
+    auto_cap.RegisterControl(m_hyperlink1, wxT("wxHyperlinkCtrl"));
     auto_cap.RegisterControl(m_spinCtrl1, AJ_RegionAdjust);
     auto_cap.RegisterControl(m_spinBtn1);
     auto_cap.RegisterControl(m_scrollBar1);