* Begin ========================================================================================================== *
* DERIVED CLASS
CLASS TXbrGrid FROM TXBrowse
CLASSDATA lRegistered AS LOGICAL && This is compulsory for derived classes
DATA bColClass INIT { | | TXbGridCol () }
DATA nGridCols INIT 1 PROTECTED
DATA hlGridView AS LOGICAL INIT .F.
DATA nRows
ACCESS lListview INLINE ( ! ::hlGridView )
ASSIGN lListView ( l ) INLINE IIF ( ::hlGridView == l, ( ::hlGridview := ! l, ::ResetGridView (), ::Refresh () ), NIL )
ACCESS lGridView INLINE ( ::hlGridView )
ASSIGN lGridView ( l ) INLINE IIF ( ::hlGridView != l, ( ::hlGridView := l, ::ResetGridView (), ::Refresh () ), NIL )
METHOD New ( oWnd ) CONSTRUCTOR
METHOD SetArray ( aData, lAutoSort, nColOrder, aCols )
METHOD Adjust ()
METHOD Resize ( nSizeType, nWidth, nHeight ) INLINE ( ::ResetGridView (), Super:ReSize ( nSizeType, nWidth * 2, nHeight * 2 ) )
PROTECTED:
METHOD ResetGridView()
ENDCLASS
* ---------------------------------------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------------------------------------- *
METHOD New( oWnd ) CLASS TXbrGrid
Super:New( oWnd )
Return ( Self )
* ---------------------------------------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------------------------------------- *
METHOD SetArray ( aData, lAutoSort, nColOrder, aCols ) CLASS TXbrGrid
Local nCols, n
IF VALTYPE ( aCols ) != "A"; aCols := NIL; ENDIF
Super:SetArray ( aData, .F., NIL, aCols )
::nRows := LEN ( ::aArrayData )
::bKeyCount := { | | ::nRows }
::bEof := { | | ::nArrayAt > ::nRows * ::nGridCols }
::bGoTop := { | | ::nArrayAt := 1 }
::bGoBottom := { | | ::nArrayAt := ( ::nRows - 1 ) * ::nGridCols + 1 }
::bKeyCount := { | | ::nRows }
::bSkip := { | nSkip, nOld | IIF ( nSkip == NIL, nSkip := 1, ), ;
nOld := ::nArrayAt, ;
::nArrayAt += ::nGridCols * nSkip, ;
::nArrayAt := MAX ( 1, MIN ( ::nArrayAt, ::nRows * ::nGridCols - 3 ) ), ( ::nArrayAt - nOld ) / ::nGridCols }
::bBookMark := ::bKeyNo := { | n | IIF ( n != NIL, ::nArrayAt := ( n - 1 ) * ::nGridCols + 1, NIL ), INT ( ( ::nArrayAt - 1 ) / ::nGridCols ) + 1 }
nCols := LEN ( ::aCols )
AEval ( ::aCols, { | o | o:nArrayRow := 0 } )
Return ( Self )
* ---------------------------------------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------------------------------------- *
METHOD Adjust () CLASs TXbrGrid
Local n
FOR n := 1 TO 10
AddGridCols ( Self, LEN ( ::aCols ), n )
NEXT n
AEVAL ( ::aCols, { | o, i | o:nCreationOrder := i } )
Return Super:Adjust ()
* ---------------------------------------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------------------------------------- *
Static Function AddGridCols ( oBrw, nCols, n )
Local nCol
FOR x := 1 TO nCols
AADD ( oBrw:aCols, OClone ( oBrw:aCols [ x ] ) )
WITH OBJECT ATAIL ( oBrw:aCols )
:nArrayRow := n
:lHide := .T.
END
NEXT x
Return ( NIL )
* ---------------------------------------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------------------------------------- *
METHOD ResetGridview () CLASS TXbrGrid
Local nWidth := 0
Local nCols := 0
AEVAL ( ::aCols, { | o | IIF ( EMPTY ( o:nArrayRow ), ( nCols ++, nWidth += o:nWidth ), NIL ) } )
nWidth += 3
IF ::hlGridView
::nGridCols := INT ( ( ::BrwWidth () - 2 ) / nWidth )
::nRows := Ceiling ( LEN ( ::aArrayData ) / ::nGridCols )
nCols *= ::nGridCols
ELSE
::nGridCols := 1
::nRows := LEN ( ::aArrayData )
ENDIF
AEVAL ( ::aCols, { | o, i | o:lHide := o:nCreationOrder > nCols } )
::GetDisplayCols ()
* ::Refresh ()
Return ( Self )
* End ============================================================================================================ *
* Begin ========================================================================================================== *
CLASS TXbGridCol FROM TXBrwColumn
DATA nArrayRow INIT 0
METHOD New ( oBrw ) CONSTRUCTOR
METHOD Adjust ()
ENDCLASS
* ---------------------------------------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------------------------------------- *
METHOD New ( oBrw ) CLASS TXbGridCol
Super:New( oBrw )
Return ( Self )
* ---------------------------------------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------------------------------------- *
METHOD Adjust () CLASS TXbGridCol
Local tmp
::bEditValue := { | x | IIF ( x == NIL, ::oBrw:ArrCell ( ::oBrw:nArrayAt + ::nArrayRow, ::nArrayCol ),;
::oBrw:ArrCellSet ( ::oBrw:nArrayAt + ::nArrayRow, ::nArrayCol, x ) ) }
IF VALTYPE ( ::bBmpData ) == "N"
tmp := ::bBmpData
::bBmpData := { | | ::oBrw:aRow [ tmp ] }
ELSEIF ::bStrData == NIL .AND. ! ::hChecked
::bStrData := { | | ::oBrw:ArrCell ( ::oBrw:nArrayAt + ::nArrayRow, ::nArrayCol, ::cEditPicture, ::lDisplayZeros ) }
ENDIF
Return Super:Adjust ()
* End ============================================================================================================ *
* ---------------------------------------------------------------------------------------------------------------- *
*
*
*