#include "Appevent.ch" #include "Common.ch" #include "Font.ch" #include "Xbp.ch" #include "DMLB.CH" #include "DBFDBE.CH" CLASS CheckboxCellGroup FROM XbpCellGroup PROTECTED: VAR checkboxArray VAR Parent VAR Owner EXPORTED: VAR datalink METHOD init METHOD create METHOD getcell METHOD setcell METHOD drawcell METHOD cellfromPos METHOD cellrect METHOD hilitecell METHOD rowcount METHOD scrolldown METHOD scrollup METHOD setcellcolor METHOD show ENDCLASS METHOD CheckboxCellGroup:cellfromPos( aPos ) return ::xbpCellGroup:cellfromPos( aPos ) METHOD CheckboxCellGroup:cellrect( nRowPos ) return ::xbpCellGroup:cellrect(nRowPos) METHOD CheckboxCellGroup:hilitecell(nRow, lHilite, lFrame, lRepaint) return self METHOD CheckboxCellGroup:rowcount return ::xbpCellGroup:rowcount() METHOD CheckboxCellGroup:scrolldown(nRows, lRepaint) return ::xbpCellGroup:scrolldown(nRows, .T.) METHOD CheckboxCellGroup:scrollup(nRows, lRepaint) return ::xbpCellGroup:scrollup(nRows, .T. ) METHOD CheckboxCellGroup:setcellcolor(nRows, nFG, nBG, lRepaint) return ::xbpCellGroup:setcellcolor(nRows, nFG, nBG, .t.) METHOD CheckboxCellGroup:show local n for n := 1 to len( ::checkboxArray ) ::checkboxArray[ n ]:show( ) next return self METHOD CheckboxCellGroup:init( oParent, oOwner, aPos, aSize, aPP, lVisible ) ::xbpCellGroup:init( oParent, oOwner, aPos, aSize, aPP, lVisible ) ::checkBoxArray := { } if oParent <> NIL ::parent := oParent endif if oOwner <> NIL ::owner := oOwner endif ::type := XBPCOL_TYPE_TEXT return self METHOD CheckboxCellGroup:create( oParent, oOwner, aPos, aSize, aPP, lVisible ) ::xbpCellGroup:create( oParent, oOwner, aPos, aSize, aPP, lVisible ) if oParent <> NIL ::parent := oParent endif if oOwner <> NIL ::owner := oOwner endif return self METHOD CheckboxCellGroup:getcell( nRowPos ) LOCAL aRect, nWidth, nHeight, aPos, aSize aSize := { 12, 12 } do while len( ::checkboxArray ) < nRowPos aadd( ::checkboxArray, NIL ) enddo if ::checkboxArray[ nRowPos ] == NIL aRect := ::cellRect( nRowPos ) nWidth := aRect[3] - aRect[1] nHeight := aRect[4] - aRect[2] aPos := { aRect[1] + ( nWidth - aSize[1] ) / 2, aRect[2] + ( nHeight - aSize[2] ) / 2 } ::checkboxArray[ nRowPos ] := XBPCheckbox():new( ::Parent, ::Owner, aPos, {12, 12} ):create( ) ::checkboxArray[ nRowPos ]:datalink := ::Parent:datalink endif ::checkboxArray[ nRowPos ]:getData( ) return .t. METHOD CheckboxCellGroup:setcell( nRowPos, xValue, nType, Repaint ) LOCAL aRect, nWidth, nHeight, aPos, aSize aSize := { 12, 12 } do while len( ::checkboxArray ) < nRowPos aadd( ::checkboxArray, NIL ) enddo if ::checkboxArray[ nRowPos ] == NIL aRect := ::cellRect( nRowPos ) nWidth := aRect[3] - aRect[1] nHeight := aRect[4] - aRect[2] aPos := { aRect[1] + ( nWidth - aSize[1] ) / 2, aRect[2] + ( nHeight - aSize[2] ) / 2 } ::checkboxArray[ nRowPos ] := XBPCheckbox():new( ::Parent, ::Owner, aPos, {12, 12} ):create( ) ::checkboxArray[ nRowPos ]:datalink := ::Parent:datalink endif ::checkboxArray[ nRowPos ]:setData( ) return .t. METHOD CheckboxCellGroup:drawcell( xRowPos ) LOCAL aRect, aPos, aSize, nWidth, nHeight, n ::xbpCellGroup:drawcell( xRowPos ) aSize := { 12, 12 } if valtype( xRowPos ) == "N" aRect := ::cellRect( xRowPos ) // x1, y1, x2, y2 nWidth := aRect[3] - aRect[1] nHeight := aRect[4] - aRect[2] aPos := { aRect[1] + ( nWidth - aSize[1] ) / 2, aRect[2] + ( nHeight - aSize[2] ) / 2 } do while len( ::checkboxArray ) < xRowPos aadd( ::checkboxArray, NIL ) enddo if ::checkboxArray[ xRowPos ] == NIL ::checkboxArray[ xRowPos ] := XBPCheckbox():new( ::Parent, ::Owner, aPos, {12, 12} ):create( ) ::checkboxArray[ xRowPos ]:datalink := ::Parent:datalink endif ::checkboxArray[ xRowPos ]:setPos( aPos ) ::checkboxArray[ xRowPos ]:setData( ) elseif valtype( xRowPos ) == "A" for n := 1 to len( xRowPos ) if valtype( xRowPos[ n ] ) == "N" aRect := ::cellRect( xRowPos[ n ] ) // x1, y1, x2, y2 nWidth := aRect[3] - aRect[1] nHeight := aRect[4] - aRect[2] aPos := { aRect[1] + ( nWidth - aSize[1] ) / 2, aRect[2] + ( nHeight - aSize[2] ) / 2 } do while len( ::checkboxArray ) < xRowPos[ n ] aadd( ::checkboxArray, NIL ) enddo if ::checkboxArray[ xRowPos[ n ] ] == NIL ::checkboxArray[ xRowPos[ n ] ] := XBPCheckbox():new( ::Parent, ::Owner, aPos, {12, 12} ):create( ) ::checkboxArray[ xRowPos[ n ] ]:datalink := ::Parent:datalink endif ::checkboxArray[ xRowPos[ n ] ]:setPos( aPos ) ::checkboxArray[ xRowPos[ n ] ]:setData( ) endif next endif return .T. CLASS CheckboxColumn FROM XbpColumn EXPORTED: INLINE METHOD Init( oParent, oOwner, aPos, aSize, aPP, lVisible ) ::XbpColumn:Init( oParent, oOwner, aPos, aSize, aPP, lVisible ) ::dataArea := CheckboxCellgroup():New( self ) RETURN self ENDCLASS // EOF //////