From 069980257ba8c9ba8b546a241e7c339a2b72e77c Mon Sep 17 00:00:00 2001 From: Antonio Linares Date: Sat, 7 Aug 1999 11:05:59 +0000 Subject: [PATCH] *** empty log message *** --- harbour/ChangeLog | 8 ++++++++ harbour/source/rtl/tbcolumn.prg | 1 + harbour/source/rtl/tbrowse.prg | 26 +++++++++++++++++++++++++- harbour/tests/working/testbrw.prg | 17 +++++++++++++++-- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 66de95b595..d986539484 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,11 @@ +19990807-12:54 GMT+1 Antonio Linares + * source/rtl/tbrowse.prg + * improved + * source/rtl/tbcolumn.prg + * improved + * tests/working/TestBrw.prg + * improved + 19990807-11:37 GMT+1 Antonio Linares * source/rtl/tbrowse.prg * Some methods added diff --git a/harbour/source/rtl/tbcolumn.prg b/harbour/source/rtl/tbcolumn.prg index 1e2fdd3d4a..9b818895e2 100644 --- a/harbour/source/rtl/tbcolumn.prg +++ b/harbour/source/rtl/tbcolumn.prg @@ -51,6 +51,7 @@ function TBColumnNew( cHeading, bBlock ) oCol:Heading = cHeading oCol:block = bBlock + oCol:Width = If( cHeading != nil, Len( cHeading ), 10 ) return oCol diff --git a/harbour/source/rtl/tbrowse.prg b/harbour/source/rtl/tbrowse.prg index 13e1b1fe23..619014ddb8 100644 --- a/harbour/source/rtl/tbrowse.prg +++ b/harbour/source/rtl/tbrowse.prg @@ -46,6 +46,7 @@ CLASS TBrowse DATA rowPos // Current cursor row position DATA skipBlock // Code block used to reposition data source DATA stable // Indicates if the TBrowse object is stable + DATA StabLevel // Stabilize() progressive level METHOD New() // Constructor METHOD Down() VIRTUAL // Moves the cursor down one row @@ -93,7 +94,7 @@ CLASS TBrowse METHOD SetColumn( nColumn, oCol ) INLINE If( 0 < nColumn .and. nColumn <= Len( ::aColumns ),; ::aColumns[ nColumn ] := oCol, nil ), oCol // Replaces one TBColumn object with another - METHOD Stabilize() VIRTUAL // Performs incremental stabilization + METHOD Stabilize() // Performs incremental stabilization ENDCLASS @@ -113,6 +114,7 @@ METHOD New() CLASS TBrowse ::ColSep = " " ::FootSep = "" ::HeadSep = "" + ::StabLevel = 0 return Self @@ -126,6 +128,28 @@ METHOD DelColumn( nPos ) CLASS TBrowse return oCol +METHOD Stabilize() CLASS TBrowse + + local n, lDisplay := .t. + + @ ::nTop, ::nLeft SAY PadC( ::aColumns[ 1 ]:Heading, ::nRight - ::nLeft ) ; + COLOR ::ColorSpec + + for n = 1 to ::nBottom - ::nTop + if lDisplay + @ ::nTop + n, ::nLeft SAY ; + PadC( SubStr( Eval( ::aColumns[ 1 ]:Block ), 1, ::aColumns[ 1 ]:Width ),; + ::nRight - ::nLeft ) ; + COLOR ::ColorSpec + else + @ ::nTop + n, ::nLeft SAY Space( ::nRight - ::nLeft ) ; + COLOR ::ColorSpec + endif + lDisplay = Eval( ::SkipBlock, 1 ) != 0 + next + +return .t. + function TBrowseNew( nTop, nLeft, nBottom, nRight ) local oBrw := TBrowse():New() diff --git a/harbour/tests/working/testbrw.prg b/harbour/tests/working/testbrw.prg index 5196db5747..d1cbbb9adb 100644 --- a/harbour/tests/working/testbrw.prg +++ b/harbour/tests/working/testbrw.prg @@ -2,11 +2,24 @@ function Main() - local oBrowse := TBrowse():New() + local oBrowse := TBrowseNew( 5, 5, 15, 30 ) + local aTest := { "This", "is", "a", "browse", "on", "an", "array", "test" } + local n := 1 - oBrowse:AddColumn( TBColumnNew( "Test", { || "This is a test" } ) ) + oBrowse:colorSpec = "W+/B, N/BG" + oBrowse:GoTopBlock = { || n := 1 } + oBrowse:GoBottomBlock = { || n := Len( aTest ) } + oBrowse:SkipBlock = { | nSkip, nPos | nPos := n,; + n := If( nSkip > 0, Min( Len( aTest ), n + nSkip ),; + Max( 1, n + nSkip )), n - nPos } + + oBrowse:AddColumn( TBColumnNew( "Test", { || aTest[ n ] } ) ) Alert( oBrowse:ClassName() ) Alert( oBrowse:GetColumn( 1 ):ClassName() ) + while ! oBrowse:Stabilize() + InKey( 0 ) + end + return nil