#include "Fivewin.ch"
#include "xbrowse.ch"
//#include "colores.ch"
#define METRO_TURQUE RGB( 0, 128, 128 )
#define METRO_ROJO1 RGB( 115, 13, 26 )
#define METRO_ROJO2 RGB( 224, 67, 67 )
#define METRO_AZUL0 RGB( 118,148,168 )
#define METRO_AZUL1 RGB( 0,140,255 )
#define METRO_AZUL2 RGB( 0,175,242 )
#define METRO_AZUL3 RGB( 0, 32, 80 )
#define METRO_AZUL4 RGB( 0, 22, 62 )
#define METRO_AZUL5 RGB( 0,191,255 )
#define METRO_AZUL6 RGB( 196,255,255 )
#define METRO_AZUL7 RGB( 0, 50,128 )
#define METRO_AZUL8 RGB( 43, 87,154 )
#define METRO_AZUL9 RGB( 0, 25, 64 )
#define METRO_MORA1 RGB( 116, 40,148 )
#define METRO_GRIS1 RGB( 17, 17, 17 )
#define METRO_GRIS2 RGB( 51, 51, 51 )
#define METRO_BTNFACE RGB( 240,240,240 )
#define METRO_WINDOW RGB( 255,255,255 )
#define METRO_MENU RGB( 240,240,240 )
#define METRO_MENUTEXT RGB( 0, 0, 0 )
#define METRO_BACKGROUND RGB( 0, 0, 0 )
#define METRO_APPWORKSPACE RGB( 171,171,171 )
#define METRO_ACTIVECAPTION RGB( 153,180,209 )
#define METRO_INACTIVECAPTION RGB( 191,205,219 )
#define METRO_CAPTIONTEXT RGB( 0, 0, 0 )
#define METRO_ACTIVEBORDER RGB( 180,180,180 )
#define METRO_INACTIVEBORDER RGB( 244,247,252 )
#define METRO_HIGHLIGHT RGB( 51,153,255 )
#define METRO_HIGHLIGHTTEXT RGB( 255,255,255 )
#define METRO_BTNSHADOW RGB( 160,160,160 )
#define METRO_GRAYTEXT RGB( 109,109,109 )
#define METRO_BTNTEXT RGB( 0, 0, 0 )
#define METRO_INACTIVECAPTIONTEXT RGB( 0, 0, 0 )
#define METRO_BTNHIGHLIGHT RGB( 255,255,255 )
#define METRO_3DDHSHADOW RGB( 105,105,105 )
#define METRO_3DLIGHT RGB( 227,227,227 )
#define METRO_INFOTEXT RGB( 0, 0, 0 )
#define METRO_INFOBK RGB( 255,255,255 )
#define METRO_WINDOWFRAME RGB( 100,100,100 )
#define METRO_WINDOWTEXT RGB( 0, 0, 0 )
#define METRO_SCROLLBAR RGB( 200,200,200 )
#define BTN_UP 1
#define BTN_DOWN 2
#define BTN_DISABLE 3
#define BTN_OVERMOUSE 4
static oWndUI
Function Main( lMax )
local oMnu
local oBrush
local nColor := METRO_AZUL3 //APPWORKSPACE
local cShow := "MAXIMIZED" //IF( lMax, "MAXIMIZED", "NORMAL" )
local oTitUI
local cTitUI := "Titulo Aplicacion"
local oTUserUI
local cTUserUI := "Usuario"
local oFont1 := TFont():New("Segoe UI Light", 0 , -54 ) //-12
local oFont2 := TFont():New("Segoe UI Light", 0 , -24 ) //-12
local nColor1 := METRO_WINDOW
local nColor2 := METRO_AZUL3
local oBtn
local bBttIco := { || oWndUI:End() }
Local aBmps1 := { ;
"..\Bitmaps\32x32\edit.bmp" ,;
"..\Bitmaps\32x32\new.bmp" ,;
"..\Bitmaps\32x32\down.BMP" ,;
"..\Bitmaps\32x32\copy.BMP" ;
}
Local aBmps2 := { ;
"..\Bitmaps\alphabmp\chat.BMP" ,;
"..\Bitmaps\alphabmp\calendar.bmp" ,;
"..\Bitmaps\alphabmp\folder.bmp" ;
}
Local aBmps3 := { ;
"..\Bitmaps\alphabmp\cilinder.bmp",;
"..\Bitmaps\alphabmp\lock.bmp",;
"..\Bitmaps\alphabmp\android.bmp",;
"..\Bitmaps\alphabmp\terminal.bmp";
}
Local aBmps4 := { ;
"..\Bitmaps\alphabmp\trash.bmp" ;
}
Local aBmps5 := { ;
"..\Bitmaps\alphabmp\printer.bmp",;
"..\Bitmaps\32x32\movie.bmp" ;
}
Local aBmps6 := { ;
"..\Bitmaps\alphabmp\weather.bmp" ,;
"..\Bitmaps\alphabmp\widgets.bmp" ,;
"..\Bitmaps\alphabmp\text.bmp" ,;
"..\Bitmaps\alphabmp\phone.bmp" ;
}
Local aBmps7 := { ;
"..\Bitmaps\alphabmp\pendrive.bmp" ,;
"..\Bitmaps\alphabmp\imac.bmp" ,;
"..\Bitmaps\alphabmp\movie.bmp" ;
}
Local aBmps8 := { ;
"..\Bitmaps\32x32\floppy.bmp",;
"..\Bitmaps\32x32\fax.bmp",;
"..\Bitmaps\32x32\goto.bmp",;
"..\Bitmaps\32x32\graphics.bmp";
}
Local aBmps9 := { ;
"..\Bitmaps\32x32\help.bmp",;
"..\Bitmaps\32x32\info.bmp",;
"..\Bitmaps\32x32\keys.bmp";
}
Local aBmps := { aBmps1, aBmps2, , aBmps3, aBmps4, , ;
aBmps5, aBmps6, , aBmps7, aBmps8 , aBmps9 }
Local aTitGrps := { "Grupo Inicial","Grupo Trabajo","Otras Pruebas","Mis Utilidades" }
DEFINE BRUSH oBrush COLOR nColor
DEFINE WINDOW oWndUI ;
MENU oMnu ;
BRUSH oBrush
NoTitle()
@ 42, 105 SAY oTitUI PROMPT cTitUI OF oWndUI ;
FONT oFont1 ;
PIXEL COLOR nColor1, nColor2 ;
SIZE GetTextWidth(0,cTitUI, oFont1:hFont )+20, (-(oFont1:nInpHeight)+14) //;
@ 68, ScreenWidth()-240 SAY oTUserUI PROMPT cTUserUI OF oWndUI ;
FONT oFont2 ;
PIXEL COLOR nColor1, nColor2 ;
SIZE GetTextWidth(0,cTUserUI, oFont2:hFont ), (-(oFont2:nInpHeight)+14) //;
// 24, 24
oBtn := TBtnBmp():New( 70, ScreenWidth()-90, 32, 32,,, "..\Bitmaps\32x32\user.bmp",,;
bBttIco, oWndUI,,, .F., .F.,,,,, !.T.,, .F.,, ,;
.T.,, !.F.,, .T., .F. )
UIMnu( aBmps, aTitGrps, 118 )
ACTIVATE WINDOW oWndUI MAXIMIZED //ON INIT NoTitle()
Return nil
//----------------------------------------------------------------------------//
Function NoTitle()
Return SetWindowLong( oWndUI:hWnd, -16, "L" )
//----------------------------------------------------------------------------//
Function UIMnu( aBmps, aTitGrps, nSzBmp )
Local oXBrw
Local n := 0
Local z := 0
Local aT := {}
Local x
//Local oWClient := oWndUI
Local nWidth := 645
//if( oWinUI:lMdiUI, oWClient:oWndClient:nWidth - 4, ScreenWidth() - 5 ) //oWClient:nWidth - 4 )
Local nHeight //:= if( oWinUI:lMdiUI, oWClient:oWndClient:nHeight -2 - 26, ScreenHeight() - 68 ) //oWClient:nHeight + 100 )
Local oDlg
Local oBrush1
Local oFont1
Local oRect
Local y := 0
Local nColumnas := 0
Local nFilas := 0
Local nColVacias := 0
Local nNumFilas := 0
Local nMonitor := 0 //TipoMonitor()
Local aGruposHeader := {}
Local nBmp := 3
Local aBitmaps := {}
Local aBmpPal
Local nPonBorde := 0
Local hOldWhite
Local hOldShadow
local oFont2 := TFont():New("Segoe UI Light", 0 , -24 ) //-12
DEFAULT aBmps := {}
DEFAULT aTitGrps := {}
DEFAULT nSzBmp := 118
Do Case
Case nMonitor = 0
nFilas := 4
nColumnas := 9
nColVacias := 3
Case nMonitor = 1
nFilas := 5
nColumnas := 11
nColVacias := 5
Case nMonitor = 2
nFilas := 6
nColumnas := 13
nColVacias := 7
EndCase
For n := 1 to Len( aBmps )
if !Empty( aBmps[ n ] )
z := Max( z , Len( aBmps[ n ] ) )
endif
Next n
nNumFilas := z
//z := Min( z , nColumnas )
For n := 1 to z
AAdd( aT, n )
Next n
z := 0
y := 0
For n := 1 to Len( aBmps )
if !Empty( aBmps[ n ] )
if Empty( y )
y := n
endif
if n <= nColumnas + nColVacias
AAdd( aBitmaps , SetImgUI( aBmps[ n ], nSzBmp, nSzBmp, , ) )
endif
else
AAdd( aGruposHeader, { "Grupo: "+Strzero(y,2)+" a "+Strzero(n-1,2), y, n-1, nil } )
y := 0
endif
Next n
if y > 0
AAdd( aGruposHeader, { "Grupo: "+Strzero(y,2)+" a "+Strzero(n-1,2), y, n-1, nil } )
endif
For n := 1 to Len( aTitGrps )
if Len( aGruposHeader ) >= n
aGruposHeader[ n ][ 1 ] := aTitGrps[ n ]
endif
Next n
y := 0
nHeight := GetSysMetrics(1) - 68
// ScreenHeight()
DEFINE BRUSH oBrush1 COLOR METRO_AZUL3 //CLR_WHITE
DEFINE FONT oFont1 NAME "Segoe UI LIGHT" SIZE 0, -22 //-12
//oDlg := oWClient
//TXCBrowse
oXBrw := TXBrowse():New( oWndUI ) //oDlg )
WITH OBJECT oXBrw
:nStyle -= WS_BORDER
//nPonBorde := 3
:lTransparent := .F.
:cCaption := "" //"Prueba de Browse"
:l2007 := .F.
:lAllowColHiding := .T.
:lAllowColSwapping := .F.
:lVScroll := .F.
:lHScroll := .F.
:nRowHeight := 124
//:nFreeze := 1
:nMarqueeStyle := 3 //4 //MARQSTYLE_HIGHLCELL 3
nWidth := 0
For n = 1 to Len( aBmps )
if !Empty( aBmps[ n ] )
nWidth += ( oXBrw:nRowHeight ) //+ 4
else
nWidth += INT( oXBrw:nRowHeight / 3 ) //+ 4
endif
Next n
nWidth += 2*Len( aBmps )
:lHeader := .T.
:nHeaderHeight := 32
:lFooter := .F.
:nFooterHeight := 0 //32
:nTop := 168 - IF( :lHeader, :nHeaderHeight, 0 )
:nLeft := Min( (100 - IF( !:lVScroll, 0, 18 ) - IF( Empty( nPonBorde ), -3 , nPonBorde )),;
(GetSysMetrics( 0 ) - nWidth - IF( !:lVScroll, 0, 18 ) - nPonBorde ))
nHeight := :nRowHeight * nNumFilas + :nTop + 1
nWidth += :nLeft + nPonBorde - IF( Empty( nPonBorde ) , 0 , 1 )
:nBottom := nHeight + IF( !:lHScroll, 0 , 18 ) + ;
IF( :lFooter, :nFooterHeight, 0 ) + ; //+20
IF( !Empty( aGruposHeader ), :nHeaderHeight*IF(:lHeader,2,1), 0 )
//IF( :lHeader, :nHeaderHeight + 4, 0 ) + ;
:nRight := nWidth + IF( !:lVScroll, 0 , 18 )
:oBrush := oBrush1
:lDesign := .F.
:SetFont( oFont1 )
// DATAs del XCBrowse
if Upper( oXBrw:ClassName() ) == "TXCBROWSE"
oXBrw:lHeadSelec := .F.
oXBrw:lLinBorder := .F.
oXBrw:lLinDataSep := .F.
oXBrw:lLinHeadVSep := .F.
oXBrw:lLinHeadHSep := .F.
oXBrw:lLinFootVSep := .F.
oXBrw:lLinFootHSep := .F.
oXBrw:lHeadBtton := .F.
oXBrw:lRowDividerComplete := .F.
oXBrw:lNoEmpty := .T.
//:nWRecordSel := 24
//:nSpRecordSel := 0
else
hOldWhite := :hWhitePen
hOldShadow := :hBtnShadowPen
:hWhitePen := CreatePen( PS_SOLID, 1, METRO_AZUL3 )
:hBtnShadowPen := CreatePen( PS_SOLID, 1, METRO_AZUL3 )
endif
:lRecordSelector := .F.
:nRowDividerStyle := LINESTYLE_NOLINES //4
:nColDividerStyle := LINESTYLE_NOLINES //4
:nRecSelColor := METRO_AZUL8 //APPWORKSPACE //Rgb( 202, 162, 126 )
//:nStretchCol := STRETCHCOL_LAST
:nDataLines := 1
:bClrHeader := { || { CLR_WHITE, METRO_AZUL3, METRO_AZUL3 } }
:bClrFooter := { || { CLR_WHITE, METRO_AZUL3, METRO_AZUL3 } }
:bClrSel := { || { CLR_BLACK, METRO_AZUL8 } }
:bClrStd := { || { CLR_BLACK, METRO_AZUL3 } }
:bClrStds := { || { CLR_BLACK, METRO_AZUL3 } }
:bClrSelFocus := { || { CLR_BLACK, ;
if( len( oXBrw:aCols[ oXBrw:nColSel ]:aBitmaps ) >= oXBrw:nRowSel,;
METRO_AZUL8, METRO_AZUL3 ) } }
//8
:SetColor( CLR_BLACK, METRO_AZUL3 )
:SetArray( aT ) //aT
:lAutoSort := .F.
:bKeyChar := {|x,y,nF,oCol| XBrw1Elige( oXBrw:nArrayAt, oXBrw, x, y, oXBrw:nRowSel, oXBrw:nColSel, nF, oCol ) }
n := 0
For n := 1 to Len( aBmps )
if oXBrw:lHeader
oXBrw:aCols[ n ]:bClrHeader := { || { CLR_WHITE, METRO_AZUL3 } }
//oXBrw:aCols[ n ]:nHeadStrAlign := 0
if !Empty( aBmps[ n ] )
oXBrw:aCols[ n ]:cHeader := "" //"Columna"
endif
endif
if oXBrw:lFooter
oXBrw:aCols[ n ]:bClrFooter := { || { CLR_WHITE, METRO_AZUL3 } }
if !Empty( aBmps[ n ] )
oXBrw:aCols[ n ]:cFooter := "" //"Final"
endif
endif
if !Empty( aBmps[ n ] )
z++
oXBrw:aCols[n]:nWidth := oXBrw:nRowHeight
oXBrw:aCols[n]:aBitmaps := aBitmaps[z]
oXBrw:aCols[n]:bStrData := { || Nil }
oXBrw:aCols[n]:bBmpData := { | oB | oXBrw:nArrayAt }
oXBrw:aCols[n]:nDataStrAlign := 1
oXBrw:aCols[n]:lBmpStretch := .F. // Rellenar toda la celda con el BitMap
oXBrw:aCols[n]:lAllowSizing := .F.
oXBrw:aCols[n]:nEditType := 0
oXBrw:aCols[n]:lColTransparent := .F. // No funciona si el del Browse SI es TRANSPARENT
oXBrw:aCols[n]:lBmpTransparent := .F.
oXBrw:aCols[n]:bClrSel := { || { , METRO_AZUL3 } }
//oXBrw:aCols[n]:bClrStd := { || { CLR_BLACK, METRO_AZUL3 } }
//oXBrw:aCols[n]:bClrSelFocus := { || { CLR_BLACK, METRO_AZUL3 } }
oXBrw:aCols[n]:bLDClickData := {|x,y,nF,oCol| ;
XBrw1Elige( oXBrw:nArrayAt,;
oXBrw, x, y, oXBrw:nRowSel,;
oXBrw:nColSel, nF, oCol ) }
if n < Len( aBmps )
oXBrw:AddCol()
endif
else
if n < Len( aBmps )
oXBrw:AddCol()
oXBrw:aCols[n]:nWidth := Int( oXBrw:nRowHeight / 3 ) //+1
oXBrw:aCols[n]:bClrSel := { || { , METRO_AZUL3 } }
oXBrw:aCols[n]:bClrStd := { || { , METRO_AZUL3 } }
oXBrw:aCols[n]:bClrSelFocus := { || { , METRO_AZUL3 } }
endif
endif
Next n
For n = 1 to Len( aGruposHeader )
:SetGroupHeader( aGruposHeader[n][1], aGruposHeader[n][2], aGruposHeader[n][3], oFont2 )
Next n
:CreateFromCode()
//:hWhitePen := hOldWhite
//:hBtnShadowPen := hOldShadow
aBitmaps := Nil
aBmps := Nil
END
while oFont1:nCount > 0
oFont1:End()
end
//oFont1:End()
oBrush1:End()
oFont1 := Nil
oBrush1 := Nil
Return oXBrw
//----------------------------------------------------------------------------//
Function SetImgUI( aBmps, nH, nW, oButton, nPos )
Local x
Local aBitmaps := {}
Local aBmpPal
Local cExt := ""
Local uFile := ""
DEFAULT aBmps := {}
DEFAULT nH := 32
DEFAULT nW := 32
DEFAULT oButton := Nil
DEFAULT nPos := 0
if !empty( aBmps )
Do Case
Case Valtype( aBmps ) = "C"
uFile := aBmps
cExt := Right( Upper( uFile ), 3 )
Do Case
Case Upper( cExt ) = "BMP"
AAdd( aBitmaps, Array(6) )
aBmpPal := PalBmpRead( , aBmps )
aBitmaps[ x, 1 ] := aBmpPal[ 1 ]
aBitmaps[ x, 2 ] := aBmpPal[ 2 ]
aBitmaps[ x, 3 ] := nH //64
aBitmaps[ x, 4 ] := nW //108
aBitmaps[ x, 5 ] := 0
aBitmaps[ x, 6 ] := .F.
aBmpPal := Nil
Case Upper( cExt ) = "PNG"
AAdd( aBitmaps, Array(6) )
aBmpPal := FWOpenPngFile( aBmps )
aBitmaps[ x, 1 ] := aBmpPal
aBitmaps[ x, 2 ] := 0
aBitmaps[ x, 3 ] := nH //64
aBitmaps[ x, 4 ] := nW //108
aBitmaps[ x, 5 ] := 0
aBitmaps[ x, 6 ] := .F.
aBmpPal := Nil
EndCase
Case Valtype( aBmps ) = "A"
For x = 1 to Len( aBmps )
uFile := aBmps[ x ]
cExt := Right( Upper( uFile ), 3 )
Do Case
Case Upper( cExt ) = "BMP"
AAdd( aBitmaps, Array(6) )
aBmpPal := PalBmpRead( , aBmps[x] )
aBitmaps[ x, 1 ] := aBmpPal[ 1 ]
aBitmaps[ x, 2 ] := aBmpPal[ 2 ]
aBitmaps[ x, 3 ] := nH //64
aBitmaps[ x, 4 ] := nW //108
aBitmaps[ x, 5 ] := 0
aBitmaps[ x, 6 ] := .F.
aBmpPal := Nil
Case Upper( cExt ) = "PNG"
AAdd( aBitmaps, Array(6) )
aBmpPal := FWOpenPngFile( aBmps[ x ] )
//if Valtype( aBmpPal ) = "A"
aBitmaps[ x, 1 ] := aBmpPal
aBitmaps[ x, 2 ] := 0
aBitmaps[ x, 3 ] := nH //64
aBitmaps[ x, 4 ] := nW //108
aBitmaps[ x, 5 ] := 0
aBitmaps[ x, 6 ] := .F.
//endif
aBmpPal := Nil
Otherwise
if empty( aBmps[x] )// .and. aBmps[x] <> Nil
AAdd( aBitmaps, Array(6) )
endif
EndCase
uFile := ""
cExt := ""
Next x
EndCase
endif
return aBitmaps
//----------------------------------------------------------------------------//
Function XBrw1Elige( nPos, oBrw, x, y, nRow, nCol, nF, oCol )
? nRow, nCol
Do Case
Case nCol = 1
Do Case
Case nRow = 1
Case nRow = 2
Case nRow = 3
Case nRow = 4
EndCase
Case nCol = 2
Do Case
Case nRow = 1
Case nRow = 2
Case nRow = 3
Case nRow = 4
EndCase
Case nCol = 4
Do Case
Case nRow = 1
Case nRow = 2
Case nRow = 3
Case nRow = 4
EndCase
Otherwise
EndCase
Return nil
//----------------------------------------------------------------------------//