#include "FiveWin.ch"
#include "report.ch"
#xcommand OVERRIDE METHOD <!Message!> [IN] CLASS <!Class!> ;
WITH [METHOD] <!Method!> [SCOPE <Scope>] => ;
__clsModMsg( <Class>():classH, #<Message>, @<Method>() )
static bUserBtns, lRebar, nBtnW, nBtnH, nStyle
static lWord, lCalc
function Ut_override()
OVERRIDE METHOD BuildWindow IN CLASS TPreview WITH PreviewBuildWindow
OVERRIDE METHOD Activate IN CLASS TPreview WITH PreviewActivate
OVERRIDE METHOD CheckStyle IN CLASS TPreview WITH PreviewCheckStyle
return nil
Function PreviewBuildWindow()
local Self := HB_QSelf()
local lRebar := .t.
local oIcon, cTitle := FWString( "Printing Preview" )
local oBar, nCol := 420
local oThis := Self, nRow := 7, nHelpID
if Len( ::oDevice:aMeta ) < 1
return nil
endif
DEFAULT ::oWndMain := WndMain()
if ::oDevice != nil
cTitle = ::oDevice:cDocument
endif
if ::oWndMain != nil
oIcon = ::oWndMain:oIcon
else
DEFINE ICON oIcon RESOURCE "Print"
ENDIF
DEFINE FONT ::oFont NAME GetSysFont() SIZE 0, -12
::CheckStyle()
if (::oReport != nil) // dfl 1712
nHelpId := ::oReport:nHelpId
endif
if ! ::oDevice:lPrvModal .and. ::oWndMain != nil .and. ;
Upper( ::oWndMain:ClassName() ) == "TMDIFRAME"
DEFINE WINDOW ::oWnd FROM 0,0 TO 900, 1150 ;
TITLE cTitle ;
COLOR CLR_BLACK,CLR_LIGHTGRAY ;
HELPID nHelpId ; // dfl 1712
VSCROLL HSCROLL MDICHILD
else
DEFINE WINDOW ::oWnd FROM 0,0 TO 900, 1150 ;
TITLE cTitle ;
COLOR CLR_BLACK,CLR_LIGHTGRAY ;
HELPID nHelpId ; // dfl 1712
VSCROLL HSCROLL MENU ::BuildMenu()
ENDIF
::oWnd:SetIcon( oIcon )
::oWnd:SetFont( ::oFont )
::oWnd:oVScroll:SetRange( 0, 0 )
::oWnd:oHScroll:SetRange( 0, 0 )
::cPageNum = FWString( "Page number:" )
::BuildButtonBar()
if lRebar
DEFINE STATUSBAR OF ::oWnd PROMPT " " + FWString( "Preview" )
else
SET MESSAGE OF ::oWnd TO FWString( "Preview" ) CENTERED ;
NOINSET CLOCK DATE KEYBOARD
::oWnd:oMsgBar:l2007 := ( nStyle == 2007 )
::oWnd:oMsgBar:l2010 := ( nStyle == 2010 )
endif
// We build the left thumbs listview
if ! ::lListViewHide
::BuildListView()
endif
// We build the main metafiles to display the pages
::oMeta1 := TMetaFile():New( 0, 0, 0, 0,;
::oDevice:aMeta[ 1 ],;
::oWnd,;
CLR_BLACK,;
CLR_WHITE,;
::oDevice:nHorzRes(),;
::oDevice:nVertRes() )
DEFINE CURSOR ::oCursor SEARCH
::oMeta1:oCursor := ::oCursor
::oMeta1:blDblClick := { | nRow, nCol, nKeyFlags | ;
::SetOrg1( nCol, nRow, nKeyFlags ),;
If ( ::lListViewHide, nil, If( ::lZoom, ::oLvw:Hide(), ::oLvw:Show() ) ) }
::oMeta1:bKeyDown := { | nKey, nFlags | ::CheckKey( nKey, nFlags ) }
::oMeta1:bKeyChar := { |k| If( k == 16, ( If( ValType( ::bPrint ) == 'B', Eval( ::bPrint, Self ), ::PrintPage() ), 0 ), nil ) }
::oMeta1:bMouseWheel := { | nKeys, nDelta, nXPos, nYPos | ;
::CheckMouseWheel( nKeys, nDelta, nXPos, nYPos ) }
::oMeta2 := TMetaFile():New( 0, 0, 0, 0, "",;
::oWnd, CLR_BLACK, CLR_WHITE, ::oDevice:nHorzRes(),;
::oDevice:nVertRes() )
::oMeta2:oCursor = ::oCursor
::oMeta2:blDblClick := { | nRow, nCol, nKeyFlags | ;
::SetOrg2( nCol, nRow, nKeyFlags ),;
If ( ::lListViewHide, nil, If( ::lZoom, ::oLvw:Hide(), ::oLvw:Show() ) ) }
::oMeta2:hide()
::SetFactor()
oBar := ::oBar
if ::bButtonBar == nil
if .T. // ! lRebar
nCol := If( ! Empty( oBar:aControls ), ATail( oBar:aControls ):nRight, Len( oBar:aButtons ) * ( oBar:nBtnWidth + 2 ) ) + 30
nRow := Int( oBar:nHeight / 2 ) - 8
endif
::CheckStyle()
if nStyle >= 2007
oBar:bPainted = { || oBar:Say( nRow, nCol, "Factor:",,, ::oFont, .T., .T. ),;
oBar:Say( nRow, nCol+100, ::cPageNum + " " + ;
LTrim( Str( ::nPage, 4, 0 ) ) + " / " + ;
LTrim( Str( Len( ::oDevice:aMeta ) ) ),,, ::oFont, .T., .T. ) }
endif
if nStyle < 2007
@ nRow, nCol SAY ::oSay PROMPT "Factor:" ;
SIZE 45, 15 PIXEL OF ::oBar FONT ::oFont
::oSay:lTransparent = .T.
endif
@ nRow - 4, nCol + 40 COMBOBOX ::oFactor VAR ::nZFactor ;
ITEMS { "1", "2", "3", "4", "5", "6", "7", "8", "9" } ;
OF ::oBar FONT ::oFont PIXEL SIZE 35,200 ;
ON CHANGE oThis:SetFactor( oThis:nZFactor )
if nStyle < 2007
@ nRow, nCol + 100 SAY ::oPage PROMPT FWString( "Page number:" ) + ;
LTrim( Str( ::nPage, 4, 0 ) ) + " / " + ;
LTrim( Str( Len( ::oDevice:aMeta ) ) ) ;
SIZE 180, 15 PIXEL OF ::oBar FONT ::oFont
::oPage:lTransparent = .T.
endif
if lRebar .or. nStyle >= 2007
#define NULL_BRUSH 5
FixSays( ::oBar:hWnd, GetStockObject( NULL_BRUSH ) )
endif
::oFactor:Set3dLook( .T. )
endif
::oWnd:oHScroll:bPos := { | nPos | ::HScroll( GO_POS, .f., nPos ) }
::oWnd:oVScroll:bPos := { | nPos | ::VScroll( GO_POS, .f., nPos ) }
return nil
//---------------------------------------------------------------------------------------
Function PreviewActivate()
local Self := HB_QSelf()
local hWndMain
if ::oWnd == nil
return nil
endif
if ::bSetUp != nil
Eval( ::bSetUp, Self, ::oWnd )
endif
ACTIVATE WINDOW ::oWnd CENTERED ;
ON RESIZE ( ::PaintMeta(), ::ResizeListView() ) ;
ON UP ::VScroll( GO_UP ) ;
ON DOWN ::VScroll( GO_DOWN ) ;
ON PAGEUP ::VScroll( GO_UP, GO_PAGE) ;
ON PAGEDOWN ::VScroll( GO_DOWN, GO_PAGE) ;
ON LEFT ::HScroll( GO_LEFT ) ;
ON RIGHT ::HScroll( GO_RIGHT ) ;
ON PAGELEFT ::HScroll( GO_LEFT, GO_PAGE ) ;
ON PAGERIGHT ::HScroll( GO_RIGHT, GO_PAGE ) ;
VALID ( ::oWnd:oIcon := nil ,;
::oFont:End() ,;
::oCursor:End() ,;
::oMeta1:End() ,;
::oMeta2:End() ,;
::oDevice:End() ,;
::oHand:End() ,;
If( Empty( ::oImageList ),, ( ::oImageList:End(), ::oImageList := nil ) ),;
If( ! Empty( ::oImageListPages ), ::oImageListPages:End(),),;
::oWnd := nil ,;
::oDevice:oPreview := nil ,;
::lExit := .T. )
if ::oDevice:lPrvModal
if ::oWndMain == nil
StopUntil( { || ::lExit } )
else
hWndMain := WndMain():hWnd
StopUntil( { || ::lExit .or. !IsWindow( hWndMain ) } )
endif
endif
return nil
Function PreviewCheckStyle()
local Self := HB_QSelf()
local o
if nStyle == nil
nStyle := 0
DEFAULT ::oWndMain := WndMain()
if ::oWndMain != nil
if ( o := ::oWndMain:oMenu ) != nil
nStyle := Max( nStyle, If( o:l2010, 2010, 0 ) )
endif
if nStyle < 2010 .and. ( o := ::oWndMain:oMsgBar ) != nil
nStyle := Max( nStyle, If( o:l2010, 2010, If( o:l2007, 2007, 0 ) ) )
endif
if nStyle < 2010 .and. ( o := ::oWndMain:oTop ) != nil
if o:IsKindOf( "TRIBBONBAR" )
nStyle := Max( nStyle, If( o:l2010, 2010, 2007 ) )
elseif o:IsKindOf( "TBAR" )
nStyle := Max( nStyle, If( o:l2010, 2010, 2007 ) )
if Empty( nStyle ) .and. Len( o:aControls ) > 0 .and. o:aControls[ 1 ]:l97look
nStyle := 97
endif
endif
endif
endif
endif
lRebar := ( IsAppThemed() .and. Empty( nStyle ) .and. bUserBtns == nil .and. nBtnW == nil .and. nBtnH == nil )
return Self