wxIScan
wxIScanFrame Class Reference

The frame window class. More...

#include <wxiscanframe.h>

Inheritance diagram for wxIScanFrame:
wxIViewPaintBase

List of all members.

Public Types

enum  {
  wxCANVASFULLSIZE,
  wxCANVASFITWIDTH,
  wxCANVASFITWINDOW,
  wxCANVASCUSTOMSIZE
}

Public Member Functions

 wxIScanFrame (wxWindow *poParent, wxWindowID nId=wxID_ANY)
 Standard constructor.
virtual ~wxIScanFrame ()
 Virtual destructor.
virtual bool CanClose (bool bCanVeto=true)
 Handle window closing requests.
virtual bool OpenImage (const wxString &strFileName, bool bSetFileName=true)
 Open an image using the given name.
virtual bool OnDocumentPageChanged ()
 (Re)loads the (zero based) page number given in m_nPage.
virtual void UpdateBitmap ()
 Update the canvas bitmap.
virtual wxImage GetImageSelection ()
 Get the selected sub image.
virtual bool ScanImage ()
 Get an image from scanner.
virtual void SetProfile (int nProfileIndex)
 Select a profile (by number).
virtual void ApplyProfile ()
 Apply the selected profile to the image.
virtual void EnhenceOpticalContrast ()
 Enhance the optical contrast by replacing white by yellow.
virtual wxString OCR (const wxString &strTempFileName, bool bUseHocr=false)
 Call an external OCR software and return the filename of the resulting text file.
virtual bool ReadOut (bool bAsync=true)
 Do OCR and read out the returned text.
virtual bool Execute (const wxString &strCommand, bool bAsync=false, const wxString &strTempTextFileName=wxEmptyString)
 Fork an external process.
virtual bool CreateNewPdfDocument ()
 Create (and initialize) a new PDF document.
virtual bool AddPdfPage ()
 Add a new image/OCR text page to the existing PDF document.
virtual bool IsPdfDirty ()
 Check if the PDF dirty flag is set to TRUE.
virtual bool IsPortrait ()
 State if the image is in portrait direction.
virtual void ResetFileName ()
 Reset the filename to "unknown.jpg" etc.
virtual void LogProcessOutput (wxProcess *poProcess)
 Write a sub processes stdout and stderr output to the program's log.
virtual void UpdatePageNumber ()
 Update the page number info in the statusbar and in the toolbar.
virtual void ToggleFullScreen ()
 Toggle full screen mode.
virtual void RestoreSettings ()
 Restore program settings from config file.
virtual void RestoreSashSettings ()
 Restore sash settings from config file.
virtual void SaveSettings ()
 Save program settings in config file.
virtual void EnableControls ()
 Enable or disable controls according to the actual progam state.
virtual void LockUI (bool bLock=true)
 Locks/Unlocks the user interface.
virtual void UnlockUI ()
 Unlocks the user interface.
virtual void StartScript (const wxString &strScriptStartupFunction, wxString strScriptFileName=wxEmptyString)
 Start a Lua script from a give file.
virtual void AdjustOrientation ()
 ...
virtual bool GetPageSizeMM (int *pnWidth, int *pnHeight)
 Calculates the image extents in mm while printing or print previewing.
virtual int GetMaxPage ()
 Get the (zero based) page number of the last page.
virtual bool GotoPage (int nPage)
 Go to a given printer page.
virtual bool Paint (wxDC &oDc)
 Paints the image while printing or print previewing.

Private Member Functions

void AddPdfPageTraverseXmlNodes (wxXmlNode *poNode)
 DOM tree traverse helper function for AddPdfPage().
void OnFileQuit (wxCommandEvent &event)
 Handle menu command "File|Quit".
void OnFileScanImage (wxCommandEvent &event)
 Handle menu command "File|Scan image".
void OnFileOpen (wxCommandEvent &event)
 Handle menu command "File|Open...".
void OnFileSaveAs (wxCommandEvent &event)
 Handle menu command "File|Save as...".
void OnFilePrint (wxCommandEvent &oEvent)
 Handle menu command "File|Print".
void OnFilePrintPreview (wxCommandEvent &oEvent)
 Handle menu command "File|Print Preview".
void OnFilePrintSetup (wxCommandEvent &oEvent)
 Handle menu command "File|Page Setup ".
void OnEditCopy (wxCommandEvent &event)
 Copy the (selected part of the) image to the system clipboard.
void OnPdfBeginPdf (wxCommandEvent &event)
 Begin an new (empty) PDF document.
void OnDocumentCopyText (wxCommandEvent &event)
 Do OCR on the loaded/scanned image and copy the text to the system clipboard.
void OnDocumentReadText (wxCommandEvent &event)
 Do OCR on the loaded/scanned image and read the text out loud.
void OnDocumentFirstPage (wxCommandEvent &event)
 Go to first page of a multipage document.
void OnDocumentPreviousPage (wxCommandEvent &event)
 Go to previous page of a multipage document.
void OnDocumentNextPage (wxCommandEvent &event)
 Go to next page of a multipage document.
void OnDocumentLastPage (wxCommandEvent &event)
 Go to last page of a multipage document.
void OnDocumentRotate90Left (wxCommandEvent &event)
 Rotate image by 90° to the left.
void OnDocumentRotate90Right (wxCommandEvent &event)
 Rotate image by 90° to the right.
void OnDocumentApplyProfile (wxCommandEvent &event)
 Apply a previously selected profile to the image.
void OnPdfAddPage (wxCommandEvent &event)
 Add the current image as a new page to the current PDF document.
void OnPdfSavePdf (wxCommandEvent &event)
 Save the current PDF document as a PDF file.
void OnHelpAbout (wxCommandEvent &event)
 Handle menu command "Help|About...".
void OnCmdStop (wxCommandEvent &event)
 Handle (sub-)process killing.
void OnClose (wxCloseEvent &event)
 Handle window closing requests.
void OnEditPaste (wxCommandEvent &event)
 Replace the image by the content of the system clipboard.
void OnEditSettings (wxCommandEvent &event)
 Edit program settings (using an wxOptionsDialog window).
void OnEditSettingsFile (wxCommandEvent &event)
 Start the configured editor to edit the configuration file.
void OnDocumentCrop (wxCommandEvent &event)
 Crop the image to the selected rectangle.
void OnEditClearHistory (wxCommandEvent &event)
 Wipe out the file name history (under file menu).
void OnEditClearLog (wxCommandEvent &event)
 Wipe out the log window.
void OnDocumentZoom (wxCommandEvent &event)
 Zoom the image to the selected rectangle to fit the canvas size.
void OnViewFit (wxCommandEvent &event)
 Select an image fitting option.
void OnViewFullScreen (wxCommandEvent &event)
 Toggle full screen mode.
void OnEditScanScanners (wxCommandEvent &event)
 Scan for scanning devices and fill the corresponding wxChoice control in the toolbar.
void OnViewCloseDebugWindow (wxCommandEvent &event)
 Close the debug window.
void OnViewClosePreviewPanel (wxCommandEvent &event)
 Close the preview panel window.
void OnDocumentProfilesChooseProfile (wxCommandEvent &oEvent)
 Handle menu command "Document|Profile|[PROFILE #X]".
void OnScriptStartScript (wxCommandEvent &oEvent)
 Handle menu command "Scripts|[SCRIPT NAME]".
void OnMRUFiles (wxCommandEvent &oEvent)
 Handle menu command "File|[MOST RECENTLY USED FILE #X]".
void OnFileDrop (wxExtFileDropEvent &oEvent)
 Handle file dropping.
void OnCanvasSize (wxIViewCanvasSizeEvent &oEvent)
 Handle bitmap resizing introduced by canvas resizing.
void OnCanvasSelected (wxIViewCanvasSelectedEvent &oEvent)
 Handle canvas selection events.
void OnProcessTerminated (wxProcessEvent &oEvent)
 Handle process termination.
void OnTextCtrlPageProcessEnter (wxCommandEvent &oEvent)
 Handle page number editor field events.

Private Attributes

bool m_bUILocked
 States if the GUI should be locked by wxIScanFrame::EnableControls().
wxImage m_oImage
 Image object.
wxImage m_oPrintImage
 Image object for printing.
wxString m_strImageFileName
 Image file name.
int m_nPage
 Page number.
int m_nImageCount
 The number of images in an image file.
int m_nResolution
 The (fictive) resolution of an image in dpi.
wxScan * m_poScanner
 Object representing the scanner.
int m_nFit
 Fit bitmap size according to its value.
double m_nScaleFactor
 Bitmap scalation factor.
double m_nZoomFactor
 Zoom factor by which the bitmap should be scaled.
bool m_bAutoApplyProfile
 Apply a profile automatically after scanning.
bool m_bAutoApplyProfileOnMultiPage
 Apply a profile automatically after loading a page from a multi page file.
int m_nProfileIndex
 Index number of the current image profile.
wxString m_strBitmapMimeType
 Image mimetype for any export but PDF export.
wxString m_strPdfBitmapMimeType
 Image mimetype for PDF export.
bool m_bLua
 Enable Lua scripting.
int m_nLuaCount
 Number of Lua scripts.
bool m_bOCR
 Enable OCR.
wxString m_strOcrOutputExtension
 The output extension of the via OCR extracted text file.
wxString m_strOcrOutputExtensionHocr
 The output extension of the via OCR extracted hocr (html) file.
bool m_bCmdConvertEnable
 ...
wxString m_strCmdConvert
 ...
bool m_bCmdOcrEnable
 ...
wxString m_strCmdOcr
 ...
bool m_bCmdCleanUpEnable
 ...
wxString m_strCmdCleanUp
 ...
bool m_bHocrEnable
 ...
wxString m_strHocrClass
 ...
bool m_bSmartHocrEnable
 ...
wxString m_strCmdOcrUseHocr
 ...
bool m_bCmdHtml2XhtmlEnable
 ...
wxString m_strCmdHtml2Xhtml
 ...
bool m_bCmdHocrCleanUpEnable
 ...
wxString m_strCmdHocrCleanUp
 ...
bool m_bCmdTtsEnable
 ...
wxString m_strCmdTts
 ...
bool m_bCmdEditEnable
 ...
wxString m_strCmdEdit
 ...
wxFileHistory m_oFileHistory
 History of last opened files.
wxPrintData m_oPrintData
 Holds related to printers and printer device contexts.
wxPdfDocument * m_poPdfDoc
 PDF document.
int m_nPdfPages
 Number of PDF pages in memory.
bool m_bPdfDirty
 States if the PDF file is dirty (and should be saved).
bool bLuaReturnFromEventHandler
 Lua return value of the event handlers.
wxExtProcessm_poRunningProcess
 A concurrent running process (equals to NULL if there isn't any).
wxIViewCanvasm_poCanvas
wxToolBarToolBase * ToolBarItem5
wxToolBarToolBase * ToolBarItem11
wxSplitterWindow * m_poVSplitterWindow
wxToolBarToolBase * ToolBarItem6
wxImagePanelm_poPanelPages
wxToolBarToolBase * ToolBarItem12
wxToolBarToolBase * ToolBarItem7
wxToolBarToolBase * ToolBarItem2
wxToolBarToolBase * ToolBarItem13
wxToolBarToolBase * ToolBarItem9
wxToolBarToolBase * ToolBarItem10
wxToolBarToolBase * ToolBarItem4
wxMenu * poMenuEdit
wxToolBarToolBase * ToolBarItem1
wxToolBarToolBase * ToolBarItem3
wxSplitterWindow * m_poHSplitterWindow
wxTextCtrl * m_poLogTextCtrl
wxToolBarToolBase * ToolBarItem8
wxTextCtrl * m_poTextCtrlPage
 A pointer to the page number editor.
wxTextValidator m_oTextValidatorTextCtrlPage
 The validator to the page number editor.

Static Private Attributes

static const long ID_CANVAS = wxNewId()
static const long ID_PAGES = wxNewId()
static const long ID_VSPLITTERWINDOW = wxNewId()
static const long ID_LOGTEXTCTRL = wxNewId()
static const long ID_HSPLITTERWINDOW = wxNewId()
static const long ID_FILESCANIMAGE = wxNewId()
static const long ID_FILEOPEN = wxNewId()
static const long ID_FILESAVEAS = wxNewId()
static const long ID_FILEPRINT = wxNewId()
static const long ID_FILEPRINTPREVIEW = wxNewId()
static const long ID_FILEPRINTSETUP = wxNewId()
static const long ID_FILEQUIT = wxNewId()
static const long ID_EDITCOPY = wxNewId()
static const long ID_EDITPASTE = wxNewId()
static const long ID_EDITSETTINGS = wxNewId()
static const long ID_EDITSETTINGSFILE = wxNewId()
static const long ID_EDITSCANSCANNERS = wxNewId()
static const long ID_EDITCLEARLOG = wxNewId()
static const long ID_EDITCLEARHISTORY = wxNewId()
static const long ID_VIEWFULLSCREEN = wxNewId()
static const long ID_VIEWFITWIDTH = wxNewId()
static const long ID_VIEWFITWINDOW = wxNewId()
static const long ID_VIEWFULLSIZE = wxNewId()
static const long ID_VIEWCUSTOMSIZE = wxNewId()
static const long ID_VIEWZOOMIN = wxNewId()
static const long ID_VIEWZOOMOUT = wxNewId()
static const long ID_VIEWZOOMSELECTION = wxNewId()
static const long ID_VIEWCLOSEDEBUGWINDOW = wxNewId()
static const long ID_VIEWCLOSEPREVIEWPANEL = wxNewId()
static const long ID_DOCUMENTCOPYTEXT = wxNewId()
static const long ID_DOCUMENTREADTEXT = wxNewId()
static const long ID_CMDSTOP = wxNewId()
static const long ID_DOCUMENTFIRSTPAGE = wxNewId()
static const long ID_DOCUMENTPREVIOUSPAGE = wxNewId()
static const long ID_DOCUMENTNEXTPAGE = wxNewId()
static const long ID_DOCUMENTLASTPAGE = wxNewId()
static const long ID_DOCUMENTROTATE90LEFT = wxNewId()
static const long ID_DOCUMENTROTATE90RIGHT = wxNewId()
static const long ID_DOCUMENTCROP = wxNewId()
static const long ID_DOCUMENTAPPLYPROFILE = wxNewId()
static const long ID_MENUDOCUMENTPROFILES = wxNewId()
static const long ID_PDFBEGINPDF = wxNewId()
static const long ID_PDFADDPAGE = wxNewId()
static const long ID_PDFSAVEASPDF = wxNewId()
static const long ID_HELPABOUT = wxNewId()
static const long ID_FILESCANIMAGE_TB = wxNewId()
static const long ID_FILEOPEN_TB = wxNewId()
static const long ID_FILESAVEAS_TB = wxNewId()
static const long ID_FILEPRINT_TB = wxNewId()
static const long ID_PDFBEGINPDF_TB = wxNewId()
static const long ID_PDFADDPAGE_TB = wxNewId()
static const long ID_PDFSAVEASPDF_TB = wxNewId()
static const long ID_DOCUMENTFIRSTPAGE_TB = wxNewId()
static const long ID_DOCUMENTPREVIOUSPAGE_TB = wxNewId()
static const long ID_DOCUMENTNEXTPAGE_TB = wxNewId()
static const long ID_DOCUMENTLASTPAGE_TB = wxNewId()
static const long ID_DOCUMENTREADTEXT_TB = wxNewId()
static const long ID_CMDSTOP_TB = wxNewId()
static const long ID_DOCUMENTREADTEXTSYNC = wxNewId()
 ...
static const long ID_DOCUMENTPROFILE0 = wxNewId()
 ...
static const long ID_TEXTCTRLPAGE = wxNewId()
 ...

Friends

class wxIScanLuaScript

Detailed Description

The frame window class.

wxIScanFrame represents the scanning application's main window and handles most of the events (e. g. menu, timer etc.).

Note: In addition to wxFrame wxIScanFrame inherits the class wxIViewPaintBase which is an interface to basic printing and print previewing of an image.

Definition at line 67 of file wxiscanframe.h.


Member Enumeration Documentation

anonymous enum
Enumerator:
wxCANVASFULLSIZE 

Show image full size (without any zooming).

wxCANVASFITWIDTH 

Zoom image to fit the window width.

wxCANVASFITWINDOW 

Zoom image to fit the window size.

wxCANVASCUSTOMSIZE 

Zoom image to an explicit given zoom factor (m_nScaleFactor).

Definition at line 70 of file wxiscanframe.h.

        {
            wxCANVASFULLSIZE,                                       ///< Show image full size (without any zooming).
            wxCANVASFITWIDTH,                                       ///< Zoom image to fit the window width.
            wxCANVASFITWINDOW,                                      ///< Zoom image to fit the window size.
            wxCANVASCUSTOMSIZE                                      ///< Zoom image to an explicit given zoom factor (m_nScaleFactor).
        };

Constructor & Destructor Documentation

wxIScanFrame::wxIScanFrame ( wxWindow *  poParent,
wxWindowID  nId = wxID_ANY 
)

Standard constructor.

Parameters:
poParenta pointer to the parent window
nIdthe window id
wxIScanFrame::~wxIScanFrame ( ) [virtual]

Virtual destructor.

Definition at line 735 of file wxiscanframe.cpp.

References wxExtProcess::Kill(), m_poLogTextCtrl, m_poPdfDoc, m_poRunningProcess, m_poScanner, and SaveSettings().

{
    // Destroy an existing scanner object.
    if( m_poScanner )
    {
        delete m_poScanner;
        m_poScanner= NULL;
    }

    // Terminate a possibly running concurrent process.
    if( m_poRunningProcess )
    {
        m_poRunningProcess->Kill( wxSIGTERM, wxKILL_CHILDREN );
        delete m_poRunningProcess;
        m_poRunningProcess= NULL;
    }

#if __WXPDFDOC__
    // Destroy pending PDF documents.
    if( m_poPdfDoc )
    {
        delete m_poPdfDoc;
        m_poPdfDoc= NULL;
    }
#endif // __WXPDFDOC__

    // Save configuration data.
    SaveSettings();

    //(*Destroy(wxIScanFrame)
    //*)

    // Save the log to a text file.
    if( m_poLogTextCtrl )
    {
        wxFileName oFileName( wxStandardPaths::Get().GetDocumentsDir(), ::wxGetApp().GetAppName(), wxT( "log" ) );

        m_poLogTextCtrl->SaveFile( oFileName.GetFullPath() );
    }
}

Member Function Documentation

bool wxIScanFrame::AddPdfPage ( ) [virtual]

Add a new image/OCR text page to the existing PDF document.

Definition at line 2697 of file wxiscanframe.cpp.

References wxImagePanel::AddImage(), Execute(), GetTextFromFile(), IsPortrait(), m_bCmdHtml2XhtmlEnable, m_bHocrEnable, m_bOCR, m_bPdfDirty, m_bSmartHocrEnable, m_nPdfPages, m_nResolution, m_oImage, m_poPanelPages, m_poPdfDoc, m_strCmdHtml2Xhtml, m_strHocrClass, m_strPdfBitmapMimeType, OCR(), and wxIScanHocr2Pdf::Run().

Referenced by OnPdfAddPage().

{
    if( !m_poPdfDoc )
    {
        wxLogError( wxString( wxT( "wxIScanFrame::AddPdfPage - " ) )
                      + _( "wxPdfDocument is NULL" ) );
        return false;
    }

    // Save image in a temporary file.
    wxString strTempFileName= wxFileName::CreateTempFileName( wxEmptyString );

    m_oImage.SaveFile( strTempFileName, m_strPdfBitmapMimeType );

#if defined( __WXSCANDEBUG__ ) && __WXSCANDEBUG__ >= 1
    wxLogMessage( wxT( "PDF PARAMETERS" ) );
    wxLogMessage( wxT( "\tGetPageWidth == %.2f mm (%f)"  ), m_poPdfDoc->GetPageWidth(),  m_poPdfDoc->GetPageWidth()  / m_oImage.GetWidth() );
    wxLogMessage( wxT( "\tGetPageHeight == %.2f mm (%f)" ), m_poPdfDoc->GetPageHeight(), m_poPdfDoc->GetPageHeight() / m_oImage.GetHeight() );
    wxLogMessage( wxT( "\tGetImageScale == %f (new: %f)" ), m_poPdfDoc->GetImageScale(), (double)m_nResolution / 72.0 );
    wxLogMessage( wxT( "\tGetScaleFactor == %f" ), m_poPdfDoc->GetScaleFactor() );
    wxLogMessage( wxT( "\tm_nResolution == %.2f DPI (%.2f/mm)" ), (double)m_nResolution, (double)m_nResolution / 25.4 );
    wxLogMessage( wxT( "============" ) );
    ::wxSafeYield();
#endif

    // Add a page, ...
    m_poPdfDoc->AddPage( IsPortrait() ? wxPORTRAIT : wxLANDSCAPE );

    // ... do some OCR and include the recognized text if enabled, and ...
    if( m_bOCR )
    {
        wxString strOcrTextFileName= OCR( strTempFileName, m_bHocrEnable );

        if( !strOcrTextFileName.IsEmpty() )
        {
            m_poPdfDoc->SetFont( wxT( "Times" ), wxPDF_FONTSTYLE_REGULAR, 8 );
            m_poPdfDoc->SetTextRenderMode( wxPDF_TEXT_RENDER_INVISIBLE );

            if( m_bHocrEnable )
            {
                wxXmlDocument oXmlDoc;

                // Try to load the OCR result file as XML (XHTML).
                {
                    // Suppress the error message if wxXmlDocument::Load(...) fails.
                    //
                    // Note: We want to suppress only the logging of
                    //       wxXmlDocument::Load(...). Therefore we use a local
                    //       variable oLogNull in an additional inner context
                    //       which is automatically destroyed after leaving this
                    //       context.
                    //
                    wxLogNull oLogNull;

                    // Load the XML file.
                    //
                    // Note: We need the flag wxXMLDOC_KEEP_WHITESPACE_NODES
                    //       because we need the whitespace for flushing!
                    oXmlDoc.Load( strOcrTextFileName, wxT( "UTF-8" ), wxXMLDOC_KEEP_WHITESPACE_NODES );
                }

                // If this was not successfull convert try to convert from HTML to XHTML.
                if( !oXmlDoc.IsOk() && m_bCmdHtml2XhtmlEnable )
                {
                    // Try to convert the file from HTML to XHTML.
                    wxString strCommand= wxString::Format( m_strCmdHtml2Xhtml, strOcrTextFileName.c_str() );
#if __DEBUG__
                    wxLogMessage( wxT( "wxIScanFrame::AddPdfPage - strCommand == '%s'" ), strCommand.c_str() );
#endif
                    Execute( strCommand );

                    // Retry to load the file as XHTML file.
                    {
                        // Suppress the error message if wxXmlDocument::Load(...)
                        // fails.
                        wxLogNull oLogNull;

                        // Load the XML file.
                        //
                        // Note: We need the flag wxXMLDOC_KEEP_WHITESPACE_NODES
                        //       because we need the whitespace for flushing!
                        oXmlDoc.Load( strOcrTextFileName, wxT( "UTF-8" ), wxXMLDOC_KEEP_WHITESPACE_NODES );
                    }

                    // In case of an error use the fallback action.
                    if( !oXmlDoc.IsOk() )
                    {
                        // Do a fallback by treating the file as unformated text.
                        goto FallBack;
                    }
                }

                // Traverse DOM tree and draw the text on the PDF document.
                if( m_bSmartHocrEnable )
                {
                    wxIScanSmartHocr2Pdf oHocr2Pdf( &oXmlDoc, m_poPdfDoc, m_nResolution, m_strHocrClass );

                    oHocr2Pdf.Run();
                }
                else
                {
                    wxIScanHocr2Pdf oHocr2Pdf( &oXmlDoc, m_poPdfDoc, m_nResolution, m_strHocrClass );

                    oHocr2Pdf.Run();
                }

                // On success leave out the fall back code.
                goto GoOn;
            }

FallBack:
            // Handle unformated text file (non-hocr-files).
            //
            m_poPdfDoc->MultiCell( 0, 3, ::GetTextFromFile( strOcrTextFileName ), wxPDF_BORDER_NONE, wxPDF_ALIGN_LEFT, 1 );

GoOn:
            // Remove the text file created by the OCR program.
            ::wxRemoveFile( strOcrTextFileName );
        }
    }

    // ... put the image onto the current PDF page.
    m_poPdfDoc->SetImageScale(  (double)m_nResolution / 72.0 );
    m_poPdfDoc->Image( strTempFileName, 0 , 0, 0, 0, m_strPdfBitmapMimeType );

    // Remove temporary file.
    ::wxRemoveFile( strTempFileName );

    // Incremement the page counter and mark the PDF document as 'dirty'.;
    m_nPdfPages++;
    m_bPdfDirty= true;
    SetStatusText( wxString::Format( wxT( "PDF: %d" ), m_nPdfPages ), 1 );

    // Add a thumb to the pages panel.
    m_poPanelPages->AddImage( m_oImage );

    // Signal success.
    return true;
}
void wxIScanFrame::AddPdfPageTraverseXmlNodes ( wxXmlNode *  poNode) [private]

DOM tree traverse helper function for AddPdfPage().

virtual void wxIScanFrame::AdjustOrientation ( ) [inline, virtual]

...

Definition at line 213 of file wxiscanframe.h.

References IsPortrait(), and m_oPrintData.

Referenced by OnFilePrint(), OnFilePrintPreview(), and OnFilePrintSetup().

void wxIScanFrame::ApplyProfile ( ) [virtual]

Apply the selected profile to the image.

Definition at line 2190 of file wxiscanframe.cpp.

References CropImage(), Image2Grey(), Image2Mono(), m_bLua, m_nResolution, m_oImage, and StartScript().

Referenced by OnDocumentApplyProfile(), OnPdfAddPage(), and ScanImage().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Get profile configuration.
    wxConfigBase *poConfig= wxConfigBase::Get();

    poConfig->SetRecordDefaults();
    poConfig->SetPath( wxString::Format( wxT( "/Profile/%d" ), m_nProfileIndex ) );

#if __WXLUASCRIPT__
    wxString strScriptStartupFunction= poConfig->Read( wxT( "Function" ), wxT( "" ) );

    if( m_bLua && !strScriptStartupFunction.IsEmpty() )
    {
        wxString strScriptFileName= poConfig->Read( wxT( "Script" ), wxT( "" ) );

        StartScript( strScriptStartupFunction, strScriptFileName );
    }
    else
#endif // __WXLUASCRIPT__
    {
        // Crop image to the corresponding image rect.
        bool bCrop= (bool)poConfig->Read( wxT( "Crop" ), (long)false );

        if( bCrop )
        {
            int x= poConfig->Read( wxT( "x" ), 0L );
            int y= poConfig->Read( wxT( "y" ), 0L );
            int w= poConfig->Read( wxT( "w" ), (long)( 210.0 / 25.4 * (double)m_nResolution ) );
            int h= poConfig->Read( wxT( "h" ), (long)( 297.0 / 25.4 * (double)m_nResolution ) );

            m_oImage= ::CropImage( m_oImage, x, y, w, h );
        }

        // Convert the image to greyscale.
        bool bGreyScale= (bool)poConfig->Read( wxT( "GreyScale" ), (long)false );

        if( bGreyScale )
        {
            m_oImage= ::Image2Grey( m_oImage );
        }

        // Convert the image to mono chrome.
        bool bMonoChrome= (bool)poConfig->Read( wxT( "MonoChrome" ), (long)false );

        if( bMonoChrome )
        {
            int nMonoThreshold= poConfig->Read( wxT( "MonoThreshold" ), 128L );

            m_oImage= ::Image2Mono( m_oImage, nMonoThreshold);
        }

        // Rotate the image 90° to the right (multiple times).
        int nRotate90Right= poConfig->Read( wxT( "Rotate90Right" ), 0L );

        for( int i= 0; i < nRotate90Right; i++ )
        {
            m_oImage= m_oImage.Rotate90();
        }
    }
}
bool wxIScanFrame::CanClose ( bool  bCanVeto = true) [virtual]

Handle window closing requests.

Definition at line 1785 of file wxiscanframe.cpp.

References ID_PDFSAVEASPDF, IsPdfDirty(), and OnPdfSavePdf().

Referenced by OnClose(), and OnPdfBeginPdf().

{
#if __WXPDFDOC__
    if( IsPdfDirty() )
    {
        switch( ::wxMessageBox( _( "The changes to the current PDF document have not yet been saved. "
                                   "Do you want to save the PDF document now?" ),
                                ::wxGetApp().GetAppName(),
                                wxYES_NO | ( bCanVeto ? wxCANCEL : 0 ) | wxICON_QUESTION ) )
        {
            case wxYES: {
                            wxCommandEvent oDummyEvent( wxEVT_COMMAND_MENU_SELECTED, ID_PDFSAVEASPDF );

                            OnPdfSavePdf  ( oDummyEvent );
                        }
                        return !IsPdfDirty();
            case wxNO : return true;
            default:    return false;
        }
    }
    else
    {
        return true;
    }
#else
    return true;
#endif
}
bool wxIScanFrame::CreateNewPdfDocument ( ) [virtual]

Create (and initialize) a new PDF document.

Definition at line 2669 of file wxiscanframe.cpp.

References m_bPdfDirty, m_nPdfPages, m_oPrintData, and m_poPdfDoc.

Referenced by OnPdfBeginPdf().

{
    // Delete any old PDF documents.
    if( m_poPdfDoc  )
    {
        delete m_poPdfDoc;
    }
    SetStatusText( wxString( wxT( "PDF: " ) ) + _( "empty" ), 1 );

    // Create a new PDF document in portrait mode on A4 paper using mm
    // as measurement unit.
    m_poPdfDoc= new wxPdfDocument( wxPORTRAIT,
                                   wxString( _T( "mm" ) ),
                                   m_oPrintData.GetPaperId() );
    m_nPdfPages= 0;
    m_bPdfDirty= false;
    if( !m_poPdfDoc )
    {
        wxLogError( _( "Cannot create wxPdfDocument." ) );
    }
    m_poPdfDoc->SetCreator( ::wxGetApp().GetAppName() );
    m_poPdfDoc->SetAutoPageBreak( false );
    m_poPdfDoc->SetCompression( true );
    return true;
}
void wxIScanFrame::EnableControls ( ) [virtual]

Enable or disable controls according to the actual progam state.

Definition at line 2528 of file wxiscanframe.cpp.

References ID_CMDSTOP, ID_CMDSTOP_TB, ID_DOCUMENTAPPLYPROFILE, ID_DOCUMENTCOPYTEXT, ID_DOCUMENTCROP, ID_DOCUMENTFIRSTPAGE, ID_DOCUMENTFIRSTPAGE_TB, ID_DOCUMENTLASTPAGE, ID_DOCUMENTLASTPAGE_TB, ID_DOCUMENTNEXTPAGE, ID_DOCUMENTNEXTPAGE_TB, ID_DOCUMENTPREVIOUSPAGE, ID_DOCUMENTPREVIOUSPAGE_TB, ID_DOCUMENTPROFILE0, ID_DOCUMENTREADTEXT, ID_DOCUMENTREADTEXT_TB, ID_DOCUMENTROTATE90LEFT, ID_DOCUMENTROTATE90RIGHT, ID_EDITCOPY, ID_EDITPASTE, ID_EDITSCANSCANNERS, ID_EDITSETTINGSFILE, ID_FILEOPEN, ID_FILEOPEN_TB, ID_FILEPRINT, ID_FILEPRINT_TB, ID_FILEPRINTPREVIEW, ID_FILEPRINTSETUP, ID_FILESAVEAS, ID_FILESAVEAS_TB, ID_FILESCANIMAGE, ID_FILESCANIMAGE_TB, ID_PDFADDPAGE, ID_PDFADDPAGE_TB, ID_PDFBEGINPDF, ID_PDFBEGINPDF_TB, ID_PDFSAVEASPDF, ID_PDFSAVEASPDF_TB, ID_VIEWCUSTOMSIZE, ID_VIEWFITWIDTH, ID_VIEWFITWINDOW, ID_VIEWFULLSIZE, ID_VIEWZOOMIN, ID_VIEWZOOMOUT, ID_VIEWZOOMSELECTION, m_bCmdEditEnable, m_bCmdOcrEnable, m_bCmdTtsEnable, m_bLua, m_bUILocked, m_nFit, m_nImageCount, m_nLuaCount, m_nPage, m_nPdfPages, m_oFileHistory, m_oImage, m_poRunningProcess, m_poScanner, wxCANVASCUSTOMSIZE, wxCANVASFITWIDTH, wxCANVASFITWINDOW, wxCANVASFULLSIZE, and wxISCAN_SCRIPTMENUPOS.

Referenced by LockUI(), OnCmdStop(), OnDocumentCrop(), OnDocumentPageChanged(), OnDocumentReadText(), OnDocumentZoom(), OnEditPaste(), OnEditSettings(), OnFileScanImage(), OnPdfAddPage(), OnPdfBeginPdf(), OnProcessTerminated(), OnScriptStartScript(), OnViewFit(), and OpenImage().

{
    // Enable/disable menu items (on first call).
    bool bImageOk= !m_bUILocked && m_oImage.IsOk();

    GetMenuBar()->Enable(     ID_FILESAVEAS,                bImageOk );
    GetToolBar()->EnableTool( ID_FILESAVEAS_TB,             bImageOk );
    GetMenuBar()->Enable(     ID_FILEPRINT,                 bImageOk );
    GetToolBar()->EnableTool( ID_FILEPRINT_TB,              bImageOk );
    GetMenuBar()->Enable(     ID_FILEPRINTPREVIEW,          bImageOk );
    GetMenuBar()->Enable(     ID_FILEPRINTSETUP,            bImageOk );
    GetMenuBar()->Enable(     ID_EDITCOPY,                  bImageOk );
    GetMenuBar()->Enable(     ID_VIEWZOOMIN,                bImageOk );
    GetMenuBar()->Enable(     ID_VIEWZOOMOUT,               bImageOk );
    GetMenuBar()->Enable(     ID_VIEWZOOMSELECTION,         bImageOk );
#if __WXPDFDOC__
    GetMenuBar()->Enable(     ID_PDFBEGINPDF,               true     );
    GetToolBar()->EnableTool( ID_PDFBEGINPDF_TB,            true     );
    GetMenuBar()->Enable(     ID_PDFADDPAGE,                bImageOk );
    GetToolBar()->EnableTool( ID_PDFADDPAGE_TB,             bImageOk );
#else
    GetMenuBar()->Enable(     ID_PDFBEGINPDF,               false    );
    GetToolBar()->EnableTool( ID_PDFBEGINPDF_TB,            false    );
    GetMenuBar()->Enable(     ID_PDFADDPAGE,                false    );
    GetToolBar()->EnableTool( ID_PDFADDPAGE_TB,             false    );
#endif // __WXPDFDOC__
    GetMenuBar()->Enable(     ID_DOCUMENTROTATE90LEFT,      bImageOk );
    GetMenuBar()->Enable(     ID_DOCUMENTROTATE90RIGHT,     bImageOk );
    GetMenuBar()->Enable(     ID_DOCUMENTCROP,              bImageOk );
    GetMenuBar()->Enable(     ID_DOCUMENTAPPLYPROFILE,      bImageOk );

#if __WXPDFDOC__
    // Enable/disable PDF file save controls.
    bool bCanSavePdfFile= !m_bUILocked && ( m_nPdfPages > 0 );

    GetMenuBar()->Enable(     ID_PDFSAVEASPDF,              bCanSavePdfFile );
    GetToolBar()->EnableTool( ID_PDFSAVEASPDF_TB,           bCanSavePdfFile );
#else
    GetMenuBar()->Enable(     ID_PDFSAVEASPDF,              false );
    GetToolBar()->EnableTool( ID_PDFSAVEASPDF_TB,           false );
#endif // __WXPDFDOC__

    // ...
    bool bCopyText= bImageOk && m_bCmdOcrEnable;

    GetMenuBar()->Enable(     ID_DOCUMENTCOPYTEXT,         bCopyText );

    // ...
    GetMenuBar()->Enable(     ID_EDITSETTINGSFILE ,        m_bCmdEditEnable );

    // Enable text-to-speach controls
    bool bTTS= bImageOk
                && m_bCmdOcrEnable
                && m_bCmdTtsEnable
                && ( m_poRunningProcess ? false : true );

    GetMenuBar()->Enable(     ID_DOCUMENTREADTEXT,          bTTS );
    GetToolBar()->EnableTool( ID_DOCUMENTREADTEXT_TB,       bTTS );

    // Enable/disable page controls
    bool bNotFirstPage= ( m_nPage > 0 );
    bool bNotLastPage=  ( m_nPage < ( m_nImageCount - 1 ) );

    GetMenuBar()->Enable(     ID_DOCUMENTFIRSTPAGE,         bImageOk && bNotFirstPage );
    GetToolBar()->EnableTool( ID_DOCUMENTFIRSTPAGE_TB,      bImageOk && bNotFirstPage );
    GetMenuBar()->Enable(     ID_DOCUMENTPREVIOUSPAGE,      bImageOk && bNotFirstPage );
    GetToolBar()->EnableTool( ID_DOCUMENTPREVIOUSPAGE_TB,   bImageOk && bNotFirstPage );
    GetMenuBar()->Enable(     ID_DOCUMENTNEXTPAGE,          bImageOk && bNotLastPage  );
    GetToolBar()->EnableTool( ID_DOCUMENTNEXTPAGE_TB,       bImageOk && bNotLastPage  );
    GetMenuBar()->Enable(     ID_DOCUMENTLASTPAGE,          bImageOk && bNotLastPage  );
    GetToolBar()->EnableTool( ID_DOCUMENTLASTPAGE_TB,       bImageOk && bNotLastPage  );
    GetToolBar()->EnableTool( ID_TEXTCTRLPAGE,              bImageOk                  );

    // Enable process killer.
    GetMenuBar()->Enable(     ID_CMDSTOP,                   m_poRunningProcess );
    GetToolBar()->EnableTool( ID_CMDSTOP_TB,                m_poRunningProcess );

    // Enable scanning.
    bool bScanEnabled= !m_bUILocked && m_poScanner && m_poScanner->IsOk();

    GetMenuBar()->Enable(     ID_FILESCANIMAGE,             bScanEnabled );
    GetToolBar()->EnableTool( ID_FILESCANIMAGE_TB,          bScanEnabled );
#ifdef __WXSCANSANE__
    GetMenuBar()->Enable(     ID_EDITSCANSCANNERS ,         !m_bUILocked && m_poScanner /*bScanEnabled*/ );
    GetToolBar()->EnableTool( ID_CHOICESCANNER,             bScanEnabled );
#else // __WXSCANSANE__
    GetMenuBar()->Enable(     ID_EDITSCANSCANNERS ,         false );
#endif // __WXSCANSANE__

    // Lock ...
    GetMenuBar()->Enable(     ID_FILEOPEN,                  !m_bUILocked );
    GetToolBar()->EnableTool( ID_FILEOPEN_TB,               !m_bUILocked );
    GetMenuBar()->Enable(     ID_EDITPASTE,                 !m_bUILocked );

    // Check the active viewing (fitting) option.
    GetMenuBar()->Check( ID_VIEWFITWIDTH,   false );
    GetMenuBar()->Check( ID_VIEWFITWINDOW,  false );
    GetMenuBar()->Check( ID_VIEWFULLSIZE,   false );
    GetMenuBar()->Check( ID_VIEWCUSTOMSIZE, false );
    switch( m_nFit )
    {
        case wxCANVASFITWIDTH   : GetMenuBar()->Check( ID_VIEWFITWIDTH,   true );
                                  break;
        case wxCANVASFITWINDOW  : GetMenuBar()->Check( ID_VIEWFITWINDOW,  true );
                                  break;
        case wxCANVASFULLSIZE   : GetMenuBar()->Check( ID_VIEWFULLSIZE,   true );
                                  break;
        case wxCANVASCUSTOMSIZE : GetMenuBar()->Check( ID_VIEWCUSTOMSIZE, true );
                                  break;
    }

    // ... file history... .
    for( unsigned i= 0; i <  m_oFileHistory.GetCount(); i++ )
    {
        GetMenuBar()->Enable( m_oFileHistory.GetBaseId() + i, !m_bUILocked );
    }

#if __WXLUASCRIPT__
    // Enable/disable Lua script menu.
    GetMenuBar()->EnableTop( wxISCAN_SCRIPTMENUPOS, m_bLua );
    for( int i= 0; i < m_nLuaCount; i++ )
    {
        GetMenuBar()->Enable( ID_DOCUMENTPROFILE0 + 1000 + i, m_bLua );
    }
#endif // __WXLUASCRIPT__

    // Disable (by compiler option) not implemented controls .
#if defined( __WXPDFDOC__ ) && __WXPDFDOC__ >= 1
    GetMenuBar()->Enable(     ID_PDFBEGINPDF,               !m_bUILocked );
    GetToolBar()->EnableTool( ID_PDFBEGINPDF_TB,            !m_bUILocked );
#else
    GetMenuBar()->Enable(     ID_PDFBEGINPDF,               false );
    GetToolBar()->EnableTool( ID_PDFBEGINPDF_TB,            false );
#endif
}
virtual void wxIScanFrame::EnhenceOpticalContrast ( ) [inline, virtual]

Enhance the optical contrast by replacing white by yellow.

Definition at line 103 of file wxiscanframe.h.

References m_oImage, and UpdateBitmap().

Referenced by wxIScanLuaScript::EnhenceOpticalContrast().

        {
            m_oImage.Replace( 255, 255, 255, 255, 255, 0 );
            UpdateBitmap();
        }
bool wxIScanFrame::Execute ( const wxString &  strCommand,
bool  bAsync = false,
const wxString &  strTempTextFileName = wxEmptyString 
) [virtual]

Fork an external process.

Parameters:
strCommandthe command line to be executed.
bAsyncan (optional) flag which decides if the new process is to be executed synchronous (default) or asynchronous.
strTempTextFileNamean (optional) file name of a file that should be deleted at the end of an asynchronous running process.

Definition at line 2384 of file wxiscanframe.cpp.

References wxExtProcess::Execute(), LogProcessOutput(), and m_poRunningProcess.

Referenced by AddPdfPage(), wxIScanLuaScript::Execute(), OCR(), OnEditSettingsFile(), and ReadOut().

{
    if( bAsync )
    {
        // Check if an asynchronous process is still running.
        if( m_poRunningProcess )
        {
            // Log an error message.
            wxLogError( wxString( wxT( "wxIScanFrame::Execute - " ) )
                          + _( "Cannot create new asynchronous process. An old one is still running. "
                               "Please wait until it stops or press the STOP button in the taskbar." ) );

            // Signal error.
            return false;
        }

        // Create an asynchronous running process, ...
        if( strTempTextFileName.IsEmpty() )
        {
            m_poRunningProcess= new wxExtProcess( this, wxISCAN_PROCESS );
        }
        else
        {
            m_poRunningProcess= new wxExtProcessDelTempFile( this, wxISCAN_PROCESS, strTempTextFileName );
        }

        // ... check if is was created correctly, ...
        if( !m_poRunningProcess )
        {
            // Log an error message.
            wxLogError( wxString( wxT( "wxIScanFrame::Execute - " ) )
                          + _( "Cannot create process object." ) );

            // Signal error.
            return false;
        }

        // ... redirect its output, ...
//        m_poRunningProcess->Redirect();

        // ... and execute it.
        if( !m_poRunningProcess->Execute( strCommand, wxEXEC_ASYNC | wxEXEC_MAKE_GROUP_LEADER ) )
        {
            // Log an error message.
            wxLogError( wxString( wxT( "wxIScanFrame::Execute - " ) )
                          + wxString::Format( _( "Cannot start asynchronous process [%s]." ),
                                              strCommand.c_str() ) );

            // Signal error.
            return false;
        }
    }
    else
    {
        // Create a process, ...
        wxProcess oProcess( this );

        // ... redirect its output, ...
        oProcess.Redirect();

        // ... execute it synchronous, and await its ending.
        long nExitCode= ::wxExecute( strCommand, wxEXEC_SYNC, &oProcess );

       // Log process's output.
        LogProcessOutput( &oProcess );

        if( nExitCode )
        {
            // Log an error message.
            wxLogError( wxString( wxT( "wxIScanFrame::Execute - " ) )
                          + wxString::Format( _( "An error occured on synchronous process [%s]." ),
                                              strCommand.c_str() ) );

            // Signal error.
            return false;
        }
    }

    // Signal success.
    return true;
}
wxImage wxIScanFrame::GetImageSelection ( ) [virtual]

Get the selected sub image.

Definition at line 1964 of file wxiscanframe.cpp.

References wxIViewCanvas::GetSelection(), wxIViewCanvas::IsSelected(), m_oImage, and m_poCanvas.

Referenced by wxIScanLuaScript::OCR(), OCR(), OnDocumentCopyText(), OnDocumentCrop(), OnEditCopy(), OnFileSaveAs(), ReadOut(), and wxIScanLuaScript::SaveImage().

{
    if( m_poCanvas->IsSelected() )
    {
        wxRect oSelection= m_poCanvas->GetSelection();

        oSelection.x     = int( (double)oSelection.x      / m_nScaleFactor );
        oSelection.y     = int( (double)oSelection.y      / m_nScaleFactor );
        oSelection.width = int( (double)oSelection.width  / m_nScaleFactor );
        oSelection.height= int( (double)oSelection.height / m_nScaleFactor );

        int nWidth= m_oImage.GetWidth();
        if( nWidth < ( oSelection.x + oSelection.width ) )
        {
            oSelection.width= nWidth - oSelection.x;
        }

        int nHeight= m_oImage.GetHeight();
        if( nHeight < ( oSelection.y + oSelection.height ) )
        {
            oSelection.height= nHeight - oSelection.y;
        }

        return m_oImage.GetSubImage( oSelection );
    }
    else
    {
        return m_oImage;
    }
}
virtual int wxIScanFrame::GetMaxPage ( ) [inline, virtual]

Get the (zero based) page number of the last page.

Implements wxIViewPaintBase.

Definition at line 215 of file wxiscanframe.h.

References m_nImageCount.

bool wxIScanFrame::GetPageSizeMM ( int *  pnWidth,
int *  pnHeight 
) [virtual]

Calculates the image extents in mm while printing or print previewing.

Implements wxIViewPaintBase.

Definition at line 3241 of file wxiscanframe.cpp.

References m_nResolution, and m_oPrintImage.

{
     if( m_oPrintImage.Ok() )
     {
         (*pnWidth)=  (int)( (double)m_oPrintImage.GetWidth()  / (double)m_nResolution * 25.4 );
         (*pnHeight)= (int)( (double)m_oPrintImage.GetHeight() / (double)m_nResolution * 25.4 );
         return true;
     }
     else
     {
         return false;
     }
}
bool wxIScanFrame::GotoPage ( int  nPage) [virtual]

Go to a given printer page.

Implements wxIViewPaintBase.

Definition at line 3257 of file wxiscanframe.cpp.

References m_nPage, m_oImage, m_oPrintImage, and m_strImageFileName.

{
    // NOTE: The wxPrintOut object passes pages one-based. We need it
    //        zero-based. Therefore we decrement the page number by 1.
    //
    nPage--;

    // Avoid loading an already loaded image.
    if( nPage == m_nPage )
    {
        m_oPrintImage= m_oImage;
        return true;
    }
    else
    {
        return m_oPrintImage.LoadFile( m_strImageFileName, wxBITMAP_TYPE_ANY, nPage );
    }
}
virtual bool wxIScanFrame::IsPdfDirty ( ) [inline, virtual]

Check if the PDF dirty flag is set to TRUE.

Definition at line 139 of file wxiscanframe.h.

References m_bPdfDirty.

Referenced by CanClose().

        {
            return m_bPdfDirty;
        }
virtual bool wxIScanFrame::IsPortrait ( ) [inline, virtual]

State if the image is in portrait direction.

Definition at line 146 of file wxiscanframe.h.

References m_oImage.

Referenced by AddPdfPage(), and AdjustOrientation().

        {
            return ( m_oImage.GetHeight() > m_oImage.GetWidth() );
        }
virtual void wxIScanFrame::LockUI ( bool  bLock = true) [inline, virtual]

Locks/Unlocks the user interface.

Parameters:
bLockif true locks otherwise unlocks the user interface.

Definition at line 181 of file wxiscanframe.h.

References EnableControls(), and m_bUILocked.

Referenced by UnlockUI().

        {
            m_bUILocked= bLock;
            EnableControls();
        }
void wxIScanFrame::LogProcessOutput ( wxProcess *  poProcess) [virtual]

Write a sub processes stdout and stderr output to the program's log.

Definition at line 2484 of file wxiscanframe.cpp.

References m_poLogTextCtrl.

Referenced by Execute(), OnCmdStop(), and OnProcessTerminated().

{
    // Save the log text control's default colour.
    wxTextAttr oStyle( m_poLogTextCtrl->GetDefaultStyle() );
    wxColour oOldColor( oStyle.GetTextColour() );

    // Check if there is text on the process's stdout and stderr stream
    // and log it.
    //
    // Process's stdout in light blue:
    wxTextInputStream oIn( *poProcess->GetInputStream() );

    oStyle.SetTextColour( wxColour( 64, 64, 255 ) );
    m_poLogTextCtrl->SetDefaultStyle( oStyle );
    while( poProcess->IsInputAvailable() )
    {
        wxLogMessage( oIn.ReadLine() );
    }

    // Process's stderr in light violet:
    wxTextInputStream oErr( *poProcess->GetErrorStream() );

    oStyle.SetTextColour( wxColour( 192, 96, 192 ) );
    m_poLogTextCtrl->SetDefaultStyle( oStyle );
    while( poProcess->IsErrorAvailable() )
    {
        wxLogMessage( oErr.ReadLine() );
    }

    // Restore the log text control's default colour.
    oStyle.SetTextColour( oOldColor );
    m_poLogTextCtrl->SetDefaultStyle( oStyle );
}
wxString wxIScanFrame::OCR ( const wxString &  strTempFileName,
bool  bUseHocr = false 
) [virtual]

Call an external OCR software and return the filename of the resulting text file.

Parameters:
strTempFileNamethe file name of the image that should be read by OCR().
bUseHocrflag if hOCR (as html) output should be done, defaults to false.

Definition at line 2257 of file wxiscanframe.cpp.

References Execute(), GetImageSelection(), Image2Mono(), m_bCmdCleanUpEnable, m_bCmdConvertEnable, m_bCmdHocrCleanUpEnable, m_bCmdOcrEnable, m_strBitmapMimeType, m_strCmdCleanUp, m_strCmdConvert, m_strCmdHocrCleanUp, m_strCmdOcr, m_strCmdOcrUseHocr, m_strOcrOutputExtension, and m_strOcrOutputExtensionHocr.

Referenced by AddPdfPage(), wxIScanLuaScript::OCR(), OnDocumentCopyText(), and ReadOut().

{
    wxString strCommand;            // Command line to execute as an external process.
    wxString strReturnFileName;     // ...

    // Check if OCR command is enabled.
    if( !m_bCmdOcrEnable )
    {
#if __DEBUG__
        wxLogWarning( wxString( wxT( "wxIScanFrame::OCR - " ) )
                        + _( "OCR command is disabled by option." ) );
#endif
        return wxEmptyString;
    }

    // Convert image to a monochrome version, ...
    if( m_bCmdConvertEnable )
    {
        // ... either by using an external command, ...
        strCommand.Printf( m_strCmdConvert,
                           strTempFileName.c_str(),
                           strTempFileName.c_str() );
#if __DEBUG__
        wxLogMessage( wxT( "wxIScanFrame::OCR - strCommand == '%s'" ), strCommand.c_str() );
#endif
        if( !Execute( strCommand ) )
        {
            wxLogError( wxString( wxT( "wxIScanFrame::OCR - " ) )
                          + _( "Monochrome file creation failed." ) );
            strReturnFileName.Empty();
            goto leave;
        }
    }
    else
    {
        // ... or by using an internal function (Image2Mono()).
        //
        // Note: Image2Mono() replaces the image in place, i. e.
        //       the monochrome image shows on the screen, too.
        //
        ::Image2Mono( GetImageSelection() ).SaveFile( strTempFileName, m_strBitmapMimeType );
    }

    // Do OCR using an external command.
    strCommand.Printf( bUseHocr ? m_strCmdOcrUseHocr : m_strCmdOcr,
                       strTempFileName.c_str(),
                       strTempFileName.c_str() );
#if __DEBUG__
    wxLogMessage( wxT( "wxIScanFrame::OCR - strCommand == '%s'" ), strCommand.c_str() );
#endif
    if( !Execute( strCommand ) )
    {
        wxLogError( wxString( wxT( "wxIScanFrame::OCR - " ) )
                      + _( "OCR failed." ) );
        strReturnFileName.Empty();
        goto leave;
    }

    strReturnFileName= strTempFileName + wxT( "." ) + ( bUseHocr ? m_strOcrOutputExtensionHocr : m_strOcrOutputExtension );

leave:
    // Clean up temporary image file.
    if(m_bCmdCleanUpEnable )
    {

        // Clean up.
        strCommand.Printf( m_strCmdCleanUp,
                           strTempFileName.c_str(),
                           strTempFileName.c_str() );
#if __DEBUG__
        wxLogMessage( wxT( "wxIScanFrame::OCR - strCommand == '%s'" ), strCommand.c_str() );
#endif
        Execute( strCommand );
    }

    // Clean up temporary hOCR file(s).
    if( bUseHocr && m_bCmdHocrCleanUpEnable )
    {

        // Clean up.
        strCommand.Printf( m_strCmdHocrCleanUp,
                           strTempFileName.c_str(),
                           strTempFileName.c_str() );
#if __DEBUG__
        wxLogMessage( wxT( "wxIScanFrame::OCR - strCommand == '%s'" ), strCommand.c_str() );
#endif
        Execute( strCommand );
    }

    // Return filename of the created text file (or an empty string on errors).
    return strReturnFileName;
}
void wxIScanFrame::OnCanvasSelected ( wxIViewCanvasSelectedEvent oEvent) [private]

Handle canvas selection events.

Definition at line 1714 of file wxiscanframe.cpp.

References wxIViewCanvasSelectedEvent::m_bAlt, wxIViewCanvasSelectedEvent::m_bCtrl, wxIViewCanvasSelectedEvent::m_bShift, m_oImage, wxIViewCanvasSelectedEvent::m_oSelection, OnDocumentCrop(), OnDocumentZoom(), RotateImage(), and UpdateBitmap().

{
    // Check if the CTRL key was pressed when the selection was finished.
    if( oEvent.m_bCtrl )
    {
        wxCommandEvent oDummyEvent;

        // Zoom the selected rect to fit in the canvas window.
        OnDocumentZoom( oDummyEvent );
    }

    // Check if the ALT key was pressed when the selection was finished.
    else if( oEvent.m_bAlt )
    {
        wxCommandEvent oDummyEvent;

        // Crop the selected rect.
        OnDocumentCrop( oDummyEvent );
    }

#if __NOTYETRELEASED__
    // Check if the SHIFT key was pressed when the selection was finished.
    else if( oEvent.m_bShift )
    {
        // ...
double nHeight= (double)( oEvent.m_oSelection.GetTop() - oEvent.m_oSelection.GetBottom() );//oEvent.m_oSelection.GetHeight();
double nWidth= (double)oEvent.m_oSelection.GetWidth();
double nAngle= asin( nHeight / sqrt( nHeight * nHeight + nWidth * nWidth ) );
m_oImage= ::RotateImage( m_oImage, nAngle );

        // ...
        UpdateBitmap();
    }
#endif // __NOTYETRELEASED__
}
void wxIScanFrame::OnCanvasSize ( wxIViewCanvasSizeEvent oEvent) [private]

Handle bitmap resizing introduced by canvas resizing.

Definition at line 1704 of file wxiscanframe.cpp.

References m_nFit, UpdateBitmap(), wxCANVASFITWIDTH, and wxCANVASFITWINDOW.

{
    if( ( m_nFit == wxCANVASFITWIDTH ) || ( m_nFit == wxCANVASFITWINDOW ) )
    {
        UpdateBitmap();
    }
}
void wxIScanFrame::OnClose ( wxCloseEvent &  event) [private]

Handle window closing requests.

Definition at line 780 of file wxiscanframe.cpp.

References CanClose().

Referenced by wx__DECLARE_EVT0().

{
    // Check if the content is "dirty" and veto closing
    // (if it is not forbidden).
    if( CanClose( oEvent.CanVeto() ) )
    {
        this->Destroy();
    }
    else
    {
        if( oEvent.CanVeto() )
        {
            oEvent.Veto();
        }
        else
        {
            this->Destroy();
        }
    }
}
void wxIScanFrame::OnCmdStop ( wxCommandEvent &  event) [private]

Handle (sub-)process killing.

Definition at line 1668 of file wxiscanframe.cpp.

References EnableControls(), wxExtProcess::Kill(), LogProcessOutput(), and m_poRunningProcess.

Referenced by wx__DECLARE_EVT0().

{
    // Check if the (sub-)process is running.
    if( m_poRunningProcess )
    {
        // Log process's output.
        LogProcessOutput( m_poRunningProcess );

        // Try to terminate the (sub-)process.
        //
        // NOTE: In case the process is not terminated properly
        //       it is at least detached and released from the
        //       the main process.
        m_poRunningProcess->Kill( wxSIGTERM, wxKILL_CHILDREN );
        m_poRunningProcess->Detach();

        // Mark (sub-)process pointer as "clean".
        m_poRunningProcess= NULL;
   }

   // Enable/disable menu options according to the actual state.
   EnableControls();
}
void wxIScanFrame::OnDocumentApplyProfile ( wxCommandEvent &  event) [private]

Apply a previously selected profile to the image.

Definition at line 1537 of file wxiscanframe.cpp.

References ApplyProfile(), and UpdateBitmap().

Referenced by wx__DECLARE_EVT0().

{
    // Apply an image profile (crop, convert to monochrome etc.), and ...
    ApplyProfile();

    // ... reset the image on the canvas window.
    UpdateBitmap();
}
void wxIScanFrame::OnDocumentCopyText ( wxCommandEvent &  event) [private]

Do OCR on the loaded/scanned image and copy the text to the system clipboard.

Definition at line 1351 of file wxiscanframe.cpp.

References bLuaReturnFromEventHandler, CopyText2Clipboard(), GetImageSelection(), GetTextFromFile(), m_strBitmapMimeType, and OCR().

Referenced by wx__DECLARE_EVT0().

{
    // Save image in a temporary JPEG file.
    wxString strTempFileName= wxFileName::CreateTempFileName( wxT( "" ) );

    GetImageSelection().SaveFile( strTempFileName, m_strBitmapMimeType );

    // Do OCR (and get the file name of the generated text file).
    wxString strOcrTextFileName= OCR( strTempFileName );

    // Remove the temporary JPEG file.
    ::wxRemoveFile( strTempFileName );

    // Get the text and copy it to the clipboard.
    if( !strOcrTextFileName.IsEmpty() )
    {
        // Copy text (from text file) to clipboard.
        ::CopyText2Clipboard( ::GetTextFromFile( strOcrTextFileName ) );

        // Remove the temporary text file
        ::wxRemoveFile( strOcrTextFileName );
    }
#if __WXLUASCRIPT__
    else
    {
        // Signal error to Lua.
        bLuaReturnFromEventHandler= false;
    }
#endif // __WXLUASCRIPT__
}
void wxIScanFrame::OnDocumentCrop ( wxCommandEvent &  event) [private]

Crop the image to the selected rectangle.

Definition at line 1451 of file wxiscanframe.cpp.

References EnableControls(), GetImageSelection(), m_oImage, ResetFileName(), and UpdateBitmap().

Referenced by OnCanvasSelected(), and wx__DECLARE_EVT0().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Get the selected subimage.
    m_oImage= GetImageSelection();

    // Replace the image by the selected subimage.
    UpdateBitmap();

    // Set the file name to unknown (because the main image changed).
    ResetFileName();

    // Enable/disable menu options according to the actual state.
    EnableControls();
}
void wxIScanFrame::OnDocumentFirstPage ( wxCommandEvent &  event) [private]

Go to first page of a multipage document.

Definition at line 1399 of file wxiscanframe.cpp.

References m_nPage, and OnDocumentPageChanged().

Referenced by wx__DECLARE_EVT0().

void wxIScanFrame::OnDocumentLastPage ( wxCommandEvent &  event) [private]

Go to last page of a multipage document.

Definition at line 1443 of file wxiscanframe.cpp.

References m_nImageCount, m_nPage, and OnDocumentPageChanged().

Referenced by wx__DECLARE_EVT0().

void wxIScanFrame::OnDocumentNextPage ( wxCommandEvent &  event) [private]

Go to next page of a multipage document.

Definition at line 1425 of file wxiscanframe.cpp.

References bLuaReturnFromEventHandler, m_nImageCount, m_nPage, and OnDocumentPageChanged().

Referenced by OnPdfAddPage(), and wx__DECLARE_EVT0().

{
    if( m_nPage < ( m_nImageCount - 1 ) )
    {
        m_nPage++;
        OnDocumentPageChanged();
    }
#if __WXLUASCRIPT__
    else
    {
            // Signal error to Lua.
            bLuaReturnFromEventHandler= false;
    }
#endif // __WXLUASCRIPT__
}
bool wxIScanFrame::OnDocumentPageChanged ( ) [virtual]

(Re)loads the (zero based) page number given in m_nPage.

Definition at line 1879 of file wxiscanframe.cpp.

References EnableControls(), m_nPage, m_oImage, m_strImageFileName, UpdateBitmap(), and UpdatePageNumber().

Referenced by OnDocumentFirstPage(), OnDocumentLastPage(), OnDocumentNextPage(), OnDocumentPreviousPage(), and OnTextCtrlPageProcessEnter().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Load the image by name and page number.
    if( !m_oImage.LoadFile( m_strImageFileName, wxBITMAP_TYPE_ANY, m_nPage ) )
    {
        // Signal error.
        return false;
    }

    // Get the image direction.
//    m_bPortrait= ( m_oImage.GetHeight() > m_oImage.GetWidth() );

    // Update the page number info in the statusbar and in the toolbar.
    UpdatePageNumber();

    // Show the image
    UpdateBitmap();

    // Update the menu and toolbar controls.
    EnableControls();

    // Signal success.
    return true;
}
void wxIScanFrame::OnDocumentPreviousPage ( wxCommandEvent &  event) [private]

Go to previous page of a multipage document.

Definition at line 1407 of file wxiscanframe.cpp.

References bLuaReturnFromEventHandler, m_nPage, and OnDocumentPageChanged().

Referenced by wx__DECLARE_EVT0().

{
    if( m_nPage > 0 )
    {
        m_nPage--;
        OnDocumentPageChanged();
    }
#if __WXLUASCRIPT__
    else
    {
            // Signal error to Lua.
            bLuaReturnFromEventHandler= false;
    }
#endif // __WXLUASCRIPT__
}
void wxIScanFrame::OnDocumentProfilesChooseProfile ( wxCommandEvent &  oEvent) [private]

Handle menu command "Document|Profile|[PROFILE #X]".

Select a profile from the corresponding sub menu.

Definition at line 1548 of file wxiscanframe.cpp.

References ID_DOCUMENTPROFILE0, and SetProfile().

Referenced by wx__DECLARE_EVT0().

{
    SetProfile( oEvent.GetId() - ID_DOCUMENTPROFILE0 );
}
void wxIScanFrame::OnDocumentReadText ( wxCommandEvent &  event) [private]

Do OCR on the loaded/scanned image and read the text out loud.

Definition at line 1385 of file wxiscanframe.cpp.

References bLuaReturnFromEventHandler, EnableControls(), ID_DOCUMENTREADTEXTSYNC, and ReadOut().

Referenced by wx__DECLARE_EVT0().

{
#if __WXLUASCRIPT__
    bLuaReturnFromEventHandler= ReadOut( oEvent.GetId() != ID_DOCUMENTREADTEXTSYNC );
#else
    ReadOut();
#endif // __WXLUASCRIPT__

    // Enable/disable menu options according to the actual state.
    EnableControls();
}
void wxIScanFrame::OnDocumentRotate90Left ( wxCommandEvent &  event) [private]

Rotate image by 90° to the left.

Definition at line 1513 of file wxiscanframe.cpp.

References m_oImage, and UpdateBitmap().

Referenced by wx__DECLARE_EVT0().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Rotate image and change image orientation.
    m_oImage= m_oImage.Rotate90( false );
    UpdateBitmap();
}
void wxIScanFrame::OnDocumentRotate90Right ( wxCommandEvent &  event) [private]

Rotate image by 90° to the right.

Definition at line 1525 of file wxiscanframe.cpp.

References m_oImage, and UpdateBitmap().

Referenced by wx__DECLARE_EVT0().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Rotate image and change image orientation.
    m_oImage= m_oImage.Rotate90( true );
    UpdateBitmap();
}
void wxIScanFrame::OnDocumentZoom ( wxCommandEvent &  event) [private]

Zoom the image to the selected rectangle to fit the canvas size.

Definition at line 1472 of file wxiscanframe.cpp.

References EnableControls(), wxIViewCanvas::GetSelection(), wxIViewCanvas::IsSelected(), m_nFit, m_poCanvas, UpdateBitmap(), and wxCANVASCUSTOMSIZE.

Referenced by OnCanvasSelected(), and wx__DECLARE_EVT0().

{
    // If there is nothing selected there is nothing to do at all.
    if( !m_poCanvas->IsSelected() )
    {
        // So just return.
        return;
    }

    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Calculate the new zoom factor.
    wxRect oSelection= m_poCanvas->GetSelection();
    wxSize oWindowSize= m_poCanvas->GetClientSize();
    double nScaleFactorX= (double)oWindowSize.GetWidth()  / (double)oSelection.GetWidth();
    double nScaleFactorY= (double)oWindowSize.GetHeight() / (double)oSelection.GetHeight();
    double nScaleFactor= ( nScaleFactorX < nScaleFactorY ) ? nScaleFactorX : nScaleFactorY;

    // Scale old zoom factor by the new one.
    m_nScaleFactor *= nScaleFactor;

    // Set zooming to fixed size.
    m_nFit= wxCANVASCUSTOMSIZE;

    // Rezoom the image.
    UpdateBitmap();

    // Scroll left upper corner of selection to the beginning of
    // the visuable part of the canvas.
    int nXUnit, nYUnit;
    m_poCanvas->GetScrollPixelsPerUnit( &nXUnit, &nYUnit );
    m_poCanvas->Scroll( (double)oSelection.GetX() * nScaleFactor / (double)nXUnit,
                        (double)oSelection.GetY() * nScaleFactor / (double)nYUnit );

    // Enable/disable menu options according to the actual state.
    EnableControls();
}
void wxIScanFrame::OnEditClearHistory ( wxCommandEvent &  event) [private]

Wipe out the file name history (under file menu).

Definition at line 1339 of file wxiscanframe.cpp.

References m_oFileHistory.

Referenced by wx__DECLARE_EVT0().

{
    // Delete file history entries.
    for( int i= m_oFileHistory.GetCount() - 1; i >= 0; i-- )
    {
        m_oFileHistory.RemoveFileFromHistory( i );
    }
}
void wxIScanFrame::OnEditClearLog ( wxCommandEvent &  event) [private]

Wipe out the log window.

Definition at line 1332 of file wxiscanframe.cpp.

References m_poLogTextCtrl.

Referenced by wx__DECLARE_EVT0().

{
    m_poLogTextCtrl->Clear();
}
void wxIScanFrame::OnEditCopy ( wxCommandEvent &  event) [private]

Copy the (selected part of the) image to the system clipboard.

Definition at line 1165 of file wxiscanframe.cpp.

References CopyImage2Clipboard(), and GetImageSelection().

Referenced by wx__DECLARE_EVT0().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Copy the (selected part of the) image to the system clipboard.
    ::CopyImage2Clipboard( GetImageSelection() );
}
void wxIScanFrame::OnEditPaste ( wxCommandEvent &  event) [private]

Replace the image by the content of the system clipboard.

Definition at line 1176 of file wxiscanframe.cpp.

References EnableControls(), m_oImage, ResetFileName(), and UpdateBitmap().

Referenced by wx__DECLARE_EVT0().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    wxBitmapDataObject oBitmapData;

    // Open the clipboard.
    //
    // Note: There is a global object ::wxTheClipboard.
    //
    if( !wxTheClipboard->Open() )
    {
        wxLogError( wxString( wxT( "wxIScanFrame::CopyImage2Clipboard -- " ) )
              + _( "Failed to open clipboard." ) );
    }

    // If there is bitmap data in the clipboard get it.
    if( wxTheClipboard->GetData( oBitmapData ) )
    {
        // Get the image from the bitmap data in the clipboard.
        wxBitmap oBitmap= oBitmapData.GetBitmap();

        m_oImage= oBitmap.ConvertToImage();
        UpdateBitmap();

        // Enable/disable menu options according to the actual state.
        EnableControls();
    }

    // Close the clipboard.
    wxTheClipboard->Close();

    // Reset the filename.
    ResetFileName();
}
void wxIScanFrame::OnEditScanScanners ( wxCommandEvent &  event) [private]

Scan for scanning devices and fill the corresponding wxChoice control in the toolbar.

Definition at line 1322 of file wxiscanframe.cpp.

Referenced by wx__DECLARE_EVT0().

{
#ifdef __WXSCANSANE__
    // Scan for scanning devices.
    ScanForScanners( true );
#endif // __WXSCANSANE__
}
void wxIScanFrame::OnEditSettings ( wxCommandEvent &  event) [private]

Edit program settings (using an wxOptionsDialog window).

Definition at line 1215 of file wxiscanframe.cpp.

References wxOptionsDialog::AppendOption(), EnableControls(), m_bAutoApplyProfile, m_bAutoApplyProfileOnMultiPage, m_bCmdCleanUpEnable, m_bCmdConvertEnable, m_bCmdEditEnable, m_bCmdHocrCleanUpEnable, m_bCmdHtml2XhtmlEnable, m_bCmdOcrEnable, m_bCmdTtsEnable, m_bHocrEnable, m_bLua, m_bOCR, m_bSmartHocrEnable, m_strBitmapMimeType, m_strCmdCleanUp, m_strCmdConvert, m_strCmdEdit, m_strCmdHocrCleanUp, m_strCmdHtml2Xhtml, m_strCmdOcr, m_strCmdOcrUseHocr, m_strCmdTts, m_strHocrClass, m_strOcrOutputExtension, m_strOcrOutputExtensionHocr, m_strPdfBitmapMimeType, and wxOptionsDialog::SetupDialog().

Referenced by wx__DECLARE_EVT0().

{
    // Get the global configuration object.
    wxConfigBase *poConfig = wxConfigBase::Get();
    poConfig->SetPath( wxT( "/Global" ) );

    // Get internationalization state flag directly from configuration.
    bool bI18n= (bool)poConfig->Read( wxT( "I18n" ), (long)true );

    // Get splashscreen state flag directly from configuration.
    bool bSplashscreen= (bool)poConfig->Read( wxT( "Splashscreen" ), (long)true );

    // Create, setup and display the options dialog (as a modal dialog).
#if __NOTYETRELEASED__ >= 2
    wxOptionsBookDialog oDialog( this, wxT( "Common" ) );
#else // __NOTYETRELEASED__
    wxOptionsDialog oDialog( this );
#endif // __NOTYETRELEASED__

    // Create, setup and display the options dialog (as a modal dialog).
    oDialog.AppendOption( new wxOptionCheckBox( _( "Use internationalization on next program start." ), &bI18n ) );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Show splashscreen at program startup." ), &bSplashscreen ) );
#if __WXLUASCRIPT__
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable Lua scripting." ), &m_bLua ) );
#endif // __WXLUASCRIPT__
    oDialog.AppendOption( new wxOptionCheckBox( _( "Automatically apply profile after scanning." ), &m_bAutoApplyProfile ) );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Automatically apply profile after loading a page from a multi page file." ), &m_bAutoApplyProfileOnMultiPage ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "Mime type of image exported:" ), &m_strBitmapMimeType, 150 ) );
    oDialog.AppendOption( new wxOptionStaticLine );
#if __WXPDFDOC__
    oDialog.AppendOption( new wxOptionCheckBox( _( "Use OCR when adding text to a PDF page." ), &m_bOCR ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "Mime type of image exported to a PDF page:" ), &m_strPdfBitmapMimeType, 150 ) );
    oDialog.AppendOption( new wxOptionStaticLine );
#endif // __WXPDFDOC__
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable OCR command." ), &m_bCmdOcrEnable ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "OCR command:" ), &m_strCmdOcr ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "Output extension of the extracted text:" ), &m_strOcrOutputExtension, 150 ) );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable hOCR processing." ), &m_bHocrEnable ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "OCR command to create hOCR output:" ), &m_strCmdOcrUseHocr ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "Output extension of the hOCR output file:" ), &m_strOcrOutputExtensionHocr, 150 ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "hOCR class in HOCR file to extract:" ), &m_strHocrClass, 150 ) );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Use smart hOCR processing." ), &m_bSmartHocrEnable ) );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable HTML to XHTML conversion." ), &m_bCmdHtml2XhtmlEnable ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "HTML to XHTML conversion command:" ), &m_strCmdHtml2Xhtml ) );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable image convertion command." ), &m_bCmdConvertEnable ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "Bitmap conversion command:" ), &m_strCmdConvert ) );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable clean up command." ), &m_bCmdCleanUpEnable ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "Clean up command:" ), &m_strCmdCleanUp ) );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable additional clean up after hOCR processing." ), &m_bCmdHocrCleanUpEnable ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "Additional clean up command after hOCR processing:" ), &m_strCmdHocrCleanUp ) );
    oDialog.AppendOption( new wxOptionStaticLine );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable TTS command." ), &m_bCmdTtsEnable ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "TTS command:" ), &m_strCmdTts, 500 ) );
    oDialog.AppendOption( new wxOptionStaticLine );
    oDialog.AppendOption( new wxOptionCheckBox( _( "Enable editor command." ), &m_bCmdEditEnable ) );
    oDialog.AppendOption( new wxOptionComboBox( _( "Editor command:" ), &m_strCmdEdit ) );
    // ... (Add another options.)

    oDialog.SetupDialog();

    if( oDialog.ShowModal() == wxID_OK )
    {
        // Get the global configuration object and set the config path.
        //
        // NOTE: We do this because wxConfigBase::Get() returns a global object
        //       that could have been changed by the option dialog itself.
        //
        poConfig= wxConfigBase::Get();
        poConfig->SetPath( wxT( "/Global" ) );

        // Set i18n flag state directly in configuration (file or registry).
        poConfig->Write( wxT( "I18n" ), (long)bI18n );

        // Set splashscreen flag state directly in configuration (file or registry).
        poConfig->Write( wxT( "Splashscreen" ), (long)bSplashscreen );

        // ... (Handle another options.)

        // Adjust control states.
        EnableControls();
    }
}
void wxIScanFrame::OnEditSettingsFile ( wxCommandEvent &  event) [private]

Start the configured editor to edit the configuration file.

Definition at line 1300 of file wxiscanframe.cpp.

References Execute(), m_strCmdEdit, RestoreSettings(), and SaveSettings().

Referenced by wx__DECLARE_EVT0().

{
    // Save programme settings.
    SaveSettings();

    // Open settings editor.
    wxFileConfig *poConfig = (wxFileConfig *)wxConfigBase::Get();
    wxString strConfigFilename= wxFileConfig::GetLocalFileName( poConfig->GetAppName() );
    wxString strCommand= wxString::Format( m_strCmdEdit, strConfigFilename.c_str() );

#if __DEBUG__
    wxLogMessage( wxT( "wxIScanFrame::OnEditSettings - strCommand == '%s'" ), strCommand.c_str() );
#endif
    Execute( strCommand );

    // Restore settings (from file).
    RestoreSettings();
}
void wxIScanFrame::OnFileDrop ( wxExtFileDropEvent oEvent) [private]

Handle file dropping.

Definition at line 803 of file wxiscanframe.cpp.

References wxExtFileDropEvent::GetFileName(), and OpenImage().

{
    // Open file.
    OpenImage( oEvent.GetFileName() );
}
void wxIScanFrame::OnFileOpen ( wxCommandEvent &  event) [private]

Handle menu command "File|Open...".

Definition at line 829 of file wxiscanframe.cpp.

References OpenImage().

Referenced by wx__DECLARE_EVT0().

{
    // Open an "Open file" dialog an let the user choose a filename.
    wxFileDialog oDlg( this,
                       _( "Open file" ),
                       wxT( "" ),
                       wxT( "" ),
                       ::wxGetApp().GetImageFilter(),
#if wxCHECK_VERSION( 2, 9, 0 )
                       wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_CHANGE_DIR );
#else
                       wxOPEN | wxFILE_MUST_EXIST | wxCHANGE_DIR );
#endif // wxCHECK_VERSION

    if( oDlg.ShowModal() == wxID_OK )
    {
        // Open file.
        OpenImage( oDlg.GetPath() );
    }
}
void wxIScanFrame::OnFilePrint ( wxCommandEvent &  oEvent) [private]

Handle menu command "File|Print".

Definition at line 887 of file wxiscanframe.cpp.

References AdjustOrientation(), bLuaReturnFromEventHandler, m_nImageCount, m_nResolution, m_oPrintData, m_oPrintImage, and m_strImageFileName.

Referenced by wx__DECLARE_EVT0().

{
    // ...
    AdjustOrientation();

    // Data object representing the print dialog's values.
    wxPrintDialogData oPrintDialogData( m_oPrintData );

    // Set the printer dialog's maximal page.
    oPrintDialogData.SetMaxPage( m_nImageCount );

    // Printer object.
    wxPrinter oPrinter( &oPrintDialogData );

    // ...
    wxIViewPrintout oPrintout( this, m_strImageFileName, false, m_nResolution, m_nResolution );

    // Create cancel dialog.
    oPrinter.CreateAbortWindow( this, &oPrintout );

    // Print.
    if( oPrinter.Print( this, &oPrintout, true ) )
    {
        m_oPrintData= oPrinter.GetPrintDialogData().GetPrintData();
    }
    else
    {
        if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
        {
            wxLogError( _( "An error occured while printing." ) );
#if __WXLUASCRIPT__
            // Signal error to Lua.
            bLuaReturnFromEventHandler= false;
#endif // __WXLUASCRIPT__
        }
    }

    // Destroy the print image (for to release MBs of memory).
    m_oPrintImage.Destroy();
}
void wxIScanFrame::OnFilePrintPreview ( wxCommandEvent &  oEvent) [private]

Handle menu command "File|Print Preview".

Definition at line 930 of file wxiscanframe.cpp.

References AdjustOrientation(), m_nResolution, m_oPrintData, m_oPrintImage, and m_strImageFileName.

Referenced by wx__DECLARE_EVT0().

{
    // ...
    AdjustOrientation();

    // Data object representing the print dialog's values.
    wxPrintDialogData oPrintDialogData( m_oPrintData );

    // Pass two printout objects: for preview, and possible printing.
    wxPrintPreview *poPreview = new wxPrintPreview(
        new wxIViewPrintout( this, m_strImageFileName, false, m_nResolution, m_nResolution ),
        new wxIViewPrintout( this, m_strImageFileName, false, m_nResolution, m_nResolution ),
        &oPrintDialogData );

    if ( !poPreview || !poPreview->Ok() )
    {
        if( poPreview )
        {
            delete poPreview;
        }
        wxLogError( _( "An error occured while creating print preview object.") );
        return;
    }

    // Set the zoom factor to 100%.
    poPreview->SetZoom( 100 );

    int x, y, w, h;

    // Get the frame window position and size and create a print preview
    // window with the same postion and size.
    GetSize( &w, &h );
    GetPosition( &x, &y );
    wxIViewPreviewFrame *poPreviewFrame= new wxIViewPreviewFrame(
                                          poPreview,
                                          this,
                                          _( "Print Preview" ),
                                          wxPoint( x, y ),
                                          wxSize( w, h ) );
    if( !poPreviewFrame )
    {
        delete poPreview;
        wxLogError( _( "An error occured while creating print preview window.") );
        return;
    }
    poPreviewFrame->Initialize();
    poPreviewFrame->Show();

    // Destory the print image (for to save MBs memory).
    m_oPrintImage.Destroy();
}
void wxIScanFrame::OnFilePrintSetup ( wxCommandEvent &  oEvent) [private]

Handle menu command "File|Page Setup ".

Definition at line 984 of file wxiscanframe.cpp.

References AdjustOrientation(), and m_oPrintData.

Referenced by wx__DECLARE_EVT0().

{
    // ...
    AdjustOrientation();

    wxPageSetupDialogData oPageSetupData( m_oPrintData );

    oPageSetupData.EnableOrientation( false );

    wxPageSetupDialog oPageSetupDialog( this, &oPageSetupData );

    if( oPageSetupDialog.ShowModal() == wxID_OK )
    {
        m_oPrintData= oPageSetupDialog.GetPageSetupData().GetPrintData();
    }
}
void wxIScanFrame::OnFileQuit ( wxCommandEvent &  event) [private]

Handle menu command "File|Quit".

Definition at line 1003 of file wxiscanframe.cpp.

Referenced by wx__DECLARE_EVT0().

{
    Close();
}
void wxIScanFrame::OnFileSaveAs ( wxCommandEvent &  event) [private]

Handle menu command "File|Save as...".

Definition at line 852 of file wxiscanframe.cpp.

References cstrAppName, GetImageSelection(), and m_strImageFileName.

Referenced by wx__DECLARE_EVT0().

{
    // Open a "Save file" dialog and let the user choose a filename.
    wxFileDialog oDlg( this,
                       _( "Save as" ),
                       wxT( "" ),
                       m_strImageFileName,
                       ::wxGetApp().GetImageFilter(),
#if wxCHECK_VERSION( 2, 9, 0 )
                       wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR );
#else
                       wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR );
#endif // wxCHECK_VERSION

    if( oDlg.ShowModal() == wxID_OK )
    {
        // Show hourglass cursor.
        wxBusyCursor oWait;

        // Save file.
        if( !GetImageSelection().SaveFile( oDlg.GetPath() ) )
        {
            // On error warn the user.
            wxLogError( wxT( "Image cannot be written to file '%s'." ), oDlg.GetPath().c_str() );
            return;
        }

        // Save the filename.
        m_strImageFileName= oDlg.GetPath();
        SetTitle( m_strImageFileName + wxT( " - " ) + cstrAppName );
    }
}
void wxIScanFrame::OnFileScanImage ( wxCommandEvent &  event) [private]

Handle menu command "File|Scan image".

Definition at line 811 of file wxiscanframe.cpp.

References bLuaReturnFromEventHandler, EnableControls(), and ScanImage().

Referenced by wx__DECLARE_EVT0().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Scan image.
#if __WXLUASCRIPT__
    bLuaReturnFromEventHandler= ScanImage();
#else
    ScanImage();
#endif // __WXLUASCRIPT__

    // Enable (additional) menu options after the 1st scan.
    EnableControls();
}
void wxIScanFrame::OnHelpAbout ( wxCommandEvent &  event) [private]

Handle menu command "Help|About...".

Definition at line 1694 of file wxiscanframe.cpp.

Referenced by wx__DECLARE_EVT0().

{
    // Create an show the program's about box.
    wxIScanAbout oAboutBox( this );

    oAboutBox.ShowModal();
}
void wxIScanFrame::OnMRUFiles ( wxCommandEvent &  oEvent) [private]

Handle menu command "File|[MOST RECENTLY USED FILE #X]".

Definition at line 1010 of file wxiscanframe.cpp.

References m_oFileHistory, and OpenImage().

{
    // Get the filename from history menu index, ...
    int nId= oEvent.GetId() - wxID_FILE1;
    wxString strFilename = m_oFileHistory.GetHistoryFile( nId );

    // ... check if it is valid, and reopen the image file.
    if( strFilename.IsEmpty() || !::wxFileExists( strFilename ) || !OpenImage( strFilename ) )
    {
        // Otherwise remove the file from the file name history, ...
        m_oFileHistory.RemoveFileFromHistory( nId );

        // and signal an error.
        wxLogError( wxString::Format( _( "File '%s' does not exist (any more) or cannot be opened." ),
                                        strFilename.c_str() ) );
    }
}
void wxIScanFrame::OnPdfAddPage ( wxCommandEvent &  event) [private]

Add the current image as a new page to the current PDF document.

Definition at line 1056 of file wxiscanframe.cpp.

References AddPdfPage(), ApplyProfile(), EnableControls(), m_bAutoApplyProfileOnMultiPage, m_nImageCount, m_nPage, and OnDocumentNextPage().

Referenced by wx__DECLARE_EVT0().

{
#if defined( __WXPDFDOC__ ) && __WXPDFDOC__ >= 1
    bool bAddAllPages= false;

    // On multipage images ask for permission to add all pages.
    if( ( m_nImageCount > 1 ) && ( m_nPage == 0 ) )
    {

        switch( ::wxMessageBox( _( "This is a multipage image. Do you want to "
                                   "add all image pages to the PDF file?" ),
                                ::wxGetApp().GetAppName(),
                                wxYES_DEFAULT | wxYES_NO | wxCANCEL | wxICON_QUESTION  ) )
        {
            case wxYES    : bAddAllPages= true;
                            break;
            case wxCANCEL : return;
        }
    }

    // Show busy cursor (until the automatic variable is destroyed).
    wxBusyCursor oWait;

    // Apply a profile automatically after loading a page from a
    // multi page file.
    if( bAddAllPages and m_bAutoApplyProfileOnMultiPage )
    {
        ApplyProfile();
    }

    // Add page to PDF document.
    AddPdfPage();

    // Add the following pages (if wished).
    if( bAddAllPages )
    {
        while( m_nPage < ( m_nImageCount - 1 ) )
        {
            // Load next image page.
            OnDocumentNextPage( oEvent );

            // Optionally apply a profile automatically after loading
            // a page from a multi page file.
            if( m_bAutoApplyProfileOnMultiPage )
            {
                ApplyProfile();
            }

            // Add page to PDF document.
            AddPdfPage();
        }
    }

    // Enable (additional) menu options.
    EnableControls();
#else
    wxLogError( _( "PDF support is not enabled." ) );
#endif
}
void wxIScanFrame::OnPdfBeginPdf ( wxCommandEvent &  event) [private]

Begin an new (empty) PDF document.

Definition at line 1030 of file wxiscanframe.cpp.

References CanClose(), CreateNewPdfDocument(), EnableControls(), m_poPanelPages, and wxImagePanel::Reset().

Referenced by OnPdfSavePdf(), and wx__DECLARE_EVT0().

{
#if defined( __WXPDFDOC__ ) && __WXPDFDOC__ >= 1
    if( !CanClose() )
    {
        return;
    }

    if( !CreateNewPdfDocument() )
    {
        return;
    }

    // Remove all thumbs from the the pages panel.
    m_poPanelPages->Reset();

    // Enable (additional) menu options.
    EnableControls();
#else
    wxLogError( _( "PDF support is not enabled." ) );
#endif
}
void wxIScanFrame::OnPdfSavePdf ( wxCommandEvent &  event) [private]

Save the current PDF document as a PDF file.

Definition at line 1118 of file wxiscanframe.cpp.

References m_bPdfDirty, m_poPdfDoc, and OnPdfBeginPdf().

Referenced by CanClose(), and wx__DECLARE_EVT0().

{
#if defined( __WXPDFDOC__ ) && __WXPDFDOC__ >= 1
    if( !m_poPdfDoc )
    {
        wxLogError( _( "wxPdfDocument is NULL" ) );
        return;
    }

    // Open a "Save file" dialog and let the user choose a filename.
    wxFileDialog oDlg( this,
                       _( "Save as" ),
                       wxT( "" ),
                       _( "unknown.pdf" ),
                       _( "PDF file" ) + wxString( wxT( " (*.pdf)|*.pdf|" ) )
                       + _( "All files" ) + wxString( wxT( "|*.*" ) ),
#if wxCHECK_VERSION( 2, 9, 0 )
                       wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxFD_CHANGE_DIR );
#else
                       wxSAVE | wxOVERWRITE_PROMPT | wxCHANGE_DIR );
#endif // wxCHECK_VERSION( 2, 9, 0 )

    if( oDlg.ShowModal() == wxID_OK )
    {
        // Show busy cursor (until the automatic variable is destroyed).
        wxBusyCursor oWait;

        // Save file.
        //
        // NOTE: At the moment there is no error checking on writing the
        //       PDF file. Does anyone know a (real) workaround?
        m_poPdfDoc->SaveAsFile( oDlg.GetPath() );

        // Mark PDF document as 'clean'.
        m_bPdfDirty= false;

        // Create a new PDF document.
        OnPdfBeginPdf( oEvent );
    }
#else
    wxLogError( _( "PDF support is not enabled." ) );
#endif
}
void wxIScanFrame::OnProcessTerminated ( wxProcessEvent &  oEvent) [private]

Handle process termination.

Definition at line 1752 of file wxiscanframe.cpp.

References EnableControls(), LogProcessOutput(), and m_poRunningProcess.

{
    if( m_poRunningProcess )
    {
        // Log process's output.
        LogProcessOutput( m_poRunningProcess );

        // Delete the process and set its pointer to NULL.
        delete m_poRunningProcess;
        m_poRunningProcess= NULL;
    }

    // Enable/disable menu options according to the actual state.
    EnableControls();
}
void wxIScanFrame::OnScriptStartScript ( wxCommandEvent &  oEvent) [private]

Handle menu command "Scripts|[SCRIPT NAME]".

Definition at line 1629 of file wxiscanframe.cpp.

References EnableControls(), ID_DOCUMENTPROFILE0, and StartScript().

Referenced by wx__DECLARE_EVT0().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Let the system do the showing the hourglass cursor.
    ::wxSafeYield();

    // Get the script index, ...
    int nIndex= oEvent.GetId() - ( ID_DOCUMENTPROFILE0 + 1000 );

    // ... and get the filename and the start up ("main") function.
    wxConfigBase *poConfig= wxConfigBase::Get();

    poConfig->SetPath( wxString::Format( wxT( "/Script/%d" ), nIndex ) );

    wxString strScriptStartupFunction= poConfig->Read( wxT( "Function" ), wxT( "" ) );
    wxString strScriptFileName= poConfig->Read( wxT( "Script" ), wxT( "" ) );

    if( strScriptStartupFunction.IsEmpty() )
    {
        // Signal error.
        wxLogError( wxString( wxT( "wxIScanFrame::OnScriptStartScript -- " ) )
                      + _( "Script startup function is empty." ) );
        return;
    }
    else
    {
        // Run script
        StartScript( strScriptStartupFunction, strScriptFileName );
    }

    // Enable/disable menu options according to the actual state.
    EnableControls();
}
void wxIScanFrame::OnTextCtrlPageProcessEnter ( wxCommandEvent &  oEvent) [private]

Handle page number editor field events.

Definition at line 1770 of file wxiscanframe.cpp.

References m_nImageCount, m_nPage, m_poTextCtrlPage, and OnDocumentPageChanged().

{
    long nNewPage;

    if( m_poTextCtrlPage->GetValue().ToLong( &nNewPage )
        && ( 0 < nNewPage )
        && ( nNewPage <=  m_nImageCount ) )
    {
        m_nPage= nNewPage - 1;
        OnDocumentPageChanged();
    }
}
void wxIScanFrame::OnViewCloseDebugWindow ( wxCommandEvent &  event) [private]

Close the debug window.

Definition at line 1612 of file wxiscanframe.cpp.

References m_poHSplitterWindow.

Referenced by wx__DECLARE_EVT0().

{
    // Close the debug window by moving the the sash downwards.
    m_poHSplitterWindow->SetSashPosition( -1 );
}
void wxIScanFrame::OnViewClosePreviewPanel ( wxCommandEvent &  event) [private]

Close the preview panel window.

Definition at line 1620 of file wxiscanframe.cpp.

References m_poVSplitterWindow.

Referenced by wx__DECLARE_EVT0().

{
    // Close the preview panel window by moving the the sash right.
    m_poVSplitterWindow->SetSashPosition( -1 );
}
void wxIScanFrame::OnViewFit ( wxCommandEvent &  event) [private]

Select an image fitting option.

Definition at line 1555 of file wxiscanframe.cpp.

References EnableControls(), ID_VIEWCUSTOMSIZE, ID_VIEWFITWIDTH, ID_VIEWFITWINDOW, ID_VIEWFULLSIZE, ID_VIEWZOOMIN, ID_VIEWZOOMOUT, m_nFit, m_nScaleFactor, m_nZoomFactor, UpdateBitmap(), wxCANVASCUSTOMSIZE, wxCANVASFITWIDTH, wxCANVASFITWINDOW, and wxCANVASFULLSIZE.

Referenced by wx__DECLARE_EVT0().

{
    // Save the old fitting state and the old scalation
    // factor (for optimizing see below).
    int nFitOld= m_nFit;
    double nScaleFactorOld= m_nScaleFactor;

    // Transform the given event into an option value.
    if( oEvent.GetId() == ID_VIEWFITWIDTH )
    {
        m_nFit= wxCANVASFITWIDTH;
    }
    else if( oEvent.GetId() == ID_VIEWFITWINDOW )
    {
        m_nFit= wxCANVASFITWINDOW;
    }
    else if( oEvent.GetId() == ID_VIEWFULLSIZE )
    {
        m_nFit= wxCANVASFULLSIZE;
    }
    else if( oEvent.GetId() == ID_VIEWCUSTOMSIZE )
    {
        m_nFit= wxCANVASCUSTOMSIZE;
    }
    else if( oEvent.GetId() == ID_VIEWZOOMIN )
    {
        m_nFit= wxCANVASCUSTOMSIZE;
        m_nScaleFactor *= ( 1.0 + m_nZoomFactor );
    }
    else if( oEvent.GetId() == ID_VIEWZOOMOUT )
    {
        m_nFit= wxCANVASCUSTOMSIZE;
        m_nScaleFactor /= ( 1.0 + m_nZoomFactor );
    }

    // Optimization: If the fitting state and the scalation
    // factor hasn't changed just do nothing.
    if( ( nFitOld != m_nFit ) || ( nScaleFactorOld != m_nScaleFactor ) )
    {
        // Otherwise (re)zoom the image.
        UpdateBitmap();
    }

    // Enable/disable menu options according to the actual state.
    EnableControls();
}
void wxIScanFrame::OnViewFullScreen ( wxCommandEvent &  event) [private]

Toggle full screen mode.

Definition at line 1604 of file wxiscanframe.cpp.

References ToggleFullScreen().

Referenced by wx__DECLARE_EVT0().

{
    // Toggle full screen mode.
    ToggleFullScreen();
}
bool wxIScanFrame::OpenImage ( const wxString &  strFileName,
bool  bSetFileName = true 
) [virtual]

Open an image using the given name.

Definition at line 1818 of file wxiscanframe.cpp.

References cstrAppName, EnableControls(), m_nImageCount, m_nPage, m_nResolution, m_oFileHistory, m_oImage, m_strImageFileName, UpdateBitmap(), and UpdatePageNumber().

Referenced by wxIScanApp::OnCmdLineParsed(), OnFileDrop(), OnFileOpen(), OnMRUFiles(), and wxIScanLuaScript::OpenImage().

{
    // Show hourglass cursor.
    wxBusyCursor oWait;

    // Save the filename.
    wxFileName oFileName( strFileName );
    oFileName.Normalize();
    wxString strFileNameFullPath= oFileName.GetFullPath();

    // Open file.
    if( !m_oImage.LoadFile( strFileNameFullPath ) )
    {
        // Signal error;
        return false;
    }

    // Set filename to new one (if indicated).
    if( bSetFileName )
    {
        m_strImageFileName= strFileNameFullPath;
        SetTitle( m_strImageFileName + wxT( " - " ) + cstrAppName );
    }

    // Get the image count and reset the page number.
    m_nImageCount= m_oImage.GetImageCount( m_strImageFileName );
    m_nPage= 0;

    // Update the page number info in the statusbar and in the toolbar.
    UpdatePageNumber();

    // Get the image resolution (or use the resolution value of the last
    // acquired/loaded image by not changing the resolution).
    if( m_oImage.HasOption( wxIMAGE_OPTION_RESOLUTION ) )
    {
        m_nResolution= m_oImage.GetOptionInt( wxIMAGE_OPTION_RESOLUTION );
    }
    else if( m_oImage.HasOption( wxIMAGE_OPTION_RESOLUTIONX ) )
    {
        m_nResolution= m_oImage.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONX );
    }
    else if( m_oImage.HasOption( wxIMAGE_OPTION_RESOLUTIONY ) )
    {
        m_nResolution= m_oImage.GetOptionInt( wxIMAGE_OPTION_RESOLUTIONY );
    }

    // Show the image on the canvas window.
    UpdateBitmap();

    // Enable (additional) menu options after the 1st scan.
    EnableControls();

    // Add filename to file history.
    m_oFileHistory.AddFileToHistory( m_strImageFileName );

    // Signal success.
    return true;
}
bool wxIScanFrame::Paint ( wxDC &  oDc) [virtual]

Paints the image while printing or print previewing.

Implements wxIViewPaintBase.

Definition at line 3219 of file wxiscanframe.cpp.

References m_oPrintImage.

{
    // If there is a bitmap connected to this canvas window (re)paint it.
#if wxCHECK_VERSION( 2, 9, 0 )
    if( oDc.IsOk() && m_oPrintImage.Ok() )
#else
    if( oDc.Ok() && m_oPrintImage.Ok() )
#endif // wxCHECK_VERSION( 2, 9, 0 )

    {
        // Repaint the bitmap.
        oDc.DrawBitmap( wxBitmap( m_oPrintImage ), 0, 0 );
        return true;
    }
    else
    {
        return false;
    }
}
bool wxIScanFrame::ReadOut ( bool  bAsync = true) [virtual]

Do OCR and read out the returned text.

Parameters:
bAsyncstart the read out asynchronously, defaults to true.

Definition at line 2352 of file wxiscanframe.cpp.

References Execute(), GetImageSelection(), m_strBitmapMimeType, m_strCmdTts, and OCR().

Referenced by OnDocumentReadText().

{
    // Save image in a temporary JPEG file.
    wxString strTempFileName= wxFileName::CreateTempFileName( wxT( "" ) );

    GetImageSelection().SaveFile( strTempFileName, m_strBitmapMimeType );

    // Do OCR, and get the temporary text file name.
    wxString strTempTextFileName= OCR( strTempFileName );

    // Remove temporary JPEG file.
    ::wxRemoveFile( strTempFileName );

    // Read the text using a custom command (if it is not the empty string).
    if( strTempTextFileName.IsEmpty() )
    {
        // Signal error.
        return false;
    }

    wxString strCommand= wxString::Format( m_strCmdTts, strTempTextFileName.c_str() );

#if __DEBUG__
    wxLogMessage( wxT( "wxIScanFrame::ReadText - strCommand == '%s'" ), strCommand.c_str() );
#endif

    // Execute the read out process.
    return Execute( strCommand, bAsync, strTempTextFileName );
}
void wxIScanFrame::ResetFileName ( ) [virtual]

Reset the filename to "unknown.jpg" etc.

Definition at line 2468 of file wxiscanframe.cpp.

References cstrAppName, m_nImageCount, m_nPage, m_strImageFileName, and UpdatePageNumber().

Referenced by OnDocumentCrop(), OnEditPaste(), wxIScanLuaScript::ResetFileName(), and ScanImage().

{
    // Reset the file name.
    m_strImageFileName= _( "unknown.jpg" );
    SetTitle( cstrAppName );

    // Reset the image count, the page number and the image filename.
    m_nImageCount= 1;
    m_nPage= 0;

    // Update the page number info in the statusbar and in the toolbar.
    UpdatePageNumber();
}
void wxIScanFrame::RestoreSashSettings ( ) [virtual]

Restore sash settings from config file.

Definition at line 3093 of file wxiscanframe.cpp.

References cstrwxFrame, m_poHSplitterWindow, and m_poVSplitterWindow.

Referenced by wxIScanApp::OnInit(), and RestoreSettings().

{
    // Reset window settings.
    wxConfigBase *poConfig = wxConfigBase::Get();
    poConfig->SetRecordDefaults();
    poConfig->SetPath( wxT( "/" )  );
    poConfig->SetPath( cstrwxFrame );

    // Reset sash positions and splitting options.
    int nHSashPos= poConfig->Read( wxT( "HSashPos" ), -1 );
    int nVSashPos= poConfig->Read( wxT( "VSashPos" ), -1 );

    m_poHSplitterWindow->SetSashPosition( nHSashPos );
    m_poVSplitterWindow->SetSashPosition( nVSashPos );
}
void wxIScanFrame::RestoreSettings ( ) [virtual]

Restore program settings from config file.

Definition at line 3016 of file wxiscanframe.cpp.

References cstrwxFrame, m_bAutoApplyProfile, m_bAutoApplyProfileOnMultiPage, m_bCmdCleanUpEnable, m_bCmdConvertEnable, m_bCmdEditEnable, m_bCmdHocrCleanUpEnable, m_bCmdHtml2XhtmlEnable, m_bCmdOcrEnable, m_bCmdTtsEnable, m_bHocrEnable, m_bLua, m_bOCR, m_bSmartHocrEnable, m_nFit, m_nResolution, m_oPrintData, m_strBitmapMimeType, m_strCmdCleanUp, m_strCmdConvert, m_strCmdEdit, m_strCmdHocrCleanUp, m_strCmdHtml2Xhtml, m_strCmdOcr, m_strCmdOcrUseHocr, m_strCmdTts, m_strHocrClass, m_strOcrOutputExtension, m_strOcrOutputExtensionHocr, m_strPdfBitmapMimeType, RestoreSashSettings(), ToggleFullScreen(), and wxCANVASFITWINDOW.

Referenced by OnEditSettingsFile().

{
    // Reset window settings.
    wxConfigBase *poConfig = wxConfigBase::Get();
    poConfig->SetRecordDefaults();
    poConfig->SetPath( wxT( "/" )  );
    poConfig->SetPath( cstrwxFrame );

    int x= poConfig->Read( wxT( "x" ),   5 );
    int y= poConfig->Read( wxT( "y" ),   5 );
    int w= poConfig->Read( wxT( "w" ), 630 );
    int h= poConfig->Read( wxT( "h" ), 470 );
    bool bMaximized= (bool)poConfig->Read( wxT( "Maximized"  ), (long)false );
    bool bIconized= (bool)poConfig->Read( wxT( "Iconized"  ), (long)false );
    bool bFullScreen= (bool)poConfig->Read( wxT( "FullScreen"  ), (long)false );

    // Reset window position, size, maximization and full screen state.
    Move( x, y );
    SetSize( w, h );
    Maximize( bMaximized );
    Iconize( bIconized );
    if( bFullScreen )
    {
        ToggleFullScreen();
    }

    // Reset ...
    m_oPrintData.SetPaperId( (wxPaperSize)poConfig->Read( wxT( "PaperSize" ), (long)wxPAPER_A4 ) );
    m_nFit= poConfig->Read( wxT( "Fit" ), wxCANVASFITWINDOW );
    poConfig->Read( wxT( "ScaleFactor" ), &m_nScaleFactor );
    poConfig->Read( wxT( "ZoomFactor" ), &m_nZoomFactor );

    // Reset bitmap mimetype for everything but pdf export.
    m_strBitmapMimeType= poConfig->Read( wxT( "BitmapMimeType" ), wxT( "image/tiff" ) );

#if __WXPDFDOC__
    // Reset bitmap mimetype for pdf export.
    m_strPdfBitmapMimeType= poConfig->Read( wxT( "PdfBitmapMimeType" ), wxT( "image/png" ) );
#endif // __WXPDFDOC__

    // Get OCR and tts configuration.
    m_bAutoApplyProfile= (bool)poConfig->Read( wxT( "AutoApplyProfile" ), (long)false );
    m_bAutoApplyProfileOnMultiPage= (bool)poConfig->Read( wxT( "AutoApplyProfileOnMultiPage" ), (long)false );
    m_strOcrOutputExtension= poConfig->Read( wxT( "OcrOutputExtension" ), wxT( "txt" ) );
    m_bCmdConvertEnable= poConfig->Read( wxT( "CmdConvertEnable" ), (long)false );
    m_strCmdConvert= poConfig->Read( wxT( "CmdConvert" ), wxT( "convert %s -compress Group4 %s.tif" ) );
    m_bCmdOcrEnable= poConfig->Read( wxT( "CmdOcrEnable" ), (long)false );
    m_strCmdOcr= poConfig->Read( wxT( "CmdOcr" ), wxT( "cuneiform -f text -o %s.txt %s.tif" ) );
    m_bOCR= (bool)poConfig->Read( wxT( "OCR" ), (long)false );
#if __WXLUASCRIPT__
    m_bLua= (bool)poConfig->Read( wxT( "Lua" ), (long)false );
#endif // __WXLUASCRIPT__
    m_bCmdCleanUpEnable= poConfig->Read( wxT( "CmdCleanUpEnable" ), (long)false );
    m_strCmdCleanUp= poConfig->Read( wxT( "CmdCleanUp" ), wxT( "rm %s.tif" ) );
    m_bCmdTtsEnable= poConfig->Read( wxT( "CmdTtsEnable" ), (long)false );
    m_strCmdTts= poConfig->Read( wxT( "CmdTts" ), wxT( "espeak -f %s" ) );
    m_bCmdEditEnable= poConfig->Read( wxT( "CmdEditEnable" ), (long)false );
    m_strCmdEdit= poConfig->Read( wxT( "CmdEdit" ), wxT( "scite %s" ) );
    m_bHocrEnable= poConfig->Read( wxT( "HocrEnable" ), (long)false );
    m_strHocrClass= poConfig->Read( wxT( "HocrClass" ), wxT( "ocr_line" ) );
    m_bSmartHocrEnable= poConfig->Read( wxT( "SmartHocrEnable" ), (long)false );
    m_strCmdOcrUseHocr= poConfig->Read( wxT( "CmdOcrUseHocr" ), wxT( "cuneiform -f hocr -o %s.html %s.tif" ) );
    m_strOcrOutputExtensionHocr= poConfig->Read( wxT( "OcrOutputExtensionHocr" ), wxT( "html" ) );
    m_bCmdHtml2XhtmlEnable= poConfig->Read( wxT( "CmdHtml2XhtmlEnable" ), (long)false );
    m_strCmdHtml2Xhtml= poConfig->Read( wxT( "CmdHtml2Xhtml" ), wxT( "tidy -q -m -numeric -asxhtml -utf8 %s" ) );
    m_bCmdHocrCleanUpEnable= poConfig->Read( wxT( "CmdHocrCleanUpEnable" ), (long)false );
    m_strCmdHocrCleanUp= poConfig->Read( wxT( "CmdHocrCleanUp" ), wxT( "rm -r %s_files" ) );

    // Restore the standard resolution.
    m_nResolution= poConfig->Read( wxT( "Resolution" ), 300 );

    // Reset sash positions and splitting options.
    RestoreSashSettings();
}
void wxIScanFrame::SaveSettings ( ) [virtual]

Save program settings in config file.

Definition at line 3111 of file wxiscanframe.cpp.

References cstrwxFrame, m_bAutoApplyProfile, m_bAutoApplyProfileOnMultiPage, m_bCmdCleanUpEnable, m_bCmdConvertEnable, m_bCmdEditEnable, m_bCmdHocrCleanUpEnable, m_bCmdHtml2XhtmlEnable, m_bCmdOcrEnable, m_bCmdTtsEnable, m_bHocrEnable, m_bLua, m_bOCR, m_bSmartHocrEnable, m_nFit, m_nResolution, m_oFileHistory, m_oPrintData, m_poHSplitterWindow, m_poVSplitterWindow, m_strBitmapMimeType, m_strCmdCleanUp, m_strCmdConvert, m_strCmdEdit, m_strCmdHocrCleanUp, m_strCmdHtml2Xhtml, m_strCmdOcr, m_strCmdOcrUseHocr, m_strCmdTts, m_strHocrClass, m_strOcrOutputExtension, m_strOcrOutputExtensionHocr, m_strPdfBitmapMimeType, and ToggleFullScreen().

Referenced by OnEditSettingsFile(), and ~wxIScanFrame().

{
    // Save configuration data.
    wxConfigBase *poConfig= wxConfigBase::Get();

    poConfig->SetPath( wxT( "/" ) );
    poConfig->SetPath( cstrwxFrame );

    // Save iconifization state.
    poConfig->Write( wxT( "Iconized" ),  (long)IsIconized() );
    if( IsIconized() )
    {
        Iconize( false );
    }

    // Save maximization state.
    poConfig->Write( wxT( "Maximized" ),  (long)IsMaximized() );
    if( IsMaximized() )
    {
        Maximize( false );
        ::wxSafeYield();
        ::wxSafeYield();
    }

    // Save full screen state.
    poConfig->Write( wxT( "FullScreen" ),  (long)IsFullScreen() );
    if( IsFullScreen() )
    {
        ToggleFullScreen();
        ::wxSafeYield();
        ::wxSafeYield();
        ::wxSafeYield();
    }

    // Save window position and size.
    //
    int x, y, w, h;

    GetSize( &w, &h );
    GetPosition( &x, &y );
    poConfig->Write( wxT( "x" ), (long)x );
    poConfig->Write( wxT( "y" ), (long)y );
    poConfig->Write( wxT( "w" ), (long)w );
    poConfig->Write( wxT( "h" ), (long)h );

    // Save the sash positions.
    poConfig->Write( wxT( "HSashPos" ), (long)m_poHSplitterWindow->GetSashPosition() );
    poConfig->Write( wxT( "VSashPos" ), (long)m_poVSplitterWindow->GetSashPosition() );

    // Save the resolution as standard resolution.
    poConfig->Write( wxT( "Resolution" ), (long)m_nResolution );

    // ...
    poConfig->Write( wxT( "PaperSize" ), (long)m_oPrintData.GetPaperId() );
    poConfig->Write( wxT( "Fit" ), (long)m_nFit );
    poConfig->Write( wxT( "ScaleFactor" ), m_nScaleFactor );
    poConfig->Write( wxT( "ZoomFactor" ), m_nZoomFactor );

    // ...
    poConfig->Write( wxT( "BitmapMimeType" ), m_strBitmapMimeType );

#if __WXPDFDOC__
    // ...
    poConfig->Write( wxT( "PdfBitmapMimeType" ), m_strPdfBitmapMimeType );
#endif // __WXPDFDOC__

    // ...
    poConfig->Write( wxT( "AutoApplyProfile" ), (long)m_bAutoApplyProfile );
    poConfig->Write( wxT( "AutoApplyProfileOnMultiPage" ), (long)m_bAutoApplyProfileOnMultiPage );
    poConfig->Write( wxT( "OCR" ), (long)m_bOCR );
#if __WXLUASCRIPT__
    poConfig->Write( wxT( "Lua" ), (long)m_bLua );
#endif // __WXLUASCRIPT__
    poConfig->Write( wxT( "CmdConvertEnable" ), (long)m_bCmdConvertEnable );
    poConfig->Write( wxT( "CmdConvert" ), m_strCmdConvert );
    poConfig->Write( wxT( "CmdOcrEnable" ), (long)m_bCmdOcrEnable );
    poConfig->Write( wxT( "CmdOcr" ), m_strCmdOcr );
    poConfig->Write( wxT( "OcrOutputExtension" ), m_strOcrOutputExtension );
    poConfig->Write( wxT( "CmdCleanUpEnable" ), (long)m_bCmdCleanUpEnable );
    poConfig->Write( wxT( "CmdCleanUp" ), m_strCmdCleanUp );
    poConfig->Write( wxT( "CmdTtsEnable" ), (long)m_bCmdTtsEnable );
    poConfig->Write( wxT( "CmdTts" ), m_strCmdTts );
    poConfig->Write( wxT( "CmdEditEnable" ), (long)m_bCmdEditEnable );
    poConfig->Write( wxT( "CmdEdit" ), m_strCmdEdit );
    poConfig->Write( wxT( "HocrEnable" ), (long)m_bHocrEnable );
    poConfig->Write( wxT( "HocrClass" ), m_strHocrClass );
    poConfig->Write( wxT( "SmartHocrEnable" ), (long)m_bSmartHocrEnable );
    poConfig->Write( wxT( "CmdOcrUseHocr" ), m_strCmdOcrUseHocr );
    poConfig->Write( wxT( "OcrOutputExtensionHocr" ), m_strOcrOutputExtensionHocr );
    poConfig->Write( wxT( "CmdHtml2XhtmlEnable" ), (long)m_bCmdHtml2XhtmlEnable );
    poConfig->Write( wxT( "CmdHtml2Xhtml" ), m_strCmdHtml2Xhtml );
    poConfig->Write( wxT( "CmdHocrCleanUpEnable" ), (long)m_bCmdHocrCleanUpEnable );
    poConfig->Write( wxT( "CmdHocrCleanUp" ), m_strCmdHocrCleanUp );

    // ...
    poConfig->Write( wxT( "ProfileIndex" ), m_nProfileIndex );

    // Save file history to config file.
    poConfig->SetPath( wxT( "/Files" ) );
    m_oFileHistory.Save( *poConfig );
}
bool wxIScanFrame::ScanImage ( ) [virtual]

Get an image from scanner.

Definition at line 1997 of file wxiscanframe.cpp.

References ApplyProfile(), m_bAutoApplyProfile, m_nResolution, m_oImage, m_poScanner, ResetFileName(), and UpdateBitmap().

Referenced by OnFileScanImage().

{
#ifdef __WXSCANSANE__
    // Enter critical section to protect m_poScanner.
    m_oCriticalSectionScanner.Enter();

    // ...
    if( !m_poScanner->SetDeviceIndex( m_poChoiceScanner->GetSelection() ) )
    {
        wxLogWarning( ( m_poScanner->GetDeviceCount() ? _( "The selected scanning device is invald." )
                                                        : _( "No scanning device found." ) )
                        + wxString( wxT( " " ) )
                        + _( "Rescanning for scanning devices..." ) );

        // Leave the critical section that protects m_poScanner.
        //
        // Note: We do this because ScanForScanners() enters the
        //       the same critical section.
        //
        m_oCriticalSectionScanner.Leave();

        // Rescan for scanning devices.
        ScanForScanners();

        if( !m_poScanner->SetDeviceIndex( m_poChoiceScanner->GetSelection() ) )
        {
            wxLogError( m_poScanner->GetDeviceCount() ? _( "The selected scanning device is invald." )
                                                        : _( "No scanning device found." ) );
            return false;
        }

        // Reenter critical section to protect m_poScanner.
        m_oCriticalSectionScanner.Enter();
    }
#endif // __WXSCANSANE__

    // Check if the scanner object initialization was successful.
    if( !m_poScanner->IsOk() )
    {
        wxLogError( _( "Cannot initialize scanner object." ) );
        return false;
    }

    // Scan an image, ...
    if( !m_poScanner->ScanImage( m_oImage ) )
    {
        wxLogError( _( "An error occured while scanning." ) );
        return false;
    }

    // ... get its resolution, ...
    m_nResolution= m_poScanner->GetResolution();

#ifdef __WXSCANSANE__
    // Leave the critical section that protects m_poScanner.
    m_oCriticalSectionScanner.Leave();
#endif // __WXSCANSANE__

    // ... apply an image profile (crop, convert to monochrome etc.), and ...
    if( m_bAutoApplyProfile )
    {
        ApplyProfile();
    }

    // ... show the image on the canvas window.
    UpdateBitmap();

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

    // Signal success.
    return true;
}
void wxIScanFrame::SetProfile ( int  nProfileIndex) [virtual]

Select a profile (by number).

Definition at line 2181 of file wxiscanframe.cpp.

References ID_DOCUMENTPROFILE0.

Referenced by OnDocumentProfilesChooseProfile().

{
    GetMenuBar()->Check( ID_DOCUMENTPROFILE0 + m_nProfileIndex, false );
    m_nProfileIndex= nProfileIndex;
    GetMenuBar()->Check( ID_DOCUMENTPROFILE0 + m_nProfileIndex, true  );
}
void wxIScanFrame::StartScript ( const wxString &  strScriptStartupFunction,
wxString  strScriptFileName = wxEmptyString 
) [virtual]

Start a Lua script from a give file.

Parameters:
strScriptStartupFunctionstartup function of the Lua script
strScriptFileNamefile name of the text file containing the Lua script (defaults to the empty string which means, that no script is to be loaded before running the start up function).

Definition at line 2841 of file wxiscanframe.cpp.

References bLuaReturnFromEventHandler, cstrAppName, GetTextFromFile(), ID_CMDSTOP, ID_DOCUMENTAPPLYPROFILE, ID_DOCUMENTCOPYTEXT, ID_DOCUMENTCROP, ID_DOCUMENTLASTPAGE, ID_DOCUMENTNEXTPAGE, ID_DOCUMENTPREVIOUSPAGE, ID_DOCUMENTREADTEXT, ID_DOCUMENTROTATE90LEFT, ID_DOCUMENTROTATE90RIGHT, ID_EDITCOPY, ID_EDITPASTE, ID_EDITSETTINGS, ID_EDITSETTINGSFILE, ID_FILEOPEN, ID_FILEPRINT, ID_FILEPRINTPREVIEW, ID_FILEPRINTSETUP, ID_FILEQUIT, ID_FILESAVEAS, ID_FILESCANIMAGE, ID_HELPABOUT, ID_PDFADDPAGE, ID_PDFBEGINPDF, ID_PDFSAVEASPDF, ID_VIEWCUSTOMSIZE, ID_VIEWFITWIDTH, ID_VIEWFITWINDOW, ID_VIEWFULLSCREEN, ID_VIEWFULLSIZE, wxLuaScript::IsOk(), m_bAutoApplyProfile, m_bAutoApplyProfileOnMultiPage, m_bCmdCleanUpEnable, m_bCmdConvertEnable, m_bCmdEditEnable, m_bCmdHocrCleanUpEnable, m_bCmdHtml2XhtmlEnable, m_bCmdOcrEnable, m_bCmdTtsEnable, m_bHocrEnable, m_bOCR, m_bPdfDirty, m_bSmartHocrEnable, m_nImageCount, m_nPage, m_nPdfPages, m_nResolution, m_strBitmapMimeType, m_strCmdCleanUp, m_strCmdConvert, m_strCmdEdit, m_strCmdHocrCleanUp, m_strCmdHtml2Xhtml, m_strCmdOcr, m_strCmdOcrUseHocr, m_strCmdTts, m_strHocrClass, m_strImageFileName, m_strPdfBitmapMimeType, wxLuaScript::RegisterConstant(), wxLuaScript::RegisterVariable(), and wxLuaScript::Run().

Referenced by ApplyProfile(), and OnScriptStartScript().

{
    // Create the final script ...
    wxString strScriptCode; // Contains the Lua script code.

    if( strScriptFileName.IsEmpty() )
    {
        // ... by using the given main function call(s) (chunk).
        strScriptCode= strScriptStartupFunction + wxT( "\n" );
    }
    else
    {
        // Search for the directory containing the script file:
        //
        // Check...
        if( !::wxFileExists( strScriptFileName ) )
        {
            // If the script file does not exist replace its directory part by the
            // user's home directory.
            //
            // Signal a warning.
            wxLogWarning( wxString( wxT( "wxIScanFrame::StartScript -- " ) )
                            + _( "Script file does not exist. I try searching in the home directory." ) );

            // Replace the directory part of the script file name
            // by the user's home directory.
            wxFileName oScriptFileName( strScriptFileName );

            strScriptFileName= oScriptFileName.GetFullName();
            oScriptFileName.AssignHomeDir();
            oScriptFileName.SetFullName( strScriptFileName );

            strScriptFileName= oScriptFileName.GetFullPath();
    #if __DEBUG__
            wxLogWarning( wxT( "wxIScanFrame::StartScript -- strScriptFileName == '%s'" ),
                            strScriptFileName.c_str() );
    #endif // __DEBUG

                // Check...
            if( !::wxFileExists( strScriptFileName ) )
            {
                // If the script file does not exist replace its directory
                // part by the data directory.
                //
                // Display (log) a warning.
                wxLogWarning( wxString( wxT( "wxIScanFrame::StartScript -- " ) )
                                + _( "Script file does not exist. I try searching in the data directory." ) );

                // Replace the directory part of the script file name
                // by the program's data directory.
                wxFileName oScriptFileName( strScriptFileName );

                strScriptFileName= oScriptFileName.GetFullName();
                oScriptFileName.AssignDir( wxStandardPaths::Get().GetDataDir() );
                oScriptFileName.SetFullName( strScriptFileName );

                strScriptFileName= oScriptFileName.GetFullPath();
    #if __DEBUG__
                wxLogWarning( wxT( "wxIScanFrame::StartScript -- strScriptFileName == '%s'" ),
                                strScriptFileName.c_str() );
    #endif // __DEBUG
            }
        }

        // ... by concatinating the file content and the main
        // function call(s) (chunk).
        strScriptCode= ::GetTextFromFile( strScriptFileName ) + wxT( "\n\n" ) +
                       strScriptStartupFunction + wxT( "\n" );
    }

    // Create the Lua scripting object, ...
    wxIScanLuaScript oScript( strScriptCode, this, cstrAppName, &bLuaReturnFromEventHandler );

#if __WXLUASCRIPT_DYNAMIC__
    // Check if the script object is initialized correctly. This is only done
    // on dynamic loading of the Lua library because only there the library
    // may not be loaded correctly.
    if( !oScript.IsOk() )
    {
        // Log an error message, ...
        wxLogError( wxString( wxT( "wxIScanFrame::StartScript -- " ) )
                      + _( "Cannot initialize wxIScanLuaScript object." ) );

        // ... and leave.
        return;
    }
#endif // __WXLUASCRIPT_DYNAMIC__

    // ..., register menu id constants, ...
    oScript.RegisterConstant( wxT( "ID_FILESCANIMAGE" ), ID_FILESCANIMAGE );
    oScript.RegisterConstant( wxT( "ID_FILEOPEN" ), ID_FILEOPEN );
    oScript.RegisterConstant( wxT( "ID_FILESAVEAS" ), ID_FILESAVEAS );
    oScript.RegisterConstant( wxT( "ID_FILEPRINT" ), ID_FILEPRINT );
    oScript.RegisterConstant( wxT( "ID_FILEPRINTPREVIEW" ), ID_FILEPRINTPREVIEW );
    oScript.RegisterConstant( wxT( "ID_FILEPRINTSETUP" ), ID_FILEPRINTSETUP );
    oScript.RegisterConstant( wxT( "ID_FILEQUIT" ), ID_FILEQUIT );
    oScript.RegisterConstant( wxT( "ID_EDITCOPY" ), ID_EDITCOPY );
    oScript.RegisterConstant( wxT( "ID_EDITPASTE" ), ID_EDITPASTE );
    oScript.RegisterConstant( wxT( "ID_EDITSETTINGS" ), ID_EDITSETTINGS );
    oScript.RegisterConstant( wxT( "ID_EDITSETTINGSFILE" ), ID_EDITSETTINGSFILE );
    oScript.RegisterConstant( wxT( "ID_VIEWFITWIDTH" ), ID_VIEWFITWIDTH );
    oScript.RegisterConstant( wxT( "ID_VIEWFITWINDOW" ), ID_VIEWFITWINDOW );
    oScript.RegisterConstant( wxT( "ID_VIEWFULLSIZE" ), ID_VIEWFULLSIZE );
    oScript.RegisterConstant( wxT( "ID_VIEWCUSTOMSIZE" ), ID_VIEWCUSTOMSIZE );
    oScript.RegisterConstant( wxT( "ID_VIEWFULLSCREEN" ), ID_VIEWFULLSCREEN );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTCOPYTEXT" ), ID_DOCUMENTCOPYTEXT );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTREADTEXT" ), ID_DOCUMENTREADTEXT );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTREADTEXT" ), ID_DOCUMENTREADTEXT );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTREADTEXTSYNC" ), ID_DOCUMENTREADTEXTSYNC );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTPREVIOUSPAGE" ), ID_DOCUMENTPREVIOUSPAGE );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTNEXTPAGE" ), ID_DOCUMENTNEXTPAGE );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTLASTPAGE" ), ID_DOCUMENTLASTPAGE );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTCROP" ), ID_DOCUMENTCROP );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTROTATE90LEFT" ), ID_DOCUMENTROTATE90LEFT );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTROTATE90RIGHT" ), ID_DOCUMENTROTATE90RIGHT );
    oScript.RegisterConstant( wxT( "ID_DOCUMENTAPPLYPROFILE" ), ID_DOCUMENTAPPLYPROFILE );
#if __WXPDFDOC__
    oScript.RegisterConstant( wxT( "ID_PDFBEGINPDF" ), ID_PDFBEGINPDF );
    oScript.RegisterConstant( wxT( "ID_PDFADDPAGE" ), ID_PDFADDPAGE );
    oScript.RegisterConstant( wxT( "ID_PDFSAVEASPDF" ), ID_PDFSAVEASPDF );
#endif // __WXPDFDOC__
    oScript.RegisterConstant( wxT( "ID_HELPABOUT" ), ID_HELPABOUT );
    oScript.RegisterConstant( wxT( "ID_CMDSTOP" ), ID_CMDSTOP );

    // ..., register variables, ...
    oScript.RegisterVariable( wxT( "Resolution" ), &m_nResolution );
    oScript.RegisterVariable( wxT( "Page" ), &m_nPage );
    oScript.RegisterVariable( wxT( "ImageCount" ), &m_nImageCount );
    oScript.RegisterVariable( wxT( "PdfPages" ), &m_nPdfPages );
    oScript.RegisterVariable( wxT( "ProfileIndex" ), &m_nProfileIndex );
    oScript.RegisterVariable( wxT( "ImageFileName" ), &m_strImageFileName );
    oScript.RegisterVariable( wxT( "BitmapMimeType" ), &m_strBitmapMimeType );
    oScript.RegisterVariable( wxT( "ScaleFactor" ), &m_nScaleFactor );
    oScript.RegisterVariable( wxT( "ZoomFactor" ), &m_nZoomFactor );
    oScript.RegisterVariable( wxT( "AutoApplyProfile" ), &m_bAutoApplyProfile );
    oScript.RegisterVariable( wxT( "AutoApplyProfileOnMultiPage" ), &m_bAutoApplyProfileOnMultiPage );
    oScript.RegisterVariable( wxT( "OCR" ), &m_bOCR );
    oScript.RegisterVariable( wxT( "CmdConvertEnable" ), &m_bCmdConvertEnable );
    oScript.RegisterVariable( wxT( "CmdConvert" ), &m_strCmdConvert );
    oScript.RegisterVariable( wxT( "CmdOcrEnable" ), &m_bCmdOcrEnable );
    oScript.RegisterVariable( wxT( "CmdOcr" ), &m_strCmdOcr );
    oScript.RegisterVariable( wxT( "CmdCleanUpEnable" ), &m_bCmdCleanUpEnable );
    oScript.RegisterVariable( wxT( "CmdCleanUp" ), &m_strCmdCleanUp );
    oScript.RegisterVariable( wxT( "HocrEnable" ), &m_bHocrEnable );
    oScript.RegisterVariable( wxT( "HocrClass" ), &m_strHocrClass );
    oScript.RegisterVariable( wxT( "SmartHocrEnable" ), &m_bSmartHocrEnable );
    oScript.RegisterVariable( wxT( "CmdOcrUseHocr" ), &m_strCmdOcrUseHocr );
    oScript.RegisterVariable( wxT( "CmdHtml2XhtmlEnable" ), &m_bCmdHtml2XhtmlEnable );
    oScript.RegisterVariable( wxT( "CmdHtml2Xhtml" ), &m_strCmdHtml2Xhtml );
    oScript.RegisterVariable( wxT( "CmdHocrCleanUpEnable" ), &m_bCmdHocrCleanUpEnable );
    oScript.RegisterVariable( wxT( "CmdHocrCleanUp" ), &m_strCmdHocrCleanUp );
    oScript.RegisterVariable( wxT( "CmdTtsEnable" ), &m_bCmdTtsEnable );
    oScript.RegisterVariable( wxT( "CmdTts" ), &m_strCmdTts );
    oScript.RegisterVariable( wxT( "CmdEditEnable" ), &m_bCmdEditEnable );
    oScript.RegisterVariable( wxT( "CmdEdit" ), &m_strCmdEdit );
    oScript.RegisterVariable( wxT( "PdfDirty" ), &m_bPdfDirty );
#if __WXPDFDOC__
    oScript.RegisterVariable( wxT( "PdfBitmapMimeType" ), &m_strPdfBitmapMimeType );
#endif // __WXPDFDOC__

    // ... and run the script.
#if __DEBUG__
    wxLogMessage( wxT( "wxIScanFrame::StartScript - " )
                    + wxString::Format( _( "Running Lua Script '%s' starting function '%s'." ),
                                        strScriptFileName.c_str(),
                                        strScriptStartupFunction.c_str() ) );
#endif // __DEBUG__
    oScript.Run();
}
virtual void wxIScanFrame::ToggleFullScreen ( ) [inline, virtual]

Toggle full screen mode.

Definition at line 161 of file wxiscanframe.h.

Referenced by OnViewFullScreen(), RestoreSettings(), and SaveSettings().

        {
            ShowFullScreen( !IsFullScreen() );
        }
virtual void wxIScanFrame::UnlockUI ( ) [inline, virtual]

Unlocks the user interface.

Definition at line 188 of file wxiscanframe.h.

References LockUI().

        {
            LockUI( false );
        }
void wxIScanFrame::UpdateBitmap ( ) [virtual]

Update the canvas bitmap.

Definition at line 1909 of file wxiscanframe.cpp.

References m_nFit, m_nScaleFactor, m_oImage, m_poCanvas, wxIViewCanvas::SetBitmap(), wxCANVASCUSTOMSIZE, wxCANVASFITWIDTH, and wxCANVASFITWINDOW.

Referenced by wxIScanLuaScript::CropImage(), wxIScanLuaScript::EnhenceColours(), EnhenceOpticalContrast(), wxIScanLuaScript::Image2Grey(), wxIScanLuaScript::Image2Mono(), OnCanvasSelected(), OnCanvasSize(), OnDocumentApplyProfile(), OnDocumentCrop(), OnDocumentPageChanged(), OnDocumentRotate90Left(), OnDocumentRotate90Right(), OnDocumentZoom(), OnEditPaste(), OnViewFit(), OpenImage(), wxIScanLuaScript::ResizeImage(), wxIScanLuaScript::RotateImage(), wxIScanLuaScript::RotateImage90(), and ScanImage().

{
    // Some little optimization for empty images.
    if( !m_oImage.IsOk() )
    {
        return;
    }

    // Resize image (if necessary).
    switch( m_nFit )
    {
        case wxCANVASFITWIDTH   : {
                                      int x, nDummy;

                                      m_poCanvas->GetClientSize( &x, &nDummy );

                                      m_nScaleFactor= (double)x / (double)m_oImage.GetWidth();
                                  }
                                  break;
        case wxCANVASFITWINDOW  : {
                                      int x, y;

                                      m_poCanvas->GetClientSize( &x, &y );

                                      double nScaleFactorX= (double)x / (double)m_oImage.GetWidth();
                                      double nScaleFactorY= (double)y / (double)m_oImage.GetHeight();

                                      m_nScaleFactor= nScaleFactorX > nScaleFactorY ? nScaleFactorY : nScaleFactorX;
                                  }
                                  break;
        case wxCANVASCUSTOMSIZE : break;
        default                 : m_nScaleFactor= 1.0;
                                  break;
    }

    // Some little optimization:
    //  - A scalation factor of 1.0 means there is no scalation at all.
    if( m_nScaleFactor == 1.0 )
    {
        m_poCanvas->SetBitmap( m_oImage );
    }
    else
    {
        // Show busy cursor (until the automatic variable is destroyed).
        wxBusyCursor oWait;

        m_poCanvas->SetBitmap( m_oImage.Scale(
            (int)( (double)m_oImage.GetWidth()  * m_nScaleFactor ),
            (int)( (double)m_oImage.GetHeight() * m_nScaleFactor ),
            wxIMAGE_QUALITY_HIGH ) );
    }
}
void wxIScanFrame::UpdatePageNumber ( ) [virtual]

Update the page number info in the statusbar and in the toolbar.

Definition at line 2520 of file wxiscanframe.cpp.

References m_nImageCount, m_nPage, and m_poTextCtrlPage.

Referenced by OnDocumentPageChanged(), OpenImage(), and ResetFileName().

{
    SetStatusText( wxString::Format( wxT( "%d/%d" ),  m_nPage + 1, m_nImageCount ), 2 );
    m_poTextCtrlPage->SetValue( wxString::Format( wxT( "%d" ),  m_nPage + 1 ) );
}

Friends And Related Function Documentation

friend class wxIScanLuaScript [friend]

Definition at line 445 of file wxiscanframe.h.


Member Data Documentation

const long wxIScanFrame::ID_CANVAS = wxNewId() [static, private]

Definition at line 350 of file wxiscanframe.h.

const long wxIScanFrame::ID_CMDSTOP = wxNewId() [static, private]

Definition at line 381 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_CMDSTOP_TB = wxNewId() [static, private]

Definition at line 407 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_DOCUMENTAPPLYPROFILE = wxNewId() [static, private]

Definition at line 389 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_DOCUMENTCOPYTEXT = wxNewId() [static, private]

Definition at line 379 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_DOCUMENTCROP = wxNewId() [static, private]

Definition at line 388 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_DOCUMENTFIRSTPAGE = wxNewId() [static, private]

Definition at line 382 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_DOCUMENTFIRSTPAGE_TB = wxNewId() [static, private]

Definition at line 402 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_DOCUMENTLASTPAGE = wxNewId() [static, private]

Definition at line 385 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_DOCUMENTLASTPAGE_TB = wxNewId() [static, private]

Definition at line 405 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_DOCUMENTNEXTPAGE = wxNewId() [static, private]

Definition at line 384 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_DOCUMENTNEXTPAGE_TB = wxNewId() [static, private]

Definition at line 404 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_DOCUMENTPREVIOUSPAGE = wxNewId() [static, private]

Definition at line 383 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_DOCUMENTPREVIOUSPAGE_TB = wxNewId() [static, private]

Definition at line 403 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_DOCUMENTPROFILE0 = wxNewId() [static, private]
const long wxIScanFrame::ID_DOCUMENTREADTEXT = wxNewId() [static, private]

Definition at line 380 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_DOCUMENTREADTEXT_TB = wxNewId() [static, private]

Definition at line 406 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_DOCUMENTREADTEXTSYNC = wxNewId() [static, private]

...

Definition at line 409 of file wxiscanframe.h.

Referenced by OnDocumentReadText().

const long wxIScanFrame::ID_DOCUMENTROTATE90LEFT = wxNewId() [static, private]

Definition at line 386 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_DOCUMENTROTATE90RIGHT = wxNewId() [static, private]

Definition at line 387 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_EDITCLEARHISTORY = wxNewId() [static, private]

Definition at line 368 of file wxiscanframe.h.

const long wxIScanFrame::ID_EDITCLEARLOG = wxNewId() [static, private]

Definition at line 367 of file wxiscanframe.h.

const long wxIScanFrame::ID_EDITCOPY = wxNewId() [static, private]

Definition at line 362 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_EDITPASTE = wxNewId() [static, private]

Definition at line 363 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_EDITSCANSCANNERS = wxNewId() [static, private]

Definition at line 366 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_EDITSETTINGS = wxNewId() [static, private]

Definition at line 364 of file wxiscanframe.h.

Referenced by StartScript().

const long wxIScanFrame::ID_EDITSETTINGSFILE = wxNewId() [static, private]

Definition at line 365 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_FILEOPEN = wxNewId() [static, private]

Definition at line 356 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_FILEOPEN_TB = wxNewId() [static, private]

Definition at line 396 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_FILEPRINT = wxNewId() [static, private]

Definition at line 358 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_FILEPRINT_TB = wxNewId() [static, private]

Definition at line 398 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_FILEPRINTPREVIEW = wxNewId() [static, private]

Definition at line 359 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_FILEPRINTSETUP = wxNewId() [static, private]

Definition at line 360 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_FILEQUIT = wxNewId() [static, private]

Definition at line 361 of file wxiscanframe.h.

Referenced by StartScript().

const long wxIScanFrame::ID_FILESAVEAS = wxNewId() [static, private]

Definition at line 357 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_FILESAVEAS_TB = wxNewId() [static, private]

Definition at line 397 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_FILESCANIMAGE = wxNewId() [static, private]

Definition at line 355 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_FILESCANIMAGE_TB = wxNewId() [static, private]

Definition at line 395 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_HELPABOUT = wxNewId() [static, private]

Definition at line 394 of file wxiscanframe.h.

Referenced by StartScript().

const long wxIScanFrame::ID_HSPLITTERWINDOW = wxNewId() [static, private]

Definition at line 354 of file wxiscanframe.h.

const long wxIScanFrame::ID_LOGTEXTCTRL = wxNewId() [static, private]

Definition at line 353 of file wxiscanframe.h.

const long wxIScanFrame::ID_MENUDOCUMENTPROFILES = wxNewId() [static, private]

Definition at line 390 of file wxiscanframe.h.

const long wxIScanFrame::ID_PAGES = wxNewId() [static, private]

Definition at line 351 of file wxiscanframe.h.

const long wxIScanFrame::ID_PDFADDPAGE = wxNewId() [static, private]

Definition at line 392 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_PDFADDPAGE_TB = wxNewId() [static, private]

Definition at line 400 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_PDFBEGINPDF = wxNewId() [static, private]

Definition at line 391 of file wxiscanframe.h.

Referenced by EnableControls(), and StartScript().

const long wxIScanFrame::ID_PDFBEGINPDF_TB = wxNewId() [static, private]

Definition at line 399 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_PDFSAVEASPDF = wxNewId() [static, private]

Definition at line 393 of file wxiscanframe.h.

Referenced by CanClose(), EnableControls(), and StartScript().

const long wxIScanFrame::ID_PDFSAVEASPDF_TB = wxNewId() [static, private]

Definition at line 401 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_TEXTCTRLPAGE = wxNewId() [static, private]

...

Definition at line 411 of file wxiscanframe.h.

const long wxIScanFrame::ID_VIEWCLOSEDEBUGWINDOW = wxNewId() [static, private]

Definition at line 377 of file wxiscanframe.h.

const long wxIScanFrame::ID_VIEWCLOSEPREVIEWPANEL = wxNewId() [static, private]

Definition at line 378 of file wxiscanframe.h.

const long wxIScanFrame::ID_VIEWCUSTOMSIZE = wxNewId() [static, private]

Definition at line 373 of file wxiscanframe.h.

Referenced by EnableControls(), OnViewFit(), and StartScript().

const long wxIScanFrame::ID_VIEWFITWIDTH = wxNewId() [static, private]

Definition at line 370 of file wxiscanframe.h.

Referenced by EnableControls(), OnViewFit(), and StartScript().

const long wxIScanFrame::ID_VIEWFITWINDOW = wxNewId() [static, private]

Definition at line 371 of file wxiscanframe.h.

Referenced by EnableControls(), OnViewFit(), and StartScript().

const long wxIScanFrame::ID_VIEWFULLSCREEN = wxNewId() [static, private]

Definition at line 369 of file wxiscanframe.h.

Referenced by StartScript().

const long wxIScanFrame::ID_VIEWFULLSIZE = wxNewId() [static, private]

Definition at line 372 of file wxiscanframe.h.

Referenced by EnableControls(), OnViewFit(), and StartScript().

const long wxIScanFrame::ID_VIEWZOOMIN = wxNewId() [static, private]

Definition at line 374 of file wxiscanframe.h.

Referenced by EnableControls(), and OnViewFit().

const long wxIScanFrame::ID_VIEWZOOMOUT = wxNewId() [static, private]

Definition at line 375 of file wxiscanframe.h.

Referenced by EnableControls(), and OnViewFit().

const long wxIScanFrame::ID_VIEWZOOMSELECTION = wxNewId() [static, private]

Definition at line 376 of file wxiscanframe.h.

Referenced by EnableControls().

const long wxIScanFrame::ID_VSPLITTERWINDOW = wxNewId() [static, private]

Definition at line 352 of file wxiscanframe.h.

Apply a profile automatically after scanning.

Definition at line 237 of file wxiscanframe.h.

Referenced by OnEditSettings(), RestoreSettings(), SaveSettings(), ScanImage(), and StartScript().

Apply a profile automatically after loading a page from a multi page file.

Definition at line 238 of file wxiscanframe.h.

Referenced by OnEditSettings(), OnPdfAddPage(), RestoreSettings(), SaveSettings(), and StartScript().

...

Definition at line 255 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

...

Definition at line 251 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

...

Definition at line 257 of file wxiscanframe.h.

Referenced by AddPdfPage(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

bool wxIScanFrame::m_bLua [private]

Enable Lua scripting.

Definition at line 245 of file wxiscanframe.h.

Referenced by ApplyProfile(), EnableControls(), OnEditSettings(), RestoreSettings(), and SaveSettings().

bool wxIScanFrame::m_bOCR [private]

Enable OCR.

Definition at line 248 of file wxiscanframe.h.

Referenced by AddPdfPage(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

bool wxIScanFrame::m_bPdfDirty [private]

States if the PDF file is dirty (and should be saved).

Definition at line 280 of file wxiscanframe.h.

Referenced by AddPdfPage(), CreateNewPdfDocument(), IsPdfDirty(), OnPdfSavePdf(), and StartScript().

bool wxIScanFrame::m_bUILocked [private]

States if the GUI should be locked by wxIScanFrame::EnableControls().

Definition at line 221 of file wxiscanframe.h.

Referenced by EnableControls(), and LockUI().

int wxIScanFrame::m_nFit [private]

Fit bitmap size according to its value.

Definition at line 234 of file wxiscanframe.h.

Referenced by EnableControls(), OnCanvasSize(), OnDocumentZoom(), OnViewFit(), RestoreSettings(), SaveSettings(), and UpdateBitmap().

Number of Lua scripts.

Definition at line 246 of file wxiscanframe.h.

Referenced by EnableControls().

Number of PDF pages in memory.

Definition at line 279 of file wxiscanframe.h.

Referenced by AddPdfPage(), CreateNewPdfDocument(), EnableControls(), and StartScript().

Index number of the current image profile.

Definition at line 239 of file wxiscanframe.h.

The (fictive) resolution of an image in dpi.

Definition at line 227 of file wxiscanframe.h.

Referenced by AddPdfPage(), ApplyProfile(), GetPageSizeMM(), OnFilePrint(), OnFilePrintPreview(), OpenImage(), RestoreSettings(), SaveSettings(), ScanImage(), and StartScript().

double wxIScanFrame::m_nScaleFactor [private]

Bitmap scalation factor.

Definition at line 235 of file wxiscanframe.h.

Referenced by OnViewFit(), and UpdateBitmap().

double wxIScanFrame::m_nZoomFactor [private]

Zoom factor by which the bitmap should be scaled.

Definition at line 236 of file wxiscanframe.h.

Referenced by OnViewFit().

wxFileHistory wxIScanFrame::m_oFileHistory [private]

History of last opened files.

Definition at line 271 of file wxiscanframe.h.

Referenced by EnableControls(), OnEditClearHistory(), OnMRUFiles(), OpenImage(), and SaveSettings().

wxPrintData wxIScanFrame::m_oPrintData [private]

Holds related to printers and printer device contexts.

Definition at line 274 of file wxiscanframe.h.

Referenced by AdjustOrientation(), CreateNewPdfDocument(), OnFilePrint(), OnFilePrintPreview(), OnFilePrintSetup(), RestoreSettings(), and SaveSettings().

wxImage wxIScanFrame::m_oPrintImage [private]

Image object for printing.

Definition at line 223 of file wxiscanframe.h.

Referenced by GetPageSizeMM(), GotoPage(), OnFilePrint(), OnFilePrintPreview(), and Paint().

wxTextValidator wxIScanFrame::m_oTextValidatorTextCtrlPage [private]

The validator to the page number editor.

Definition at line 438 of file wxiscanframe.h.

wxSplitterWindow* wxIScanFrame::m_poHSplitterWindow [private]

Definition at line 433 of file wxiscanframe.h.

Referenced by OnViewCloseDebugWindow(), RestoreSashSettings(), and SaveSettings().

wxTextCtrl* wxIScanFrame::m_poLogTextCtrl [private]

Definition at line 434 of file wxiscanframe.h.

Referenced by LogProcessOutput(), OnEditClearLog(), and ~wxIScanFrame().

Definition at line 422 of file wxiscanframe.h.

Referenced by AddPdfPage(), and OnPdfBeginPdf().

wxPdfDocument* wxIScanFrame::m_poPdfDoc [private]

PDF document.

Definition at line 278 of file wxiscanframe.h.

Referenced by AddPdfPage(), CreateNewPdfDocument(), OnPdfSavePdf(), and ~wxIScanFrame().

A concurrent running process (equals to NULL if there isn't any).

Definition at line 288 of file wxiscanframe.h.

Referenced by EnableControls(), Execute(), OnCmdStop(), OnProcessTerminated(), and ~wxIScanFrame().

wxScan* wxIScanFrame::m_poScanner [private]

Object representing the scanner.

Definition at line 228 of file wxiscanframe.h.

Referenced by EnableControls(), ScanImage(), and ~wxIScanFrame().

wxTextCtrl* wxIScanFrame::m_poTextCtrlPage [private]

A pointer to the page number editor.

Definition at line 437 of file wxiscanframe.h.

Referenced by OnTextCtrlPageProcessEnter(), and UpdatePageNumber().

wxSplitterWindow* wxIScanFrame::m_poVSplitterWindow [private]

Definition at line 420 of file wxiscanframe.h.

Referenced by OnViewClosePreviewPanel(), RestoreSashSettings(), and SaveSettings().

Image mimetype for any export but PDF export.

Definition at line 240 of file wxiscanframe.h.

Referenced by wxIScanLuaScript::OCR(), OCR(), OnDocumentCopyText(), OnEditSettings(), ReadOut(), RestoreSettings(), SaveSettings(), and StartScript().

wxString wxIScanFrame::m_strCmdCleanUp [private]

...

Definition at line 256 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

wxString wxIScanFrame::m_strCmdConvert [private]

...

Definition at line 252 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

wxString wxIScanFrame::m_strCmdEdit [private]

...

Definition at line 264 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

...

Definition at line 262 of file wxiscanframe.h.

Referenced by AddPdfPage(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

wxString wxIScanFrame::m_strCmdOcr [private]

...

Definition at line 254 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

...

Definition at line 260 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

wxString wxIScanFrame::m_strCmdTts [private]

...

Definition at line 266 of file wxiscanframe.h.

Referenced by OnEditSettings(), ReadOut(), RestoreSettings(), SaveSettings(), and StartScript().

wxString wxIScanFrame::m_strHocrClass [private]

...

Definition at line 258 of file wxiscanframe.h.

Referenced by AddPdfPage(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

The output extension of the via OCR extracted text file.

Definition at line 249 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), and SaveSettings().

The output extension of the via OCR extracted hocr (html) file.

Definition at line 250 of file wxiscanframe.h.

Referenced by OCR(), OnEditSettings(), RestoreSettings(), and SaveSettings().

Image mimetype for PDF export.

Definition at line 242 of file wxiscanframe.h.

Referenced by AddPdfPage(), OnEditSettings(), RestoreSettings(), SaveSettings(), and StartScript().

wxMenu* wxIScanFrame::poMenuEdit [private]

Definition at line 430 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem1 [private]

Definition at line 431 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem10 [private]

Definition at line 428 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem11 [private]

Definition at line 419 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem12 [private]

Definition at line 423 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem13 [private]

Definition at line 426 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem2 [private]

Definition at line 425 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem3 [private]

Definition at line 432 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem4 [private]

Definition at line 429 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem5 [private]

Definition at line 418 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem6 [private]

Definition at line 421 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem7 [private]

Definition at line 424 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem8 [private]

Definition at line 435 of file wxiscanframe.h.

wxToolBarToolBase* wxIScanFrame::ToolBarItem9 [private]

Definition at line 427 of file wxiscanframe.h.


The documentation for this class was generated from the following files: