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.
This commit is contained in:
@@ -8,6 +8,82 @@
|
||||
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
|
||||
*/
|
||||
* harbour/makefile.vc
|
||||
* added optional BOOL parameter to functions which translate to UTF8
|
||||
to not translate control code characters
|
||||
|
||||
* harbour/source/rtl/gtsln/gtsln.c
|
||||
* harbour/source/rtl/gtxwc/gtxwc.c
|
||||
* update for new parameter in UTF8 functions
|
||||
|
||||
2006-03-01 16:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/source/rtl/cdpapi.c
|
||||
* harbour/source/rtl/gtxwc/gtxwc.c
|
||||
! fixed UTF8 trnalsations
|
||||
|
||||
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
|
||||
|
||||
@@ -86,10 +86,10 @@
|
||||
|
||||
|
||||
#xtranslate RestState(<a>) => DispBegin() ;;
|
||||
RestScreen(,,,,<a>\[\5]) ;;
|
||||
SetColor(<a>\[\3] ) ;;
|
||||
SetCursor(<a>\[\4]) ;;
|
||||
SetPos(<a>\[\1], <a>\[\2] ) ;;
|
||||
RestScreen(,,,,<a>\[5\]) ;;
|
||||
SetColor(<a>\[3\] ) ;;
|
||||
SetCursor(<a>\[4\]) ;;
|
||||
SetPos(<a>\[1\], <a>\[2\] ) ;;
|
||||
DispEnd()
|
||||
|
||||
|
||||
@@ -103,10 +103,10 @@
|
||||
NIL )
|
||||
|
||||
#xTranslate DbRestState( <a> ) => IIF( <a> != NIL, ;
|
||||
( Select( <a>\[\1] ), ;
|
||||
OrdListAdd(<a>\[\3] ), ;
|
||||
OrdSetFocus(<a>\[\4] ), ;
|
||||
DbGoto(<a>\[\2] )),)
|
||||
( Select( <a>\[1\] ), ;
|
||||
OrdListAdd(<a>\[3\] ), ;
|
||||
OrdSetFocus(<a>\[4\] ),;
|
||||
DbGoto(<a>\[2\] )),)
|
||||
|
||||
|
||||
// --> Display a Message at MAXROW() with optional colour...
|
||||
|
||||
@@ -1647,16 +1647,22 @@ static ERRCODE adsFlush( ADSAREAP pArea )
|
||||
HB_TRACE(HB_TR_DEBUG, ("adsFlush(%p)", pArea ));
|
||||
|
||||
/* This function should flush current record buffer if hot and
|
||||
send to OS request to flush its file buffers to disk, so instead
|
||||
of AdsWriteRecord(), AdsFlushFileBuffers() should be used */
|
||||
/* AdsWriteRecord( pArea->hTable ); */
|
||||
send to OS request to flush its file buffers to disk, so as well as
|
||||
of AdsWriteRecord(), AdsFlushFileBuffers() should be used FOR LOCAL
|
||||
TABLES (it's ignored by Remote Server).
|
||||
AdsWriteRecord() "flushes to the Advantage server",
|
||||
AdsFlushFileBuffers() tells the local server to flush to disk.
|
||||
Without it, we are dependent on the adslocal.cfg Flush Frequency setting.
|
||||
*/
|
||||
|
||||
if( !pArea->fReadonly )
|
||||
{
|
||||
#if ADS_REQUIRE_VERSION >= 6
|
||||
AdsFlushFileBuffers( pArea->hTable );
|
||||
#else
|
||||
AdsWriteRecord( pArea->hTable );
|
||||
#if ADS_REQUIRE_VERSION >= 6
|
||||
if( hb_set.HB_SET_HARDCOMMIT )
|
||||
{
|
||||
AdsFlushFileBuffers( pArea->hTable );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -70,11 +70,13 @@ PRG_HEADERS=\
|
||||
hbdebug.ch \
|
||||
hbextern.ch \
|
||||
hbgetcmt.ch \
|
||||
hbgfx.ch \
|
||||
hbgfxdef.ch \
|
||||
hbgtinfo.ch \
|
||||
hbinkey.ch \
|
||||
hblang.ch \
|
||||
hbmacro.ch \
|
||||
hbmath.ch \
|
||||
hbmath.ch \
|
||||
hbmemory.ch \
|
||||
hbmemvar.ch \
|
||||
hboo.ch \
|
||||
@@ -89,6 +91,7 @@ PRG_HEADERS=\
|
||||
setcurs.ch \
|
||||
simpleio.ch \
|
||||
std.ch \
|
||||
tbrowse.ch \
|
||||
|
||||
API_HEADERS=\
|
||||
error.api \
|
||||
@@ -102,4 +105,3 @@ API_HEADERS=\
|
||||
vm.api \
|
||||
|
||||
include $(TOP)$(ROOT)config/header.cf
|
||||
|
||||
|
||||
@@ -193,6 +193,8 @@ extern HB_EXPORT ERRCODE hb_gtOutErr( BYTE * pbyStr, ULONG ulLen );
|
||||
extern HB_EXPORT ERRCODE hb_gtSetDispCP( char * pszTermCDP, char * pszHostCDP, BOOL fBox );
|
||||
extern HB_EXPORT ERRCODE hb_gtSetKeyCP( char * pszTermCDP, char * pszHostCDP );
|
||||
extern HB_EXPORT ERRCODE hb_gtInfo( int iType, PHB_GT_INFO pInfo );
|
||||
extern HB_EXPORT int hb_gtGfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor );
|
||||
extern HB_EXPORT ERRCODE hb_gtGfxText( int iTop, int iLeft, char * szText, int iColor, int iSize, int iWidth );
|
||||
|
||||
extern HB_EXPORT BOOL hb_mouseIsPresent( void );
|
||||
extern HB_EXPORT BOOL hb_mouseGetCursor( void );
|
||||
|
||||
@@ -1091,22 +1091,26 @@ typedef PHB_FUNC HB_FUNC_PTR;
|
||||
Note that "HB_" is not enough, since the Harbour internals
|
||||
are also prefixed with HB_. [vszakats] */
|
||||
|
||||
#define HB_FUNCNAME( funcname ) HB_FUN_##funcname
|
||||
#define HB_INIT_FUNCNAME( funcname ) HB_FUN_init_##funcname
|
||||
#define HB_EXIT_FUNCNAME( funcname ) HB_FUN_exit_##funcname
|
||||
#define HB_FUNCNAME( funcname ) HB_FUN_##funcname
|
||||
#define HB_INIT_FUNCNAME( funcname ) HB_FUN_init_##funcname
|
||||
#define HB_EXIT_FUNCNAME( funcname ) HB_FUN_exit_##funcname
|
||||
#define HB_INITSTATICS_FUNCNAME() hb_INITSTATICS
|
||||
|
||||
#if ( defined( _MSC_VER ) || defined( __WATCOMC__ ) ) && defined( HB_FUNC_NO_DECORATION )
|
||||
#if defined( __cplusplus ) && defined( HB_FUNC_NO_DECORATION )
|
||||
#define HB_EXTERN_C_ extern "C"
|
||||
#define HB_EXTERN_
|
||||
#else
|
||||
#define HB_EXTERN_C_
|
||||
#define HB_EXTERN_ extern
|
||||
#endif
|
||||
|
||||
#define HB_FUNC_EXEC( funcname ) HB_FUN_##funcname();
|
||||
#define HB_FUNC( funcname ) HB_EXTERN_C_ HB_EXPORT HARBOUR HB_FUN_##funcname ( void )
|
||||
#define HB_FUNC_STATIC( funcname ) HB_EXTERN_C_ static HARBOUR HB_FUN_##funcname ( void )
|
||||
#define HB_FUNC_EXTERN( funcname ) HB_EXTERN_C_ extern HARBOUR HB_FUN_##funcname ( void )
|
||||
#define HB_FUNC_INIT( funcname ) HB_EXTERN_C_ static HARBOUR HB_FUN_init_##funcname ( void )
|
||||
#define HB_FUNC_EXIT( funcname ) HB_EXTERN_C_ static HARBOUR HB_FUN_exit_##funcname ( void )
|
||||
#define HB_FUNC_EXTERN( funcname ) HB_EXTERN_C_ HB_EXTERN_ HARBOUR HB_EXPORT HB_FUN_##funcname ( void )
|
||||
#define HB_FUNC_STATIC( funcname ) static HARBOUR HB_FUN_##funcname ( void )
|
||||
#define HB_FUNC_INIT( funcname ) static HARBOUR HB_FUN_init_##funcname ( void )
|
||||
#define HB_FUNC_EXIT( funcname ) static HARBOUR HB_FUN_exit_##funcname ( void )
|
||||
#define HB_FUNC_INITSTATICS( ) static HARBOUR hb_INITSTATICS( void )
|
||||
|
||||
typedef ULONG HB_HANDLE; /* handle to memvar value */
|
||||
typedef SHORT HB_SYMBOLSCOPE; /* stores symbol's scope */
|
||||
|
||||
95
harbour/include/hbgfx.ch
Normal file
95
harbour/include/hbgfx.ch
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* xHarbour Project source code:
|
||||
* GT Graphics functions
|
||||
*
|
||||
* Copyright 2004 Mauricio Abre <maurifull@datafull.com>
|
||||
* www - http://www.xharbour.org
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* WARNING: this file is also included in C code, so don't add xHarbour specific stuff,
|
||||
* or protect it under #ifdef __XHARBOUR__
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _HBGFX_CH_
|
||||
#define _HBGFX_CH_
|
||||
|
||||
#include "hbgfxdef.ch"
|
||||
|
||||
/*
|
||||
* NOTE: ACQUIRE / RELEASE screen pair must work same way DispBegin()/DispEnd() pair does
|
||||
* (that is, with an internal counter), as lots of function may want to 'acquire/release' it.
|
||||
*
|
||||
* However, a GT must properly manage its gfx output if the user didn't requested to acquire the
|
||||
* screen, so this is under user choice.
|
||||
* (the user just needs to know that it is not the same to aquire the screen, draw 100 lines, then
|
||||
* release screen, than simply drawing 100 lines -as the GT will be acquiring/releasing the screen
|
||||
* 100 times, which will slow down things a lot-)
|
||||
*
|
||||
* Mauricio
|
||||
*
|
||||
*/
|
||||
#xtranslate HB_GFXACQUIRESCREEN() => hb_gfxPrimitive(GFX_ACQUIRESCREEN)
|
||||
#xtranslate HB_GFXRELEASESCREEN() => hb_gfxPrimitive(GFX_RELEASESCREEN)
|
||||
#xtranslate HB_GFXMAKECOLOR(<nRed>, <nGreen>, <nBlue>[, <nAlpha>]) => hb_gfxPrimitive(GFX_MAKECOLOR, <nRed>, <nGreen>, <nBlue>[, <nAlpha>])
|
||||
#xtranslate HB_GFXGETCLIP(<nTop>, <nLeft>, <nBottom>, <nRight>) => <nTop> := hb_gfxPrimitive(GFX_CLIPTOP); <nLeft> := hb_gfxPrimitive(GFX_CLIPLEFT); <nBottom> := hb_gfxPrimitive(GFX_CLIPBOTTOM); <nRight> := hb_gfxPrimitive(GFX_CLIPRIGHT)
|
||||
#xtranslate HB_GFXSETCLIP(<nTop>, <nLeft>, <nBottom>, <nRight>) => hb_gfxPrimitive(GFX_SETCLIP, <nTop>, <nLeft>, <nBottom>, <nRight>)
|
||||
#xtranslate HB_GFXDRAWINGMODE([<nMode>]) => hb_gfxPrimitive(GFX_DRAWINGMODE[, <nMode>])
|
||||
#xtranslate HB_GFXGETPIXEL(<nY>, <nX>) => hb_gfxPrimitive(GFX_GETPIXEL, <nY>, <nX>)
|
||||
#xtranslate HB_GFXPUTPIXEL(<nY>, <nX>, <nColor>) => hb_gfxPrimitive(GFX_PUTPIXEL, <nY>, <nX>, <nColor>)
|
||||
#xtranslate HB_GFXLINE(<nTop>, <nLeft>, <nBottom>, <nRight>, <nColor>) => hb_gfxPrimitive(GFX_LINE, <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor>)
|
||||
#xtranslate HB_GFXRECT(<nTop>, <nLeft>, <nBottom>, <nRight>, <nColor>) => hb_gfxPrimitive(GFX_RECT, <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor>)
|
||||
#xtranslate HB_GFXFILLEDRECT(<nTop>, <nLeft>, <nBottom>, <nRight>, <nColor>) => hb_gfxPrimitive(GFX_FILLEDRECT, <nTop>, <nLeft>, <nBottom>, <nRight>, <nColor>)
|
||||
#xtranslate HB_GFXCIRCLE(<nY>, <nX>, <nRadius>, <nColor>) => hb_gfxPrimitive(GFX_CIRCLE, <nY>, <nX>, <nRadius>, <nColor>)
|
||||
#xtranslate HB_GFXFILLEDCIRCLE(<nY>, <nX>, <nRadius>, <nColor>) => hb_gfxPrimitive(GFX_FILLEDCIRCLE, <nY>, <nX>, <nRadius>, <nColor>)
|
||||
#xtranslate HB_GFXELLIPSE(<nY>, <nX>, <nRadY>, <nRadX>, <nColor>) => hb_gfxPrimitive(GFX_ELLIPSE, <nY>, <nX>, <nRadY>, <nRadX>, <nColor>)
|
||||
#xtranslate HB_GFXFILLEDELLIPSE(<nY>, <nX>, <nRadY>, <nRadX>, <nColor>) => hb_gfxPrimitive(GFX_FILLEDELLIPSE, <nY>, <nX>, <nRadY>, <nRadX>, <nColor>)
|
||||
#xtranslate HB_GFXFLOODFILL(<nY>, <nX>, <nColor>) => hb_gfxPrimitive(GFX_FLOODFILL, <nY>, <nX>, <nColor>)
|
||||
|
||||
#endif /* _HBGFX_CH_ */
|
||||
107
harbour/include/hbgfxdef.ch
Normal file
107
harbour/include/hbgfxdef.ch
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* xHarbour Project source code:
|
||||
* GT Graphics definitions (GFX_*)
|
||||
*
|
||||
* Copyright 2004 Mauricio Abre <maurifull@datafull.com>
|
||||
* www - http://www.xharbour.org
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* WARNING: this file is also included in C code, so don't add xHarbour specific stuff,
|
||||
* or protect it under #ifdef __XHARBOUR__
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _HBGFXDEF_CH_
|
||||
#define _HBGFXDEF_CH_
|
||||
|
||||
/*
|
||||
* NOTE: ACQUIRE / RELEASE screen pair must work same way DispBegin()/DispEnd() pair does
|
||||
* (that is, with an internal counter), as lots of function may want to 'acquire/release' it.
|
||||
*
|
||||
* However, a GT must properly manage its gfx output if the user didn't requested to acquire the
|
||||
* screen, so this is under user choice.
|
||||
* (the user just needs to know that it is not the same to aquire the screen, draw 100 lines, then
|
||||
* release screen, than simply drawing 100 lines -as the GT will be acquiring/releasing the screen
|
||||
* 100 times, which will slow down things a lot-)
|
||||
*
|
||||
* Mauricio
|
||||
*
|
||||
*/
|
||||
|
||||
/* Misc, internals */
|
||||
#define GFX_ACQUIRESCREEN 1 /* Some GTs may require that you 'acquire' the screen before doing gfx things */
|
||||
#define GFX_RELEASESCREEN 2 /* Release a previously 'acquired' screen */
|
||||
#define GFX_MAKECOLOR 3 /* Calculate gfx color number based on RGBA values */
|
||||
/* Functions that affect drawing area */
|
||||
#define GFX_CLIPTOP 10
|
||||
#define GFX_CLIPLEFT 11
|
||||
#define GFX_CLIPBOTTOM 12
|
||||
#define GFX_CLIPRIGHT 13
|
||||
#define GFX_SETCLIP 14 /* NOTE: set to 0, 0, 0, 0 to disable ;) */
|
||||
/* Functions that affect drawing mode */
|
||||
#define GFX_DRAWINGMODE 20
|
||||
/* Drawing primitives */
|
||||
#define GFX_GETPIXEL 50
|
||||
#define GFX_PUTPIXEL 51
|
||||
#define GFX_LINE 52
|
||||
#define GFX_RECT 53
|
||||
#define GFX_FILLEDRECT 54
|
||||
#define GFX_CIRCLE 55
|
||||
#define GFX_FILLEDCIRCLE 56
|
||||
#define GFX_ELLIPSE 57
|
||||
#define GFX_FILLEDELLIPSE 58
|
||||
#define GFX_FLOODFILL 59
|
||||
|
||||
/* Drawing mode constants */
|
||||
#define GFX_MODE_SOLID 1 /* Solid mode, no translucency, no patterned primitives */
|
||||
#define GFX_MODE_XOR 2 /* XOR with current screen contents */
|
||||
#define GFX_MODE_ALPHA 3 /* Use alpha for transluced effect (SLOW) */
|
||||
/* TODO: add patterned mode drawings */
|
||||
|
||||
#endif /* _HBGFXDEF_CH_ */
|
||||
@@ -212,6 +212,10 @@ typedef struct
|
||||
BOOL (* MouseButtonReleased) ( int, int *, int * );
|
||||
int (* MouseReadKey) ( int );
|
||||
|
||||
/* Graphics API */
|
||||
int (* GfxPrimitive) ( int, int, int, int, int, int );
|
||||
void (* GfxText) ( int, int, char *, int, int, int );
|
||||
|
||||
#if 0
|
||||
/* keyboard */
|
||||
int (* ExtendedKeySupport) ( void );
|
||||
@@ -227,10 +231,6 @@ typedef struct
|
||||
void (* update ) ( int );
|
||||
int (* info ) ( int, BOOL , int , void * );
|
||||
|
||||
/* Graphics API */
|
||||
int (* gfxPrimitive) ( int, int, int, int, int, int );
|
||||
void (* gfxText) ( int, int, char *, int, int, int );
|
||||
|
||||
#endif
|
||||
|
||||
void (* WhoCares) ( void * );
|
||||
@@ -400,6 +400,8 @@ extern BOOL hb_mouse_ButtonState( int iButton );
|
||||
extern BOOL hb_mouse_ButtonPressed( int iButton, int * piRow, int * piCol );
|
||||
extern BOOL hb_mouse_ButtonReleased( int iButton, int * piRow, int * piCol );
|
||||
extern int hb_mouse_ReadKey( int iEventMask );
|
||||
extern int hb_gt_GfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor );
|
||||
extern void hb_gt_GfxText( int iTop, int iLeft, char * szText, int iColor, int iSize, int iWidth );
|
||||
extern void hb_gt_WhoCares( void * pCargo );
|
||||
|
||||
#define HB_GTSUPER_NEW() (HB_GTSUPER)->New()
|
||||
@@ -499,6 +501,8 @@ extern void hb_gt_WhoCares( void * pCargo );
|
||||
#define HB_GTSUPER_MOUSEBUTTONPRESSED(b,r,c) (HB_GTSUPER)->MouseButtonPressed(b,r,c)
|
||||
#define HB_GTSUPER_MOUSEBUTTONRELEASED(b,r,c) (HB_GTSUPER)->MouseButtonReleased(b,r,c)
|
||||
#define HB_GTSUPER_MOUSEREADKEY(m) (HB_GTSUPER)->MouseReadKey(m)
|
||||
#define HB_GTSUPER_GFXPRIMITIVE(g,t,l,b,r,c) (HB_GTSUPER)->GfxPrimitive(g,t,l,b,r,c)
|
||||
#define HB_GTSUPER_GFXTEXT(t,l,s,c,h,w) (HB_GTSUPER)->GfxPrimitive(t,l,s,c,h,w)
|
||||
#define HB_GTSUPER_WHOCARES(p) (HB_GTSUPER)->WhoCares(p)
|
||||
|
||||
extern HB_EXPORT void hb_gtSetDefault( char * szGtName );
|
||||
|
||||
@@ -106,7 +106,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
|
||||
fprintf( yyc, "HB_FUNC( %s );\n", pFunc->szName );
|
||||
/* Is it a STATIC$ */
|
||||
else if ( bIsStaticVariable )
|
||||
fprintf( yyc, "static HARBOUR hb_INITSTATICS( void );\n" ); /* NOTE: hb_ intentionally in lower case */
|
||||
fprintf( yyc, "HB_FUNC_INITSTATICS();\n" ); /* NOTE: hb_ intentionally in lower case */
|
||||
/* Is it an INIT FUNCTION/PROCEDURE */
|
||||
else if ( bIsInitFunction )
|
||||
hb_compGenCFunc( yyc, "HB_FUNC_INIT( %s );\n", pFunc->szName, 1 );
|
||||
@@ -170,7 +170,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
|
||||
* we are using these two bits to mark the special function used to
|
||||
* initialize static variables
|
||||
*/
|
||||
fprintf( yyc, "{ \"(_INITSTATICS)\", {HB_FS_INIT | HB_FS_EXIT}, {hb_INITSTATICS}, NULL }" ); /* NOTE: hb_ intentionally in lower case */
|
||||
fprintf( yyc, "{ \"(_INITSTATICS)\", {HB_FS_INITEXIT}, {hb_INITSTATICS}, NULL }" ); /* NOTE: hb_ intentionally in lower case */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -242,7 +242,7 @@ void hb_compGenCCode( PHB_FNAME pFileName ) /* generates the C language ou
|
||||
fprintf( yyc, "HB_FUNC( %s )", pFunc->szName );
|
||||
/* Is it STATICS$ */
|
||||
else if( bIsStaticVariable )
|
||||
fprintf( yyc, "static HARBOUR hb_INITSTATICS( void )" ); /* NOTE: hb_ intentionally in lower case */
|
||||
fprintf( yyc, "HB_FUNC_INITSTATICS()" ); /* NOTE: hb_ intentionally in lower case */
|
||||
/* Is it an INIT FUNCTION/PROCEDURE */
|
||||
else if ( bIsInitFunction )
|
||||
hb_compGenCFunc( yyc, "HB_FUNC_INIT( %s )", pFunc->szName, 1 );
|
||||
@@ -1214,7 +1214,7 @@ static HB_GENC_FUNC( hb_p_pushblock )
|
||||
* because at the time of C code generation we don't know
|
||||
* in which function was defined this local variable
|
||||
*/
|
||||
if( ( pFunc->cScope & ( HB_FS_INIT | HB_FS_EXIT ) ) != ( HB_FS_INIT | HB_FS_EXIT ) )
|
||||
if( ( pFunc->cScope & HB_FS_INITEXIT ) != HB_FS_INITEXIT )
|
||||
if( cargo->bVerbose ) fprintf( cargo->yyc, "\t/* %s */", hb_compLocalVariableFind( pFunc, w )->szName );
|
||||
fprintf( cargo->yyc, "\n" );
|
||||
lPCodePos +=2;
|
||||
|
||||
@@ -2353,7 +2353,7 @@ int hb_compLocalGetPos( char * szVarName ) /* returns the order + 1 of a variabl
|
||||
while( pFunc )
|
||||
{
|
||||
bStatic = FALSE;
|
||||
if( ( pFunc->cScope & ( HB_FS_INIT | HB_FS_EXIT ) ) == ( HB_FS_INIT | HB_FS_EXIT ) )
|
||||
if( ( pFunc->cScope & HB_FS_INITEXIT ) == HB_FS_INITEXIT )
|
||||
{
|
||||
/* we are in a codeblock used to initialize a static variable -
|
||||
* skip to a function where this static variable was declared
|
||||
@@ -3142,7 +3142,7 @@ void hb_compGenPopVar( char * szVarName ) /* generates the pcode to pop a value
|
||||
* initialization function - if YES then we have to switch to a function
|
||||
* where the static variable was declared
|
||||
*/
|
||||
if( ( hb_comp_functions.pLast->cScope & ( HB_FS_INIT | HB_FS_EXIT ) ) == ( HB_FS_INIT | HB_FS_EXIT ) )
|
||||
if( ( hb_comp_functions.pLast->cScope & HB_FS_INITEXIT ) == HB_FS_INITEXIT )
|
||||
pFunc = hb_comp_functions.pLast->pOwner;
|
||||
else
|
||||
pFunc = hb_comp_functions.pLast;
|
||||
@@ -4408,7 +4408,7 @@ void hb_compStaticDefStart( void )
|
||||
hb_comp_pInitFunc = hb_compFunctionNew( hb_compIdentifierNew("(_INITSTATICS)", TRUE), HB_FS_INIT );
|
||||
hb_comp_pInitFunc->pOwner = hb_comp_functions.pLast;
|
||||
hb_comp_pInitFunc->bFlags = FUN_USES_STATICS | FUN_PROCEDURE;
|
||||
hb_comp_pInitFunc->cScope = HB_FS_INIT | HB_FS_EXIT;
|
||||
hb_comp_pInitFunc->cScope = HB_FS_INITEXIT;
|
||||
hb_comp_functions.pLast = hb_comp_pInitFunc;
|
||||
|
||||
pBuffer[ 0 ] = HB_P_STATICS;
|
||||
@@ -5038,6 +5038,7 @@ static void hb_compCompileEnd( void )
|
||||
while( hb_comp_files.pLast )
|
||||
{
|
||||
PFILE pFile = hb_comp_files.pLast;
|
||||
hb_xfree( pFile->szFileName );
|
||||
fclose( pFile->handle );
|
||||
if( pFile->pBuffer )
|
||||
{
|
||||
|
||||
@@ -1936,7 +1936,7 @@ BOOL hb_compInclude( char * szFileName, HB_PATHNAMES * pSearch )
|
||||
pFile->handle = yyin;
|
||||
pFile->pBuffer = hb_xgrab( HB_PP_BUFF_SIZE );
|
||||
pFile->iBuffer = pFile->lenBuffer = 10;
|
||||
pFile->szFileName = szFileName;
|
||||
pFile->szFileName = hb_strdup( szFileName );
|
||||
pFile->iLine = 0;
|
||||
pFile->pPrev = hb_comp_files.pLast;
|
||||
|
||||
|
||||
@@ -304,6 +304,11 @@ void hb_pp_SetRules( HB_INCLUDE_FUNC_PTR hb_compInclude, BOOL hb_comp_bQuiet )
|
||||
|
||||
fclose( hb_comp_files.pLast->handle );
|
||||
hb_xfree( hb_comp_files.pLast->pBuffer );
|
||||
hb_xfree( hb_comp_files.pLast->szFileName );
|
||||
if( hb_comp_files.pLast->yyBuffer )
|
||||
{
|
||||
hb_compParserStop(); /* uses hb_comp_files.pLast */
|
||||
}
|
||||
hb_xfree( hb_comp_files.pLast );
|
||||
hb_comp_files.pLast = NULL;
|
||||
hb_comp_files.iFiles = 0;
|
||||
@@ -2023,7 +2028,7 @@ static int CommandStuff( char * ptrmp, char * inputLine, char * ptro, int * lenr
|
||||
|
||||
static int RemoveSlash( char * cpatt )
|
||||
{
|
||||
int i;
|
||||
int i = 0;
|
||||
int lenres = strlen( cpatt );
|
||||
|
||||
while( cpatt[ i ] != '\0' )
|
||||
@@ -4500,8 +4505,8 @@ static BOOL OpenInclude( char * szFileName, HB_PATHNAMES * pSearch, PHB_FNAME pM
|
||||
pFile->handle = fptr;
|
||||
pFile->pBuffer = hb_xgrab( HB_PP_BUFF_SIZE );
|
||||
pFile->iBuffer = pFile->lenBuffer = 10;
|
||||
pFile->szFileName = ( char * ) hb_xgrab( strlen( szFileName ) + 1 );
|
||||
hb_pp_strocpy( pFile->szFileName, szFileName );
|
||||
pFile->yyBuffer = NULL;
|
||||
pFile->szFileName = hb_strdup( szFileName );
|
||||
|
||||
if( hb_comp_files.pLast )
|
||||
hb_comp_files.pLast->iLine = hb_comp_iLine;
|
||||
|
||||
@@ -254,5 +254,10 @@ PINLINE hb_compInlineAdd( char * szFunName )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hb_compParserStop( void )
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -631,6 +631,8 @@ HB_EXPORT ULONG hb_cdpStrnToUTF8( PHB_CODEPAGE cdp, BYTE* pSrc, ULONG ulLen, BYT
|
||||
u = uniCodes[ u ];
|
||||
n += u16toutf8( &pDst[n], u );
|
||||
}
|
||||
pDst[ n ] = '\0';
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,7 +85,6 @@ HB_FUNC( CTOD )
|
||||
{
|
||||
char * szDate = hb_parc( 1 );
|
||||
int d_value = 0, m_value = 0, y_value = 0;
|
||||
char szDateFormat[ 9 ];
|
||||
|
||||
if( szDate )
|
||||
{
|
||||
@@ -170,9 +169,7 @@ HB_FUNC( CTOD )
|
||||
}
|
||||
}
|
||||
|
||||
sprintf( szDateFormat, "%04i%02i%02i", y_value, m_value, d_value );
|
||||
|
||||
hb_retds( szDateFormat );
|
||||
hb_retd( y_value, m_value, d_value );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE_SubstR( EG_ARG, 1119, NULL, "CTOD", 1, hb_paramError( 1 ) );
|
||||
|
||||
13
harbour/source/rtl/gtalleg/Makefile
Normal file
13
harbour/source/rtl/gtalleg/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
|
||||
ROOT = ../../../
|
||||
|
||||
C_SOURCES=\
|
||||
gtalleg.c ssf.c
|
||||
|
||||
LIBNAME=gtalleg
|
||||
|
||||
include $(TOP)$(ROOT)config/lib.cf
|
||||
|
||||
ifeq ($(HB_MULTI_GT),yes)
|
||||
CFLAGS += -DHB_MULTI_GT
|
||||
endif
|
||||
1371
harbour/source/rtl/gtalleg/fixedth.sfc
Normal file
1371
harbour/source/rtl/gtalleg/fixedth.sfc
Normal file
File diff suppressed because it is too large
Load Diff
1227
harbour/source/rtl/gtalleg/gtalleg.c
Normal file
1227
harbour/source/rtl/gtalleg/gtalleg.c
Normal file
File diff suppressed because it is too large
Load Diff
210
harbour/source/rtl/gtalleg/ssf.c
Normal file
210
harbour/source/rtl/gtalleg/ssf.c
Normal file
@@ -0,0 +1,210 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* This file was conceived while I was developing an allegro based gt
|
||||
* (gtAlleg) for xHarbour, so it is brought under the same license terms.
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* xHarbour Project source code:
|
||||
* Simple Scalable Font library, main C module.
|
||||
*
|
||||
* Copyright 2004 Mauricio Abre <maurifull@datafull.com>
|
||||
* www - http: (yet to be constructed...)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "hbapi.h"
|
||||
#include "ssf.h"
|
||||
#include "fixedth.sfc"
|
||||
|
||||
ssfFont *ssfDefaultFont = &ssfFixedThinFont;
|
||||
|
||||
#define fSize sfont->fsize
|
||||
#define fLeft points[0]
|
||||
#define fTop points[1]
|
||||
#define fRight points[2]
|
||||
#define fBottom points[3]
|
||||
#define fLeft2 points[4]
|
||||
#define fTop2 points[5]
|
||||
#define fRight2 points[6]
|
||||
#define fBottom2 points[7]
|
||||
|
||||
void ssfSetFontSize(ssfFont *sfont, USHORT fsize)
|
||||
{
|
||||
fSize = fsize;
|
||||
}
|
||||
|
||||
USHORT ssfDrawChar(AL_BITMAP *dst, ssfFont *sfont, char c, int x, int y, int color)
|
||||
{
|
||||
BYTE p;
|
||||
int i, j, thick;
|
||||
ssfGlyph charGlyph;
|
||||
ssfFrame charFrame;
|
||||
int points[8];
|
||||
float fScale;
|
||||
|
||||
p = (BYTE) c;
|
||||
charGlyph = *sfont->chars[p];
|
||||
fScale = (float) ((float) sfont->fsize / (float) 65535);
|
||||
|
||||
for (i = 0; i < charGlyph.num; i++)
|
||||
{
|
||||
charFrame = charGlyph.frames[i];
|
||||
if (charFrame.ftype == SSF_SPLINE2)
|
||||
{
|
||||
fLeft2 = x + (int) (fScale * charFrame.left);
|
||||
fTop2 = y + (int) (fScale * charFrame.top);
|
||||
fRight2 = x + (int) (fScale * charFrame.right);
|
||||
fBottom2 = y + (int) (fScale * charFrame.bottom);
|
||||
}
|
||||
else
|
||||
{
|
||||
fLeft = x + (int) (fScale * charFrame.left);
|
||||
fTop = y + (int) (fScale * charFrame.top);
|
||||
fRight = x + (int) (fScale * charFrame.right);
|
||||
fBottom = y + (int) (fScale * charFrame.bottom);
|
||||
}
|
||||
|
||||
switch (charFrame.ftype)
|
||||
{
|
||||
case SSF_SPLINE2:
|
||||
thick = (int) (fScale * charFrame.thick);
|
||||
|
||||
if (thick == 0)
|
||||
thick++;
|
||||
|
||||
for (j = 0; j < thick; j++)
|
||||
{
|
||||
al_draw_spline(dst, points, color);
|
||||
switch (charFrame.thickdir)
|
||||
{
|
||||
case THICK_LEFT:
|
||||
fLeft--;
|
||||
fRight--;
|
||||
fLeft2--;
|
||||
fRight2--;
|
||||
break;
|
||||
case THICK_UP:
|
||||
fTop--;
|
||||
fBottom--;
|
||||
fTop2--;
|
||||
fBottom2--;
|
||||
break;
|
||||
case THICK_RIGHT:
|
||||
fLeft++;
|
||||
fRight++;
|
||||
fLeft2++;
|
||||
fRight2++;
|
||||
break;
|
||||
case THICK_DOWN:
|
||||
fTop++;
|
||||
fBottom++;
|
||||
fTop2++;
|
||||
fBottom2++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SSF_LINE:
|
||||
thick = (int) (fScale * charFrame.thick);
|
||||
|
||||
if (thick == 0)
|
||||
thick++;
|
||||
|
||||
for (j = 0; j < thick; j++)
|
||||
{
|
||||
al_draw_line(dst, fLeft, fTop, fRight, fBottom, color);
|
||||
switch (charFrame.thickdir) {
|
||||
case THICK_LEFT:
|
||||
fLeft--;
|
||||
fRight--;
|
||||
break;
|
||||
case THICK_UP:
|
||||
fTop--;
|
||||
fBottom--;
|
||||
break;
|
||||
case THICK_RIGHT:
|
||||
fLeft++;
|
||||
fRight++;
|
||||
break;
|
||||
case THICK_DOWN:
|
||||
fTop++;
|
||||
fBottom++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case SSF_BOX:
|
||||
al_draw_rect_fill(dst, fLeft, fTop, fRight, fBottom, color);
|
||||
break;
|
||||
|
||||
case SSF_TRIANGLE:
|
||||
thick = x + (int) (fScale * charFrame.thick);
|
||||
al_draw_triangle(dst, fLeft, fTop, fRight, fBottom, thick, y + (int) (fScale * charFrame.thickdir), color);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return (sfont->fsize / 2);
|
||||
}
|
||||
|
||||
int ssfDrawText(AL_BITMAP *dst, ssfFont *sfont, char *s, int x, int y, int color)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
while ( s[i] )
|
||||
{
|
||||
x += ssfDrawChar(dst, sfont, s[i], x, y, color);
|
||||
i++;
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
242
harbour/source/rtl/gtalleg/ssf.h
Normal file
242
harbour/source/rtl/gtalleg/ssf.h
Normal file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
*
|
||||
* This file was conceived while I was developing an allegro based gt
|
||||
* (gtAlleg) for xHarbour, so it is brought under the same license terms.
|
||||
*
|
||||
* Mauricio Abre
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* xHarbour Project source code:
|
||||
* Simple Scalable Font library, main header file.
|
||||
*
|
||||
* Copyright 2004 Mauricio Abre <maurifull@datafull.com>
|
||||
* www - http: (yet to be constructed...)
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SSF_H_
|
||||
#define _SSF_H_
|
||||
|
||||
#include <allegro.h>
|
||||
|
||||
// Hack to use old Allegro branches
|
||||
#ifndef AL_GFX_NONE
|
||||
#define AL_GFX_NONE GFX_NONE
|
||||
#define AL_GFX_SAFE GFX_SAFE
|
||||
#ifdef GFX_XWINDOWS
|
||||
#define AL_GFX_XDGA GFX_XDGA
|
||||
#define AL_GFX_XDGA2 GFX_XDGA2
|
||||
#define AL_GFX_XWINDOWS GFX_XWINDOWS
|
||||
#endif
|
||||
#define AL_GFX_VBEAF GFX_VBEAF
|
||||
#ifdef GFX_FBCON
|
||||
#define AL_GFX_FBCON GFX_FBCON
|
||||
#endif
|
||||
#define AL_GFX_AUTODETECT_WINDOWED GFX_AUTODETECT_WINDOWED
|
||||
#define AL_GFX_AUTODETECT GFX_AUTODETECT
|
||||
#ifdef GFX_GDI
|
||||
#define AL_GFX_GDI GFX_GDI
|
||||
#define AL_GFX_DIRECTX_WIN GFX_DIRECTX_WIN
|
||||
#endif
|
||||
#define AL_BITMAP BITMAP
|
||||
#define AL_SCREEN_W SCREEN_W
|
||||
#define AL_SCREEN_H SCREEN_H
|
||||
#define AL_KEY_ESC KEY_ESC
|
||||
#define AL_KEY_INSERT KEY_INSERT
|
||||
#define AL_KEY_HOME KEY_HOME
|
||||
#define AL_KEY_PGUP KEY_PGUP
|
||||
#define AL_KEY_PGDN KEY_PGDN
|
||||
#define AL_KEY_END KEY_END
|
||||
#define AL_KEY_DEL KEY_DEL
|
||||
#define AL_KEY_UP KEY_UP
|
||||
#define AL_KEY_DOWN KEY_DOWN
|
||||
#define AL_KEY_LEFT KEY_LEFT
|
||||
#define AL_KEY_RIGHT KEY_RIGHT
|
||||
#define AL_KEY_QUOTE KEY_QUOTE
|
||||
#define AL_KEY_A KEY_A
|
||||
#define AL_KEY_B KEY_B
|
||||
#define AL_KEY_C KEY_C
|
||||
#define AL_KEY_D KEY_D
|
||||
#define AL_KEY_E KEY_E
|
||||
#define AL_KEY_F KEY_F
|
||||
#define AL_KEY_G KEY_G
|
||||
#define AL_KEY_H KEY_H
|
||||
#define AL_KEY_I KEY_I
|
||||
#define AL_KEY_J KEY_J
|
||||
#define AL_KEY_K KEY_K
|
||||
#define AL_KEY_L KEY_L
|
||||
#define AL_KEY_M KEY_M
|
||||
#define AL_KEY_N KEY_N
|
||||
#define AL_KEY_O KEY_O
|
||||
#define AL_KEY_P KEY_P
|
||||
#define AL_KEY_Q KEY_Q
|
||||
#define AL_KEY_R KEY_R
|
||||
#define AL_KEY_S KEY_S
|
||||
#define AL_KEY_T KEY_T
|
||||
#define AL_KEY_U KEY_U
|
||||
#define AL_KEY_V KEY_V
|
||||
#define AL_KEY_W KEY_W
|
||||
#define AL_KEY_X KEY_X
|
||||
#define AL_KEY_Y KEY_Y
|
||||
#define AL_KEY_Z KEY_Z
|
||||
#define AL_KEY_F1 KEY_F1
|
||||
#define AL_KEY_F2 KEY_F2
|
||||
#define AL_KEY_F3 KEY_F3
|
||||
#define AL_KEY_F4 KEY_F4
|
||||
#define AL_KEY_F5 KEY_F5
|
||||
#define AL_KEY_F6 KEY_F6
|
||||
#define AL_KEY_F7 KEY_F7
|
||||
#define AL_KEY_F8 KEY_F8
|
||||
#define AL_KEY_F9 KEY_F9
|
||||
#define AL_KEY_F10 KEY_F10
|
||||
#define AL_KEY_F11 KEY_F11
|
||||
#define AL_KEY_F12 KEY_F12
|
||||
#define al_desktop_color_depth desktop_color_depth
|
||||
#define al_set_color_depth set_color_depth
|
||||
#define al_bitmap_color_depth bitmap_color_depth
|
||||
#define al_get_desktop_resolution get_desktop_resolution
|
||||
#define al_install_timer install_timer
|
||||
#define al_screen screen
|
||||
#define al_set_gfx_mode set_gfx_mode
|
||||
#define al_set_window_title set_window_title
|
||||
#define al_text_mode text_mode
|
||||
#define al_make_color makecol
|
||||
#define al_key_shifts key_shifts
|
||||
#define al_install_keyboard install_keyboard
|
||||
#define al_keyboard_needs_poll keyboard_needs_poll
|
||||
#define al_poll_keyboard poll_keyboard
|
||||
#define al_key_pressed keypressed
|
||||
#define al_read_key readkey
|
||||
#define al_set_keyboard_leds set_leds
|
||||
#define al_install_mouse install_mouse
|
||||
#define al_show_mouse show_mouse
|
||||
#define al_mouse_needs_poll mouse_needs_poll
|
||||
#define al_poll_mouse poll_mouse
|
||||
#define al_mouse_x mouse_x
|
||||
#define al_mouse_y mouse_y
|
||||
#define al_mouse_b mouse_b
|
||||
#define al_scare_mouse scare_mouse
|
||||
#define al_scare_mouse_area scare_mouse_area
|
||||
#define al_unscare_mouse unscare_mouse
|
||||
#define al_position_mouse position_mouse
|
||||
#define al_set_mouse_range set_mouse_range
|
||||
#define al_create_bitmap create_bitmap
|
||||
#define al_create_system_bitmap create_system_bitmap
|
||||
#define al_destroy_bitmap destroy_bitmap
|
||||
#define al_acquire_screen acquire_screen
|
||||
#define al_release_screen release_screen
|
||||
#define al_acquire_bitmap acquire_bitmap
|
||||
#define al_release_bitmap release_bitmap
|
||||
#define al_drawing_mode drawing_mode
|
||||
#define al_get_pixel getpixel
|
||||
#define al_put_pixel putpixel
|
||||
#define al_draw_line line
|
||||
#define al_draw_vline vline
|
||||
#define al_draw_hline hline
|
||||
#define al_draw_rect rect
|
||||
#define al_draw_rect_fill rectfill
|
||||
#define al_draw_spline spline
|
||||
#define al_draw_circle circle
|
||||
#define al_draw_circle_fill circlefill
|
||||
#define al_draw_ellipse ellipse
|
||||
#define al_draw_ellipse_fill ellipsefill
|
||||
#define al_floodfill floodfill
|
||||
#define al_draw_triangle triangle
|
||||
#define al_blit blit
|
||||
#define al_clear_to_color clear_to_color
|
||||
#ifndef al_set_clip
|
||||
#if ALLEGRO_SUB_VERSION < 2
|
||||
#define al_set_clip set_clip
|
||||
#else
|
||||
#define al_set_clip set_clip_rect
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
SSF_NONE,
|
||||
SSF_LINE,
|
||||
SSF_BOX,
|
||||
SSF_SPLINE1,
|
||||
SSF_SPLINE2,
|
||||
SSF_TRIANGLE,
|
||||
SSF_COLOR
|
||||
} ssfType;
|
||||
|
||||
#ifndef SSF_MAXFRAMES
|
||||
#define SSF_MAXFRAMES 128
|
||||
#endif
|
||||
|
||||
#define THICK_LEFT 0
|
||||
#define THICK_UP 1
|
||||
#define THICK_RIGHT 2
|
||||
#define THICK_DOWN 3
|
||||
|
||||
typedef struct _ssfFrame {
|
||||
char ftype;
|
||||
unsigned short left, top, right, bottom, thick;
|
||||
unsigned short thickdir;
|
||||
} ssfFrame;
|
||||
|
||||
typedef struct _ssfGlyph {
|
||||
int num;
|
||||
ssfFrame frames[SSF_MAXFRAMES];
|
||||
} ssfGlyph;
|
||||
|
||||
typedef struct _ssfFont {
|
||||
unsigned short fsize;
|
||||
ssfGlyph **chars;
|
||||
} ssfFont;
|
||||
|
||||
extern ssfFont *ssfDefaultFont;
|
||||
|
||||
extern void ssfSetFontSize(ssfFont *sfont, unsigned short fsize);
|
||||
extern unsigned short ssfDrawChar(AL_BITMAP *dst, ssfFont *sfont, char c, int x, int y, int color);
|
||||
extern int ssfDrawText(AL_BITMAP *dst, ssfFont *sfont, char *s, int x, int y, int color);
|
||||
|
||||
#endif // _SSF_H_
|
||||
@@ -607,3 +607,21 @@ ERRCODE hb_gtInfo( int iType, PHB_GT_INFO pInfo )
|
||||
else
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
int hb_gtGfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
|
||||
{
|
||||
int iResult;
|
||||
|
||||
iResult = hb_gt_GfxPrimitive( iType, iTop, iLeft, iBottom, iRight, iColor );
|
||||
hb_gt_Flush();
|
||||
|
||||
return iResult;
|
||||
}
|
||||
|
||||
ERRCODE hb_gtGfxText( int iTop, int iLeft, char * cBuf, int iColor, int iSize, int iWidth )
|
||||
{
|
||||
hb_gt_GfxText( iTop, iLeft, cBuf, iColor, iSize, iWidth );
|
||||
hb_gt_Flush();
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -126,3 +126,32 @@ HB_FUNC( HB_GTVERSION )
|
||||
{
|
||||
hb_retc( hb_gtVersion( hb_parni( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_GFXPRIMITIVE )
|
||||
{
|
||||
PHB_ITEM pType = hb_param( 1, HB_IT_NUMERIC );
|
||||
PHB_ITEM pTop = hb_param( 2, HB_IT_NUMERIC );
|
||||
PHB_ITEM pLeft = hb_param( 3, HB_IT_NUMERIC );
|
||||
PHB_ITEM pBottom = hb_param( 4, HB_IT_NUMERIC );
|
||||
PHB_ITEM pRight = hb_param( 5, HB_IT_NUMERIC );
|
||||
PHB_ITEM pColor = hb_param( 6, HB_IT_NUMERIC );
|
||||
|
||||
hb_retni( hb_gtGfxPrimitive( hb_itemGetNI(pType),
|
||||
hb_itemGetNI(pTop), hb_itemGetNI(pLeft),
|
||||
hb_itemGetNI(pBottom), hb_itemGetNI(pRight),
|
||||
hb_itemGetNI(pColor) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_GFXTEXT )
|
||||
{
|
||||
PHB_ITEM pTop = hb_param( 1, HB_IT_NUMERIC );
|
||||
PHB_ITEM pLeft = hb_param( 2, HB_IT_NUMERIC );
|
||||
char *cText = hb_parc(3);
|
||||
PHB_ITEM pColor = hb_param( 4, HB_IT_NUMERIC );
|
||||
PHB_ITEM pSize = hb_param( 5, HB_IT_NUMERIC );
|
||||
PHB_ITEM pWidth = hb_param( 6, HB_IT_NUMERIC );
|
||||
|
||||
hb_gtGfxText( hb_itemGetNI(pTop),
|
||||
hb_itemGetNI(pLeft), cText, hb_itemGetNI(pColor),
|
||||
hb_itemGetNI(pSize), hb_itemGetNI(pWidth) );
|
||||
}
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
|
||||
/* NOTE: User programs should never call this layer directly! */
|
||||
|
||||
/* #define XWC_DEBUG */
|
||||
#include "gtxwc.h"
|
||||
|
||||
static HB_GT_FUNCS SuperTable;
|
||||
@@ -287,19 +288,26 @@ static char *rgb_colors[] = {
|
||||
};
|
||||
|
||||
static Atom s_atomDelWin;
|
||||
static Atom s_atomTimestamp;
|
||||
static Atom s_atomAtom;
|
||||
static Atom s_atomInteger;
|
||||
static Atom s_atomString;
|
||||
static Atom s_atomUTF8String;
|
||||
static Atom s_atomPrimary;
|
||||
static Atom s_atomSecondary;
|
||||
static Atom s_atomClipboard;
|
||||
static Atom s_atomTargets;
|
||||
static Atom s_atomCutBuffer0;
|
||||
static Atom s_atomText;
|
||||
static Atom s_atomCompoundText;
|
||||
|
||||
|
||||
typedef struct tag_rect
|
||||
{
|
||||
int top;
|
||||
int left;
|
||||
USHORT right;
|
||||
USHORT bottom;
|
||||
int right;
|
||||
int bottom;
|
||||
} RECT;
|
||||
|
||||
typedef struct tag_modifiers
|
||||
@@ -409,7 +417,15 @@ typedef struct tag_x_wnddef
|
||||
unsigned char * ClipboardData;
|
||||
ULONG ClipboardSize;
|
||||
Atom ClipboardRequest;
|
||||
Time ClipboardTime;
|
||||
BOOL ClipboardOwner;
|
||||
BOOL ClipboardRcvd;
|
||||
|
||||
/* Clipping */
|
||||
XRectangle ClipRect;
|
||||
|
||||
/* Keep last event time */
|
||||
Time lastEventTime;
|
||||
|
||||
} XWND_DEF, *PXWND_DEF;
|
||||
|
||||
@@ -424,7 +440,7 @@ static PXWND_DEF s_wnd = NULL;
|
||||
static BOOL s_fNoXServer = FALSE;
|
||||
|
||||
static BOOL s_cursorState = TRUE;
|
||||
static ULONG s_cursorBlinkRate = 100;
|
||||
static ULONG s_cursorBlinkRate = 350;
|
||||
static ULONG s_cursorStateTime = 0;
|
||||
|
||||
#if 1
|
||||
@@ -1933,10 +1949,18 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
evt->xexpose.y + evt->xexpose.height );
|
||||
break;
|
||||
|
||||
case NoExpose:
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: NoExpose\r\n" ); fflush(stdout);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case KeyPress:
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: KeyPress\r\n" ); fflush(stdout);
|
||||
#endif
|
||||
if( evt->xkey.time != CurrentTime )
|
||||
wnd->lastEventTime = evt->xkey.time;
|
||||
hb_gt_xwc_ProcessKey( wnd, &evt->xkey );
|
||||
break;
|
||||
|
||||
@@ -1944,6 +1968,8 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: KeyRelease\r\n" ); fflush(stdout);
|
||||
#endif
|
||||
if( evt->xkey.time != CurrentTime )
|
||||
wnd->lastEventTime = evt->xkey.time;
|
||||
out = XLookupKeysym( &evt->xkey, 0 );
|
||||
switch( out )
|
||||
{
|
||||
@@ -1970,6 +1996,9 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: MotionNotify\r\n" ); fflush(stdout);
|
||||
#endif
|
||||
if( evt->xmotion.time != CurrentTime )
|
||||
wnd->lastEventTime = evt->xmotion.time;
|
||||
|
||||
wnd->mouseCol = evt->xmotion.x / wnd->fontWidth;
|
||||
wnd->mouseRow = evt->xmotion.y / wnd->fontHeight;
|
||||
if( hb_gt_xwc_LastCharInInputQueue( wnd ) != K_MOUSEMOVE )
|
||||
@@ -1986,6 +2015,8 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: %s, button=%d\r\n", evt->type == ButtonPress ? "ButtonPress" : "ButtonRelease", button ); fflush(stdout);
|
||||
#endif
|
||||
if( evt->xbutton.time != CurrentTime )
|
||||
wnd->lastEventTime = evt->xbutton.time;
|
||||
if( button >= 0 && button < XWC_MAX_BUTTONS )
|
||||
{
|
||||
button = wnd->mouseButtonsMap[ button ] - 1;
|
||||
@@ -2040,6 +2071,12 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
wnd->keyModifiers.bShift = FALSE;
|
||||
break;
|
||||
|
||||
case FocusOut:
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: FocusOut\r\n" ); fflush(stdout);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ConfigureNotify:
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: ConfigureNotify\r\n" ); fflush(stdout);
|
||||
@@ -2051,7 +2088,7 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
|
||||
case ClientMessage:
|
||||
#ifdef XWC_DEBUG
|
||||
printf("Event: ClientMessage:%ld\r\n", evt->xclient.data.l[ 0 ]); fflush(stdout);
|
||||
printf( "Event: ClientMessage:%ld (%s)\r\n", evt->xclient.data.l[ 0 ], XGetAtomName(wnd->dpy, ( Atom ) evt->xclient.data.l[ 0 ]) ); fflush(stdout);
|
||||
#endif
|
||||
if( ( Atom ) evt->xclient.data.l[ 0 ] == s_atomDelWin )
|
||||
{
|
||||
@@ -2060,8 +2097,18 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
break;
|
||||
|
||||
case SelectionNotify:
|
||||
{
|
||||
Atom aNextRequest = None;
|
||||
#ifdef XWC_DEBUG
|
||||
printf("Event: SelectionNotify\r\n"); fflush(stdout);
|
||||
printf( "Event: SelectionNotify: selection=%ld (%s), property=%ld (%s), target=%ld (%s) => %ld (%s)\r\n",
|
||||
evt->xselection.selection,
|
||||
evt->xselection.selection == None ? "None" : XGetAtomName(wnd->dpy, evt->xselection.selection),
|
||||
evt->xselection.property,
|
||||
evt->xselection.property == None ? "None" : XGetAtomName(wnd->dpy, evt->xselection.property),
|
||||
evt->xselection.target,
|
||||
evt->xselection.target == None ? "None" : XGetAtomName(wnd->dpy, evt->xselection.target),
|
||||
wnd->ClipboardRequest,
|
||||
wnd->ClipboardRequest == None ? "None" : XGetAtomName(wnd->dpy, wnd->ClipboardRequest) ); fflush(stdout);
|
||||
#endif
|
||||
if( evt->xselection.property != None && wnd->ClipboardRequest )
|
||||
{
|
||||
@@ -2071,42 +2118,62 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
if( XGetTextProperty( wnd->dpy, wnd->window, &text,
|
||||
evt->xselection.property ) != 0 )
|
||||
{
|
||||
if( wnd->ClipboardRequest == s_atomUTF8String )
|
||||
if( evt->xselection.target == s_atomUTF8String && text.format == 8 )
|
||||
{
|
||||
nItem = hb_cdpUTF8StringLength( text.value, text.nitems );
|
||||
if( wnd->ClipboardData != NULL )
|
||||
hb_xfree( wnd->ClipboardData );
|
||||
wnd->ClipboardData = ( unsigned char * ) hb_xgrab( nItem + 1 );
|
||||
wnd->ClipboardSize = nItem;
|
||||
hb_cdpUTF8ToStrn( wnd->inCDP ? wnd->inCDP : wnd->hostCDP,
|
||||
text.value, text.nitems,
|
||||
hb_cdpUTF8ToStrn( wnd->hostCDP, text.value, text.nitems,
|
||||
wnd->ClipboardData, nItem + 1 );
|
||||
wnd->ClipboardTime = evt->xselection.time;
|
||||
wnd->ClipboardRcvd = TRUE;
|
||||
}
|
||||
else if( wnd->ClipboardRequest == s_atomString )
|
||||
else if( evt->xselection.target == s_atomString && text.format == 8 )
|
||||
{
|
||||
unsigned char cData;
|
||||
|
||||
if( wnd->ClipboardData != NULL )
|
||||
hb_xfree( wnd->ClipboardData );
|
||||
wnd->ClipboardData = ( unsigned char * ) hb_xgrab( text.nitems + 1 );
|
||||
memcpy( wnd->ClipboardData, text.value, text.nitems );
|
||||
if( wnd->inCDP && wnd->hostCDP && wnd->inCDP != wnd->hostCDP )
|
||||
hb_cdpnTranslate( ( char * ) wnd->ClipboardData, wnd->inCDP, wnd->hostCDP, text.nitems );
|
||||
wnd->ClipboardData[ text.nitems ] = '\0';
|
||||
wnd->ClipboardSize = text.nitems;
|
||||
wnd->ClipboardTime = evt->xselection.time;
|
||||
wnd->ClipboardRcvd = TRUE;
|
||||
}
|
||||
else if( evt->xselection.target == s_atomTargets && text.format == 32 )
|
||||
{
|
||||
Atom aValue;
|
||||
#ifdef XWC_DEBUG
|
||||
printf("text.nitems=%ld, text.format=%d\r\n", text.nitems, text.format); fflush(stdout);
|
||||
#endif
|
||||
for( nItem = 0; nItem < text.nitems; ++nItem )
|
||||
{
|
||||
switch( text.format )
|
||||
{
|
||||
case 8: cData = text.value[ nItem ]; break;
|
||||
case 16: cData = ( unsigned char ) ( ( unsigned short * ) text.value)[ nItem ]; break;
|
||||
case 32: cData = ( unsigned char ) ( ( unsigned int * ) text.value)[ nItem ]; break;
|
||||
default: cData = 0;
|
||||
}
|
||||
wnd->ClipboardData[ nItem ] = cData;
|
||||
aValue = ( ( unsigned int * ) text.value )[ nItem ];
|
||||
if( aValue == s_atomUTF8String )
|
||||
aNextRequest = s_atomUTF8String;
|
||||
else if( aValue == s_atomString && aNextRequest == None )
|
||||
aNextRequest = s_atomString;
|
||||
#ifdef XWC_DEBUG
|
||||
printf("%ld, %8lx (%s)\r\n", nItem, aValue, XGetAtomName(wnd->dpy, aValue));fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
wnd->ClipboardData[ nItem ] = '\0';
|
||||
wnd->ClipboardSize = nItem;
|
||||
}
|
||||
}
|
||||
}
|
||||
wnd->ClipboardRequest = 0;
|
||||
else if( wnd->ClipboardRequest == s_atomTargets )
|
||||
{
|
||||
aNextRequest = s_atomUTF8String;
|
||||
}
|
||||
else if( wnd->ClipboardRequest == s_atomUTF8String )
|
||||
{
|
||||
aNextRequest = s_atomString;
|
||||
}
|
||||
wnd->ClipboardRequest = aNextRequest;
|
||||
break;
|
||||
}
|
||||
|
||||
case SelectionRequest:
|
||||
{
|
||||
@@ -2114,14 +2181,44 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
XEvent respond;
|
||||
|
||||
#ifdef XWC_DEBUG
|
||||
printf("Event: SelectionRequest\r\n"); fflush(stdout);
|
||||
printf( "Event: SelectionRequest: %ld (%s)\r\n", req->target,
|
||||
XGetAtomName(wnd->dpy, req->target) ); fflush(stdout);
|
||||
#endif
|
||||
respond.xselection.property = req->property;
|
||||
if( req->target == s_atomString )
|
||||
|
||||
if ( req->target == s_atomTimestamp )
|
||||
{
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomString, 8, PropModeReplace,
|
||||
wnd->ClipboardData, wnd->ClipboardSize );
|
||||
s_atomInteger, 8 * sizeof( Time ), PropModeReplace,
|
||||
( unsigned char * ) &wnd->ClipboardTime, 1 );
|
||||
}
|
||||
else if ( req->target == s_atomTargets )
|
||||
{
|
||||
Atom aProp[] = { s_atomTimestamp, s_atomTargets,
|
||||
s_atomString, s_atomUTF8String,
|
||||
s_atomCompoundText, s_atomText };
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomAtom, 8 * sizeof( Atom ), PropModeReplace,
|
||||
( unsigned char * ) aProp, sizeof( aProp ) / sizeof( Atom ) );
|
||||
}
|
||||
else if( req->target == s_atomString )
|
||||
{
|
||||
if( wnd->inCDP && wnd->hostCDP && wnd->inCDP != wnd->hostCDP )
|
||||
{
|
||||
BYTE * pBuffer = ( BYTE * ) hb_xgrab( wnd->ClipboardSize + 1 );
|
||||
memcpy( pBuffer, wnd->ClipboardData, wnd->ClipboardSize + 1 );
|
||||
hb_cdpnTranslate( ( char * ) pBuffer, wnd->inCDP, wnd->hostCDP, wnd->ClipboardSize );
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomString, 8, PropModeReplace,
|
||||
pBuffer, wnd->ClipboardSize );
|
||||
hb_xfree( pBuffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomString, 8, PropModeReplace,
|
||||
wnd->ClipboardData, wnd->ClipboardSize );
|
||||
}
|
||||
}
|
||||
else if( req->target == s_atomUTF8String )
|
||||
{
|
||||
@@ -2131,19 +2228,10 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
|
||||
hb_cdpStrnToUTF8( cdp, wnd->ClipboardData, wnd->ClipboardSize, pBuffer );
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomString, 8, PropModeReplace,
|
||||
s_atomUTF8String, 8, PropModeReplace,
|
||||
pBuffer, ulLen );
|
||||
hb_xfree( pBuffer );
|
||||
}
|
||||
else if ( req->target == s_atomTargets )
|
||||
{
|
||||
Atom aProp[ 2 ];
|
||||
aProp[ 0 ] = s_atomUTF8String;
|
||||
aProp[ 1 ] = s_atomString;
|
||||
XChangeProperty( wnd->dpy, req->requestor, req->property,
|
||||
s_atomTargets, 32, PropModeReplace,
|
||||
( unsigned char * ) aProp, 2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
respond.xselection.property = None;
|
||||
@@ -2154,7 +2242,7 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
respond.xselection.requestor = req->requestor;
|
||||
respond.xselection.selection = req->selection;
|
||||
respond.xselection.target = req->target;
|
||||
respond.xselection.time = CurrentTime;
|
||||
respond.xselection.time = req->time;
|
||||
|
||||
XSendEvent( wnd->dpy, req->requestor, 0, 0, &respond );
|
||||
break;
|
||||
@@ -2162,11 +2250,19 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent *evt )
|
||||
|
||||
case SelectionClear:
|
||||
#ifdef XWC_DEBUG
|
||||
printf("Event: SelectionClear\r\n"); fflush(stdout);
|
||||
printf( "Event: SelectionClear\r\n" ); fflush(stdout);
|
||||
#endif
|
||||
wnd->ClipboardOwner = FALSE;
|
||||
break;
|
||||
|
||||
case PropertyNotify:
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: PropertyNotify\r\n" ); fflush(stdout);
|
||||
#endif
|
||||
if( evt->xproperty.time != CurrentTime )
|
||||
wnd->lastEventTime = evt->xproperty.time;
|
||||
break;
|
||||
|
||||
#ifdef XWC_DEBUG
|
||||
default:
|
||||
printf( "Event: #%d\r\n", evt->type ); fflush(stdout);
|
||||
@@ -2713,46 +2809,41 @@ static ULONG hb_gt_xwc_CurrentTime( void )
|
||||
static void hb_gt_xwc_ProcessMessages( PXWND_DEF wnd )
|
||||
{
|
||||
XEvent evt;
|
||||
ULONG ulCurrentTime = hb_gt_xwc_CurrentTime();
|
||||
|
||||
if( ulCurrentTime - s_cursorStateTime > s_cursorBlinkRate )
|
||||
if( s_cursorBlinkRate == 0 )
|
||||
{
|
||||
s_cursorState = !s_cursorState;
|
||||
s_cursorStateTime = ulCurrentTime;
|
||||
s_cursorState = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ULONG ulCurrentTime = hb_gt_xwc_CurrentTime();
|
||||
|
||||
if( ulCurrentTime - s_cursorStateTime > s_cursorBlinkRate )
|
||||
{
|
||||
s_cursorState = !s_cursorState;
|
||||
s_cursorStateTime = ulCurrentTime;
|
||||
}
|
||||
}
|
||||
|
||||
while( XEventsQueued( wnd->dpy, QueuedAfterFlush) )
|
||||
{
|
||||
XNextEvent( wnd->dpy, &evt );
|
||||
hb_gt_xwc_WndProc( wnd, &evt );
|
||||
}
|
||||
|
||||
hb_gt_xwc_UpdateSize( wnd );
|
||||
hb_gt_xwc_UpdateChr( wnd );
|
||||
hb_gt_xwc_UpdatePts( wnd );
|
||||
hb_gt_xwc_UpdateCursor( wnd );
|
||||
if( wnd->fDspTitle )
|
||||
{
|
||||
wnd->fDspTitle = FALSE;
|
||||
XStoreName( wnd->dpy, wnd->window, wnd->szTitle ? wnd->szTitle : "" );
|
||||
}
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* The even checking is repeated intentionaly because some operation
|
||||
* can be bufferd by XLIB until incomming events are checked
|
||||
*/
|
||||
while( XEventsQueued( wnd->dpy, QueuedAfterFlush) )
|
||||
do
|
||||
{
|
||||
XNextEvent( wnd->dpy, &evt );
|
||||
hb_gt_xwc_WndProc( wnd, &evt );
|
||||
while( XEventsQueued( wnd->dpy, QueuedAfterFlush ) )
|
||||
{
|
||||
XNextEvent( wnd->dpy, &evt );
|
||||
hb_gt_xwc_WndProc( wnd, &evt );
|
||||
}
|
||||
hb_gt_xwc_UpdateSize( wnd );
|
||||
hb_gt_xwc_UpdatePts( wnd );
|
||||
hb_gt_xwc_UpdateCursor( wnd );
|
||||
}
|
||||
hb_gt_xwc_UpdateSize( wnd );
|
||||
hb_gt_xwc_UpdatePts( wnd );
|
||||
hb_gt_xwc_UpdateCursor( wnd );
|
||||
#endif
|
||||
|
||||
XFlush( wnd->dpy );
|
||||
while( XEventsQueued( wnd->dpy, QueuedAfterFlush ) );
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
@@ -2885,6 +2976,8 @@ static PXWND_DEF hb_gt_xwc_CreateWndDef( void )
|
||||
wnd->keyModifiers.bAltGr = FALSE;
|
||||
wnd->keyModifiers.bShift = FALSE;
|
||||
|
||||
wnd->lastEventTime = CurrentTime;
|
||||
|
||||
return wnd;
|
||||
}
|
||||
|
||||
@@ -2915,11 +3008,19 @@ static BOOL hb_gt_xwc_ConnectX( PXWND_DEF wnd, BOOL fExit )
|
||||
hb_gt_xwc_MouseInit( wnd );
|
||||
|
||||
/* set atom identifiers for atom names we will use */
|
||||
s_atomDelWin = XInternAtom( wnd->dpy, "WM_DELETE_WINDOW", True );
|
||||
s_atomString = XInternAtom( wnd->dpy, "STRING", False );
|
||||
s_atomPrimary = XInternAtom( wnd->dpy, "PRIMARY", False );
|
||||
s_atomTargets = XInternAtom( wnd->dpy, "TARGETS", False );
|
||||
s_atomCutBuffer0 = XInternAtom( wnd->dpy, "CUT_BUFFER0", False );
|
||||
s_atomDelWin = XInternAtom( wnd->dpy, "WM_DELETE_WINDOW", True );
|
||||
s_atomTimestamp = XInternAtom( wnd->dpy, "TIMESTAMP", False );
|
||||
s_atomAtom = XInternAtom( wnd->dpy, "ATOM", False );
|
||||
s_atomInteger = XInternAtom( wnd->dpy, "INTEGER", False );
|
||||
s_atomString = XInternAtom( wnd->dpy, "STRING", False );
|
||||
s_atomUTF8String = XInternAtom( wnd->dpy, "UTF8_STRING", False );
|
||||
s_atomPrimary = XInternAtom( wnd->dpy, "PRIMARY", False );
|
||||
s_atomSecondary = XInternAtom( wnd->dpy, "SECONDARY", False );
|
||||
s_atomClipboard = XInternAtom( wnd->dpy, "CLIPBOARD", False );
|
||||
s_atomTargets = XInternAtom( wnd->dpy, "TARGETS", False );
|
||||
s_atomCutBuffer0 = XInternAtom( wnd->dpy, "CUT_BUFFER0", False );
|
||||
s_atomText = XInternAtom( wnd->dpy, "TEXT", False );
|
||||
s_atomCompoundText = XInternAtom( wnd->dpy, "COMPOUND_TEXT", False );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -3070,15 +3171,35 @@ static void hb_gt_xwc_Initialize( PXWND_DEF wnd )
|
||||
|
||||
static void hb_gt_xwc_SetSelection( PXWND_DEF wnd, char *szData, ULONG ulSize )
|
||||
{
|
||||
if( wnd->ClipboardOwner && ulSize == 0 )
|
||||
{
|
||||
XSetSelectionOwner( wnd->dpy, s_atomPrimary, None, wnd->ClipboardTime );
|
||||
XSetSelectionOwner( wnd->dpy, s_atomClipboard, None, wnd->ClipboardTime );
|
||||
}
|
||||
|
||||
if( wnd->ClipboardData != NULL )
|
||||
hb_xfree( wnd->ClipboardData );
|
||||
wnd->ClipboardData = ( unsigned char * ) hb_xgrab( ulSize + 1 );
|
||||
memcpy( wnd->ClipboardData, szData, ulSize );
|
||||
wnd->ClipboardData[ ulSize ] = '\0';
|
||||
wnd->ClipboardSize = ulSize;
|
||||
wnd->ClipboardTime = wnd->lastEventTime;
|
||||
wnd->ClipboardOwner = FALSE;
|
||||
|
||||
wnd->ClipboardOwner = TRUE;
|
||||
XSetSelectionOwner( wnd->dpy, s_atomPrimary, wnd->window, CurrentTime );
|
||||
if( ulSize > 0 )
|
||||
{
|
||||
XSetSelectionOwner( wnd->dpy, s_atomPrimary, wnd->window, wnd->ClipboardTime );
|
||||
if( XGetSelectionOwner( wnd->dpy, s_atomPrimary ) == wnd->window )
|
||||
{
|
||||
wnd->ClipboardOwner = TRUE;
|
||||
XSetSelectionOwner( wnd->dpy, s_atomClipboard, wnd->window, wnd->ClipboardTime );
|
||||
}
|
||||
else
|
||||
{
|
||||
char * cMsg = "Cannot set primary selection\r\n";
|
||||
hb_gt_OutErr( ( BYTE * ) cMsg, strlen( cMsg ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
@@ -3087,50 +3208,57 @@ static void hb_gt_xwc_RequestSelection( PXWND_DEF wnd )
|
||||
{
|
||||
if( !wnd->ClipboardOwner )
|
||||
{
|
||||
BOOL fRepeat = TRUE;
|
||||
wnd->ClipboardRequest = s_atomUTF8String;
|
||||
while( wnd->ClipboardRequest )
|
||||
Atom aRequest;
|
||||
int iConnFD = ConnectionNumber( wnd->dpy );
|
||||
struct timeval timeout;
|
||||
fd_set readfds;
|
||||
|
||||
timeout.tv_sec = 3;
|
||||
timeout.tv_usec = 0;
|
||||
|
||||
wnd->ClipboardRcvd = FALSE;
|
||||
wnd->ClipboardRequest = s_atomTargets;
|
||||
aRequest = None;
|
||||
|
||||
if( s_updateMode == XWC_ASYNC_UPDATE )
|
||||
s_iUpdateCounter = 150;
|
||||
|
||||
do
|
||||
{
|
||||
XConvertSelection( wnd->dpy, s_atomPrimary, wnd->ClipboardRequest,
|
||||
s_atomCutBuffer0, wnd->window, CurrentTime );
|
||||
if( aRequest != wnd->ClipboardRequest )
|
||||
{
|
||||
aRequest = wnd->ClipboardRequest;
|
||||
if( aRequest == None )
|
||||
break;
|
||||
#ifdef XWC_DEBUG
|
||||
printf("XConvertSelection: %ld (%s)\r\n", aRequest,
|
||||
XGetAtomName(wnd->dpy, aRequest)); fflush(stdout);
|
||||
#endif
|
||||
XConvertSelection( wnd->dpy, s_atomPrimary, aRequest,
|
||||
s_atomCutBuffer0, wnd->window, wnd->lastEventTime );
|
||||
}
|
||||
|
||||
if( s_updateMode == XWC_ASYNC_UPDATE )
|
||||
{
|
||||
s_iUpdateCounter = 100;
|
||||
while( s_iUpdateCounter && wnd->ClipboardRequest )
|
||||
sleep( 1 );
|
||||
if( s_iUpdateCounter == 0 )
|
||||
break;
|
||||
sleep( 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int iConnFD = ConnectionNumber( wnd->dpy );
|
||||
struct timeval timeout;
|
||||
fd_set readfds;
|
||||
|
||||
timeout.tv_sec = 0;
|
||||
timeout.tv_usec = 2500000;
|
||||
|
||||
for( ;; )
|
||||
hb_gt_xwc_ProcessMessages( wnd );
|
||||
if( !wnd->ClipboardRcvd && wnd->ClipboardRequest == aRequest )
|
||||
{
|
||||
hb_gt_xwc_ProcessMessages( wnd );
|
||||
if( !wnd->ClipboardRequest )
|
||||
break;
|
||||
|
||||
FD_ZERO( &readfds );
|
||||
FD_SET( iConnFD, &readfds );
|
||||
if( select( iConnFD + 1, &readfds, NULL, NULL, &timeout ) <= 0 )
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( wnd->ClipboardRequest )
|
||||
{
|
||||
wnd->ClipboardRequest = 0;
|
||||
}
|
||||
else if( fRepeat )
|
||||
{
|
||||
fRepeat = FALSE;
|
||||
wnd->ClipboardRequest = s_atomString;
|
||||
}
|
||||
}
|
||||
while( !wnd->ClipboardRcvd && wnd->ClipboardRequest != None );
|
||||
|
||||
wnd->ClipboardRequest = None;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3454,6 +3582,7 @@ static BOOL hb_gt_xwc_Info( int iType, PHB_GT_INFO pInfo )
|
||||
case GTI_SCREENWIDTH:
|
||||
pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_wnd->width );
|
||||
break;
|
||||
|
||||
case GTI_SCREENHEIGHT:
|
||||
pInfo->pResult = hb_itemPutNI( pInfo->pResult, s_wnd->height );
|
||||
break;
|
||||
@@ -3571,6 +3700,145 @@ static BOOL hb_gt_xwc_Info( int iType, PHB_GT_INFO pInfo )
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static int hb_gt_xwc_gfx_Primitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
|
||||
{
|
||||
int iRet = 1;
|
||||
XColor color;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_xwc_gfx_Primitive(%d, %d, %d, %d, %d, %d)", iType, iTop, iLeft, iBottom, iRight, iColor ) );
|
||||
|
||||
hb_gt_xwc_Initialize( s_wnd );
|
||||
hb_gt_Refresh();
|
||||
|
||||
switch( iType )
|
||||
{
|
||||
case GFX_ACQUIRESCREEN:
|
||||
/* TODO: */
|
||||
break;
|
||||
|
||||
case GFX_RELEASESCREEN:
|
||||
/* TODO: */
|
||||
break;
|
||||
|
||||
case GFX_MAKECOLOR:
|
||||
/* TODO: */
|
||||
color.red = iTop * 256;
|
||||
color.green = iLeft * 256;
|
||||
color.blue = iBottom * 256;
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
hb_gt_xwc_AllocColor( s_wnd, &color );
|
||||
iRet = color.pixel;
|
||||
break;
|
||||
|
||||
case GFX_CLIPTOP:
|
||||
iRet = s_wnd->ClipRect.y;
|
||||
break;
|
||||
|
||||
case GFX_CLIPLEFT:
|
||||
iRet = s_wnd->ClipRect.x;
|
||||
break;
|
||||
|
||||
case GFX_CLIPBOTTOM:
|
||||
iRet = s_wnd->ClipRect.y + s_wnd->ClipRect.height - 1;
|
||||
break;
|
||||
|
||||
case GFX_CLIPRIGHT:
|
||||
iRet = s_wnd->ClipRect.x + s_wnd->ClipRect.width - 1;
|
||||
break;
|
||||
|
||||
case GFX_SETCLIP:
|
||||
s_wnd->ClipRect.y = iTop;
|
||||
s_wnd->ClipRect.x = iLeft;
|
||||
s_wnd->ClipRect.width = iBottom;
|
||||
s_wnd->ClipRect.height = iRight;
|
||||
XSetClipRectangles( s_wnd->dpy, s_wnd->gc, 0, 0, &s_wnd->ClipRect, 1, YXBanded );
|
||||
break;
|
||||
|
||||
case GFX_DRAWINGMODE:
|
||||
iRet = GFX_MODE_SOLID;
|
||||
break;
|
||||
|
||||
case GFX_GETPIXEL:
|
||||
/* TODO: */
|
||||
iRet = 0;
|
||||
break;
|
||||
|
||||
case GFX_PUTPIXEL:
|
||||
XSetForeground( s_wnd->dpy, s_wnd->gc, iBottom );
|
||||
XDrawPoint( s_wnd->dpy, s_wnd->drw, s_wnd->gc, iLeft, iTop );
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, iLeft, iTop, iLeft, iTop );
|
||||
break;
|
||||
|
||||
case GFX_LINE:
|
||||
XSetForeground( s_wnd->dpy, s_wnd->gc, iColor );
|
||||
XDrawLine( s_wnd->dpy, s_wnd->drw, s_wnd->gc,
|
||||
iLeft, iTop, iRight, iBottom );
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, iLeft, iTop, iRight, iBottom );
|
||||
break;
|
||||
|
||||
case GFX_RECT:
|
||||
XSetForeground( s_wnd->dpy, s_wnd->gc, iColor );
|
||||
XDrawRectangle( s_wnd->dpy, s_wnd->drw, s_wnd->gc,
|
||||
iLeft, iTop, iRight - iLeft, iBottom - iTop );
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, iLeft, iTop, iRight, iBottom );
|
||||
break;
|
||||
|
||||
case GFX_FILLEDRECT:
|
||||
XSetForeground( s_wnd->dpy, s_wnd->gc, iColor );
|
||||
XFillRectangle( s_wnd->dpy, s_wnd->drw, s_wnd->gc,
|
||||
iLeft, iTop, iRight - iLeft, iBottom - iTop );
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, iLeft, iTop, iRight, iBottom );
|
||||
break;
|
||||
|
||||
case GFX_CIRCLE:
|
||||
XSetForeground( s_wnd->dpy, s_wnd->gc, iRight );
|
||||
XDrawArc( s_wnd->dpy, s_wnd->drw, s_wnd->gc,
|
||||
iLeft, iTop, iBottom, iBottom, 0, 360*64 );
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, iLeft - iBottom, iTop - iBottom,
|
||||
iLeft + iBottom, iTop + iBottom );
|
||||
break;
|
||||
|
||||
case GFX_FILLEDCIRCLE:
|
||||
XSetForeground( s_wnd->dpy, s_wnd->gc, iRight );
|
||||
XFillArc( s_wnd->dpy, s_wnd->drw, s_wnd->gc,
|
||||
iLeft, iTop, iBottom, iBottom, 0, 360*64 );
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, iLeft - iBottom, iTop - iBottom,
|
||||
iLeft + iBottom, iTop + iBottom );
|
||||
break;
|
||||
|
||||
case GFX_ELLIPSE:
|
||||
XSetForeground( s_wnd->dpy, s_wnd->gc, iColor );
|
||||
XDrawArc( s_wnd->dpy, s_wnd->drw, s_wnd->gc,
|
||||
iLeft, iTop, iRight, iBottom, 0, 360*64 );
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, iLeft - iRight, iTop - iBottom,
|
||||
iLeft + iRight, iTop + iBottom );
|
||||
break;
|
||||
|
||||
case GFX_FILLEDELLIPSE:
|
||||
XSetForeground( s_wnd->dpy, s_wnd->gc, iColor );
|
||||
XFillArc( s_wnd->dpy, s_wnd->drw, s_wnd->gc,
|
||||
iLeft, iTop, iRight, iBottom, 0, 360*64 );
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, iLeft - iRight, iTop - iBottom,
|
||||
iLeft + iRight, iTop + iBottom );
|
||||
break;
|
||||
|
||||
case GFX_FLOODFILL:
|
||||
/* TODO: */
|
||||
hb_gt_xwc_InvalidatePts( s_wnd, 0, 0, s_wnd->width, s_wnd->height );
|
||||
break;
|
||||
|
||||
default:
|
||||
return HB_GTSUPER_GFXPRIMITIVE( iType, iTop, iLeft, iBottom, iRight, iColor );
|
||||
}
|
||||
|
||||
if ( hb_gt_DispCount() == 0 )
|
||||
{
|
||||
hb_gt_xwc_RealRefresh();
|
||||
}
|
||||
|
||||
return iRet;
|
||||
}
|
||||
|
||||
/* *********************************************************************** */
|
||||
|
||||
static void hb_gt_xwc_Redraw( int iRow, int iCol, int iSize )
|
||||
@@ -3646,6 +3914,8 @@ static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable )
|
||||
pFuncTable->MouseButtonState = hb_gt_xwc_mouse_ButtonState;
|
||||
pFuncTable->MouseCountButton = hb_gt_xwc_mouse_CountButton;
|
||||
|
||||
pFuncTable->GfxPrimitive = hb_gt_xwc_gfx_Primitive;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
#include "hbapiitm.h"
|
||||
#include "hbapierr.h"
|
||||
#include "inkey.ch"
|
||||
#include "error.ch"
|
||||
#include "hbgfxdef.ch"
|
||||
|
||||
#ifndef HB_CDP_SUPPORT_OFF
|
||||
#include "hbapicdp.h"
|
||||
|
||||
@@ -1920,6 +1920,28 @@ static int hb_gt_def_MouseReadKey( int iEventMask )
|
||||
return iKey;
|
||||
}
|
||||
|
||||
static int hb_gt_def_GfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( iType );
|
||||
HB_SYMBOL_UNUSED( iTop );
|
||||
HB_SYMBOL_UNUSED( iLeft );
|
||||
HB_SYMBOL_UNUSED( iBottom );
|
||||
HB_SYMBOL_UNUSED( iRight );
|
||||
HB_SYMBOL_UNUSED( iColor );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hb_gt_def_GfxText( int iTop, int iLeft, char * szText, int iColor, int iSize, int iWidth )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( iTop );
|
||||
HB_SYMBOL_UNUSED( iLeft );
|
||||
HB_SYMBOL_UNUSED( szText );
|
||||
HB_SYMBOL_UNUSED( iColor );
|
||||
HB_SYMBOL_UNUSED( iSize );
|
||||
HB_SYMBOL_UNUSED( iWidth );
|
||||
}
|
||||
|
||||
static void hb_gt_def_WhoCares( void * pCargo )
|
||||
{
|
||||
HB_SYMBOL_UNUSED( pCargo );
|
||||
@@ -2029,6 +2051,8 @@ static HB_GT_FUNCS gtCoreFunc =
|
||||
MouseButtonPressed : hb_gt_def_MouseButtonPressed ,
|
||||
MouseButtonReleased : hb_gt_def_MouseButtonReleased ,
|
||||
MouseReadKey : hb_gt_def_MouseReadKey ,
|
||||
GfxPrimitive : hb_gt_def_GfxPrimitive ,
|
||||
GfxText : hb_gt_def_GfxText ,
|
||||
WhoCares : hb_gt_def_WhoCares
|
||||
};
|
||||
#else
|
||||
@@ -2133,6 +2157,8 @@ static HB_GT_FUNCS gtCoreFunc =
|
||||
hb_gt_def_MouseButtonPressed ,
|
||||
hb_gt_def_MouseButtonReleased ,
|
||||
hb_gt_def_MouseReadKey ,
|
||||
hb_gt_def_GfxPrimitive ,
|
||||
hb_gt_def_GfxText ,
|
||||
hb_gt_def_WhoCares
|
||||
};
|
||||
#endif
|
||||
@@ -2633,6 +2659,16 @@ int hb_mouse_ReadKey( int iEventMask )
|
||||
return gtCoreFunc.MouseReadKey( iEventMask );
|
||||
}
|
||||
|
||||
int hb_gt_GfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
|
||||
{
|
||||
return gtCoreFunc.GfxPrimitive( iType, iTop, iLeft, iBottom, iRight, iColor );
|
||||
}
|
||||
|
||||
void hb_gt_GfxText( int iTop, int iLeft, char * szText, int iColor, int iSize, int iWidth )
|
||||
{
|
||||
gtCoreFunc.GfxText( iTop, iLeft, szText, iColor, iSize, iWidth );
|
||||
}
|
||||
|
||||
void hb_gt_WhoCares( void * pCargo )
|
||||
{
|
||||
gtCoreFunc.WhoCares( pCargo );
|
||||
|
||||
@@ -4579,7 +4579,7 @@ static void hb_vmSFrame( PHB_SYMB pSym ) /* sets the statics frame for a fu
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_vmSFrame(%p)", pSym));
|
||||
|
||||
/* _INITSTATICS is now the statics frame. Statics() changed it! */
|
||||
hb_stack.iStatics = pSym->value.iStaticsBase; /* pSym is { "$_INITSTATICS", HB_FS_INIT | HB_FS_EXIT, _INITSTATICS } for each PRG */
|
||||
hb_stack.iStatics = pSym->value.iStaticsBase; /* pSym is { "$_INITSTATICS", HB_FS_INITEXIT, _INITSTATICS } for each PRG */
|
||||
}
|
||||
|
||||
static void hb_vmStatics( PHB_SYMB pSym, USHORT uiStatics ) /* initializes the global aStatics array or redimensionates it */
|
||||
@@ -5697,7 +5697,7 @@ static void hb_vmReleaseLocalSymbols( void )
|
||||
}
|
||||
|
||||
/* This calls all _INITSTATICS functions defined in the application.
|
||||
* We are using a special symbol's scope ( HB_FS_INIT | HB_FS_EXIT ) to mark
|
||||
* We are using a special symbol's scope HB_FS_INITEXIT to mark
|
||||
* this function. These two bits cannot be marked at the same
|
||||
* time for normal user defined functions.
|
||||
*/
|
||||
@@ -5709,7 +5709,7 @@ static void hb_vmDoInitStatics( void )
|
||||
|
||||
do
|
||||
{
|
||||
if( ( pLastSymbols->hScope & ( HB_FS_INIT | HB_FS_EXIT ) ) == ( HB_FS_INIT | HB_FS_EXIT ) )
|
||||
if( ( pLastSymbols->hScope & HB_FS_INITEXIT ) == HB_FS_INITEXIT )
|
||||
{
|
||||
USHORT ui;
|
||||
|
||||
@@ -5717,7 +5717,7 @@ static void hb_vmDoInitStatics( void )
|
||||
{
|
||||
HB_SYMBOLSCOPE scope = ( pLastSymbols->pModuleSymbols + ui )->scope.value & ( HB_FS_EXIT | HB_FS_INIT );
|
||||
|
||||
if( scope == ( HB_FS_INIT | HB_FS_EXIT ) )
|
||||
if( scope == HB_FS_INITEXIT )
|
||||
{
|
||||
hb_vmPushSymbol( pLastSymbols->pModuleSymbols + ui );
|
||||
hb_vmPushNil();
|
||||
|
||||
101
harbour/tests/gfx.prg
Normal file
101
harbour/tests/gfx.prg
Normal file
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* $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
|
||||
@@ -541,3 +541,8 @@ PINLINE hb_compInlineAdd( char * szFunName )
|
||||
HB_SYMBOL_UNUSED( szFunName );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void hb_compParserStop( void )
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user