home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C!T ROM 2
/
ctrom_ii_b.zip
/
ctrom_ii_b
/
PROGRAM
/
CLIPPER
/
TBR62
/
TBR62.PRG
Wrap
Text File
|
1993-01-28
|
4KB
|
148 lines
/*
Every time a user ask for color based in conditions (like DELETED())
you should tell them to use column:colorBlock. The codeblock should
return an array with two values (selected and unselected colors).
Also, keep in mind that colorBlock receives an argument from TBrowse,
like in:
{ |x| IF(x == Something, { 1, 4}, {5, 7}) }
That was not included below since you need only the DELETED() status,
but can be useful for things like:
column := TBColumnNew( "Something", FIELDBLOCK( SomeField ) )
column:colorBlock := { |p| IF( "Smith" $ p, {3, 5}, {1, 2}) }
browse:addColumn(column)
*/
/*****
*
* TBR62.PRG
*
* Luiz F. Quintela
* Copyright (c) 1991 Nantucket Corporation.
* All Rights Reserved.
*
* Clipper tbr62 /N /W
* RTLINK FILE tbr62
*
*/
#include "inkey.ch"
#include "setcurs.ch"
#define COLSEP CHR(32) + CHR(179) + CHR(32)
#define HEADSEP CHR(205) + CHR(209) + CHR(205)
#define FOOTSEP CHR(205) + CHR(207) + CHR(205)
#define MYCOLORS "W+/BG,N/W,W/N,N," +;
"GR+/W,N/BG,B+/BG,GR+/BG"
FUNCTION Main()
LOCAL b, column, nKey
SET(_SET_SCOREBOARD, .F.)
SET(_SET_CONFIRM, .T.)
READEXIT(.T.)
USE test INDEX test3,test7 NEW
DISPBEGIN()
SETCURSOR(SC_NONE)
SETCOLOR("N/W")
SCROLL()
@ 2, 6 TO 22,72 COLOR "W+/BG"
@ MAXROW(), 0 SAY ;
PADR("ESC - Quit",;
MAXCOL() + 1) COLOR "W+/RB"
DISPEND()
b := TBrowseDB( 3, 7, 21, 71 )
b:colorSpec := MYCOLORS
b:colSep := COLSEP
b:headSep := HEADSEP
// Columns
column := TBColumnNew( "Field 3", FIELDBLOCK("fld3") )
column:colorBlock := {|| IF(DELETED(),;
{8, 2}, {1, 2}) }
b:addColumn( column )
column := TBColumnNew( "Field 7", FIELDBLOCK("fld7") )
column:colorBlock := {|| IF(DELETED(),;
{8, 2}, {1, 2}) }
b:addColumn( column )
column := TBColumnNew( "Field 4", FIELDBLOCK("fld4") )
column:colorBlock := {|| IF(DELETED(),;
{8, 2}, {1, 2}) }
b:addColumn( column )
WHILE .T.
ForceStable( b )
IF ( b:hitTop .OR. b:hitBottom )
TONE(87.3,1)
TONE(40,3.5)
ENDIF
nKey := INKEY(0)
IF !TBMoveCursor( b, nKey )
IF ( nKey == K_ESC )
SCROLL()
EXIT
ENDIF
ENDIF
END
RETURN (NIL)
/*****
*
* Forces stabilization
*
*/
STATIC FUNCTION ForceStable( obj )
DISPBEGIN()
WHILE !obj:stabilize()
END
DISPEND()
RETURN (NIL)
/*****
*
* Cursor Movement Methods
*
*/
STATIC FUNCTION TBMoveCursor( o, nKey )
LOCAL nFound
STATIC aKeys := ;
{ K_DOWN , {|obj| obj:down()},;
K_UP , {|obj| obj:up()},;
K_PGDN , {|obj| obj:pageDown()},;
K_PGUP , {|obj| obj:pageUp()},;
K_CTRL_PGUP , {|obj| obj:goTop()},;
K_CTRL_PGDN , {|obj| obj:goBottom()},;
K_RIGHT , {|obj| obj:right()},;
K_LEFT , {|obj| obj:left()},;
K_HOME , {|obj| obj:home()},;
K_END , {|obj| obj:end()},;
K_CTRL_LEFT , {|obj| obj:panLeft()},;
K_CTRL_RIGHT, {|obj| obj:panRight()},;
K_CTRL_HOME , {|obj| obj:panHome()},;
K_CTRL_END , {|obj| obj:panEnd()} }
nFound := ASCAN( aKeys, nKey )
IF (nFound != 0)
EVAL( aKeys[++nFound], o )
ENDIF
RETURN (nFound != 0)
// EOF - TBR62.PRG //