From 913cfad6baf392c41f5f6d016b285bbcf1a4744b Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 26 Jan 2009 23:11:50 +0000 Subject: [PATCH] 2009-01-26 15:07 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/gtwvg/gtwvg.c * harbour/contrib/gtwvg/gtwvg.h ! Synchronized with GTWVT per Viktor's changes for box characters. ! Commented out previous change per Przemek's "Layered Attributes". Somehow, this change had increased the flickering of the window as it invalidates the whole window when it regain focus, not desirable behavior in GTWVG with GUI elelments. --- harbour/ChangeLog | 9 +++++++ harbour/contrib/gtwvg/gtwvg.c | 50 +++++++++++++++++++++++++++++------ harbour/contrib/gtwvg/gtwvg.h | 7 +++++ 3 files changed, 58 insertions(+), 8 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 36dcfe3e66..8827eece80 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,15 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-01-26 15:07 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/gtwvg/gtwvg.c + * harbour/contrib/gtwvg/gtwvg.h + ! Synchronized with GTWVT per Viktor's changes for box characters. + ! Commented out previous change per Przemek's "Layered Attributes". + Somehow, this change had increased the flickering of the window as + it invalidates the whole window when it regain focus, not desirable + behavior in GTWVG with GUI elelments. + 2009-01-26 23:37 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/examples/uhttpd/hbmk_b32.bat ! Missed update from previous commit. diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index 821eb80254..25fbdb2861 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -356,6 +356,7 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->hostCDP = hb_vmCDP(); #if defined( UNICODE ) pWVT->inCDP = hb_vmCDP(); + pWVT->boxCDP = hb_cdpFind( "EN" ); #else { int i; @@ -751,6 +752,12 @@ static BOOL hb_gt_wvt_FitSize( PHB_GTWVT pWVT ) { if( pWVT->hFont ) DeleteObject( pWVT->hFont ); +#if ! defined( UNICODE ) + if( pWVT->hFontBox ) + DeleteObject( pWVT->hFontBox ); + + pWVT->hFontBox = hb_gt_wvt_GetFont( pWVT->fontFace, fontHeight, fontWidth, pWVT->fontWeight, pWVT->fontQuality, OEM_CHARSET ); +#endif pWVT->hFont = hFont; pWVT->fontHeight = tm.tmHeight; @@ -866,6 +873,13 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT ) DeleteObject( pWVT->hFont ); pWVT->hFont = hFont; +#if ! defined( UNICODE ) + if( pWVT->hFontBox ) + DeleteObject( pWVT->hFontBox ); + pWVT->hFontBox = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, + pWVT->fontWeight, pWVT->fontQuality, OEM_CHARSET ); +#endif + hdc = GetDC( pWVT->hWnd ); hOldFont = ( HFONT ) SelectObject( hdc, hFont ); GetTextMetrics( hdc, &tm ); @@ -954,7 +968,7 @@ static void hb_gt_wvt_SetWindowTitle( HWND hWnd, const char * title ) static BOOL hb_gt_wvt_GetWindowTitle( HWND hWnd, char ** title ) { - TCHAR buffer[WVT_MAX_TITLE_SIZE]; + TCHAR buffer[ WVT_MAX_TITLE_SIZE ]; int iResult; iResult = GetWindowText( hWnd, buffer, WVT_MAX_TITLE_SIZE ); @@ -1631,6 +1645,9 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect ) RECT rcRect; int iRow, iCol, startCol, len; BYTE bColor, bAttr, bOldColor = 0; +#if ! defined( UNICODE ) + BYTE bOldAttr = 0; +#endif USHORT usChar; TCHAR text[ WVT_MAX_ROWS ]; @@ -1673,25 +1690,43 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect ) break; #if defined( UNICODE ) - usChar = hb_cdpGetU16( pWVT->hostCDP, TRUE, ( BYTE ) usChar ); -#else - usChar = pWVT->chrTransTbl[ usChar & 0xFF ]; -#endif + usChar = hb_cdpGetU16( bAttr & HB_GT_ATTR_BOX ? pWVT->boxCDP : pWVT->hostCDP, TRUE, ( BYTE ) usChar ); if( len == 0 ) { bOldColor = bColor; } else if( bColor != bOldColor ) + { + hb_gt_wvt_TextOut( pWVT, hdc, ( USHORT ) startCol, ( USHORT ) iRow, bOldColor, text, ( USHORT ) len ); + bOldColor = bColor; + startCol = iCol; + len = 0; + } +#else + usChar = pWVT->chrTransTbl[ usChar & 0xFF ]; + if( len == 0 ) + { + SelectObject( hdc, ( bAttr & HB_GT_ATTR_BOX ) ? pWVT->hFontBox : pWVT->hFont ); + bOldAttr = bAttr; + bOldColor = bColor; + } + else if( bColor != bOldColor || bAttr != bOldAttr ) { hb_gt_wvt_TextOut( pWVT, hdc, ( USHORT ) startCol, ( USHORT ) iRow, bOldColor, text, ( USHORT ) len ); if( pWVT->bGui ) { hb_gt_wvt_TextOut( pWVT, pWVT->hGuiDC, ( USHORT ) startCol, ( USHORT ) iRow, bOldColor, text, ( USHORT ) len ); } + if( bAttr != bOldAttr ) + { + SelectObject( hdc, ( bAttr & HB_GT_ATTR_BOX ) ? pWVT->hFontBox : pWVT->hFont ); + bOldAttr = bAttr; + } bOldColor = bColor; startCol = iCol; len = 0; } +#endif text[ len++ ] = ( TCHAR ) usChar; iCol++; } @@ -2167,7 +2202,7 @@ static BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT ) pWVT->hWnd = hb_gt_wvt_CreateWindow( pWVT ); if( !pWVT->hWnd ) hb_errInternal( 10001, "Failed to create WVT window", NULL, NULL ); - +#if 0 if( ! GetSystemMetrics( SM_REMOTESESSION ) ) { typedef BOOL ( WINAPI * P_SLWA )( HWND, COLORREF, BYTE, DWORD ); @@ -2196,7 +2231,7 @@ static BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT ) LWA_ALPHA /* DWORD dwFlags */ ); } } - +#endif hb_gt_wvt_InitWindow( pWVT, pWVT->ROWS, pWVT->COLS ); /* Set icon */ if( pWVT->hIcon ) @@ -3825,7 +3860,6 @@ static void hb_wvt_gtReleaseGuiData( void ) static void hb_wvt_gtCreateObjects( PHB_GTWVT pWVT ) { LOGBRUSH lb; - HINSTANCE h; int iIndex; pWVT->bDeferPaint = FALSE; diff --git a/harbour/contrib/gtwvg/gtwvg.h b/harbour/contrib/gtwvg/gtwvg.h index 7e506f9cc1..770dd81188 100644 --- a/harbour/contrib/gtwvg/gtwvg.h +++ b/harbour/contrib/gtwvg/gtwvg.h @@ -310,12 +310,19 @@ typedef struct int fontQuality; /* requested font quality */ char fontFace[ LF_FACESIZE ]; /* requested font face name LF_FACESIZE #defined in wingdi.h */ HFONT hFont; /* current font handle */ +#if ! defined( UNICODE ) + HFONT hFontBox; /* current font handle to draw lines */ +#endif HWND hWnd; /* the window handle */ BOOL fInit; /* logical variable indicating that window should be open */ PHB_CODEPAGE hostCDP; /* Host/HVM CodePage for unicode output translations */ PHB_CODEPAGE inCDP; /* Host/HVM CodePage for unicode input translations */ +#if defined( UNICODE ) + PHB_CODEPAGE boxCDP; /* CodePage for legacy drawing chars: IBM437 */ +#endif + #if !defined(UNICODE) BYTE keyTransTbl[ 256 ]; BYTE chrTransTbl[ 256 ];