2013-03-04 12:58 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/contrib/hbnetio/netiosrv.c
* harbour/contrib/hbnetio/hbnetio.hbx
* harbour/contrib/hbnetio/readme.txt
+ added new PRG function:
NETIO_SERVERTIMEOUT( <pConnectionSocket> [, <nTimeOut>] )
-> [<nTimeOut>]
This function allows to set maximal time for client request.
It can be useful if NETIO server is used only for short time
connections in which client makes few requests and then
disconnects.
Clients keeping longer connections without any request will
be disconnected automatically. It means that in some cases
it's possible to create server which works efficiently in
single thread mode without MT HVM.
* harbour/contrib/hbnetio/netiomt.prg
* restored formatting
* harbour/src/rtl/gtxwc/gtxwc.c
! fixed getting window position in HB_GTI_SETPOS_XY and
HB_GTI_SETPOS_ROWCOL.
Warnings:
1) some WMs may report window upper left coroner inside
the border and some other ones border upper left coroner.
2) Setting window position by this function strictly depends
on WMs behavior and in most cases code like:
aPos := hb_gtInfo( HB_GTI_SETPOS_XY )
hb_gtInfo( HB_GTI_SETPOS_XY, aPos )
will move the window because most of WMs used to add some
offsets to XMoveWindow() cords.
! fixed GFX line and rect cords with reverted parameters
! fixed GFX circle and eclipse parameters - it is documented that
3-rd parameter in hb_gfxCircle() is radius (also 3-rd and 4-th
in hb_gfxEllipse()) but it was implemented as diameter.
Warning: incompatible, existing code have to be updated.
! fixed GFX circle and eclipse parameters to correctly map updated
region.
; Thanks to Rolf for reporting problems with GTXWC
* harbour/src/rtl/gtwvt/gtwvt.c
! fixed rect size - it was one pixel smaller then in other GTs
Now rect cords are interpreted in the same way as in BOX command
and functions.
! fixed GFX circle and eclipse parameters - it is documented that
3-rd parameter in hb_gfxCircle() is radius (also 3-rd and 4-th
in hb_gfxEllipse()) but it was implemented as diameter.
Warning: incompatible, existing code have to be updated.
* harbour/contrib/gtalleg/gtallegd.c
! fixed GFX line and rect cords with reverted parameters
+ harbour/tests/gfx2.prg
* added test code to check basic GFX cord settings.
This commit is contained in:
@@ -10,6 +10,60 @@
|
||||
* Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment
|
||||
*/
|
||||
|
||||
2013-03-04 12:58 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* harbour/contrib/hbnetio/netiosrv.c
|
||||
* harbour/contrib/hbnetio/hbnetio.hbx
|
||||
* harbour/contrib/hbnetio/readme.txt
|
||||
+ added new PRG function:
|
||||
NETIO_SERVERTIMEOUT( <pConnectionSocket> [, <nTimeOut>] )
|
||||
-> [<nTimeOut>]
|
||||
This function allows to set maximal time for client request.
|
||||
It can be useful if NETIO server is used only for short time
|
||||
connections in which client makes few requests and then
|
||||
disconnects.
|
||||
Clients keeping longer connections without any request will
|
||||
be disconnected automatically. It means that in some cases
|
||||
it's possible to create server which works efficiently in
|
||||
single thread mode without MT HVM.
|
||||
* harbour/contrib/hbnetio/netiomt.prg
|
||||
* restored formatting
|
||||
|
||||
* harbour/src/rtl/gtxwc/gtxwc.c
|
||||
! fixed getting window position in HB_GTI_SETPOS_XY and
|
||||
HB_GTI_SETPOS_ROWCOL.
|
||||
Warnings:
|
||||
1) some WMs may report window upper left coroner inside
|
||||
the border and some other ones border upper left coroner.
|
||||
2) Setting window position by this function strictly depends
|
||||
on WMs behavior and in most cases code like:
|
||||
aPos := hb_gtInfo( HB_GTI_SETPOS_XY )
|
||||
hb_gtInfo( HB_GTI_SETPOS_XY, aPos )
|
||||
will move the window because most of WMs used to add some
|
||||
offsets to XMoveWindow() cords.
|
||||
! fixed GFX line and rect cords with reverted parameters
|
||||
! fixed GFX circle and eclipse parameters - it is documented that
|
||||
3-rd parameter in hb_gfxCircle() is radius (also 3-rd and 4-th
|
||||
in hb_gfxEllipse()) but it was implemented as diameter.
|
||||
Warning: incompatible, existing code have to be updated.
|
||||
! fixed GFX circle and eclipse parameters to correctly map updated
|
||||
region.
|
||||
; Thanks to Rolf for reporting problems with GTXWC
|
||||
|
||||
* harbour/src/rtl/gtwvt/gtwvt.c
|
||||
! fixed rect size - it was one pixel smaller then in other GTs
|
||||
Now rect cords are interpreted in the same way as in BOX command
|
||||
and functions.
|
||||
! fixed GFX circle and eclipse parameters - it is documented that
|
||||
3-rd parameter in hb_gfxCircle() is radius (also 3-rd and 4-th
|
||||
in hb_gfxEllipse()) but it was implemented as diameter.
|
||||
Warning: incompatible, existing code have to be updated.
|
||||
|
||||
* harbour/contrib/gtalleg/gtallegd.c
|
||||
! fixed GFX line and rect cords with reverted parameters
|
||||
|
||||
+ harbour/tests/gfx2.prg
|
||||
* added test code to check basic GFX cord settings.
|
||||
|
||||
2013-03-03 15:30 UTC+0100 Viktor Szakats (harbour syenar.net)
|
||||
* ChangeLog.txt
|
||||
! fixed mistyped dates in entries
|
||||
|
||||
@@ -902,9 +902,15 @@ static HB_BOOL hb_gt_alleg_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
|
||||
/* ********** Graphics API ********** */
|
||||
|
||||
#define hb_gfx_cord( t, l, b, r, tmp ) \
|
||||
do { \
|
||||
if( l > r ) { tmp = r; r = l; l = tmp; } \
|
||||
if( t > b ) { tmp = b; b = t; t = tmp; } \
|
||||
} while( 0 )
|
||||
|
||||
static int hb_gt_alleg_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
|
||||
{
|
||||
int iRet = 1;
|
||||
int iRet = 1, iTmp;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_alleg_gfx_Primitive(%p,%d,%d,%d,%d,%d,%d)", pGT, iType, iTop, iLeft, iBottom, iRight, iColor ) );
|
||||
|
||||
@@ -942,6 +948,7 @@ static int hb_gt_alleg_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft
|
||||
break;
|
||||
|
||||
case HB_GFX_SETCLIP:
|
||||
hb_gfx_cord( iTop, iLeft, iBottom, iRight, iTmp );
|
||||
al_set_clip( s_bmp, iLeft, iTop, iRight, iBottom );
|
||||
s_CLIP.iTop = iTop;
|
||||
s_CLIP.iLeft = iLeft;
|
||||
@@ -973,10 +980,12 @@ static int hb_gt_alleg_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft
|
||||
else
|
||||
al_draw_line( s_bmp, iLeft, iTop, iRight, iBottom, iColor );
|
||||
al_release_bitmap( s_bmp );
|
||||
hb_gfx_cord( iTop, iLeft, iBottom, iRight, iTmp );
|
||||
GT_UPD_GFXRECT( iTop, iLeft, iBottom, iRight );
|
||||
break;
|
||||
|
||||
case HB_GFX_RECT:
|
||||
hb_gfx_cord( iTop, iLeft, iBottom, iRight, iTmp );
|
||||
al_acquire_bitmap( s_bmp );
|
||||
al_draw_rect( s_bmp, iLeft, iTop, iRight, iBottom, iColor );
|
||||
al_release_bitmap( s_bmp );
|
||||
@@ -984,6 +993,7 @@ static int hb_gt_alleg_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft
|
||||
break;
|
||||
|
||||
case HB_GFX_FILLEDRECT:
|
||||
hb_gfx_cord( iTop, iLeft, iBottom, iRight, iTmp );
|
||||
al_acquire_bitmap( s_bmp );
|
||||
al_draw_rect_fill( s_bmp, iLeft, iTop, iRight, iBottom, iColor );
|
||||
al_release_bitmap( s_bmp );
|
||||
|
||||
@@ -41,6 +41,7 @@ DYNAMIC netio_RPC
|
||||
DYNAMIC netio_RPCFilter
|
||||
DYNAMIC netio_Server
|
||||
DYNAMIC netio_ServerStop
|
||||
DYNAMIC netio_ServerTimeOut
|
||||
DYNAMIC netio_SrvSendData
|
||||
DYNAMIC netio_SrvSendItem
|
||||
DYNAMIC netio_SrvStatus
|
||||
|
||||
@@ -62,8 +62,8 @@
|
||||
#include "error.ch"
|
||||
|
||||
FUNCTION netio_MTServer( nPort, cIfAddr, cRootDir, xRPC, ;
|
||||
cPasswd, nCompressLevel, nStrategy, ;
|
||||
sSrvFunc )
|
||||
cPasswd, nCompressLevel, nStrategy, ;
|
||||
sSrvFunc )
|
||||
|
||||
LOCAL pListenSocket, lRPC
|
||||
LOCAL oError
|
||||
@@ -89,8 +89,8 @@ FUNCTION netio_MTServer( nPort, cIfAddr, cRootDir, xRPC, ;
|
||||
pListenSocket := netio_Listen( nPort, cIfAddr, cRootDir, lRPC )
|
||||
IF ! Empty( pListenSocket )
|
||||
hb_threadDetach( hb_threadStart( @netio_srvloop(), pListenSocket, ;
|
||||
xRPC, sSrvFunc, ;
|
||||
cPasswd, nCompressLevel, nStrategy ) )
|
||||
xRPC, sSrvFunc, ;
|
||||
cPasswd, nCompressLevel, nStrategy ) )
|
||||
ENDIF
|
||||
ELSE
|
||||
oError := ErrorNew()
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
* NETIO_SERVER( <pConnectionSocket> ) -> NIL
|
||||
* NETIO_SERVERSTOP( <pListenSocket> | <pConnectionSocket> [, <lStop>] )
|
||||
* -> NIL
|
||||
* NETIO_SERVERTIMEOUT( <pConnectionSocket> [, <nTimeOut>] ) -> [<nTimeOut>]
|
||||
* NETIO_RPC( <pListenSocket> | <pConnectionSocket> [, <lEnable>] )
|
||||
* -> <lPrev>
|
||||
* NETIO_RPCFILTER( <pConnectionSocket>,
|
||||
@@ -85,6 +86,7 @@
|
||||
#include "hbvm.h"
|
||||
#include "hbstack.h"
|
||||
#include "hbthread.h"
|
||||
#include "hbdate.h"
|
||||
#include "netio.h"
|
||||
|
||||
|
||||
@@ -107,6 +109,7 @@ typedef struct _HB_CONSRV
|
||||
PHB_FILE fileTable[ NETIO_FILES_MAX ];
|
||||
int filesCount;
|
||||
int firstFree;
|
||||
int timeout;
|
||||
HB_BOOL stop;
|
||||
HB_BOOL rpc;
|
||||
HB_BOOL login;
|
||||
@@ -346,6 +349,7 @@ static PHB_CONSRV s_consrvNew( HB_SOCKET connsd, const char * szRootPath, HB_BOO
|
||||
|
||||
conn->sd = connsd;
|
||||
conn->rpc = rpc;
|
||||
conn->timeout = -1;
|
||||
if( szRootPath )
|
||||
{
|
||||
hb_strncpy( conn->rootPath, szRootPath, sizeof( conn->rootPath ) - 1 );
|
||||
@@ -358,8 +362,11 @@ static PHB_CONSRV s_consrvNew( HB_SOCKET connsd, const char * szRootPath, HB_BOO
|
||||
static long s_srvRecvAll( PHB_CONSRV conn, void * buffer, long len )
|
||||
{
|
||||
HB_BYTE * ptr = ( HB_BYTE * ) buffer;
|
||||
HB_MAXUINT end_timer;
|
||||
long lRead = 0, l;
|
||||
|
||||
end_timer = conn->timeout > 0 ? hb_dateMilliSeconds() + conn->timeout : 0;
|
||||
|
||||
while( lRead < len && ! conn->stop )
|
||||
{
|
||||
if( conn->zstream )
|
||||
@@ -369,7 +376,8 @@ static long s_srvRecvAll( PHB_CONSRV conn, void * buffer, long len )
|
||||
if( l <= 0 )
|
||||
{
|
||||
if( hb_socketGetError() != HB_SOCKET_ERR_TIMEOUT ||
|
||||
hb_vmRequestQuery() != 0 )
|
||||
hb_vmRequestQuery() != 0 ||
|
||||
( end_timer != 0 && end_timer <= hb_dateMilliSeconds() ) )
|
||||
break;
|
||||
}
|
||||
else
|
||||
@@ -560,6 +568,20 @@ HB_FUNC( NETIO_SERVERSTOP )
|
||||
}
|
||||
}
|
||||
|
||||
/* NETIO_SERVERTIMEOUT( <pConnectionSocket> [, <nTimeOut>] ) -> [<nTimeOut>]
|
||||
*/
|
||||
HB_FUNC( NETIO_SERVERTIMEOUT )
|
||||
{
|
||||
PHB_CONSRV conn = s_consrvParam( 1 );
|
||||
|
||||
if( conn )
|
||||
{
|
||||
hb_retni( conn->timeout );
|
||||
if( HB_ISNUM( 2 ) )
|
||||
conn->timeout = hb_parni( 2 );
|
||||
}
|
||||
}
|
||||
|
||||
/* NETIO_LISTEN( [<nPort>], [<cIfAddr>], [<cRootDir>], [<lRPC>] )
|
||||
* -> <pListenSocket> | NIL
|
||||
*/
|
||||
|
||||
@@ -146,6 +146,7 @@ Server side functions:
|
||||
NETIO_RPCFILTER( <pConnectionSocket>,
|
||||
<sFuncSym> | <hValue> | NIL ) -> NIL
|
||||
NETIO_SERVERSTOP( <pListenSocket> | <pConnectionSocket> [, <lStop>] ) -> NIL
|
||||
NETIO_SERVERTIMEOUT( <pConnectionSocket> [, <nTimeOut>] ) -> [<nTimeOut>]
|
||||
NETIO_MTSERVER( [<nPort>], [<cIfAddr>], [<cRootDir>],
|
||||
[<xRPC> | <sFuncSym> | <hValue>],
|
||||
[<cPasswd>], [<nCompressionLevel>], [<nStrategy>],
|
||||
|
||||
@@ -3065,6 +3065,7 @@ static int hb_gt_wvt_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
HDC hdc;
|
||||
HPEN hPen, hOldPen;
|
||||
HBRUSH hBrush, hOldBrush;
|
||||
RECT r;
|
||||
int iRet = 0;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_gfx_Primitive(%p,%d,%d,%d,%d,%d,%d)", pGT, iType, iTop, iLeft, iBottom, iRight, iColor ) );
|
||||
@@ -3106,13 +3107,10 @@ static int hb_gt_wvt_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
break;
|
||||
|
||||
case HB_GFX_RECT:
|
||||
{
|
||||
RECT r;
|
||||
|
||||
r.left = iLeft;
|
||||
r.top = iTop;
|
||||
r.right = iRight;
|
||||
r.bottom = iBottom;
|
||||
r.left = HB_MIN( iLeft, iRight );
|
||||
r.top = HB_MIN( iTop, iBottom );
|
||||
r.right = HB_MAX( iLeft, iRight ) + 1;
|
||||
r.bottom = HB_MAX( iTop, iBottom ) + 1;
|
||||
|
||||
SetGFXContext( iColor );
|
||||
|
||||
@@ -3120,11 +3118,16 @@ static int hb_gt_wvt_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
|
||||
ClearGFXContext();
|
||||
break;
|
||||
}
|
||||
|
||||
case HB_GFX_FILLEDRECT:
|
||||
SetGFXContext( iColor );
|
||||
|
||||
iRet = Rectangle( hdc, iLeft, iTop, iRight, iBottom ) ? 1 : 0;
|
||||
r.left = HB_MIN( iLeft, iRight );
|
||||
r.top = HB_MIN( iTop, iBottom );
|
||||
r.right = HB_MAX( iLeft, iRight ) + 1;
|
||||
r.bottom = HB_MAX( iTop, iBottom ) + 1;
|
||||
|
||||
iRet = Rectangle( hdc, r.left, r.top, r.right, r.bottom ) ? 1 : 0;
|
||||
|
||||
ClearGFXContext();
|
||||
break;
|
||||
@@ -3132,7 +3135,7 @@ static int hb_gt_wvt_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
case HB_GFX_CIRCLE:
|
||||
SetGFXContext( iRight );
|
||||
|
||||
iRet = Arc( hdc, iLeft - iBottom / 2, iTop - iBottom / 2, iLeft + iBottom / 2, iTop + iBottom / 2, 0, 0, 0, 0 ) ? 1 : 0;
|
||||
iRet = Arc( hdc, iLeft - iBottom, iTop - iBottom, iLeft + iBottom + 1, iTop + iBottom + 1, 0, 0, 0, 0 ) ? 1 : 0;
|
||||
|
||||
ClearGFXContext();
|
||||
break;
|
||||
@@ -3140,7 +3143,7 @@ static int hb_gt_wvt_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
case HB_GFX_FILLEDCIRCLE:
|
||||
SetGFXContext( iRight );
|
||||
|
||||
iRet = Ellipse( hdc, iLeft - iBottom / 2, iTop - iBottom / 2, iLeft + iBottom / 2, iTop + iBottom / 2 ) ? 1 : 0;
|
||||
iRet = Ellipse( hdc, iLeft - iBottom, iTop - iBottom, iLeft + iBottom + 1, iTop + iBottom + 1 ) ? 1 : 0;
|
||||
|
||||
ClearGFXContext();
|
||||
break;
|
||||
@@ -3148,7 +3151,7 @@ static int hb_gt_wvt_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
case HB_GFX_ELLIPSE:
|
||||
SetGFXContext( iColor );
|
||||
|
||||
iRet = Arc( hdc, iLeft - iRight / 2, iTop - iBottom / 2, iLeft + iRight / 2, iTop + iBottom / 2, 0, 0, 0, 0 ) ? 1 : 0;
|
||||
iRet = Arc( hdc, iLeft - iRight, iTop - iBottom, iLeft + iRight + 1, iTop + iBottom + 1, 0, 0, 0, 0 ) ? 1 : 0;
|
||||
|
||||
ClearGFXContext();
|
||||
break;
|
||||
@@ -3156,7 +3159,7 @@ static int hb_gt_wvt_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
case HB_GFX_FILLEDELLIPSE:
|
||||
SetGFXContext( iColor );
|
||||
|
||||
iRet = Ellipse( hdc, iLeft - iRight / 2, iTop - iBottom / 2, iLeft + iRight / 2, iTop + iBottom / 2 ) ? 1 : 0;
|
||||
iRet = Ellipse( hdc, iLeft - iRight, iTop - iBottom, iLeft + iRight, iTop + iBottom ) ? 1 : 0;
|
||||
|
||||
ClearGFXContext();
|
||||
break;
|
||||
|
||||
@@ -3135,6 +3135,8 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent * evt )
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: CreateNotify\r\n" ); fflush( stdout );
|
||||
#endif
|
||||
wnd->iNewPosX = evt->xcreatewindow.x;
|
||||
wnd->iNewPosY = evt->xcreatewindow.y;
|
||||
break;
|
||||
|
||||
case MappingNotify:
|
||||
@@ -3167,8 +3169,10 @@ static void hb_gt_xwc_WndProc( PXWND_DEF wnd, XEvent * evt )
|
||||
#ifdef XWC_DEBUG
|
||||
printf( "Event: ConfigureNotify\r\n" ); fflush( stdout );
|
||||
#endif
|
||||
wnd->newWidth = evt->xconfigure.width;
|
||||
wnd->newHeight = evt->xconfigure.height;
|
||||
wnd->iNewPosX = evt->xconfigure.x;
|
||||
wnd->iNewPosY = evt->xconfigure.y;
|
||||
wnd->newWidth = evt->xconfigure.width;
|
||||
wnd->newHeight = evt->xconfigure.height;
|
||||
wnd->fWinResize = HB_TRUE;
|
||||
break;
|
||||
|
||||
@@ -4594,6 +4598,7 @@ static void hb_gt_xwc_CreateWindow( PXWND_DEF wnd )
|
||||
wnd->fontWidth * wnd->cols,
|
||||
wnd->fontHeight * wnd->rows,
|
||||
0, blackColor, blackColor );
|
||||
XSelectInput( wnd->dpy, wnd->window, XWC_STD_MASK );
|
||||
wnd->gc = XCreateGC( wnd->dpy, wnd->window, 0, NULL );
|
||||
|
||||
/* Line width 2 */
|
||||
@@ -4622,7 +4627,6 @@ static void hb_gt_xwc_CreateWindow( PXWND_DEF wnd )
|
||||
/* Request WM to deliver destroy event */
|
||||
XSetWMProtocols( wnd->dpy, wnd->window, &s_atomDelWin, 1 );
|
||||
|
||||
XSelectInput( wnd->dpy, wnd->window, XWC_STD_MASK );
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
wnd->im = XOpenIM( wnd->dpy, NULL, NULL, NULL );
|
||||
if( wnd->im )
|
||||
@@ -5243,26 +5247,31 @@ static HB_BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
case HB_GTI_SETPOS_XY:
|
||||
case HB_GTI_SETPOS_ROWCOL:
|
||||
{
|
||||
int x = 0, y = 0;
|
||||
int x = wnd->iNewPosX, y = wnd->iNewPosY;
|
||||
|
||||
/*
|
||||
if( wnd->window )
|
||||
{
|
||||
XWindowAttributes wndAttr;
|
||||
if( XGetWindowAttributes( wnd->dpy, wnd->window, &wndAttr ) )
|
||||
{
|
||||
if( iType == HB_GTI_SETPOS_ROWCOL )
|
||||
{
|
||||
x = wndAttr.y / wnd->fontHeight;
|
||||
y = wndAttr.x / wnd->fontWidth;
|
||||
}
|
||||
else
|
||||
Window wndChild;
|
||||
if( ! XTranslateCoordinates( wnd->dpy, wnd->window, wndAttr.root,
|
||||
wndAttr.x, wndAttr.y, &x, &y,
|
||||
&wndChild ) )
|
||||
{
|
||||
x = wndAttr.x;
|
||||
y = wndAttr.y;
|
||||
}
|
||||
if( iType == HB_GTI_SETPOS_ROWCOL )
|
||||
{
|
||||
iVal = x;
|
||||
x = y / wnd->fontHeight;
|
||||
y = iVal / wnd->fontWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
if( ! pInfo->pResult )
|
||||
pInfo->pResult = hb_itemNew( NULL );
|
||||
hb_arrayNew( pInfo->pResult, 2 );
|
||||
@@ -5288,9 +5297,9 @@ static HB_BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
|
||||
if( iType == HB_GTI_SETPOS_ROWCOL )
|
||||
{
|
||||
int c = y;
|
||||
iVal = y;
|
||||
y = x * wnd->fontHeight;
|
||||
x = c * wnd->fontWidth;
|
||||
x = iVal * wnd->fontWidth;
|
||||
}
|
||||
if( wnd->window )
|
||||
{
|
||||
@@ -5361,10 +5370,16 @@ static HB_BOOL hb_gt_xwc_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
|
||||
return HB_TRUE;
|
||||
}
|
||||
|
||||
#define hb_gfx_cord( t, l, b, r, tmp ) \
|
||||
do { \
|
||||
if( l > r ) { tmp = r; r = l; l = tmp; } \
|
||||
if( t > b ) { tmp = b; b = t; t = tmp; } \
|
||||
} while( 0 )
|
||||
|
||||
static int hb_gt_xwc_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor )
|
||||
{
|
||||
PXWND_DEF wnd;
|
||||
int iRet = 1;
|
||||
int iRet = 1, iTmp;
|
||||
XColor color;
|
||||
|
||||
HB_TRACE( HB_TR_DEBUG, ( "hb_gt_xwc_gfx_Primitive(%p,%d,%d,%d,%d,%d,%d)", pGT, iType, iTop, iLeft, iBottom, iRight, iColor ) );
|
||||
@@ -5445,10 +5460,12 @@ static int hb_gt_xwc_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
XDrawLine( wnd->dpy, wnd->drw, wnd->gc,
|
||||
iLeft, iTop, iRight, iBottom );
|
||||
HB_XWC_XLIB_UNLOCK();
|
||||
hb_gfx_cord( iTop, iLeft, iBottom, iRight, iTmp );
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft, iTop, iRight, iBottom );
|
||||
break;
|
||||
|
||||
case HB_GFX_RECT:
|
||||
hb_gfx_cord( iTop, iLeft, iBottom, iRight, iTmp );
|
||||
HB_XWC_XLIB_LOCK();
|
||||
XSetForeground( wnd->dpy, wnd->gc, iColor );
|
||||
XDrawRectangle( wnd->dpy, wnd->drw, wnd->gc,
|
||||
@@ -5458,6 +5475,7 @@ static int hb_gt_xwc_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
break;
|
||||
|
||||
case HB_GFX_FILLEDRECT:
|
||||
hb_gfx_cord( iTop, iLeft, iBottom, iRight, iTmp );
|
||||
HB_XWC_XLIB_LOCK();
|
||||
XSetForeground( wnd->dpy, wnd->gc, iColor );
|
||||
XFillRectangle( wnd->dpy, wnd->drw, wnd->gc,
|
||||
@@ -5467,42 +5485,56 @@ static int hb_gt_xwc_gfx_Primitive( PHB_GT pGT, int iType, int iTop, int iLeft,
|
||||
break;
|
||||
|
||||
case HB_GFX_CIRCLE:
|
||||
iTop -= iBottom;
|
||||
iLeft -= iBottom;
|
||||
iBottom <<= 1;
|
||||
HB_XWC_XLIB_LOCK();
|
||||
XSetForeground( wnd->dpy, wnd->gc, iRight );
|
||||
XDrawArc( wnd->dpy, wnd->drw, wnd->gc,
|
||||
iLeft, iTop, iBottom, iBottom, 0, 360*64 );
|
||||
iLeft, iTop, iBottom, iBottom, 0, 360 * 64 );
|
||||
HB_XWC_XLIB_UNLOCK();
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft - iBottom, iTop - iBottom,
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft, iTop,
|
||||
iLeft + iBottom, iTop + iBottom );
|
||||
break;
|
||||
|
||||
case HB_GFX_FILLEDCIRCLE:
|
||||
iTop -= iBottom;
|
||||
iLeft -= iBottom;
|
||||
iBottom <<= 1;
|
||||
HB_XWC_XLIB_LOCK();
|
||||
XSetForeground( wnd->dpy, wnd->gc, iRight );
|
||||
XFillArc( wnd->dpy, wnd->drw, wnd->gc,
|
||||
iLeft, iTop, iBottom, iBottom, 0, 360*64 );
|
||||
iLeft, iTop, iBottom, iBottom, 0, 360 * 64 );
|
||||
HB_XWC_XLIB_UNLOCK();
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft - iBottom, iTop - iBottom,
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft, iTop,
|
||||
iLeft + iBottom, iTop + iBottom );
|
||||
break;
|
||||
|
||||
case HB_GFX_ELLIPSE:
|
||||
iTop -= iBottom;
|
||||
iLeft -= iRight;
|
||||
iBottom <<= 1;
|
||||
iRight <<= 1;
|
||||
HB_XWC_XLIB_LOCK();
|
||||
XSetForeground( wnd->dpy, wnd->gc, iColor );
|
||||
XDrawArc( wnd->dpy, wnd->drw, wnd->gc,
|
||||
iLeft, iTop, iRight, iBottom, 0, 360*64 );
|
||||
iLeft, iTop, iRight, iBottom, 0, 360 * 64 );
|
||||
HB_XWC_XLIB_UNLOCK();
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft - iRight, iTop - iBottom,
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft, iTop,
|
||||
iLeft + iRight, iTop + iBottom );
|
||||
break;
|
||||
|
||||
case HB_GFX_FILLEDELLIPSE:
|
||||
iTop -= iBottom;
|
||||
iLeft -= iRight;
|
||||
iBottom <<= 1;
|
||||
iRight <<= 1;
|
||||
HB_XWC_XLIB_LOCK();
|
||||
XSetForeground( wnd->dpy, wnd->gc, iColor );
|
||||
XFillArc( wnd->dpy, wnd->drw, wnd->gc,
|
||||
iLeft, iTop, iRight, iBottom, 0, 360*64 );
|
||||
iLeft, iTop, iRight, iBottom, 0, 360 * 64 );
|
||||
HB_XWC_XLIB_UNLOCK();
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft - iRight, iTop - iBottom,
|
||||
hb_gt_xwc_InvalidatePts( wnd, iLeft, iTop,
|
||||
iLeft + iRight, iTop + iBottom );
|
||||
break;
|
||||
|
||||
|
||||
92
harbour/tests/gfx2.prg
Normal file
92
harbour/tests/gfx2.prg
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* demonstration/test code for GFX operations
|
||||
*
|
||||
* Copyright 2013 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
|
||||
* www - http://harbour-project.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbgtinfo.ch"
|
||||
#include "hbgfx.ch"
|
||||
|
||||
#if defined( __PLATFORM__WINDOWS )
|
||||
REQUEST HB_GT_WVT_DEFAULT
|
||||
#elif defined( __PLATFORM__UNIX )
|
||||
REQUEST HB_GT_XWC_DEFAULT
|
||||
#endif
|
||||
|
||||
PROCEDURE Main()
|
||||
|
||||
LOCAL nRed, nGreen, nBlue
|
||||
|
||||
#if defined( __HBSCRIPT__HBSHELL )
|
||||
# if defined( __PLATFORM__WINDOWS )
|
||||
hbshell_gtSelect( "GTWVT" )
|
||||
# elif defined( __PLATFORM__UNIX )
|
||||
hbshell_gtSelect( "GTXWC" )
|
||||
# endif
|
||||
#endif
|
||||
|
||||
? hb_gtVersion()
|
||||
IF ! hb_gtInfo( HB_GTI_ISGRAPHIC )
|
||||
? "You are using a non graphics capable gt:"
|
||||
QUIT
|
||||
ENDIF
|
||||
|
||||
// SetMode( 30, 80 )
|
||||
|
||||
nRed := hb_gfxMakeColor( 200, 32, 32 )
|
||||
nGreen := hb_gfxMakeColor( 32, 200, 32 )
|
||||
nBlue := hb_gfxMakeColor( 32, 32, 200 )
|
||||
|
||||
hb_gfxLine( 100, 300, 200, 400, nRed )
|
||||
WAIT
|
||||
hb_gfxLine( 200, 300, 100, 400, nBlue )
|
||||
WAIT
|
||||
hb_gfxLine( 100, 420, 200, 320, nGreen )
|
||||
WAIT
|
||||
hb_gfxLine( 200, 420, 100, 320, nGreen )
|
||||
WAIT
|
||||
hb_gfxRect( 100, 300, 200, 420, nRed )
|
||||
WAIT
|
||||
hb_gfxRect( 90, 290, 210, 430, nBlue )
|
||||
WAIT
|
||||
hb_gfxLine( 100, 450, 100, 550, nRed )
|
||||
hb_gfxLine( 100, 550, 200, 550, nRed )
|
||||
hb_gfxLine( 200, 550, 200, 450, nRed )
|
||||
hb_gfxLine( 200, 450, 100, 450, nRed )
|
||||
WAIT
|
||||
hb_gfxRect( 100, 450, 200, 550, nGreen )
|
||||
WAIT
|
||||
|
||||
hb_gfxFilledRect( 220, 300, 320, 400, nRed )
|
||||
WAIT
|
||||
hb_gfxRect( 219, 449, 321, 551, nRed )
|
||||
WAIT
|
||||
hb_gfxFilledRect( 320, 550, 220, 450, nGreen )
|
||||
WAIT
|
||||
hb_gfxRect( 230, 310, 310, 390, nGreen )
|
||||
WAIT
|
||||
hb_gfxCircle( 270, 350, 40, nBlue )
|
||||
WAIT
|
||||
hb_gfxFilledCircle( 270, 500, 50, nBlue )
|
||||
WAIT
|
||||
|
||||
hb_gfxRect( 329, 299, 391, 501, nRed )
|
||||
hb_gfxFilledRect( 330, 300, 390, 500, nBlue )
|
||||
WAIT
|
||||
hb_gfxFilledEllipse( 360, 400, 30, 100, nGreen )
|
||||
WAIT
|
||||
hb_gfxEllipse( 360, 400, 15, 50, nRed )
|
||||
WAIT
|
||||
|
||||
hb_gfxRect( 0, 0, hb_gtInfo( HB_GTI_SCREENHEIGHT ) - 1, ;
|
||||
hb_gtInfo( HB_GTI_SCREENWIDTH ) - 1, nGreen )
|
||||
WAIT
|
||||
|
||||
RETURN
|
||||
Reference in New Issue
Block a user