Files
harbour-core/harbour/tests/gfx.prg
Viktor Szakats 29a46a1302 2012-11-17 23:11 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/gtwvg/tests/_wvtcls.prg
  * contrib/gtwvg/tests/demowvg.prg
  * contrib/hbct/doc/en/dattime3.txt
  * contrib/hbct/tests/datetime.prg
  * contrib/hbnf/doc/en/acctadj.txt
  * contrib/hbnf/doc/en/acctmnth.txt
  * contrib/hbnf/doc/en/acctqtr.txt
  * contrib/hbnf/doc/en/acctweek.txt
  * contrib/hbnf/doc/en/acctyear.txt
  * contrib/hbnf/doc/en/dayofyr.txt
  * contrib/hbnf/doc/en/daytobow.txt
  * contrib/hbnf/doc/en/elapsed.txt
  * contrib/hbnf/doc/en/firstday.txt
  * contrib/hbnf/doc/en/lastday.txt
  * contrib/hbnf/doc/en/madd.txt
  * contrib/hbnf/doc/en/month.txt
  * contrib/hbnf/doc/en/qtr.txt
  * contrib/hbnf/doc/en/savearr.txt
  * contrib/hbnf/doc/en/setdate.txt
  * contrib/hbnf/doc/en/wda.txt
  * contrib/hbnf/doc/en/week.txt
  * contrib/hbnf/doc/en/workdays.txt
  * contrib/hbnf/doc/en/woy.txt
  * contrib/hbnf/doc/en/year.txt
  * contrib/hbnf/tests/elapsed.prg
  * contrib/hbnf/tests/savearr.prg
  * contrib/hbnf/tests/setdate.prg
  * contrib/hbnf/tests/wda.prg
  * contrib/hbnf/tests/workdays.prg
  * contrib/hbnf/tests/woy.prg
  * contrib/hbpgsql/tests/dbf2pg.prg
  * contrib/hbsqlit3/hdbcsqlt.prg
  * contrib/rddsql/tests/arrayrdd.prg
  * doc/en/datetime.txt
  * doc/en/math.txt
  * doc/en/string.txt
  * doc/hdr_tpl.txt
  * extras/gtwvw/tests/ebtest7.prg
  * extras/gtwvw/tests/wvwtest9.prg
  * extras/guestbk/inifiles.prg
  * extras/hbvpdf/core.prg
  * extras/httpsrv/cgifunc.prg
  * tests/array16.prg
  * tests/bldtest/bldtest.c
  * tests/byref.prg
  * tests/dates.prg
  * tests/gfx.prg
  * tests/inifiles.prg
  * tests/initexit.prg
  * tests/longdev.prg
  * tests/parseini.ini
  * tests/parseini.prg
  * tests/usrrdd/exarr.prg
  * website/samples/byref.prg.html
  * website/samples/initexit.prg.html
  * website/samples/longdev.prg.html
  * website/samples/mousetst.prg.html
  * website/samples/parseini.ini.html
  * website/samples/parseini.prg.html
    * various cleanups
2012-11-17 22:20:13 +00:00

108 lines
3.2 KiB
Plaintext

/*
* $Id$
*/
#include "hbgtinfo.ch"
#include "hbgfx.ch"
PROCEDURE Main()
LOCAL nFontHeight, nFontWidth
LOCAL nTop, nLeft, nHeight, nWidth, nColor, nSec := Seconds()
LOCAL cWelcome
#if defined( __HBSCRIPT__HBSHELL )
# if defined( __PLATFORM__WINDOWS )
hbshell_gtSelect( "GTWVT" )
# elif defined( __PLATFORM__UNIX )
hbshell_gtSelect( "GTXWC" )
# endif
#endif
IF ! hb_gtInfo( HB_GTI_ISGRAPHIC )
? "You are using a non graphics capable gt:"
? hb_gtVersion()
QUIT
ENDIF
IF hb_gtInfo( HB_GTI_DESKTOPWIDTH ) > 1000
hb_gtInfo( HB_GTI_FONTWIDTH, 12 )
hb_gtInfo( HB_GTI_FONTSIZE, 24 )
ENDIF
nFontHeight := hb_gtInfo( HB_GTI_FONTSIZE )
nFontWidth := hb_gtInfo( HB_GTI_FONTWIDTH )
cWelcome := "Welcome to the World of Harbour multiplatform Graphics!" + " (" + hb_gtVersion( 0 ) + ")"
SetColor( "n/w" )
@ 0, 0 SAY Space( MaxCol() + 1 )
@ 1, 0 SAY PadC( cWelcome, MaxCol() + 1 )
@ 2, 0 SAY Space( MaxCol() + 1 )
hb_gtInfo( HB_GTI_WINTITLE, "Cross-GT, multiplatform graphics demo" )
PutFrame( nFontHeight / 2, ;
MaxCol() / 2 * nFontWidth - Len( cWelcome ) / 2 * nFontWidth - nFontWidth, ;
nFontHeight * 2 + nFontHeight / 2, ;
nFontWidth + MaxCol() / 2 * nFontWidth + Len( cWelcome ) / 2 * nFontWidth, ;
hb_gfxMakeColor( 0, 0, 0 ), hb_gfxMakeColor( 255, 255, 255 ) )
DO WHILE Inkey() == 0
nTop := Int( hb_Random( 3.1 * nFontHeight, hb_gtInfo( HB_GTI_SCREENHEIGHT ) ) )
nLeft := Int( hb_Random( hb_gtInfo( HB_GTI_SCREENWIDTH ) ) )
nHeight := Int( hb_Random( 251 ) )
nWidth := Int( hb_Random( 251 ) )
nColor := hb_gfxMakeColor( Int( hb_Random( 32, 256 ) ), Int( hb_Random( 32, 256 ) ), Int( hb_Random( 32, 256 ) ) )
SWITCH Int( hb_Random( 1, 9 ) )
CASE 1
hb_gfxLine( nTop, nLeft, nTop + nHeight, nLeft + nWidth, nColor )
EXIT
CASE 2
hb_gfxRect( nTop, nLeft, nTop + nHeight, nLeft + nWidth, nColor )
EXIT
CASE 3
hb_gfxFilledRect( nTop, nLeft, nTop + nHeight, nLeft + nWidth, nColor )
EXIT
CASE 4
nTop += nHeight
hb_gfxCircle( nTop, nLeft, nHeight, nColor )
EXIT
CASE 5
nTop += nHeight
hb_gfxFilledCircle( nTop, nLeft, nHeight, nColor )
EXIT
CASE 6
nTop += nHeight
hb_gfxEllipse( nTop, nLeft, nHeight, nWidth, nColor )
EXIT
CASE 7
nTop += nHeight
hb_gfxFilledEllipse( nTop, nLeft, nHeight, nWidth, nColor )
EXIT
CASE 8
nHeight %= 64
IF nHeight % 2 == 1
nHeight++
ENDIF
hb_gfxText( nTop, nLeft, "Hello", nColor, nHeight )
EXIT
ENDSWITCH
IF Seconds() - nSec > 3
hb_gfxFloodFill( 0, 0, nColor )
nSec := Seconds()
ENDIF
ENDDO
RETURN
FUNCTION PutFrame( nTop, nLeft, nBottom, nRight, nColor1, nColor2 )
hb_gfxRect( nTop, nLeft, nBottom, nRight, nColor1 )
hb_gfxRect( nTop + 1, nLeft + 1, nBottom - 1, nRight - 1, nColor2 )
hb_gfxLine( nTop + 1, nLeft + 1, nTop + 1, nRight - 1, nColor2 )
hb_gfxLine( nTop + 2, nLeft + 1, nBottom - 1, nLeft + 1, nColor2 )
RETURN NIL