2009-07-10 08:31 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)

* harbour/contrib/hbxbp/Makefile
  * harbour/contrib/hbxbp/xbp.ch
  * harbour/contrib/hbxbp/xbpgeneric.prg
  * harbour/contrib/hbxbp/xbpwindow.prg
    ! Cleanups ad tweaks.

  + harbour/contrib/hbxbp/xbppresspace.prg
    + Started XbpPresSpace() class - skeleton only.

  + harbour/contrib/hbxbp/xbpprintdialog.prg
    + Implemented XbpPrintDialog() class. 
      Mostly working but has some differences with Xbase++ - a work-in-progress.

  + harbour/contrib/hbxbp/xbpprinter.prg
    + Implemented XbpPrinter() class. 
      Mostly working but has some differences with Xbase++ - a work-in-progress.
      Integrated with XbpPrintDialog()

  * harbour/contrib/hbxbp/tests/demoxbp.prg
    + Demonstration of XbpPrintDialog() and XbpPrinter() classes.
      Click on <Print Dialog> toolbar button.

    /*  I would request Xbase++ users to test the code under different 
        permutations and combinations and please report the differences.
        So far I have not received any support in this direction.
     */
This commit is contained in:
Pritpal Bedi
2009-07-10 15:39:48 +00:00
parent d16fe3cd42
commit 5c0f9ebd06
9 changed files with 1044 additions and 32 deletions

View File

@@ -17,6 +17,34 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-07-10 08:31 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbxbp/Makefile
* harbour/contrib/hbxbp/xbp.ch
* harbour/contrib/hbxbp/xbpgeneric.prg
* harbour/contrib/hbxbp/xbpwindow.prg
! Cleanups ad tweaks.
+ harbour/contrib/hbxbp/xbppresspace.prg
+ Started XbpPresSpace() class - skeleton only.
+ harbour/contrib/hbxbp/xbpprintdialog.prg
+ Implemented XbpPrintDialog() class.
Mostly working but has some differences with Xbase++ - a work-in-progress.
+ harbour/contrib/hbxbp/xbpprinter.prg
+ Implemented XbpPrinter() class.
Mostly working but has some differences with Xbase++ - a work-in-progress.
Integrated with XbpPrintDialog()
* harbour/contrib/hbxbp/tests/demoxbp.prg
+ Demonstration of XbpPrintDialog() and XbpPrinter() classes.
Click on <Print Dialog> toolbar button.
/* I would request Xbase++ users to test the code under different
permutations and combinations and please report the differences.
So far I have not received any support in this direction.
*/
2009-07-10 08:19 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* harbour/contrib/hbqt/generator/qt45.qtp

View File

@@ -67,6 +67,9 @@ PRG_SOURCES=\
xbpfiledialog.prg \
xbpfontdialog.prg \
xbpbitmap.prg \
xbppresspace.prg \
xbpprinter.prg \
xbpprintdialog.prg \
PRG_HEADERS=\

View File

@@ -57,7 +57,7 @@
#include "gra.ch"
#ifdef __XPP__
#pragma library("XppUi2")
#pragma library("XppUi2")
#endif
/*----------------------------------------------------------------------*/
@@ -68,6 +68,8 @@
#define TAB_4 4
#define TAB_5 5
#define CRLF chr( 13 )+chr( 10 )
STATIC oMLE /* Change Font elsewhere */
/*----------------------------------------------------------------------*/
@@ -201,12 +203,64 @@ FUNCTION hb_DirBase() ; RETURN CurDir()
/*----------------------------------------------------------------------*/
STATIC FUNCTION uiXtoS( xVar )
LOCAL cType
cType := valtype( xVar )
DO CASE
CASE cType == "N"
RETURN str( xVar )
CASE cType == "D"
RETURN dtoc( xVar )
CASE cType == "L"
RETURN IF( xVar, "Yes", "No" )
CASE cType == "M"
RETURN xVar
CASE cType == "C"
RETURN xVar
CASE cType == "A"
RETURN "A:"+hb_ntos( len( xVar ) )
CASE cType == "O"
RETURN "<OBJECT>"
OTHERWISE
RETURN "<"+cType+">"
ENDCASE
RETURN xVar
/*----------------------------------------------------------------------*/
FUNCTION uiDebug( p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 )
LOCAL s
s := ' ' + uiXtoS( p1 ) + CRLF
s += ' ' + uiXtoS( p2 ) + CRLF
s += ' ' + uiXtoS( p3 ) + CRLF
s += ' ' + uiXtoS( p4 ) + CRLF
s += ' ' + uiXtoS( p5 ) + CRLF
s += ' ' + uiXtoS( p6 ) + CRLF
s += ' ' + uiXtoS( p7 ) + CRLF
s += ' ' + uiXtoS( p8 ) + CRLF
s += ' ' + uiXtoS( p9 ) + CRLF
s += ' ' + uiXtoS( p10 )
#ifdef __XPP__
MsgBox( s )
#else
//MsgBox( s )
hb_outDebug( s )
#endif
RETURN nil
/*----------------------------------------------------------------------*/
STATIC FUNCTION PP_Debug( oXbp )
LOCAL aPP := oXbp:setPresParam()
LOCAL s := ''
aeval( aPP, {|e_| s += ( hb_ntos( e_[ 1 ] ) +' '+ valtype( e_[ 2 ] ) +' '+ ;
IF( valtype( e_[ 2 ] )=='N', hb_ntos( e_[ 2 ] ), ' ' ) + '; '+ chr( 13 )+chr( 10 ) ) } )
IF( valtype( e_[ 2 ] )=='N', hb_ntos( e_[ 2 ] ), ' ' ) + '; '+ CRLF ) } )
#ifdef __XPP__
MsgBox( s )
@@ -351,11 +405,13 @@ FUNCTION Build_ToolBar( oDA )
oTBar:addItem( "Save" , "new.png" , , , , , "1" )
oTBar:addItem( "Open" , "open.png", , , , , "2" )
oTBar:addItem( "Font Dialog", "copy.png", , , , , "3" )
oTBar:addItem( "Print Dialog", "print.png", , , , , "4" )
#else
oTBar:addItem( "Save" )//, 100 )
oTBar:addItem( "Open" )//, 101 )
oTBar:addItem( "Font Dialog" )
oTBar:addItem( "Print Dialog" )
#endif
oTBar:transparentColor := GRA_CLR_INVALID
@@ -374,6 +430,8 @@ STATIC FUNCTION ExeToolbar( oButton, oDa )
Build_FileDialog( oDA,"open" )
CASE oButton:caption == "Font Dialog"
Build_FontDialog( oDa )
CASE oButton:caption == "Print Dialog"
Build_PrintDialog( oDa )
ENDCASE
RETURN nil
@@ -974,8 +1032,6 @@ FUNCTION Build_Statics( oWnd )
oBox:caption := XBPSTATIC_SYSICON_ICONINFORMATION //XBPSTATIC_SYSICON_ICONQUESTION //
oBox:create()
#define CRLF chr(13)+chr(10)
oLbl := XbpStatic():new( oWnd, , {30,60}, {200,240} )
oLbl:type := XBPSTATIC_TYPE_TEXT
oLbl:options := XBPSTATIC_TEXT_CENTER + XBPSTATIC_TEXT_VCENTER + XBPSTATIC_TEXT_WORDBREAK
@@ -1131,3 +1187,31 @@ FUNCTION DisplayFontInfo( oFont )
/*----------------------------------------------------------------------*/
FUNCTION Build_PrintDialog( oWnd )
LOCAL oDlg, oPrn
oDlg := XbpPrintDialog():new( oWnd ):create()
oDlg:enablePrintToFile := .t.
#if 1
ODlg:pageRange := { 1,3 }
oDlg:printRange := XBPPDLG_PRINT_PAGERANGE
#endif
#if 0
oDlg:enableMark := .t.
oDlg:printRange := XBPPDLG_PRINT_MARK
#endif
IF valtype( oPrn := oDlg:display() ) == "O"
uiDebug( oPrn:devName , ;
oPrn:setOrientation() , ;
oPrn:setFormSize() , ;
oPrn:setResolution()[1], ;
oPrn:setNumCopies() , ;
oPrn:setPaperBin() )
ENDIF
RETURN nil
/*----------------------------------------------------------------------*/

View File

@@ -280,6 +280,14 @@
#define XBPBMP_DEF_COMPRESSION -1
#define XBPPDLG_PRINT_MARK 1
#define XBPPDLG_PRINT_ALLPAGES 2
#define XBPPDLG_PRINT_PAGERANGE 3
#define XBPPDLG_MODE_DRIVER 1
#define XBPPDLG_MODE_APPLICATION 2
/*----------------------------------------------------------------------*/
#define _XBP_CH
#endif

View File

@@ -264,33 +264,6 @@ FUNCTION GraMakeRGBColor( aRGB )
/*----------------------------------------------------------------------*/
FUNCTION Xbp_XtoS( xVar )
LOCAL cType
cType := valtype( xVar )
DO CASE
CASE cType == "N"
RETURN str( xVar )
CASE cType == "D"
RETURN dtoc( xVar )
CASE cType == "L"
RETURN IF( xVar, "Yes", "No" )
CASE cType == "M"
RETURN xVar
CASE cType == "C"
RETURN xVar
CASE cType == "A"
RETURN "A:"+hb_ntos( len( xVar ) )
CASE cType == "O"
RETURN "<OBJECT>"
OTHERWISE
RETURN "<"+cType+">"
ENDCASE
RETURN xVar
/*----------------------------------------------------------------------*/
FUNCTION SetEventFilter()
LOCAL pEventFilter
@@ -333,3 +306,43 @@ FUNCTION RemoveEventLoop( oEventLoop )
RETURN nil
/*----------------------------------------------------------------------*/
#define CRLF chr( 13 )+chr( 10 )
FUNCTION Xbp_Debug( ... )
LOCAL s := CRLF
LOCAL aP := hb_aParams()
aeval( aP, {|e| s += Xbp_XtoS( e ) + CRLF } )
hb_outDebug( s )
RETURN nil
/*----------------------------------------------------------------------*/
STATIC FUNCTION Xbp_XtoS( xVar )
LOCAL cType
cType := valtype( xVar )
DO CASE
CASE cType == "N"
RETURN str( xVar )
CASE cType == "D"
RETURN dtoc( xVar )
CASE cType == "L"
RETURN IF( xVar, "Yes", "No" )
CASE cType == "M"
RETURN xVar
CASE cType == "C"
RETURN xVar
CASE cType == "A"
RETURN "A:"+hb_ntos( len( xVar ) )
CASE cType == "O"
RETURN "<OBJECT>"
OTHERWISE
RETURN "<"+cType+">"
ENDCASE
RETURN xVar
/*----------------------------------------------------------------------*/

View File

@@ -0,0 +1,135 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Source file for the Xbp*Classes
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*
* EkOnkar
* ( The LORD is ONE )
*
* Xbase++ Compatible xbpPresSpace Class
*
* Pritpal Bedi <pritpal@vouchcac.com>
* 08Jul2009
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
#include "hbclass.ch"
#include "common.ch"
#include "xbp.ch"
#include "appevent.ch"
#include "hbqt.ch"
/*----------------------------------------------------------------------*/
CLASS XbpPresSpace
DATA mode
DATA d
METHOD new()
METHOD create()
METHOD configure() VIRTUAL
METHOD destroy() VIRTUAL
METHOD drawMode( nDrawMode ) VIRTUAL
METHOD device() VIRTUAL
METHOD lastError() VIRTUAL
METHOD mapPoint() VIRTUAL
METHOD mapColor() VIRTUAL
METHOD mapColorIndex( lCompatible ) VIRTUAL
METHOD setAttrArea( aAttributes ) VIRTUAL
METHOD setAttrLine( aAttributes ) VIRTUAL
METHOD setAttrMarker( aAttributes ) VIRTUAL
METHOD setAttrString( aAttributes ) VIRTUAL
METHOD setColor( nForeground, nBackground ) INLINE ::d := { ::nColorFG, ::nColorBG }, ;
IF( !empty( nForeground ), ::nColorFG := nForeground, ), ;
IF( !empty( nBackground ), ::nColorBG := nBackground, ), ::d
METHOD setColorIndex() VIRTUAL
METHOD setFont( oXbpFont ) VIRTUAL
METHOD setGraTransform( aMatrix, nMode ) VIRTUAL
METHOD setPageSize( aPageSize, nUnits ) VIRTUAL
METHOD setViewPort( aViewPort ) VIRTUAL
PROTECTED:
DATA aAttrArea
DATA aAttrLine
DATA aAttrMarker
DATA aAttrString
DATA nDrawMode
DATA lMapColorIndex
DATA nColorFG INIT GraMakeRGBColor( { 0,0,0 } )
DATA nColorBG INIT GraMakeRGBColor( { 255,255,255 } )
DATA oXbpFont
DATA aGraTransMatrix
DATA nGraTransMode
DATA aPageSize
DATA nUnits
DATA aViewPort
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpPresSpace:new()
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPresSpace:create()
RETURN Self
/*----------------------------------------------------------------------*/

View File

@@ -0,0 +1,179 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Source file for the Xbp*Classes
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*
* EkOnkar
* ( The LORD is ONE )
*
* Xbase++ Compatible xbpPrintDialog Class
*
* Pritpal Bedi <pritpal@vouchcac.com>
* 08Jul2009
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
#include "hbclass.ch"
#include "common.ch"
#include "xbp.ch"
#include "appevent.ch"
#include "hbqt.ch"
/*----------------------------------------------------------------------*/
CLASS XbpPrintDialog INHERIT XbpWindow
DATA enableCollate INIT .F.
DATA enableMark INIT .F.
DATA enableNumCopies INIT .F.
DATA enablePrintToFile INIT .F.
DATA mode INIT XBPPDLG_MODE_DRIVER
DATA pageRange INIT { 0,0 }
DATA collate INIT .F.
DATA numCopies INIT 1
DATA pageRangeSelected INIT {}
DATA printRange INIT XBPPDLG_PRINT_ALLPAGES
DATA printToFile INIT .F.
METHOD new()
METHOD create()
//METHOD configure() VIRTUAL
//METHOD destroy() VIRTUAL
METHOD display( oXbpPrinter )
DATA pPrinter PROTECTED
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpPrintDialog:new( oParent, oOwner )
::xbpWindow:init( oParent, oOwner )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrintDialog:create( oParent, oOwner )
::xbpWindow:create( oParent, oOwner )
::oWidget := QPrintDialog():new()
::connect( ::pWidget, "accepted(QPrinter)", {|o,p| o := o, ::pPrinter := p } )
::addChild( self )
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrintDialog:display( oXbpPrinter )
LOCAL nResult, nOpt, n
IF hb_isObject( oXbpPrinter )
// Parameters be based onto that
ENDIF
::oWidget:setOption( QAbstractPrintDialog_None , .T. )
::oWidget:setOption( QAbstractPrintDialog_PrintToFile , ::enablePrintToFile )
::oWidget:setOption( QAbstractPrintDialog_PrintSelection , ::enableMark )
::oWidget:setOption( QAbstractPrintDialog_PrintPageRange , ::pageRange[ 1 ] > 0 .and. ::pageRange[ 2 ] > 0 )
::oWidget:setOption( QAbstractPrintDialog_PrintCollateCopies , ::enableCollate )
IF ::pageRange[ 1 ] > 0 .and. ::pageRange[ 2 ] > 0
::oWidget:setMinMax( ::pageRange[ 1 ], ::pageRange[ 2 ] )
::oWidget:setFromTo( ::pageRange[ 1 ], ::pageRange[ 2 ] )
ENDIF
DO CASE
CASE ::printRange == XBPPDLG_PRINT_ALLPAGES
::oWidget:setPrintRange( QAbstractPrintDialog_AllPages )
CASE ::printRange == XBPPDLG_PRINT_MARK
::oWidget:setPrintRange( QAbstractPrintDialog_Selection )
CASE ::printRange == XBPPDLG_PRINT_PAGERANGE
::oWidget:setPrintRange( QAbstractPrintDialog_PageRange )
ENDCASE
nResult := ::oWidget:exec()
IF nResult == QDialog_Accepted
IF !hb_isObject( oXbpPrinter )
oXbpPrinter := XbpPrinter():new()
oXbpPrinter:oWidget := QPrinter()
ENDIF
oXbpPrinter:oWidget:pPtr := ::pPrinter
oXbpPrinter:oPrintEngine := QPrintEngine()
oXbpPrinter:oPrintEngine:pPtr := oXbpPrinter:oWidget:printEngine()
oXbpPrinter:setDevName( oXbpPrinter:oWidget:printerName() )
::numCopies := oXbpPrinter:setNumCopies()
::collate := oXbpPrinter:setCollationMode()
nOpt := ::oWidget:options()
::printToFile := hb_bitAnd( nOpt, QAbstractPrintDialog_PrintToFile ) == QAbstractPrintDialog_PrintToFile
n := oXbpPrinter:oWidget:setPrintRange()
::printRange := IF( n == 0, XBPPDLG_PRINT_ALLPAGES, IF( n == 1, XBPPDLG_PRINT_MARK, XBPPDLG_PRINT_PAGERANGE ) )
::pageRangeSelected := { oXbpPrinter:oWidget:fromPage(), oXbpPrinter:oWidget:toPage() }
ENDIF
RETURN oXbpPrinter
/*----------------------------------------------------------------------*/

View File

@@ -0,0 +1,563 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Source file for the Xbp*Classes
*
* Copyright 2009 Pritpal Bedi <pritpal@vouchcac.com>
* http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*
* EkOnkar
* ( The LORD is ONE )
*
* Xbase++ Compatible XbpPrinter Class
*
* Pritpal Bedi <pritpal@vouchcac.com>
* 08Jul2009
*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
#include "hbclass.ch"
#include "common.ch"
#include "xbp.ch"
#include "xbpdev.ch"
#include "appevent.ch"
#include "hbqt.ch"
/*----------------------------------------------------------------------*/
CLASS XbpPrinter
DATA oWidget
ACCESS pWidget INLINE IF( empty( ::oWidget ), NIL, QT_PTROF( ::oWidget ) )
DATA comment READONLY
DATA devName READONLY
DATA devParams READONLY
DATA devPort READONLY
DATA location READONLY
DATA spoolFormat READONLY
DATA collate INIT .F.
DATA numCopies INIT 1
DATA pageRangeSelected INIT {}
DATA printRange INIT XBPPDLG_PRINT_ALLPAGES
DATA printToFile INIT .F.
/* Internal */
DATA isValid
METHOD new()
METHOD create()
METHOD configure() VIRTUAL
METHOD destroy() VIRTUAL
METHOD getHDC()
METHOD forms()
METHOD list()
METHOD paperBins()
METHOD paperSize()
METHOD printerStatus()
METHOD resolution()
METHOD setCollationMode( nMode )
METHOD setColorMode( nMode )
METHOD setDuplexMode( nMode )
METHOD setFontMode( nMode )
METHOD setFormSize( nFormID )
METHOD setNumCopies( nNumCopies )
METHOD setOrientation( nOrientation )
METHOD setPaperBin( nBin )
METHOD setPrintFile( cFileName )
METHOD setResolution( aResolution )
METHOD setupDialog()
METHOD abort()
METHOD endDoc()
METHOD newPage()
METHOD startPage()
METHOD endPage()
METHOD startDoc()
METHOD setDevName( cName ) INLINE ::devName := cName
DATA oPrintEngine
ACCESS oEngine INLINE ::oPrintEngine
METHOD getEngineProperty( nProperty )
ENDCLASS
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:new()
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:create( cDeviceName, nSpoolFormat, cDeviceParams )
HB_SYMBOL_UNUSED( nSpoolFormat )
HB_SYMBOL_UNUSED( cDeviceParams )
::oWidget := QPrinter():new()
IF hb_isChar( cDeviceName )
::oWidget:setPrinterName( cDeviceName )
ENDIF
IF !::oWidget:isValid()
//::oWidget:setPrinterName( const QString & name )
::oWidget:setPrinterName( "" )
ENDIF
::devName := ::oWidget:printerName()
::oPrintEngine := QPrintEngine()
::oPrintEngine:pPtr := ::oWidget:printEngine()
#if 0
::oWidget:setCreator( const QString & creator )
::oWidget:setDoubleSidedPrinting( bool doubleSided )
::oWidget:setFromTo( int from, int to )
::oWidget:setFullPage( bool fp )
::oWidget:setOutputFormat( OutputFormat format )
::oWidget:setPageMargins( qreal left, qreal top, qreal right, qreal bottom, Unit unit )
::oWidget:setPageOrder( PageOrder pageOrder )
::oWidget:setPrintProgram( const QString & printProg )
::oWidget:setPrintRange( PrintRange range )
::oWidget:setPrinterSelectionOption( const QString & option )
::oWidget:setWinPageSize( int pageSize )
#endif
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:getHDC()
LOCAL hDC := NIL
RETURN hDC
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:forms()
LOCAL aForms := {}
RETURN aForms
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:list()
LOCAL aPrinterNames := {}
RETURN aPrinterNames
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:paperBins()
LOCAL aPaperBins := {}
RETURN aPaperBins
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:paperSize()
LOCAL aPaperSize := {}
//::oWidget:setPaperSize( PaperSize newPaperSize )
//::oWidget:setPaperSize( const QSizeF & paperSize, Unit unit )
RETURN aPaperSize
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:printerStatus()
LOCAL nStatus := 0
RETURN nStatus
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:resolution()
LOCAL aResolution := {}
RETURN aResolution
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setCollationMode( nMode )
LOCAL nModeOld := IF( ::oWidget:collateCopies(), XBPPRN_COLLATIONMODE_ON, XBPPRN_COLLATIONMODE_OFF )
IF hb_isNumeric( nMode )
::oWidget:setCollateCopies( IF( nMode == XBPPRN_COLLATIONMODE_ON, .t., .f. ) )
ENDIF
RETURN nModeOld
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setColorMode( nMode )
LOCAL nModeOld := IF( ::oWidget:colorMode() == QPrinter_Color, XBPPRN_COLORMODE_ON, XBPPRN_COLORMODE_OFF )
IF hb_isNumeric( nMode )
::oWidget:setColorMode( IF( nMode == XBPPRN_COLORMODE_ON, QPrinter_Color, QPrinter_GrayScale ) )
ENDIF
RETURN nModeOld
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setDuplexMode( nMode )
LOCAL nModeOld := ::oWidget:duplex()
IF nModeOld == QPrinter_DuplexNone .OR. nModeOld == QPrinter_DuplexAuto
nModeOld := XBPPRN_DUPLEXMODE_OFF
ELSEIF nModeOld == QPrinter_DuplexLongSide
nModeOld := XBPPRN_DUPLEXMODE_MEMO
ELSEIF nModeOld == QPrinter_DuplexShortSide
nModeOld := XBPPRN_DUPLEXMODE_BOOK
ENDIF
IF hb_isNumeric( nMode )
IF nMode == XBPPRN_DUPLEXMODE_MEMO
nMode := QPrinter_DuplexLongSide
ELSEIF nMode == XBPPRN_DUPLEXMODE_BOOK
nMode := QPrinter_DuplexShortSide
ELSE
nMode := QPrinter_DuplexNone
ENDIF
::oWidget:setDuplex( nMode )
ENDIF
RETURN nModeOld
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setFontMode( nMode )
LOCAL nModeOld := nMode
//::oWidget:setFontEmbeddingEnabled( bool enable )
RETURN nModeOld
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setFormSize( nFormID )
LOCAL nFormIDOld := ::oWidget:paperSize()
#if 0
LOCAL q_:={}
LOCAL x_:={}
LOCAL n
aadd( q_, QPrinter_A0 )
aadd( q_, QPrinter_A1 )
aadd( q_, QPrinter_A2 , XBPPRN_FORM_A2 )
aadd( q_, QPrinter_A3 , XBPPRN_FORM_A3 )
aadd( q_, QPrinter_A4 , XBPPRN_FORM_A4 )
aadd( q_, QPrinter_A5 , XBPPRN_FORM_A5 )
aadd( q_, QPrinter_A6 )
aadd( q_, QPrinter_A7 )
aadd( q_, QPrinter_A8 )
aadd( q_, QPrinter_A9 )
aadd( q_, QPrinter_B0 )
aadd( q_, QPrinter_B1 )
aadd( q_, QPrinter_B2 )
aadd( q_, QPrinter_B3 )
aadd( q_, QPrinter_B4 , XBPPRN_FORM_B4 )
aadd( q_, QPrinter_B5 , XBPPRN_FORM_B5 )
aadd( q_, QPrinter_B6 )
aadd( q_, QPrinter_B7 )
aadd( q_, QPrinter_B8 )
aadd( q_, QPrinter_B9 )
aadd( q_, QPrinter_B10 )
aadd( q_, QPrinter_Letter , XBPPRN_FORM_LETTER )
aadd( q_, QPrinter_Legal , XBPPRN_FORM_LEGAL )
aadd( q_, QPrinter_Executive, XBPPRN_FORM_EXECUTIVE )
aadd( q_, QPrinter_C5E )
aadd( q_, QPrinter_Comm10E , XBPPRN_FORM_ENVELOPE_10 )
aadd( q_, QPrinter_DLE )
aadd( q_, QPrinter_Folio , XBPPRN_FORM_FOLIO )
aadd( q_, QPrinter_Ledger , XBPPRN_FORM_LEDGER )
aadd( q_, QPrinter_Tabloid , XBPPRN_FORM_TABLOID )
aadd( q_, QPrinter_Custom )
XBPPRN_FORM_LETTERSMALL
XBPPRN_FORM_STATEMENT
XBPPRN_FORM_A4SMALL
XBPPRN_FORM_QUARTO
XBPPRN_FORM_10X14
XBPPRN_FORM_11X17
XBPPRN_FORM_NOTE
XBPPRN_FORM_ENVELOPE_9
XBPPRN_FORM_ENVELOPE_11
XBPPRN_FORM_ENVELOPE_12
XBPPRN_FORM_ENVELOPE_14
XBPPRN_FORM_CSHEET
XBPPRN_FORM_DSHEET
XBPPRN_FORM_ESHEET
XBPPRN_FORM_ENVELOPE_DL
XBPPRN_FORM_ENVELOPE_C5
XBPPRN_FORM_ENVELOPE_C3
XBPPRN_FORM_ENVELOPE_C4
XBPPRN_FORM_ENVELOPE_C6
XBPPRN_FORM_ENVELOPE_C65
XBPPRN_FORM_ENVELOPE_B4
XBPPRN_FORM_ENVELOPE_B5
XBPPRN_FORM_ENVELOPE_B6
XBPPRN_FORM_ENVELOPE_ITALY
XBPPRN_FORM_ENVELOPE_MONARCH
XBPPRN_FORM_ENVELOPE_PERS
XBPPRN_FORM_FANFOLD_US
XBPPRN_FORM_FANFOLD_GER
XBPPRN_FORM_FANFOLD_LGL_GER
XBPPRN_FORM_ISO_B4
XBPPRN_FORM_JAPANESE_POSTCARD
XBPPRN_FORM_9X11
XBPPRN_FORM_10X11
XBPPRN_FORM_15X11
XBPPRN_FORM_ENVELOPE_INV
XBPPRN_FORM_LETTER_EXTRA
XBPPRN_FORM_LEGAL_EXTRA
XBPPRN_FORM_TABLOID_EXTRA
XBPPRN_FORM_A4_EXTRA
XBPPRN_FORM_LETTER_TRANSVERSE
XBPPRN_FORM_A4_TRANSVERSE
XBPPRN_FORM_LETTER_XTRA_TRANS
XBPPRN_FORM_A_PLUS
XBPPRN_FORM_B_PLUS
XBPPRN_FORM_LETTER_PLUS
XBPPRN_FORM_A4_PLUS
XBPPRN_FORM_A5_TRANSVERSE
XBPPRN_FORM_B5_TRANSVERSE
XBPPRN_FORM_A3_EXTRA
XBPPRN_FORM_A5_EXTRA
XBPPRN_FORM_B5_EXTRA
XBPPRN_FORM_A3_TRANSVERSE
XBPPRN_FORM_A3_EXTRA_TRANS
#endif
IF hb_isNumeric( nFormID )
::oWidget:setPaperSize( nFormID )
ENDIF
//::oWidget:setPaperSize( const QSizeF & paperSize, Unit unit )
RETURN nFormIDOld
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setNumCopies( nNumCopies )
LOCAL nOldNumCopies := ::oWidget:numCopies()
IF hb_isNumeric( nNumCopies )
::oWidget:setNumCopies( nNumCopies )
ENDIF
RETURN nOldNumCopies
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setOrientation( nOrientation )
LOCAL nOldOrientation := IF( ::oWidget:orientation() == QPrinter_Landscape, XBPPRN_ORIENT_LANDSCAPE, XBPPRN_ORIENT_PORTRAIT )
IF hb_isNumeric( nOrientation )
::oWidget:setOrientation( if( nOrientation == XBPPRN_ORIENT_LANDSCAPE, QPrinter_Landscape, QPrinter_Portrait ) )
ENDIF
RETURN nOldOrientation
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setPaperBin( nBin )
LOCAL q_:= { }
LOCAL x_:= {}
LOCAL nOldBin
aadd( q_, QPrinter_OnlyOne )
aadd( q_, QPrinter_Lower )
aadd( q_, QPrinter_Middle )
aadd( q_, QPrinter_Manual )
aadd( q_, QPrinter_Envelope )
aadd( q_, QPrinter_EnvelopeManual )
aadd( q_, QPrinter_Auto )
aadd( q_, QPrinter_Tractor )
aadd( q_, QPrinter_SmallFormat )
aadd( q_, QPrinter_LargeFormat )
aadd( q_, QPrinter_LargeCapacity )
aadd( q_, QPrinter_Cassette )
aadd( q_, QPrinter_FormSource )
//aadd( q_, QPrinter_MaxPageSource ) // Xbase++ does not define it
aadd( x_, XBPPRN_PAPERBIN_SINGLE )
aadd( x_, XBPPRN_PAPERBIN_LOWER )
aadd( x_, XBPPRN_PAPERBIN_MIDDLE )
aadd( x_, XBPPRN_PAPERBIN_MANUAL )
aadd( x_, XBPPRN_PAPERBIN_ENVELOPE )
aadd( x_, XBPPRN_PAPERBIN_ENVMANUAL )
aadd( x_, XBPPRN_PAPERBIN_AUTO )
aadd( x_, XBPPRN_PAPERBIN_TRACTOR )
aadd( x_, XBPPRN_PAPERBIN_SMALLFORMAT )
aadd( x_, XBPPRN_PAPERBIN_LARGEFORMAT )
aadd( x_, XBPPRN_PAPERBIN_LARGECAPACITY )
aadd( x_, XBPPRN_PAPERBIN_CASETTE )
aadd( x_, XBPPRN_PAPERBIN_FORMSOURCE )
nOldBin := ::oWidget:paperSource()
nOldBin := x_[ ascan( q_, nOldBin ) ]
IF hb_isNumeric( nBin )
nBin := q_[ ascan( x_, nBin ) ]
::oWidget:setPaperSource( nBin )
ENDIF
RETURN nOldBin
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setPrintFile( cFileName )
LOCAL cOldFileName := ::oWidget:outputFileName()
IF hb_isChar( cFileName )
::oWidget:setOutputFileName( cFileName )
ENDIF
RETURN cOldFileName
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setResolution( anResolution )
LOCAL aOldResolution := { ::getEngineProperty( QPrintEngine_PPK_Resolution ), ::oWidget:resolution() }
IF hb_isNumeric( anResolution ) .or. hb_isArray( anResolution )
::oWidget:setResolution( IF( hb_isNumeric( anResolution ), anResolution, anResolution[ 1 ] ) )
ENDIF
RETURN aOldResolution
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:setupDialog()
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:abort()
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:endDoc()
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:newPage()
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:startPage()
LOCAL lSuccess := .T.
RETURN lSuccess
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:endPage()
LOCAL lSuccess := .T.
RETURN lSuccess
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:startDoc( cDocName )
IF !empty( cDocName )
//::oWidget:setDocName( const QString & name )
ENDIF
RETURN Self
/*----------------------------------------------------------------------*/
METHOD XbpPrinter:getEngineProperty( nProperty )
LOCAL xValue := 0
LOCAL oVariant := QVariant()
oVariant:pPtr := ::oEngine:property( nProperty )
DO CASE
CASE nProperty == QPrintEngine_PPK_CollateCopies
CASE nProperty == QPrintEngine_PPK_ColorMode
CASE nProperty == QPrintEngine_PPK_Creator
CASE nProperty == QPrintEngine_PPK_Duplex
CASE nProperty == QPrintEngine_PPK_DocumentName
CASE nProperty == QPrintEngine_PPK_FontEmbedding
CASE nProperty == QPrintEngine_PPK_FullPage
CASE nProperty == QPrintEngine_PPK_NumberOfCopies
CASE nProperty == QPrintEngine_PPK_Orientation
CASE nProperty == QPrintEngine_PPK_OutputFileName
CASE nProperty == QPrintEngine_PPK_PageOrder
CASE nProperty == QPrintEngine_PPK_PageRect
CASE nProperty == QPrintEngine_PPK_PageSize
CASE nProperty == QPrintEngine_PPK_PaperRect
CASE nProperty == QPrintEngine_PPK_PaperSource
CASE nProperty == QPrintEngine_PPK_PaperSources
CASE nProperty == QPrintEngine_PPK_PaperSize
CASE nProperty == QPrintEngine_PPK_PrinterName
CASE nProperty == QPrintEngine_PPK_PrinterProgram
CASE nProperty == QPrintEngine_PPK_Resolution
RETURN oVariant:toInt()
CASE nProperty == QPrintEngine_PPK_SelectionOption
CASE nProperty == QPrintEngine_PPK_SupportedResolutions
CASE nProperty == QPrintEngine_PPK_SuppressSystemPrintStatus
CASE nProperty == QPrintEngine_PPK_WindowsPageSize
CASE nProperty == QPrintEngine_PPK_CustomPaperSize
CASE nProperty == QPrintEngine_PPK_PageMargins
ENDCASE
RETURN xValue
/*----------------------------------------------------------------------*/

View File

@@ -1040,7 +1040,6 @@ METHOD XbpWindow:setPointer( cDllName, xResID, nType )
#if 0 /* The original image size - but in practice pointer should be proper sized */
::oWidget:setCursor( QT_PTROF( QCursor():new( "QPixmap", QT_PTROF( QPixmap():new( xResID ) ) ) ) )
#else
hb_OutDebug( "sssssssssssss" )
::oWidget:setCursor( QT_PTROF( QCursor():new( "QPixmap", QPixmap():new( xResID ):scaled( 24,24 ) ) ) )
#endif
ENDIF