Files
harbour-core/harbour/tests/testbrw.prg
Viktor Szakats fca19513ca 2012-10-01 19:13 UTC+0200 Viktor Szakats (harbour syenar.net)
* include/harbour.hbx
  * src/rtl/Makefile
  + src/rtl/cdpbox.prg
    + added HB_UTF8TOSTRBOX( <cUTF8String> ) -> <cStringEncodedIn_GT_BOXCP>
      It's needed because HB_UTF8TOSTR() will convert to main CP,
      but box drawing CP can be setup differently with HB_GTI_BOXCP,
      that function call will take that into account.

  * contrib/hbnf/aredit.prg
  * contrib/hbnf/clrsel.prg
  * contrib/hbnf/dispmsg.prg
  * contrib/hbnf/menu1.prg
  * contrib/hbnf/pegs.prg
  * contrib/hbnf/pickday.prg
  * contrib/hbnf/popadder.prg
  * contrib/hbnf/tbwhile.prg
  * contrib/hbnf/vertmenu.prg
  * tests/db_brows.prg
  * tests/gtchars.prg
  * tests/testbrw.prg
  * extras/gtwvw/tests/prog0.prg
  * extras/gtwvw/tests/prog1.prg
  * extras/gtwvw/tests/prog2.prg
    ! fixed drawing chars to display properly regardless of HB_GTI_BOXCP
      setting.
    ! some related minor fixes

  * tests/tb1.prg
    ! fixed to compile and build using Clipper after recent 
      UTF8 compatibility updates (not tested though)

  ; TOFIX: Pad*() function handle 3rd parameter as binary string,
           so it doesn't work properly in UTF8 mode.
2012-10-01 17:15:48 +00:00

158 lines
3.8 KiB
Plaintext

/*
* $Id$
*/
/* UTF-8 */
// Harbour Class TBrowse and TBColumn sample
#include "inkey.ch"
PROCEDURE Main()
LOCAL oBrowse := TBRowseNew( 5, 5, 16, 30 )
LOCAL aTest0 := { "This", "is", "a", "browse", "on", "an", "array", "test", "with", "a", "long", "data" }
LOCAL aTest1 := { 1, 2, 3, 4, 5, 6, 7, 8, 10000, - 1000, 54, 456342 }
LOCAL aTest2 := { Date(), Date() + 4, Date() + 56, Date() + 14, Date() + 5, Date() + 6, Date() + 7, Date() + 8, Date() + 10000, Date() - 1000, Date() - 54, Date() + 456342 }
LOCAL aTest3 := { .T. , .F. , .T. , .T. , .F. , .F. , .T. , .F. , .T. , .T. , .F. , .F. }
LOCAL n := 1
LOCAL nCursor
LOCAL cColor
LOCAL nRow, nCol
#ifndef HB_COMPAT_C53
LOCAL nKey
LOCAL nTmpRow, nTmpCol
LOCAL lEnd := .F.
#endif
oBrowse:colorSpec := "W+/B, N/BG"
oBrowse:ColSep := hb_UTF8ToStrBox( "│" )
oBrowse:HeadSep := hb_UTF8ToStrBox( "╤═" )
oBrowse:FootSep := hb_UTF8ToStrBox( "╧═" )
oBrowse:GoTopBlock := {|| n := 1 }
oBrowse:GoBottomBlock := {|| n := Len( aTest0 ) }
oBrowse:SkipBlock := {| nSkip, nPos | nPos := n, ;
n := iif( nSkip > 0, Min( Len( aTest0 ), n + nSkip ), ;
Max( 1, n + nSkip ) ), n - nPos }
oBrowse:AddColumn( TBColumnNew( "First", {|| n } ) )
oBrowse:AddColumn( TBColumnNew( "Second", {|| aTest0[ n ] } ) )
oBrowse:AddColumn( TBColumnNew( "Third", {|| aTest1[ n ] } ) )
oBrowse:AddColumn( TBColumnNew( "Forth", {|| aTest2[ n ] } ) )
oBrowse:AddColumn( TBColumnNew( "Fifth", {|| aTest3[ n ] } ) )
oBrowse:GetColumn( 1 ):Footing := "Number"
oBrowse:GetColumn( 2 ):Footing := "Strins"
oBrowse:GetColumn( 2 ):Picture := "@!"
oBrowse:GetColumn( 3 ):Footing := "Number"
oBrowse:GetColumn( 3 ):Picture := "999,999.99"
oBrowse:GetColumn( 4 ):Footing := "Dates"
oBrowse:GetColumn( 5 ):Footing := "Logical"
// needed since I've changed some columns _after_ I've added them to TBrowse object
oBrowse:Configure()
Alert( oBrowse:ClassName() )
Alert( oBrowse:GetColumn( 1 ):ClassName() )
oBrowse:Freeze := 1
nCursor := SetCursor( 0 )
cColor := SetColor( "W+/B" )
nRow := Row()
nCol := Col()
@ 4, 4, 17, 31 BOX hb_UTF8ToStrBox( "┌─┐│┘─└│ " )
#ifdef HB_COMPAT_C53
oBrowse:SetKey( 0, {| ob, nkey | Defproc( ob, nKey ) } )
WHILE .T.
oBrowse:ForceStable()
IF oBrowse:applykey( Inkey( 0 ) ) == -1
EXIT
ENDIF
ENDDO
#else
WHILE !lEnd
oBrowse:ForceStable()
nKey := Inkey( 0 )
DO CASE
CASE nKey == K_ESC
SetPos( 17, 0 )
lEnd := .T.
CASE nKey == K_DOWN
oBrowse:Down()
CASE nKey == K_UP
oBrowse:Up()
CASE nKey == K_LEFT
oBrowse:Left()
CASE nKey == K_RIGHT
oBrowse:Right()
CASE nKey == K_PGDN
oBrowse:pageDown()
CASE nKey == K_PGUP
oBrowse:pageUp()
CASE nKey == K_CTRL_PGUP
oBrowse:goTop()
CASE nKey == K_CTRL_PGDN
oBrowse:goBottom()
CASE nKey == K_HOME
oBrowse:home()
CASE nKey == K_END
oBrowse:end()
CASE nKey == K_CTRL_LEFT
oBrowse:panLeft()
CASE nKey == K_CTRL_RIGHT
oBrowse:panRight()
CASE nKey == K_CTRL_HOME
oBrowse:panHome()
CASE nKey == K_CTRL_END
oBrowse:panEnd()
CASE nKey == K_TAB
nTmpRow := Row()
nTmpCol := Col()
@ 0, 0 SAY Time()
DevPos( nTmpRow, nTmpCol )
ENDCASE
end
#endif
DevPos( nRow, nCol )
SetColor( cColor )
SetCursor( nCursor )
RETURN
#ifdef HB_COMPAT_C53
FUNCTION defproc( ob, nkey )
LOCAL nTmpRow, nTmpCol
IF nKey == K_TAB
nTmpRow := Row()
nTmpCol := Col()
@ 0, 0 SAY Time()
DevPos( nTmpRow, nTmpCol )
ob:Refreshall()
ENDIF
RETURN 1
#endif