METHOD DrawSelect( xRow, lDrawCell ) CLASS TSBrowse Local nI, nJ, nBegin, nStartCol, oColumn, nLastCol, hBitMap, hFont, nAlign, cPicture, nClrFore, nClrBack, ; lNoLite, uData, l3DLook, lMulti, nClrTo, lOpaque, lBrush, nCursor, lCheck, uBmpCell, cMsg, lAdjBmp, ; lSelected, ; nVertText := 0, ; nMaxWidth := ::nWidth(), ; // use local copies for speed nRowPos := ::nRowPos, ; aColSizes := AClone( ::aColSizes ), ; hWnd := ::hWnd, ; hDC := ::hDc, ; lFocused := ::lFocused := ( GetFocus() == ::hWnd ), ; nVAlign := 1 Local l3DText, nClr3dL, nClr3dS Local aBitMaps, lCheckVal := .F., cColAls Local nDeltaLen, lDraw := .F., xData Local nAt, oCell, cCell, lCell Local nClrText := ::nClrText, ; nClrPane := ::nClrPane, ; nClrFocuFore := ::nClrFocuFore, ; nClrFocuBack := ::nClrFocuBack, ; nClrLine := ::nClrLine, ; nLineStyle /*:= ::nLineStyle*/, ; nClrSeleBack := ::nClrSeleBack, ; nClrSeleFore := ::nClrSeleFore, ; nHeightCell := ::nHeightCell, ; nHeightHead := iif( ::lDrawHeaders, ::nHeightHead, 0 ), ; nHeightFoot := iif( ::lDrawFooters != Nil .and. ::lDrawFooters, ::nHeightFoot, 0 ), ; nHeightSuper := iif( ::lDrawHeaders, ::nHeightSuper, 0 ),; nHeightSpecHd:= iif( ::lDrawSpecHd, ::nHeightSpecHd, 0 ) Default xRow := nRowPos, lDrawCell := .T. ::nPaintRow := xRow ::aDrawCols := {} If Empty( ::aColumns ) Return Self EndIf If _HMG_MainClientMDIHandle != 0 .and. ! lFocused .and. ::hWndParent == GetActiveMdiHandle() lFocused := .T. EndIf ::lDrawSelect := .T. lSelected := ::lCanSelect .and. ( AScan( ::aSelected, iif( ::lIsDbf, ( ::cAlias )->( RecNo() ), ::nAt ) ) > 0 ) If ( ::lNoLiteBar .or. ( ::lNoGrayBar .and. ! lFocused ) ) .and. Empty( ::hBmpCursor ) ::DrawLine() // don't want hilited cursor bar of any color ElseIf ::nLen > 0 nClrBack := iif( ::nPhantom = -1 .and. ! Empty( ::aColumns ), ATail( ::aColumns ):nClrBack, nClrPane ) nClrBack := iif( ValType( nClrBack ) == "B", Eval( nClrBack, ::nAt, Len( ::aColumns ), Self ), nClrBack ) l3DLook := iif( ::nPhantom = -1 .and. ! Empty( ::aColumns ), ATail( ::aColumns ):l3DLook, .F. ) If ::oPhant == Nil // "Phantom" column; :nPhantom hidden IVar ::oPhant := TSColumn():New( "", ; // cHeading {|| "" }, ; // bdata nil, ; // cPicture { nClrText, nClrBack }, ; // aColors nil, ; // aAlign ::nPhantom, ; // nWidth nil, ; // lBitMap nil, ; // lEdit nil, ; // bValid .T., ; // lNoLite nil, ; // cOrder nil, ; // cFooting nil, ; // bPrevEdit nil, ; // bPostEdit nil, ; // nEditMove nil, ; // lFixLite {l3DLook}, ; nil, ; Self ) ::oPhant:cName := "oPhant" ::oPhant:nId := -1 Else ::oPhant:nClrFore := nClrText ::oPhant:nClrBack := nClrBack ::oPhant:nWidth := ::nPhantom ::oPhant:l3DLook := l3DLook EndIf AAdd( aColSizes, ::nPhantom ) nJ := nStartCol := 0 nLastCol := Len( ::aColumns ) + 1 nBegin := Min( iif( ::nColPos <= ::nFreeze, ( ::nColPos := ::nFreeze + 1, ::nColPos - ::nFreeze ), ; ::nColPos - ::nFreeze ), nLastCol ) IF ::lRowPosAtRec IF Empty( ::aRowPosAtRec ) .or. Len( ::aRowPosAtRec ) != ::nRowCount() ::aRowPosAtRec := Array( ::nRowCount() ) AFill( ::aRowPosAtRec, 0 ) ENDIF IF xRow == 0 .or. xRow > Len( ::aRowPosAtRec ) ELSEIF ::lIsDbf ::aRowPosAtRec[ xRow ] := ( nAt := ( ::cAlias )->( RecNo() ) ) ELSEIF ::lIsArr ::aRowPosAtRec[ xRow ] := ( nAt := ::nAt ) ENDIF ENDIF If ::bOnDrawLine != Nil IF !Empty( Eval( ::bOnDrawLine, Self, xRow ) ) RETURN Self ENDIF EndIf If ! ::lDrawLine nBegin := 1 nLastCol := ::nColCount() EndIf IF nAt == NIL nAt := iif( ::lIsDbf, ( ::cAlias )->( RecNo() ), ::nAt ) ENDIF For nI := nBegin To nLastCol If nStartCol >= nMaxWidth .and. ::lDrawLine Exit EndIf nJ := iif( nI < ::nColPos, nJ + 1, nI ) oColumn := iif( nJ > Len( ::aColumns ), ::oPhant, ::aColumns[ nJ ] ) nLineStyle := ::nLineStyle nDeltaLen := ::GetDeltaLen( nJ, nStartCol, nMaxWidth, aColSizes ) cCell := hb_ntos(nAt)+"."+hb_ntos(oColumn:nId) lCell := .F. IF ::lFastDrawCell oCell := hb_HGetDef( ::aFastDrawCell, cCell, NIL ) lCell := ISOBJECT(oCell) ENDIF //If HB_ISNUMERIC( oColumn:nLineStyle ) // nLineStyle := oColumn:nLineStyle //EndIf nLineStyle := iif( HB_ISNUMERIC( oColumn:nLineStyle ), oColumn:nLineStyle, ::nLineStyle ) hFont := ::hFontGet( oColumn, nJ ) lAdjBmp := oColumn:lAdjBmp nAlign := oColumn:nAlign lOpaque := .T. lMulti := .F. cColAls := iif( '->' $ oColumn:cField, Nil, oColumn:cAlias ) If nJ == 1 .and. ! Empty( ::hBmpCursor ) uBmpCell := ::hBmpCursor uData := "" xData := "" nAlign := nMakeLong( oColumn:nAlign, oColumn:nAlign ) lNoLite := .T. lAdjBmp := .F. lCheck := .F. Else If Valtype( oColumn:bSeek ) == 'B' If cColAls != Nil ( cColAls )->( Eval( oColumn:bSeek, Self, nJ ) ) Else Eval( oColumn:bSeek, Self, nJ ) EndIf EndIf If ::lIsArr .and. ( ::lAppendMode .or. ::nAt > Len( ::aArray ) ) uData := "" // append mode for arrays //ElseIf cColAls != Nil // If Valtype( oColumn:bSeek ) == 'B' // ( cColAls )->( Eval( oColumn:bSeek, Self, nJ ) ) // EndIf // uData := ::bDataEval( oColumn, , nJ ) ElseIf lCell uData := oCell:uValue Else //If Valtype( oColumn:bSeek ) == 'B' // Eval( oColumn:bSeek, Self, nJ ) //EndIf uData := ::bDataEval( oColumn, , nJ ) EndIf xData := uData lMulti := Valtype( uData ) == "C" .and. At( Chr( 13 ), uData ) > 0 cPicture := ::cPictureGet( oColumn, nJ ) lCheck := ( oColumn:lCheckBox .and. ValType( uData ) == "L" .and. oColumn:lVisible ) lNoLite := oColumn:lNoLite nVertText := 0 If lCheck cPicture := "" nVertText := iif( uData, 3, 4 ) lCheckVal := uData EndIf uBmpCell := oColumn:uBmpCell If nJ == ::nColSel .and. ::uBmpSel != Nil .and. lSelected uBmpCell := ::uBmpSel nAlign := nMakeLong( LoWord( nAlign ), ::nAligBmp ) ElseIf oColumn:lBitMap .and. Valtype( uData ) == "N" aBitMaps := iif( Valtype( oColumn:aBitMaps ) == "A", oColumn:aBitMaps, ::aBitMaps ) If ! Empty( aBitMaps ) .and. uData > 0 .and. uData <= Len( aBitMaps ) uBmpCell := aBitMaps[ uData ] EndIf nAlign := nMakeLong( LoWord( nAlign ), nAlign ) uData := "" ElseIf ! lCheck .and. oColumn:lEmptyValToChar .and. Empty( uData ) uData := "" ElseIf lCell uData := oCell:cValue ElseIf Empty( cPicture ) .or. lMulti uData := iif( Valtype( uData ) != "C", cValToChar( uData ), uData ) Else uData := iif( uData == NIL, "", Transform( uData, cPicture ) ) EndIf EndIf nAlign := ::nAlignGet( oColumn:nAlign, nJ, DT_LEFT ) If lNoLite If ::lLiteBar nClrFore := ::GetValProp( oColumn:nClrFocuFore, nClrText, nJ, ::nAt ) nClrBack := ::GetValProp( oColumn:nClrFocuBack, nClrPane, nJ, ::nAt ) If ! Empty(oColumn:cName) .and. oColumn:cName == "oPhant" nClrBack := nClrPane ElseIf ValType( nClrBack ) == "N" .and. nClrBack < 0 nClrBack *= -1 EndIf Else nClrFore := ::GetValProp( oColumn:nClrFore, nClrText, nJ, ::nAt ) nClrBack := ::GetValProp( oColumn:nClrBack, nClrPane, nJ, ::nAt ) EndIf nCursor := 0 Else If ( nClrFore := iif( lFocused, oColumn:nClrFocuFore, oColumn:nClrSeleFore ) ) == Nil nClrFore := iif( lFocused, nClrFocuFore, nClrSeleFore ) EndIf nClrFore := ::GetValProp( nClrFore, nClrFore, nJ, ::nAt ) If ( nClrBack := iif( lFocused, oColumn:nClrFocuBack, oColumn:nClrSeleBack ) ) == Nil nClrBack := iif( lFocused, nClrFocuBack, nClrSeleBack ) EndIf nClrBack := ::GetValProp( nClrBack, nClrBack, nJ, ::nAt ) If ValType( nClrBack ) == "N" .and. nClrBack < 0 nCursor := Abs( nClrBack ) nClrBack := ::GetValProp( oColumn:nClrBack, nClrPane, nJ, ::nAt ) Else nCursor := 0 EndIf EndIf If ValType( nClrBack ) == "A" nClrBack := ::nClrBackArr( nClrBack, nJ, ::nAt ) nClrTo := nClrBack[2] nClrBack := nClrBack[1] Else nClrTo := nClrBack EndIf lBrush := Valtype( nClrBack ) == "O" l3DLook := oColumn:l3DLook hBitMap := iif( ValType( uBmpCell ) == "B" .and. ! ::lPhantArrRow, Eval( uBmpCell, nJ, Self ), uBmpCell ) hBitMap := iif( ValType( hBitMap ) == "O" .and. ! ::lPhantArrRow, Eval( ::bBitMapH, hBitMap ), hBitMap ) Default hBitMap := 0 If lCheck IF lCell hBitMap := oCell:hBitMap nAlign := oCell:nAlign ELSE Default ::aCheck := { StockBmp( 6 ), StockBmp( 7 ) } If Valtype(oColumn:aCheck) == "A" hBitMap := oColumn:aCheck[ iif( lCheckVal, 1, 2 ) ] Else hBitMap := ::aCheck[ iif( lCheckVal, 1, 2 ) ] EndIf nAlign := nMakeLong( DT_CENTER, DT_CENTER ) ENDIF uData := "" EndIf If oColumn:l3DTextCell != Nil l3DText := oColumn:l3DTextCell nClr3dL := oColumn:nClr3DLCell nClr3dS := oColumn:nClr3DSCell nClr3dL := iif( ValType( nClr3dL ) == "B", Eval( nClr3dL, ::nAt, nJ, Self ), nClr3dL ) nClr3dS := iif( ValType( nClr3dS ) == "B", Eval( nClr3dS, ::nAt, nJ, Self ), nClr3dS ) Else l3DText := nClr3dL := nClr3dS := Nil EndIf oColumn:nEditWidthDraw := 0 If nDeltaLen > 0 oColumn:nEditWidthDraw := aColSizes[ nJ ] + nDeltaLen EndIf IF ! lCell If nAlign != DT_CENTER .and. ::nCellMarginLR != NIL uData := ::CellMarginLeftRight( nJ, uData, oColumn, nAlign, lMulti, 0 ) EndIf ENDIF IF Empty( oColumn:oCell ) oColumn:oCell := TSBcell():New() ENDIF oColumn:oCell:nRow := nRowPos oColumn:oCell:nCol := nStartCol oColumn:oCell:nWidth := aColSizes[ nJ ] + nDeltaLen oColumn:oCell:nHeight := ::nHeightCell oColumn:oCell:nCell := nJ oColumn:oCell:uValue := xData oColumn:oCell:lDrawLine := .F. // DrawSelect() oColumn:oCell:hWnd := hWnd // 1 oColumn:oCell:hDC := hDC // 2 oColumn:oCell:xRow := nRowPos // 3 oColumn:oCell:nStartCol := nStartCol // 4 oColumn:oCell:nSize := aColSizes[ nJ ] + nDeltaLen // 5 aColSizes[ nJ ] + nDeltaLen oColumn:oCell:uData := uData // 6 oColumn:oCell:nAlign := nAlign // 7 oColumn:oCell:nClrFore := nClrFore // 8 oColumn:oCell:nClrBack := nClrBack // 9 oColumn:oCell:hFont := hFont // 10 oColumn:oCell:hBitMap := hBitMap // 11 oColumn:oCell:nHeightCell:= nHeightCell // 12 oColumn:oCell:l3DLook := l3DLook // 13 oColumn:l3DLook oColumn:oCell:nLineStyle := nLineStyle // 14 oColumn:oCell:nClrLine := nClrLine // 15 oColumn:oCell:nDrawType := 0 // 16 line/header/footer/super oColumn:oCell:nHeightHead:= nHeightHead // 17 oColumn:oCell:nHeightFoot:= nHeightFoot // 18 oColumn:oCell:nHeightSuper := nHeightSuper // 19 oColumn:oCell:nHeightSpecHd := nHeightSpecHd // 20 oColumn:oCell:lAdjBmp := lAdjBmp // 21 oColumn:oCell:lMultiline := lMulti // 22 oColumn:oCell:nVAlign := nVAlign // 23 oColumn:oCell:nVertText := nVertText // 24 oColumn:oCell:nClrTo := nClrTo // 25 oColumn:oCell:lOpaque := lOpaque // 26 oColumn:oCell:hBrush := iif( lBrush, nClrBack:hBrush, 0 ) // 27 oColumn:oCell:l3DText := l3DText // 28 3D text oColumn:oCell:nClr3dL := nClr3dL // 29 3D text light color oColumn:oCell:nClr3dS := nClr3dS // 30 3D text shadow color oColumn:oCell:nCursor := nCursor // 31 Rect cursor oColumn:oCell:lInvertColor := !(::lCellBrw .and. nJ != ::nCell) // 32 Invert color If lDrawCell .and. ::lDrawLine lDraw := ::TSDrawCell( oColumn:oCell, oColumn ) Else lDraw := .T. EndIf nStartCol += aColSizes[ nJ ] + nDeltaLen If lDraw AAdd( ::aDrawCols, nJ ) EndIf Next EndIf If ::bOnDraw != Nil Eval( ::bOnDraw, Self ) EndIf If ::lCellBrw cMsg := iif( ! Empty( ::AColumns[ ::nCell ]:cMsg ), ::AColumns[ ::nCell ]:cMsg, ::cMsg ) cMsg := iif( ValType( cMsg ) == "B", Eval( cMsg, Self, ::nCell ), cMsg ) If ! Empty( cMsg ) ::SetMsg( cMsg ) EndIf EndIf ::lDrawSelect := .F. Return Self
|