wxIScan
wxiscanframe.cpp File Reference
#include "wx_pch.h"
#include <wx/string.h>
#include <wx/intl.h>
#include <wx/bitmap.h>
#include <wx/icon.h>
#include <wx/image.h>
#include <wx/artprov.h>
#include <wx/accel.h>
#include <wx/clipbrd.h>
#include <wx/config.h>
#include <wx/fileconf.h>
#include <wx/filename.h>
#include <wx/pdfdoc.h>
#include <wx/print.h>
#include <wx/printdlg.h>
#include <wx/stdpaths.h>
#include <wx/txtstrm.h>
#include "wxextprocess.h"
#include "wxiscanabout.h"
#include "wxiscanapp.h"
#include "wxiscanframe.h"
#include "wxiscanglobals.h"
#include "wxiscanluascript.h"
#include "wxiscanresources.h"
#include "wxchainlogtextctrl.h"
#include "wxiviewprintout.h"
#include "wxoptionsdialog.h"
#include "wxtextctrlcolourizer.h"
#include "lua5.1/lua.hpp"

Go to the source code of this file.

Functions

 wx__DECLARE_EVT0 (wxEVT_EXTFILEDROP,(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent(wxExtFileDropEventEventFunction,&wxIScanFrame::OnFileDrop)) wx__DECLARE_EVT0(wxEVT_IVIEWCANVASSIZE
() wxObjectEventFunction (wxEventFunction) wxStaticCastEvent(wxIViewCanvasSizeEventEventFunction
()&wxIScanFrame::OnCanvasSize wx__DECLARE_EVT0 (wxEVT_IVIEWCANVASSELECTED,(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent(wxIViewCanvasSelectedEventEventFunction,&wxIScanFrame::OnCanvasSelected)) wxIScanFrame

Variables

static const wxString cstrwxFrame = wxT( "wxIScanFrame" )

Function Documentation

wx__DECLARE_EVT0 ( wxEVT_EXTFILEDROP  ,
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent(wxExtFileDropEventEventFunction,&wxIScanFrame::OnFileDrop)   
)
() & wxIScanFrame::OnCanvasSize wx__DECLARE_EVT0 ( wxEVT_IVIEWCANVASSELECTED  ,
(wxObjectEventFunction)(wxEventFunction) wxStaticCastEvent(wxIViewCanvasSelectedEventEventFunction,&wxIScanFrame::OnCanvasSelected)   
)

Definition at line 156 of file wxiscanframe.cpp.

References cmdstop_xpm, cstrAppName, cstrStatusCopyRight, cstrVersionString, cstrwxFrame, documentfirstpage_xpm, documentlastpage_xpm, documentnextpage_xpm, documentpreviouspage_xpm, documentreadtext_xpm, fileprintpreviewbmp_xpm, fileprintsetupbmp_xpm, filescanimagebmp_xpm, wxIScanFrame::OnClose(), wxIScanFrame::OnCmdStop(), wxIScanFrame::OnDocumentApplyProfile(), wxIScanFrame::OnDocumentCopyText(), wxIScanFrame::OnDocumentCrop(), wxIScanFrame::OnDocumentFirstPage(), wxIScanFrame::OnDocumentLastPage(), wxIScanFrame::OnDocumentNextPage(), wxIScanFrame::OnDocumentPreviousPage(), wxIScanFrame::OnDocumentProfilesChooseProfile(), wxIScanFrame::OnDocumentReadText(), wxIScanFrame::OnDocumentRotate90Left(), wxIScanFrame::OnDocumentRotate90Right(), wxIScanFrame::OnDocumentZoom(), wxIScanFrame::OnEditClearHistory(), wxIScanFrame::OnEditClearLog(), wxIScanFrame::OnEditCopy(), wxIScanFrame::OnEditPaste(), wxIScanFrame::OnEditScanScanners(), wxIScanFrame::OnEditSettings(), wxIScanFrame::OnEditSettingsFile(), wxIScanFrame::OnFileOpen(), wxIScanFrame::OnFilePrint(), wxIScanFrame::OnFilePrintPreview(), wxIScanFrame::OnFilePrintSetup(), wxIScanFrame::OnFileQuit(), wxIScanFrame::OnFileSaveAs(), wxIScanFrame::OnFileScanImage(), wxIScanFrame::OnHelpAbout(), wxIScanFrame::OnPdfAddPage(), wxIScanFrame::OnPdfBeginPdf(), wxIScanFrame::OnPdfSavePdf(), wxIScanFrame::OnScriptStartScript(), wxIScanFrame::OnViewCloseDebugWindow(), wxIScanFrame::OnViewClosePreviewPanel(), wxIScanFrame::OnViewFit(), wxIScanFrame::OnViewFullScreen(), wxIViewCanvas::wxICANVAS_MOUSE_SCROLL, wxIViewCanvas::wxICANVAS_MOUSE_SELECTION, wxIViewCanvas::wxICANVAS_MOUSEWHEEL_SCROLL, wxISCAN_SCRIPTMENUPOS, wxiscanico_xpm, and wxObjectEventFunction().

  :
  m_bUILocked( false ),
  m_poScanner( NULL ),
  m_nScaleFactor( 1.0 ),
  m_nZoomFactor( 0.1 ),
  m_nProfileIndex( 0 ),
#if __WXPDFDOC__
  m_poPdfDoc( NULL ),
  m_nPdfPages( 0 ),
  m_bPdfDirty( false ),
#endif
#if __WXLUASCRIPT__
  bLuaReturnFromEventHandler( true ),
#endif // __WXLUASCRIPT__
  m_poRunningProcess( NULL ),
  m_oTextValidatorTextCtrlPage( wxFILTER_NUMERIC )
{
    //(*Initialize(wxIScanFrame)
    wxMenuItem* poOnDocumentZoom;
    wxMenu* poMenuHelp;
    wxMenuItem* poMenuSavePdf;
    wxMenuItem* poViewCustomSize;
    wxMenuItem* poDocumentRotate90Left;
    wxMenuItem* poViewZoomOut;
    wxMenuItem* poMenuFileOpen;
    wxMenuItem* poMenuFileSaveAs;
    wxMenuItem* poHelpAbout;
    wxMenuItem* poMenuCmdStop;
    wxMenuItem* poFileQuit;
    wxMenuItem* poMenuPdfBeginPdf;
    wxMenuItem* poMenuFileScanImage;
    wxMenuItem* poViewFitWidth;
    wxMenuItem* poMenuDocumentPreviousPage;
    wxMenuItem* poEditSettingsFile;
    wxMenuItem* poMenuFilePrint;
    wxMenuItem* poViewFullSize;
    wxMenuItem* poOnDocumentCrop;
    wxMenuItem* poEditClearHistory;
    wxMenu* poMenuDocument;
    wxMenuItem* poMenuFilePrintPreview;
    wxStatusBar* poStatusBar;
    wxMenuItem* poViewClosePreviewPanel;
    wxMenuItem* poMenuDocumentLastPage;
    wxMenuItem* poMenuDocumentReadText;
    wxMenuItem* poViewFullScreen;
    wxMenuItem* poViewFitWindow;
    wxMenuItem* poMenuPdfAddPage;
    wxMenuItem* poViewZoomIn;
    wxMenuItem* poEditSettings;
    wxToolBar* poToolBar;
    wxMenu* poMenuDocumentProfiles;
    wxMenuItem* poViewCloseDebugWindow;
    wxMenuItem* poDocumentApplyProfile;
    wxMenuItem* poMenuDocumentCopyText;
    wxMenuItem* poEditCopy;
    wxMenu* poMenuFile;
    wxMenu* poMenuPdf;
    wxMenuBar* poMenuBar;
    wxMenu* poView;
    wxMenuItem* poMenuFilePrintSetup;
    wxMenuItem* poEditPaste;
    wxMenuItem* poEditClearLog;
    wxMenuItem* poDocumentRotate90Right;
    wxMenuItem* poMenuDocumentFirstPage;
    wxMenuItem* poEditScanScanners;
    wxMenuItem* poMenuDocumentNextPage;

    Create(parent, wxID_ANY, _("wxIScan"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("wxID_ANY"));
    {
        wxIcon FrameIcon;
        FrameIcon.CopyFromBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_NORMAL_FILE")),wxART_FRAME_ICON));
        SetIcon(FrameIcon);
    }
    m_poHSplitterWindow = new wxSplitterWindow(this, ID_HSPLITTERWINDOW, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE, _T("ID_HSPLITTERWINDOW"));
    m_poHSplitterWindow->SetMinSize(wxSize(1,1));
    m_poHSplitterWindow->SetMinimumPaneSize(1);
    m_poHSplitterWindow->SetSashGravity(0);
    m_poVSplitterWindow = new wxSplitterWindow(m_poHSplitterWindow, ID_VSPLITTERWINDOW, wxDefaultPosition, wxDefaultSize, wxSP_3D|wxSP_LIVE_UPDATE, _T("ID_VSPLITTERWINDOW"));
    m_poVSplitterWindow->SetMinSize(wxSize(1,1));
    m_poVSplitterWindow->SetMinimumPaneSize(1);
    m_poVSplitterWindow->SetSashGravity(0);
    m_poCanvas = new wxIViewCanvas(m_poVSplitterWindow, ID_CANVAS, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL, _T("ID_CANVAS"));
    m_poPanelPages = new wxImagePanel(m_poVSplitterWindow, ID_PAGES, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER|wxVSCROLL|wxHSCROLL, _T("ID_PAGES"));
    m_poVSplitterWindow->SplitVertically(m_poCanvas, m_poPanelPages);
    m_poVSplitterWindow->SetSashPosition(1);
    m_poLogTextCtrl = new wxTextCtrl(m_poHSplitterWindow, ID_LOGTEXTCTRL, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxTE_AUTO_URL|wxTE_DONTWRAP, wxDefaultValidator, _T("ID_LOGTEXTCTRL"));
    m_poHSplitterWindow->SplitHorizontally(m_poVSplitterWindow, m_poLogTextCtrl);
    m_poHSplitterWindow->SetSashPosition(250);
    poMenuBar = new wxMenuBar();
    poMenuFile = new wxMenu();
    poMenuFileScanImage = new wxMenuItem(poMenuFile, ID_FILESCANIMAGE, _("Scan &Image\tCtrl+I"), _("Scan an image"), wxITEM_NORMAL);
    poMenuFile->Append(poMenuFileScanImage);
    poMenuFileScanImage= poMenuFile->Remove( ID_FILESCANIMAGE );
    poMenuFileScanImage->SetBitmap( filescanimagebmp_xpm );
    poMenuFile->Append( poMenuFileScanImage );
    poMenuFile->AppendSeparator();
    poMenuFileOpen = new wxMenuItem(poMenuFile, ID_FILEOPEN, _("&Open...\tCtrl+O"), _("Open an image file."), wxITEM_NORMAL);
    poMenuFileOpen->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_FILE_OPEN")),wxART_MENU));
    poMenuFile->Append(poMenuFileOpen);
    poMenuFileSaveAs = new wxMenuItem(poMenuFile, ID_FILESAVEAS, _("Save &as...\tCtrl+S"), _("Save scanned image to file."), wxITEM_NORMAL);
    poMenuFileSaveAs->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_FILE_SAVE_AS")),wxART_MENU));
    poMenuFile->Append(poMenuFileSaveAs);
    poMenuFileSaveAs->Enable(false);
    poMenuFile->AppendSeparator();
    poMenuFilePrint = new wxMenuItem(poMenuFile, ID_FILEPRINT, _("&Print...\tCtrl+P"), _("Print the current image."), wxITEM_NORMAL);
    poMenuFilePrint->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_PRINT")),wxART_MENU));
    poMenuFile->Append(poMenuFilePrint);
    poMenuFilePrint->Enable(false);
    poMenuFilePrintPreview = new wxMenuItem(poMenuFile, ID_FILEPRINTPREVIEW, _("Print pre&view\tCtrl+Alt+P"), _("Show a print preview of the current image."), wxITEM_NORMAL);
    poMenuFile->Append(poMenuFilePrintPreview);
    poMenuFilePrintPreview->Enable(false);
    poMenuFilePrintPreview= poMenuFile->Remove( ID_FILEPRINTPREVIEW );
    poMenuFilePrintPreview->SetBitmap( fileprintpreviewbmp_xpm );
    poMenuFile->Append( poMenuFilePrintPreview );
    poMenuFilePrintSetup = new wxMenuItem(poMenuFile, ID_FILEPRINTSETUP, _("Page setup"), _("Show page setup dialog."), wxITEM_NORMAL);
    poMenuFile->Append(poMenuFilePrintSetup);
    poMenuFilePrintSetup= poMenuFile->Remove( ID_FILEPRINTSETUP );
    poMenuFilePrintSetup->SetBitmap( fileprintsetupbmp_xpm );
    poMenuFile->Append( poMenuFilePrintSetup );
    poMenuFile->AppendSeparator();
    poFileQuit = new wxMenuItem(poMenuFile, ID_FILEQUIT, _("&Quit\tCtrl+Q"), _("Quit the application"), wxITEM_NORMAL);
    poFileQuit->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_QUIT")),wxART_MENU));
    poMenuFile->Append(poFileQuit);
    poMenuBar->Append(poMenuFile, _("&File"));
    poMenuEdit = new wxMenu();
    poEditCopy = new wxMenuItem(poMenuEdit, ID_EDITCOPY, _("&Copy\tCtrl+C"), _("Copy image to clipboard"), wxITEM_NORMAL);
    poEditCopy->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_COPY")),wxART_MENU));
    poMenuEdit->Append(poEditCopy);
    poEditCopy->Enable(false);
    poEditPaste = new wxMenuItem(poMenuEdit, ID_EDITPASTE, _("&Paste\tCtrl-V"), _("Inserts the content of the clipboard."), wxITEM_NORMAL);
    poEditPaste->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_PASTE")),wxART_TOOLBAR));
    poMenuEdit->Append(poEditPaste);
    poMenuEdit->AppendSeparator();
    poEditSettings = new wxMenuItem(poMenuEdit, ID_EDITSETTINGS, _("&Settings...\tCtrl-Alt-O"), _("Edit (most) settings in a dialog window."), wxITEM_NORMAL);
    poEditSettings->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_EXECUTABLE_FILE")),wxART_MENU));
    poMenuEdit->Append(poEditSettings);
    poEditSettingsFile = new wxMenuItem(poMenuEdit, ID_EDITSETTINGSFILE, _("Edit settings &file"), _("Edit settings file in a text editor."), wxITEM_NORMAL);
    poEditSettingsFile->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_HELP_SETTINGS")),wxART_MENU));
    poMenuEdit->Append(poEditSettingsFile);
    poMenuEdit->AppendSeparator();
    poEditScanScanners = new wxMenuItem(poMenuEdit, ID_EDITSCANSCANNERS, _("Scan for scanne&rs\tF4"), _("Scan for available scanning devices (USB, network etc.)."), wxITEM_NORMAL);
    poMenuEdit->Append(poEditScanScanners);
    poEditScanScanners= poMenuEdit->Remove( ID_EDITSCANSCANNERS );
    poEditScanScanners->SetBitmap( filescanimagebmp_xpm );
    poMenuEdit->Append( poEditScanScanners );
    poMenuEdit->AppendSeparator();
    poEditClearLog = new wxMenuItem(poMenuEdit, ID_EDITCLEARLOG, _("Clear &log\tF5"), _("Clear log window."), wxITEM_NORMAL);
    poEditClearLog->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_DELETE")),wxART_MENU));
    poMenuEdit->Append(poEditClearLog);
    poEditClearHistory = new wxMenuItem(poMenuEdit, ID_EDITCLEARHISTORY, _("Clear file &history"), _("Clear the file history."), wxITEM_NORMAL);
    poEditClearHistory->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_DEL_BOOKMARK")),wxART_MENU));
    poMenuEdit->Append(poEditClearHistory);
    poMenuBar->Append(poMenuEdit, _("&Edit"));
    poView = new wxMenu();
    poViewFullScreen = new wxMenuItem(poView, ID_VIEWFULLSCREEN, _("&Full screen\tF12"), _("View in full screen mode (no frame, no caption etc.)"), wxITEM_CHECK);
    poView->Append(poViewFullScreen);
    poView->AppendSeparator();
    poViewFitWidth = new wxMenuItem(poView, ID_VIEWFITWIDTH, _("Fit image to window w&idth\tI"), _("Zoom image to fit the window width."), wxITEM_CHECK);
    poView->Append(poViewFitWidth);
    poViewFitWindow = new wxMenuItem(poView, ID_VIEWFITWINDOW, _("Fit image to &window\tW"), _("Zoom image to fit the window size."), wxITEM_CHECK);
    poView->Append(poViewFitWindow);
    poViewFullSize = new wxMenuItem(poView, ID_VIEWFULLSIZE, _("View image in &original size\tO"), _("Show image in its original size (without any zooming)."), wxITEM_CHECK);
    poView->Append(poViewFullSize);
    poViewCustomSize = new wxMenuItem(poView, ID_VIEWCUSTOMSIZE, _("View image in &custom size\tC"), _("Zoom image to an explicit given (fixed) zoom factor."), wxITEM_CHECK);
    poView->Append(poViewCustomSize);
    poView->AppendSeparator();
    poViewZoomIn = new wxMenuItem(poView, ID_VIEWZOOMIN, _("Zoom &in\t+"), _("Zoom into the image."), wxITEM_NORMAL);
    poView->Append(poViewZoomIn);
    poViewZoomOut = new wxMenuItem(poView, ID_VIEWZOOMOUT, _("Zoom &out\t-"), _("Zoom out of the image."), wxITEM_NORMAL);
    poView->Append(poViewZoomOut);
    poOnDocumentZoom = new wxMenuItem(poView, ID_VIEWZOOMSELECTION, _("&Zoom selection\tZ"), _("Zoom the image along selection rectangle."), wxITEM_NORMAL);
    poView->Append(poOnDocumentZoom);
    poOnDocumentZoom->Enable(false);
    poView->AppendSeparator();
    poViewCloseDebugWindow = new wxMenuItem(poView, ID_VIEWCLOSEDEBUGWINDOW, _("Close the &debug window\tF2"), _("Close the debug window."), wxITEM_NORMAL);
    poView->Append(poViewCloseDebugWindow);
    poViewClosePreviewPanel = new wxMenuItem(poView, ID_VIEWCLOSEPREVIEWPANEL, _("Close the preview &panel\tF3"), _("Close the PDF preview panel."), wxITEM_NORMAL);
    poView->Append(poViewClosePreviewPanel);
    poMenuBar->Append(poView, _("&View"));
    poMenuDocument = new wxMenu();
    poMenuDocumentCopyText = new wxMenuItem(poMenuDocument, ID_DOCUMENTCOPYTEXT, _("Copy &text\tCtrl-Alt-C"), _("Copies via OCR detected text to the clipboard."), wxITEM_NORMAL);
    poMenuDocumentCopyText->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_COPY")),wxART_MENU));
    poMenuDocument->Append(poMenuDocumentCopyText);
    poMenuDocumentCopyText->Enable(false);
    poMenuDocumentReadText = new wxMenuItem(poMenuDocument, ID_DOCUMENTREADTEXT, _("&Read out document\tCtrl+Alt+R"), _("Reads the document through TTS."), wxITEM_NORMAL);
    poMenuDocument->Append(poMenuDocumentReadText);
    poMenuDocumentReadText->Enable(false);
    poMenuDocumentReadText= poMenuDocument->Remove( ID_DOCUMENTREADTEXT );
    poMenuDocumentReadText->SetBitmap( documentreadtext_xpm );
    poMenuDocument->Append( poMenuDocumentReadText );
    poMenuCmdStop = new wxMenuItem(poMenuDocument, ID_CMDSTOP, _("&Stop\tCtrl-Alt-E"), _("Stop background action."), wxITEM_NORMAL);
    poMenuDocument->Append(poMenuCmdStop);
    poMenuCmdStop->Enable(false);
    poMenuCmdStop= poMenuDocument->Remove( ID_CMDSTOP );
    poMenuCmdStop->SetBitmap( cmdstop_xpm );
    poMenuDocument->Append( poMenuCmdStop );
    poMenuDocument->AppendSeparator();
    poMenuDocumentFirstPage = new wxMenuItem(poMenuDocument, ID_DOCUMENTFIRSTPAGE, _("&First page\tCtrl+Home"), _("Go to first document page."), wxITEM_NORMAL);
    poMenuDocument->Append(poMenuDocumentFirstPage);
    poMenuDocumentFirstPage->Enable(false);
    poMenuDocumentFirstPage= poMenuDocument->Remove( ID_DOCUMENTFIRSTPAGE );
    poMenuDocumentFirstPage->SetBitmap( documentfirstpage_xpm );
    poMenuDocument->Append( poMenuDocumentFirstPage );
    poMenuDocumentPreviousPage = new wxMenuItem(poMenuDocument, ID_DOCUMENTPREVIOUSPAGE, _("&Previous page\tCtrl+PageUp"), _("Go to previous document page."), wxITEM_NORMAL);
    poMenuDocument->Append(poMenuDocumentPreviousPage);
    poMenuDocumentPreviousPage->Enable(false);
    poMenuDocumentPreviousPage= poMenuDocument->Remove( ID_DOCUMENTPREVIOUSPAGE );
    poMenuDocumentPreviousPage->SetBitmap( documentpreviouspage_xpm );
    poMenuDocument->Append( poMenuDocumentPreviousPage );
    poMenuDocumentNextPage = new wxMenuItem(poMenuDocument, ID_DOCUMENTNEXTPAGE, _("&Next page\tCtrl+PageDown"), _("Go to next document page."), wxITEM_NORMAL);
    poMenuDocument->Append(poMenuDocumentNextPage);
    poMenuDocumentNextPage->Enable(false);
    poMenuDocumentNextPage= poMenuDocument->Remove( ID_DOCUMENTNEXTPAGE );
    poMenuDocumentNextPage->SetBitmap( documentnextpage_xpm );
    poMenuDocument->Append( poMenuDocumentNextPage );
    poMenuDocumentLastPage = new wxMenuItem(poMenuDocument, ID_DOCUMENTLASTPAGE, _("&Last page\tCtrl+End"), _("Go to last document page."), wxITEM_NORMAL);
    poMenuDocument->Append(poMenuDocumentLastPage);
    poMenuDocumentLastPage->Enable(false);
    poMenuDocumentLastPage= poMenuDocument->Remove( ID_DOCUMENTLASTPAGE );
    poMenuDocumentLastPage->SetBitmap( documentlastpage_xpm );
    poMenuDocument->Append( poMenuDocumentLastPage );
    poMenuDocument->AppendSeparator();
    poDocumentRotate90Left = new wxMenuItem(poMenuDocument, ID_DOCUMENTROTATE90LEFT, _("Rotate 90 degress &left\tL"), _("Rotate 90 degress left"), wxITEM_NORMAL);
    poDocumentRotate90Left->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_UNDO")),wxART_MENU));
    poMenuDocument->Append(poDocumentRotate90Left);
    poDocumentRotate90Left->Enable(false);
    poDocumentRotate90Right = new wxMenuItem(poMenuDocument, ID_DOCUMENTROTATE90RIGHT, _("Rotate 90 degress &right\tR"), _("Rotate 90 degress right"), wxITEM_NORMAL);
    poDocumentRotate90Right->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_REDO")),wxART_MENU));
    poMenuDocument->Append(poDocumentRotate90Right);
    poDocumentRotate90Right->Enable(false);
    poOnDocumentCrop = new wxMenuItem(poMenuDocument, ID_DOCUMENTCROP, _("&Crop selection\tCtrl+Y"), _("Crop the image along selection rectangle."), wxITEM_NORMAL);
    poOnDocumentCrop->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_CUT")),wxART_MENU));
    poMenuDocument->Append(poOnDocumentCrop);
    poOnDocumentCrop->Enable(false);
    poMenuDocument->AppendSeparator();
    poDocumentApplyProfile = new wxMenuItem(poMenuDocument, ID_DOCUMENTAPPLYPROFILE, _("&Apply profile\tp"), _("Apply the current selected image profile to the image."), wxITEM_NORMAL);
    poMenuDocument->Append(poDocumentApplyProfile);
    poDocumentApplyProfile->Enable(false);
    poMenuDocumentProfiles = new wxMenu();
    poMenuDocumentProfiles->AppendSeparator();
    poMenuDocument->Append(ID_MENUDOCUMENTPROFILES, _("&Profiles"), poMenuDocumentProfiles, wxEmptyString);
    poMenuBar->Append(poMenuDocument, _("&Document"));
    poMenuPdf = new wxMenu();
    poMenuPdfBeginPdf = new wxMenuItem(poMenuPdf, ID_PDFBEGINPDF, _("&Begin PDF\tCtrl+Alt+N"), _("Start a new PDF document."), wxITEM_NORMAL);
    poMenuPdfBeginPdf->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_NEW")),wxART_MENU));
    poMenuPdf->Append(poMenuPdfBeginPdf);
    poMenuPdfBeginPdf->Enable(false);
    poMenuPdfAddPage = new wxMenuItem(poMenuPdf, ID_PDFADDPAGE, _("&Add Page\tCtrl++"), _("Add image as new page to the PDF document."), wxITEM_NORMAL);
    poMenuPdfAddPage->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_ADD_BOOKMARK")),wxART_MENU));
    poMenuPdf->Append(poMenuPdfAddPage);
    poMenuPdfAddPage->Enable(false);
    poMenuPdf->AppendSeparator();
    poMenuSavePdf = new wxMenuItem(poMenuPdf, ID_PDFSAVEASPDF, _("Save &PDF...\tCtrl+Shift+S"), _("Save image as PDF file."), wxITEM_NORMAL);
    poMenuSavePdf->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_FILE_SAVE")),wxART_MENU));
    poMenuPdf->Append(poMenuSavePdf);
    poMenuSavePdf->Enable(false);
    poMenuBar->Append(poMenuPdf, _("&PDF"));
    poMenuHelp = new wxMenu();
    poHelpAbout = new wxMenuItem(poMenuHelp, ID_HELPABOUT, _("&About\tCtrl-Alt-I"), _("Show info about this application"), wxITEM_NORMAL);
    poHelpAbout->SetBitmap(wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_INFORMATION")),wxART_MENU));
    poMenuHelp->Append(poHelpAbout);
    poMenuBar->Append(poMenuHelp, _("&Help"));
    SetMenuBar(poMenuBar);
    poStatusBar = new wxStatusBar(this, wxID_ANY, 0, _T("wxID_ANY"));
    int __wxStatusBarWidths_1[4] = { -3, 80, 80, -2 };
    int __wxStatusBarStyles_1[4] = { wxSB_FLAT, wxSB_FLAT, wxSB_FLAT, wxSB_FLAT };
    poStatusBar->SetFieldsCount(4,__wxStatusBarWidths_1);
    poStatusBar->SetStatusStyles(4,__wxStatusBarStyles_1);
    SetStatusBar(poStatusBar);
    poToolBar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_VERTICAL|wxNO_BORDER, _T("wxID_ANY"));
    ToolBarItem1 = poToolBar->AddTool(ID_FILESCANIMAGE_TB, _("Scan"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_MISSING_IMAGE")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Scan"), _("Scan an image"));
    poToolBar->AddSeparator();
    ToolBarItem2 = poToolBar->AddTool(ID_FILEOPEN_TB, _("Open"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_FILE_OPEN")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Open file"), _("Open an image file."));
    ToolBarItem3 = poToolBar->AddTool(ID_FILESAVEAS_TB, _("Save as"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_FILE_SAVE_AS")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Save as"), _("Save scanned image to file."));
    ToolBarItem4 = poToolBar->AddTool(ID_FILEPRINT_TB, _("Print"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_PRINT")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Print"), _("Print the current image."));
    poToolBar->AddSeparator();
    ToolBarItem5 = poToolBar->AddTool(ID_PDFBEGINPDF_TB, _("Begin PDF"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_NEW")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Begin PDF"), _("Start a new PDF document."));
    ToolBarItem6 = poToolBar->AddTool(ID_PDFADDPAGE_TB, _("Add Page"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_ADD_BOOKMARK")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Add PDF Page"), _("Add image as new page to the PDF document."));
    ToolBarItem7 = poToolBar->AddTool(ID_PDFSAVEASPDF_TB, _("Save PDF"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_FILE_SAVE_AS")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Save PDF"), _("Save image as PDF file."));
    poToolBar->AddSeparator();
    ToolBarItem8 = poToolBar->AddTool(ID_DOCUMENTFIRSTPAGE_TB, _("First page"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_GO_BACK")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("First page"), _("Go To first document page."));
    ToolBarItem9 = poToolBar->AddTool(ID_DOCUMENTPREVIOUSPAGE_TB, _("Previous page"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_GO_BACK")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Previous page"), _("Go to previous document page."));
    ToolBarItem10 = poToolBar->AddTool(ID_DOCUMENTNEXTPAGE_TB, _("Next page"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_GO_FORWARD")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Next page"), _("Go to next document page."));
    ToolBarItem11 = poToolBar->AddTool(ID_DOCUMENTLASTPAGE_TB, _("Last page"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_GO_FORWARD")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Last page"), _("Go to last document page."));
    poToolBar->AddSeparator();
    ToolBarItem12 = poToolBar->AddTool(ID_DOCUMENTREADTEXT_TB, _("Read out"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_HELP_BOOK")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Read out document via TTS."), _("Read out document via text-to-speach system."));
    ToolBarItem13 = poToolBar->AddTool(ID_CMDSTOP_TB, _("Stop"), wxArtProvider::GetBitmap(wxART_MAKE_ART_ID_FROM_STR(_T("wxART_ERROR")),wxART_TOOLBAR), wxNullBitmap, wxITEM_NORMAL, _("Stop background action."), _("Stop background action."));
    poToolBar->Realize();
    SetToolBar(poToolBar);

    Connect(ID_FILESCANIMAGE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnFileScanImage);
    Connect(ID_FILEOPEN,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnFileOpen);
    Connect(ID_FILESAVEAS,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnFileSaveAs);
    Connect(ID_FILEPRINT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnFilePrint);
    Connect(ID_FILEPRINTPREVIEW,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnFilePrintPreview);
    Connect(ID_FILEPRINTSETUP,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnFilePrintSetup);
    Connect(ID_FILEQUIT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnFileQuit);
    Connect(ID_EDITCOPY,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnEditCopy);
    Connect(ID_EDITPASTE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnEditPaste);
    Connect(ID_EDITSETTINGS,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnEditSettings);
    Connect(ID_EDITSETTINGSFILE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnEditSettingsFile);
    Connect(ID_EDITSCANSCANNERS,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnEditScanScanners);
    Connect(ID_EDITCLEARLOG,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnEditClearLog);
    Connect(ID_EDITCLEARHISTORY,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnEditClearHistory);
    Connect(ID_VIEWFULLSCREEN,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewFullScreen);
    Connect(ID_VIEWFITWIDTH,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewFit);
    Connect(ID_VIEWFITWINDOW,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewFit);
    Connect(ID_VIEWFULLSIZE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewFit);
    Connect(ID_VIEWCUSTOMSIZE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewFit);
    Connect(ID_VIEWZOOMIN,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewFit);
    Connect(ID_VIEWZOOMOUT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewFit);
    Connect(ID_VIEWZOOMSELECTION,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentZoom);
    Connect(ID_VIEWCLOSEDEBUGWINDOW,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewCloseDebugWindow);
    Connect(ID_VIEWCLOSEPREVIEWPANEL,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnViewClosePreviewPanel);
    Connect(ID_DOCUMENTCOPYTEXT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentCopyText);
    Connect(ID_DOCUMENTREADTEXT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentReadText);
    Connect(ID_CMDSTOP,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnCmdStop);
    Connect(ID_DOCUMENTFIRSTPAGE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentFirstPage);
    Connect(ID_DOCUMENTPREVIOUSPAGE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentPreviousPage);
    Connect(ID_DOCUMENTNEXTPAGE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentNextPage);
    Connect(ID_DOCUMENTLASTPAGE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentLastPage);
    Connect(ID_DOCUMENTROTATE90LEFT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentRotate90Left);
    Connect(ID_DOCUMENTROTATE90RIGHT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentRotate90Right);
    Connect(ID_DOCUMENTCROP,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentCrop);
    Connect(ID_DOCUMENTAPPLYPROFILE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentApplyProfile);
    Connect(ID_PDFBEGINPDF,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnPdfBeginPdf);
    Connect(ID_PDFADDPAGE,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnPdfAddPage);
    Connect(ID_PDFSAVEASPDF,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnPdfSavePdf);
    Connect(ID_HELPABOUT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&wxIScanFrame::OnHelpAbout);
    Connect(ID_FILESCANIMAGE_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnFileScanImage);
    Connect(ID_FILEOPEN_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnFileOpen);
    Connect(ID_FILESAVEAS_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnFileSaveAs);
    Connect(ID_FILEPRINT_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnFilePrint);
    Connect(ID_PDFBEGINPDF_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnPdfBeginPdf);
    Connect(ID_PDFADDPAGE_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnPdfAddPage);
    Connect(ID_PDFSAVEASPDF_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnPdfSavePdf);
    Connect(ID_DOCUMENTFIRSTPAGE_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentFirstPage);
    Connect(ID_DOCUMENTPREVIOUSPAGE_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentPreviousPage);
    Connect(ID_DOCUMENTNEXTPAGE_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentNextPage);
    Connect(ID_DOCUMENTLASTPAGE_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentLastPage);
    Connect(ID_DOCUMENTREADTEXT_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnDocumentReadText);
    Connect(ID_CMDSTOP_TB,wxEVT_COMMAND_TOOL_CLICKED,(wxObjectEventFunction)&wxIScanFrame::OnCmdStop);
    Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&wxIScanFrame::OnClose);
    //*)

    // Custom tool bar icons.
    GetToolBar()->SetToolNormalBitmap( ID_CMDSTOP_TB,              wxBitmap( cmdstop_xpm              ) );
    GetToolBar()->SetToolNormalBitmap( ID_DOCUMENTREADTEXT_TB,     wxBitmap( documentreadtext_xpm     ) );
    GetToolBar()->SetToolNormalBitmap( ID_DOCUMENTFIRSTPAGE_TB,    wxBitmap( documentfirstpage_xpm    ) );
    GetToolBar()->SetToolNormalBitmap( ID_DOCUMENTPREVIOUSPAGE_TB, wxBitmap( documentpreviouspage_xpm ) );
    GetToolBar()->SetToolNormalBitmap( ID_DOCUMENTNEXTPAGE_TB,     wxBitmap( documentnextpage_xpm     ) );
    GetToolBar()->SetToolNormalBitmap( ID_DOCUMENTLASTPAGE_TB,     wxBitmap( documentlastpage_xpm     ) );
    GetToolBar()->SetToolNormalBitmap( ID_FILESCANIMAGE_TB,        wxBitmap( filescanimagebmp_xpm     ) );

    // Insert a text editor control to switch to a given page.
    m_poTextCtrlPage= new wxTextCtrl( GetToolBar(), ID_TEXTCTRLPAGE,
                                      wxEmptyString, wxDefaultPosition,
                                      wxSize( GetToolBar()->IsVertical() ? 22 : 44, -1 ),
                                      wxTE_PROCESS_ENTER,
                                      m_oTextValidatorTextCtrlPage );
    GetToolBar()->InsertControl( 12, m_poTextCtrlPage );
    GetToolBar()->SetToolShortHelp( ID_TEXTCTRLPAGE, _( "Current page" ) );

#if __WXSCANSANE__
    // Insert a wxChoice object to change the scanning device in the toolbar.
    m_poChoiceScanner= new wxChoice( GetToolBar(), ID_CHOICESCANNER,
                                     wxDefaultPosition,
                                     wxSize( GetToolBar()->IsVertical() ? 22 : 150, -1 ) );
    GetToolBar()->InsertControl( 1, m_poChoiceScanner );
    GetToolBar()->SetToolShortHelp( ID_CHOICESCANNER, _( "Select a scanner" ) );
#endif // __WXSCANSANE__

    // Validate the toolbar.
    GetToolBar()->Realize();

    // Custom splitter window (sash) configuration.
    m_poHSplitterWindow->SetSashGravity( 1.0 );
    m_poVSplitterWindow->SetSashGravity( 1.0 );

//    // Custom key accelerators.
//    wxAcceleratorEntry aoAcceleratorEntries[1];
//    aoAcceleratorEntries[0].Set( wxACCEL_NORMAL, 'a', ID_CMDSTOP_TB );
//    wxAcceleratorTable oAcceleratorTable( WXSIZEOF( aoAcceleratorEntries ),
//                                          aoAcceleratorEntries );
//    SetAcceleratorTable( oAcceleratorTable );

    // Custom Initializations:
    //
    m_poCanvas->SetOptions(   wxIViewCanvas::wxICANVAS_MOUSE_SCROLL
                            | wxIViewCanvas::wxICANVAS_MOUSEWHEEL_SCROLL
                            | wxIViewCanvas::wxICANVAS_MOUSE_SELECTION );

    // Reset the image count, the page number and the image filename.
    ResetFileName();

#if defined( __WXPDFDOC__ ) && __WXPDFDOC__ >= 1
    // Initialize a new pdf document object.
    if( !CreateNewPdfDocument() )
    {
        wxLogFatalError( _( "Failed to create wxPdfDocument object." ) );
    }
#endif

    // Complete status bar information.
    SetStatusText( cstrStatusCopyRight, 3 );

    // Give the window an icon.
    SetIcon( wxiscanico_xpm );

    // Restore (most) settings.
    RestoreSettings();

    // Restore some additional settings (which should not be initialized twice).
    wxConfigBase *poConfig = wxConfigBase::Get();
    poConfig->SetRecordDefaults();
    poConfig->SetPath( wxT( "/" )  );
    poConfig->SetPath( cstrwxFrame );

    // Set style attributes to log text control:
    //
    // Read the font size from config file, ...
    int nFontSize= poConfig->Read( wxT( "FontSize" ), 8 );

    // ... get default text style parameters, and ...
    wxTextAttr oStyle( m_poLogTextCtrl->GetDefaultStyle() );

    // ... set some styling options (e. g. font).
    wxFont oFont( nFontSize, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL );

    oStyle.SetFont( oFont );
    m_poLogTextCtrl->SetDefaultStyle( oStyle );

    // Redirect logging to text control.
    int nMaxLogLevel= poConfig->Read( wxT( "MaxLogLevel" ), 2 );
    new wxChainLogTextCtrl( m_poLogTextCtrl, nMaxLogLevel );

    // Output a program version info to the log.
    wxLogMessage( wxT( "%s %s" ), cstrAppName.c_str(), cstrVersionString.c_str() );
    wxLogMessage( wxT( "----------------------------------------------------------" ) );

    // Restore profile settings.
    int nProfileIndex= poConfig->Read( wxT( "ProfileIndex" ), (long)0 );

    for( int i= 0; i < 999; i++ )
    {
        wxString strMenuItemText;
        wxString strProfileConfigPath= wxString::Format( wxT( "/Profile/%d" ), i );

        if( !poConfig->Exists( strProfileConfigPath ) )
        {
            break;
        }

        poConfig->SetPath( strProfileConfigPath );

        wxString strProfileName= poConfig->Read( wxT( "ProfileName" ), wxString::Format( wxT( "%d" ), i ) );

        if( i <= 9 )
        {
            strMenuItemText= wxString::Format( wxT( "&%d " ), i ) + strProfileName + wxString::Format( wxT( "\tCtrl+%d" ), i );
        }
        else
        {
            strMenuItemText= wxString::Format( wxT( "%d " ), i ) + strProfileName;
        }

        int nMenuID= ID_DOCUMENTPROFILE0 + i;

        poMenuDocumentProfiles->AppendCheckItem( nMenuID, strMenuItemText );
        Connect( nMenuID, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&wxIScanFrame::OnDocumentProfilesChooseProfile );
    }
    SetProfile( nProfileIndex );

#if __WXLUASCRIPT__
    GetMenuBar()->Insert( wxISCAN_SCRIPTMENUPOS, new wxMenu, _( "&Scripts" ) );

    // Restore scripting settings.
    m_nLuaCount= 0;
    for( int i= 0; i < 999; i++ )
    {
        if( !poConfig->Exists( wxString::Format( wxT( "/Script/%d" ), i ) ) )
        {
            break;
        }

        // Switch to the scripting sub section.
        poConfig->SetPath( wxString::Format( wxT( "/Script/%d" ), i ) );

        // Get the string for the menu entry and its help string.
        wxString strMenuItemText= poConfig->Read( wxT( "MenuEntry" ), wxString::Format( wxT( "Script%d" ), i ) );
        wxString strMenuItemHelpText= poConfig->Read( wxT( "MenuEntryHelp" ), wxEmptyString );

        // Get the menu from config file where the new menu entry should appear, ...
        wxString strMenuPosition= poConfig->Read( wxT( "MenuPosition" ), wxT( "&Scripts" ) );

        // ... get its position number in the menu bar, ...
        int nMenuPos= GetMenuBar()->FindMenu( ::wxGetTranslation( strMenuPosition ) );

        // ... check its existence, ...
        if( nMenuPos == wxNOT_FOUND )
        {
            wxLogError( _( "Cannot find menu '%s'. "
                             "The according script will not be reachable by menu entry '%s'." ),
                          strMenuPosition.c_str(),
                          strMenuItemText.c_str()
                        );
            break;
        }

        // ... gets the position of the menu item after it, and ..
        int nMenuItem= poConfig->Read( wxT( "MenuItem" ), 0L );

        // ... gets its menu ID.
        int nMenuID= ID_DOCUMENTPROFILE0 + 1000 + i;

        // Create the menu entry and connect its ID to the scripting event handler.
        GetMenuBar()->GetMenu( nMenuPos )->Insert( nMenuItem, nMenuID, strMenuItemText, strMenuItemHelpText );
        Connect( nMenuID, wxEVT_COMMAND_MENU_SELECTED, (wxObjectEventFunction)&wxIScanFrame::OnScriptStartScript );

        // Adjust script number counter.
        m_nLuaCount++;
    }
#endif // __WXLUASCRIPT__

    // Reset file history.
    poConfig->SetPath( wxT( "/Files" ) );
    m_oFileHistory.Load( *poConfig );

    // Delete file history entries of files that do not exist.
    for( int i= m_oFileHistory.GetCount() - 1; i >= 0; i-- )
    {
        wxString strFileName= m_oFileHistory.GetHistoryFile( i );

        if( !::wxFileExists( strFileName ) )
        {
            m_oFileHistory.RemoveFileFromHistory( i );
        }
    }

    // Add file history to the 'files' menu.
    m_oFileHistory.AddFilesToMenu( poMenuFile );
    m_oFileHistory.UseMenu( poMenuFile );

    // Set drop target.
    SetDropTarget( new wxExtFileDropTarget( this ) );

#if __WXSCANSANE__
    // Scan for scanning devices and create a scanner object.
    //
    // Note: A new wxScan object is created and EnableControls() called
    //       implicidly in an independent thread by ScanForScanners().
    //       So we don't have to do it here again.
    ScanForScanners( true );
#else
    // Create a scanner object.
    m_poScanner= new wxScan;

    // Switch (mostly disable) controls.
    EnableControls();
#endif // __WXSCANSANE__
}
() wxObjectEventFunction ( wxEventFunction  )

Referenced by wx__DECLARE_EVT0().


Variable Documentation

const wxString cstrwxFrame = wxT( "wxIScanFrame" ) [static]