* contrib/hbnf/acctmnth.prg
* contrib/hbnf/acctqtr.prg
* contrib/hbnf/acctweek.prg
* contrib/hbnf/aemaxlen.prg
* contrib/hbnf/aeminlen.prg
* contrib/hbnf/aredit.prg
* contrib/hbnf/clrsel.prg
* contrib/hbnf/dayofyr.prg
* contrib/hbnf/elapsed.prg
* contrib/hbnf/month.prg
* contrib/hbnf/qtr.prg
* contrib/hbnf/tbwhile.prg
* contrib/hbnf/week.prg
* contrib/hbnf/xbox.prg
% optimizations (cleaned constructs, opt out variables,
use SWITCH)
! FT_AEMINLEN() fixed to return proper length for strings
larger than Clipper's maximum.
* use K_ENTER instead of K_RETURN
(to use uniformly K_ENTER in repo)
* contrib/hbnf/popadder.prg
* use hb_keyCode() instead of hardwired key numbers
* contrib/hbmisc/hbedit.prg
* contrib/hbmysql/tsqlbrw.prg
* contrib/xhb/xhbtedit.prg
* src/rtl/teditor.prg
* tests/ac_test.prg
* tests/ac_test2.prg
* tests/sbartest.prg
* use K_ENTER instead of K_RETURN
(to use uniformly K_ENTER in repo)
* contrib/hbnf/tests/datecnfg.prg
! use a non-current date for better testing
* use simpleio.ch
* contrib/hbnf/aavg.prg
* contrib/hbnf/adessort.prg
* contrib/hbnf/anomatch.prg
* contrib/hbnf/any2any.prg
* contrib/hbnf/asum.prg
* formatting
122 lines
2.7 KiB
Plaintext
122 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
|
|
|
|
LOCAL aFileList := {}
|
|
LOCAL 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, , {| modo | updateFilesScroll( modo, aFileList, filesScroll ) } )
|
|
|
|
@ 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, aFileList, filesScroll )
|
|
|
|
LOCAL newPos, valRet := AC_CONT // Default to continue
|
|
LOCAL nLastKey := LastKey()
|
|
|
|
newPos := filesScroll:current
|
|
|
|
DO CASE
|
|
CASE nLastKey == K_CTRL_PGUP
|
|
newPos := 1
|
|
CASE nLastKey == K_CTRL_PGDN
|
|
newPos := filesScroll:total
|
|
CASE nLastKey == K_CTRL_HOME
|
|
newPos := newPos - ( filesScroll:barLength + 1 )
|
|
CASE nLastKey == K_CTRL_END
|
|
newPos := newPos + ( filesScroll:barLength + 1 )
|
|
CASE nLastKey == K_PGUP
|
|
newPos := newPos - ( filesScroll:barLength + 1 )
|
|
CASE nLastKey == K_PGDN
|
|
newPos := newPos + ( filesScroll:barLength + 1 )
|
|
CASE nLastKey == K_UP
|
|
newPos--
|
|
CASE nLastKey == K_DOWN
|
|
newPos++
|
|
CASE modo == AC_EXCEPT
|
|
DO CASE
|
|
CASE nLastKey == K_ENTER
|
|
valRet := AC_SELECT
|
|
CASE nLastKey == 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
|