diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b9784cadc4..3f98e8fc51 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,13 @@ 2009-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2009-02-25 18:57 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/gtwvg/gtwvg.c + * harbour/contrib/gtwvg/gtwvg.h + ! Updated to honor Box Caharcter Changes as in GTWVT by Przemek. + ! Updated HB_GTI_CLOSABLE and HB_GTI_RESIZABLE behavior as in GTWVT + by Viktor. + 2009-02-26 20:30 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * bin/hb-mkdyn.bat + Added hbrun-dll.exe generation for msvc64. diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index 81c42abd5c..f03666e1b4 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -84,8 +84,15 @@ #define HB_OS_WIN_USED +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x0500 /* Set to Windows 2000 for WS_EX_LAYERED */ + #include "gtwvg.h" +#if !defined( SM_REMOTESESSION ) + #define SM_REMOTESESSION 0x1000 +#endif + static int s_GtId; static HB_GT_FUNCS SuperTable; #define HB_GTSUPER (&SuperTable) @@ -232,6 +239,13 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) if( pWVT->pszSelectCopy ) hb_xfree( pWVT->pszSelectCopy ); +#if !defined( UNICODE ) + if( pWVT->hFontBox && pWVT->hFontBox != pWVT->hFont ) + DeleteObject( pWVT->hFontBox ); +#endif + if( pWVT->hFont ) + DeleteObject( pWVT->hFont ); + // Detach PRG callback pWVT->pSymWVT_PAINT = NULL; pWVT->pSymWVT_SETFOCUS = NULL; @@ -329,6 +343,9 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->CentreWindow = TRUE; /* Default is to always display window in centre of screen */ pWVT->CodePage = OEM_CHARSET; /* GetACP(); - set code page to default system */ +#if !defined( UNICODE ) + pWVT->boxCodePage = OEM_CHARSET; /* GetACP(); - set code page to default system */ +#endif pWVT->Win9X = ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ); pWVT->AltF4Close = FALSE; @@ -346,6 +363,8 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->ResizeMode = HB_GTI_RESIZEMODE_FONT; + pWVT->bResizing = FALSE; + pWVT->pPP = ( HB_GT_PARAMS * ) hb_xgrab( sizeof( HB_GT_PARAMS ) ); pWVT->pPP->style = WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX; pWVT->pPP->exStyle = 0; @@ -373,8 +392,7 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) #endif #endif - pWVT->bResizing = FALSE; - + /* GUI Related members initialized */ hb_wvt_gtCreateObjects( pWVT ); @@ -628,7 +646,7 @@ static int hb_gt_wvt_key_ansi_to_oem( int c ) BYTE pszAnsi[ 2 ]; BYTE pszOem[ 2 ]; - pszAnsi[ 0 ] = ( BYTE ) c; + pszAnsi[ 0 ] = ( CHAR ) c; pszAnsi[ 1 ] = 0; CharToOemBuffA( ( LPCSTR ) pszAnsi, ( LPSTR ) pszOem, 1 ); @@ -755,14 +773,21 @@ static BOOL hb_gt_wvt_FitSize( PHB_GTWVT pWVT ) tm.tmAveCharWidth >= 3 && tm.tmHeight >= 4 ) { - if( pWVT->hFont ) - DeleteObject( pWVT->hFont ); #if ! defined( UNICODE ) - if( pWVT->hFontBox ) + if( pWVT->hFontBox && pWVT->hFontBox != pWVT->hFont ) DeleteObject( pWVT->hFontBox ); - pWVT->hFontBox = hb_gt_wvt_GetFont( pWVT->fontFace, fontHeight, fontWidth, pWVT->fontWeight, pWVT->fontQuality, OEM_CHARSET ); + if( pWVT->CodePage == pWVT->boxCodePage ) + pWVT->hFontBox = hFont; + else + { + pWVT->hFontBox = hb_gt_wvt_GetFont( pWVT->fontFace, fontHeight, fontWidth, pWVT->fontWeight, pWVT->fontQuality, pWVT->boxCodePage ); + if( !pWVT->hFontBox ) + pWVT->hFontBox = hFont; + } #endif + if( pWVT->hFont ) + DeleteObject( pWVT->hFont ); pWVT->hFont = hFont; pWVT->fontHeight = tm.tmHeight; @@ -879,8 +904,15 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT ) #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 ); + if( pWVT->CodePage == pWVT->boxCodePage ) + pWVT->hFontBox = hFont; + else + { + pWVT->hFontBox = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, + pWVT->fontWeight, pWVT->fontQuality, pWVT->boxCodePage ); + if( !pWVT->hFontBox ) + pWVT->hFontBox = hFont; + } #endif hdc = GetDC( pWVT->hWnd ); @@ -2233,7 +2265,7 @@ static BOOL hb_gt_wvt_ValidWindowSize( HWND hWnd, int rows, int cols, HFONT hFon return ( width <= maxWidth ) && ( height <= maxHeight ); } -static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT ) +static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT, BOOL bResizable ) { HWND hWnd, hWndParent; LPTSTR szAppName; @@ -2317,6 +2349,9 @@ static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT ) pWVT->CentreWindow = TRUE; } + if( ! bResizable ) + pWVT->pPP->style = ( pWVT->pPP->style &~ ( WS_THICKFRAME | WS_MAXIMIZEBOX ) | WS_BORDER ); + hWnd = CreateWindowEx( pWVT->pPP->exStyle, /* extended style */ s_szClassName, /* classname */ @@ -2342,7 +2377,7 @@ static BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT ) if( !pWVT->hWnd ) { - pWVT->hWnd = hb_gt_wvt_CreateWindow( pWVT ); + pWVT->hWnd = hb_gt_wvt_CreateWindow( pWVT, pWVT->bResizable ); if( !pWVT->hWnd ) hb_errInternal( 10001, "Failed to create WVT window", NULL, NULL ); #if 0 @@ -2388,14 +2423,18 @@ static BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT ) hb_gt_wvt_SetWindowTitle( pWVT->hWnd, pFileName->szName ); hb_xfree( pFileName ); } - /* Create "Mark" prompt in SysMenu to allow console type copy operation */ + { HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE ); if( hSysMenu ) { + /* Create "Mark" prompt in SysMenu to allow console type copy operation */ LPTSTR buffer = HB_TCHAR_CONVTO( pWVT->pszSelectCopy ); AppendMenu( hSysMenu, MF_STRING, SYS_EV_MARK, buffer ); HB_TCHAR_FREE( buffer ); + + if( ! pWVT->bClosable ) + EnableMenuItem( hSysMenu, SC_CLOSE, MF_BYCOMMAND | MF_GRAYED ); } } @@ -2524,7 +2563,7 @@ static BOOL hb_gt_wvt_SetMode( PHB_GT pGT, int iRow, int iCol ) } else { - hb_gt_wvt_SetWindowSize( pWVT, iRow, iCol ); + fResult = hb_gt_wvt_SetWindowSize( pWVT, iRow, iCol ); HB_GTSELF_SEMICOLD( pGT ); } } @@ -2788,9 +2827,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_DESKTOPWIDTH: { RECT rDesk; - HWND hDesk; - - hDesk = GetDesktopWindow(); + HWND hDesk = GetDesktopWindow(); GetWindowRect( hDesk, &rDesk ); pInfo->pResult = hb_itemPutNI( pInfo->pResult, rDesk.right - rDesk.left ); break; @@ -2806,8 +2843,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_DESKTOPCOLS: { RECT rDesk; - HWND hDesk; - hDesk = GetDesktopWindow(); + HWND hDesk = GetDesktopWindow(); GetClientRect( hDesk, &rDesk ); pInfo->pResult = hb_itemPutNI( pInfo->pResult, ( rDesk.right - rDesk.left ) / pWVT->PTEXTSIZE.x ); @@ -2816,8 +2852,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_DESKTOPROWS: { RECT rDesk; - HWND hDesk; - hDesk = GetDesktopWindow(); + HWND hDesk = GetDesktopWindow(); GetClientRect( hDesk, &rDesk ); pInfo->pResult = hb_itemPutNI( pInfo->pResult, ( rDesk.bottom - rDesk.top ) / pWVT->PTEXTSIZE.y ); @@ -2838,15 +2873,91 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) case HB_GTI_CODEPAGE: pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->CodePage ); - iVal = hb_itemGetNI( pInfo->pNewVal ); - if( iVal > 0 && iVal != pWVT->CodePage ) + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) { + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal != pWVT->CodePage ) + { + if( !pWVT->hWnd ) + { + pWVT->CodePage = iVal; + } +#if !defined( UNICODE ) + else if( iVal == pWVT->boxCodePage ) + { + if( pWVT->hFont != pWVT->hFontBox ) + { + if( pWVT->hFont ) + DeleteObject( pWVT->hFont ); + pWVT->hFont = pWVT->hFontBox; + } + pWVT->CodePage = iVal; + } +#endif + else + { + HFONT hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, + pWVT->fontWeight, pWVT->fontQuality, iVal ); + if( hFont ) + { + if( pWVT->hFont ) + DeleteObject( pWVT->hFont ); + pWVT->hFont = hFont; pWVT->CodePage = iVal; - if( pWVT->hWnd ) - hb_gt_wvt_ResetWindowSize( pWVT ); + } + } + } } break; + case HB_GTI_BOXCP: +#if defined( UNICODE ) + pInfo->pResult = hb_itemPutC( pInfo->pResult, + pWVT->boxCDP ? pWVT->boxCDP->id : NULL ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + PHB_CODEPAGE cdpBox = hb_cdpFind( hb_itemGetCPtr( pInfo->pNewVal ) ); + if( cdpBox ) + pWVT->boxCDP = cdpBox; + } +#else + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->boxCodePage ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal != pWVT->boxCodePage ) + { + if( !pWVT->hWnd ) + { + pWVT->boxCodePage = iVal; + } + else if( iVal == pWVT->CodePage ) + { + if( pWVT->hFontBox != pWVT->hFont ) + { + if( pWVT->hFontBox ) + DeleteObject( pWVT->hFontBox ); + pWVT->hFontBox = pWVT->hFont; + } + pWVT->boxCodePage = iVal; + } + else + { + HFONT hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, + pWVT->fontWeight, pWVT->fontQuality, iVal ); + if( hFont ) + { + if( pWVT->hFontBox ) + DeleteObject( pWVT->hFontBox ); + pWVT->hFontBox = hFont; + pWVT->boxCodePage = iVal; + } + } + } + } +#endif + break; + case HB_GTI_ICONFILE: { if( ( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) ) diff --git a/harbour/contrib/gtwvg/gtwvg.h b/harbour/contrib/gtwvg/gtwvg.h index 1237851d42..594a05b813 100644 --- a/harbour/contrib/gtwvg/gtwvg.h +++ b/harbour/contrib/gtwvg/gtwvg.h @@ -281,7 +281,7 @@ typedef struct PHB_GT pGT; /* core GT pointer */ int iHandle; /* window number */ - HINSTANCE hInstance; + HINSTANCE hInstance; /* parent window instance */ int iCmdShow; USHORT ROWS; /* number of displayable rows in window */ @@ -324,7 +324,7 @@ typedef struct PHB_CODEPAGE boxCDP; /* CodePage for legacy drawing chars: IBM437 */ #endif -#if !defined(UNICODE) +#if !defined( UNICODE ) BYTE keyTransTbl[ 256 ]; BYTE chrTransTbl[ 256 ]; #endif @@ -333,6 +333,9 @@ typedef struct BOOL bIconToFree; /* Do we need to free this icon when it's not NULL? */ int CodePage; /* Code page to use for display characters */ +#if ! defined( UNICODE ) + int boxCodePage; /* Code page to use for display draw line characters */ +#endif 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 */ @@ -506,8 +509,22 @@ typedef struct _tag_HB_GT_COLDEF #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 POINT HB_EXPORT hb_wvt_gtGetXYFromColRow( USHORT col, USHORT row ); IPicture HB_EXPORT * hb_wvt_gtLoadPicture( char * image );