#include "fivewin.ch"
function colsasrows2()
local oWnd, oBrw, oFont, aCols
local nLine := 0
USE CUSTOMER ALIAS CUST
// xbrowse()
DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
DEFINE WINDOW oWnd
oWnd:SetFont( oFont )
aCols := { ;
{ { || If( nLine == 0, STR(CUST->ID,4), "" ) }, "ID" }, ;
{ { || If( nLine == 0, CUST->FIRST+" "+CUST->LAST, If( nLine == 1, CUST->ZIP, CUST->ZIP ) ) }, "CustName" }, ;
{ { || If( nLine == 0, CUST->STREET, If( nLine == 1, CUST->CITY, CUST->ZIP ) ) }, "Address" }, ;
{ { || If( nLine == 0, DTOC(CUST->HIREDATE), If( nLine == 1, Str( CUST->AGE, 2 ), TRANSFORM( CUST->SALARY,"9,999,999.99") ) ) }, "Details" } }
@ 0,0 XBROWSE oBrw OF oWnd DATASOURCE "CUST" ;
COLUMNS aCols ;
CELL LINES NOBORDER
// Navigation blocks
oBrw:bGoTop := { || nLine := 0, ( oBrw:cAlias )->( DBGOTOP() ) }
oBrw:bGoBottom := { || nLine := 2, ( oBrw:cAlias )->( DBGOBOTTOM() ) }
oBrw:bKeyCount := { || ( oBrw:cAlias )->( OrdKeyCount() ) * 3 }
oBrw:bKeyNo := { || ( ( oBrw:cAlias )->( OrdKeyNo() - 1 ) * 3 ) + 1 + nLine }
oBrw:bSkip := { |nSkip| ( oBrw:cAlias )->( MySkipper( nSkip, @nLine ) ) }
oBrw:bKeyNo := { |n| If( n != nil, ( n--, ( oBrw:cAlias )->( OrdKeyGoTo( Int( n / 3 ) + 1 ) ), nLine := n % 3 ), nil ), ;
( ( oBrw:cAlias )->( OrdKeyNo() - 1 ) * 3 ) + 1 + nLine }
oBrw:bBookMark := { |n| If( n != nil, ( n--, ( oBrw:cAlias )->( DbGoTo( Int( n / 3 ) + 1 ) ), nLine := n % 3 ), nil ), ;
( ( oBrw:cAlias )->( RecNo() - 1 ) * 3 ) + 1 + nLine }
WITH OBJECT oBrw
:aCols[ 1 ]:nDataStrAlign := AL_RIGHT
:aCols[ 2 ]:bLeftText := { || If( nLine == 0, "", If( nLine == 1, "Phone1", "Phone2:" ) ) }
:aCols[ 2 ]:bStrImage := { || If( nLine == 0, "", If( nLine == 1, "phone.bmp", "phone2.bmp" ) ) }
:aCols[ 2 ]:nDataBmpAlign := AL_RIGHT
:aCols[ 3 ]:bStrImage := { || If( nLine == 0, "address.bmp", If( nLine == 1, "city.bmp", "note.bmp" ) ) }
:aCols[ 3 ]:nDataBmpAlign := AL_RIGHT
:aCols[ 3 ]:nWidth := 340
:aCols[ 3 ]:bLeftText := { || If( nLine == 0, "Address:", If( nLine == 1, "City:", "Cap:" ) ) }
:aCols[ 4 ]:nWidth := 140
:aCols[ 4 ]:nDataStrAlign := AL_RIGHT
:aCols[ 4 ]:bLeftText := { || If( nLine == 0, "Date:", If( nLine == 1, "Age:", "Sal:" ) ) }
:bClrStd := { || { CLR_BLACK, If( nLine == 0, CLR_HGRAY, CLR_WHITE ) } }
//
:CreateFromCode()
END
oWnd:oClient := oBrw
ACTIVATE WINDOW oWnd CENTERED
RELEASE FONT oFont
return nil
static function MySkipper( nSkip, nLine )
local nSkipped := 0
DEFAULT nSkip := 1
if nSkip == 0
return 0
endif
if nSkip > 0
do while nSkipped < nSkip
if nLine < 2
nLine++
nSkipped++
else
DBSKIP( 1 )
if Eof()
DBGOBOTTOM()
EXIT
endif
nLine := 0
nSkipped++
endif
enddo
else
do while nSkipped > nSkip
if nLine > 0
nLine--
nSkipped--
else
DBSKIP( -1 )
if BOF()
EXIT
endif
nLine := 2
nSkipped--
endif
enddo
endif
return nSkipped