Files
harbour-core/harbour/tests/sbartest.prg
Viktor Szakats 23f154863e 2012-10-15 00:37 UTC+0200 Viktor Szakats (harbour syenar.net)
+ contrib/hbnf/tests/fttext.prg
    + added test code for FTTEXT API

  * contrib/hbnf/fttext.c
    + added MT compatibility by moving static vars to a structure 
      and that structure to TSD

  * contrib/hbnf/menutonf.prg
    * use HB_KEYPUT() instead of FT_PUTKEY()

  * extras/gtwvw/tests/cbtest1.prg
  * extras/gtwvw/tests/cbtest6.prg
  * extras/gtwvw/tests/inpfocus.prg
  * extras/gtwvw/tests/wvwmouse.prg
    * KEYBOARD/__KEYBOARD() -> hb_keyPut()

  * extras/gtwvw/tests/inpfocus.prg
    ! Do not use K_* constants for characters.

  * contrib/gtwvg/tests/demowvg.prg
  * extras/gtwvw/tests/wvwtest9.prg
    * minor code cleanup

  * contrib/gtwvg/class.prg
  * contrib/gtwvg/menubar.prg
  * contrib/gtwvg/paint.prg
  * contrib/hbct/fcopy.prg
  * contrib/hbcups/tests/test.prg
  * contrib/hbcurl/tests/ftp_uldl.prg
  * contrib/hbmisc/hb_f.c
  * contrib/hbmisc/tests/testhbf.prg
  * contrib/hbmysql/utils/dbf2mysq.prg
  * contrib/hbnf/amedian.prg
  * contrib/hbnf/tests/dfile.prg
  * contrib/hbpgsql/tests/dbf2pg.prg
  * contrib/hbpgsql/tests/test.prg
  * contrib/hbtip/tests/upld_ftp.prg
  * contrib/hbwin/tests/testcopy.prg
  * contrib/hbwin/tests/testmapi.prg
  * contrib/xhb/tests/testcp.prg
  * contrib/xhb/xhbtedit.prg
  * tests/ac_test.prg
  * tests/db_brows.prg
  * tests/stripem.prg
  * tests/testhtml.prg
    * deleted references to self-filename, or replaced them
      with __FILE__, so they will continue to work (and there
      won't be outdated comments) when files are renamed.

  * tests/sbartest.prg
    * minor
2012-10-14 22:44:32 +00:00

123 lines
2.7 KiB
Plaintext

/*
* $Id$
*/
/*
* ScrollBar class test
*
* Harbour Project source code
* http://harbour-project.org/
*
* Example donated by Diego Pego,
* modified by Alejandro de Garate
*/
/* UTF-8 */
#include "directry.ch"
#include "achoice.ch"
#include "inkey.ch"
#ifdef __HARBOUR__
#define B_THIN hb_UTF8ToStrBox( "█▀███▄██" )
#else
#define B_THIN ( Chr( 219 ) + Chr( 223 ) + Chr( 219 ) + Chr( 219 ) + ;
Chr( 219 ) + Chr( 220 ) + Chr( 219 ) + Chr( 219 ) )
#endif
PROCEDURE Main()
InitScrlBar()
RETURN
FUNCTION InitScrlBar()
LOCAL tmpFileList, i
MEMVAR aFileList, filesScroll
PRIVATE aFileList := {}, filesScroll
CLS
SetBlink( .F. )
#ifdef __HARBOUR__
@ 0, 0, 24, 79 BOX Replicate( hb_UTF8ToStrBox( "▓" ), 9 ) COLOR "GR+/W*"
#else
@ 0, 0, 24, 79 BOX Replicate( Chr( 178 ), 9 ) COLOR "GR+/W*"
#endif
@ 4, 28 SAY " Directory " COLOR "W+/B"
@ 5, 28, 15, 60 BOX B_THIN + " " COLOR "W/W*"
// get the current folder files to display on the aChoice menu
tmpFileList := Directory()
FOR i := 1 TO Len( tmpFileList )
AAdd( aFileList, tmpFileList[ i ][ F_NAME ] )
NEXT
filesScroll := ScrollBar( 06, 14, 60, NIL, 1 )
filesScroll:total := Len( aFileList )
filesScroll:colorSpec := "W+/W, W+/W"
SET COLOR TO "N/W*, W+/B,,,W/N"
filesScroll:display()
i := AChoice( 06, 29, 14, 59, aFileList, , "updateFilesScroll" )
@ 23, 0 SAY iif( i < 1, "", aFileList[ i ] ) COLOR "N/W*"
SET COLOR TO
@ 24, 0
RETURN 0
// function used to update scrollbar
STATIC FUNCTION updateFilesScroll( modo )
LOCAL newPos, valRet := AC_CONT // Default to continue
LOCAL ultTecla := LastKey()
MEMVAR filesScroll
newPos := filesScroll:current
DO CASE
CASE ultTecla == K_CTRL_PGUP
newPos := 1
CASE ultTecla == K_CTRL_PGDN
newPos := filesScroll:total
CASE ultTecla == K_CTRL_HOME
newPos := newPos - ( filesScroll:barLength + 1 )
CASE ultTecla == K_CTRL_END
newPos := newPos + ( filesScroll:barLength + 1 )
CASE ultTecla == K_PGUP
newPos := newPos - ( filesScroll:barLength + 1 )
CASE ultTecla == K_PGDN
newPos := newPos + ( filesScroll:barLength + 1 )
CASE ultTecla == K_UP
newPos--
CASE ultTecla == K_DOWN
newPos++
CASE modo == AC_EXCEPT
DO CASE
CASE ultTecla == K_RETURN
valRet := AC_SELECT
CASE ultTecla == K_ESC
valRet := AC_ABORT
OTHERWISE
valRet := AC_GOTO
ENDCASE
ENDCASE
IF newPos < 1
newPos := 1
ELSEIF newPos >= filesScroll:total
newPos := filesScroll:total
ENDIF
filesScroll:current := newPos
filesScroll:update()
RETURN valRet