From 5c2e4521ce39cebf491eaa87177288498627a222 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Tue, 18 Nov 2008 08:16:08 +0000 Subject: [PATCH] 2008-11-17 23:59 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/gtwvg/Makefile * harbour/contrib/gtwvg/common.mak + wvgdlg.prg * harbour/contrib/gtwvg/gtwvg.c ! Fixed one more issue with screen repaint behavior when window was changing size due to font settings. * harbour/contrib/gtwvg/wvgcore.c * harbour/contrib/gtwvg/wvggui.c * harbour/contrib/gtwvg/wvgwin.c * harbour/contrib/gtwvg/hbgtwvg.ch * harbour/contrib/gtwvg/wvggui.h * harbour/contrib/gtwvg/wvgax.prg * harbour/contrib/gtwvg/wvgcrt.prg * harbour/contrib/gtwvg/wvgphdlr.prg * harbour/contrib/gtwvg/wvgwnd.prg ! A reshuffling exercise, Wvt*Classes inching towards Xbase++ compatibility, more synchronizations. + harbour/contrib/gtwvg/wvgdlg.prg + Added WvgDialog() class on lines with XbpDialog(). * harbour/contrib/gtwvg/tests/demowvg.prg ! Active-X controls hosted with WvgDialog(), pure Windows GT. Previously these were being hosted in WvtCrt() console. --- harbour/ChangeLog | 29 + harbour/contrib/gtwvg/Makefile | 1 + harbour/contrib/gtwvg/common.mak | 1 + harbour/contrib/gtwvg/gtwvg.c | 20 +- harbour/contrib/gtwvg/hbgtwvg.ch | 22 +- harbour/contrib/gtwvg/tests/demowvg.prg | 58 +- harbour/contrib/gtwvg/wvgax.prg | 1 + harbour/contrib/gtwvg/wvgcore.c | 45 +- harbour/contrib/gtwvg/wvgcrt.prg | 128 +--- harbour/contrib/gtwvg/wvgdlg.prg | 147 ++++ harbour/contrib/gtwvg/wvggui.c | 879 ++++-------------------- harbour/contrib/gtwvg/wvggui.h | 37 +- harbour/contrib/gtwvg/wvgphdlr.prg | 125 +++- harbour/contrib/gtwvg/wvgwin.c | 3 +- harbour/contrib/gtwvg/wvgwnd.prg | 195 +++++- 15 files changed, 730 insertions(+), 961 deletions(-) create mode 100644 harbour/contrib/gtwvg/wvgdlg.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a25d82d0fc..7e833a0dfd 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,35 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ + +2008-11-17 23:59 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/gtwvg/Makefile + * harbour/contrib/gtwvg/common.mak + + wvgdlg.prg + + * harbour/contrib/gtwvg/gtwvg.c + ! Fixed one more issue with screen repaint behavior when + window was changing size due to font settings. + + * harbour/contrib/gtwvg/wvgcore.c + * harbour/contrib/gtwvg/wvggui.c + * harbour/contrib/gtwvg/wvgwin.c + * harbour/contrib/gtwvg/hbgtwvg.ch + * harbour/contrib/gtwvg/wvggui.h + * harbour/contrib/gtwvg/wvgax.prg + * harbour/contrib/gtwvg/wvgcrt.prg + * harbour/contrib/gtwvg/wvgphdlr.prg + * harbour/contrib/gtwvg/wvgwnd.prg + ! A reshuffling exercise, Wvt*Classes inching towards + Xbase++ compatibility, more synchronizations. + + + harbour/contrib/gtwvg/wvgdlg.prg + + Added WvgDialog() class on lines with XbpDialog(). + + * harbour/contrib/gtwvg/tests/demowvg.prg + ! Active-X controls hosted with WvgDialog(), pure Windows GT. + Previously these were being hosted in WvtCrt() console. + 2008-11-18 03:04 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * ChangeLog * Two recent TODOs in entries marked as [DONE] by this change: diff --git a/harbour/contrib/gtwvg/Makefile b/harbour/contrib/gtwvg/Makefile index a5051f9f75..2437cb6885 100644 --- a/harbour/contrib/gtwvg/Makefile +++ b/harbour/contrib/gtwvg/Makefile @@ -23,6 +23,7 @@ PRG_SOURCES=\ wvgwnd.prg \ wvgcrt.prg \ wvgax.prg \ + wvgdlg.prg \ PRG_HEADERS=\ hbgtwvg.ch \ diff --git a/harbour/contrib/gtwvg/common.mak b/harbour/contrib/gtwvg/common.mak index 302f50967a..1745802280 100644 --- a/harbour/contrib/gtwvg/common.mak +++ b/harbour/contrib/gtwvg/common.mak @@ -17,6 +17,7 @@ LIB_OBJS = \ $(OBJ_DIR)wvgwnd$(OBJEXT) \ $(OBJ_DIR)wvgcrt$(OBJEXT) \ $(OBJ_DIR)wvgax$(OBJEXT) \ + $(OBJ_DIR)wvgdlg$(OBJEXT) \ \ $(OBJ_DIR)gtwvg$(OBJEXT) \ $(OBJ_DIR)wvgcore$(OBJEXT) \ diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index af3069f025..ef20df3d69 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -776,7 +776,7 @@ static BOOL hb_gt_wvt_FitSize( PHB_GTWVT pWVT ) return( TRUE ); } -static BOOL hb_gt_wvt_IsSizeChanged( PHB_GTWVT pWVT ) +static BOOL hb_gt_wvt_FitSizeRows( PHB_GTWVT pWVT ) { BOOL bSizeChanged = FALSE; @@ -891,12 +891,8 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT ) if( wi.left < 0 || wi.top < 0 ) { - #if 1 // IMO not required [pritpal] - if( hb_gt_wvt_IsSizeChanged( pWVT ) ) - { - hb_gt_wvt_AddCharToInputQueue( pWVT, HB_K_RESIZE ); - } - #endif + pWVT->bMaximized = TRUE; + hb_gt_wvt_FitSizeRows( pWVT ); /* resize the window to get the specified number of rows and columns */ GetWindowRect( pWVT->hWnd, &wi ); @@ -1718,7 +1714,6 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara case WM_PAINT: { RECT updateRect; - if( !pWVT->bDeferPaint ) { if( pWVT->bResizing ) @@ -1868,7 +1863,7 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara return 0; case WM_EXITSIZEMOVE: - hb_gt_wvt_IsSizeChanged( pWVT ); + hb_gt_wvt_FitSizeRows( pWVT ); return 0; case WM_SYSCOMMAND: @@ -1878,7 +1873,7 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara { pWVT->bMaximized = TRUE; - hb_gt_wvt_IsSizeChanged( pWVT ); + hb_gt_wvt_FitSizeRows( pWVT ); /* Disable "maximize" button */ @@ -2460,6 +2455,8 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) hb_gt_wvt_ResetWindowSize( pWVT ); hb_gt_wvt_UpdateCaret( pWVT ); HB_GTSELF_REFRESH( pGT ); + + hb_wvt_gtSaveGuiState( pWVT ); } } DeleteObject( hFont ); @@ -3936,9 +3933,11 @@ static void hb_wvt_gtInitGui( PHB_GTWVT pWVT ) static void hb_wvt_gtRestGuiState( PHB_GTWVT pWVT, LPRECT rect ) { if( pWVT->bGui ) + { BitBlt( pWVT->hdc, rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top, pWVT->hGuiDC, rect->left, rect->top, SRCCOPY ); + } } static void hb_wvt_gtSaveGuiState( PHB_GTWVT pWVT ) @@ -3948,6 +3947,7 @@ static void hb_wvt_gtSaveGuiState( PHB_GTWVT pWVT ) RECT rc = { 0, 0, 0, 0 }; GetClientRect( pWVT->hWnd, &rc ); + pWVT->iGuiWidth = rc.right - rc.left; pWVT->iGuiHeight = rc.bottom - rc.top; diff --git a/harbour/contrib/gtwvg/hbgtwvg.ch b/harbour/contrib/gtwvg/hbgtwvg.ch index 6d4b7a5070..83ff969d2a 100644 --- a/harbour/contrib/gtwvg/hbgtwvg.ch +++ b/harbour/contrib/gtwvg/hbgtwvg.ch @@ -56,9 +56,16 @@ //----------------------------------------------------------------------// // Extended GT Manipulation Constants //----------------------------------------------------------------------// - -#define HB_GTE_MOUSE 6 -#define HB_GTE_KEYBOARD 7 +#if 0 // Already in hbgtinfo.ch + #define HB_GTE_ACTIVATE 1 + #define HB_GTE_SETFOCUS 2 + #define HB_GTE_KILLFOCUS 3 + #define HB_GTE_CLOSE 4 + #define HB_GTE_RESIZED 5 +#endif +#define HB_GTE_MOUSE 6 +#define HB_GTE_KEYBOARD 7 +#define HB_GTE_TIMER 8 #define HB_GTI_SETFONT 71 #define HB_GTI_PRESPARAMS 72 @@ -125,10 +132,11 @@ // Class Framework Constants //----------------------------------------------------------------------// -#define objTypeNone 0 -#define objTypeCrt 1 -#define objTypeWindow 2 -#define objTypeActiveX 3 +#define objTypeNone 0 +#define objTypeCrt 1 +#define objTypeWindow 2 +#define objTypeActiveX 3 +#define objTypeDialog 4 //----------------------------------------------------------------------// diff --git a/harbour/contrib/gtwvg/tests/demowvg.prg b/harbour/contrib/gtwvg/tests/demowvg.prg index fd1da89458..819d105ef5 100644 --- a/harbour/contrib/gtwvg/tests/demowvg.prg +++ b/harbour/contrib/gtwvg/tests/demowvg.prg @@ -2245,13 +2245,21 @@ FUNCTION DrawSlide( hDlg, nSlide ) Function ExecuteActiveX( nActiveX ) Local oCrt - oCrt := WvgCrt():New( , , { 5,5 }, { 29,59 }, , .f. ) - oCrt:closable := .f. - oCrt:create() + #if 0 + oCrt := WvgCrt():New( , , { 5,5 }, { 29,59 }, , .f. ) - SetCursor( 0 ) - SetColor( 'N/W' ) - CLS + oCrt:closable := .f. + oCrt:create() + + SetCursor( 0 ) + SetColor( 'N/W' ) + CLS + #else + oCrt := WvgDialog():init( , , { 30,30 }, { 400,500 }, , .f. ) + + oCrt:closable := .f. + oCrt:create() + #endif oCrt:show() @@ -2260,8 +2268,14 @@ Function ExecuteActiveX( nActiveX ) oCrt:Destroy() Return nil //----------------------------------------------------------------------// -Static Function Resize( oCom ) - Win_MoveWindow( oCom:hWnd, 0, 0, hb_gtInfo( HB_GTI_SCREENWIDTH ), hb_gtInfo( HB_GTI_SCREENHEIGHT ), .F. ) +Static Function ResizeMe( oCom ) + Local nW, nH + + nW := hb_gtInfo( HB_GTI_SCREENWIDTH ) + nH := hb_gtInfo( HB_GTI_SCREENHEIGHT ) + + oCom:SetSize( { nW, nH }, .t. ) + Return nil //----------------------------------------------------------------------// Static Function ExeActiveX( oCrt, nActiveX ) @@ -2322,7 +2336,6 @@ Static Function ExeActiveX( oCrt, nActiveX ) oCom:create() if hb_isObject( oCom ) - // After :CREATE() Messages // if nActiveX == 1 @@ -2339,9 +2352,13 @@ Static Function ExeActiveX( oCrt, nActiveX ) do while !( lEnd ) nKey := inkey() - +#if 0 +if nKey <> 0 + hb_toOutDebug( 'nKey = %i : %i ', nKey, HB_K_RESIZE ) +endif +#endif if nKey == HB_K_RESIZE - Resize( oCom ) + ResizeMe( oCom ) elseif nKey == K_F12 if nActiveX == 1 @@ -2363,12 +2380,13 @@ Static Function ExeActiveX( oCrt, nActiveX ) if nTurn > 6 nTurn := 1 endif + sData := NIL sData := '' do case case nTurn == 1 hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] ' + 'Stacked Bars' ) - SetMode( 30,100 ) + //SetMode( 30,100 ) sData += "00003600|00004450|000051|000061|000073|00008-6972|00009412|00011Tahoma|100011|10" sData += "0035|1000410|10005-5|10006-5|1000911|100101|100111|100181|100200|1002150000|1002" @@ -2389,7 +2407,7 @@ Static Function ExeActiveX( oCrt, nActiveX ) case nTurn == 2 hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Floating Bars' ) - SetMode( 20,90 ) + //SetMode( 20,90 ) sData += "00003550|00004300|000051|000073|00008-2894893|00009412|00011Tahoma|100011|100035" sData += "|100045|10005-5|10006-5|1000911|100101|100111|100131|100181|100201|1002113|10022" @@ -2404,7 +2422,7 @@ Static Function ExeActiveX( oCrt, nActiveX ) case nTurn == 3 hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Four Regions' ) - SetMode( 40,120 ) + //SetMode( 40,120 ) sData += "00003700|00004500|000054|000061|000071|00008-984833|00009412|00011Tahoma|100011|" sData += "100032|100042|10005348|10006248|1000910|100101|100111|100181|100200|10021100|100" @@ -2437,7 +2455,7 @@ Static Function ExeActiveX( oCrt, nActiveX ) case nTurn == 4 hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'10 Biggest Companies' ) - SetMode( 25,90 ) + //SetMode( 25,90 ) sData += "00003670|00004450|000051|000061|000071|00008-10185235|00009412|00011Tahoma|10001" sData += "1|100035|1000410|10005-5|10006-5|1000912|100101|100111|100131|100181|10020100000" @@ -2455,7 +2473,7 @@ Static Function ExeActiveX( oCrt, nActiveX ) case nTurn == 5 hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Grouped Bars' ) - SetMode( 25,80 ) + //SetMode( 25,80 ) sData += "00003600|00004450|000051|000061|000075|00008-2|00009412|00010paper.jpg|00011Taho" sData += "ma|100011|100035|100045|10005-5|10006-5|1000910|100101|100111|100181|100200|1002" @@ -2468,7 +2486,7 @@ Static Function ExeActiveX( oCrt, nActiveX ) case nTurn == 6 hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Flow Chart' ) - SetMode( 30,50 ) + //SetMode( 30,50 ) sData += "00003305|00004400|000051|00008-984833|00009412|00011Tahoma|100011|100035|100045|" sData += "10005-5|10006-5|10180\7C|010011|010051|010072|010081|0101050|0101125|01012100|01" @@ -2507,8 +2525,7 @@ Static Function ExeActiveX( oCrt, nActiveX ) oCom:Reset() oCom:RMCFile := sData oCom:Draw( .t. ) - Resize( oCom ) - + ResizeMe( oCom ) endif endif @@ -2633,9 +2650,6 @@ Static Function ExperimentWGU() do while .t. nKey := inkey( 0.1 ) - if nKey <> 0 -//hb_toOutDebug( 'inkey == %i rows=%i cols=%i', nKey, maxrow(), maxcol() ) - endif if nKey == 27 exit endif diff --git a/harbour/contrib/gtwvg/wvgax.prg b/harbour/contrib/gtwvg/wvgax.prg index 0ac09e211e..e48465a7c9 100644 --- a/harbour/contrib/gtwvg/wvgax.prg +++ b/harbour/contrib/gtwvg/wvgax.prg @@ -112,6 +112,7 @@ CLASS WvgActiveXControl FROM TOleAuto, WvgWindow DATA hSink DATA style INIT WS_CHILD + WS_VISIBLE + WS_CLIPCHILDREN + WS_CLIPSIBLINGS + DATA hWnd METHOD New() METHOD Create() diff --git a/harbour/contrib/gtwvg/wvgcore.c b/harbour/contrib/gtwvg/wvgcore.c index 29e7ea31a6..26c6f1141d 100644 --- a/harbour/contrib/gtwvg/wvgcore.c +++ b/harbour/contrib/gtwvg/wvgcore.c @@ -2994,6 +2994,7 @@ HB_FUNC( WVT_SAVESCREEN ) { PHB_GTWVT _s = hb_wvt_gtGetWVT(); + HDC hCompDC; HBITMAP hBmp, oldBmp; POINT xy = { 0,0 }; int iTop, iLeft, iBottom, iRight, iWidth, iHeight; @@ -3011,10 +3012,18 @@ HB_FUNC( WVT_SAVESCREEN ) iHeight = iBottom - iTop + 1; hBmp = CreateCompatibleBitmap( _s->hdc, iWidth, iHeight ) ; + + #if 0 oldBmp = (HBITMAP) SelectObject( _s->hCompDC, hBmp ); BitBlt( _s->hCompDC, 0, 0, iWidth, iHeight, _s->hdc, iLeft, iTop, SRCCOPY ); SelectObject( _s->hCompDC, oldBmp ); - + #else + hCompDC = CreateCompatibleDC( _s->hdc ); + oldBmp = (HBITMAP) SelectObject( hCompDC, hBmp ); + BitBlt( hCompDC, 0, 0, iWidth, iHeight, _s->hdc, iLeft, iTop, SRCCOPY ); + SelectObject( hCompDC, oldBmp ); + DeleteDC( hCompDC ); + #endif hb_arraySetNI( info, 1, iWidth ); hb_arraySetNI( info, 2, iHeight ); hb_arraySetNInt( info, 3, ( HB_PTRDIFF ) hBmp ); @@ -3033,6 +3042,7 @@ HB_FUNC( WVT_RESTSCREEN ) POINT xy = { 0,0 }; int iTop, iLeft, iBottom, iRight, iWidth, iHeight; HBITMAP hBmp; + HDC hCompDC; BOOL bResult = FALSE; BOOL bDoNotDestroyBMP = ISNIL( 6 ) ? FALSE : hb_parl( 6 ); @@ -3048,6 +3058,38 @@ HB_FUNC( WVT_RESTSCREEN ) iWidth = iRight - iLeft + 1 ; iHeight = iBottom - iTop + 1 ; + #if 1 + hCompDC = CreateCompatibleDC( _s->hdc ); + hBmp = (HBITMAP) SelectObject( hCompDC, ( HBITMAP ) ( HB_PTRDIFF ) hb_parnint( 5,3 ) ); + if ( hBmp ) + { + if ( ( iWidth == hb_parni( 5,1 ) ) && ( iHeight == hb_parni( 5,2 ) ) ) + { + if ( BitBlt( _s->hdc, + iLeft, iTop, iWidth, iHeight, + hCompDC, + 0, 0, + SRCCOPY ) ) + { + bResult = TRUE; + } + } + else + { + if ( StretchBlt( _s->hdc, + iLeft, iTop, iWidth, iHeight, + hCompDC, + 0, 0, + hb_parni( 5,1 ), + hb_parni( 5,2 ), + SRCCOPY ) ) + { + bResult = TRUE; + } + } + } + DeleteDC( hCompDC ); + #else hBmp = (HBITMAP) SelectObject( _s->hCompDC, ( HBITMAP ) ( HB_PTRDIFF ) hb_parnint( 5,3 ) ); if ( hBmp ) { @@ -3084,6 +3126,7 @@ HB_FUNC( WVT_RESTSCREEN ) } } } + #endif SelectObject( _s->hCompDC, hBmp ); diff --git a/harbour/contrib/gtwvg/wvgcrt.prg b/harbour/contrib/gtwvg/wvgcrt.prg index a3fd9620d7..c6b19c0a73 100644 --- a/harbour/contrib/gtwvg/wvgcrt.prg +++ b/harbour/contrib/gtwvg/wvgcrt.prg @@ -242,7 +242,6 @@ EXPORTED: DATA objType INIT objTypeCrt DATA ClassName INIT 'WVGCRT' - METHOD notifier() METHOD setFocus() METHOD sendMessage() @@ -558,7 +557,14 @@ METHOD setPresParam() CLASS WvgCrt //----------------------------------------------------------------------// -METHOD setSize() CLASS WvgCrt +METHOD setSize( aSize, lPaint ) CLASS WvgCrt + + if hb_isArray( aSize ) + DEFAULT lPaint TO .T. + + hb_gtInfo( HB_GTI_SCREENHEIGHT, aSize[ 1 ] ) + hb_gtInfo( HB_GTI_SCREENWIDTH , aSize[ 2 ] ) + endif RETURN Self @@ -1099,123 +1105,6 @@ METHOD dragDrop( xParam, xParam1 ) CLASS WvgCrt //----------------------------------------------------------------------// // HARBOUR SPECIFIC //----------------------------------------------------------------------// - -METHOD notifier( nEvent, xParams ) CLASS WvgCrt - Local aPos, nReturn := 0 - - DO CASE - - CASE nEvent == HB_GTE_MOUSE - if xParams[ 1 ] == WM_MOUSEHOVER - aPos := { xParams[ 3 ], xParams[ 4 ] } - elseif xParams[ 1 ] == WM_MOUSELEAVE - // Nothing - else - aPos := if( ::mouseMode == 2, { xParams[ 3 ], xParams[ 4 ] }, { xParams[ 5 ], xParams[ 6 ] } ) - endif - - SWITCH xParams[ 1 ] - - case WM_MOUSEHOVER - if hb_isBlock( ::sl_enter ) - eval( ::sl_enter, aPos, NIL, self ) - endif - EXIT - case WM_MOUSELEAVE - if hb_isBlock( ::sl_leave ) - eval( ::sl_leave, aPos, NIL, self ) - endif - EXIT - case WM_RBUTTONDOWN - if hb_isBlock( ::sl_rbDown ) - eval( ::sl_rbDown, aPos, NIL, self ) - endif - EXIT - case WM_LBUTTONDOWN - if hb_isBlock( ::sl_lbDown ) - eval( ::sl_lbDown, aPos, NIL, self ) - endif - EXIT - case WM_RBUTTONUP //// - if hb_isBlock( ::sl_rbUp ) - eval( ::sl_rbUp, aPos, NIL, self ) - endif - EXIT - case WM_LBUTTONUP //// - if hb_isBlock( ::sl_lbUp ) - eval( ::sl_lbUp, aPos, NIL, self ) - endif - EXIT - case WM_RBUTTONDBLCLK - if hb_isBlock( ::sl_rbDblClick ) - eval( ::sl_rbDblClick, aPos, NIL, self ) - endif - EXIT - case WM_LBUTTONDBLCLK - if hb_isBlock( ::sl_lbDblClick ) - eval( ::sl_lbDblClick, aPos, NIL, self ) - endif - EXIT - case WM_MBUTTONDOWN - if hb_isBlock( ::sl_mbDown ) - eval( ::sl_mbDown, aPos, NIL, self ) - endif - EXIT - case WM_MBUTTONUP //// - if hb_isBlock( ::sl_mbClick ) - eval( ::sl_mbClick, aPos, NIL, self ) - endif - EXIT - case WM_MBUTTONDBLCLK - if hb_isBlock( ::sl_mbDblClick ) - eval( ::sl_mbDblClick, aPos, NIL, self ) - endif - EXIT - case WM_MOUSEMOVE - if hb_isBlock( ::sl_motion ) - eval( ::sl_motion, aPos, NIL, self ) - endif - EXIT - case WM_MOUSEWHEEL - if hb_isBlock( ::sl_wheel ) - eval( ::sl_wheel, aPos, NIL, self ) - endif - EXIT - case WM_NCMOUSEMOVE - EXIT - END - - CASE nEvent == HB_GTE_KEYBOARD - if hb_isBlock( ::keyboard ) - eval( ::keyboard, xParams, NIL, Self ) - endif - - CASE nEvent == HB_GTE_SETFOCUS - if hb_isBlock( ::setInputFocus ) - eval( ::setInputFocus, NIL, NIL, Self ) - endif - ::lHasInputFocus := .t. - - CASE nEvent == HB_GTE_KILLFOCUS - if hb_isBlock( ::killInputFocus ) - eval( ::killInputFocus, NIL, NIL, Self ) - endif - ::lHasInputFocus := .f. - - CASE nEvent == HB_GTE_RESIZED - if hb_isBlock( ::sl_resize ) - eval( ::sl_resize, { xParams[ 1 ], xParams[ 2 ] }, { xParams[ 3 ], xParams[ 4 ] }, Self ) - endif - - CASE nEvent == HB_GTE_CLOSE - if hb_isBlock( ::close ) - nReturn := eval( ::close, NIL, NIL, Self ) - endif - - ENDCASE - - RETURN nReturn -//----------------------------------------------------------------------// METHOD setFocus() CLASS WvgCrt ::sendMessage( WM_ACTIVATE, 1, 0 ) @@ -1228,4 +1117,3 @@ METHOD sendMessage( nMessage, nlParam, nwParam ) CLASS WvgCrt RETURN Self //----------------------------------------------------------------------// - diff --git a/harbour/contrib/gtwvg/wvgdlg.prg b/harbour/contrib/gtwvg/wvgdlg.prg new file mode 100644 index 0000000000..4769cf2746 --- /dev/null +++ b/harbour/contrib/gtwvg/wvgdlg.prg @@ -0,0 +1,147 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Source file for the Wvg*Classes + * + * Copyright 2008 Pritpal Bedi + * 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. + * + */ +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +// +// EkOnkar +// ( The LORD is ONE ) +// +// Xbase++ Compatible xbpDialog Class +// +// Pritpal Bedi +// 17Nov2008 +// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// + +#include 'hbclass.ch' +#include 'common.ch' +#include 'hbgtinfo.ch' +#include 'hbgtwvg.ch' +#include 'wvtwin.ch' +#include 'inkey.ch' + +//----------------------------------------------------------------------// +CLASS WvgDialog FROM WvgWindow + + METHOD init() + METHOD create() + METHOD configure() + METHOD destroy() + + ENDCLASS +//----------------------------------------------------------------------// +METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDialog + + ::WvgWindow:init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::className := 'WVGDIALOG' + ::resizeMode := 0 + ::mouseMode := 0 + ::objType := objTypeDialog + + ::style := WS_THICKFRAME+WS_OVERLAPPED+WS_CAPTION+WS_SYSMENU+WS_MINIMIZEBOX+WS_MAXIMIZEBOX; + + RETURN Self +//----------------------------------------------------------------------// +METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDialog + + ::WvgWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + if ::lModal + ::pGT := hb_gtCreate( 'WGU' ) + ::pGTp := hb_gtSelect( ::pGT ) + else + hb_gtReload( 'WGU' ) + ::pGT := hb_gtSelect() + endif + + hb_gtInfo( HB_GTI_PRESPARAMS, { ::exStyle, ::style, ::aPos[ 1 ], ::aPos[ 2 ], ; + ::aSize[ 1 ], ::aSize[ 2 ], ::pGTp, .F., .f. } ) + + ::hWnd := hb_gtInfo( HB_GTI_SPEC, HB_GTS_WINDOWHANDLE ) + + hb_gtInfo( HB_GTI_RESIZABLE , ::resizable ) + hb_gtInfo( HB_GTI_CLOSABLE , ::closable ) + hb_gtInfo( HB_GTI_WINTITLE , ::title ) + + if !empty( ::icon ) + if hb_isNumeric( ::icon ) + hb_gtInfo( HB_GTI_ICONRES, ::icon ) + + elseif hb_isChar( ::icon ) + hb_gtInfo( HB_GTI_ICONFILE, ::icon ) + + endif + endif + + if ::lModal + hb_gtInfo( HB_GTI_DISABLE, ::pGTp ) + endif + + if ::visible + hb_gtInfo( HB_GTI_SPEC, HB_GTS_SHOWWINDOW, SW_NORMAL ) + ::lHasInputFocus := .t. + endif + + hb_gtInfo( HB_GTI_NOTIFIERBLOCK, {|nEvent, ...| ::notifier( nEvent, ... ) } ) + + RETURN Self +//----------------------------------------------------------------------// +METHOD configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgDialog + RETURN Self +//----------------------------------------------------------------------// +METHOD destroy() CLASS WvgDialog + RETURN Self +//----------------------------------------------------------------------// diff --git a/harbour/contrib/gtwvg/wvggui.c b/harbour/contrib/gtwvg/wvggui.c index 7589a6ad01..e61137f5bb 100644 --- a/harbour/contrib/gtwvg/wvggui.c +++ b/harbour/contrib/gtwvg/wvggui.c @@ -81,7 +81,7 @@ * Cross-GT, multiplatform Graphics API * */ -#if 1 + #define HB_OS_WIN_32_USED @@ -126,7 +126,7 @@ static void hb_gt_wvt_RegisterClass( HINSTANCE hInstance ) wndclass.hInstance = hInstance; /* wndclass.hIcon = NULL; */ wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ); - wndclass.hbrBackground = ( HBRUSH ) ( COLOR_BTNFACE + 1 ); + wndclass.hbrBackground = NULL; /* ( HBRUSH ) ( COLOR_BTNFACE + 1 ) */; /* wndclass.lpszMenuName = NULL; */ wndclass.lpszClassName = s_szClassName; @@ -211,12 +211,6 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) HB_WVT_UNLOCK // Detach PRG callback - pWVT->pSymWVT_PAINT = NULL; - pWVT->pSymWVT_SETFOCUS = NULL; - pWVT->pSymWVT_KILLFOCUS = NULL; - pWVT->pSymWVT_MOUSE = NULL; - pWVT->pSymWVT_TIMER = NULL; - pWVT->pSymWVT_KEY = NULL; hb_itemRelease( pWVT->pPP->pParentGT ); hb_xfree( pWVT->pPP ); @@ -275,11 +269,9 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->CodePage = OEM_CHARSET; /* GetACP(); - set code page to default system */ pWVT->Win9X = ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ); - pWVT->AltF4Close = FALSE; pWVT->IgnoreWM_SYSCHAR = FALSE; - pWVT->bMaximized = FALSE; pWVT->bResizable = TRUE; pWVT->bClosable = TRUE; @@ -307,8 +299,9 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) } #endif #endif - pWVT->bResizing = FALSE; + pWVT->width = 600; + pWVT->height = 400; return pWVT; } @@ -333,51 +326,6 @@ static int hb_gt_wvt_FireEvent( PHB_GTWVT pWVT, int nEvent, PHB_ITEM pParams ) return nResult; } - -/* - * use the standard fixed oem font, unless the caller has requested set size fonts - */ -static HFONT hb_gt_wvt_GetFont( const char * pszFace, int iHeight, int iWidth, int iWeight, int iQuality, int iCodePage ) -{ - if( iHeight > 0 ) - { - LOGFONT logfont; - - memset( &logfont, 0, sizeof( LOGFONT ) ); - logfont.lfEscapement = 0; - logfont.lfOrientation = 0; - logfont.lfWeight = iWeight; - logfont.lfItalic = 0; - logfont.lfUnderline = 0; - logfont.lfStrikeOut = 0; - logfont.lfCharSet = ( BYTE ) iCodePage; /* OEM_CHARSET */ - logfont.lfOutPrecision = 0; - logfont.lfClipPrecision = 0; - logfont.lfQuality = ( BYTE ) iQuality; /* DEFAULT_QUALITY, DRAFT_QUALITY or PROOF_QUALITY */ - logfont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN; /* all mapping depends on fixed width fonts! */ - logfont.lfHeight = iHeight; - logfont.lfWidth = iWidth < 0 ? -iWidth : iWidth; - - HB_TCHAR_CPTO( logfont.lfFaceName, pszFace, sizeof( logfont.lfFaceName ) - 1 ); - - return CreateFontIndirect( &logfont ); - } - else - return ( HFONT ) GetStockObject( OEM_FIXED_FONT /* SYSTEM_FIXED_FONT */ ); -} - -static RECT hb_gt_wvt_GetXYFromColRowRect( PHB_GTWVT pWVT, RECT colrow ) -{ - RECT xy; - - xy.left = colrow.left * pWVT->PTEXTSIZE.x; - xy.top = colrow.top * pWVT->PTEXTSIZE.y; - xy.right = ( colrow.right + 1 ) * pWVT->PTEXTSIZE.x; - xy.bottom = ( colrow.bottom + 1 ) * pWVT->PTEXTSIZE.y; - - return xy; -} - /* * functions for handling the input queues for the mouse and keyboard */ @@ -402,17 +350,6 @@ static void hb_gt_wvt_AddCharToInputQueue( PHB_GTWVT pWVT, int iKey ) if( iPos != pWVT->keyPointerOut ) pWVT->keyPointerIn = iPos; - if( pWVT->pSymWVT_KEY ) - { - if( hb_vmRequestReenter() ) - { - hb_vmPushDynSym( pWVT->pSymWVT_KEY ); - hb_vmPushNil(); - hb_vmPushInteger( iKey ); - hb_vmDo( 1 ); - hb_vmRequestRestore(); - } - } /* Fire event to be trapped by the application */ { PHB_ITEM pEvParams = hb_itemNew( NULL ); @@ -476,110 +413,29 @@ static int hb_gt_wvt_key_ansi_to_oem( int c ) return * pszOem; } -static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT ) +static int hb_gt_wvt_SizeChanged( PHB_GTWVT pWVT ) { - HDC hdc; - HFONT hFont, hOldFont; - USHORT height, width; - RECT wi, ci; - TEXTMETRIC tm; - RECT rcWorkArea; - int n; + PHB_ITEM pEvParams = hb_itemNew( NULL ); + RECT rc; - /* - * set the font and get it's size to determine the size of the client area - * for the required number of rows and columns . - * No need to call hb_gt_wvt_GetFont() if font is already existant [prtpal 20081108] - */ - if( !pWVT->hFont ) - { - hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, - pWVT->fontWeight, pWVT->fontQuality, pWVT->CodePage ); - pWVT->hFont = hFont; - } - else - { - hFont = pWVT->hFont; - } + GetClientRect( pWVT->hWnd, &rc ); - hdc = GetDC( pWVT->hWnd ); - hOldFont = ( HFONT ) SelectObject( hdc, hFont ); - GetTextMetrics( hdc, &tm ); - SetTextCharacterExtra( hdc, 0 ); /* do not add extra char spacing even if bold */ - SelectObject( hdc, hOldFont ); - ReleaseDC( pWVT->hWnd, hdc ); + hb_arrayNew( pEvParams, 4 ); + hb_arraySetNI( pEvParams, 1, pWVT->width ); + hb_arraySetNI( pEvParams, 2, pWVT->height ); + hb_arraySetNI( pEvParams, 3, rc.right - rc.left ); + hb_arraySetNI( pEvParams, 4, rc.bottom - rc.top ); - /* - * we will need to use the font size to handle the transformations from - * row column space in the future, so we keep it around in a static! - */ + hb_gt_wvt_AddCharToInputQueue( pWVT, HB_K_RESIZE ); - pWVT->PTEXTSIZE.x = pWVT->fontWidth < 0 ? -pWVT->fontWidth : - tm.tmAveCharWidth; /* For fixed FONT should == tm.tmMaxCharWidth */ - pWVT->PTEXTSIZE.y = tm.tmHeight; /* but seems to be a problem on Win9X so */ - /* assume proportional fonts always for Win9X */ -#if defined(HB_WINCE) - pWVT->FixedFont = FALSE; -#else - pWVT->FixedFont = !pWVT->Win9X && pWVT->fontWidth >= 0 && - ( tm.tmPitchAndFamily & TMPF_FIXED_PITCH ) == 0 && - ( pWVT->PTEXTSIZE.x == tm.tmMaxCharWidth ); -#endif + hb_gt_wvt_FireEvent( pWVT, HB_GTE_RESIZED, pEvParams ); - /* pWVT->FixedSize[] is used by ExtTextOut() to emulate - fixed font when a proportional font is used */ - for( n = 0; n < pWVT->COLS; n++ ) - pWVT->FixedSize[ n ] = pWVT->PTEXTSIZE.x; + pWVT->width = rc.right - rc.left; + pWVT->height = rc.bottom - rc.top; - /* resize the window to get the specified number of rows and columns */ - GetWindowRect( pWVT->hWnd, &wi ); - GetClientRect( pWVT->hWnd, &ci ); + hb_itemRelease( pEvParams ); - height = ( USHORT ) ( pWVT->PTEXTSIZE.y * pWVT->ROWS ); - width = ( USHORT ) ( pWVT->PTEXTSIZE.x * pWVT->COLS ); - - width += ( USHORT ) ( wi.right - wi.left - ci.right ); - height += ( USHORT ) ( wi.bottom - wi.top - ci.bottom ); - - /* Center the window within the CLIENT area on the screen - but only if pWVT->CentreWindow == TRUE */ - if( pWVT->CentreWindow && SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWorkArea, 0 ) ) - { - wi.left = rcWorkArea.left + ( ( rcWorkArea.right - rcWorkArea.left - width ) / 2 ); - wi.top = rcWorkArea.top + ( ( rcWorkArea.bottom - rcWorkArea.top - height ) / 2 ); - } - - if( wi.left < 0 || wi.top < 0 ) - { - #if 0 // IMO not required [pritpal] - if( hb_gt_wvt_IsSizeChanged( pWVT ) ) - { - hb_gt_wvt_AddCharToInputQueue( pWVT, HB_K_RESIZE ); - } - #endif - - /* resize the window to get the specified number of rows and columns */ - GetWindowRect( pWVT->hWnd, &wi ); - GetClientRect( pWVT->hWnd, &ci ); - - height = ( USHORT ) ( pWVT->PTEXTSIZE.y * pWVT->ROWS ); - width = ( USHORT ) ( pWVT->PTEXTSIZE.x * pWVT->COLS ); - - width += ( USHORT ) ( wi.right - wi.left - ci.right ); - height += ( USHORT ) ( wi.bottom - wi.top - ci.bottom ); - - /* Center the window within the CLIENT area on the screen - but only if pWVT->CentreWindow == TRUE */ - if( pWVT->CentreWindow && SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWorkArea, 0 ) ) - { - wi.left = rcWorkArea.left + ( ( rcWorkArea.right - rcWorkArea.left - width ) / 2 ); - wi.top = rcWorkArea.top + ( ( rcWorkArea.bottom - rcWorkArea.top - height ) / 2 ); - } - } - - SetWindowPos( pWVT->hWnd, NULL, wi.left, wi.top, width, height, SWP_NOZORDER ); - - HB_GTSELF_EXPOSEAREA( pWVT->pGT, 0, 0, pWVT->ROWS, pWVT->COLS ); + return 0; } static void hb_gt_wvt_SetWindowTitle( HWND hWnd, const char * title ) @@ -607,27 +463,6 @@ static BOOL hb_gt_wvt_GetWindowTitle( HWND hWnd, char ** title ) return FALSE; } -static BOOL hb_gt_wvt_SetWindowSize( PHB_GTWVT pWVT, int iRow, int iCol ) -{ - if( HB_GTSELF_RESIZE( pWVT->pGT, iRow, iCol ) ) - { - pWVT->ROWS = ( USHORT ) iRow; - pWVT->COLS = ( USHORT ) iCol; - return TRUE; - } - - return FALSE; -} - -static BOOL hb_gt_wvt_InitWindow( PHB_GTWVT pWVT, int iRow, int iCol ) -{ - BOOL fRet = hb_gt_wvt_SetWindowSize( pWVT, iRow, iCol ); - - hb_gt_wvt_ResetWindowSize( pWVT ); - - return fRet; -} - static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, LPARAM lParam ) { POINT xy; @@ -705,6 +540,7 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L default: keyCode = K_MOUSEMOVE; } + #if 0 if( !pWVT->bTracking ) { TRACKMOUSEEVENT tmi; @@ -714,6 +550,7 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L tmi.dwHoverTime = 1; pWVT->bTracking = _TrackMouseEvent( &tmi ); } + #endif break; } } @@ -738,8 +575,8 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L hb_arraySetNI( pEvParams, 2, keyCode ); hb_arraySetNI( pEvParams, 3, xy.x ); hb_arraySetNI( pEvParams, 4, xy.y ); - hb_arraySetNI( pEvParams, 5, xy.y ); - hb_arraySetNI( pEvParams, 6, xy.x ); + hb_arraySetNI( pEvParams, 5, xy.x ); + hb_arraySetNI( pEvParams, 6, xy.y ); hb_gt_wvt_FireEvent( pWVT, HB_GTE_MOUSE, pEvParams ); hb_itemRelease( pEvParams ); @@ -800,8 +637,10 @@ static BOOL hb_gt_wvt_KeyEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, LPA hb_gt_wvt_TranslateKey( pWVT, K_F3 , K_SH_F3, K_ALT_F3 , K_CTRL_F3 ); break; case VK_F4: +#if 0 if( pWVT->AltF4Close && bAlt ) return DefWindowProc( pWVT->hWnd, message, wParam, lParam ) != 0; +#endif hb_gt_wvt_TranslateKey( pWVT, K_F4 , K_SH_F4, K_ALT_F4 , K_CTRL_F4 ); break; case VK_F5: @@ -1084,53 +923,40 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara if( pWVT ) switch( message ) { - case WM_CREATE: - return hb_gt_wvt_InitWindow( pWVT, pWVT->ROWS, pWVT->COLS ); - case WM_PAINT: return DefWindowProc( hWnd, message, wParam, lParam );; case WM_SETFOCUS: + { if( pWVT->bGetFocus ) { - if( pWVT->pSymWVT_SETFOCUS ) - { - if( hb_vmRequestReenter() ) - { - hb_vmPushDynSym( pWVT->pSymWVT_SETFOCUS ); - hb_vmPushNil(); - hb_vmPushNumInt( ( HB_LONG ) ( HB_PTRDIFF ) hWnd ); - hb_vmDo( 1 ); - hb_vmRequestRestore(); - } + PHB_ITEM pEvParams = hb_itemNew( NULL ); + hb_itemPutNL( pEvParams, ( HB_LONG ) ( HB_PTRDIFF ) hWnd ); + hb_gt_wvt_FireEvent( pWVT, HB_GTE_SETFOCUS, pEvParams ); + hb_itemRelease( pEvParams ); + return 0; } - } else { pWVT->bGetFocus = TRUE; } return 0; - + } case WM_KILLFOCUS: - if( pWVT->pSymWVT_KILLFOCUS ) - { - if( hb_vmRequestReenter() ) - { - hb_vmPushDynSym( pWVT->pSymWVT_KILLFOCUS ); - hb_vmPushNil(); - hb_vmPushNumInt( ( HB_LONG ) ( HB_PTRDIFF ) hWnd ); - hb_vmDo( 1 ); - hb_vmRequestRestore(); - } - } + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + hb_itemPutNL( pEvParams, ( HB_LONG ) ( HB_PTRDIFF ) hWnd ); + hb_gt_wvt_FireEvent( pWVT, HB_GTE_KILLFOCUS, pEvParams ); + hb_itemRelease( pEvParams ); return 0; - + } case WM_KEYDOWN: case WM_SYSKEYDOWN: case WM_CHAR: case WM_SYSCHAR: + { return hb_gt_wvt_KeyEvent( pWVT, message, wParam, lParam ); - + } case WM_RBUTTONDOWN: case WM_LBUTTONDOWN: case WM_RBUTTONUP: @@ -1143,35 +969,21 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara case WM_MOUSEMOVE: case WM_MOUSEWHEEL: case WM_NCMOUSEMOVE: + { hb_gt_wvt_MouseEvent( pWVT, message, wParam, lParam ); return 0; - + } case WM_QUERYENDSESSION: /* Closing down computer */ + { hb_vmRequestQuit(); return 0; - - case WM_CLOSE: /* Clicked 'X' on system menu */ - { - PHB_ITEM pEvParams = hb_itemNew( NULL ); - if( hb_gt_wvt_FireEvent( pWVT, HB_GTE_CLOSE, pEvParams ) == 0 ) - { - PHB_ITEM pItem = hb_itemPutL( NULL, TRUE ); - hb_setSetItem( HB_SET_CANCEL, pItem ); - hb_itemRelease( pItem ); - hb_vmRequestCancel(); - } - hb_itemRelease( pEvParams ); - return 0; } - case WM_QUIT: - case WM_DESTROY: - return 0; - case WM_ENTERIDLE: + { /* FSG - 12/05/2004 - Signal than i'm on idle */ hb_idleState(); return 0; - + } /* Pritpal Bedi - 06 Jun 2008 */ case WM_ACTIVATE: { @@ -1180,36 +992,35 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara hb_itemRelease( pEvParams ); return 0; } - case WM_SIZE: - // Fire Event + { + return( hb_gt_wvt_SizeChanged( pWVT ) ); + } + case WM_COMMAND: + { return 0; - + } case WM_SYSCOMMAND: + { switch( wParam ) { case SC_MAXIMIZE: { - pWVT->bMaximized = TRUE; + // TODO } } break; - + } case WM_TIMER: - if( pWVT->pSymWVT_TIMER ) - { - if( hb_vmRequestReenter() ) - { - hb_vmPushDynSym( pWVT->pSymWVT_TIMER ); - hb_vmPushNil(); - hb_vmPushNumInt( wParam ); - hb_vmDo( 1 ); - hb_vmRequestRestore(); - } - } + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + hb_itemPutNI( pEvParams, ( int ) wParam ); + hb_gt_wvt_FireEvent( pWVT, HB_GTE_TIMER, pEvParams ); + hb_itemRelease( pEvParams ); return 0; - + } case HB_MSG_NOTIFYICON: + { if( lParam == WM_RBUTTONUP ) { NOTIFYICONDATA tnid ; @@ -1222,11 +1033,7 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara ShowWindow( hWnd, SW_RESTORE ); } return 0; - - case WM_COMMAND: - - return 0; - + } case WM_MOUSEHOVER: { PHB_ITEM pEvParams = hb_itemNew( NULL ); @@ -1254,7 +1061,23 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara hb_itemRelease( pEvParams ); pWVT->bTracking = FALSE; - return DefWindowProc( hWnd, message, wParam, lParam );; + return DefWindowProc( pWVT->hWnd, message, wParam, lParam );; + } + case WM_CREATE: + { + return 0; + } + case WM_CLOSE: /* Clicked 'X' on system menu */ + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + hb_gt_wvt_FireEvent( pWVT, HB_GTE_CLOSE, pEvParams ); + hb_itemRelease( pEvParams ); + return 0; + } + case WM_QUIT: + case WM_DESTROY: + { + return 0; } } @@ -1264,42 +1087,15 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara static DWORD hb_gt_wvt_ProcessMessages( PHB_GTWVT pWVT ) { MSG msg; - HB_SYMBOL_UNUSED( pWVT ); while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } - return ( DWORD ) msg.wParam; } -static BOOL hb_gt_wvt_ValidWindowSize( HWND hWnd, int rows, int cols, HFONT hFont, int iWidth ) -{ - HDC hdc; - HFONT hOldFont; - USHORT width, height, maxWidth, maxHeight; - TEXTMETRIC tm; - RECT rcWorkArea; - - SystemParametersInfo( SPI_GETWORKAREA,0, &rcWorkArea, 0 ); - - maxWidth = ( USHORT ) ( rcWorkArea.right - rcWorkArea.left ); - maxHeight = ( USHORT ) ( rcWorkArea.bottom - rcWorkArea.top ); - - hdc = GetDC( hWnd ); - hOldFont = ( HFONT ) SelectObject( hdc, hFont ); - GetTextMetrics( hdc, &tm ); - SelectObject( hdc, hOldFont ); /* Put old font back */ - ReleaseDC( hWnd, hdc ); - - width = ( USHORT ) ( iWidth < 0 ? -iWidth : tm.tmAveCharWidth * cols ); /* Total pixel width this setting would take */ - height = ( USHORT ) ( tm.tmHeight * rows ); /* Total pixel height this setting would take */ - - return ( width <= maxWidth ) && ( height <= maxHeight ); -} - static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT ) { HWND hWnd, hWndParent; @@ -1359,11 +1155,15 @@ static BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT ) { if( !pWVT->hWnd ) { + RECT rc = { 0,0,0,0 }; + pWVT->hWnd = hb_gt_wvt_CreateWindow( pWVT ); if( !pWVT->hWnd ) hb_errInternal( 10001, "Failed to create WVT window", NULL, NULL ); - hb_gt_wvt_InitWindow( pWVT, pWVT->ROWS, pWVT->COLS ); + GetClientRect( pWVT->hWnd, &rc ); + pWVT->width = rc.right - rc.left; + pWVT->height = rc.bottom - rc.top; /* Set icon */ if( pWVT->hIcon ) @@ -1437,91 +1237,6 @@ static void hb_gt_wvt_Exit( PHB_GT pGT ) /* ********************************************************************** */ -static BOOL hb_gt_wvt_SetMode( PHB_GT pGT, int iRow, int iCol ) -{ - PHB_GTWVT pWVT; - BOOL fResult = FALSE; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_SetMode(%p,%d,%d)", pGT, iRow, iCol ) ); - - pWVT = HB_GTWVT_GET( pGT ); - - /* Only execute if iRow|iCol is different then previous settings [pritpal 20081108]*/ - if( iRow <= WVT_MAX_ROWS && iCol <= WVT_MAX_COLS && ( iRow != pWVT->ROWS || iCol != pWVT->COLS ) ) - { - if( pWVT->hWnd ) /* Is the window already open */ - { - /* SETMODE() is supposed to retain the same font as is current */ - /* So no need to recreate it if one is already created [pritpal 20081108] */ - HFONT hFont; - BOOL bCreated; - - if( !pWVT->hFont ) - { - hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, - pWVT->fontWeight, pWVT->fontQuality, pWVT->CodePage ); - bCreated = TRUE; - } - else - { - hFont = pWVT->hFont; - bCreated = FALSE; - } - - if( hFont ) - { - /* - * make sure that the mode selected along with the current - * font settings will fit in the window - */ - if( hb_gt_wvt_ValidWindowSize( pWVT->hWnd, iRow, iCol, hFont, pWVT->fontWidth ) ) - { - fResult = hb_gt_wvt_InitWindow( pWVT, iRow, iCol ); - } - if( bCreated ) - DeleteObject( hFont ); - HB_GTSELF_REFRESH( pGT ); - } - } - else - { - hb_gt_wvt_SetWindowSize( pWVT, iRow, iCol ); - HB_GTSELF_SEMICOLD( pGT ); - } - } - - return fResult; -} - -/* ********************************************************************** */ - -static BOOL hb_gt_wvt_PutChar( PHB_GT pGT, int iRow, int iCol, - BYTE bColor, BYTE bAttr, USHORT usChar ) -{ - if( HB_GTSUPER_PUTCHAR( pGT, iRow, iCol, bColor, bAttr, usChar ) ) - { - HB_GTSELF_TOUCHCELL( pGT, iRow, iCol ); - return TRUE; - } - return FALSE; -} - -/* ********************************************************************** */ - -static const char * hb_gt_wvt_Version( PHB_GT pGT, int iType ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Version(%p,%d)", pGT, iType ) ); - - HB_SYMBOL_UNUSED( pGT ); - - if( iType == 0 ) - return HB_GT_DRVNAME( HB_GT_NAME ); - - return "Harbour Terminal: Windows GUI console (WVG)"; -} - -/* ********************************************************************** */ - static int hb_gt_wvt_ReadKey( PHB_GT pGT, int iEventMask ) { PHB_GTWVT pWVT; @@ -1555,75 +1270,13 @@ static void hb_gt_wvt_Tone( PHB_GT pGT, double dFrequency, double dDuration ) /* ********************************************************************** */ -static BOOL hb_gt_wvt_mouse_IsPresent( PHB_GT pGT ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_gt_wvt_mouse_IsPresent(%p)", pGT)); - - HB_SYMBOL_UNUSED( pGT ); - - return TRUE; -} - -static void hb_gt_wvt_mouse_GetPos( PHB_GT pGT, int * piRow, int * piCol ) -{ - PHB_GTWVT pWVT; - - HB_TRACE(HB_TR_DEBUG, ("hb_gt_wvt_mouse_GetPos(%p,%p,%p)", pGT, piRow, piCol)); - - pWVT = HB_GTWVT_GET( pGT ); - *piRow = pWVT->MousePos.y; - *piCol = pWVT->MousePos.x; -} - -static BOOL hb_gt_wvt_mouse_ButtonState( PHB_GT pGT, int iButton ) -{ - HB_TRACE( HB_TR_DEBUG, ("hb_gt_wvt_mouse_ButtonState(%p,%i)", pGT, iButton) ); - - HB_SYMBOL_UNUSED( pGT ); - - switch( iButton ) - { - case 0: - return ( GetKeyState( VK_LBUTTON ) & 0x8000 ) != 0; - case 1: - return ( GetKeyState( VK_RBUTTON ) & 0x8000 ) != 0; - case 2: - return ( GetKeyState( VK_MBUTTON ) & 0x8000 ) != 0; - } - return FALSE; -} - -static int hb_gt_wvt_mouse_CountButton( PHB_GT pGT ) -{ - HB_TRACE( HB_TR_DEBUG, ("hb_gt_wvt_mouse_CountButton(%p)", pGT) ); - - HB_SYMBOL_UNUSED( pGT ); - - return GetSystemMetrics( SM_CMOUSEBUTTONS ); -} - -/* ********************************************************************** */ - static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { PHB_GTWVT pWVT; int iVal; HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Info(%p,%d,%p)", pGT, iType, pInfo ) ); - /* - if( pInfo->pGT && hb_itemType( pInfo->pGT ) & HB_IT_POINTER ) - { - pGT = hb_gt_ItemBase( pInfo->pGT ); - if( pGT ) - hb_gt_BaseFree( pGT ); - else - pGT = pGTx; - } - if( !pGT ) - { - pGT = pGTx; - } - */ + pWVT = HB_GTWVT_GET( pGT ); switch( iType ) @@ -1658,6 +1311,8 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) break; case HB_GTI_SETFONT: + { + #if 0 pInfo->pResult = hb_itemPutL( pInfo->pResult, FALSE ); if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY ) { @@ -1680,17 +1335,20 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) pWVT->fontQuality = hb_arrayGetNI( pInfo->pNewVal, 5 ); if( pWVT->hWnd ) { - hb_gt_wvt_ResetWindowSize( pWVT ); - HB_GTSELF_REFRESH( pGT ); + //hb_gt_wvt_ResetWindowSize( pWVT ); + //HB_GTSELF_REFRESH( pGT ); } } DeleteObject( hFont ); } } - break; + #endif + break; + } case HB_GTI_FONTSIZE: pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->PTEXTSIZE.y ); + #if 0 iVal = hb_itemGetNI( pInfo->pNewVal ); if( iVal > 0 ) { @@ -1699,14 +1357,17 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) if( hFont ) { pWVT->fontHeight = iVal; + #if 0 if( pWVT->hWnd ) { hb_gt_wvt_ResetWindowSize( pWVT ); HB_GTSELF_REFRESH( pGT ); } + #endif DeleteObject( hFont ); } } + #endif break; case HB_GTI_FONTWIDTH: @@ -1739,23 +1400,31 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) break; case HB_GTI_SCREENHEIGHT: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->PTEXTSIZE.y * pWVT->ROWS ); + { + RECT rc; + GetClientRect( pWVT->hWnd, &rc ); + + pInfo->pResult = hb_itemPutNI( pInfo->pResult, rc.bottom - rc.top ); iVal = hb_itemGetNI( pInfo->pNewVal ); if( iVal > 0 ) { - HB_GTSELF_SETMODE( pGT, ( USHORT ) ( iVal / pWVT->PTEXTSIZE.y ), pWVT->COLS ); + // Set windows new height } break; - + } case HB_GTI_SCREENWIDTH: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->PTEXTSIZE.x * pWVT->COLS ); + { + RECT rc; + GetClientRect( pWVT->hWnd, &rc ); + + pInfo->pResult = hb_itemPutNI( pInfo->pResult, rc.right - rc.left ); iVal = hb_itemGetNI( pInfo->pNewVal ); if( iVal > 0 ) { - HB_GTSELF_SETMODE( pGT, pWVT->ROWS, ( USHORT ) ( iVal / pWVT->PTEXTSIZE.x ) ); + //HB_GTSELF_SETMODE( pGT, pWVT->ROWS, ( USHORT ) ( iVal / pWVT->PTEXTSIZE.x ) ); } break; - + } case HB_GTI_DESKTOPWIDTH: { RECT rDesk; @@ -1813,8 +1482,10 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) if( iVal > 0 && iVal != pWVT->CodePage ) { pWVT->CodePage = iVal; + #if 0 if( pWVT->hWnd ) hb_gt_wvt_ResetWindowSize( pWVT ); + #endif } break; @@ -1944,9 +1615,9 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) hb_arrayNew( pInfo->pResult, 2 ); hb_arraySetNI( pInfo->pResult, 2, pWVT->PTEXTSIZE.y * pWVT->ROWS ); hb_arraySetNI( pInfo->pResult, 1, pWVT->PTEXTSIZE.x * pWVT->COLS ); +#if 0 iY = hb_arrayGetNI( pInfo->pNewVal,2 ); iX = hb_arrayGetNI( pInfo->pNewVal,1 ); - if( iY > 0 ) { BOOL bOldCentre = pWVT->CentreWindow; @@ -1954,6 +1625,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) HB_GTSELF_SETMODE( pGT, ( USHORT ) ( iY / pWVT->PTEXTSIZE.y ), ( USHORT ) ( iX / pWVT->PTEXTSIZE.x ) ); pWVT->CentreWindow = bOldCentre; } +#endif break; } case HB_GTI_RESIZABLE: @@ -2058,8 +1730,10 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) pWVT->CentreWindow = hb_arrayGetL( pInfo->pNewVal2, 1 ); if( hb_arrayGetL( pInfo->pNewVal2, 2 ) ) { + #if 0 if( pWVT->hWnd ) hb_gt_wvt_ResetWindowSize( pWVT ); + #endif } } break; @@ -2075,8 +1749,10 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) break; case HB_GTS_RESETWINDOW: + #if 0 if( pWVT->hWnd ) hb_gt_wvt_ResetWindowSize( pWVT ); + #endif break; case HB_GTS_SETTIMER: @@ -2350,179 +2026,6 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) return TRUE; } -/* ********************************************************************** */ - -static void hb_gt_wvt_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize ) -{ - PHB_GTWVT pWVT; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) ); - - pWVT = HB_GTWVT_GET( pGT ); - if( pWVT ) - { - if( pWVT->hWnd ) - { - RECT rect; - - rect.top = rect.bottom = ( SHORT ) iRow; - rect.left = ( SHORT ) iCol; - rect.right = ( SHORT ) ( iCol + iSize - 1 ); - - rect = hb_gt_wvt_GetXYFromColRowRect( pWVT, rect ); - - InvalidateRect( pWVT->hWnd, &rect, FALSE ); - } - else - pWVT->fInit = TRUE; - } -} - -/* ********************************************************************** */ - -static void hb_gt_wvt_Refresh( PHB_GT pGT ) -{ - PHB_GTWVT pWVT; - - HB_TRACE( HB_TR_DEBUG, ("hb_gt_wvt_Refresh(%p)", pGT) ); - - HB_GTSUPER_REFRESH( pGT ); - - pWVT = HB_GTWVT_GET( pGT ); - if( pWVT ) - { - if( !pWVT->hWnd && pWVT->fInit ) - hb_gt_wvt_CreateConsoleWindow( pWVT ); - - if( pWVT->hWnd ) - { - hb_gt_wvt_ProcessMessages( pWVT ); - } - } -} - -/* ********************************************************************** */ - -static BOOL hb_gt_wvt_SetDispCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP, BOOL fBox ) -{ - HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ); - -#ifndef HB_CDP_SUPPORT_OFF - -#if defined( UNICODE ) - /* - * We are displaying text in U16 so pszTermCDP is unimportant. - * We only have to know what is the internal application codepage - * to make proper translation - */ - if( !pszHostCDP || !*pszHostCDP ) - pszHostCDP = hb_cdpID(); - - if( pszHostCDP && *pszHostCDP ) - { - PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP ); - if( cdpHost ) - HB_GTWVT_GET( pGT )->hostCDP = cdpHost; - } - -#else - - if( !pszHostCDP ) - pszHostCDP = hb_cdpID(); - if( !pszTermCDP ) - pszTermCDP = pszHostCDP; - - if( pszTermCDP && pszHostCDP ) - { - PHB_GTWVT pWVT = HB_GTWVT_GET( pGT ); - PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), - cdpHost = hb_cdpFind( pszHostCDP ); - int i; - - for( i = 0; i < 256; ++i ) - pWVT->chrTransTbl[ i ] = ( BYTE ) i; - - if( cdpTerm && cdpHost && cdpTerm != cdpHost && - cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) - { - for( i = 0; i < cdpHost->nChars; ++i ) - { - pWVT->chrTransTbl[ ( BYTE ) cdpHost->CharsUpper[ i ] ] = - ( BYTE ) cdpTerm->CharsUpper[ i ]; - pWVT->chrTransTbl[ ( BYTE ) cdpHost->CharsLower[ i ] ] = - ( BYTE ) cdpTerm->CharsLower[ i ]; - } - } - } - -#endif - -#endif - - return TRUE; -} - -static BOOL hb_gt_wvt_SetKeyCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP ) -{ - HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP ); - -#ifndef HB_CDP_SUPPORT_OFF - -#if defined( UNICODE ) - /* - * We are receiving WM_CHAR events in U16 so pszTermCDP is unimportant. - * We only have to know what is the internal application codepage - * to make proper translation - */ - if( !pszHostCDP || !*pszHostCDP ) - pszHostCDP = hb_cdpID(); - - if( pszHostCDP && *pszHostCDP ) - { - PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP ); - if( cdpHost ) - HB_GTWVT_GET( pGT )->inCDP = cdpHost; - } - -#else - - if( !pszHostCDP ) - pszHostCDP = hb_cdpID(); - if( !pszTermCDP ) - pszTermCDP = pszHostCDP; - - if( pszTermCDP && pszHostCDP ) - { - PHB_GTWVT pWVT = HB_GTWVT_GET( pGT ); - PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), - cdpHost = hb_cdpFind( pszHostCDP ); - int i; - - for( i = 0; i < 256; ++i ) - pWVT->keyTransTbl[ i ] = ( BYTE ) i; - - if( cdpTerm && cdpHost && cdpTerm != cdpHost && - cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) - { - for( i = 0; i < cdpHost->nChars; ++i ) - { - pWVT->keyTransTbl[ ( BYTE ) cdpTerm->CharsUpper[ i ] ] = - ( BYTE ) cdpHost->CharsUpper[ i ]; - pWVT->keyTransTbl[ ( BYTE ) cdpTerm->CharsLower[ i ] ] = - ( BYTE ) cdpHost->CharsLower[ i ]; - } - } - - pWVT->inCDP = cdpTerm; - } -#endif - -#endif - - return TRUE; -} - - /* ********************************************************************** */ static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable ) @@ -2531,24 +2034,11 @@ static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable ) pFuncTable->Init = hb_gt_wvt_Init; pFuncTable->Exit = hb_gt_wvt_Exit; - pFuncTable->SetMode = hb_gt_wvt_SetMode; - pFuncTable->Redraw = hb_gt_wvt_Redraw; - pFuncTable->Refresh = hb_gt_wvt_Refresh; - pFuncTable->Version = hb_gt_wvt_Version; pFuncTable->Tone = hb_gt_wvt_Tone; pFuncTable->Info = hb_gt_wvt_Info; - pFuncTable->SetDispCP = hb_gt_wvt_SetDispCP; - pFuncTable->SetKeyCP = hb_gt_wvt_SetKeyCP; - - pFuncTable->PutChar = hb_gt_wvt_PutChar; pFuncTable->ReadKey = hb_gt_wvt_ReadKey; - pFuncTable->MouseIsPresent = hb_gt_wvt_mouse_IsPresent; - pFuncTable->MouseGetPos = hb_gt_wvt_mouse_GetPos; - pFuncTable->MouseButtonState = hb_gt_wvt_mouse_ButtonState; - pFuncTable->MouseCountButton = hb_gt_wvt_mouse_CountButton; - return TRUE; } @@ -2576,137 +2066,4 @@ HB_CALL_ON_STARTUP_END( _hb_startup_gt_Init_ ) #pragma data_seg() #endif -//----------------------------------------------------------------------// -//----------------------------------------------------------------------// -//----------------------------------------------------------------------// -#if 0 -/* NOTE: User programs should never call this layer directly! */ -#define HB_GT_NAME GUI - -#define HB_OS_WIN_32_USED -#include "hbgtcore.h" -#include "hbinit.h" -#include "hbapiitm.h" - -/* *********************************************************************** */ - -static int s_GtId; -static HB_GT_FUNCS SuperTable; -#define HB_GTSUPER (&SuperTable) -#define HB_GTID_PTR (&s_GtId) - -/* *********************************************************************** */ - -static const char * hb_gt_gui_Version( PHB_GT pGT, int iType ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_gui_Version(%p,%d)", pGT, iType ) ); - - HB_SYMBOL_UNUSED( pGT ); - - if ( iType == 0 ) - return HB_GT_DRVNAME( HB_GT_NAME ); - - return "Harbour Terminal: Windows dummy console for GUI programs"; -} - -/* *********************************************************************** */ -/* dDuration is in 'Ticks' (18.2 per second) */ -static void hb_gt_gui_Tone( PHB_GT pGT, double dFrequency, double dDuration ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_gt_gui_Tone(%p,%lf,%lf)", pGT, dFrequency, dDuration)); - -#if defined( HB_OS_WIN_32 ) - HB_SYMBOL_UNUSED( pGT ); - hb_gt_w32_tone( dFrequency, dDuration ); -#else - HB_GTSUPER_TONE( pGT, dFrequency, dDuration ); -#endif -} - -/* *********************************************************************** */ - -static BOOL hb_gt_gui_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_gui_Info(%p,%d,%p)", pGT, iType, pInfo ) ); - - switch( iType ) - { -#if defined( HB_OS_WIN_32 ) - case HB_GTI_CLIPBOARDDATA: - if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) - { - hb_gt_w32_setClipboard( CF_TEXT, hb_itemGetCPtr( pInfo->pNewVal ), - hb_itemGetCLen( pInfo->pNewVal ) ); - } - else - { - char * szClipboardData; - ULONG ulLen; - - if( hb_gt_w32_getClipboard( CF_TEXT, &szClipboardData, &ulLen ) ) - { - pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, - szClipboardData, ulLen ); - } - else - { - pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL ); - } - } - break; - - case HB_GTI_KBDSHIFTS: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, hb_gt_w32_getKbdState() ); - if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) - hb_gt_w32_setKbdState( hb_itemGetNI( pInfo->pNewVal ) ); - break; -#endif - default: - return HB_GTSUPER_INFO( pGT, iType, pInfo ); - } - - return TRUE; -} - -/* *********************************************************************** */ - -static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_gt_FuncInit(%p)", pFuncTable)); - - pFuncTable->Version = hb_gt_gui_Version; - pFuncTable->Tone = hb_gt_gui_Tone; - pFuncTable->Info = hb_gt_gui_Info; - - return TRUE; -} - -/* ********************************************************************** */ - -static const HB_GT_INIT gtInit = { HB_GT_DRVNAME( HB_GT_NAME ), - hb_gt_FuncInit, - HB_GTSUPER, - HB_GTID_PTR }; - -HB_GT_ANNOUNCE( HB_GT_NAME ) - -HB_CALL_ON_STARTUP_BEGIN( _hb_startup_gt_Init_ ) - hb_gtRegister( >Init ); -HB_CALL_ON_STARTUP_END( _hb_startup_gt_Init_ ) - -#if defined( HB_PRAGMA_STARTUP ) - #pragma startup _hb_startup_gt_Init_ -#elif defined( HB_MSC_STARTUP ) - #if defined( HB_OS_WIN_64 ) - #pragma section( HB_MSC_START_SEGMENT, long, read ) - #endif - #pragma data_seg( HB_MSC_START_SEGMENT ) - static HB_$INITSYM hb_vm_auto__hb_startup_gt_Init_ = _hb_startup_gt_Init_; - #pragma data_seg() -#endif -//----------------------------------------------------------------------// -#endif // GUI -//----------------------------------------------------------------------// -#endif -//----------------------------------------------------------------------// diff --git a/harbour/contrib/gtwvg/wvggui.h b/harbour/contrib/gtwvg/wvggui.h index b31dcc0f9e..b814fd02b3 100644 --- a/harbour/contrib/gtwvg/wvggui.h +++ b/harbour/contrib/gtwvg/wvggui.h @@ -254,28 +254,6 @@ typedef struct } HB_GT_PARAMS, * PHB_GT_PARAMS; -typedef struct -{ - HPEN penWhite; // White pen to draw GDI elements - HPEN penBlack; // Black pen to draw GDI elements - HPEN penWhiteDim; // White dim pen to draw GDI elements - HPEN penDarkGray; // Dark gray pen to draw GDI elements - HPEN penGray; // Gray pen equivilant to Clipper White - HPEN penNull; // Null pen - HPEN currentPen; // Handle to current pen settable at runtime - HBRUSH currentBrush; // Handle to current brush settable by runtime - HBRUSH diagonalBrush; // Handle to diaoganl brush to draw scrollbars - HBRUSH solidBrush; // Handle to solid brush - HBRUSH wvtWhiteBrush; // Wvt specific White colored brush - IPicture *iPicture[ WVT_PICTURES_MAX ]; // Array to hold the Picture Streams to avoid recurring loading and unloading - HFONT hUserFonts[ WVT_FONTS_MAX ] ; // User defined font handles - HPEN hUserPens[ WVT_PENS_MAX ]; // User defined pens - HINSTANCE hMSImg32; // Handle to the loaded library msimg32.dll - wvtGradientFill pfnGF; // Pointer to Address of the GradientFill function in MSImg32.dll - wvtSetLayeredWindowAttributes pfnLayered;// Pointer to set Windows attribute - transparency. - -} HB_GUIDATA, * PHB_GUIDATA; - typedef struct { PHB_GT pGT; /* core GT pointer */ @@ -320,12 +298,10 @@ typedef struct int CodePage; /* Code page to use for display characters */ BOOL Win9X; /* Flag to say if running on Win9X not NT/2000/XP */ - BOOL AltF4Close; /* Can use Alt+F4 to close application */ BOOL CentreWindow; /* True if window is to be Reset into centre of window */ BOOL IgnoreWM_SYSCHAR; - BOOL bMaximized; /* Flag is set when window has been maximized */ BOOL bResizable; BOOL bClosable; @@ -338,9 +314,6 @@ typedef struct int iFactor; // Transparency factor 0~255 - HDC hdc; // Handle to Windows Device Context - HDC hCompDC; // Compatible DC to _s.hdc - int LastMenuEvent; // Last menu item selected int MenuKeyEvent; // User definable event number for windows menu command BOOL InvalidateWindow; // Flag for controlling whether to use ScrollWindowEx() @@ -351,13 +324,6 @@ typedef struct BOOL bSetFocus; BOOL bKillFocus; - PHB_DYNS pSymWVT_PAINT; // Stores pointer to WVT_PAINT function - PHB_DYNS pSymWVT_SETFOCUS; // Stores pointer to WVT_SETFOCUS function - PHB_DYNS pSymWVT_KILLFOCUS; // Stores pointer to WVT_KILLFOCUS function - PHB_DYNS pSymWVT_MOUSE; // Stores pointer to WVT_MOUSE function - PHB_DYNS pSymWVT_TIMER; // Stores pointer to WVT_TIMER function - PHB_DYNS pSymWVT_KEY; - HINSTANCE hMSImg32; // Handle to the loaded library msimg32.dll wvtGradientFill pfnGF; // Pointer to Address of the GradientFill function in MSImg32.dll HINSTANCE hUser32; // Handle to the loaded library user32.dll @@ -366,8 +332,9 @@ typedef struct PHB_GT_PARAMS pPP; // Presentation Parameters BOOL bTracking; // To track if mouse has eneter or left the window area - BOOL bResizing; // To know when it is in resizing mode + int width; + int height; } HB_GTWVT, * PHB_GTWVT; diff --git a/harbour/contrib/gtwvg/wvgphdlr.prg b/harbour/contrib/gtwvg/wvgphdlr.prg index 2f336cb567..6dc4b9ce6c 100644 --- a/harbour/contrib/gtwvg/wvgphdlr.prg +++ b/harbour/contrib/gtwvg/wvgphdlr.prg @@ -67,12 +67,16 @@ #include 'hbclass.ch' #include 'common.ch' +#include 'hbgtinfo.ch' +#include 'hbgtwvg.ch' +#include 'wvtwin.ch' +#include 'inkey.ch' //----------------------------------------------------------------------// CLASS WvgPartHandler - DATA Cargo + DATA cargo METHOD init( oParent, oOwner ) METHOD create( oParent, oOwner ) @@ -89,6 +93,8 @@ CLASS WvgPartHandler METHOD setOwner( oWvg ) METHOD setParent( oWvg ) + METHOD notifier( nEvent, xParams ) + DATA hChildren INIT hb_hash() DATA nNameId DATA oParent @@ -226,3 +232,120 @@ METHOD setParent( oWvg ) CLASS WvgPartHandler //----------------------------------------------------------------------// +METHOD notifier( nEvent, xParams ) CLASS WvgPartHandler + Local aPos, nReturn := 0 + + DO CASE + + CASE nEvent == HB_GTE_MOUSE + if xParams[ 1 ] == WM_MOUSEHOVER + aPos := { xParams[ 3 ], xParams[ 4 ] } + elseif xParams[ 1 ] == WM_MOUSELEAVE + // Nothing + else + aPos := if( ::mouseMode == 2, { xParams[ 3 ], xParams[ 4 ] }, { xParams[ 5 ], xParams[ 6 ] } ) + endif + + SWITCH xParams[ 1 ] + + case WM_MOUSEHOVER + if hb_isBlock( ::sl_enter ) + eval( ::sl_enter, aPos, NIL, self ) + endif + EXIT + case WM_MOUSELEAVE + if hb_isBlock( ::sl_leave ) + eval( ::sl_leave, aPos, NIL, self ) + endif + EXIT + case WM_RBUTTONDOWN + if hb_isBlock( ::sl_rbDown ) + eval( ::sl_rbDown, aPos, NIL, self ) + endif + EXIT + case WM_LBUTTONDOWN + if hb_isBlock( ::sl_lbDown ) + eval( ::sl_lbDown, aPos, NIL, self ) + endif + EXIT + case WM_RBUTTONUP //// + if hb_isBlock( ::sl_rbUp ) + eval( ::sl_rbUp, aPos, NIL, self ) + endif + EXIT + case WM_LBUTTONUP //// + if hb_isBlock( ::sl_lbUp ) + eval( ::sl_lbUp, aPos, NIL, self ) + endif + EXIT + case WM_RBUTTONDBLCLK + if hb_isBlock( ::sl_rbDblClick ) + eval( ::sl_rbDblClick, aPos, NIL, self ) + endif + EXIT + case WM_LBUTTONDBLCLK + if hb_isBlock( ::sl_lbDblClick ) + eval( ::sl_lbDblClick, aPos, NIL, self ) + endif + EXIT + case WM_MBUTTONDOWN + if hb_isBlock( ::sl_mbDown ) + eval( ::sl_mbDown, aPos, NIL, self ) + endif + EXIT + case WM_MBUTTONUP //// + if hb_isBlock( ::sl_mbClick ) + eval( ::sl_mbClick, aPos, NIL, self ) + endif + EXIT + case WM_MBUTTONDBLCLK + if hb_isBlock( ::sl_mbDblClick ) + eval( ::sl_mbDblClick, aPos, NIL, self ) + endif + EXIT + case WM_MOUSEMOVE + if hb_isBlock( ::sl_motion ) + eval( ::sl_motion, aPos, NIL, self ) + endif + EXIT + case WM_MOUSEWHEEL + if hb_isBlock( ::sl_wheel ) + eval( ::sl_wheel, aPos, NIL, self ) + endif + EXIT + case WM_NCMOUSEMOVE + EXIT + END + + CASE nEvent == HB_GTE_KEYBOARD + if hb_isBlock( ::keyboard ) + eval( ::keyboard, xParams, NIL, Self ) + endif + + CASE nEvent == HB_GTE_SETFOCUS + if hb_isBlock( ::setInputFocus ) + eval( ::setInputFocus, NIL, NIL, Self ) + endif + ::lHasInputFocus := .t. + + CASE nEvent == HB_GTE_KILLFOCUS + if hb_isBlock( ::killInputFocus ) + eval( ::killInputFocus, NIL, NIL, Self ) + endif + ::lHasInputFocus := .f. + + CASE nEvent == HB_GTE_RESIZED + if hb_isBlock( ::sl_resize ) + eval( ::sl_resize, { xParams[ 1 ], xParams[ 2 ] }, { xParams[ 3 ], xParams[ 4 ] }, Self ) + endif + + CASE nEvent == HB_GTE_CLOSE + if hb_isBlock( ::close ) + nReturn := eval( ::close, NIL, NIL, Self ) + endif + + ENDCASE + + RETURN nReturn + +//----------------------------------------------------------------------// diff --git a/harbour/contrib/gtwvg/wvgwin.c b/harbour/contrib/gtwvg/wvgwin.c index a572420430..6fc607e0c0 100644 --- a/harbour/contrib/gtwvg/wvgwin.c +++ b/harbour/contrib/gtwvg/wvgwin.c @@ -477,7 +477,8 @@ HB_FUNC( WIN_GETWINDOWRECT ) } //-------------------------------------------------------------------// - +// Win_MoveWindow( hWnd, nLeft, nTop, nWidth, nHeight, lRePaint ) +// HB_FUNC( WIN_MOVEWINDOW ) { MoveWindow( (HWND) ( HB_PTRDIFF ) hb_parnint( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ), hb_parnl( 5 ), hb_parl( 6 ) ); diff --git a/harbour/contrib/gtwvg/wvgwnd.prg b/harbour/contrib/gtwvg/wvgwnd.prg index fc009a3186..f41a88180d 100644 --- a/harbour/contrib/gtwvg/wvgwnd.prg +++ b/harbour/contrib/gtwvg/wvgwnd.prg @@ -67,7 +67,10 @@ #include 'hbclass.ch' #include 'common.ch' +#include 'hbgtinfo.ch' #include 'hbgtwvg.ch' +#include 'wvtwin.ch' +#include 'inkey.ch' //----------------------------------------------------------------------// @@ -98,6 +101,8 @@ CLASS WvgWindow INHERIT WvgPartHandler DATA aPresParams INIT {} DATA objType INIT objTypeNone DATA ClassName INIT '' + DATA title INIT ' ' + DATA icon INIT 0 // CALLBACK SLOTS DATA sl_enter @@ -215,6 +220,34 @@ EXPORTED: METHOD setDisplayFocus() SETGET METHOD killDisplayFocus() SETGET + // HARBOUR implementation + DATA closable INIT .T. + DATA resizable INIT .t. + DATA resizeMode INIT 0 + DATA style INIT WS_OVERLAPPEDWINDOW + DATA exStyle INIT 0 + DATA lModal INIT .f. + DATA pGTp + DATA pGT + DATA objType INIT objTypeNone + DATA ClassName INIT '' + + METHOD notifier() + METHOD setFocus() + METHOD sendMessage() + +PROTECTED: + DATA hWnd + DATA aPos INIT { 0,0 } + DATA aSize INIT { 0,0 } + DATA aPresParams INIT {} + DATA lHasInputFocus INIT .F. + DATA nFrameState INIT 0 // normal + + DATA maxCol INIT 79 + DATA maxRow INIT 24 + DATA mouseMode INIT 1 + ENDCLASS //----------------------------------------------------------------------// @@ -228,8 +261,16 @@ METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgWind DEFAULT aPresParams TO ::aPresParams DEFAULT lVisible TO ::visible + ::oParent := oParent + ::oOwner := oOwner + ::aPos := aPos + ::aSize := aSize + ::aPresParams := aPresParams + ::visible := lVisible + ::WvgPartHandler:init( oParent, oOwner ) + #if 0 if hb_isArray( aPos ) ::aPos := aPos endif @@ -242,7 +283,7 @@ METHOD init( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgWind if hb_isLogical( lVisible ) ::visible := lVisible endif - + #endif RETURN Self //----------------------------------------------------------------------// @@ -361,14 +402,31 @@ METHOD setPosAndSize() CLASS WvgWindow //----------------------------------------------------------------------// -METHOD setSize() CLASS WvgWindow +METHOD setSize( aSize, lPaint ) CLASS WvgWindow + if hb_isArray( aSize ) + DEFAULT lPaint TO .T. + + switch ::objType + case objTypeDialog + case objTypeActiveX + Win_MoveWindow( ::hWnd, 0, 0, aSize[ 1 ], aSize[ 2 ], lPaint ) + exit + + case objTypeCrt + hb_gtInfo( HB_GTI_SCREENWIDTH , aSize[ 1 ] ) + hb_gtInfo( HB_GTI_SCREENHEIGHT, aSize[ 2 ] ) + exit + + end + endif RETURN Self //----------------------------------------------------------------------// METHOD show() CLASS WvgWindow - + Hb_GtInfo( HB_GTI_SPEC, HB_GTS_SHOWWINDOW, SW_NORMAL ) + ::lHasInputFocus := .t. RETURN Self //----------------------------------------------------------------------// @@ -969,3 +1027,134 @@ METHOD dragDrop( xParam, xParam1 ) CLASS WvgWindow RETURN Self //----------------------------------------------------------------------// +// HARBOUR SPECIFIC +//----------------------------------------------------------------------// + +METHOD notifier( nEvent, xParams ) CLASS WvgWindow + Local aPos, nReturn := 0 + + DO CASE + + CASE nEvent == HB_GTE_MOUSE + if xParams[ 1 ] == WM_MOUSEHOVER + aPos := { xParams[ 3 ], xParams[ 4 ] } + elseif xParams[ 1 ] == WM_MOUSELEAVE + // Nothing + else + aPos := if( ::mouseMode == 2, { xParams[ 3 ], xParams[ 4 ] }, { xParams[ 5 ], xParams[ 6 ] } ) + endif + + SWITCH xParams[ 1 ] + + case WM_MOUSEHOVER + if hb_isBlock( ::sl_enter ) + eval( ::sl_enter, aPos, NIL, self ) + endif + EXIT + case WM_MOUSELEAVE + if hb_isBlock( ::sl_leave ) + eval( ::sl_leave, aPos, NIL, self ) + endif + EXIT + case WM_RBUTTONDOWN + if hb_isBlock( ::sl_rbDown ) + eval( ::sl_rbDown, aPos, NIL, self ) + endif + EXIT + case WM_LBUTTONDOWN + if hb_isBlock( ::sl_lbDown ) + eval( ::sl_lbDown, aPos, NIL, self ) + endif + EXIT + case WM_RBUTTONUP //// + if hb_isBlock( ::sl_rbUp ) + eval( ::sl_rbUp, aPos, NIL, self ) + endif + EXIT + case WM_LBUTTONUP //// + if hb_isBlock( ::sl_lbUp ) + eval( ::sl_lbUp, aPos, NIL, self ) + endif + EXIT + case WM_RBUTTONDBLCLK + if hb_isBlock( ::sl_rbDblClick ) + eval( ::sl_rbDblClick, aPos, NIL, self ) + endif + EXIT + case WM_LBUTTONDBLCLK + if hb_isBlock( ::sl_lbDblClick ) + eval( ::sl_lbDblClick, aPos, NIL, self ) + endif + EXIT + case WM_MBUTTONDOWN + if hb_isBlock( ::sl_mbDown ) + eval( ::sl_mbDown, aPos, NIL, self ) + endif + EXIT + case WM_MBUTTONUP //// + if hb_isBlock( ::sl_mbClick ) + eval( ::sl_mbClick, aPos, NIL, self ) + endif + EXIT + case WM_MBUTTONDBLCLK + if hb_isBlock( ::sl_mbDblClick ) + eval( ::sl_mbDblClick, aPos, NIL, self ) + endif + EXIT + case WM_MOUSEMOVE + if hb_isBlock( ::sl_motion ) + eval( ::sl_motion, aPos, NIL, self ) + endif + EXIT + case WM_MOUSEWHEEL + if hb_isBlock( ::sl_wheel ) + eval( ::sl_wheel, aPos, NIL, self ) + endif + EXIT + case WM_NCMOUSEMOVE + EXIT + END + + CASE nEvent == HB_GTE_KEYBOARD + if hb_isBlock( ::keyboard ) + eval( ::keyboard, xParams, NIL, Self ) + endif + + CASE nEvent == HB_GTE_SETFOCUS + if hb_isBlock( ::setInputFocus ) + eval( ::setInputFocus, NIL, NIL, Self ) + endif + ::lHasInputFocus := .t. + + CASE nEvent == HB_GTE_KILLFOCUS + if hb_isBlock( ::killInputFocus ) + eval( ::killInputFocus, NIL, NIL, Self ) + endif + ::lHasInputFocus := .f. + + CASE nEvent == HB_GTE_RESIZED + if hb_isBlock( ::sl_resize ) + eval( ::sl_resize, { xParams[ 1 ], xParams[ 2 ] }, { xParams[ 3 ], xParams[ 4 ] }, Self ) + endif + + CASE nEvent == HB_GTE_CLOSE + if hb_isBlock( ::close ) + nReturn := eval( ::close, NIL, NIL, Self ) + endif + + ENDCASE + + RETURN nReturn +//----------------------------------------------------------------------// +METHOD setFocus() CLASS WvgWindow + + ::sendMessage( WM_ACTIVATE, 1, 0 ) + + RETURN Self +//----------------------------------------------------------------------// +METHOD sendMessage( nMessage, nlParam, nwParam ) CLASS WvgWindow + + Win_SendMessage( ::hWnd, nMessage, nlParam, nwParam ) + + RETURN Self +//----------------------------------------------------------------------//