From 7f83dce5832d53aa14f5226f16f92ba732870920 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 14 Apr 2011 01:23:15 +0000 Subject: [PATCH] 2011-04-13 18:20 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbqt/qtcore/qth/HBQEvents.qth * contrib/hbqt/qtcore/qth/HBQSlots.qth ! Commented out tracelogs. * contrib/hbqt/gtqtc/gtqtc.cpp * contrib/hbqt/gtqtc/gtqtc.h ! Improved: object handelling. * contrib/hbxbp/xbpgeneric.prg ! Minor. * contrib/hbxbp/xbpcrt.prg + Functional: the class is functional to an extent. Example code in reply-message to this commit on dev-list. NOTE: now this seems possible that Harbour can have a pure GUI along with a console inside it to pave a way for seemless migration to GUI world. See example code. --- harbour/ChangeLog | 19 +++ harbour/contrib/hbqt/gtqtc/gtqtc.cpp | 17 ++- harbour/contrib/hbqt/gtqtc/gtqtc.h | 32 ++--- harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth | 6 +- harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth | 6 +- harbour/contrib/hbxbp/xbpcrt.prg | 116 ++++++++---------- harbour/contrib/hbxbp/xbpgeneric.prg | 44 ++++--- 7 files changed, 119 insertions(+), 121 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 46903c936b..34cb4e146f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,25 @@ The license applies to all entries newer than 2009-04-28. */ +2011-04-13 18:20 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbqt/qtcore/qth/HBQEvents.qth + * contrib/hbqt/qtcore/qth/HBQSlots.qth + ! Commented out tracelogs. + + * contrib/hbqt/gtqtc/gtqtc.cpp + * contrib/hbqt/gtqtc/gtqtc.h + ! Improved: object handelling. + + * contrib/hbxbp/xbpgeneric.prg + ! Minor. + * contrib/hbxbp/xbpcrt.prg + + Functional: the class is functional to an extent. + Example code in reply-message to this commit on dev-list. + + NOTE: now this seems possible that Harbour can have a + pure GUI along with a console inside it to pave a + way for seemless migration to GUI world. See example code. + 2011-04-13 03:13 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbmk2/hbmk2.prg + Added TOFIX. There is a build error caused by gpm, when diff --git a/harbour/contrib/hbqt/gtqtc/gtqtc.cpp b/harbour/contrib/hbqt/gtqtc/gtqtc.cpp index aeb66b60d9..98152022b9 100644 --- a/harbour/contrib/hbqt/gtqtc/gtqtc.cpp +++ b/harbour/contrib/hbqt/gtqtc/gtqtc.cpp @@ -707,7 +707,7 @@ static int hb_gt_wvt_ReadKey( PHB_GT pGT, int iEventMask ) int c = 0; bool fKey = HB_FALSE; - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_ReadKey(%p,%d)", pGT, iEventMask ) ); + //HB_TRACE( HB_TR_ALWAYS, ( "hb_gt_wvt_ReadKey(%p,%d)", pGT, iEventMask ) ); HB_SYMBOL_UNUSED( iEventMask ); /* we ignore the eventmask! */ pWVT = HB_GTWVT_GET( pGT ); @@ -1033,10 +1033,13 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_WINTITLE: if( pWVT->qWnd ) { - //pInfo->pResult = hb_itemPutCPtr2( pInfo->pResult, pWVT->qWnd->windowTitle().toLatin1().data() ); - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, pWVT->qWnd->windowTitle().toLatin1().data() ); + pInfo->pResult = hb_itemPutStrUTF8( pInfo->pResult, pWVT->qWnd->windowTitle().toUtf8().data() ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) - pWVT->qWnd->setWindowTitle( hb_itemGetCPtr( pInfo->pNewVal ) ); + { + void * pText01 = NULL; + pWVT->qWnd->setWindowTitle( hb_itemGetStrUTF8( pInfo->pNewVal, &pText01, NULL ) ); + hb_strfree( pText01 ); + } } break; @@ -1303,11 +1306,13 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) break; case HB_GTI_WIDGET: - pInfo->pResult = hb_itemPutPtr( pInfo->pResult, pWVT->qWnd ); + //pInfo->pResult = hb_itemPutPtrGC( pInfo->pResult, hbqt_gcAllocate_QWidget( pWVT->qWnd, false ) ); + pInfo->pResult = hb_itemNew( hbqt_create_objectGC( hbqt_gcAllocate_QMainWindow( pWVT->qWnd, false ), "HB_QMAINWINDOW" ) ); break; case HB_GTI_DRAWINGAREA: - pInfo->pResult = hb_itemPutPtr( pInfo->pResult, pWVT->qWnd->_drawingArea ); + //pInfo->pResult = hb_itemPutPtrGC( pInfo->pResult, hbqt_gcAllocate_QMainWindow( pWVT->qWnd->_drawingArea, false ) ); + pInfo->pResult = hb_itemNew( hbqt_create_objectGC( hbqt_gcAllocate_QWidget( pWVT->qWnd->_drawingArea, false ), "HB_QWIDGET" ) ); break; default: diff --git a/harbour/contrib/hbqt/gtqtc/gtqtc.h b/harbour/contrib/hbqt/gtqtc/gtqtc.h index fe37dbce77..a91c531557 100644 --- a/harbour/contrib/hbqt/gtqtc/gtqtc.h +++ b/harbour/contrib/hbqt/gtqtc/gtqtc.h @@ -79,6 +79,9 @@ #include "inkey.ch" #include "hbvm.h" #include "hbthread.h" +#include "hbapistr.h" + +#include "hbqt.h" #define WVT_CHAR_QUEUE_SIZE 4096 // 128 #define WVT_MAX_TITLE_SIZE 128 @@ -143,32 +146,8 @@ #define K_SH_ENTER K_ENTER /* Shift-Enter == Enter */ #endif -#if 0 -#ifndef WM_MOUSEWHEEL -# define WM_MOUSEWHEEL 0x020A -#endif -#ifndef WM_ENTERSIZEMOVE -# define WM_ENTERSIZEMOVE 561 -#endif -#ifndef WM_EXITSIZEMOVE -# define WM_EXITSIZEMOVE 562 -#endif - -#ifndef SWP_DEFERERASE -# define SWP_DEFERERASE 0x2000 -#endif -#ifndef SW_NORMAL -# define SW_NORMAL 1 -#endif -#ifndef SC_MAXIMIZE -# define SC_MAXIMIZE 0xF030 -#endif -#endif - #define SYS_EV_MARK 1000 -void hb_ToOutDebug( const char * sTraceMsg, ... ); - /*----------------------------------------------------------------------*/ class MainWindow; @@ -342,6 +321,11 @@ typedef struct #define HB_GTI_WIDGET 2001 #define HB_GTI_DRAWINGAREA 2002 +HB_EXTERN_BEGIN +extern void * hbqt_gcAllocate_QWidget( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QMainWindow( void * pObj, bool bNew ); +HB_EXTERN_END + /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth b/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth index 459c857b76..e918cc7fa3 100644 --- a/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth +++ b/harbour/contrib/hbqt/qtcore/qth/HBQEvents.qth @@ -42,7 +42,7 @@ HB_FUNC( QT_HBQEVENTS ) static HB_GARBAGE_FUNC( hbqt_gcMark_HBQEvents ) { HBQT_GC_T_HBQEvents * p = ( HBQT_GC_T_HBQEvents * ) Cargo; - HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcMark_HBQEvents cargo=%p", (void*)Cargo ) ); + //HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcMark_HBQEvents cargo=%p", (void*)Cargo ) ); if( p ) { if( p->ph ) @@ -52,11 +52,11 @@ static HB_GARBAGE_FUNC( hbqt_gcMark_HBQEvents ) for( i = t_slots->listBlock.size() - 1; i >= 0 ; i-- ) { -// HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcMark_HBQEvents marking %d", i ) ); + //HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcMark_HBQEvents marking %d", i ) ); if( t_slots->listBlock[ i ] != NULL ) { hb_gcMark( t_slots->listBlock[ i ] ); -// HB_TRACE( HB_TR_ALWAYS, ( " MARKED %d ptr=%p", i, (void *)t_slots->listBlock.at( i ) ) ); + //HB_TRACE( HB_TR_ALWAYS, ( " MARKED %d ptr=%p", i, (void *)t_slots->listBlock.at( i ) ) ); } } } diff --git a/harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth b/harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth index 0299cb51e1..420daa8015 100644 --- a/harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth +++ b/harbour/contrib/hbqt/qtcore/qth/HBQSlots.qth @@ -31,7 +31,7 @@ New = HB_GARBAGE_FUNC( hbqt_gcMark_HBQSlots ) { HBQT_GC_T_HBQSlots * p = ( HBQT_GC_T_HBQSlots * ) Cargo; - HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcMark_HBQSlots cargo=%p", Cargo ) ); + //HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcMark_HBQSlots cargo=%p", Cargo ) ); if( p ) { if( p->ph ) @@ -41,11 +41,11 @@ HB_GARBAGE_FUNC( hbqt_gcMark_HBQSlots ) for( i = t_slots->listBlock.size() - 1; i >= 0 ; i-- ) { - HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcMark_HBQSlots marking %d", i ) ); + //HB_TRACE( HB_TR_ALWAYS, ( "hbqt_gcMark_HBQSlots marking %d", i ) ); if( t_slots->listBlock[ i ] != NULL ) { hb_gcMark( t_slots->listBlock[ i ] ); - HB_TRACE( HB_TR_ALWAYS, ( " MARKED %d ptr=%p", i, (void *)t_slots->listBlock.at( i ) ) ); + //HB_TRACE( HB_TR_ALWAYS, ( " MARKED %d ptr=%p", i, (void *)t_slots->listBlock.at( i ) ) ); } } } diff --git a/harbour/contrib/hbxbp/xbpcrt.prg b/harbour/contrib/hbxbp/xbpcrt.prg index b60cda53d8..141896a37a 100644 --- a/harbour/contrib/hbxbp/xbpcrt.prg +++ b/harbour/contrib/hbxbp/xbpcrt.prg @@ -72,6 +72,10 @@ #include "xbp.ch" #include "appevent.ch" +#define HB_GTI_WIDGET 2001 +#define HB_GTI_DRAWINGAREA 2002 +#define HB_GTI_DISABLE 2003 + /*----------------------------------------------------------------------*/ CLASS XbpCrt INHERIT XbpWindow, XbpPartHandler @@ -251,6 +255,9 @@ CLASS XbpCrt INHERIT XbpWindow, XbpPartHandler METHOD dragLeave( xParam ) SETGET METHOD dragDrop( xParam, xParam1 ) SETGET + DATA nFlags + DATA oMDI + ENDCLASS /*----------------------------------------------------------------------*/ @@ -261,18 +268,10 @@ METHOD XbpCrt:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::xbpWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - if hb_isArray( aPos ) - ::aPos := aPos - endif - if hb_isArray( aSize ) - ::aSize := aSize - endif - if hb_isArray( aPresParams ) - ::aPresParams := aPresParams - endif - if hb_isLogical( lVisible ) - ::visible := lVisible - endif + ::resizeMode := 0 + ::mouseMode := 0 + + ::drawingArea := XbpDrawingArea():new( self, , {0,0}, ::aSize, , .t. ) RETURN Self @@ -281,70 +280,57 @@ METHOD XbpCrt:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /*----------------------------------------------------------------------*/ METHOD XbpCrt:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - //Local lRowCol := .T. + + ::XbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::maxRow := ::aSize[ 1 ] ::maxCol := ::aSize[ 2 ] - ::XbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + hb_gtReload( "QTC" ) + ::pGT := hb_gtSelect() - if ::lModal - ::pGT := hb_gtCreate( "QTC" ) - ::pGTp := hb_gtSelect( ::pGT ) - else - hb_gtReload( "QTC" ) - ::pGT := hb_gtSelect() - endif -#if 0 - IF ::lModal - ::style := WS_POPUP + WS_CAPTION + WS_SYSMENU - IF ::resizable - ::style += WS_MINIMIZEBOX + WS_MAXIMIZEBOX + WS_THICKFRAME - ENDIF + /* CreateWindow() be forced to execute */ + ? " " + + ::oWidget := hb_gtInfo( HB_GTI_WIDGET ) + ::drawingArea:oWidget := hb_gtInfo( HB_GTI_DRAWINGAREA ) + + ::oWidget:setWindowTitle( ::title ) + + hb_gtInfo( HB_GTI_CLOSABLE , ::closable ) + hb_gtInfo( HB_GTI_RESIZABLE, ::resizable ) + + //hb_gtInfo( HB_GTI_RESIZEMODE, iif( ::resizeMode == HB_GTI_RESIZEMODE_ROWS, HB_GTI_RESIZEMODE_ROWS, HB_GTI_RESIZEMODE_FONT ) ) + + IF ! empty( ::toolTipText ) + ::oWidget:setTooltip( ::toolTipText ) + ENDIF + IF hb_isChar( ::icon ) + ::oWidget:setWindowIcon( ::icon ) ENDIF - hb_gtInfo( HB_GTI_RESIZABLE, ::resizable ) + IF ::lModal + hb_gtInfo( HB_GTI_DISABLE, ::pGTp ) + ENDIF + IF ::visible + ::oWidget:show() + ::lHasInputFocus := .t. + ENDIF + + + ::nFlags := ::oWidget:windowFlags() + IF __objGetClsName( ::oParent ) == "XBPDRAWINGAREA" + ::setParent( ::oParent ) + ENDIF + + + // HB_GtInfo( HB_GTI_NOTIFIERBLOCK, {|nEvent, ...| ::notifier( nEvent, ... ) } ) + +#if 0 hb_gtInfo( HB_GTI_PRESPARAMS, { ::exStyle, ::style, ::aPos[ 1 ], ::aPos[ 2 ], ; ::maxRow+1, ::maxCol+1, ::pGTp, .F., lRowCol, HB_WNDTYPE_CRT } ) hb_gtInfo( HB_GTI_SETFONT, { ::fontName, ::fontHeight, ::fontWidth } ) #endif - IF hb_isNumeric( ::icon ) - hb_gtInfo( HB_GTI_ICONRES, ::icon ) - ELSE - IF ( ".png" $ lower( ::icon ) ) - hb_gtInfo( HB_GTI_ICONFILE, ::icon ) - ELSE - hb_gtInfo( HB_GTI_ICONRES, ::icon ) - ENDIF - ENDIF - - /* CreateWindow() be forced to execute */ - ? " " - //::hWnd := hb_gtInfo( HB_GTI_SPEC, HB_GTS_WINDOWHANDLE ) - - hb_gtInfo( HB_GTI_CLOSABLE , ::closable ) - hb_gtInfo( HB_GTI_WINTITLE , ::title ) - hb_gtInfo( HB_GTI_RESIZEMODE, if( ::resizeMode == HB_GTI_RESIZEMODE_ROWS, HB_GTI_RESIZEMODE_ROWS, HB_GTI_RESIZEMODE_FONT ) ) - - - IF ::lModal - //hb_gtInfo( HB_GTI_DISABLE, ::pGTp ) - ENDIF - - IF ::visible - //hb_gtInfo( HB_GTI_SPEC, HB_GTS_SHOWWINDOW, .t. ) - ::lHasInputFocus := .t. - ENDIF - - /* Drawing Area of oCrt will point to itself */ - ::drawingArea := XbpDrawingArea():new():create( self, , ::aPos, ::aSize, , .t. ) - - HB_GtInfo( HB_GTI_NOTIFIERBLOCK, {|nEvent, ...| ::notifier( nEvent, ... ) } ) - - /* Not working yet. need to investigate how I have implemented it. */ - if !empty( ::toolTipText ) - //Wvt_SetTooltip( ::toolTipText ) - endif RETURN Self diff --git a/harbour/contrib/hbxbp/xbpgeneric.prg b/harbour/contrib/hbxbp/xbpgeneric.prg index 0e8a4d98e2..9eb8d65bd9 100644 --- a/harbour/contrib/hbxbp/xbpgeneric.prg +++ b/harbour/contrib/hbxbp/xbpgeneric.prg @@ -172,26 +172,6 @@ FUNCTION PostAppEvent( nEvent, mp1, mp2, oXbp ) RETURN .T. -/*----------------------------------------------------------------------*/ -/* - * Internal to the XbpParts, must NOT be called from application code - */ -FUNCTION SetAppEvent( nEvent, mp1, mp2, oXbp ) - - IF ++t_nEventIn > EVENT_BUFFER - t_nEventIn := 1 - ENDIF - -//HB_TRACE( HB_TR_DEBUG, 0, "SetAppEvent ... ", hb_threadId(), nEvent, xbeP_Paint ) - - t_events[ t_nEventIn, 1 ] := nEvent - t_events[ t_nEventIn, 2 ] := mp1 - t_events[ t_nEventIn, 3 ] := mp2 - t_events[ t_nEventIn, 4 ] := oXbp - -//HB_TRACE( HB_TR_DEBUG, 1, "SetAppEvent ... ", hb_threadId(), nEvent ) - RETURN nil - /*----------------------------------------------------------------------*/ FUNCTION LastAppEvent( mp1, mp2, oXbp, nThreadID ) @@ -228,6 +208,30 @@ FUNCTION NextAppEvent( mp1, mp2, oXbp ) RETURN nEvent +/*----------------------------------------------------------------------*/ +/* + * Internal to the XbpParts, must NOT be called from application code + */ +FUNCTION SetAppEvent( nEvent, mp1, mp2, oXbp ) + + IF empty( t_events ) + hbxbp_InitializeEventBuffer() + ENDIF + + IF ++t_nEventIn > EVENT_BUFFER + t_nEventIn := 1 + ENDIF + +//HB_TRACE( HB_TR_ALWAYS, "SetAppEvent ... ", t_nEventIn, nEvent, oXbp:className(), oXbp:title ) + + t_events[ t_nEventIn, 1 ] := nEvent + t_events[ t_nEventIn, 2 ] := mp1 + t_events[ t_nEventIn, 3 ] := mp2 + t_events[ t_nEventIn, 4 ] := iif( empty( oXbp ), t_oAppWindow, oXbp ) + +//HB_TRACE( HB_TR_DEBUG, 1, "SetAppEvent ... ", hb_threadId(), nEvent ) + RETURN nil + /*----------------------------------------------------------------------*/ FUNCTION AppEvent( mp1, mp2, oXbp, nTimeout )