#include "FiveWin.ch"
#include "Folder.ch"
static oWnd, oDlg, oFld, hDC
FUNCTION MAIN()
oFont := TFont():New("Arial", ,-14,.F.,.F. , , , ,.F. )
SetBalloon( .T. ) // Balloon shape required for tooltips
DEFINE WINDOW oWnd TITLE "Foldertest" MDI MENU TMenu():New()
SET MESSAGE OF oWnd TO "Folder-Test" ;
CENTERED CLOCK KEYBOARD 2007
ACTIVATE WINDOW oWnd MAXIMIZED ;
ON INIT TEST(oWnd) ;
ON PAINT Degrade ( hDC, oWnd, 8388608, 16777215 )
RETURN NIL
// ----------------- WINDOW and DIALOG GRADIENT -------------------
STATIC FUNCTION Degrade ( hDC, oWnd, nCOLOR1, nCOLOR2 )
LOCAL nStep , nStepY
LOCAL oBrush
LOCAL i, r,g,b
LOCAL r0,g0,b0
LOCAL r1, g1, b1
LOCAL rD, gD, bD
LOCAL aRect := GETCLIENTRECT( oWnd:hWnd )
nStep := ( aRect[ 3 ] - aRect[ 1 ] )
nStepY := ( aRect[ 3 ] - aRect[ 1 ] ) / nStep
aRect[ 3 ] = aRect[ 1 ] + nStepY
r0 := nRGBRed (nCOLOR1)
g0 := nRGBGreen (nCOLOR1)
b0 := nRGBBlue (nCOLOR1)
r1 := nRGBRed (nCOLOR2)
g1 := nRGBGreen (nCOLOR2)
b1 := nRGBBlue (nCOLOR2)
rD := r1-r0
gD := g1-g0
bD := b1-b0
r := 256*rD/Max(nStep,1)
g := 256*gD/Max(nStep,1)
b := 256*bD/Max(nStep,1)
r0*=256
g0*=256
b0*=256
FOR i = 0 TO nStep-1 STEP nStepY
r0 += r
g0 += g
b0 += b
DEFINE BRUSH oBrush COLOR nRGB( r0/256, g0/256, b0/256 )
FILLRECT( hDC, aRect, oBrush:hBrush )
RELEASE BRUSH oBrush
aRect[ 1 ] += nStepY
aRect[ 3 ] += nStepY
NEXT
RETURN (nil)
// ---------- FOLDER GRADIENT --------------------------------------
STATIC FUNCTION SetFoldGrad( oFld, nCOLOR1, nCOLOR2 )
local n, oDlg
for n = 1 to Len( oFld:aDialogs )
oDlg = oFld:aDialogs[ n ]
oDlg:bPainted = { | hDC | Degrade ( hDC, oDlg, nCOLOR1, nCOLOR2 ) }
next
RETURN NIL
//----------------- TEST ---------------------------------------------
FUNCTION Test(oWnd)
nStyle :=nOR( DS_MODALFRAME, WS_POPUP, WS_CAPTION, WS_SYSMENU,WS_MINIMIZEBOX, WS_MAXIMIZEBOX )
DEFINE DIALOG oDlg RESOURCE "MainDlg" OF oWnd STYLE nSTYLE ; // TRANSPARENT ;
TITLE "Folder-Test" FONT oFont
REDEFINE FOLDER oFld ID 100 OF oDlg UPDATE ;
PROMPTS " &Page 1 ", " &Page 2 ", " &Page 3 ", " &Page 4 " ;
DIALOGS "Page1", "Page2", "Page3", "Page4" FONT oFont ;
ON CHANGE( SetFolder( oWnd, oFld, nOption, nOldOption ) )
FOLDER_1(oDlg,oFld)
FOLDER_2(oDlg,oFld)
FOLDER_3(oDlg,oFld)
FOLDER_4(oDlg,oFld)
ACTIVATE DIALOG oDlg CENTERED NOWAIT ;
ON INIT ( oDlg:Move( 30 , 10, oDlg:nWidth, oDlg:nHeight, .f. ), ;
SetImages( oDlg, oFld ) ) ;
ON PAINT ( Degrade ( hDC, oWnd, 32768, 16777215 ), SetFoldGrad( oFld, 128, 16777215 ) )
RETURN NIL
//------------ IMAGES for FOLDER-TABS --------------------------------------------
FUNCTION SetImages( oDlg, oFld )
local oImageList
DEFINE IMAGELIST oImageList SIZE 16, 16
oImageList:AddMasked( TBitmap():Define( "New",, oDlg ), nRGB( 192, 192, 192 ) )
oImageList:AddMasked( TBitmap():Define( "Open",, oDlg ), nRGB( 192, 192, 192 ) )
oImageList:AddMasked( TBitmap():Define( "Print",, oDlg ), nRGB( 192, 192, 192 ) )
oImageList:AddMasked( TBitmap():Define( "Search",, oDlg ), nRGB( 192, 192, 192 ) )
oFld:SetImageList( oImageList )
RETURN NIL
//------------------- ACTIONS before TAB-SELECT -----------------------------------------------
STATIC FUNCTION SetFolder( oWnd, oFld, nOption, nOldOption )
IF nOption == 1
MsgAlert( "Action Page 1", "Attention" )
ENDIF
IF nOption == 2
MsgAlert( "Action Page 2", "Attention" )
ENDIF
IF nOption == 3
MsgAlert( "Action Page 3", "Attention" )
ENDIF
IF nOption == 4
MsgAlert( "Action Page 4", "Attention" )
ENDIF
RETURN .T.
// ---------- FOLDER-PAGE 1 --------------------
FUNCTION FOLDER_1(oDlg,oFld)
RETURN( NIL )
// ---------- FOLDER-PAGE 2 --------------------
FUNCTION FOLDER_2(oDlg,oFld)
RETURN( NIL )
// ---------- FOLDER-PAGE 3 --------------------
FUNCTION FOLDER_3(oDlg,oFld)
RETURN( NIL )
// ---------- FOLDER-PAGE 4 --------------------
FUNCTION FOLDER_4(oDlg,oFld)
RETURN( NIL )