From d69236b9583c322d9dc611fe7041d83a634ca440 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 11 Sep 2012 23:37:10 +0000 Subject: [PATCH] 2012-09-11 16:27 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/gtwvg/hbgtwvg.ch + Added: constants HB_GTE_CREATED and HB_GTE_CLOSED. * contrib/gtwvg/gtwvg.c * contrib/gtwvg/gtwvg.h + Implemented: two more events fired at PRG code, one when window is created and another when window is closed. The events supply a two element array: 1. Window Handle No 2. Thread Number. These events will greatly help develop a rewarding GUI applns. * contrib/gtwvg/parthdlr.prg * contrib/gtwvg/crt.prg + Added: slot :notifierBlock( ... ) SETGET which accepts a block from the application code which pass on designated events back. --- harbour/ChangeLog | 16 ++++++++++++++++ harbour/contrib/gtwvg/crt.prg | 6 ++++-- harbour/contrib/gtwvg/gtwvg.c | 23 ++++++++++++++++++++++- harbour/contrib/gtwvg/gtwvg.h | 2 ++ harbour/contrib/gtwvg/hbgtwvg.ch | 2 ++ harbour/contrib/gtwvg/parthdlr.prg | 20 ++++++++++++++++++++ 6 files changed, 66 insertions(+), 3 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 81895efaeb..be0b776d18 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,22 @@ The license applies to all entries newer than 2009-04-28. */ +2012-09-11 16:27 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/gtwvg/hbgtwvg.ch + + Added: constants HB_GTE_CREATED and HB_GTE_CLOSED. + + * contrib/gtwvg/gtwvg.c + * contrib/gtwvg/gtwvg.h + + Implemented: two more events fired at PRG code, one when window + is created and another when window is closed. The events supply + a two element array: 1. Window Handle No 2. Thread Number. + These events will greatly help develop a rewarding GUI applns. + + * contrib/gtwvg/parthdlr.prg + * contrib/gtwvg/crt.prg + + Added: slot :notifierBlock( ... ) SETGET which accepts a block + from the application code which pass on designated events back. + 2012-09-11 13:19 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/gtwvg/hbgtwvg.ch ! Fixed: wrong contant values for HB_GTS_SW_* constants. diff --git a/harbour/contrib/gtwvg/crt.prg b/harbour/contrib/gtwvg/crt.prg index 7be77c7f71..bb58ce54aa 100644 --- a/harbour/contrib/gtwvg/crt.prg +++ b/harbour/contrib/gtwvg/crt.prg @@ -316,6 +316,9 @@ METHOD WvgCrt:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::pGT := hb_gtSelect() ENDIF + HB_GtInfo( HB_GTI_NOTIFIERBLOCKGUI, {|nEvent, ...| ::notifier( nEvent, ... ) } ) + HB_GtInfo( HB_GTI_NOTIFIERBLOCK , {|nEvent, ...| ::notifierBlock( nEvent, ... ) } ) + IF ::lModal ::style := WS_POPUP + WS_CAPTION + WS_SYSMENU IF ::resizable @@ -347,7 +350,6 @@ METHOD WvgCrt:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) hb_gtInfo( HB_GTI_WINTITLE , ::title ) hb_gtInfo( HB_GTI_RESIZEMODE, iif( ::resizeMode == HB_GTI_RESIZEMODE_ROWS, HB_GTI_RESIZEMODE_ROWS, HB_GTI_RESIZEMODE_FONT ) ) - IF ::lModal hb_gtInfo( HB_GTI_DISABLE, ::pGTp ) ENDIF @@ -357,7 +359,7 @@ METHOD WvgCrt:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::lHasInputFocus := .t. ENDIF - HB_GtInfo( HB_GTI_NOTIFIERBLOCKGUI, {|nEvent, ...| ::notifier( nEvent, ... ) } ) +// HB_GtInfo( HB_GTI_NOTIFIERBLOCKGUI, {|nEvent, ...| ::notifier( nEvent, ... ) } ) RETURN Self diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index 8b5c054813..7821492db1 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -468,6 +468,8 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->pNotifierGUI = NULL; + pWVT->threadNO = hb_threadNO(); + return pWVT; } @@ -705,7 +707,7 @@ static HB_BOOL hb_gt_wvt_GetCharFromInputQueue( PHB_GTWVT pWVT, int * iKey ) static void hb_gt_wvt_TranslateKey( PHB_GTWVT pWVT, int key, int shiftkey, int altkey, int controlkey ) { int nVirtKey; - + nVirtKey = GetKeyState( VK_MENU ); if( nVirtKey & 0x8000 ) /* alt + key */ { @@ -2814,6 +2816,15 @@ static void hb_gt_wvt_Exit( PHB_GT pGT ) HB_TRACE(HB_TR_DEBUG, ("hb_gt_wvt_Exit(%p)", pGT)); pWVT = HB_GTWVT_GET( pGT ); + if( pWVT && pWVT->hWnd ) + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + hb_arrayNew( pEvParams, 2 ); + hb_arraySetNInt( pEvParams, 1, ( HB_MAXINT ) ( HB_PTRDIFF ) pWVT->hWnd ); + hb_arraySetNI( pEvParams, 2, pWVT->threadNO ); + hb_gt_wvt_FireEvent( pWVT, HB_GTE_CLOSED, pEvParams ); + } + HB_GTSUPER_EXIT( pGT ); if( pWVT ) @@ -4196,7 +4207,17 @@ static void hb_gt_wvt_Refresh( PHB_GT pGT ) { #if 1 if( !pWVT->hWnd && pWVT->fInit ) + { hb_gt_wvt_CreateConsoleWindow( pWVT ); + if( pWVT->hWnd ) + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + hb_arrayNew( pEvParams, 2 ); + hb_arraySetNInt( pEvParams, 1, ( HB_MAXINT ) ( HB_PTRDIFF ) pWVT->hWnd ); + hb_arraySetNI( pEvParams, 2, pWVT->threadNO ); + hb_gt_wvt_FireEvent( pWVT, HB_GTE_CREATED, pEvParams ); + } + } if( pWVT->hWnd ) { diff --git a/harbour/contrib/gtwvg/gtwvg.h b/harbour/contrib/gtwvg/gtwvg.h index afd4fc0ff1..d119d36a99 100644 --- a/harbour/contrib/gtwvg/gtwvg.h +++ b/harbour/contrib/gtwvg/gtwvg.h @@ -468,6 +468,8 @@ typedef struct PHB_ITEM pNotifierGUI; /* Notifier to Wvg*Parts if embedded into a GT Window */ + int threadNO; /* Will hold the current THREAD No */ + } HB_GTWVT, * PHB_GTWVT; /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/gtwvg/hbgtwvg.ch b/harbour/contrib/gtwvg/hbgtwvg.ch index 5032816adc..fe32e9eb05 100644 --- a/harbour/contrib/gtwvg/hbgtwvg.ch +++ b/harbour/contrib/gtwvg/hbgtwvg.ch @@ -76,6 +76,8 @@ #define HB_GTE_VSCROLL 16 #define HB_GTE_ANY 17 #define HB_GTE_KEYTOITEM 18 +#define HB_GTE_CREATED 19 +#define HB_GTE_CLOSED 20 #define HB_GTI_SETFONT 71 #define HB_GTI_PRESPARAMS 72 diff --git a/harbour/contrib/gtwvg/parthdlr.prg b/harbour/contrib/gtwvg/parthdlr.prg index 2f308f91bc..d3fc006b6d 100644 --- a/harbour/contrib/gtwvg/parthdlr.prg +++ b/harbour/contrib/gtwvg/parthdlr.prg @@ -105,6 +105,10 @@ CLASS WvgPartHandler DATA oOwner DATA nStatus INIT 0 + /* Application Level Notifier */ + DATA sb_notifier + METHOD notifierBlock( ... ) SETGET + ENDCLASS /*----------------------------------------------------------------------*/ @@ -254,6 +258,22 @@ METHOD WvgPartHandler:setParent( oWvg ) RETURN oOldXbp /*----------------------------------------------------------------------*/ + +METHOD WvgPartHandler:notifierBlock( ... ) + LOCAL a_:= hb_AParams() + + IF ! Empty( a_ ) .AND. HB_ISBLOCK( a_[ 1 ] ) + ::sb_notifier := a_[ 1 ] + + ELSEIF ! Empty( a_ ) .AND. HB_ISBLOCK( ::sb_notifier ) .AND. HB_ISNUMERIC( a_[ 1 ] ) .AND. HB_ISARRAY( a_[ 2 ] ) + Eval( ::sb_notifier, a_[ 1 ], a_[ 2 ], Self ) + + ENDIF + + RETURN NIL + +/*----------------------------------------------------------------------*/ + /* This will be called by the WvgCRT() console FOR various events TO be propogated TO child controls */