Now the procedure FullView( cFile, mPar) took the form:
Code: Select all
***********************************************************************
/*
* This procedure displays an image file in a separate window
*/
***********************************************************************
PROCEDURE FullView( cFile, mPar )
LOCAL oDlg, oImage, oPS, aSize, aPos
LOCAL lBGClr := XBPSYSCLR_TRANSPARENT
/*
* Only bitmap and meta files are supported
*/
IF cFile <> NIL .AND. ;
( ".BMP" $ Upper( cFile ) .OR. ;
".EMF" $ Upper( cFile ) .OR. ;
".GIF" $ Upper( cFile ) .OR. ;
".JPG" $ Upper( cFile ) .OR. ;
".PNG" $ Upper( cFile ) .OR. ;
".MET" $ Upper( cFile ) )
/*
* Create hidden dialog window
*/
oDlg := XbpDialog():new( AppDesktop(),,,{100,100} )
oDlg:taskList := .F.
oDlg:visible := .F.
oDlg:title := cFile
oDlg:sizeRedraw := .T.
oDlg:close := {|mp1,mp2,obj| obj:destroy() }
oDlg:alwaysOnTop := .T. // Выводить изображение на переднем плане
oDlg:create()
/*
* Create a presentation space and connect it with the device
* context of :drawingArea
*/
oPS := XbpPresSpace():new():create( oDlg:drawingArea:winDevice() )
IF ".BMP" $ Upper( cFile ) .OR. ;
".GIF" $ Upper( cFile ) .OR. ;
".JPG" $ Upper( cFile ) .OR. ;
".PNG" $ Upper( cFile )
/*
* File contains a bitmap. Limit the window size to a range
* between 16x16 pixel and the screen resolution
*/
oImage := XbpBitmap():new():create( oPS )
oImage:loadFile( cFile )
IF oImage:transparentClr <> GRA_CLR_INVALID
lBGClr := XBPSYSCLR_DIALOGBACKGROUND
ENDIF
*************** ЗДЕСЬ ВЗЯТЬ ОПРЕДЕЛЕННЫЕ ВЫШЕ РАЗМЕРЫ ИЗОБРАЖЕНИЯ <<<===##########################
aSize := { oImage:xSize, oImage:ySize }
aSize[1] := Max( 16, Min( aSize[1], AppDeskTop():currentSize()[1] ) )
aSize[2] := Max( 16, Min( aSize[2], AppDeskTop():currentSize()[2] ) )
aSize := oDlg:calcFrameRect( {0,0, aSize[1], aSize[2]} )
oDlg:setSize( {aSize[3], aSize[4]} )
/*
* The window must react to xbeP_Paint to redraw the bitmap
*/
oDlg:drawingarea:paint := {|x,y,obj| x:=obj:currentSize(), ;
oImage:draw( oPS, {0, 0, x[1], x[2]}, ;
{0, 0, oImage:xSize, oImage:ySize},,;
GRA_BLT_BBO_IGNORE), Sleep(0.1) }
ELSE
/*
* Display a meta file. It has no size definition for the image
*/
oImage := XbpMetafile():new():create()
oImage:load( cFile )
aSize := { 600, 400 }
oDlg:setSize( aSize )
oDlg:drawingarea:paint := {|x,y,obj| x:=obj:currentSize(), ;
oImage:draw( oPS, {0, 0, x[1], x[2]}),;
Sleep(0.1) }
lBGClr := XBPSYSCLR_DIALOGBACKGROUND
ENDIF
/*
* Set the background color for the dialog's drawingarea.
* Per default, the transparent color is used to avoid
* flicker during refreshs. For transparent images and
* metafiles, however, color gray is set instead, see above.
* This is done to prevent bits of the desktop from being
* visible in transparent areas of the bitmap/metafile image.
* Alternatively, transparency could be explicitly switched
* off for bitmapped images.
*/
oDlg:drawingArea:SetColorBG( lBGClr )
/*
* Display the window centered on the desktop
*/
DO CASE
CASE mPar = "по верху"
AlignWindow( oDlg )
CASE mPar = "по центру"
aPos:= CenterPos( oDlg:currentSize(), AppDesktop():currentSize() )
oDlg:setPos( aPos )
ENDCASE
oDlg:show()
SetAppFocus( oDlg )
* ------------------------------------------------------------- *
* Правильная реакция на Esc от Джимми
* ------------------------------------------------------------- *
// add this
nEvent := 0
DO WHILE nEvent != xbeP_Close
nEvent := APPEVENT( @mp1, @mp2, @oXbp )
IF nEvent == xbeP_Keyboard .AND. mp1 == xbeK_ESC
oDlg:destroy()
Exit
ELSE
oXbp:HandleEvent( nEvent, mp1, mp2 )
ENDIF
ENDDO
* ------------------------------------------------------------- *
ENDIF
RETURN
******************************************************************************************
******** Выравнивание вывода в FullView() по верхнему краю без панели задач **************
******************************************************************************************
FUNCTION AlignWindow( oDlg )
LOCAL aCoords := DC_GetWorkArea(), nBottom, nLeft
nBottom := AppDeskTop():currentSize()[2] - aCoords[4]
nLeft := AppDeskTop():currentSize()[1]/2 - oDlg:currentSize()[1]/2
oDlg:setPos({nLeft,nBottom})
RETURN nil