Files
harbour-core/harbour/tests/gfx.prg
Przemyslaw Czerpak c5ccfa9978 2006-03-01 14:30 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/htmllib/default.ch
    * fixed few wrong definitions - Ryszard, the definitions where wrong
      but Clipper PP seems to parse them.

  * harbour/contrib/rdd_ads/ads1.c
    * call AdsFlushFileBuffers() only when _SET_HARDCOMMIT is set (default)

  * harbour/include/Makefile
  + harbour/include/hbgfx.ch
  + harbour/include/hbgfxdef.ch
    + added hbgfx.ch, hbgfxdef.ch and missing tbrowse.ch

  * harbour/include/hbapigt.h
  * harbour/include/hbgtcore.h
  * harbour/source/rtl/gtapi.c
  * harbour/source/rtl/hbgtcore.c
    + added hb_gtGfxPrimitive(), hb_gtGfxText() - it's a work in progress
      now this functions works like in xHarbour allow to draw graphic
      objects in GTs which can do that (GTALLEG, GTXWC) but I plan to
      introduce some modifications in them.

  + harbour/tests/gfx.prg
    + added test program by Mauricio Abre (borrowed from xHarbour) which
      illustrates GFX usage

  * harbour/include/hbdefs.h
  * harbour/source/compiler/genc.c
  * harbour/source/compiler/harbour.c
  * harbour/source/vm/hvm.c
    * minor modification in some harbour func name and symbol scope
      definitions - I'd like to keep them in one place for easier
      manipulations in the future

  * harbour/source/compiler/harbour.y
  * harbour/source/pp/ppcore.c
  * harbour/source/pp/pplib.c
  * harbour/utils/hbpp/hbpp.c
    * clean a little bit recent modification it should resolve the
      problem with GPFs reported by users and some possible memory
      leaks when preprocessing/compilation process is interrupted.
      Ryszard I decided to always store copy of file name in open
      files structure - it can be used by compiler, preprocessor,
      PPLIB and HBPP and IMHO in all cases it should have valid
      and always initialized in the same way members for easier
      manipulation. In the future I'd like to clean the whole PP
      usage. I will need to keep all compiler and PP static variables
      in one structure pointed by pointer in thread local data or
      passed to called functions for MT support.

  * harbour/source/rtl/cdpapi.c
    * set 0 at the end of destination string in hb_cdpStrnToUTF8()

  * harbour/source/rtl/dateshb.c
    ! fixed possible GPF in CTOD when badly formated date is given

  * harbour/source/rtl/gtxwc/gtxwc.c
  * harbour/source/rtl/gtxwc/gtxwc.h
    * changed the selection code - now both PRIMARY and CLIPBOARD
      selections are set by Harbour. It should work with any programs
      which uses any of them but I'd like to remove one of this selections
      or give user a way to chose the preferred one. I can also add support
      for automatic setting/clearing/pasting PRIMARY selection by GTXWC
      with mouse and shift key. I'm waiting for opinions.
    + added basic support for GFX operations

  + harbour/source/rtl/gtalleg/Makefile
  + harbour/source/rtl/gtalleg/fixedth.sfc
  + harbour/source/rtl/gtalleg/gtalleg.c
  + harbour/source/rtl/gtalleg/ssf.c
  + harbour/source/rtl/gtalleg/ssf.h
    + added new GT by Mauricio Abre based on Allegro cross platform
      graphic libraries.
      Code borrowed from xHarbour and modified by my for new Harbour
      GT API.
2006-03-01 13:49:07 +00:00

102 lines
2.8 KiB
Plaintext

/*
* $Id$
*
*/
#include "hbgtinfo.ch"
#include "hbgfx.ch"
#define WELCOME "Welcome to the World of xHarbour multiplatform Graphics!"
Function Main
Local nScreenWidth, nFontHeight, nFontWidth
Local nTop, nLeft, nHeight, nWidth, nColor, nSec := Seconds()
If !hb_gtInfo(GTI_ISGRAPHIC)
?
? "You are using a non graphics capable gt:"
? hb_gtVersion()
?
Quit
End
If hb_gtInfo(GTI_DESKTOPWIDTH) > 1000
hb_gtInfo(GTI_FONTSIZE, 24)
hb_gtInfo(GTI_FONTWIDTH, 12)
End
? hb_gtVersion(1)
nScreenWidth := hb_gtInfo(GTI_SCREENWIDTH)
nFontHeight := hb_gtInfo(GTI_FONTSIZE)
nFontWidth := hb_gtInfo(GTI_FONTWIDTH)
SetColor("n/w")
@ 0, 0 Say Space(MaxCol() + 1)
@ 1, 0 Say PadC(WELCOME, MaxCol() + 1)
@ 2, 0 Say Space(MaxCol() + 1)
hb_gtInfo(GTI_WINTITLE, "Cross-GT, multiplatform graphics demo")
PutFrame(nFontHeight / 2,;
MaxCol() / 2 * nFontWidth - Len(WELCOME) / 2 * nFontWidth - nFontWidth,;
nFontHeight * 2 + nFontHeight / 2,;
nFontWidth + MaxCol() / 2 * nFontWidth + Len(WELCOME) / 2 * nFontWidth,;
hb_gfxMakeColor(0, 0, 0), hb_gfxMakeColor(255, 255, 255))
While Inkey() == 0
nTop := Int(hb_Random(3.1 * nFontHeight, hb_gtInfo(GTI_SCREENHEIGHT)))
nLeft := Int(hb_Random(hb_gtInfo(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++
End
hb_gfxText(nTop, nLeft, "Hello", nColor, nHeight)
Exit
End
If Seconds() - nSec > 3
hb_gfxFloodFill(0, 0, nColor)
nSec := Seconds()
End
End
Return Nil
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