From e80799c8421e6aecf6907c58eee97c91c96b2f45 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Fri, 21 Aug 2009 01:56:35 +0000 Subject: [PATCH] 2009-08-20 18:55 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbxbp/xbpbrowse.prg ! Synchronized horizontal navigation with respect to frozen columns. --- harbour/ChangeLog | 4 + harbour/contrib/hbxbp/xbpbrowse.prg | 158 ++++++++++++++++++---------- 2 files changed, 109 insertions(+), 53 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 3eff067eda..43dafc92be 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,10 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-08-20 18:55 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbxbp/xbpbrowse.prg + ! Synchronized horizontal navigation with respect to frozen columns. + 2009-08-20 18:08 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * contrib/hbxbp/xbpbrowse.prg + Implemented ::setLeftFrozen( aColumns ) and ::setRightFrozen( aColumns ) diff --git a/harbour/contrib/hbxbp/xbpbrowse.prg b/harbour/contrib/hbxbp/xbpbrowse.prg index ec1beec0a5..e3ed32fcf9 100644 --- a/harbour/contrib/hbxbp/xbpbrowse.prg +++ b/harbour/contrib/hbxbp/xbpbrowse.prg @@ -150,6 +150,8 @@ #define _TBR_COORD( n ) Int( n ) +#define ISFROZEN( n ) ( ascan( ::aLeftFrozen, n ) > 0 .OR. ascan( ::aRightFrozen, n ) > 0 ) + /*----------------------------------------------------------------------*/ CREATE CLASS XbpBrowse INHERIT XbpWindow @@ -1605,7 +1607,7 @@ METHOD doConfigure() CLASS XbpBrowse ENDIF FOR i := 1 TO ::colCount - IF ascan( ::aLeftFrozen, i ) > 0 .or. ascan( ::aRightFrozen, i ) > 0 + IF ISFROZEN( i ) ::oTableView:hideColumn( i - 1 ) ::oFooterView:setSectionHidden( i - 1, .t. ) ELSE @@ -2210,10 +2212,22 @@ METHOD goBottom() CLASS XbpBrowse /*----------------------------------------------------------------------*/ METHOD left() CLASS XbpBrowse - LOCAL n + LOCAL n, nCol + LOCAL lUpdate := .f. + + nCol := ::colPos + + IF nCol > 1 + DO WHILE --nCol >= 1 + IF !ISFROZEN( nCol ) + lUpdate := .t. + EXIT + ENDIF + ENDDO + ENDIF + IF lUpdate + ::colPos := nCol - IF ::colPos > 1 - ::colPos-- n := ::oHeaderView:sectionViewportPosition( ::colPos-1 ) IF n < 0 ::oHeaderView:setOffset( ::oHeaderView:offSet() + n ) @@ -2222,86 +2236,124 @@ METHOD left() CLASS XbpBrowse ELSE ::setCurrentIndex( .f. ) ENDIF + + ::oHScrollBar:setValue( ::colPos - 1 ) ENDIF - ::oHScrollBar:setValue( ::colPos - 1 ) RETURN Self /*----------------------------------------------------------------------*/ METHOD right() CLASS XbpBrowse - LOCAL n, n1, n2, nLnWidth + LOCAL n, n1, n2, nLnWidth, nCol + LOCAL lUpdate := .f. IF ::colPos < ::colCount - ::colPos++ - - n := ::oHeaderView:sectionViewportPosition( ::colPos - 1 ) - n1 := ::oHeaderView:sectionSize( ::colPos-1 ) - n2 := ::oViewport:width() - IF n + n1 > n2 - nLnWidth := ::oTableView:lineWidth() - IF n1 > n2 - ::oHeaderView:setOffset( ::oHeaderView:sectionPosition( ::colPos - 1 ) ) - ::oFooterView:setOffset( ::oHeaderView:sectionPosition( ::colPos - 1 ) ) - - ELSE - ::oHeaderView:setOffset( ::oHeaderView:offSet()+(n1-(n2-n)+1) - nLnWidth ) - ::oFooterView:setOffset( ::oFooterView:offSet()+(n1-(n2-n)+1) - nLnWidth ) + nCol := ::colPos + DO WHILE ++nCol <= ::colCount + IF !( ISFROZEN( nCol ) ) + lUpdate := .t. + EXIT ENDIF - ::setCurrentIndex( .t. ) - ELSE - ::setCurrentIndex( .f. ) + ENDDO + + IF lUpdate + ::colPos := nCol + + n := ::oHeaderView:sectionViewportPosition( ::colPos - 1 ) + n1 := ::oHeaderView:sectionSize( ::colPos-1 ) + n2 := ::oViewport:width() + IF n + n1 > n2 + nLnWidth := ::oTableView:lineWidth() + IF n1 > n2 + ::oHeaderView:setOffset( ::oHeaderView:sectionPosition( ::colPos - 1 ) ) + ::oFooterView:setOffset( ::oHeaderView:sectionPosition( ::colPos - 1 ) ) + + ELSE + ::oHeaderView:setOffset( ::oHeaderView:offSet()+(n1-(n2-n)+1) - nLnWidth ) + ::oFooterView:setOffset( ::oFooterView:offSet()+(n1-(n2-n)+1) - nLnWidth ) + + ENDIF + ::setCurrentIndex( .t. ) + ELSE + ::setCurrentIndex( .f. ) + ENDIF + + ::oHScrollBar:setValue( ::colPos - 1 ) ENDIF ENDIF - ::oHScrollBar:setValue( ::colPos - 1 ) + RETURN Self /*----------------------------------------------------------------------*/ METHOD firstCol() CLASS XbpBrowse - LOCAL n + LOCAL n, nCol + LOCAL lUpdate := .f. - ::setUnstable() - ::colPos := 1 + nCol := 0 - n := ::oHeaderView:sectionViewportPosition( ::colPos-1 ) - IF n < 0 - ::oHeaderView:setOffset( ::oHeaderView:offSet() + n ) - ::oFooterView:setOffset( ::oFooterView:offSet() + n ) - ::setCurrentIndex( .t. ) - ELSE - ::setCurrentIndex( .f. ) + DO WHILE ++nCol <= ::colCount + IF !ISFROZEN( nCol ) + lUpdate := .t. + EXIT + ENDIF + ENDDO + + IF lUpdate + ::setUnstable() + ::colPos := nCol + + n := ::oHeaderView:sectionViewportPosition( ::colPos-1 ) + IF n < 0 + ::oHeaderView:setOffset( ::oHeaderView:offSet() + n ) + ::oFooterView:setOffset( ::oFooterView:offSet() + n ) + ::setCurrentIndex( .t. ) + ELSE + ::setCurrentIndex( .f. ) + ENDIF + ::oHScrollBar:setValue( ::colPos - 1 ) ENDIF - ::oHScrollBar:setValue( ::colPos - 1 ) - RETURN Self /*----------------------------------------------------------------------*/ METHOD lastCol() CLASS XbpBrowse - LOCAL n, n1, n2 + LOCAL n, n1, n2, nCol + LOCAL lUpdate := .f. - ::setUnstable() - ::colPos := ::colCount + nCol := ::colCount + 1 - n := ::oHeaderView:sectionViewportPosition( ::colPos-1 ) - n1 := ::oHeaderView:sectionSize( ::colPos-1 ) - n2 := ::oViewport:width() - IF n + n1 > n2 - IF n1 > n2 - ::oHeaderView:setOffset( ::oHeaderView:sectionPosition( ::colPos - 1 ) ) - ::oFooterView:setOffset( ::oHeaderView:sectionPosition( ::colPos - 1 ) ) - ELSE - ::oHeaderView:setOffset( ::oHeaderView:offSet()+(n1-(n2-n)+1) - ::oTableView:lineWidth() ) - ::oFooterView:setOffset( ::oFooterView:offSet()+(n1-(n2-n)+1) - ::oTableView:lineWidth() ) + DO WHILE --nCol >= 1 + IF !ISFROZEN( nCol ) + lUpdate := .t. + EXIT ENDIF - ::setCurrentIndex( .t. ) - ELSE - ::setCurrentIndex( .f. ) + ENDDO + + IF lUpdate + ::setUnstable() + ::colPos := nCol + + n := ::oHeaderView:sectionViewportPosition( ::colPos-1 ) + n1 := ::oHeaderView:sectionSize( ::colPos-1 ) + n2 := ::oViewport:width() + IF n + n1 > n2 + IF n1 > n2 + ::oHeaderView:setOffset( ::oHeaderView:sectionPosition( ::colPos - 1 ) ) + ::oFooterView:setOffset( ::oHeaderView:sectionPosition( ::colPos - 1 ) ) + ELSE + ::oHeaderView:setOffset( ::oHeaderView:offSet()+(n1-(n2-n)+1) - ::oTableView:lineWidth() ) + ::oFooterView:setOffset( ::oFooterView:offSet()+(n1-(n2-n)+1) - ::oTableView:lineWidth() ) + ENDIF + ::setCurrentIndex( .t. ) + ELSE + ::setCurrentIndex( .f. ) + ENDIF + ::oHScrollBar:setValue( ::colPos - 1 ) ENDIF - ::oHScrollBar:setValue( ::colPos - 1 ) RETURN Self