#Include "Fivewin.ch"
#include "constant.ch"
Function Main()
Local oBmp1, oRadio1, nValue1 := 1
Local oWnd, oDlg, oFld, oBtn1, oBtn2
Local nBottom := 35
Local nRight := 110
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
Local oFont, oBrush1, oBrush2, oBrush3
LOCAL c_path, c_path1, aBitmaps
c_Path := cFilePath(GetModuleFileName( GetInstance() ) )
c_Path1 := c_path + "Images\"
aBitmaps := { c_path1 + "Preview.Bmp",;
c_path1 + "Preview.bmp",;
c_path1 + "Exit1.bmp" }
DEFINE BRUSH oBrush1 GRADIENT { { 0.50, 16710607, 16759929 }, { 0.50, 16759929, 16710607 } }
DEFINE BRUSH oBrush2 GRADIENT { { 1, 11053311, 16777215 } }
DEFINE BRUSH oBrush3 GRADIENT { { 1, 12647336, 16777215 } }
oFont := TFont():New("Arial",,-18,.F.,.F. ,,,,.F. )
DEFINE WINDOW oWnd TITLE "Foldertest FWH-version => " + FWVERSION BRUSH oBrush1
DEFINE DIALOG oDlg TITLE "Test folder" SIZE nWidth, nHeight PIXEL OF oWnd BRUSH oBrush2
@ 15, 10 FOLDEREX SIZE 280, 160 oFld PIXEL ROUND 5 UPDATE ;
PROMPT "Page &1", "Page &2", "&EXIT" OF oDlg ;
BITMAPS aBitmaps;
ON PAINT TAB PaintTab( Self, nOption );
ON CHANGE ( nSavePage := oFld:nOption, ;
IF( nOption == 3, If( MsgYesNo( "Do you want exit??" ), ;
oWnd:End(), ( ::SetOption( nOldOption ), ::Refresh() ) ), ) ) ;
ON PAINT TEXT( If( nOption == ::nOption .and. nOption == 2, 8388608, 0 ) );
TOP OPTION 1 ALIGN 0, 0, 0
oFld:lTransparent := .T.
oFld:nFolderHeight := 40
oFld:nSeparator := 2
oFld:bClrText := {| o, n | 128 }
oFld:oFont := oFont
oFld:nOption := 1
oFld:aDialogs[ 1 ]:SetBrush( oBrush1 )
oFld:aDialogs[ 2 ]:SetBrush( oBrush2 )
oFld:aDialogs[ 3 ]:SetBrush( oBrush3 )
@ 30, 20 RADIO oRadio1 VAR nValue1 ITEMS "&No" OF oFld:aDialogs[1] SIZE 30, 10 PIXEL ;
ON CHANGE { || oBmp1:Refresh() } UPDATE
@ 30, 70 RADIOITEM "&Mail" RADIOMENU oRadio1 OF oFld:aDialogs[1] SIZE 30, 10 PIXEL UPDATE
@ 30, 120 RADIOITEM "&Sms" RADIOMENU oRadio1 OF oFld:aDialogs[1] SIZE 30, 10 PIXEL UPDATE
@ 30, 170 RADIOITEM "&Telefono" RADIOMENU oRadio1 OF oFld:aDialogs[1] SIZE 45, 10 PIXEL UPDATE
AEval( oRadio1:aItems, { | oRad | oRad:lTransparent := .T., ;
oRad:SetFont ( oFont ), ;
oRad:nClrText := 255 } )
@ 70, 120 BITMAP oBmp1 FILENAME NIL PIXEL OF oFld:aDialogs[1] NOBORDER SIZE 32,32 ADJUST
oBmp1:ltransparent:=.t.
oBmp1:bPainted := { |hDC| DRAW_IMG( oBmp1, hDC, oFld, c_Path1, nValue1 ) }
ACTIVATE DIALOG oDlg NOWAIT ;
ON INIT ( oDlg:Move( oWnd:nBottom - 150, oWnd:nRight - 420, 600, 420, .f. ) )
ACTIVATE WINDOW oWnd MAXIMIZED
RELEASE BRUSH oBrush1, oBrush2, oBrush3, oFont
RETURN NIL
// ------------------------
FUNCTION PaintTab( o, nOption )
IF nOption == o:nOver .OR. nOption == o:nOption
o:SetAlphaLevel( nOption, 255 )
ELSE
o:SetAlphaLevel( nOption, 50 )
ENDIF
RETURN o:SetFldColors( o, nOption )
// ----------------------------
FUNCTION DRAW_IMG( oImage, hDC, oFld, c_Path1, nPosition )
LOCAL oImg, oImg0, nFactor1, nFactor2, aRect, nWidth, nHeight
aRect := GETCLIENTRECT( oImage:hWnd )
IF nPosition = 1
DEFINE IMAGE oImg FILENAME c_path1 + "No.bmp"
oImg0 := FILoadImg( c_path1 + "No.bmp" )
ENDIF
IF nPosition = 2
DEFINE IMAGE oImg FILENAME c_path1 + "Mail.bmp"
oImg0 := FILoadImg( c_path1 + "Mail.bmp" )
ENDIF
IF nPosition = 3
DEFINE IMAGE oImg FILENAME c_path1 + "Sms.bmp"
oImg0 := FILoadImg( c_path1 + "Sms.bmp" )
ENDIF
IF nPosition = 4
DEFINE IMAGE oImg FILENAME c_path1 + "Phone.bmp"
oImg0 := FILoadImg( c_path1 + "Phone.bmp" )
ENDIF
nFactor1 := aRect[4] / oImg:nWidth
nFactor2 := aRect[3] / oImg:nHeight
cSize := ALLTRIM(STR(oImg:nWidth)) + "x" + ALLTRIM(STR(oImg:nHeight)) + ;
" Resize-Factor : W = " + ALLTRIM(STR(nFactor1)) + " H = " + ALLTRIM(STR(nFactor2))
nWidth := oImg:nWidth
nHeight := oImg:nHeight
lAlpha := HasAlpha( oImg0 )
IF nFactor1 > 1 .and. nFactor2 > 1
IF lAlpha = .T.
ABPaint( hDC, 0, 0, oImg0, 255 )
DeleteObject( oImg0 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, ,oImg:nWidth, oImg:nHeight )
ENDIF
ENDIF
IF nFactor1 < 1 .and. nFactor2 < 1
IF nFactor1 < nFactor2 // Width-factor > Height-factor
IF lAlpha = .T.
DeleteObject( oImg )
oImg := ResizeImg( oImg0, aRect[4], nHeight * nFactor1 )
ABPaint( hDC, 0, 0, oImg, 255 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, ,aRect[4], oImg:nHeight * nFactor1 )
ENDIF
ELSE // Width-factor < Height-factor
IF lAlpha = .T.
DeleteObject( oImg )
oImg := ResizeImg( oImg0, oImg:nWidth * nFactor2, aRect[3] )
ABPaint( hDC, 0, 0, oImg, 255 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, ,oImg:nWidth * nFactor2, aRect[3] )
ENDIF
ENDIF
// MsgAlert( "True 2" )
ENDIF
IF nFactor1 < 1 .and. nFactor2 > 1
IF lAlpha = .T.
DeleteObject( oImg )
oImg := ResizeImg( oImg0, aRect[4], nHeight * nFactor1 )
ABPaint( hDC, 0, 0, oImg, 255 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, ,aRect[4], oImg:nHeight * nFactor1 )
ENDIF
ENDIF
IF nFactor1 > 1 .and. nFactor2 < 1
IF lAlpha = .T.
DeleteObject( oImg )
oImg := ResizeImg( oImg0, nWidth * nFactor2, aRect[3] )
ABPaint( hDC, 0, 0, oImg, 255 )
ELSE
PalBmpDraw( hDC, 0, 0, oImg:hBitmap, , oImg:nWidth * nFactor2, aRect[3] )
ENDIF
ENDIF
DeleteObject( oImg )
RETURN( cSize )