diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 703817a9b8..13ff3ada79 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,45 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-11-22 04:33 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/harbour-ce-spec + * harbour/harbour-w32-spec + * harbour/make_rpmce.sh + * harbour/make_rpmw32.sh + * updated for removed ace.h + + * harbour/bin/pack_src.sh + * updated for some recent modifications in contrib/pgsql + TOFIX: it should be updated for all recent modifications in + contrib and MS-Windows build scripts. + + * harbour/bin/hb-func.sh + + added gtwvg to -gt* parameters in hb* scripts + + * harbour/contrib/Makefile + + added gtwvg in W32 builds + + * harbour/contrib/xhb/hbcomprs.c + * harbour/contrib/xhb/hbcomprs.h + * cleaned some warnings + + * harbour/contrib/gtwvg/gtwvt.h + * harbour/contrib/gtwvg/wvtutils.c + * harbour/contrib/gtwvg/wvtpaint.prg + * harbour/contrib/gtwvg/wvtwin.ch + * harbour/contrib/gtwvg/wvtcore.c + * harbour/contrib/gtwvg/gtwvt.c + * harbour/contrib/gtwvg/Makefile + * harbour/contrib/gtwvg/wvtclass.prg + * set svn attributes: + svn ps svn:eol-style native + svn ps svn:keywords Id + Pritpal please remember about it before you commit new files. + For .bat files use + svn ps svn:eol-style CRLF + or better set default attribute in your SVN config file so you will + not have to set it manually each time you are adding new file. + 2007-11-21 06:08 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com) + contrib/gtwvt + gtwvt.c diff --git a/harbour/bin/hb-func.sh b/harbour/bin/hb-func.sh index ce3e5aeb78..c7df363337 100755 --- a/harbour/bin/hb-func.sh +++ b/harbour/bin/hb-func.sh @@ -88,7 +88,7 @@ mk_hbgetlibsctb() then libs="$libs gtwin" fi - echo -n "$libs rddads ct nf tip xhb hbgd hbodbc hbpg hbmysql adordd hbwin32" + echo -n "$libs rddads ct nf tip xhb hbgd hbodbc hbpg hbmysql adordd hbwin32 gtwvg" else echo -n "$@" fi diff --git a/harbour/bin/pack_src.sh b/harbour/bin/pack_src.sh index edaf98f512..987e1f2ea3 100755 --- a/harbour/bin/pack_src.sh +++ b/harbour/bin/pack_src.sh @@ -392,12 +392,16 @@ $hb_collect contrib/win32/test/*.prg # CONTRIB\PGSQL $hb_collect contrib/pgsql/[mM]akefile* $hb_collect contrib/pgsql/Change[Ll]og* -$hb_collect contrib/pgsql/README +$hb_collect contrib/pgsql/README* +$hb_collect contrib/pgsql/readme* $hb_collect contrib/pgsql/*.[ch] $hb_collect contrib/pgsql/*.ch $hb_collect contrib/pgsql/*.prg $hb_collect contrib/pgsql/*.txt $hb_collect contrib/pgsql/*.bat +$hb_collect contrib/pgsql/test/[mM]akefile* +$hb_collect contrib/pgsql/test/*.prg +$hb_collect contrib/win32/*.bat # CONTRIB\MYSQL $hb_collect contrib/mysql/[mM]akefile* diff --git a/harbour/contrib/Makefile b/harbour/contrib/Makefile index 101bb0221f..e663873680 100644 --- a/harbour/contrib/Makefile +++ b/harbour/contrib/Makefile @@ -28,6 +28,7 @@ ifeq ($(HB_ARCHITECTURE),w32) DIRS +=\ rdd_ads \ + gtwvg \ ifneq ($(HB_COMPILER),rsxnt) diff --git a/harbour/contrib/gtwvg/Makefile b/harbour/contrib/gtwvg/Makefile index 6d2ab9b864..c0ed818cce 100644 --- a/harbour/contrib/gtwvg/Makefile +++ b/harbour/contrib/gtwvg/Makefile @@ -1,24 +1,24 @@ -# -# -# - -ROOT = ../../ - -C_SOURCES=\ - gtwvt.c \ - wvtcore.c \ - wvtutils.c \ - -C_HEADERS=\ - gtwvt.h \ - -PRG_SOURCES=\ - wvtclass.prg \ - wvtpaint.prg \ - -PRG_HEADERS=\ - wvtwin.ch \ - -LIBNAME=gtwvg - -include $(TOP)$(ROOT)config/lib.cf +# +# $Id$ +# + +ROOT = ../../ + +C_SOURCES=\ + gtwvt.c \ + wvtcore.c \ + wvtutils.c \ + +C_HEADERS=\ + gtwvt.h \ + +PRG_SOURCES=\ + wvtclass.prg \ + wvtpaint.prg \ + +PRG_HEADERS=\ + wvtwin.ch \ + +LIBNAME=gtwvg + +include $(TOP)$(ROOT)config/lib.cf diff --git a/harbour/contrib/gtwvg/gtwvt.c b/harbour/contrib/gtwvg/gtwvt.c index 149707856f..68ee1ffd06 100644 --- a/harbour/contrib/gtwvg/gtwvt.c +++ b/harbour/contrib/gtwvg/gtwvt.c @@ -1,5096 +1,5096 @@ -/* - * Chr(36) + "Id" + Chr(36) - */ - -/* - * Harbour Project source code: - * Video subsystem for Win32 using GUI windows instead of Console - * Copyright 2003 Peter Rees - * Rees Software & Systems Ltd - * based on - * Bcc ConIO Video subsystem by - * Copyright 2002 Marek Paliwoda - * Copyright 2002 Przemyslaw Czerpak - * Video subsystem for Win32 compilers - * Copyright 1999-2000 Paul Tucker - * Copyright 2002 Przemysław Czerpak - * - * The following parts are Copyright of the individual authors. - * www - http://www.harbour-project.org - * - * - * Copyright 1999 David G. Holm - * hb_gt_Tone() - * - * See doc/license.txt for licensing terms. - * - * www - 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. - * - */ - -//-------------------------------------------------------------------// -/* -* Individual authors: -* (C) 2003-2004 Giancarlo Niccolai -* Standard xplatform GT Info system, -* Graphical object system and event system. -* GTINFO() And GTO_* implementation. -* -* (C) 2004 Mauricio Abre -* Cross-GT, multiplatform Graphics API -* -*/ -//-------------------------------------------------------------------// - -#define HB_OS_WIN_32_USED - -#ifndef _WIN32_IE - #define _WIN32_IE 0x0400 -#endif - -#include "gtwvt.h" - -static HB_GT_FUNCS SuperTable; -#define HB_GTSUPER (&SuperTable) - -#if defined(__WATCOMC__) - #include -#endif - -#ifndef WM_MOUSEWHEEL - #define WM_MOUSEWHEEL 0x020A -#endif - -#ifndef INVALID_FILE_SIZE - #define INVALID_FILE_SIZE (DWORD)0xFFFFFFFF -#endif - -#ifndef CC_ANYCOLOR - #define CC_ANYCOLOR 0x00000100 -#endif - -#ifndef IDC_HAND - #define IDC_HAND MAKEINTRESOURCE(32649) -#endif - -//----------------------------------------------------------------------// - -static TCHAR szAppName[] = TEXT( "Harbour WVT" ); - -static GLOBAL_DATA _s; - -static COLORREF _COLORS[] = { - BLACK, - BLUE, - GREEN, - CYAN, - RED, - MAGENTA, - BROWN, - WHITE, - LIGHT_GRAY, - BRIGHT_BLUE, - BRIGHT_GREEN, - BRIGHT_CYAN, - BRIGHT_RED, - BRIGHT_MAGENTA, - YELLOW, - BRIGHT_WHITE -}; - -#ifdef WVT_DEBUG -static int nCountPuts=0,nCountScroll=0, nCountPaint=0, nSetFocus=0, nKillFocus=0; -#endif - -static int K_Ctrl[] = { - K_CTRL_A, K_CTRL_B, K_CTRL_C, K_CTRL_D, K_CTRL_E, K_CTRL_F, K_CTRL_G, K_CTRL_H, - K_CTRL_I, K_CTRL_J, K_CTRL_K, K_CTRL_L, K_CTRL_M, K_CTRL_N, K_CTRL_O, K_CTRL_P, - K_CTRL_Q, K_CTRL_R, K_CTRL_S, K_CTRL_T, K_CTRL_U, K_CTRL_V, K_CTRL_W, K_CTRL_X, - K_CTRL_Y, K_CTRL_Z - }; - -//static buffer[100]; - -//-------------------------------------------------------------------// -// -// private functions declaration -// -//HB_EXTERN_BEGIN -static void gt_hbInitStatics( void ); -static HWND hb_wvt_gtCreateWindow( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow ); -static BOOL hb_wvt_gtInitWindow( HWND hWnd, USHORT col, USHORT row ); -static void hb_wvt_gtResetWindowSize( HWND hWnd ); -static LRESULT CALLBACK hb_wvt_gtWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); -static BOOL hb_wvt_gtAllocSpBuffer( USHORT col, USHORT row ); -static DWORD hb_wvt_gtProcessMessages( void ); -static BOOL hb_wvt_gtValidWindowSize( int rows, int cols, HFONT hFont, int width ); -static void hb_wvt_gtSetCaretOn( BOOL bOn ); -static BOOL hb_wvt_gtSetCaretPos( void ); -static void hb_wvt_gtValidateCaret( void ); -static void hb_wvt_gtUpdateCaret( void ); - -static USHORT hb_wvt_gtGetMouseX( void ); -static USHORT hb_wvt_gtGetMouseY( void ); -static void hb_wvt_gtSetMouseX( USHORT ix ); -static void hb_wvt_gtSetMouseY( USHORT iy ); -static BOOL hb_wvt_gtGetCharFromInputQueue( int * c ); - -static void hb_wvt_gtTranslateKey( int key, int shiftkey, int altkey, int controlkey ); - -static void hb_wvt_gtSetInvalidRect( USHORT left, USHORT top, USHORT right, USHORT bottom ); -static void hb_wvt_gtDoInvalidateRect( void ); - -static void hb_wvt_gtHandleMenuSelection( int ); - -static POINT hb_wvt_gtGetColRowFromXY( USHORT x, USHORT y ); -static RECT hb_wvt_gtGetColRowFromXYRect( RECT xy ); -static POINT hb_wvt_gtGetColRowForTextBuffer( USHORT index ); - -static void hb_wvt_gtValidateCol( void ); -static void hb_wvt_gtValidateRow( void ); - -static USHORT hb_wvt_gtCalcPixelHeight( void ); -static USHORT hb_wvt_gtCalcPixelWidth( void ); -static BOOL hb_wvt_gtSetColors( HDC hdc, BYTE attr ); -static HFONT hb_wvt_gtGetFont( char * pszFace, int iHeight, int iWidth, int iWeight, int iQuality, int iCodePage ); - -static BOOL hb_wvt_gtTextOut( HDC hdc, USHORT col, USHORT row, LPCTSTR lpString, USHORT cbString ); -static void hb_wvt_gtSetStringInTextBuffer( USHORT col, USHORT row, BYTE attr, BYTE *sBuffer, USHORT length ); -static USHORT hb_wvt_gtGetIndexForTextBuffer( USHORT col, USHORT row ); -static RECT hb_wvt_gtGetXYFromColRowRect( RECT colrow ); -static void hb_wvt_gtCreateObjects( void ); -static void hb_wvt_gtKillCaret( void ); -static void hb_wvt_gtCreateCaret( void ); -static void hb_wvt_gtMouseEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); -static void hb_wvt_gtCreateToolTipWindow( void ); -static void hb_wvt_gtRestGuiState( LPRECT rect ); -static void hb_wvt_gtInitGui( void ); -static void hb_wvt_gtPaintText( HWND hWnd, RECT rect ); -static BOOL hb_wvt_gtKeyEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); - -static void HB_GT_FUNC( gt_Init( FHANDLE iFilenoStdin, FHANDLE iFilenoStdout, FHANDLE iFilenoStderr ) ); -static void HB_GT_FUNC( gt_Exit( void ) ); -//static void HB_GT_FUNC( gt_ProcessMessages( void ) ); -static void HB_GT_FUNC( gt_GetClipboard( char *szData, ULONG *pulMaxSize ) ); -static void HB_GT_FUNC( gt_SetClipboard( char *szData, ULONG ulSize ) ); -//static ULONG HB_GT_FUNC( gt_GetClipboardSize( void ) ); -//static USHORT HB_GT_FUNC( gt_GetScreenWidth( void ) ); -//static USHORT HB_GT_FUNC( gt_GetScreenHeight( void ) ); -static SHORT HB_GT_FUNC( gt_Col( void ) ); -static SHORT HB_GT_FUNC( gt_Row( void ) ); -static void HB_GT_FUNC( gt_SetPos( int sRow, int sCol ) ); -static void HB_GT_FUNC( gt_GetPos( int * sRow, int * sCol ) ); -//static BOOL HB_GT_FUNC( gt_AdjustPos( BYTE * pStr, ULONG ulLen ) ); -static BOOL HB_GT_FUNC( gt_IsColor( void ) ); - -static void HB_GT_FUNC( gt_DispEnd( void ) ); -static int HB_GT_FUNC( gt_DispCount( void ) ); -static void HB_GT_FUNC( gt_DispBegin( void ) ); -static void HB_GT_FUNC( gt_GetPos( int * sRow, int * sCol ) ); -static void HB_GT_FUNC( gt_Box( int Top, int Left, int Bottom, int Right, BYTE * szBox, BYTE byAttr ) ); -static void HB_GT_FUNC( gt_BoxD( int Top, int Left, int Bottom, int Right, BYTE * pbyFrame, BYTE byAttr ) ); -static void HB_GT_FUNC( gt_BoxS( int Top, int Left, int Bottom, int Right, BYTE * pbyFrame, BYTE byAttr ) ); -static void HB_GT_FUNC( gt_HorizLine( int Row, int Left, int Right, BYTE byChar, BYTE byAttr ) ); -static void HB_GT_FUNC( gt_VertLine( int Col, int Top, int Bottom, BYTE byChar, BYTE byAttr ) ); -static int HB_GT_FUNC( gt_GetCursorStyle( void ) ); -static void HB_GT_FUNC( gt_SetCursorStyle( int usStyle ) ); -static void HB_GT_FUNC( gt_PutText( int top, int left, BYTE bColor, BYTE * pText, ULONG ulLen ) ); -static void HB_GT_FUNC( gt_xPutText( int top, int left, int bottom, int right, BYTE * sBuffer ) ); -static void HB_GT_FUNC( gt_GetText( int top, int left, int bottom, int right, BYTE * sBuffer ) ); -static void HB_GT_FUNC( gt_SetAttribute( int rowStart, int colStart, int rowStop, int colStop, BYTE attr ) ); -static BOOL HB_GT_FUNC( gt_SetMode( int row, int col ) ); -static void HB_GT_FUNC( gt_Scroll( int usTop, int usLeft, int usBottom, int usRight, BYTE byAttr, BYTE byChar, int iRows, int iCols ) ); -static BOOL HB_GT_FUNC( gt_Info( int iType, PHB_GT_INFO pInfo ) ); -static int HB_GT_FUNC( gt_MaxCol( void ) ); -static int HB_GT_FUNC( gt_MaxRow( void ) ); -static BOOL HB_GT_FUNC( gt_SetDispCP( char * pszTermCDP, char * pszHostCDP, BOOL fBox ) ); -static BOOL HB_GT_FUNC( gt_SetKeyCP( char * pszTermCDP, char * pszHostCDP ) ); - -static void HB_GT_FUNC( gt_Replicate( USHORT usRow, USHORT usCol, BYTE byAttr, BYTE byChar, ULONG ulLen ) ); -//static int HB_GT_FUNC( gt_RectSize( USHORT rows, USHORT cols ) ); -static void HB_GT_FUNC( gt_Puts( USHORT usRow, USHORT usCol, BYTE byAttr, BYTE *pbyStr, ULONG ulLen ) ); -static void HB_GT_FUNC( gt_xPutch( USHORT iRow, USHORT iCol, BYTE bAttr, BYTE bChar ) ); -static char * HB_GT_FUNC( gt_Version( int iType ) ); -//static void HB_GT_FUNC( gt_SetAttributeCT( USHORT rowStart, USHORT colStart, USHORT rowStop, USHORT colStop, BYTE attr ) ); -static void HB_GT_FUNC( gt_SetBlink( BOOL bBlink ) ); -static BOOL HB_GT_FUNC( gt_GetBlink( void ) ); - -//-------------------------------------------------------------------// -// -// mouse initialization was made in cmdarg.c -// - -// set in mainwin.c -// -extern HANDLE hb_hInstance; -extern HANDLE hb_hPrevInstance; -static int hb_iCmdShow = SW_NORMAL; - -static int s_uiDispCount = 0; -static int s_usCursorStyle; -static int s_usOldCurStyle; - -static int s_iStdIn, s_iStdOut, s_iStdErr; - -static BOOL b_MouseEnable = TRUE; - -#define _GetScreenHeight() (_s.ROWS) -#define _GetScreenWidth() (_s.COLS) - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// WVT specific functions -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Modeless Dialogs Implementation -// -//-------------------------------------------------------------------// - -HB_EXPORT BOOL CALLBACK hb_wvt_gtDlgProcMLess( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) -{ - int iIndex, iType; - long int bReturn = FALSE ; - PHB_ITEM pFunc = NULL; - PHB_DYNS pDynSym; - - iType = (int) NULL; - - for ( iIndex = 0; iIndex < WVT_DLGML_MAX; iIndex++ ) - { - if ( ( _s.hDlgModeless[ iIndex ] != NULL ) && ( _s.hDlgModeless[ iIndex ] == hDlg ) ) - { - if ( _s.pFunc[ iIndex ] != NULL ) - { - pFunc = _s.pFunc[ iIndex ]; - iType = _s.iType[ iIndex ]; - } - break; - } - } - - if ( pFunc ) - { - switch ( iType ) - { - case 1: // Function Name - { - pDynSym = ( PHB_DYNS ) pFunc; - hb_vmPushState(); - hb_vmPushSymbol( hb_dynsymSymbol( pDynSym ) ); - hb_vmPushNil(); - hb_vmPushLong( ( ULONG ) hDlg ); - hb_vmPushLong( ( UINT ) message ); - hb_vmPushLong( ( ULONG ) wParam ); - hb_vmPushLong( ( ULONG ) lParam ); - hb_vmDo( 4 ); - //bReturn = hb_itemGetNL( hb_stackReturnItem() ); - bReturn = hb_parnl( -1 ); - - hb_vmPopState(); - break; - } - - case 2: // Block - { - /* eval the codeblock */ - //if ( _s.pFunc[ iIndex ]->type == HB_IT_BLOCK ) - if ( hb_itemType( _s.pFunc[ iIndex ] ) == HB_IT_BLOCK ) - { - PHB_ITEM hihDlg, himessage, hiwParam, hilParam; - PHB_ITEM pReturn; - - //hihDlg.type = HB_IT_NIL; - hb_itemPutNL( &hihDlg, (ULONG) hDlg ); - - //himessage.type = HB_IT_NIL; - hb_itemPutNL( &himessage, (ULONG) message ); - - //hiwParam.type = HB_IT_NIL; - hb_itemPutNL( &hiwParam, (ULONG) wParam ); - - //hilParam.type = HB_IT_NIL; - hb_itemPutNL( &hilParam, (ULONG) lParam ); - - pReturn = hb_itemDo( (PHB_ITEM) _s.pFunc[ iIndex ], 4, &hihDlg, &himessage, &hiwParam, &hilParam ); - bReturn = hb_itemGetNL( pReturn ); - hb_itemRelease( pReturn ); - } - else - { - //internal error: missing codeblock - } - - - break; - } - } - } - - switch( message ) - { - case WM_COMMAND: - { - switch( LOWORD( wParam ) ) - { - case IDOK: - { - DestroyWindow( hDlg ); - bReturn = TRUE; - } - break; - - case IDCANCEL: - { - DestroyWindow( hDlg ); - bReturn = FALSE; - } - break; - } - } - break; - - case WM_CLOSE: - { - DestroyWindow( hDlg ); - bReturn = FALSE; - } - break; - - case WM_NCDESTROY: - { - if ( _s.pFunc[ iIndex ] != NULL && _s.iType[ iIndex ] == 2 ) - { - hb_itemRelease( ( PHB_ITEM ) _s.pFunc[ iIndex ] ); - } - _s.hDlgModeless[ iIndex ] = NULL; - _s.pFunc[ iIndex ] = NULL; - _s.iType[ iIndex ] = (int) NULL; - bReturn = FALSE; - } - break; - } - - return bReturn; -} - -//-------------------------------------------------------------------// - -HB_EXPORT BOOL CALLBACK hb_wvt_gtDlgProcModal( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) -{ - int iIndex, iType; - long int bReturn = FALSE ; - PHB_ITEM pFunc = NULL; - PHB_DYNS pDynSym; - int iFirst = ( int ) lParam; - - if ( iFirst > 0 && iFirst <= WVT_DLGMD_MAX ) - { - _s.hDlgModal[ iFirst-1 ] = hDlg ; - SendMessage( hDlg, WM_INITDIALOG, 0, 0 ); - return ( bReturn ); - } - - iType = ( int ) NULL; - - for ( iIndex = 0; iIndex < WVT_DLGMD_MAX; iIndex++ ) - { - if ( ( _s.hDlgModal[ iIndex ] != NULL ) && ( _s.hDlgModal[ iIndex ] == hDlg ) ) - { - if ( _s.pFuncModal[ iIndex ] != NULL ) - { - pFunc = _s.pFuncModal[ iIndex ]; - iType = _s.iTypeModal[ iIndex ]; - } - break; - } - } - - if ( pFunc ) - { - switch ( iType ) - { - case 1: // Function Name - { - pDynSym = ( PHB_DYNS ) pFunc; - hb_vmPushState(); - hb_vmPushSymbol( hb_dynsymSymbol( pDynSym ) ); - - hb_vmPushNil(); - hb_vmPushLong( ( ULONG ) hDlg ); - hb_vmPushLong( ( UINT ) message ); - hb_vmPushLong( ( ULONG ) wParam ); - hb_vmPushLong( ( ULONG ) lParam ); - hb_vmDo( 4 ); - //bReturn = hb_itemGetNL( hb_stackReturnItem() ); - bReturn = hb_parnl( -1 ); - - hb_vmPopState(); - break; - } - - case 2: // Block - { - /* eval the codeblock */ - if ( hb_itemType( _s.pFuncModal[ iIndex ] ) == HB_IT_BLOCK ) - { - PHB_ITEM hihDlg, himessage, hiwParam, hilParam; - PHB_ITEM pReturn; - - //hihDlg.type = HB_IT_NIL; - hb_itemPutNL( &hihDlg, (ULONG) hDlg ); - - //himessage.type = HB_IT_NIL; - hb_itemPutNL( &himessage, (ULONG) message ); - - //hiwParam.type = HB_IT_NIL; - hb_itemPutNL( &hiwParam, (ULONG) wParam ); - - //hilParam.type = HB_IT_NIL; - hb_itemPutNL( &hilParam, (ULONG) lParam ); - - pReturn = hb_itemDo( (PHB_ITEM) _s.pFuncModal[ iIndex ], 4, &hihDlg, &himessage, &hiwParam, &hilParam ); - bReturn = hb_itemGetNL( pReturn ); - hb_itemRelease( pReturn ); - } - else - { - //internal error: missing codeblock - } - - break; - } - } - } - - switch( message ) - { - case WM_COMMAND: - { - switch( LOWORD( wParam ) ) - { - case IDOK: - { - EndDialog( hDlg, IDOK ); - bReturn = TRUE; - } - break; - - case IDCANCEL: - { - EndDialog( hDlg, IDCANCEL ); - bReturn = FALSE; - } - break; - } - } - break; - - case WM_CLOSE: - { - EndDialog( hDlg, IDCANCEL ); - bReturn = FALSE; - } - break; - - case WM_NCDESTROY: - { - if ( _s.pFuncModal[ iIndex ] != NULL && _s.iTypeModal[ iIndex ] == 2 ) - { - hb_itemRelease( ( PHB_ITEM ) _s.pFuncModal[ iIndex ] ); - } - - _s.hDlgModal[ iIndex ] = NULL; - _s.pFuncModal[ iIndex ] = NULL; - _s.iTypeModal[ iIndex ] = ( int ) NULL; - bReturn = FALSE; - } - break; - } - - return bReturn; -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtCreateObjects( void ) -{ - LOGBRUSH lb; - - _s.penWhite = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 255,255,255 ) ); - _s.penBlack = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 0, 0, 0 ) ); - _s.penWhiteDim = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 205,205,205 ) ); - _s.penDarkGray = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 150,150,150 ) ); - _s.penGray = CreatePen( PS_SOLID, 0, ( COLORREF ) _COLORS[ 7 ] ); - _s.penNull = CreatePen( PS_NULL , 0, ( COLORREF ) _COLORS[ 7 ] ); - - _s.currentPen = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 0, 0, 0 ) ); - - lb.lbStyle = BS_NULL; - lb.lbColor = RGB( 198,198,198 ); - lb.lbHatch = 0; - _s.currentBrush = CreateBrushIndirect( &lb ); - - lb.lbStyle = BS_HATCHED; - lb.lbColor = RGB( 210,210,210 ); - lb.lbHatch = HS_DIAGCROSS; // HS_BDIAGONAL; - _s.diagonalBrush = CreateBrushIndirect( &lb ); - - lb.lbStyle = BS_SOLID; - lb.lbColor = 0; // NULL; // RGB( 0,0,0 ); - lb.lbHatch = 0; - _s.solidBrush = CreateBrushIndirect( &lb ); - - lb.lbStyle = BS_SOLID; - lb.lbColor = _COLORS[ 7 ]; - lb.lbHatch = 0; - _s.wvtWhiteBrush= CreateBrushIndirect( &lb ); - -} - -//-------------------------------------------------------------------// - -static USHORT hb_wvt_gtCalcPixelHeight( void ) -{ - return( (USHORT)( _s.PTEXTSIZE.y *_GetScreenHeight() ) ); -} - -//-------------------------------------------------------------------// - -static USHORT hb_wvt_gtCalcPixelWidth( void ) -{ - return( (USHORT)( _s.PTEXTSIZE.x * _GetScreenWidth() ) ); -} - -//-------------------------------------------------------------------// - -static BOOL hb_wvt_gtAllocSpBuffer( USHORT col, USHORT row ) /* NO */ -{ - BOOL bRet = TRUE; - - _s.COLS = col; - _s.ROWS = row; - _s.BUFFERSIZE = col * row * sizeof( char ); - _s.pBuffer = _s.byBuffer ; - _s.pAttributes = _s.byAttributes; - memset( _s.pBuffer, ' ', _s.BUFFERSIZE ); - memset( _s.pAttributes,_s.background, _s.BUFFERSIZE ); - - return( bRet ); -} - -//-------------------------------------------------------------------// - -static BOOL hb_wvt_gtInitWindow( HWND hWnd, USHORT col, USHORT row ) /* DIFF */ -{ - BOOL bRet = hb_wvt_gtAllocSpBuffer( col, row ); - - hb_wvt_gtResetWindowSize( hWnd ); - - return( bRet ); -} - -//-------------------------------------------------------------------// - -static BOOL hb_wvt_gtValidWindowSize( 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 = (SHORT) ( rcWorkArea.right - rcWorkArea.left ); - maxHeight = (SHORT) ( rcWorkArea.bottom - rcWorkArea.top ); - - hdc = GetDC( _s.hWnd ); - hOldFont = ( HFONT ) SelectObject( hdc, hFont ); - GetTextMetrics( hdc, &tm ); - SelectObject( hdc, hOldFont ); // Put old font back - ReleaseDC( _s.hWnd, hdc ); - - width = iWidth < 0 ? -iWidth : (USHORT)( tm.tmAveCharWidth * cols ) ; - height = (USHORT)( tm.tmHeight * rows ); - - return( ( width <= maxWidth ) && ( height <= maxHeight ) ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtResetWindowSize( HWND hWnd ) -{ - HDC hdc; - HFONT hFont, hOldFont ; - USHORT diffWidth, diffHeight; - USHORT height, width; - RECT wi, ci; - TEXTMETRIC tm; - // HMENU hMenu; - RECT rcWorkArea; - int n; - - // set the font and get it's size to determine the size of the client area - // for the required number of rows and columns - // - hdc = GetDC( hWnd ); - hFont = hb_wvt_gtGetFont( _s.fontFace, _s.fontHeight, _s.fontWidth, _s.fontWeight, _s.fontQuality, _s.CodePage ); - - if ( _s.hFont ) - { - DeleteObject( _s.hFont ); - } - - _s.hFont = hFont ; - hOldFont = ( HFONT ) SelectObject( hdc, hFont ); - //if ( hOldFont ) - //{ - // DeleteObject( hOldFont ); - //} - GetTextMetrics( hdc, &tm ); - SetTextCharacterExtra( hdc,0 ); // do not add extra char spacing even if bold - SelectObject( hdc, hOldFont ); - ReleaseDC( hWnd, hdc ); - - // 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! - // - - _s.PTEXTSIZE.x = _s.fontWidth<0 ? -_s.fontWidth : tm.tmAveCharWidth; // For fixed FONT should == tm.tmMaxCharWidth - _s.PTEXTSIZE.y = tm.tmHeight; // but seems to be a problem on Win9X so - // assume proportional fonts always for Win9X -#if defined(HB_WINCE) - _s.FixedFont = FALSE; -#else - if (_s.fontWidth < 0 || _s.Win9X || ( tm.tmPitchAndFamily & TMPF_FIXED_PITCH ) || ( _s.PTEXTSIZE.x != tm.tmMaxCharWidth ) ) - { - _s.FixedFont = FALSE; - } - else - { - _s.FixedFont = TRUE ; - } -#endif - - for( n = 0 ; n < _GetScreenWidth() ; n++ ) // _s.FixedSize[] is used by ExtTextOut() to emulate - { // fixed font when a proportional font is used - _s.FixedSize[ n ] = _s.PTEXTSIZE.x; - } - - // resize the window to get the specified number of rows and columns - // - height = hb_wvt_gtCalcPixelHeight(); - width = hb_wvt_gtCalcPixelWidth(); - - GetWindowRect( hWnd, &wi ); - GetClientRect( hWnd, &ci ); - - diffWidth = ( SHORT )( ( wi.right - wi.left ) - ( ci.right ) ); - diffHeight = ( SHORT )( ( wi.bottom - wi.top ) - ( ci.bottom ) ); - width += diffWidth ; - height += diffHeight; - - // Centre the window within the CLIENT area on the screen - // but only if _s.CentreWindow == TRUE - // - if ( _s.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( hWnd, NULL, wi.left, wi.top, width, height, SWP_NOZORDER ); - - if ( _s.bGui ) - { - hb_wvt_gtInitGui(); - } -} - -//-------------------------------------------------------------------// - -static int hb_wvt_key_ansi_to_oem( int c ) -{ - char pszAnsi[4]; - char pszOem[4]; - - sprintf( pszAnsi, "%c", c ); - CharToOemBuffA( ( LPCSTR ) pszAnsi, ( LPSTR ) pszOem, 1 ); - c = (BYTE) * pszOem; - - return c; -} - -//----------------------------------------------------------------------// - -static void hb_wvt_gtInitGui( void ) -{ - _s.iGuiWidth = _GetScreenWidth() * _s.PTEXTSIZE.x ; - _s.iGuiHeight = _GetScreenHeight() * _s.PTEXTSIZE.y ; - - if ( _s.hGuiDC ) - { - DeleteDC( _s.hGuiDC ); - } - _s.hGuiDC = CreateCompatibleDC( _s.hdc ); - - if ( _s.hGuiBmp ) - { - DeleteObject( _s.hGuiBmp ); - } - _s.hGuiBmp = CreateCompatibleBitmap( _s.hdc, _s.iGuiWidth, _s.iGuiHeight ); - - SelectObject( _s.hGuiDC, _s.hGuiBmp ); - SetTextCharacterExtra( _s.hGuiDC,0 ); - SelectObject( _s.hGuiDC, _s.hFont ); -} - -//-------------------------------------------------------------------// - -static LRESULT CALLBACK hb_wvt_gtWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) -{ - BOOL bRet; - - switch ( message ) - { - case WM_CREATE: - { - bRet = hb_wvt_gtInitWindow( hWnd, WVT_DEFAULT_COLS, WVT_DEFAULT_ROWS ); - return( bRet ); - } - - case WM_COMMAND: - { - hb_wvt_gtHandleMenuSelection( ( int ) LOWORD( wParam ) ); - return( 0 ); - } - - case WM_PAINT: - { - RECT updateRect; - /* WARNING!!! - * the GetUpdateRect call MUST be made BEFORE the BeginPaint call, since - * BeginPaint resets the update rectangle - don't move it or nothing is drawn! - */ - if ( GetUpdateRect( hWnd, &updateRect, FALSE ) ) - { - hb_wvt_gtPaintText( hWnd, updateRect ); - } - - return 0; - } - - case WM_MY_UPDATE_CARET: - { - hb_wvt_gtSetCaretPos(); - return( 0 ); - } - - case WM_SETFOCUS: - { - if ( _s.bGui ) - { - _s.bSetFocus = TRUE ; - _s.bKillFocus = FALSE; - } - - hb_wvt_gtCreateCaret() ; - - if ( _s.bGetFocus ) - { - if ( _s.pSymWVT_SETFOCUS ) - { - hb_vmPushState(); - hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_SETFOCUS ) ); - hb_vmPushNil(); - hb_vmPushLong( ( LONG ) hWnd ); - hb_vmDo( 1 ); - hb_vmPopState(); - } - } - else - { - _s.bGetFocus = TRUE; - } - return( 0 ); - } - - case WM_KILLFOCUS: - { - if ( _s.bGui ) - { - _s.bKillFocus = TRUE; - } - hb_wvt_gtKillCaret(); - - if ( _s.pSymWVT_KILLFOCUS ) - { - hb_vmPushState(); - hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_KILLFOCUS ) ); - hb_vmPushNil(); - hb_vmPushLong( ( LONG ) hWnd ); - hb_vmDo( 1 ); - hb_vmPopState(); - } - return( 0 ); - } - - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - case WM_CHAR: - case WM_SYSCHAR: - { - return hb_wvt_gtKeyEvent( hWnd, message, wParam, lParam ); - } - - case WM_QUERYENDSESSION: // Closing down computer - { - /* if we have set a shutdown command return false, - * so windows ( and our app )doesn't shutdown - * otherwise let the default handler take it - */ - /* - if ( hb_gtHandleShutdown() ) - { - return 0; - } - */ - break; - } - - case WM_CLOSE: // Clicked 'X' on system menu - { - // if an event has been set then return it otherwise fake an Alt+C - //hb_gtHandleClose(); - return( 0 ); - } - - case WM_QUIT: - case WM_DESTROY: - return( 0 ); - - case WM_RBUTTONDOWN: - case WM_LBUTTONDOWN: - case WM_RBUTTONUP: - case WM_LBUTTONUP: - case WM_RBUTTONDBLCLK: - case WM_LBUTTONDBLCLK: - case WM_MBUTTONDOWN: - case WM_MBUTTONUP: - case WM_MBUTTONDBLCLK: - case WM_MOUSEMOVE: - case WM_MOUSEWHEEL: - case WM_NCMOUSEMOVE: - { - hb_wvt_gtMouseEvent( hWnd, message, wParam, lParam ); - return( 0 ); - } - case WM_ENTERIDLE: - { - //hb_idleState( FALSE ); - hb_idleState(); - return( 0 ); - } - - case WM_TIMER: - { - if ( _s.pSymWVT_TIMER ) - { - hb_vmPushState(); - hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_TIMER ) ); - hb_vmPushNil(); - hb_vmPushLong( (LONG) wParam ); - hb_vmDo( 1 ); - hb_vmPopState(); - } - return( 0 ); - } - } - return( DefWindowProc( hWnd, message, wParam, lParam ) ); -} -//-------------------------------------------------------------------// - -static void hb_wvt_gtRestGuiState( LPRECT rect ) -{ - BitBlt( _s.hdc, rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top, - _s.hGuiDC, rect->left, rect->top, SRCCOPY ); -} - -//-------------------------------------------------------------------// - -static HWND hb_wvt_gtCreateWindow( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow ) -{ - HWND hWnd; - WNDCLASS wndclass; - - HB_SYMBOL_UNUSED( hPrevInstance ); - HB_SYMBOL_UNUSED( szCmdLine ); - - InitCommonControls(); - - wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ; - wndclass.lpfnWndProc = hb_wvt_gtWndProc; - wndclass.cbClsExtra = 0; - wndclass.cbWndExtra = 0; - wndclass.hInstance = hInstance; - wndclass.hIcon = NULL; - wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ); - wndclass.hbrBackground = NULL; - wndclass.lpszMenuName = NULL; - wndclass.lpszClassName = szAppName; - - if ( ! RegisterClass( &wndclass ) ) - { - MessageBox( NULL, TEXT( "Failed to register class." ), - szAppName, MB_ICONERROR ); - return( 0 ); - } - - hWnd = CreateWindow( szAppName, //classname - TEXT( "XHARBOUR_WVT" ), //window name - WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, //style - 0, //x - 0, //y - CW_USEDEFAULT, //width - CW_USEDEFAULT, //height - NULL, //window parent - NULL, //menu - hInstance, //instance - NULL ); //lpParam - - - if ( hWnd == NULL ) - { - MessageBox( NULL, TEXT( "Failed to create window." ), - TEXT( "XHARBOUR_WVT" ), MB_ICONERROR ); - } - - // If you wish to show window the way you want, put somewhere in your application - // ANNOUNCE HB_NOSTARTUPWINDOW - // If so compiled, then you need to issue Wvt_ShowWindow( SW_RESTORE ) - // at the point you desire in your code. - // - if ( hb_dynsymFind( "HB_NOSTARTUPWINDOW" ) != NULL ) - { - iCmdShow = SW_HIDE; - } - - ShowWindow( hWnd, iCmdShow ); - UpdateWindow( hWnd ); - - return( hWnd ) ; -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtCreateToolTipWindow( void ) /* NO */ -{ - INITCOMMONCONTROLSEX icex; - HWND hwndTT; - TOOLINFO ti; - - // Load the tooltip class from the DLL. - // - icex.dwSize = sizeof( icex ); - icex.dwICC = ICC_BAR_CLASSES; - - if( !InitCommonControlsEx( &icex ) ) - { - return; - } - - // Create the tooltip control. - // - hwndTT = CreateWindow( TOOLTIPS_CLASS, TEXT( "" ), - WS_POPUP | TTS_ALWAYSTIP , - CW_USEDEFAULT, CW_USEDEFAULT, - CW_USEDEFAULT, CW_USEDEFAULT, - NULL, - ( HMENU ) NULL, - ( HINSTANCE ) hb_hInstance, - NULL ); - - SetWindowPos( hwndTT, - HWND_TOPMOST, - 0, - 0, - 0, - 0, - SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE ); - - // Prepare TOOLINFO structure for use as tracking tooltip. - // - ti.cbSize = sizeof( TOOLINFO ); - ti.uFlags = TTF_SUBCLASS; - ti.hwnd = _s.hWnd; - ti.uId = 100000; - ti.hinst = ( HINSTANCE ) hb_hInstance; - ti.lpszText = HB_TCHAR_CONVTO( "" ); - ti.rect.left = ti.rect.top = ti.rect.bottom = ti.rect.right = 0; - - // Add the tool to the control, displaying an error if needed. - // - if( ! SendMessage( hwndTT, TTM_ADDTOOL, 0, ( LPARAM ) &ti ) ) - { - return ; - } - - _s.hWndTT = hwndTT; -} - -//-------------------------------------------------------------------// - -static DWORD hb_wvt_gtProcessMessages( void ) -{ - MSG msg; - int iIndex; - BOOL bProcessed; - - while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) - { - bProcessed = FALSE; - - for ( iIndex = 0; iIndex < WVT_DLGML_MAX; iIndex++ ) - { - if ( _s.hDlgModeless[ iIndex ] != 0 ) - { - if ( IsDialogMessage( _s.hDlgModeless[ iIndex ], &msg ) ) - { - bProcessed = TRUE; - break; - } - } - } - - if ( bProcessed == FALSE ) - { - TranslateMessage( &msg ); - DispatchMessage( &msg ); - } - } - return( msg.wParam ); -} - -//-------------------------------------------------------------------// - -POINT HB_EXPORT hb_wvt_gtGetXYFromColRow( USHORT col, USHORT row ) -{ - POINT xy; - - xy.x = ( col ) * _s.PTEXTSIZE.x; - xy.y = ( row ) * _s.PTEXTSIZE.y; - - return( xy ); -} - -//-------------------------------------------------------------------// -/* - * get the row and column from xy pixel client coordinates - * This works because we are using the FIXED system font - * - */ -static POINT hb_wvt_gtGetColRowFromXY( USHORT x, USHORT y ) /* NO */ -{ - POINT colrow; - - colrow.x = ( x/_s.PTEXTSIZE.x ); - colrow.y = ( y/_s.PTEXTSIZE.y ); - - return( colrow ); -} - -//-------------------------------------------------------------------// -/* - * return a rectangle with row and column data, corresponding to the XY pixel - * coordinates - * This works because we are using the FIXED system font - * - */ -static RECT hb_wvt_gtGetColRowFromXYRect( RECT xy ) /* NO */ -{ - RECT colrow; - - colrow.left = ( xy.left / _s.PTEXTSIZE.x ); - colrow.top = ( xy.top / _s.PTEXTSIZE.y ); // 23/07/2004 9:02a.m. - colrow.right = ( xy.right / _s.PTEXTSIZE.x - ( xy.right % _s.PTEXTSIZE.x ? 0 : 1 ) ); // Adjust for when rectangle - colrow.bottom = ( xy.bottom / _s.PTEXTSIZE.y - ( xy.bottom % _s.PTEXTSIZE.y ? 0 : 1 ) ); // EXACTLY overlaps characters - - return( colrow ); -} - -//-------------------------------------------------------------------// -/* - * return a rectangle with the XY pixel coordinates corresponding to - * the row and column data - * This works because we are using the FIXED system font - * - */ -static RECT hb_wvt_gtGetXYFromColRowRect( RECT colrow ) /* NO */ -{ - RECT xy; - - xy.left = ( colrow.left ) * _s.PTEXTSIZE.x; - xy.top = ( colrow.top ) * _s.PTEXTSIZE.y; - xy.right = ( colrow.right +1 ) * _s.PTEXTSIZE.x; - xy.bottom = ( colrow.bottom+1 ) * _s.PTEXTSIZE.y; - - return( xy ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtCreateCaret() /* NO */ -{ -//OutputDebugString( "hb_wvt_gtCreateCaret()" ); - // create and show the caret - // create an underline caret of height - _s.CaretSize - // - _s.CaretExist = CreateCaret( _s.hWnd, ( HBITMAP ) NULL, _s.PTEXTSIZE.x, _s.CaretSize ); - if ( _s.CaretExist && _s.displayCaret ) - { - hb_wvt_gtSetCaretPos(); - ShowCaret( _s.hWnd ); - } -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtKillCaret() -{ - if ( _s.CaretExist ) - { - DestroyCaret(); - _s.CaretExist = FALSE ; - } -} - -//-------------------------------------------------------------------// -/* - * hb_wvt_gtSetCaretPos converts col and row to x and y ( pixels ) and calls - * the Windows function SetCaretPos ( with the expected coordinates ) - */ -static BOOL hb_wvt_gtSetCaretPos() -{ - POINT xy; - - xy = hb_wvt_gtGetXYFromColRow( (SHORT) _s.caretPos.x, (SHORT) _s.caretPos.y ); - if ( _s.CaretSize > 0 ) - { - xy.y += ( _s.PTEXTSIZE.y - _s.CaretSize ); - } - if ( _s.CaretExist ) - { - SetCaretPos( xy.x, xy.y ); - } - return( TRUE ); -} - -//----------------------------------------------------------------------// - -static void hb_wvt_gtUpdateCaret( void ) -{ - int iRow, iCol, iStyle, iCaretSize; - - hb_gt_GetScrCursor( &iRow, &iCol, &iStyle ); - - if( iRow < 0 || iCol < 0 || iRow >= _s.ROWS || iCol >= _s.COLS ) - { - iCaretSize = 0; - } - else switch( iStyle ) - { - case SC_INSERT: - iCaretSize = _s.PTEXTSIZE.y >> 1; - break; - case SC_SPECIAL1: - iCaretSize = _s.PTEXTSIZE.y; - break; - case SC_SPECIAL2: - iCaretSize = - ( _s.PTEXTSIZE.y >> 1 ); - break; - case SC_NORMAL: - iCaretSize = 4; - break; - default: - iCaretSize = 0; - break; - } - - if( iCaretSize == 0 ) - { - if( _s.CaretExist && !_s.CaretHidden ) - { - HideCaret( _s.hWnd ); - _s.CaretHidden = TRUE; - } - } - else - { - if( iCaretSize != _s.CaretSize || !_s.CaretExist ) - { - _s.CaretSize = iCaretSize; - _s.CaretExist = CreateCaret( _s.hWnd, ( HBITMAP ) NULL, _s.PTEXTSIZE.x, - _s.CaretSize < 0 ? - _s.CaretSize : _s.CaretSize ); - } - if( _s.CaretExist ) - { - POINT xy; - xy = hb_wvt_gtGetXYFromColRow( ( SHORT ) iCol, ( SHORT ) iRow ); - SetCaretPos( xy.x, _s.CaretSize < 0 ? - xy.y : xy.y + _s.PTEXTSIZE.y - _s.CaretSize ); - ShowCaret( _s.hWnd ); - _s.CaretHidden = FALSE; - } - } -} -//-------------------------------------------------------------------// -/* - * hb_wvt_gtValidateRow checks the row bounds for the caret, wrapping if indicated - */ -static void hb_wvt_gtValidateRow( void ) -{ - if ( _s.caretPos.y < 0 ) - { - _s.caretPos.y = _GetScreenHeight()-1; - if ( _s.caretPos.x > 0 ) - { - _s.caretPos.x--; - } - else - { - _s.caretPos.x = _GetScreenWidth()-1; - } - } - else if ( _s.caretPos.y >= _GetScreenHeight() ) - { - _s.caretPos.y = 0; - if ( _s.caretPos.x < _GetScreenWidth()-1 ) - { - _s.caretPos.x++; - } - else - { - _s.caretPos.x = 0; - } - } -} - -//-------------------------------------------------------------------// -/* - * hb_wvt_gtValidateCol checks the column bounds for the caret, wrapping if indicated - */ -static void hb_wvt_gtValidateCol( void ) -{ - if ( _s.caretPos.x < 0 ) - { - _s.caretPos.x = _GetScreenWidth()-1; - if ( _s.caretPos.y > 0 ) - { - _s.caretPos.y--; - } - else - { - _s.caretPos.y = _GetScreenHeight()-1; - } - } - else if ( _s.caretPos.x >= _GetScreenWidth() ) - { - _s.caretPos.x = 0; - if ( _s.caretPos.y < _GetScreenHeight()-1 ) - { - _s.caretPos.y++; - } - else - { - _s.caretPos.y = 0; - } - } -} - -//-------------------------------------------------------------------// -/* - * hb_wvt_gtValidateCaret checks the bounds for the caret, wrapping if indicated - * before setting the caret position on the screen - */ -static void hb_wvt_gtValidateCaret( void ) /* NO SAME */ -{ - hb_wvt_gtValidateCol(); - hb_wvt_gtValidateRow(); - - // send message to window to display updated caret - // - SendMessage( _s.hWnd, WM_MY_UPDATE_CARET, 0, 0 ); -} - -//-------------------------------------------------------------------// -/* - * hb_wvt_gtGetIndexForTextBuffer takes a row and column, and returns the appropriate - * index into the screen Text buffer - */ -static USHORT hb_wvt_gtGetIndexForTextBuffer( USHORT col, USHORT row ) /* NO */ -{ - return( row * _GetScreenWidth() + col ); -} - -//-------------------------------------------------------------------// - /* - * hb_wvt_gtGetColRowForTextBuffer takes an index into the screen Text buffer - * and returns the corresponding row and column - */ -static POINT hb_wvt_gtGetColRowForTextBuffer( USHORT index ) /* NO */ -{ - POINT colrow; - colrow.x = index % _GetScreenWidth(); - colrow.y = index / _GetScreenWidth(); - - return( colrow ); -} - -//-------------------------------------------------------------------// -/* - * hb_wvt_gtTextOut converts col and row to x and y ( pixels ) and calls - * the Windows function TextOut with the expected coordinates - */ - /* DIFFERENT */ -static BOOL hb_wvt_gtTextOut( HDC hdc, USHORT col, USHORT row, LPCTSTR lpString, USHORT cbString ) -{ - BOOL Result ; - POINT xy; - RECT rClip; -// long nFontCX = _s.PTEXTSIZE.x; -// long nFontCY = _s.PTEXTSIZE.y; - if ( cbString > _GetScreenWidth() ) // make sure string is not too long - { - cbString = _GetScreenWidth(); - } - xy = hb_wvt_gtGetXYFromColRow( col, row ); - -// SetRect( &rClip, xy.x, xy.y, xy.x + cbString * nFontCX, xy.y + nFontCY ); - SetRect( &rClip, xy.x, xy.y, xy.x + cbString * _s.PTEXTSIZE.x, xy.y + _s.PTEXTSIZE.y ); - - if ( _s.FixedFont ) - { - Result = ExtTextOut( hdc, xy.x, xy.y, ETO_CLIPPED|ETO_OPAQUE, &rClip, lpString, cbString, NULL ); - } - else - { - Result = ExtTextOut( hdc, xy.x, xy.y, ETO_CLIPPED|ETO_OPAQUE, &rClip, lpString, cbString, _s.FixedSize ); - } - return( Result ) ; -} - -//----------------------------------------------------------------------// - -static void hb_wvt_gtPaintText( HWND hWnd, RECT updateRect ) -{ - PAINTSTRUCT ps; - HDC hdc; - USHORT irow; - RECT rcRect; - - if ( _s.bGui && _s.bKillFocus ) - { - hb_wvt_gtRestGuiState( &updateRect ); - ValidateRect( hWnd, &updateRect ); - return; - } - if ( _s.bGui && _s.bSetFocus ) - { - _s.bSetFocus = FALSE; - hb_wvt_gtRestGuiState( &updateRect ); - ValidateRect( hWnd, &updateRect ); - return; - } - - hdc = BeginPaint( hWnd, &ps ); - SelectObject( hdc, _s.hFont ); - if ( _s.bGui ) - { - SelectObject( _s.hGuiDC, _s.hFont ); - } - - if ( _s.pBuffer != NULL && _s.pAttributes != NULL ) - { - rcRect = hb_wvt_gtGetColRowFromXYRect( updateRect ); - - _s.rowStart = rcRect.top ; - _s.rowStop = rcRect.bottom ; - _s.colStart = rcRect.left ; - _s.colStop = rcRect.right ; - - for ( irow = _s.rowStart; irow <= _s.rowStop; irow++ ) - { - USHORT icol, index, startIndex, startCol, len; - BYTE oldAttrib, attrib; - LPTSTR text; - - icol = _s.colStart; - startCol = icol; - index = hb_wvt_gtGetIndexForTextBuffer( icol, irow ); - startIndex = index; - len = 0; - oldAttrib = *( _s.pAttributes + index ); - - while ( icol <= _s.colStop ) - { - if ( index >= _s.BUFFERSIZE ) - { - break; - } - attrib = *( _s.pAttributes + index ); - if ( attrib != oldAttrib ) - { - hb_wvt_gtSetColors( hdc, oldAttrib ); - - //text = HB_TCHAR_CONVNTO( ( const char* ) _s.pBuffer + startIndex, len ); - text = HB_TCHAR_CONVNTO( ( BYTE * ) _s.pBuffer + startIndex, len ); - //hb_wvt_gtTextOut( hdc, startCol, irow, ( char const * ) _s.pBuffer + startIndex, len ); - hb_wvt_gtTextOut( hdc, startCol, irow, text, len ); - - if ( _s.bGui ) - { - hb_wvt_gtSetColors( _s.hGuiDC, oldAttrib ); - //hb_wvt_gtTextOut( _s.hGuiDC, startCol, irow, ( char const * ) _s.pBuffer + startIndex, len ); - hb_wvt_gtTextOut( _s.hGuiDC, startCol, irow, text, len ); - } - HB_TCHAR_FREE( text ); - oldAttrib = attrib; - startIndex = index; - startCol = icol; - len = 0; - } - icol++; - len++; - index++; - } - hb_wvt_gtSetColors( hdc, oldAttrib ); - //text = HB_TCHAR_CONVNTO( ( const char* ) _s.pBuffer + startIndex, len ); - text = HB_TCHAR_CONVNTO( ( BYTE * ) _s.pBuffer + startIndex, len ); - hb_wvt_gtTextOut( hdc, startCol, irow, text, len ); - if ( _s.bGui ) - { - hb_wvt_gtSetColors( _s.hGuiDC, oldAttrib ); - hb_wvt_gtTextOut( _s.hGuiDC, startCol, irow, text, len ); - } - HB_TCHAR_FREE( text ); - } - } - - EndPaint( hWnd, &ps ); - - if ( _s.bPaint ) - { - if ( _s.pSymWVT_PAINT ) - { - hb_vmPushState(); - hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_PAINT ) ); - hb_vmPushNil(); - hb_vmDo( 0 ); - hb_vmPopState(); - } - } - else - { - _s.bPaint = TRUE; - } -} - -//-------------------------------------------------------------------// -// -// get for and background colours from attribute and set them for window -// -static BOOL hb_wvt_gtSetColors( HDC hdc, BYTE attr ) -{ - int fore = attr & 0x000F; - int back = ( attr & 0x00F0 )>>4; - - _s.foreground = _COLORS[ fore ]; - _s.background = _COLORS[ back ]; - - SetTextColor( hdc, _s.foreground ); - SetBkColor( hdc, _s.background ); - SetTextAlign( hdc, TA_LEFT ); - - return( TRUE ); -} - -//-------------------------------------------------------------------// -// -// compute invalid rect in pixels, from row and col -// -static void hb_wvt_gtSetInvalidRect( USHORT left, USHORT top, USHORT right, USHORT bottom ) -{ - RECT rect; - if ( _s.InvalidateWindow ) - { - rect.left = left; - rect.top = top; - rect.right = right; - rect.bottom = bottom; - - rect = hb_wvt_gtGetXYFromColRowRect( rect ); - - // check for wrapping - // - rect.left = min( rect.left, rect.right ); - rect.top = min( rect.top, rect.bottom ); - - rect.right = max( rect.left, rect.right ); - rect.bottom = max( rect.top, rect.bottom ); - - if ( _s.RectInvalid.left < 0 ) - { - memcpy( &_s.RectInvalid, &rect, sizeof( RECT ) ); - } - else - { - _s.RectInvalid.left = min( _s.RectInvalid.left , rect.left ); - _s.RectInvalid.top = min( _s.RectInvalid.top , rect.top ); - _s.RectInvalid.right = max( _s.RectInvalid.right , rect.right ); - _s.RectInvalid.bottom = max( _s.RectInvalid.bottom, rect.bottom ); - } - - hb_wvt_gtDoInvalidateRect() ; - } -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtDoInvalidateRect( void ) -{ - if ( HB_GT_FUNC( gt_DispCount() ) <= 0 && ( _s.RectInvalid.left != -1 ) ) - { - // InvalidateRect( _s.hWnd, &_s.RectInvalid, TRUE ); - InvalidateRect( _s.hWnd, &_s.RectInvalid, FALSE ); - _s.RectInvalid.left = -1 ; - hb_wvt_gtProcessMessages(); - } -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtTranslateKey( int key, int shiftkey, int altkey, int controlkey ) -{ - int nVirtKey = GetKeyState( VK_MENU ); - - if ( nVirtKey & 0x8000 ) // alt + key - { - hb_wvt_gtAddCharToInputQueue( altkey ); - } - else - { - nVirtKey = GetKeyState( VK_CONTROL ); - if ( nVirtKey & 0x8000 ) // control + key - { - hb_wvt_gtAddCharToInputQueue( controlkey ); - } - else - { - nVirtKey = GetKeyState( VK_SHIFT ); - if ( nVirtKey & 0x8000 ) // shift + key - { - hb_wvt_gtAddCharToInputQueue( shiftkey ); - } - else //just key - { - hb_wvt_gtAddCharToInputQueue( key ); - } - } - } -} - -//-------------------------------------------------------------------// -// -// font stuff -/* use the standard fixed oem font, unless the caller has requested set size fonts -*/ -static HFONT hb_wvt_gtGetFont( char * pszFace, int iHeight, int iWidth, int iWeight, int iQuality, int iCodePage ) -{ - HFONT hFont; - - if ( iHeight > 0 ) - { - LOGFONT logfont; - - logfont.lfEscapement = 0; - logfont.lfOrientation = 0; - logfont.lfWeight = iWeight ; - logfont.lfItalic = 0; - logfont.lfUnderline = 0; - logfont.lfStrikeOut = 0; - logfont.lfCharSet = iCodePage; // OEM_CHARSET; - logfont.lfOutPrecision = 0; - logfont.lfClipPrecision = 0; - logfont.lfQuality = 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 ); - - hFont = CreateFontIndirect( &logfont ); - } - else - { - hFont = ( HFONT ) GetStockObject( OEM_FIXED_FONT ); - } - return( hFont ); -} - -//-------------------------------------------------------------------// - -static void gt_hbInitStatics( void ) -{ - OSVERSIONINFO osvi ; - HINSTANCE h; - int iIndex; - LPTSTR msimg32 = HB_TCHAR_CONVTO( "msimg32.dll" ); - LPTSTR GradientFill = HB_TCHAR_CONVTO( "GradientFill" ); - - _s.ROWS = WVT_DEFAULT_ROWS; - _s.COLS = WVT_DEFAULT_COLS; - _s.foreground = WHITE; - _s.background = BLACK; - _s.BUFFERSIZE = 0; - _s.pAttributes = NULL; - _s.pBuffer = NULL; - _s.caretPos.x = 0; - _s.caretPos.y = 0; - _s.CaretExist = FALSE; - _s.CaretSize = 4; - _s.CaretHidden = FALSE; - _s.mousePos.x = 0; - _s.mousePos.y = 0; - _s.MouseMove = FALSE ; - _s.hWnd = NULL; - _s.keyPointerIn = 1; - _s.keyPointerOut = 0; - _s.displayCaret = TRUE; - _s.RectInvalid.left = -1 ; - - // THEESE are the default font parameters, if not changed by user - _s.PTEXTSIZE.x = 8; - _s.PTEXTSIZE.y = 16; - _s.fontHeight = 16; - _s.fontWidth = 8; - _s.fontWeight = FW_NORMAL; - _s.fontQuality = DEFAULT_QUALITY; - strcpy( _s.fontFace,"Terminal" ); - - _s.LastMenuEvent = 0; - _s.MenuKeyEvent = 1024; - _s.CentreWindow = TRUE; // Default is to always display window in centre of screen - _s.CodePage = GetACP() ; // Set code page to default system - - osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); - GetVersionEx ( &osvi ); - _s.Win9X = ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ); - _s.AltF4Close = FALSE; - _s.InvalidateWindow = TRUE; - _s.EnableShortCuts = FALSE; - _s.pSymWVT_PAINT = hb_dynsymFind( "WVT_PAINT" ) ; - _s.pSymWVT_SETFOCUS = hb_dynsymFind( "WVT_SETFOCUS" ) ; - _s.pSymWVT_KILLFOCUS= hb_dynsymFind( "WVT_KILLFOCUS" ) ; - _s.pSymWVT_MOUSE = hb_dynsymFind( "WVT_MOUSE" ) ; - _s.pSymWVT_TIMER = hb_dynsymFind( "WVT_TIMER" ) ; - _s.pSymWVT_KEY = hb_dynsymFind( "WVT_KEY" ) ; - _s.rowStart = 0; - _s.rowStop = 0; - _s.colStart = 0; - _s.colStop = 0; - _s.bToolTipActive = FALSE; - - h = LoadLibraryEx( msimg32, NULL, 0 ); - HB_TCHAR_FREE( msimg32 ); - if ( h ) - { - _s.pfnGF = ( wvtGradientFill ) GetProcAddress( h, GradientFill ); - HB_TCHAR_FREE( GradientFill ); - if ( _s.pfnGF ) - { - _s.hMSImg32 = h; - } - } - - for ( iIndex = 0; iIndex < WVT_DLGML_MAX; iIndex++ ) - { - _s.hDlgModeless[ iIndex ] = NULL; - _s.pFunc[ iIndex ] = NULL; - _s.iType[ iIndex ] = ( int ) NULL; - } - for ( iIndex = 0; iIndex < WVT_DLGMD_MAX; iIndex++ ) - { - _s.hDlgModal[ iIndex ] = NULL; - _s.pFuncModal[ iIndex ] = NULL; - _s.iTypeModal[ iIndex ] = ( int ) NULL; - } - - _s.bGui = FALSE; - _s.bIgnoreWM_SYSCHAR = FALSE; - _s.bPaint = FALSE; - _s.bGetFocus = FALSE; - _s.bSetFocus = FALSE; - _s.bKillFocus = FALSE; -} - -//-------------------------------------------------------------------// -/* - * functions for handling the input queues for the mouse and keyboard - */ -void HB_EXPORT hb_wvt_gtAddCharToInputQueue ( int data ) -{ - int iNextPos; - - iNextPos = ( _s.keyPointerIn >= WVT_CHAR_QUEUE_SIZE - 1 ) ? 0 : _s.keyPointerIn+1 ; - if ( iNextPos != _s.keyPointerOut ) // Stop accepting characters once the buffer is full - { - _s.Keys[ _s.keyPointerIn ] = data ; - _s.keyPointerIn = iNextPos ; - } - - if ( _s.pSymWVT_KEY ) - { - hb_vmPushState(); - hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_KEY ) ); - hb_vmPushNil(); - hb_vmPushLong( ( LONG ) data ); - hb_vmDo( 1 ); - hb_vmPopState(); - } -} - -//-------------------------------------------------------------------// - -static BOOL hb_wvt_gtGetCharFromInputQueue ( int *c ) -{ - int iNextPos; - BOOL bRet = FALSE; - - *c = 0; - iNextPos = ( _s.keyPointerOut >= WVT_CHAR_QUEUE_SIZE - 1 ) ? 0 : _s.keyPointerOut+1 ; - if ( iNextPos != _s.keyPointerIn ) // No more events in queue ?? - { - *c = _s.Keys[ iNextPos ] ; - _s.keyPointerOut = iNextPos ; - bRet = TRUE; - } - - return( bRet ); -} - -//-------------------------------------------------------------------// - -static USHORT hb_wvt_gtGetMouseX ( void ) -{ - return( (SHORT) _s.mousePos.x ); -} - -//-------------------------------------------------------------------// - -static USHORT hb_wvt_gtGetMouseY ( void ) -{ - return( (SHORT) _s.mousePos.y ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtSetMouseX ( USHORT ix ) -{ - _s.mousePos.x = ix; -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtSetMouseY ( USHORT iy ) -{ - _s.mousePos.y = iy; -} - -//-------------------------------------------------------------------// -/* - * hb_wvt_gtSetStringInTextBuffer puts the string of the specified length into the TextBuffer at - * the specified caret position - * It then determines the invalid rectangle, so the string will be displayed - */ -static void hb_wvt_gtSetStringInTextBuffer( USHORT col, USHORT row, BYTE attr, BYTE *sBuffer, USHORT length ) -{ - POINT end; - USHORT index; - - // determine the index and put the string into the TextBuffer - // - index = hb_wvt_gtGetIndexForTextBuffer( col, row ); - if ( length + index <= _s.BUFFERSIZE ) - { - memcpy( ( _s.pBuffer+index ), sBuffer, length ); -// if ( attr != ' ' ) // if no attribute, don't overwrite -// { - memset( ( _s.pAttributes+index ), attr, length ); -// } - - // determine bounds of rect around character to refresh - // - end = hb_wvt_gtGetColRowForTextBuffer( index + ( length -1 ) ); //location of last char - hb_wvt_gtSetInvalidRect( (SHORT) col, (SHORT) row, (SHORT) end.x, (SHORT) end.y ); - } -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtSetCaretOn( BOOL bOn ) -{ - if ( _s.CaretExist ) - { - if ( bOn ) - { - hb_wvt_gtSetCaretPos(); - ShowCaret( _s.hWnd ); - } - else - { - HideCaret( _s.hWnd ); - } - } - _s.displayCaret = bOn; -} - -//-------------------------------------------------------------------// - -static void hb_wvt_gtHandleMenuSelection( int menuIndex ) -{ - _s.LastMenuEvent = menuIndex ; - hb_wvt_gtAddCharToInputQueue( _s.MenuKeyEvent ); -} - -//-------------------------------------------------------------------// - -static BOOL hb_wvt_gtKeyEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) -{ - switch( message ) - { - case WM_KEYDOWN: - case WM_SYSKEYDOWN: - { - BOOL bAlt = GetKeyState( VK_MENU ) & 0x8000; - _s.bIgnoreWM_SYSCHAR = FALSE; - - switch ( wParam ) - { - case VK_LEFT: - hb_wvt_gtTranslateKey( K_LEFT , K_SH_LEFT , K_ALT_LEFT , K_CTRL_LEFT ); - break; - case VK_RIGHT: - hb_wvt_gtTranslateKey( K_RIGHT, K_SH_RIGHT, K_ALT_RIGHT, K_CTRL_RIGHT ); - break; - case VK_UP: - hb_wvt_gtTranslateKey( K_UP , K_SH_UP , K_ALT_UP , K_CTRL_UP ); - break; - case VK_DOWN: - hb_wvt_gtTranslateKey( K_DOWN , K_SH_DOWN , K_ALT_DOWN , K_CTRL_DOWN ); - break; - case VK_HOME: - hb_wvt_gtTranslateKey( K_HOME , K_SH_HOME , K_ALT_HOME , K_CTRL_HOME ); - break; - case VK_END: - hb_wvt_gtTranslateKey( K_END , K_SH_END , K_ALT_END , K_CTRL_END ); - break; - case VK_DELETE: - hb_wvt_gtTranslateKey( K_DEL , K_SH_DEL , K_ALT_DEL , K_CTRL_DEL ); - break; - case VK_INSERT: - hb_wvt_gtTranslateKey( K_INS , K_SH_INS , K_ALT_INS , K_CTRL_INS ); - break; - case VK_PRIOR: - hb_wvt_gtTranslateKey( K_PGUP , K_SH_PGUP , K_ALT_PGUP , K_CTRL_PGUP ); - break; - case VK_NEXT: - hb_wvt_gtTranslateKey( K_PGDN , K_SH_PGDN , K_ALT_PGDN , K_CTRL_PGDN ); - break; - - case VK_F1: - hb_wvt_gtTranslateKey( K_F1 , K_SH_F1, K_ALT_F1 , K_CTRL_F1 ); - break; - case VK_F2: - hb_wvt_gtTranslateKey( K_F2 , K_SH_F2, K_ALT_F2 , K_CTRL_F2 ); - break; - case VK_F3: - hb_wvt_gtTranslateKey( K_F3 , K_SH_F3, K_ALT_F3 , K_CTRL_F3 ); - break; - case VK_F4: - { - if ( _s.AltF4Close && bAlt ) - { - return( DefWindowProc( hWnd, message, wParam, lParam ) ); - } - else - { - hb_wvt_gtTranslateKey( K_F4 , K_SH_F4, K_ALT_F4 , K_CTRL_F4 ); - } - break; - } - case VK_F5: - hb_wvt_gtTranslateKey( K_F5 , K_SH_F5, K_ALT_F5 , K_CTRL_F5 ); - break; - case VK_F6: - hb_wvt_gtTranslateKey( K_F6 , K_SH_F6, K_ALT_F6 , K_CTRL_F6 ); - break; - case VK_F7: - hb_wvt_gtTranslateKey( K_F7 , K_SH_F7, K_ALT_F7 , K_CTRL_F7 ); - break; - case VK_F8: - hb_wvt_gtTranslateKey( K_F8 , K_SH_F8, K_ALT_F8 , K_CTRL_F8 ); - break; - case VK_F9: - hb_wvt_gtTranslateKey( K_F9 , K_SH_F9, K_ALT_F9 , K_CTRL_F9 ); - break; - case VK_F10: - hb_wvt_gtTranslateKey( K_F10 , K_SH_F10,K_ALT_F10 , K_CTRL_F10 ); - break; - case VK_F11: - hb_wvt_gtTranslateKey( K_F11 , K_SH_F11,K_ALT_F11 , K_CTRL_F11 ); - break; - case VK_F12: - hb_wvt_gtTranslateKey( K_F12 , K_SH_F12,K_ALT_F12 , K_CTRL_F12 ); - break; - default: - { - BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; - BOOL bShift = GetKeyState( VK_SHIFT ) & 0x8000; - int iScanCode = HIWORD( lParam ) & 0xFF ; - - if ( bCtrl && iScanCode == 76 ) // CTRL_VK_NUMPAD5 ) - { - hb_wvt_gtAddCharToInputQueue( KP_CTRL_5 ); - } - else if ( bCtrl && wParam == VK_TAB ) // K_CTRL_TAB - { - if ( bShift ) - { - hb_wvt_gtAddCharToInputQueue( K_CTRL_SH_TAB ); - } - else - { - hb_wvt_gtAddCharToInputQueue( K_CTRL_TAB ); - } - } - else if ( iScanCode == 70 ) // Ctrl_Break key OR Scroll Lock Key - { - if ( bCtrl ) // Not scroll lock - { - hb_wvt_gtAddCharToInputQueue( HB_BREAK_FLAG ); // Pretend Alt+C pressed - _s.bIgnoreWM_SYSCHAR = TRUE; - } - else - { - DefWindowProc( hWnd, message, wParam, lParam ) ; // Let windows handle ScrollLock - } - } - else if ( bCtrl && iScanCode == 53 && bShift ) - { - hb_wvt_gtAddCharToInputQueue( K_CTRL_QUESTION ); - } - else if ( ( bAlt || bCtrl ) && ( - wParam == VK_MULTIPLY || wParam == VK_ADD || wParam == VK_SUBTRACT || wParam == VK_DIVIDE ) ) - { - if ( bAlt ) - { - _s.bIgnoreWM_SYSCHAR = TRUE; - } - switch ( wParam ) - { - case VK_MULTIPLY: - hb_wvt_gtTranslateKey( '*','*', KP_ALT_ASTERISK, KP_CTRL_ASTERISK ); - break; - case VK_ADD: - hb_wvt_gtTranslateKey( '+','+', KP_ALT_PLUS, KP_CTRL_PLUS ); - break; - case VK_SUBTRACT: - hb_wvt_gtTranslateKey( '-','-', KP_ALT_MINUS, KP_CTRL_MINUS ); - break; - case VK_DIVIDE: - hb_wvt_gtTranslateKey( '/','/', KP_ALT_SLASH, KP_CTRL_SLASH ); - break; - } - } - else if ( _s.EnableShortCuts ) - { - return( DefWindowProc( hWnd, message, wParam, lParam ) ); - } - } - } - return( 0 ); - } - - case WM_CHAR: - { - BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; - int iScanCode = HIWORD( lParam ) & 0xFF ; - int c = ( int ) wParam; - - if ( !_s.bIgnoreWM_SYSCHAR ) - { - if ( bCtrl && iScanCode == 28 ) // K_CTRL_RETURN - { - hb_wvt_gtAddCharToInputQueue( K_CTRL_RETURN ); - } - else if ( bCtrl && ( c >= 1 && c <= 26 ) ) // K_CTRL_A - Z - { - hb_wvt_gtAddCharToInputQueue( K_Ctrl[c-1] ); - } - else - { - switch ( c ) - { - // handle special characters - case VK_BACK: - hb_wvt_gtTranslateKey( K_BS, K_SH_BS, K_ALT_BS, K_CTRL_BS ); - break; - case VK_TAB: - hb_wvt_gtTranslateKey( K_TAB, K_SH_TAB, K_ALT_TAB, K_CTRL_TAB ); - break; - case VK_RETURN: - hb_wvt_gtTranslateKey( K_RETURN, K_SH_RETURN, K_ALT_RETURN, K_CTRL_RETURN ); - break; - case VK_ESCAPE: - hb_wvt_gtAddCharToInputQueue( K_ESC ); - break; - default: -#if defined(UNICODE) - if( _s.inCDP ) - c = hb_cdpGetChar( _s.inCDP, FALSE, ( USHORT ) c ); - else -#endif - if( _s.CodePage == OEM_CHARSET ) - { - c = hb_wvt_key_ansi_to_oem( c ); - } - hb_wvt_gtAddCharToInputQueue( c ); - break; - } - } - } - - _s.bIgnoreWM_SYSCHAR = FALSE; // As Suggested by Peter - return( 0 ); - } - - case WM_SYSCHAR: - { - if ( !_s.bIgnoreWM_SYSCHAR ) - { - int c, iScanCode = HIWORD( lParam ) & 0xFF ; - switch ( iScanCode ) - { - case 2: - c = K_ALT_1 ; - break; - case 3: - c = K_ALT_2 ; - break; - case 4: - c = K_ALT_3 ; - break; - case 5: - c = K_ALT_4 ; - break; - case 6: - c = K_ALT_5 ; - break; - case 7: - c = K_ALT_6 ; - break; - case 8: - c = K_ALT_7 ; - break; - case 9: - c = K_ALT_8 ; - break; - case 10: - c = K_ALT_9 ; - break; - case 11: - c = K_ALT_0 ; - break; - case 13: - c = K_ALT_EQUALS ; - break; - case 14: - c = K_ALT_BS ; - break; - case 16: - c = K_ALT_Q ; - break; - case 17: - c = K_ALT_W ; - break; - case 18: - c = K_ALT_E ; - break; - case 19: - c = K_ALT_R ; - break; - case 20: - c = K_ALT_T ; - break; - case 21: - c = K_ALT_Y ; - break; - case 22: - c = K_ALT_U ; - break; - case 23: - c = K_ALT_I ; - break; - case 24: - c = K_ALT_O ; - break; - case 25: - c = K_ALT_P ; - break; - case 30: - c = K_ALT_A ; - break; - case 31: - c = K_ALT_S ; - break; - case 32: - c = K_ALT_D ; - break; - case 33: - c = K_ALT_F ; - break; - case 34: - c = K_ALT_G ; - break; - case 35: - c = K_ALT_H ; - break; - case 36: - c = K_ALT_J ; - break; - case 37: - c = K_ALT_K ; - break; - case 38: - c = K_ALT_L ; - break; - case 44: - c = K_ALT_Z ; - break; - case 45: - c = K_ALT_X ; - break; - case 46: - c = K_ALT_C ; - break; - case 47: - c = K_ALT_V ; - break; - case 48: - c = K_ALT_B ; - break; - case 49: - c = K_ALT_N ; - break; - case 50: - c = K_ALT_M ; - break; - default: - c = ( int ) wParam ; - break; - } - hb_wvt_gtAddCharToInputQueue( c ); - } - _s.bIgnoreWM_SYSCHAR = FALSE; - } - } - return( 0 ); -} - -//----------------------------------------------------------------------// - -static void hb_wvt_gtMouseEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) -{ - POINT xy, colrow ; - SHORT keyCode = 0; - SHORT keyState = 0; - ULONG lPopupRet ; - - HB_SYMBOL_UNUSED( hWnd ); - HB_SYMBOL_UNUSED( wParam ); - - if ( !b_MouseEnable ) - { - return; - } - else - { - if ( message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE ) - { - if ( ! _s.MouseMove ) - { - return; - } - } - - xy.x = LOWORD( lParam ); - xy.y = HIWORD( lParam ); - - colrow = hb_wvt_gtGetColRowFromXY( ( SHORT ) xy.x, ( SHORT ) xy.y ); - - hb_wvt_gtSetMouseX( ( SHORT ) colrow.x ); - hb_wvt_gtSetMouseY( ( SHORT ) colrow.y ); - - switch( message ) - { - case WM_LBUTTONDBLCLK: - keyCode = K_LDBLCLK; - break; - - case WM_RBUTTONDBLCLK: - keyCode = K_RDBLCLK; - break; - - case WM_LBUTTONDOWN: - keyCode = K_LBUTTONDOWN; - break; - - case WM_RBUTTONDOWN: - keyCode = K_RBUTTONDOWN; - break; - - case WM_RBUTTONUP: - if ( _s.hPopup ) - { - GetCursorPos( &xy ); - lPopupRet = TrackPopupMenu( _s.hPopup, TPM_CENTERALIGN + TPM_RETURNCMD, xy.x, xy.y, 0, hWnd, NULL ); - if ( lPopupRet ) - { - hb_wvt_gtAddCharToInputQueue( lPopupRet ); - } - return; - } - else - { - keyCode = K_RBUTTONUP; - break; - } - - case WM_LBUTTONUP: - keyCode = K_LBUTTONUP; - break; - - case WM_MBUTTONDOWN: - keyCode = K_MBUTTONDOWN; - break; - - case WM_MBUTTONUP: - keyCode = K_MBUTTONUP; - break; - - case WM_MBUTTONDBLCLK: - keyCode = K_MDBLCLK; - break; - - case WM_MOUSEMOVE: - keyState = wParam; - - if ( keyState == MK_LBUTTON ) - { - keyCode = K_MMLEFTDOWN; - } - else if ( keyState == MK_RBUTTON ) - { - keyCode = K_MMRIGHTDOWN; - } - else if ( keyState == MK_MBUTTON ) - { - keyCode = K_MMMIDDLEDOWN; - } - else - { - keyCode = K_MOUSEMOVE; - } - break; - - case WM_MOUSEWHEEL: - keyState = HIWORD( wParam ); - - if ( keyState > 0 ) - { - keyCode = K_MWFORWARD; - } - else - { - keyCode = K_MWBACKWARD; - } - break; - - case WM_NCMOUSEMOVE: - { - keyCode = K_NCMOUSEMOVE; - } - break; - } - - if ( _s.pSymWVT_MOUSE && keyCode != 0 ) - { - hb_vmPushState(); - //hb_vmPushSymbol( _s.pSymWVT_MOUSE->pSymbol ); - hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_MOUSE ) ); - - hb_vmPushNil(); - hb_vmPushLong( ( SHORT ) keyCode ); - hb_vmPushLong( ( SHORT ) colrow.y ); - hb_vmPushLong( ( SHORT ) colrow.x ); - hb_vmPushLong( ( SHORT ) keyState ); - hb_vmDo( 4 ); - hb_vmPopState(); - } - - hb_wvt_gtAddCharToInputQueue( keyCode ); - } -} - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Exported functions for API calls -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtSetMenuKeyEvent( int iMenuKeyEvent ) -{ - int iOldEvent; - - iOldEvent = _s.MenuKeyEvent ; - if ( iMenuKeyEvent ) - { - _s.MenuKeyEvent = iMenuKeyEvent; - } - return( iOldEvent ); -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtSetCentreWindow( BOOL bCentre, BOOL bPaint ) -{ - BOOL bWasCentre; - - bWasCentre = _s.CentreWindow ; - _s.CentreWindow = bCentre; - if ( bPaint ) - { - hb_wvt_gtResetWindowSize( _s.hWnd ) ; - } - return( bWasCentre ); -} - -//-------------------------------------------------------------------// - -void HB_EXPORT hb_wvt_gtResetWindow( void ) -{ - hb_wvt_gtResetWindowSize( _s.hWnd ) ; -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtSetCodePage( int iCodePage ) -{ - int iOldCodePage; - - iOldCodePage = _s.CodePage ; - if ( iCodePage ) - { - _s.CodePage = iCodePage; - } - if ( iOldCodePage != iCodePage ) - { - hb_wvt_gtResetWindow(); - } - return( iOldCodePage ); -} - -//-------------------------------------------------------------------// - -int HB_EXPORT hb_wvt_gtGetLastMenuEvent( void ) -{ - return( _s.LastMenuEvent ); -} - -//-------------------------------------------------------------------// - -int HB_EXPORT hb_wvt_gtSetLastMenuEvent( int iLastMenuEvent ) -{ - int iRetval = _s.LastMenuEvent; - - _s.LastMenuEvent = iLastMenuEvent; - return( iRetval ); -} - -//-------------------------------------------------------------------// - -void HB_EXPORT hb_wvt_gtSetWindowTitle( char * title ) -{ - LPTSTR text = HB_TCHAR_CONVTO( title ); - SetWindowText( _s.hWnd, text ); - HB_TCHAR_FREE( text ); -} - -//-------------------------------------------------------------------// - -DWORD HB_EXPORT hb_wvt_gtSetWindowIcon( int icon, char *lpIconName ) -{ - HICON hIcon; - - if( lpIconName == NULL ) - { - hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, MAKEINTRESOURCE( icon ) ); - } - else - { - LPTSTR iconName = HB_TCHAR_CONVTO( lpIconName ); - hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, iconName ); - HB_TCHAR_FREE( iconName ); - } - - if ( hIcon ) - { - SendMessage( _s.hWnd, WM_SETICON, ICON_SMALL, ( LPARAM )hIcon ); // Set Title Bar ICON - SendMessage( _s.hWnd, WM_SETICON, ICON_BIG, ( LPARAM )hIcon ); // Set Task List Icon - } - return( ( DWORD ) hIcon ) ; -} - -//-------------------------------------------------------------------// - -DWORD HB_EXPORT hb_wvt_gtSetWindowIconFromFile( char *icon ) -{ - LPTSTR iconName = HB_TCHAR_CONVTO( icon ); - HICON hIcon = (HICON) LoadImage( ( HINSTANCE ) NULL, iconName, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); - - HB_TCHAR_FREE( iconName ); - - if ( hIcon ) - { - SendMessage( _s.hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) hIcon ); // Set Title Bar ICON - SendMessage( _s.hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) hIcon ); // Set Task List Icon - } - - return( ( DWORD ) hIcon ) ; -} - -//-------------------------------------------------------------------// - -int HB_EXPORT hb_wvt_gtGetWindowTitle( char * cTitle, int length ) -{ - //LPTSTR title = HB_TCHAR_CONVTO( cTitle ); - return( GetWindowText( _s.hWnd, HB_TCHAR_CONVTO( cTitle ), length ) ); -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtSetFont( char *fontFace, int height, int width, int Bold, int Quality ) -{ - int size; - BOOL bResult = FALSE ; - HFONT hFont; - LPTSTR fontName = HB_TCHAR_CONVTO( fontFace ); - - hFont = hb_wvt_gtGetFont( fontFace, height, width, Bold, Quality, _s.CodePage ); - HB_TCHAR_FREE( fontName ); - - // make sure the font could actually be created - // - if ( hFont ) - { - // make sure that the font will fit inside the - // window with the current _s.ROWS and _s.COLS setting - if ( hb_wvt_gtValidWindowSize( _GetScreenHeight(),_GetScreenWidth(), hFont, width ) ) - { - _s.fontHeight = height; - _s.fontWidth = width; - _s.fontWeight = Bold; - _s.fontQuality = Quality; - - size = strlen( fontFace ); - if ( ( size > 0 ) && ( size < LF_FACESIZE-1 ) ) - { - strcpy( _s.fontFace, fontFace ); - } - if ( _s.hWnd ) - { - // resize the window based on new fonts - // - hb_wvt_gtResetWindowSize( _s.hWnd ); - - // force resize of caret - // - hb_wvt_gtKillCaret(); - hb_wvt_gtCreateCaret(); - } - bResult= TRUE; - } - DeleteObject( hFont ); - } - return( bResult ); -} - -//-------------------------------------------------------------------// - -HWND HB_EXPORT hb_wvt_gtGetWindowHandle( void ) -{ - return( _s.hWnd ); -} - -//-------------------------------------------------------------------// - -void HB_EXPORT hb_wvt_gtPostMessage( int message ) -{ - SendMessage( _s.hWnd, WM_CHAR,message, 0 ); -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtSetWindowPos( int left, int top ) -{ - RECT wi; - GetWindowRect( _s.hWnd, &wi ); - return( SetWindowPos( _s.hWnd, NULL, left, top, ( wi.right-wi.left )+1, ( wi.bottom-wi.top )+1, SWP_NOZORDER ) ); -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtSetAltF4Close( BOOL bCanClose ) -{ - BOOL bWas; - bWas = _s.AltF4Close; - _s.AltF4Close = bCanClose; - return( bWas ); -} - -//-------------------------------------------------------------------// - -void HB_EXPORT hb_wvt_gtDoProcessMessages( void ) -{ - hb_wvt_gtProcessMessages(); -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtSetMouseMove( BOOL bHandleEvent ) -{ - BOOL bWas = _s.MouseMove; - _s.MouseMove = bHandleEvent; - return( bWas ); -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtEnableShortCuts( BOOL bEnable ) -{ - BOOL bWas = _s.EnableShortCuts; - _s.EnableShortCuts = bEnable; - return( bWas ); -} - -//-------------------------------------------------------------------// -// -// Courtesy - Augusto Infante - Thanks -// -HB_EXPORT IPicture * hb_wvt_gtLoadPictureFromResource( LPCSTR cResource, LPCSTR cSection ) -{ - HRSRC res; - LPVOID iPicture = NULL; - //LPTSTR resource = cResource; //HB_TCHAR_CPTO( cResource ); - //LPTSTR section = cSection; //HB_TCHAR_CPTO( cSection ); - - res = FindResource( ( HINSTANCE ) hb_hInstance, cResource, cSection ); - if ( res ) - { - IStream *iStream = NULL; - HGLOBAL mem = LoadResource( GetModuleHandle( NULL ), res ); - void *data = LockResource( mem ); - size_t nFileSize = SizeofResource( GetModuleHandle( NULL ), res ); - HGLOBAL hGlobal = GlobalAlloc( GMEM_MOVEABLE, nFileSize ); - LPVOID pvData = GlobalLock( hGlobal ); - - memcpy( pvData, data, nFileSize ); - - GlobalUnlock( hGlobal ); - - CreateStreamOnHGlobal( hGlobal, TRUE, &iStream ); - - OleLoadPicture( iStream, nFileSize, TRUE, ( REFIID ) &IID_IPicture, &iPicture ); - - FreeResource( mem ); - } - - //HB_TCHAR_FREE( resource ); - //HB_TCHAR_FREE( section ); - - return (IPicture *) iPicture; -} - -//--------------------------------------------------------------------// - -HB_EXPORT IPicture * hb_wvt_gtLoadPicture( char * cImage ) -{ - IStream *iStream; - LPVOID iPicture = NULL; - HGLOBAL hGlobal; - HANDLE hFile; - DWORD nFileSize; - DWORD nReadByte; - LPTSTR image = HB_TCHAR_CONVTO( cImage ); - - hFile = CreateFile( image, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); - if ( hFile != INVALID_HANDLE_VALUE ) - { - nFileSize = GetFileSize( hFile, NULL ); - - if ( nFileSize != INVALID_FILE_SIZE ) - { - hGlobal = GlobalAlloc( GPTR, nFileSize ); - - if ( hGlobal ) - { - if ( ReadFile( hFile, hGlobal, nFileSize, &nReadByte, NULL ) ) - { - CreateStreamOnHGlobal( hGlobal, TRUE, &iStream ); - OleLoadPicture( iStream, nFileSize, TRUE, (REFIID) &IID_IPicture, &iPicture ); - } - GlobalFree( hGlobal ); - } - } - CloseHandle( hFile ); - } - - HB_TCHAR_FREE( image ); - return ( IPicture * ) iPicture; -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtRenderPicture( int x1, int y1, int wd, int ht, IPicture * iPicture ) -{ - LONG lWidth,lHeight; - int x,y,xe,ye; - int c = x1 ; - int r = y1 ; - int dc = wd ; - int dr = ht ; - int tor = 0 ; - int toc = 0 ; - HRGN hrgn1; - POINT lpp; - BOOL bResult = FALSE; - - if ( iPicture ) - { - iPicture->lpVtbl->get_Width( iPicture,&lWidth ); - iPicture->lpVtbl->get_Height( iPicture,&lHeight ); - - if ( dc == 0 ) - { - dc = ( int ) ( ( float ) dr * lWidth / lHeight ); - } - if ( dr == 0 ) - { - dr = ( int ) ( ( float ) dc * lHeight / lWidth ); - } - if ( tor == 0 ) - { - tor = dr; - } - if ( toc == 0 ) - { - toc = dc; - } - x = c; - y = r; - xe = c + toc - 1; - ye = r + tor - 1; - - GetViewportOrgEx( _s.hdc, &lpp ); - - hrgn1 = CreateRectRgn( c+lpp.x, r+lpp.y, xe+lpp.x, ye+lpp.y ); - SelectClipRgn( _s.hdc, hrgn1 ); - - while ( x < xe ) - { - while ( y < ye ) - { - iPicture->lpVtbl->Render( iPicture, _s.hdc, x, y, dc, dr, 0, lHeight, lWidth, -lHeight, NULL ); - y += dr; - } - y = r; - x += dc; - } - - SelectClipRgn( _s.hdc, NULL ); - DeleteObject( hrgn1 ); - - if ( _s.bGui ) - { - x = c; - y = r; - xe = c + toc - 1; - ye = r + tor - 1; - - GetViewportOrgEx( _s.hGuiDC, &lpp ); - - hrgn1 = CreateRectRgn( c+lpp.x, r+lpp.y, xe+lpp.x, ye+lpp.y ); - SelectClipRgn( _s.hGuiDC, hrgn1 ); - - while ( x < xe ) - { - while ( y < ye ) - { - iPicture->lpVtbl->Render( iPicture, _s.hGuiDC, x, y, dc, dr, 0, lHeight, lWidth, -lHeight, NULL ); - y += dr; - } - y = r; - x += dc; - } - - SelectClipRgn( _s.hGuiDC, NULL ); - DeleteObject( hrgn1 ); - } - - bResult = TRUE ; - } - - return( bResult ); -} - -//-------------------------------------------------------------------// - -BOOL HB_EXPORT hb_wvt_gtDestroyPicture( IPicture * iPicture ) -{ - BOOL bResult = FALSE; - - if ( iPicture ) - { - iPicture->lpVtbl->Release( iPicture ); - bResult = TRUE; - } - return bResult; -} - -//-------------------------------------------------------------------// - -GLOBAL_DATA * hb_wvt_gtGetGlobalData( void ) -{ - return &_s; -} - -//-------------------------------------------------------------------// - -HB_EXPORT COLORREF hb_wvt_gtGetColorData( int iIndex ) -{ - return _COLORS[ iIndex ]; -} - -//-------------------------------------------------------------------// - -HB_EXPORT BOOL hb_wvt_gtSetColorData( int iIndex, COLORREF ulCr ) -{ - BOOL bResult = FALSE; - - if ( iIndex >= 0 && iIndex < 16 ) - { - _COLORS[ iIndex ] = ulCr; - bResult = TRUE; - } - return bResult; -} - -//-------------------------------------------------------------------// - -static int kbdShiftsState( void ) -{ - BYTE kbBuffer[ 256 ]; - int kbdShifts; - kbdShifts = 0; - GetKeyboardState( kbBuffer ); - if ( kbBuffer[ VK_SHIFT ] & 0x080 ) kbdShifts += GTI_KBD_SHIFT; - if ( kbBuffer[ VK_CONTROL ] & 0x080 ) kbdShifts += GTI_KBD_CTRL; - if ( kbBuffer[ VK_MENU ] & 0x080 ) kbdShifts += GTI_KBD_ALT; - if ( kbBuffer[ VK_LWIN ] & 0x080 ) kbdShifts += GTI_KBD_LWIN; - if ( kbBuffer[ VK_RWIN ] & 0x080 ) kbdShifts += GTI_KBD_RWIN; - if ( kbBuffer[ VK_APPS ] & 0x080 ) kbdShifts += GTI_KBD_MENU; - if ( kbBuffer[ VK_SCROLL ] & 0x01 ) kbdShifts += GTI_KBD_SCROLOCK; - if ( kbBuffer[ VK_NUMLOCK ] & 0x01 ) kbdShifts += GTI_KBD_NUMLOCK; - if ( kbBuffer[ VK_CAPITAL ] & 0x01 ) kbdShifts += GTI_KBD_CAPSLOCK; - return kbdShifts; -} - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// GT Specific Functions -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_Init( FHANDLE iFilenoStdin, FHANDLE iFilenoStdout, FHANDLE iFilenoStderr ) ) -{ - /* FSG: filename var for application name */ - PHB_FNAME pFileName; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Init()" ) ); - - /* stdin && stdout && stderr */ - s_iStdIn = iFilenoStdin; - s_iStdOut = iFilenoStdout; - s_iStdErr = iFilenoStderr; - - s_usOldCurStyle = s_usCursorStyle = SC_NORMAL; - - gt_hbInitStatics(); - - _s.hWnd = hb_wvt_gtCreateWindow( ( HINSTANCE ) hb_hInstance, ( HINSTANCE ) hb_hPrevInstance, "", hb_iCmdShow ); - if ( !_s.hWnd ) - { - hb_errRT_TERM( EG_CREATE, 10001, "WINAPI CreateWindow() failed", "hb_gt_Init()", 0, 0 ); - } - pFileName = hb_fsFNameSplit( hb_cmdargARGV()[0] ); - hb_wvt_gtSetWindowTitle( pFileName->szName ); - hb_xfree( pFileName ); - - hb_wvt_gtCreateObjects(); - _s.hdc = GetDC( _s.hWnd ); - _s.hCompDC = CreateCompatibleDC( _s.hdc ); - hb_wvt_gtInitGui(); - -#ifndef HB_CDP_SUPPORT_OFF - _s.hostCDP = hb_cdp_page; - _s.inCDP = hb_cdp_page; -#endif - - if( b_MouseEnable ) - { - //HB_GT_FUNC( mouse_Init() ); - hb_wvt_gtSetMouseX( 0 ); - hb_wvt_gtSetMouseY( 0 ); - } - - if( b_MouseEnable ) - { - hb_wvt_gtCreateToolTipWindow(); - } -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_Exit( void ) ) -{ - int i; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Exit()" ) ); - - if ( _s.hWnd ) - { - for ( i = 0; i < WVT_DLGML_MAX; i++ ) - { - if ( _s.hDlgModeless[ i ] ) - { - SendMessage( _s.hDlgModeless[ i ], WM_CLOSE, 0, 0 ); - } - } - - DeleteObject( ( HPEN ) _s.penWhite ); - DeleteObject( ( HPEN ) _s.penWhiteDim ); - DeleteObject( ( HPEN ) _s.penBlack ); - DeleteObject( ( HPEN ) _s.penDarkGray ); - DeleteObject( ( HPEN ) _s.penGray ); - DeleteObject( ( HPEN ) _s.penNull ); - DeleteObject( ( HPEN ) _s.currentPen ); - DeleteObject( ( HBRUSH ) _s.currentBrush ); - DeleteObject( ( HBRUSH ) _s.diagonalBrush ); - DeleteObject( ( HBRUSH ) _s.solidBrush ); - DeleteObject( ( HBRUSH ) _s.wvtWhiteBrush ); - - if ( _s.hdc ) - { - ReleaseDC( _s.hWnd, _s.hdc ); - } - - if ( _s.hCompDC ) - { - DeleteDC( _s.hCompDC ); - } - if ( _s.hGuiDC ) - { - DeleteDC( _s.hGuiDC ); - } - if ( _s.hGuiBmp ) - { - DeleteObject( _s.hGuiBmp ); - } - - - for ( i = 0; i < WVT_PICTURES_MAX; i++ ) - { - if ( _s.iPicture[ i ] ) - { - hb_wvt_gtDestroyPicture( _s.iPicture[ i ] ); - } - } - for ( i = 0; i < WVT_FONTS_MAX; i++ ) - { - if ( _s.hUserFonts[ i ] ) - { - DeleteObject( _s.hUserFonts[ i ] ); - } - } - for ( i = 0; i < WVT_PENS_MAX; i++ ) - { - if ( _s.hUserPens[ i ] ) - { - DeleteObject( _s.hUserPens[ i ] ); - } - } - if ( _s.hMSImg32 ) - { - FreeLibrary( _s.hMSImg32 ); - } - - DestroyWindow( _s.hWnd ); - } - UnregisterClass( szAppName,( HINSTANCE ) hb_hInstance ); - - if( b_MouseEnable ) - { - //HB_GT_FUNC( mouse_Exit() ); - } -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_ProcessMessages( void ) ) -{ - hb_wvt_gtProcessMessages(); -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_GetClipboard( char *szData, ULONG *pulMaxSize ) ) -{ - HGLOBAL hglb; - LPTSTR lptstr; - UINT uFormat = ( _s.CodePage == OEM_CHARSET ) ? CF_OEMTEXT : CF_TEXT; - - if ( ! IsClipboardFormatAvailable( uFormat ) ) - { - *pulMaxSize = 0; - return; - } - - if ( !OpenClipboard( NULL ) ) - { - *pulMaxSize = 0; - return; - } - - hglb = GetClipboardData( uFormat ); - if ( hglb != NULL ) - { - lptstr = ( LPTSTR ) GlobalLock( hglb ); - if ( lptstr != NULL ) - { - ULONG iLen = strlen( lptstr ); - - if ( *pulMaxSize == 0 || *pulMaxSize > iLen ) - { - *pulMaxSize = iLen; - } - - // still nothing ? - // - if ( *pulMaxSize == 0 ) - { - return; - } - - memcpy( szData, lptstr, *pulMaxSize ); - szData[ *pulMaxSize ] = '\0'; - - GlobalUnlock( hglb ); - } - } - CloseClipboard(); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( gt_SetClipboard( char *szData, ULONG ulSize ) ) -{ - LPTSTR lptstrCopy; - HGLOBAL hglbCopy; - UINT uFormat = ( _s.CodePage == OEM_CHARSET ) ? CF_OEMTEXT : CF_TEXT; - -/* This poses problems when some other application copies a bitmap on the - clipboard. The only way to set text to clipboard is made possible - only if another application copies some text on the clipboard. - - if ( !IsClipboardFormatAvailable( CF_TEXT ) ) - { - return; - } -*/ - - if ( ! OpenClipboard( NULL ) ) - { - return; - } - EmptyClipboard(); - - // Allocate a global memory object for the text. - // - hglbCopy = GlobalAlloc( GMEM_MOVEABLE, ( ulSize+1 ) * sizeof( TCHAR ) ); - if ( ! hglbCopy ) - { - CloseClipboard(); - return; - } - - // Lock the handle and copy the text to the buffer. - // - lptstrCopy = ( LPTSTR ) GlobalLock( hglbCopy ); // LPSTR - - memcpy( lptstrCopy, szData, ( ulSize+1 ) * sizeof( TCHAR ) ); - - lptstrCopy[ ulSize+1 ] = ( TCHAR ) 0; // null character - - GlobalUnlock( hglbCopy ); - - // Place the handle on the clipboard. - // - SetClipboardData( uFormat, hglbCopy ); - - CloseClipboard(); -} - -//-------------------------------------------------------------------// - -static ULONG HB_GT_FUNC( gt_GetClipboardSize( void ) ) -{ - HGLOBAL hglb; - LPTSTR lptstr; - UINT uFormat = ( _s.CodePage == OEM_CHARSET ) ? CF_OEMTEXT : CF_TEXT; - int ret; - - if ( !IsClipboardFormatAvailable( uFormat ) ) - { - return 0; - } - - if ( ! OpenClipboard( NULL ) ) - { - return 0; - } - - hglb = GetClipboardData( uFormat ); - ret = 0; - if ( hglb != NULL ) - { - lptstr = ( LPTSTR ) GlobalLock( hglb ); // LPSTR - if ( lptstr != NULL ) - { - ret = strlen( lptstr ); - GlobalUnlock( hglb ); - } - } - CloseClipboard(); - return ret; -} - -//-------------------------------------------------------------------// -// -// returns the number of displayable columns -// -static USHORT HB_GT_FUNC( gt_GetScreenWidth( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetScreenWidth()" ) ); - return _GetScreenWidth(); -} - -//-------------------------------------------------------------------// -// -// returns the number of displayable rows -// -static USHORT HB_GT_FUNC( gt_GetScreenHeight( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetScreenHeight()")); - return _GetScreenHeight(); -} - -//-------------------------------------------------------------------// - -static SHORT HB_GT_FUNC( gt_Col( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Col()" ) ); - return( (SHORT) _s.caretPos.x ); -} - -//-------------------------------------------------------------------// - -static SHORT HB_GT_FUNC( gt_Row( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Row()" ) ); - return( (SHORT) _s.caretPos.y ); -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_SetPos( int sRow, int sCol ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetPos( %hd, %hd )", sRow, sCol ) ); - - if ( sRow >= 0 && sRow< _GetScreenHeight() && sCol>=0 && sCol <= _GetScreenWidth() ) - { - _s.caretPos.x = sCol; - _s.caretPos.y = sRow; - hb_wvt_gtValidateCaret(); - } -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_GetPos( int * sRow, int * sCol ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetPos( %hd, %hd, %hd )", sRow, sCol, sMethod ) ); - - *sCol = _s.caretPos.x; - *sRow = _s.caretPos.y; -} - -//-------------------------------------------------------------------// -/* -static BOOL HB_GT_FUNC( gt_AdjustPos( BYTE * pStr, ULONG ulLen ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_AdjustPos( %s, %lu )", pStr, ulLen ) ); - - HB_SYMBOL_UNUSED( pStr ); - HB_SYMBOL_UNUSED( ulLen ); - - return( FALSE ); -} -*/ -//-------------------------------------------------------------------// - -static BOOL HB_GT_FUNC( gt_IsColor( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_IsColor()" ) ); - return( TRUE ); -} - -//-------------------------------------------------------------------// - -int HB_GT_FUNC( gt_GetCursorStyle( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetCursorStyle()" ) ); - return( s_usCursorStyle ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( gt_SetCursorStyle( int usStyle ) ) -{ - BOOL bCursorOn= TRUE; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetCursorStyle( %hu )", usStyle ) ); - - s_usCursorStyle = usStyle; - switch( usStyle ) - { - case SC_NONE: - _s.CaretSize = 0 ; - bCursorOn= FALSE; - break ; - case SC_INSERT: - _s.CaretSize = ( _s.PTEXTSIZE.y / 2 ) ; - break; - case SC_SPECIAL1: - _s.CaretSize = _s.PTEXTSIZE.y ; - break; - case SC_SPECIAL2: - _s.CaretSize = -( _s.PTEXTSIZE.y / 2 ) ; - break; - case SC_NORMAL: - default: - _s.CaretSize = 4 ; - break; - } - if ( bCursorOn ) - { - _s.CaretExist = CreateCaret( _s.hWnd, ( HBITMAP ) NULL, _s.PTEXTSIZE.x, _s.CaretSize ); - } - - hb_wvt_gtSetCaretOn( bCursorOn ); -} - -//-------------------------------------------------------------------// - -static int HB_GT_FUNC( gt_MaxCol( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_MaxCol()")); - return( ( int )_GetScreenWidth()-1 ); -} - -//-------------------------------------------------------------------// - -static int HB_GT_FUNC( gt_MaxRow( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_MaxRow()")); - return( ( int )_GetScreenHeight()-1 ); -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_DispBegin( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_DispBegin()" ) ); - ++s_uiDispCount; -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_DispEnd() ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_DispEnd()" ) ); - - if ( s_uiDispCount > 0 ) - { - --s_uiDispCount; - } - if ( s_uiDispCount<= 0 ) - { - hb_wvt_gtDoInvalidateRect(); - } -} - -//-------------------------------------------------------------------// - -static int HB_GT_FUNC( gt_DispCount() ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_DispCount()" ) ); - return( s_uiDispCount ); -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_Replicate( USHORT usRow, USHORT usCol, BYTE byAttr, BYTE byChar, ULONG ulLen ) ) -{ - BYTE ucBuff[ WVT_CHAR_BUFFER ], *byChars; - ULONG i; - BOOL bMalloc = FALSE; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Replicate( %hu, %hu, %i, %i, %lu )", usRow, usCol, byAttr, byChar, ulLen ) ); - - if ( ulLen > WVT_CHAR_BUFFER ) - { // Avoid allocating memory if possible - byChars = ( BYTE* ) hb_xgrab( ulLen ); - bMalloc= TRUE; - } - else - { - byChars = ucBuff ; - } - - for ( i = 0; i < ulLen; i++ ) - { - *( byChars+i ) = byChar; - } - - hb_wvt_gtSetStringInTextBuffer( (SHORT) usCol, (SHORT) usRow, byAttr, byChars, (SHORT) ulLen ); - if ( bMalloc ) - { - hb_xfree( byChars ); - } -} - -//-------------------------------------------------------------------// -/* -static int HB_GT_FUNC( gt_RectSize( USHORT rows, USHORT cols ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_RectSize()" ) ); - return( rows * cols * 2 ); -} -*/ -//-------------------------------------------------------------------// - -void hb_wvt_GetStringAttrib( USHORT top, USHORT left, USHORT bottom, USHORT right, BYTE * sBuffer, BYTE * sAttrib ) -{ - USHORT irow, icol, index, j; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetText( %hu, %hu, %hu, %hu, %p )", top, left, bottom, right, sBuffer ) ); - - j = 0; - for ( irow = top; irow <= bottom; irow++ ) - { - index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); - for ( icol = left; icol <= right; icol++ ) - { - if ( index >= _s.BUFFERSIZE ) - { - break; - } - else - { - sBuffer[ j ] = _s.pBuffer[ index ]; - sAttrib[ j ] = _s.pAttributes[ index ]; - index++; - j++; - } - } - } -} - -//----------------------------------------------------------------------// - -void hb_wvt_PutStringAttrib( USHORT top, USHORT left, USHORT bottom, USHORT right, BYTE * sBuffer, BYTE * sAttrib ) -{ - USHORT irow, icol, index, j; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetText( %hu, %hu, %hu, %hu, %p )", top, left, bottom, right, sBuffer ) ); - - j = 0; - for ( irow = top; irow <= bottom; irow++ ) - { - index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); - for ( icol = left; icol <= right; icol++ ) - { - if ( index >= _s.BUFFERSIZE ) - { - break; - } - else - { - _s.pBuffer[ index ] = sBuffer[ j ]; - _s.pAttributes[ index ] = sAttrib[ j ]; - j++; - index++; - } - } - } - hb_wvt_gtSetInvalidRect( left, top, right, bottom ); -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_GetText( int top, int left, int bottom, int right, BYTE * sBuffer ) ) -{ - USHORT irow, icol, index, j; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetText( %hu, %hu, %hu, %hu, %p )", top, left, bottom, right, sBuffer ) ); - - j = 0; - for ( irow = top; irow <= bottom; irow++ ) - { - index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); - for ( icol = left; icol <= right; icol++ ) - { - if ( index >= _s.BUFFERSIZE ) - { - break; - } - else - { - sBuffer[ j++ ] = _s.pBuffer[ index ]; - sBuffer[ j++ ] = _s.pAttributes[ index ]; - index++; - } - } - } -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_Puts( USHORT usRow, USHORT usCol, BYTE byAttr, BYTE *pbyStr, ULONG ulLen ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Puts( %hu, %hu, %d, %p, %hu )", usRow, usCol, ( int ) byAttr, pbyStr, ulLen ) ); - hb_wvt_gtSetStringInTextBuffer( (SHORT) usCol, (SHORT) usRow, byAttr, pbyStr, (SHORT) ulLen ); -} - -//-------------------------------------------------------------------// -// FOR RestScrn() -// -static void HB_GT_FUNC( gt_xPutText( int top, int left, int bottom, int right, BYTE * sBuffer ) ) -{ - USHORT irow, icol, index, j; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_XPutText( %hu, %hu, %hu, %hu, %s )", top, left, bottom, right, *sBuffer ) ); - - j = 0; - for ( irow = top; irow <= bottom; irow++ ) - { - index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); - for ( icol = left; icol <= right; icol++ ) - { - if ( index >= _s.BUFFERSIZE ) - { - break; - } - else - { - _s.pBuffer[ index ] = sBuffer[ j++ ]; - _s.pAttributes[ index ] = sBuffer[ j++ ]; - index++; - } - } - } - hb_wvt_gtSetInvalidRect( left, top, right, bottom ); -} - -//----------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_PutText( int top, int left, BYTE bColor, BYTE * pText, ULONG ulLen ) ) -{ - USHORT irow, icol, index, j, right; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_PutText( %hu, %hu, %hu, %hu, %p )", top, left, bottom, right, sBuffer ) ); - - j = 0; - irow = top; - right = left + ulLen - 1; - - index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); - for ( icol = left; icol <= right; icol++ ) - { - if ( index >= _s.BUFFERSIZE ) - { - break; - } - else - { - _s.pBuffer[ index ] = pText[ j++ ]; - _s.pAttributes[ index ] = bColor; - index++; - } - } - hb_wvt_gtSetInvalidRect( left, top, right, top ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( gt_SetAttribute( int rowStart, int colStart, int rowStop, int colStop, BYTE attr ) ) -{ - USHORT irow, icol, index; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetAttribute( %hu, %hu, %hu, %hu, %d", rowStart, colStart, rowStop, colStop, ( int ) attr ) ); - - for ( irow = rowStart; irow <=rowStop; irow++ ) - { - index = hb_wvt_gtGetIndexForTextBuffer( colStart, irow ); - for ( icol = colStart; icol <= colStop; icol++ ) - { - if ( index >= _s.BUFFERSIZE ) - { - break; - } - else - { - _s.pAttributes[ index++ ] = attr; - } - } - } - hb_wvt_gtSetInvalidRect( colStart, rowStart, colStop, rowStop ); -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_SetAttributeCT( USHORT rowStart, USHORT colStart, USHORT rowStop, USHORT colStop, BYTE attr ) ) -{ - USHORT irow, icol, index; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetAttributeCT( %hu, %hu, %hu, %hu, %d", rowStart, colStart, rowStop, colStop, ( int ) attr ) ); - - for ( irow = rowStart; irow <=rowStop; irow++ ) - { - index = hb_wvt_gtGetIndexForTextBuffer( colStart, irow ); - for ( icol = colStart; icol <= colStop; icol++ ) - { - if ( index >= _s.BUFFERSIZE ) - { - break; - } - else - { - if ( _s.pAttributes[ index ] != attr && _s.pAttributes[ index ] ) - { - _s.pAttributes[ index++ ] = attr; - } - else - { - _s.pAttributes[ index++ ] = 0; - } - } - } - } - hb_wvt_gtSetInvalidRect( colStart, rowStart, colStop, rowStop ); -} - -//-------------------------------------------------------------------// -// -// copied from gtwin... -// -void HB_GT_FUNC( gt_Scroll( int usTop, int usLeft, int usBottom, int usRight, BYTE byAttr, BYTE byChar, int iRows, int iCols ) ) -{ - SHORT usSaveRow, usSaveCol; - BYTE ucBlank[ WVT_CHAR_BUFFER ], ucBuff[ WVT_CHAR_BUFFER * 2 ] ; - BYTE * fpBlank ; - BYTE * fpBuff ; - int iLength = ( usRight - usLeft ) + 1; - int iCount, iColOld, iColNew, iColSize; - BOOL bMalloc = FALSE; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Scroll( %hu, %hu, %hu, %hu, %d, %hd, %hd )", usTop, usLeft, usBottom, usRight, ( int ) byAttr, iRows, iCols ) ); - - if ( iLength > WVT_CHAR_BUFFER ) - { // Avoid allocating memory if possible - fpBlank = ( BYTE * ) hb_xgrab( iLength ); - fpBuff = ( BYTE * ) hb_xgrab( iLength * 2 ); - bMalloc = TRUE; - } - else - { - fpBlank = ucBlank ; - fpBuff = ucBuff ; - } - - memset( fpBlank, byChar /*' ' or hb_ctGetClearB()*/, iLength ); - - iColOld = iColNew = usLeft; - iColSize = iLength -1; - if( iCols >= 0 ) - { - iColOld += iCols; - iColSize -= iCols; - } - else - { - iColNew -= iCols; - iColSize += iCols; - } - // use the ScrollWindowEx() where possible ( Optimised for Terminal Server ) - // if both iCols & iRows are ZERO then the entire area is to be cleared and - // there is no advantage in using ScrollWindowEx() - // - _s.InvalidateWindow = HB_GT_FUNC( gt_DispCount() ) > 0 || ( !iRows && !iCols ) ; - - // if _s.InvalidateWindow is FALSE it is used to stop - // HB_GT_FUNC( gt_Puts() ) & HB_GT_FUNC( gt_PutText() ) - // from actually updating the screen. ScrollWindowEx() is used - // - if ( _s.InvalidateWindow ) - { - HB_GT_FUNC( gt_DispBegin() ); - } - - usSaveCol = HB_GT_FUNC( gt_Col() ) ; - usSaveRow = HB_GT_FUNC( gt_Row() ) ; - for( iCount = ( iRows >= 0 ? usTop : usBottom ); - ( iRows >= 0 ? iCount <= usBottom : iCount >= usTop ); - ( iRows >= 0 ? iCount++ : iCount-- ) ) - { - int iRowPos = iCount + iRows; - - /* Read the text to be scrolled into the current row */ - if( ( iRows || iCols ) && iRowPos <= usBottom && iRowPos >= usTop ) - { - HB_GT_FUNC( gt_GetText( iRowPos, iColOld, iRowPos, iColOld + iColSize, fpBuff ) ); - } - - /* Blank the scroll region in the current row */ - HB_GT_FUNC( gt_Puts( iCount, usLeft, byAttr, fpBlank, iLength ) ); - - /* Write the scrolled text to the current row */ - if( ( iRows || iCols ) && iRowPos <= usBottom && iRowPos >= usTop ) - { - // TO RESTORE - HB_GT_FUNC( gt_xPutText( iCount, iColNew, iCount, iColNew + iColSize, fpBuff ) ); - } - } - HB_GT_FUNC( gt_SetPos( usSaveRow, usSaveCol /*, 0 HB_GT_SET_POS_AFTER*/ ) ); - - if ( _s.InvalidateWindow ) - { - HB_GT_FUNC( gt_DispEnd() ); - } - else - { - RECT cr, crInvalid; - - cr.left = usLeft + ( iCols>0 ? 1 : 0 ) ; - cr.top = usTop + ( iRows>0 ? 1 : 0 ) ; - cr.right = usRight - ( iCols<0 ? 1 : 0 ) ; - cr.bottom = usBottom - ( iRows<0 ? 1 : 0 ) ; - - cr = hb_wvt_gtGetXYFromColRowRect( cr ); - ScrollWindowEx( _s.hWnd, -iCols * _s.PTEXTSIZE.x, -iRows *_s.PTEXTSIZE.y, &cr, NULL, NULL, &crInvalid, 0 ) ; - InvalidateRect( _s.hWnd, &crInvalid, FALSE ); - _s.InvalidateWindow = TRUE ; - } - - if ( bMalloc ) - { - hb_xfree( fpBlank ); - hb_xfree( fpBuff ); - } -} - -//-------------------------------------------------------------------// -// -// resize the ( existing ) window -// -BOOL HB_GT_FUNC( gt_SetMode( int row, int col ) ) -{ - BOOL bResult= FALSE; - HFONT hFont; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetMode( %hu, %hu )", row, col ) ); - - if ( row<= WVT_MAX_ROWS && col<= WVT_MAX_COLS ) - { - // Is the window already open - if ( _s.hWnd ) - { - hFont = hb_wvt_gtGetFont( _s.fontFace, _s.fontHeight, _s.fontWidth, _s.fontWeight, _s.fontQuality, _s.CodePage ); - if ( hFont ) - { - // make sure that the mode selected along with the current - // font settings will fit in the window - if ( hb_wvt_gtValidWindowSize( row,col, hFont, _s.fontWidth ) ) - { - bResult = hb_wvt_gtInitWindow( _s.hWnd, col, row ); - } - DeleteObject( hFont ); - } - } - else - { - hb_wvt_gtAllocSpBuffer( row, col ); - } - } - return( bResult ); -} - -//-------------------------------------------------------------------// - -static BOOL HB_GT_FUNC( gt_GetBlink( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetBlink()" ) ); - return( TRUE ); -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_SetBlink( BOOL bBlink ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetBlink( %d )", ( int ) bBlink ) ); - HB_SYMBOL_UNUSED( bBlink ); -} - -//-------------------------------------------------------------------// - -static char * HB_GT_FUNC( gt_Version( int iType ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Version()" ) ); - - if ( iType == 0 ) - { - return HB_GT_DRVNAME( HB_GT_NAME ); - } - return "Harbour Terminal: Win32 buffered Graphical WVG"; -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_xPutch( USHORT iRow, USHORT iCol, BYTE bAttr, BYTE bChar ) ) -{ - USHORT index; - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_xPutch( %hu, %hu, %d, %i )", iRow, iCol, ( int ) bAttr, bChar ) ); - - index = hb_wvt_gtGetIndexForTextBuffer( iCol, iRow ); - if ( index < _s.BUFFERSIZE ) - { - _s.pBuffer[ index ] = bChar; - _s.pAttributes[ index ] = bAttr; - - // determine bounds of rect around character to refresh - // - hb_wvt_gtSetInvalidRect( iCol, iRow, iCol, iRow ); - } -} - -//-------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_Box( int Top, int Left, int Bottom, int Right, BYTE * szBox, BYTE byAttr ) ) -{ - SHORT Row; - SHORT Col; - SHORT Height; - SHORT Width; - USHORT sWidth = _GetScreenWidth(), - sHeight = _GetScreenHeight(); - - if( ( Left >= 0 && Left < sWidth ) || - ( Right >= 0 && Right < sWidth ) || - ( Top >= 0 && Top < sHeight ) || - ( Bottom >= 0 && Bottom < sHeight ) ) - { - /* Ensure that box is drawn from top left to bottom right. */ - if( Top > Bottom ) - { - Row = Top; - Top = Bottom; - Bottom = Row; - } - - if( Left > Right ) - { - Row = Left; - Left = Right; - Right = Row; - } - - /* Draw the box or line as specified */ - Height = Bottom - Top + 1; - Width = Right - Left + 1; - - HB_GT_FUNC( gt_DispBegin() ); - - if( Height > 1 && Width > 1 && Top >= 0 && Top < sHeight && Left >= 0 && Left < sWidth ) - { - HB_GT_FUNC( gt_xPutch( Top, Left, byAttr, szBox[ 0 ] ) ); /* Upper left corner */ - } - - Col = ( Width > 1 ? Left + 1 : Left ); - - if( Col < 0 ) - { - Width += Col; - Col = 0; - } - - if( Right >= sWidth ) - { - Width -= Right - sWidth; - } - - if( Col < Right && Col < sWidth && Top >= 0 && Top < sHeight ) - { - HB_GT_FUNC( gt_Replicate( Top, Col, byAttr, szBox[ 1 ], Width + ( (Right - Left) > 1 ? -2 : 0 ) )); /* Top line */ - } - - if( Height > 1 && (Right - Left) > 0 && Right < sWidth && Top >= 0 && Top < sHeight ) - { - HB_GT_FUNC( gt_xPutch( Top, Right, byAttr, szBox[ 2 ] ) ); /* Upper right corner */ - } - - if( szBox[ 8 ] && Height > 2 && Width > 2 ) - { - for( Row = Top + 1; Row < Bottom; Row++ ) - { - if( Row >= 0 && Row < sHeight ) - { - Col = Left; - - if( Col < 0 ) - { - Col = 0; /* The width was corrected earlier. */ - } - else - { - HB_GT_FUNC( gt_xPutch( Row, Col++, byAttr, szBox[ 7 ] ) ); /* Left side */ - } - - HB_GT_FUNC( gt_Replicate( Row, Col, byAttr, szBox[ 8 ], Width - 2 ) ); /* Fill */ - - if( Right < sWidth ) - { - HB_GT_FUNC( gt_xPutch( Row, Right, byAttr, szBox[ 3 ] )); /* Right side */ - } - } - } - } - else - { - for( Row = ( Width > 1 ? Top + 1 : Top ); Row < ( (Right - Left ) > 1 ? Bottom : Bottom + 1 ); Row++ ) - { - if( Row >= 0 && Row < sHeight ) - { - if( Left >= 0 && Left < sWidth ) - { - HB_GT_FUNC(gt_xPutch( Row, Left, byAttr, szBox[ 7 ] )); /* Left side */ - } - - if( ( Width > 1 || Left < 0 ) && Right < sWidth ) - { - HB_GT_FUNC(gt_xPutch( Row, Right, byAttr, szBox[ 3 ] )); /* Right side */ - } - } - } - } - - if( Height > 1 && Width > 1 ) - { - if( Left >= 0 && Bottom < sHeight ) - { - HB_GT_FUNC(gt_xPutch( Bottom, Left, byAttr, szBox[ 6 ] )); /* Bottom left corner */ - } - - Col = Left + 1; - - if( Col < 0 ) - { - Col = 0; /* The width was corrected earlier. */ - } - - if( Col <= Right && Bottom < sHeight ) - { - HB_GT_FUNC(gt_Replicate( Bottom, Col, byAttr, szBox[ 5 ], Width - 2 )); /* Bottom line */ - } - - if( Right < sWidth && Bottom < sHeight ) - { - HB_GT_FUNC(gt_xPutch( Bottom, Right, byAttr, szBox[ 4 ] )); /* Bottom right corner */ - } - } - - HB_GT_FUNC( gt_DispEnd() ); - } -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( gt_BoxD( int Top, int Left, int Bottom, int Right, BYTE * pbyFrame, BYTE byAttr ) ) -{ - HB_GT_FUNC( gt_Box( Top, Left, Bottom, Right, pbyFrame, byAttr ) ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( gt_BoxS( int Top, int Left, int Bottom, int Right, BYTE * pbyFrame, BYTE byAttr ) ) -{ - HB_GT_FUNC( gt_Box( Top, Left, Bottom, Right, pbyFrame, byAttr ) ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( gt_HorizLine( int Row, int Left, int Right, BYTE byChar, BYTE byAttr ) ) -{ - USHORT sWidth = _GetScreenWidth(); - - if( Row >= 0 && Row < sWidth ) - { - if( Left < 0 ) - { - Left = 0; - } - else if( Left >= sWidth ) - { - Left = sWidth - 1; - } - if( Right < 0 ) - { - Right = 0; - } - else if( Right >= sWidth ) - { - Right = sWidth - 1; - } - if( Left < Right ) - { - HB_GT_FUNC( gt_Replicate( Row, Left, byAttr, byChar, Right - Left + 1 ) ); - } - else - { - HB_GT_FUNC( gt_Replicate( Row, Right, byAttr, byChar, Left - Right + 1 ) ); - } - } -} - -//-------------------------------------------------------------------// -// -void HB_GT_FUNC( gt_VertLine( int Col, int Top, int Bottom, BYTE byChar, BYTE byAttr ) ) -{ - USHORT sWidth = _GetScreenWidth(); - USHORT sHeight = _GetScreenHeight(); - SHORT Row; - - if( Col >= 0 && Col < sWidth ) - { - if( Top < 0 ) - { - Top = 0; - } - else if( Top >= sHeight ) - { - Top = sHeight - 1; - } - if( Bottom < 0 ) - { - Bottom = 0; - } - else if( Bottom >= sHeight ) - { - Bottom = sHeight - 1; - } - if( Top <= Bottom ) - { - Row = Top; - } - else - { - Row = Bottom; - Bottom = Top; - } - - HB_GT_FUNC( gt_DispBegin() ); - - while( Row <= Bottom ) - { - HB_GT_FUNC( gt_xPutch( Row++, Col, byAttr, byChar ) ); - } - - HB_GT_FUNC( gt_DispEnd() ); - } -} - -//-------------------------------------------------------------------// - -BOOL HB_GT_FUNC( gt_Suspend() ) -{ - return( TRUE ); -} - -//-------------------------------------------------------------------// - -BOOL HB_GT_FUNC( gt_Resume() ) -{ - return( TRUE ); -} - -//-------------------------------------------------------------------// - -BOOL HB_GT_FUNC( gt_PreExt() ) -{ - return( TRUE ); -} - -//-------------------------------------------------------------------// - -BOOL HB_GT_FUNC( gt_PostExt() ) -{ - return( TRUE ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( gt_OutStd( BYTE * pbyStr, ULONG ulLen ) ) -{ - hb_fsWriteLarge( s_iStdOut, ( BYTE * ) pbyStr, ulLen ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( gt_OutErr( BYTE * pbyStr, ULONG ulLen ) ) -{ - hb_fsWriteLarge( s_iStdErr, ( BYTE * ) pbyStr, ulLen ); -} - -//-------------------------------------------------------------------// - -int HB_GT_FUNC( gt_ExtendedKeySupport() ) -{ - return( FALSE ); // Only use standard Clipper hey handling -} - -//-------------------------------------------------------------------// - -int HB_GT_FUNC( gt_ReadKey() ) -{ - int c = 0; - BOOL bKey; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_ReadKey( %d )", ( int ) eventmask ) ); - - hb_wvt_gtProcessMessages() ; - bKey = hb_wvt_gtGetCharFromInputQueue( &c ); - - return( bKey ? c : 0 ); -} - -//----------------------------------------------------------------------// - -static BOOL HB_GT_FUNC( gt_Info( int iType, PHB_GT_INFO pInfo ) ) -{ - int iVal; - - HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Info(%d,%p)", iType, pInfo ) ); - - switch( iType ) - { - case GTI_FULLSCREEN: - case GTI_KBDSUPPORT: - case GTI_ISGRAPHIC: - pInfo->pResult = hb_itemPutL( pInfo->pResult, TRUE ); - break; - - case GTI_INPUTFD: - pInfo->pResult = hb_itemPutNInt( pInfo->pResult, - ( UINT_PTR ) GetStdHandle( STD_INPUT_HANDLE ) ); - break; - - case GTI_OUTPUTFD: - pInfo->pResult = hb_itemPutNInt( pInfo->pResult, - ( UINT_PTR ) GetStdHandle( STD_OUTPUT_HANDLE ) ); - break; - - case GTI_ERRORFD: - pInfo->pResult = hb_itemPutNInt( pInfo->pResult, - ( UINT_PTR ) GetStdHandle( STD_ERROR_HANDLE ) ); - break; - - case GTI_FONTSIZE: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.PTEXTSIZE.y ); - iVal = hb_itemGetNI( pInfo->pNewVal ); - if( iVal > 0 ) - { - HFONT hFont = hb_wvt_gtGetFont( _s.fontFace, iVal, _s.fontWidth, _s.fontWeight, _s.fontQuality, _s.CodePage ); - if ( hFont ) - { - _s.fontHeight = iVal; - if ( _s.hWnd ) - { - hb_wvt_gtResetWindowSize( _s.hWnd ); - hb_wvt_gtUpdateCaret(); - } - DeleteObject( hFont ); - } - } - break; - - case GTI_FONTWIDTH: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.fontWidth ); - iVal = hb_itemGetNI( pInfo->pNewVal ); - if( iVal > 0 ) - { - /* store font status for next operation on fontsize */ - _s.fontWidth = iVal; - } - break; - - case GTI_FONTNAME: - pInfo->pResult = hb_itemPutC( pInfo->pResult, _s.fontFace ); - if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) /* TODO */ - { - hb_strncpy( _s.fontFace, hb_itemGetCPtr( pInfo->pNewVal ), LF_FACESIZE - 1 ); - } - break; - - case GTI_FONTWEIGHT: - switch( _s.fontWeight ) - { - case FW_THIN: - case FW_EXTRALIGHT: - case FW_LIGHT: - iVal = GTI_FONTW_THIN; - break; - - case FW_DONTCARE: - case FW_NORMAL: - case FW_MEDIUM: - iVal = GTI_FONTW_NORMAL; - break; - - case FW_SEMIBOLD: - case FW_BOLD: - case FW_EXTRABOLD: - case FW_HEAVY: - iVal = GTI_FONTW_BOLD; - break; - - default: - iVal = 0; - break; - } - pInfo->pResult = hb_itemPutNI( pInfo->pResult, iVal ); - if ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) - { - /* store font status for next operation on fontsize */ - switch( hb_itemGetNI( pInfo->pNewVal ) ) - { - case GTI_FONTW_THIN: - _s.fontWeight = FW_LIGHT; - break; - case GTI_FONTW_NORMAL: - _s.fontWeight = FW_NORMAL; - break; - case GTI_FONTW_BOLD: - _s.fontWeight = FW_BOLD; - break; - } - } - break; - - case GTI_FONTQUALITY: - switch( _s.fontQuality ) - { - case ANTIALIASED_QUALITY: - iVal = GTI_FONTQ_HIGH; - break; - case DEFAULT_QUALITY: - case DRAFT_QUALITY: - iVal = GTI_FONTQ_NORMAL; - break; - case NONANTIALIASED_QUALITY: - case PROOF_QUALITY: - iVal = GTI_FONTQ_DRAFT; - break; - default: - iVal = 0; - break; - } - pInfo->pResult = hb_itemPutNI( pInfo->pResult, iVal ); - if ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) - { - switch( hb_itemGetNI( pInfo->pNewVal ) ) - { - case GTI_FONTQ_HIGH: - _s.fontQuality = ANTIALIASED_QUALITY; - break; - case GTI_FONTQ_NORMAL: - _s.fontQuality = DEFAULT_QUALITY; - break; - case GTI_FONTQ_DRAFT: - _s.fontQuality = DRAFT_QUALITY; - break; - } - } - break; - - case GTI_SCREENHEIGHT: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.PTEXTSIZE.y * _s.ROWS ); - iVal = hb_itemGetNI( pInfo->pNewVal ); - if( iVal > 0 ) - { - HB_GT_FUNC( gt_SetMode( (int) ( iVal / _s.PTEXTSIZE.y ), _s.COLS ) ); - } - break; - - case GTI_SCREENWIDTH: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.PTEXTSIZE.x * _s.COLS ); - iVal = hb_itemGetNI( pInfo->pNewVal ); - if( iVal > 0 ) - { - HB_GT_FUNC( gt_SetMode( _s.ROWS, (int) ( iVal / _s.PTEXTSIZE.x ) ) ); - } - break; - - case GTI_DESKTOPWIDTH: - { - RECT rDesk; - HWND hDesk; - - hDesk = GetDesktopWindow(); - GetWindowRect( hDesk, &rDesk ); - pInfo->pResult = hb_itemPutNI( pInfo->pResult, rDesk.right - rDesk.left ); - break; - } - case GTI_DESKTOPHEIGHT: - { - RECT rDesk; - HWND hDesk = GetDesktopWindow(); - GetWindowRect( hDesk, &rDesk ); - pInfo->pResult = hb_itemPutNI( pInfo->pResult, rDesk.bottom - rDesk.top ); - break; - } - case GTI_DESKTOPCOLS: - { - RECT rDesk; - HWND hDesk; - hDesk = GetDesktopWindow(); - GetClientRect( hDesk, &rDesk ); - pInfo->pResult = hb_itemPutNI( pInfo->pResult, - ( rDesk.right - rDesk.left ) / _s.PTEXTSIZE.x ); - break; - } - case GTI_DESKTOPROWS: - { - RECT rDesk; - HWND hDesk; - hDesk = GetDesktopWindow(); - GetClientRect( hDesk, &rDesk ); - pInfo->pResult = hb_itemPutNI( pInfo->pResult, - ( rDesk.bottom - rDesk.top ) / _s.PTEXTSIZE.y ); - break; - } - case GTI_WINTITLE: - pInfo->pResult = hb_itemPutC( pInfo->pResult, "" ); - if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) - { - hb_wvt_gtSetWindowTitle( hb_itemGetCPtr( pInfo->pNewVal ) ); - } - break; - - case GTI_CODEPAGE: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.CodePage ); - iVal = hb_itemGetNI( pInfo->pNewVal ); - if( iVal > 0 && iVal != _s.CodePage ) - { - _s.CodePage = iVal; - hb_wvt_gtResetWindowSize( _s.hWnd ); - } - break; - - case GTI_ICONFILE: - { - HICON hIcon = 0; - if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) - { - LPTSTR lpImage = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); - hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, lpImage, - IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); - HB_TCHAR_FREE( lpImage ); - if ( hIcon ) - { - SendMessage( _s.hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) hIcon ); /* Set Title Bar Icon */ - SendMessage( _s.hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) hIcon ); /* Set Task List Icon */ - } - } - pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( UINT_PTR ) hIcon ); - break; - } - - case GTI_ICONRES: - { - HICON hIcon = 0; - if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) - { - LPTSTR lpIcon = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); - hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, lpIcon ); - HB_TCHAR_FREE( lpIcon ); - } - else if ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) - { - hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, - MAKEINTRESOURCE( ( UINT_PTR ) - hb_itemGetNInt( pInfo->pNewVal ) ) ); - } - if ( hIcon ) - { - SendMessage( _s.hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) hIcon ); /* Set Title Bar Icon */ - SendMessage( _s.hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) hIcon ); /* Set Task List Icon */ - } - pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( UINT_PTR ) hIcon ); - break; - } - case GTI_VIEWMAXWIDTH: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.COLS ); - break; - - case GTI_VIEWMAXHEIGHT: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.ROWS ); - break; - - case GTI_KBDSHIFTS: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, kbdShiftsState() ); - /* TODO - if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) - kbdShiftsState( hb_itemGetNI( pInfo->pNewVal ) ); - break; - */ - - case GTI_CLIPBOARDDATA: - if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) - { - HB_GT_FUNC( gt_SetClipboard( hb_itemGetCPtr( pInfo->pNewVal ), - hb_itemGetCLen( pInfo->pNewVal ) ) ); - } - else - { - char *szClipboardData; - ULONG ulLen; - - HB_GT_FUNC( gt_GetClipboard( szClipboardData, &ulLen ) ); - if( szClipboardData ) - { - pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, szClipboardData, ulLen ); - } - else - { - pInfo->pResult = hb_itemPutC( pInfo->pResult, "" ); - } - } - break; - - case GTI_CURSORBLINKRATE: - pInfo->pResult = hb_itemPutNI( pInfo->pResult, GetCaretBlinkTime() ); - if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) - SetCaretBlinkTime( hb_itemGetNI( pInfo->pNewVal ) ); - break; - - default: - return HB_GTSUPER_INFO( iType, pInfo ); - } - - return TRUE; -} - -//----------------------------------------------------------------------// - -/* ********** Graphics API ********** */ -/* - * NOTE: - * gfxPrimitive() parameters may have different meanings - * ie: - Desired color is 'iBottom' for PUTPIXEL and 'iRight' for CIRCLE - * - Red is iTop, Green iLeft and Blue is iBottom for MAKECOLOR - * - */ - -#define SetGFXContext() hPen=CreatePen(PS_SOLID,1,color); hOldPen=(HPEN) SelectObject(hdc,hPen); hBrush=(HBRUSH) CreateSolidBrush(color); hOldBrush=(HBRUSH) SelectObject(hdc,hBrush); bOut=TRUE - -int HB_GT_FUNC( gt_gfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor ) ) -{ - COLORREF color; - HPEN hPen, hOldPen; - HBRUSH hBrush, hOldBrush; - HDC hdc; - BOOL bOut = FALSE; - int iRet = 0; - - hdc = GetDC( _s.hWnd ); - - switch ( iType ) - { - case GFX_ACQUIRESCREEN: - case GFX_RELEASESCREEN: - return 1; - case GFX_MAKECOLOR: - return ( (int) ( (iTop << 16) | (iLeft << 8) | ( iBottom ) ) ); - case GFX_PUTPIXEL: - color = RGB( iBottom >> 16, ( iBottom & 0xFF00 ) >> 8, iBottom & 0xFF ); - SetGFXContext(); - - MoveToEx( hdc, iLeft, iTop, NULL ); - LineTo( hdc, iLeft, iTop ); - - iRet = 1; - break; - case GFX_LINE: - color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); - SetGFXContext(); - - MoveToEx( hdc, iLeft, iTop, NULL ); - LineTo( hdc, iRight, iBottom ); - - iRet = 1; - break; - case GFX_RECT: - { - RECT r; - r.left = iLeft; - r.top = iTop; - r.right = iRight; - r.bottom = iBottom; - - color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); - SetGFXContext(); - - FrameRect( hdc, &r, hBrush ); - - iRet = 1; - } - break; - case GFX_FILLEDRECT: - color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); - SetGFXContext(); - - Rectangle( hdc, iLeft, iTop, iRight, iBottom ); - - iRet = 1; - break; - case GFX_CIRCLE: - color = RGB( iRight >> 16, ( iRight & 0xFF00 ) >> 8, iRight & 0xFF ); - SetGFXContext(); - - Arc( hdc, iLeft - iBottom / 2, iTop - iBottom / 2, iLeft + iBottom / 2, iTop + iBottom / 2, 0, 0, 0, 0 ); - - iRet = 1; - break; - case GFX_FILLEDCIRCLE: - color = RGB( iRight >> 16, ( iRight & 0xFF00 ) >> 8, iRight & 0xFF ); - SetGFXContext(); - - Ellipse( hdc, iLeft - iBottom / 2, iTop - iBottom / 2, iLeft + iBottom / 2, iTop + iBottom / 2 ); - - iRet = 1; - break; - case GFX_ELLIPSE: - color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); - SetGFXContext(); - - Arc( hdc, iLeft - iRight / 2, iTop - iBottom / 2, iLeft + iRight / 2, iTop + iBottom / 2, 0, 0, 0, 0 ); - - iRet = 1; - break; - case GFX_FILLEDELLIPSE: - color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); - SetGFXContext(); - - Ellipse( hdc, iLeft - iRight / 2, iTop - iBottom / 2, iLeft + iRight / 2, iTop + iBottom / 2 ); - - iRet = 1; - break; - case GFX_FLOODFILL: - color = RGB( iBottom >> 16, ( iBottom & 0xFF00 ) >> 8, iBottom & 0xFF ); - SetGFXContext(); - - FloodFill( hdc, iLeft, iTop, iColor ); - - iRet = 1; - break; - } - - if ( bOut ) - { - SelectObject( hdc, hOldPen ); - SelectObject( hdc, hOldBrush ); - DeleteObject( hBrush ); - DeleteObject( hPen ); - } - - return iRet; -} - -void HB_GT_FUNC( gt_gfxText( int iTop, int iLeft, char *cBuf, int iColor, int iSize, int iWidth ) ) -{ - HB_SYMBOL_UNUSED( iTop ); - HB_SYMBOL_UNUSED( iLeft ); - HB_SYMBOL_UNUSED( cBuf ); - HB_SYMBOL_UNUSED( iColor ); - HB_SYMBOL_UNUSED( iSize ); - HB_SYMBOL_UNUSED( iWidth ); -} - -//----------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_Redraw( int iRow, int iCol, int iSize ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gtRedraw(%d, %d, %d)", iRow, iCol, iSize ) ); - - if ( _s.hWnd ) - { - RECT rect; - - rect.top = rect.bottom = ( SHORT ) iRow; - rect.left = ( SHORT ) iCol; - rect.right = ( SHORT ) ( iCol + iSize - 1 ); - - rect = hb_wvt_gtGetXYFromColRowRect( rect ); - - InvalidateRect( _s.hWnd, &rect, FALSE ); - } -} - -//----------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_Refresh( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gtRefresh()") ); - - HB_GTSUPER_REFRESH(); - - if ( _s.hWnd ) - { - SendMessage( _s.hWnd, WM_MY_UPDATE_CARET, 0, 0 ); - hb_wvt_gtProcessMessages(); - } -} - -//----------------------------------------------------------------------// - -static BOOL HB_GT_FUNC( gt_SetDispCP( char * pszTermCDP, char * pszHostCDP, BOOL fBox ) ) -{ - - HB_GTSUPER_SETDISPCP( pszTermCDP, pszHostCDP, fBox ); - -#ifndef HB_CDP_SUPPORT_OFF - /* - * 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 ) - { - if( hb_cdp_page ) - pszHostCDP = hb_cdp_page->id; - else if( pszTermCDP && *pszTermCDP ) - pszHostCDP = pszTermCDP; - } - if( pszHostCDP && *pszHostCDP ) - { - PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP ); - if( cdpHost ) - _s.hostCDP = cdpHost; - } -#endif - - return TRUE; -} - -//----------------------------------------------------------------------// - -static BOOL HB_GT_FUNC( gt_SetKeyCP( char * pszTermCDP, char * pszHostCDP ) ) -{ - HB_GTSUPER_SETKEYCP( pszTermCDP, pszHostCDP ); - -#ifndef HB_CDP_SUPPORT_OFF - /* - * 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 ) - { - if( hb_cdp_page ) - pszHostCDP = hb_cdp_page->id; - else if( pszTermCDP && *pszTermCDP ) - pszHostCDP = pszTermCDP; - } - if( pszHostCDP && *pszHostCDP ) - { - PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP ); - if( cdpHost ) - _s.inCDP = cdpHost; - } -#endif - - return TRUE; -} - -//-------------------------------------------------------------------// - -#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__) -static int hb_Inp9x( USHORT usPort ) -{ - USHORT usVal; - - HB_TRACE( HB_TR_DEBUG, ( "hb_Inp9x( %hu )", usPort ) ); - - #if defined( __BORLANDC__ ) || defined(__DMC__) - - _DX = usPort; - __emit__( 0xEC ); /* ASM IN AL, DX */ - __emit__( 0x32,0xE4 ); /* ASM XOR AH, AH */ - usVal = _AX; - - #elif defined( __XCC__ ) - __asm { - mov dx, usPort - xor ax, ax - in al, dx - mov usVal, ax - } - - #elif defined( __MINGW32__ ) -// __asm__ __volatile__ ("inb %w1,%b0":"=a" (usVal):"Nd" (usPort)); - - #elif defined( __WATCOMC__ ) - usVal = inp( usPort ); - - #else - usVal = _inp( usPort ); - - #endif - - return( usVal ); -} - -//----------------------------------------------------------------------// - -static int hb_Outp9x( USHORT usPort, USHORT usVal ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_Outp9x( %hu, %hu )", usPort, usVal ) ); - - #if defined( __BORLANDC__ ) || defined(__DMC__) - - _DX = usPort; - _AL = usVal; - __emit__( 0xEE ); /* ASM OUT DX, AL */ - - #elif defined( __XCC__ ) - __asm { - mov dx, usPort - mov ax, usVal - out dx, al - } - - #elif defined( __MINGW32__ ) -// __asm__ __volatile__ ("outb %b0,%w1": :"a" (usVal), "Nd" (usPort)); - - #elif defined( __WATCOMC__ ) - outp( usPort, usVal ); - - #else - _outp( usPort, usVal ); - - #endif - - return( usVal ); -} - -//----------------------------------------------------------------------// - -static void HB_GT_FUNC(gt_w9xTone( double dFreq, double dDurat )) -{ - INT uLSB,uMSB; - ULONG lAdjFreq; - - HB_TRACE( HB_TR_DEBUG, ("hb_gt_w9xtone(%lf, %lf)", dFreq, dDurat ) ); - - /* sync with internal clock with very small time period */ - hb_idleSleep( 0.01 ); - - /* Clipper ignores Tone() requests (but delays anyway) if Frequency is - less than < 20 hz (and so should we) to maintain compatibility .. */ - - if ( dFreq >= 20.0 ) - { - /* Setup Sound Control Port Registers and timer channel 2 */ - hb_Outp9x( 67, 182 ) ; - - lAdjFreq = ( ULONG ) ( 1193180 / dFreq ) ; - - if( ( LONG ) lAdjFreq < 0 ) - uLSB = lAdjFreq + 65536; - else - uLSB = lAdjFreq % 256; - - if( ( LONG ) lAdjFreq < 0 ) - uMSB = lAdjFreq + 65536; - else - uMSB = lAdjFreq / 256; - - - /* set the frequency (LSB,MSB) */ - - hb_Outp9x( 66, uLSB ); - hb_Outp9x( 66, uMSB ); - - /* Get current Port setting */ - /* enable Speaker Data & Timer gate bits */ - /* (00000011B is bitmask to enable sound) */ - /* Turn on Speaker - sound Tone for duration.. */ - - hb_Outp9x( 97, hb_Inp9x( 97 ) | 3 ); - - hb_idleSleep( dDurat ); - - /* Read back current Port value for Reset */ - /* disable Speaker Data & Timer gate bits */ - /* (11111100B is bitmask to disable sound) */ - /* Turn off the Speaker ! */ - - hb_Outp9x( 97, hb_Inp9x( 97 ) & 0xFC ); - - } - else - { - hb_idleSleep( dDurat ); - } -} -#endif - -//-------------------------------------------------------------------// -// -/* dDurat is in seconds */ -// -static void HB_GT_FUNC( gt_wNtTone( double dFreq, double dDurat ) ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_gt_wNtTone(%lf, %lf)", dFreq, dDurat ) ); - - /* Clipper ignores Tone() requests (but delays anyway) if Frequency is - less than < 20 hz. Windows NT minimum is 37... */ - - /* sync with internal clock with very small time period */ - hb_idleSleep( 0.01 ); - - if ( dFreq >= 37.0 ) - { - Beep( (ULONG) dFreq, (ULONG) ( dDurat * 1000 ) ); /* Beep wants Milliseconds */ - } - else - { - hb_idleSleep( dDurat ); - } -} - -//-------------------------------------------------------------------// -// -/* dDuration is in 'Ticks' (18.2 per second) */ -// -void HB_GT_FUNC( gt_Tone( double dFrequency, double dDuration ) ) -{ - OSVERSIONINFO osv; - - HB_TRACE(HB_TR_DEBUG, ("hb_gt_Tone(%lf, %lf)", dFrequency, dDuration)); - - /* - According to the Clipper NG, the duration in 'ticks' is truncated to the - interger portion ... Depending on the platform, xHarbour allows a finer - resolution, but the minimum is 1 tick (for compatibility) - */ - /* Convert from ticks to seconds */ - dDuration = ( HB_MIN( HB_MAX( 1.0, dDuration ), ULONG_MAX ) ) / 18.2; - - /* keep the frequency in an acceptable range */ - dFrequency = HB_MIN( HB_MAX( 0.0, dFrequency ), 32767.0 ); - - /* What version of Windows are you running? */ - osv.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); - GetVersionEx( &osv ); - - /* If Windows 95 or 98, use w9xTone for BCC32, MSVC */ - if ( osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) - { - #if defined( __BORLANDC__ ) || defined( _MSC_VER ) || defined( __WATCOMC__ ) || defined(__MINGW32__) - HB_GT_FUNC( gt_w9xTone( dFrequency, dDuration ) ); - #else - HB_GT_FUNC( gt_wNtTone( dFrequency, dDuration ) ); - #endif - } - - /* If Windows NT or NT2k, use wNtTone, which provides TONE() - reset sequence support (new) */ - else if ( osv.dwPlatformId == VER_PLATFORM_WIN32_NT ) - { - HB_GT_FUNC( gt_wNtTone( dFrequency, dDuration ) ); - } -} - -//----------------------------------------------------------------------// -//----------------------------------------------------------------------// - -static BOOL HB_GT_FUNC( gt_mouse_IsPresent( void ) ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_gtmouse_IsPresent()")); - - return TRUE; -} - -//----------------------------------------------------------------------// - -static void HB_GT_FUNC( gt_mouse_GetPos( int * piRow, int * piCol ) ) -{ - HB_TRACE(HB_TR_DEBUG, ("hb_gtmouse_GetPos(%p,%p)", piRow, piCol)); - - *piRow = _s.mousePos.y; - *piCol = _s.mousePos.x; -} - -//----------------------------------------------------------------------// - -static BOOL HB_GT_FUNC( gt_mouse_ButtonState( int iButton ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gtmouse_ButtonState(%i)", iButton ) ); - - 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_FUNC( gt_mouse_CountButton( void ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gtmouse_CountButton()") ); - return( GetSystemMetrics( SM_CMOUSEBUTTONS ) ) ; -} - -//----------------------------------------------------------------------// -/* -void HB_GT_FUNC( mouse_Init( void ) ) -{ - hb_wvt_gtSetMouseX( 0 ); - hb_wvt_gtSetMouseY( 0 ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( mouse_Exit( void ) ) -{ -} - -//-------------------------------------------------------------------// - -BOOL HB_GT_FUNC( mouse_IsPresent( void ) ) -{ - return( TRUE ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( mouse_Show( void ) ) -{ -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( mouse_Hide( void ) ) -{ -} - -//-------------------------------------------------------------------// - -int HB_GT_FUNC( mouse_Col( void ) ) -{ - return( hb_wvt_gtGetMouseX() ); -} - -//-------------------------------------------------------------------// - -int HB_GT_FUNC( mouse_Row( void ) ) -{ - return( hb_wvt_gtGetMouseY() ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( mouse_SetPos( int iRow, int iCol ) ) -{ - hb_wvt_gtSetMouseY( iRow ); - hb_wvt_gtSetMouseX( iCol ); -} - -//-------------------------------------------------------------------// - -BOOL HB_GT_FUNC( mouse_IsButtonPressed( int iButton ) ) -{ - BOOL bReturn = FALSE; - - if ( iButton == 0 ) - { - bReturn = GetKeyState( VK_LBUTTON ) & 0x8000; - } - else if ( iButton== 1 ) - { - bReturn = GetKeyState( VK_RBUTTON ) & 0x8000; - } - else if ( iButton == 2 ) - { - bReturn = GetKeyState( VK_MBUTTON ) & 0x8000; - } - - return( bReturn ); -} - -//-------------------------------------------------------------------// - -int HB_GT_FUNC( mouse_CountButton( void ) ) -{ - return( GetSystemMetrics( SM_CMOUSEBUTTONS ) ) ; -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( mouse_SetBounds( int iTop, int iLeft, int iBottom, int iRight ) ) -{ - HB_SYMBOL_UNUSED( iTop ); - HB_SYMBOL_UNUSED( iLeft ); - HB_SYMBOL_UNUSED( iBottom ); - HB_SYMBOL_UNUSED( iRight ); -} - -//-------------------------------------------------------------------// - -void HB_GT_FUNC( mouse_GetBounds( int * piTop, int * piLeft, int * piBottom, int * piRight ) ) -{ - HB_SYMBOL_UNUSED( piTop ); - HB_SYMBOL_UNUSED( piLeft ); - HB_SYMBOL_UNUSED( piBottom ); - HB_SYMBOL_UNUSED( piRight ); -} -*/ - -//----------------------------------------------------------------------// - -static BOOL hb_gt_FuncInit( PHB_GT_FUNCS gt_funcs ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_gtFnInit( %p )", gt_funcs ) ); - - gt_funcs->Init = HB_GT_FUNC( gt_Init ); - //gt_funcs->AdjustPos = HB_GT_FUNC( gt_AdjustPos ); - //gt_funcs->Col = HB_GT_FUNC( gt_Col ); - gt_funcs->Box = HB_GT_FUNC( gt_Box ); - gt_funcs->BoxD = HB_GT_FUNC( gt_BoxD ); - gt_funcs->BoxS = HB_GT_FUNC( gt_BoxS ); - gt_funcs->DispBegin = HB_GT_FUNC( gt_DispBegin ); - gt_funcs->DispEnd = HB_GT_FUNC( gt_DispEnd ); - gt_funcs->DispCount = HB_GT_FUNC( gt_DispCount ); - gt_funcs->Exit = HB_GT_FUNC( gt_Exit ); - //gt_funcs->ExtendedKeySupport = HB_GT_FUNC( gt_ExtendedKeySupport ); - gt_funcs->GetBlink = HB_GT_FUNC( gt_GetBlink ); - //gt_funcs->GetClipboard = HB_GT_FUNC( gt_GetClipboard ); - //gt_funcs->GetClipboardSize = HB_GT_FUNC( gt_GetClipboardSize ); - gt_funcs->GetCursorStyle = HB_GT_FUNC( gt_GetCursorStyle ); - // PART OF GT BUT UNDEFINED // - gt_funcs->GetPos = HB_GT_FUNC( gt_GetPos ); - //gt_funcs->GetScreenWidth = HB_GT_FUNC( gt_GetScreenWidth ); - //gt_funcs->GetScreenHeight = HB_GT_FUNC( gt_GetScreenHeight ); - gt_funcs->MaxCol = HB_GT_FUNC( gt_MaxCol ); - gt_funcs->MaxRow = HB_GT_FUNC( gt_MaxRow ); - //gt_funcs->GetText = HB_GT_FUNC( gt_GetText ); - gt_funcs->HorizLine = HB_GT_FUNC( gt_HorizLine ); - gt_funcs->Info = HB_GT_FUNC( gt_Info ); - gt_funcs->IsColor = HB_GT_FUNC( gt_IsColor ); - gt_funcs->OutStd = HB_GT_FUNC( gt_OutStd ); - gt_funcs->OutErr = HB_GT_FUNC( gt_OutErr ); - gt_funcs->PostExt = HB_GT_FUNC( gt_PostExt ); - gt_funcs->PreExt = HB_GT_FUNC( gt_PreExt ); - //gt_funcs->ProcessMessages = HB_GT_FUNC( gt_ProcessMessages ); - //gt_funcs->Puts = HB_GT_FUNC( gt_Puts ); - //gt_funcs->PutChar = HB_GT_FUNC( gt_Puts ); - gt_funcs->PutText = HB_GT_FUNC( gt_PutText ); - gt_funcs->Redraw = HB_GT_FUNC( gt_Redraw ); // + - //gt_funcs->Refresh = HB_GT_FUNC( gt_Refresh ); // + - gt_funcs->ReadKey = HB_GT_FUNC( gt_ReadKey ); - gt_funcs->Rest = HB_GT_FUNC( gt_xPutText ); - gt_funcs->Resume = HB_GT_FUNC( gt_Resume ); - //gt_funcs->Replicate = HB_GT_FUNC( gt_Replicate ); - //gt_funcs->RectSize = HB_GT_FUNC( gt_RectSize ); - //gt_funcs->Row = HB_GT_FUNC( gt_Row ); - gt_funcs->Save = HB_GT_FUNC( gt_GetText ); - gt_funcs->SetAttribute = HB_GT_FUNC( gt_SetAttribute ); - gt_funcs->SetBlink = HB_GT_FUNC( gt_SetBlink ); - //gt_funcs->SetClipboard = HB_GT_FUNC( gt_SetClipboard ); - gt_funcs->SetCursorStyle = HB_GT_FUNC( gt_SetCursorStyle ); - gt_funcs->SetMode = HB_GT_FUNC( gt_SetMode ); - gt_funcs->SetPos = HB_GT_FUNC( gt_SetPos ); - gt_funcs->Scroll = HB_GT_FUNC( gt_Scroll ); - gt_funcs->Suspend = HB_GT_FUNC( gt_Suspend ); - gt_funcs->Tone = HB_GT_FUNC( gt_Tone ); - gt_funcs->Version = HB_GT_FUNC( gt_Version ); - gt_funcs->VertLine = HB_GT_FUNC( gt_VertLine ); - - gt_funcs->SetDispCP = HB_GT_FUNC( gt_SetDispCP ); - gt_funcs->SetKeyCP = HB_GT_FUNC( gt_SetKeyCP ); - - /* Graphics API */ - //gt_funcs->gfxPrimitive = HB_GT_FUNC( gt_gfxPrimitive ); - - gt_funcs->MouseIsPresent = HB_GT_FUNC( gt_mouse_IsPresent ); - gt_funcs->MouseGetPos = HB_GT_FUNC( gt_mouse_GetPos ); - gt_funcs->MouseButtonState = HB_GT_FUNC( gt_mouse_ButtonState ); - gt_funcs->MouseCountButton = HB_GT_FUNC( gt_mouse_CountButton ); - - return TRUE; -} - -//-------------------------------------------------------------------// -/* -static void HB_GT_FUNC( mouseFnInit( PHB_GT_FUNCS gt_funcs ) ) -{ - HB_TRACE( HB_TR_DEBUG, ( "hb_mouseFnInit( %p )", gt_funcs ) ); - - gt_funcs->mouse_Init = HB_GT_FUNC( mouse_Init ); - gt_funcs->mouse_Exit = HB_GT_FUNC( mouse_Exit ); - gt_funcs->mouse_IsPresent = HB_GT_FUNC( mouse_IsPresent ); - gt_funcs->mouse_Show = HB_GT_FUNC( mouse_Show ); - gt_funcs->mouse_Hide = HB_GT_FUNC( mouse_Hide ); - gt_funcs->mouse_Col = HB_GT_FUNC( mouse_Col ); - gt_funcs->mouse_Row = HB_GT_FUNC( mouse_Row ); - gt_funcs->mouse_SetPos = HB_GT_FUNC( mouse_SetPos ); - gt_funcs->mouse_IsButtonPressed = HB_GT_FUNC( mouse_IsButtonPressed ); - gt_funcs->mouse_CountButton = HB_GT_FUNC( mouse_CountButton ); - gt_funcs->mouse_SetBounds = HB_GT_FUNC( mouse_SetBounds ); - gt_funcs->mouse_GetBounds = HB_GT_FUNC( mouse_GetBounds ); -} -*/ -//-------------------------------------------------------------------// - -static HB_GT_INIT gtInit = { HB_GT_DRVNAME( HB_GT_NAME ), - hb_gt_FuncInit, - HB_GTSUPER }; - -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 _MSC_VER >= 1010 - #pragma data_seg( ".CRT$XIY" ) - #pragma comment( linker, "/Merge:.CRT=.data" ) - #else - #pragma data_seg( "XIY" ) - #endif - static HB_$INITSYM hb_vm_auto__hb_startup_gt_Init_ = _hb_startup_gt_Init_; - #pragma data_seg() -#endif - -//-------------------------------------------------------------------// - +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Video subsystem for Win32 using GUI windows instead of Console + * Copyright 2003 Peter Rees + * Rees Software & Systems Ltd + * based on + * Bcc ConIO Video subsystem by + * Copyright 2002 Marek Paliwoda + * Copyright 2002 Przemyslaw Czerpak + * Video subsystem for Win32 compilers + * Copyright 1999-2000 Paul Tucker + * Copyright 2002 Przemysław Czerpak + * + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * + * Copyright 1999 David G. Holm + * hb_gt_Tone() + * + * See doc/license.txt for licensing terms. + * + * www - 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. + * + */ + +//-------------------------------------------------------------------// +/* +* Individual authors: +* (C) 2003-2004 Giancarlo Niccolai +* Standard xplatform GT Info system, +* Graphical object system and event system. +* GTINFO() And GTO_* implementation. +* +* (C) 2004 Mauricio Abre +* Cross-GT, multiplatform Graphics API +* +*/ +//-------------------------------------------------------------------// + +#define HB_OS_WIN_32_USED + +#ifndef _WIN32_IE + #define _WIN32_IE 0x0400 +#endif + +#include "gtwvt.h" + +static HB_GT_FUNCS SuperTable; +#define HB_GTSUPER (&SuperTable) + +#if defined(__WATCOMC__) + #include +#endif + +#ifndef WM_MOUSEWHEEL + #define WM_MOUSEWHEEL 0x020A +#endif + +#ifndef INVALID_FILE_SIZE + #define INVALID_FILE_SIZE (DWORD)0xFFFFFFFF +#endif + +#ifndef CC_ANYCOLOR + #define CC_ANYCOLOR 0x00000100 +#endif + +#ifndef IDC_HAND + #define IDC_HAND MAKEINTRESOURCE(32649) +#endif + +//----------------------------------------------------------------------// + +static TCHAR szAppName[] = TEXT( "Harbour WVT" ); + +static GLOBAL_DATA _s; + +static COLORREF _COLORS[] = { + BLACK, + BLUE, + GREEN, + CYAN, + RED, + MAGENTA, + BROWN, + WHITE, + LIGHT_GRAY, + BRIGHT_BLUE, + BRIGHT_GREEN, + BRIGHT_CYAN, + BRIGHT_RED, + BRIGHT_MAGENTA, + YELLOW, + BRIGHT_WHITE +}; + +#ifdef WVT_DEBUG +static int nCountPuts=0,nCountScroll=0, nCountPaint=0, nSetFocus=0, nKillFocus=0; +#endif + +static int K_Ctrl[] = { + K_CTRL_A, K_CTRL_B, K_CTRL_C, K_CTRL_D, K_CTRL_E, K_CTRL_F, K_CTRL_G, K_CTRL_H, + K_CTRL_I, K_CTRL_J, K_CTRL_K, K_CTRL_L, K_CTRL_M, K_CTRL_N, K_CTRL_O, K_CTRL_P, + K_CTRL_Q, K_CTRL_R, K_CTRL_S, K_CTRL_T, K_CTRL_U, K_CTRL_V, K_CTRL_W, K_CTRL_X, + K_CTRL_Y, K_CTRL_Z + }; + +//static buffer[100]; + +//-------------------------------------------------------------------// +// +// private functions declaration +// +//HB_EXTERN_BEGIN +static void gt_hbInitStatics( void ); +static HWND hb_wvt_gtCreateWindow( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow ); +static BOOL hb_wvt_gtInitWindow( HWND hWnd, USHORT col, USHORT row ); +static void hb_wvt_gtResetWindowSize( HWND hWnd ); +static LRESULT CALLBACK hb_wvt_gtWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); +static BOOL hb_wvt_gtAllocSpBuffer( USHORT col, USHORT row ); +static DWORD hb_wvt_gtProcessMessages( void ); +static BOOL hb_wvt_gtValidWindowSize( int rows, int cols, HFONT hFont, int width ); +static void hb_wvt_gtSetCaretOn( BOOL bOn ); +static BOOL hb_wvt_gtSetCaretPos( void ); +static void hb_wvt_gtValidateCaret( void ); +static void hb_wvt_gtUpdateCaret( void ); + +static USHORT hb_wvt_gtGetMouseX( void ); +static USHORT hb_wvt_gtGetMouseY( void ); +static void hb_wvt_gtSetMouseX( USHORT ix ); +static void hb_wvt_gtSetMouseY( USHORT iy ); +static BOOL hb_wvt_gtGetCharFromInputQueue( int * c ); + +static void hb_wvt_gtTranslateKey( int key, int shiftkey, int altkey, int controlkey ); + +static void hb_wvt_gtSetInvalidRect( USHORT left, USHORT top, USHORT right, USHORT bottom ); +static void hb_wvt_gtDoInvalidateRect( void ); + +static void hb_wvt_gtHandleMenuSelection( int ); + +static POINT hb_wvt_gtGetColRowFromXY( USHORT x, USHORT y ); +static RECT hb_wvt_gtGetColRowFromXYRect( RECT xy ); +static POINT hb_wvt_gtGetColRowForTextBuffer( USHORT index ); + +static void hb_wvt_gtValidateCol( void ); +static void hb_wvt_gtValidateRow( void ); + +static USHORT hb_wvt_gtCalcPixelHeight( void ); +static USHORT hb_wvt_gtCalcPixelWidth( void ); +static BOOL hb_wvt_gtSetColors( HDC hdc, BYTE attr ); +static HFONT hb_wvt_gtGetFont( char * pszFace, int iHeight, int iWidth, int iWeight, int iQuality, int iCodePage ); + +static BOOL hb_wvt_gtTextOut( HDC hdc, USHORT col, USHORT row, LPCTSTR lpString, USHORT cbString ); +static void hb_wvt_gtSetStringInTextBuffer( USHORT col, USHORT row, BYTE attr, BYTE *sBuffer, USHORT length ); +static USHORT hb_wvt_gtGetIndexForTextBuffer( USHORT col, USHORT row ); +static RECT hb_wvt_gtGetXYFromColRowRect( RECT colrow ); +static void hb_wvt_gtCreateObjects( void ); +static void hb_wvt_gtKillCaret( void ); +static void hb_wvt_gtCreateCaret( void ); +static void hb_wvt_gtMouseEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); +static void hb_wvt_gtCreateToolTipWindow( void ); +static void hb_wvt_gtRestGuiState( LPRECT rect ); +static void hb_wvt_gtInitGui( void ); +static void hb_wvt_gtPaintText( HWND hWnd, RECT rect ); +static BOOL hb_wvt_gtKeyEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); + +static void HB_GT_FUNC( gt_Init( FHANDLE iFilenoStdin, FHANDLE iFilenoStdout, FHANDLE iFilenoStderr ) ); +static void HB_GT_FUNC( gt_Exit( void ) ); +//static void HB_GT_FUNC( gt_ProcessMessages( void ) ); +static void HB_GT_FUNC( gt_GetClipboard( char *szData, ULONG *pulMaxSize ) ); +static void HB_GT_FUNC( gt_SetClipboard( char *szData, ULONG ulSize ) ); +//static ULONG HB_GT_FUNC( gt_GetClipboardSize( void ) ); +//static USHORT HB_GT_FUNC( gt_GetScreenWidth( void ) ); +//static USHORT HB_GT_FUNC( gt_GetScreenHeight( void ) ); +static SHORT HB_GT_FUNC( gt_Col( void ) ); +static SHORT HB_GT_FUNC( gt_Row( void ) ); +static void HB_GT_FUNC( gt_SetPos( int sRow, int sCol ) ); +static void HB_GT_FUNC( gt_GetPos( int * sRow, int * sCol ) ); +//static BOOL HB_GT_FUNC( gt_AdjustPos( BYTE * pStr, ULONG ulLen ) ); +static BOOL HB_GT_FUNC( gt_IsColor( void ) ); + +static void HB_GT_FUNC( gt_DispEnd( void ) ); +static int HB_GT_FUNC( gt_DispCount( void ) ); +static void HB_GT_FUNC( gt_DispBegin( void ) ); +static void HB_GT_FUNC( gt_GetPos( int * sRow, int * sCol ) ); +static void HB_GT_FUNC( gt_Box( int Top, int Left, int Bottom, int Right, BYTE * szBox, BYTE byAttr ) ); +static void HB_GT_FUNC( gt_BoxD( int Top, int Left, int Bottom, int Right, BYTE * pbyFrame, BYTE byAttr ) ); +static void HB_GT_FUNC( gt_BoxS( int Top, int Left, int Bottom, int Right, BYTE * pbyFrame, BYTE byAttr ) ); +static void HB_GT_FUNC( gt_HorizLine( int Row, int Left, int Right, BYTE byChar, BYTE byAttr ) ); +static void HB_GT_FUNC( gt_VertLine( int Col, int Top, int Bottom, BYTE byChar, BYTE byAttr ) ); +static int HB_GT_FUNC( gt_GetCursorStyle( void ) ); +static void HB_GT_FUNC( gt_SetCursorStyle( int usStyle ) ); +static void HB_GT_FUNC( gt_PutText( int top, int left, BYTE bColor, BYTE * pText, ULONG ulLen ) ); +static void HB_GT_FUNC( gt_xPutText( int top, int left, int bottom, int right, BYTE * sBuffer ) ); +static void HB_GT_FUNC( gt_GetText( int top, int left, int bottom, int right, BYTE * sBuffer ) ); +static void HB_GT_FUNC( gt_SetAttribute( int rowStart, int colStart, int rowStop, int colStop, BYTE attr ) ); +static BOOL HB_GT_FUNC( gt_SetMode( int row, int col ) ); +static void HB_GT_FUNC( gt_Scroll( int usTop, int usLeft, int usBottom, int usRight, BYTE byAttr, BYTE byChar, int iRows, int iCols ) ); +static BOOL HB_GT_FUNC( gt_Info( int iType, PHB_GT_INFO pInfo ) ); +static int HB_GT_FUNC( gt_MaxCol( void ) ); +static int HB_GT_FUNC( gt_MaxRow( void ) ); +static BOOL HB_GT_FUNC( gt_SetDispCP( char * pszTermCDP, char * pszHostCDP, BOOL fBox ) ); +static BOOL HB_GT_FUNC( gt_SetKeyCP( char * pszTermCDP, char * pszHostCDP ) ); + +static void HB_GT_FUNC( gt_Replicate( USHORT usRow, USHORT usCol, BYTE byAttr, BYTE byChar, ULONG ulLen ) ); +//static int HB_GT_FUNC( gt_RectSize( USHORT rows, USHORT cols ) ); +static void HB_GT_FUNC( gt_Puts( USHORT usRow, USHORT usCol, BYTE byAttr, BYTE *pbyStr, ULONG ulLen ) ); +static void HB_GT_FUNC( gt_xPutch( USHORT iRow, USHORT iCol, BYTE bAttr, BYTE bChar ) ); +static char * HB_GT_FUNC( gt_Version( int iType ) ); +//static void HB_GT_FUNC( gt_SetAttributeCT( USHORT rowStart, USHORT colStart, USHORT rowStop, USHORT colStop, BYTE attr ) ); +static void HB_GT_FUNC( gt_SetBlink( BOOL bBlink ) ); +static BOOL HB_GT_FUNC( gt_GetBlink( void ) ); + +//-------------------------------------------------------------------// +// +// mouse initialization was made in cmdarg.c +// + +// set in mainwin.c +// +extern HANDLE hb_hInstance; +extern HANDLE hb_hPrevInstance; +static int hb_iCmdShow = SW_NORMAL; + +static int s_uiDispCount = 0; +static int s_usCursorStyle; +static int s_usOldCurStyle; + +static int s_iStdIn, s_iStdOut, s_iStdErr; + +static BOOL b_MouseEnable = TRUE; + +#define _GetScreenHeight() (_s.ROWS) +#define _GetScreenWidth() (_s.COLS) + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// WVT specific functions +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Modeless Dialogs Implementation +// +//-------------------------------------------------------------------// + +HB_EXPORT BOOL CALLBACK hb_wvt_gtDlgProcMLess( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) +{ + int iIndex, iType; + long int bReturn = FALSE ; + PHB_ITEM pFunc = NULL; + PHB_DYNS pDynSym; + + iType = (int) NULL; + + for ( iIndex = 0; iIndex < WVT_DLGML_MAX; iIndex++ ) + { + if ( ( _s.hDlgModeless[ iIndex ] != NULL ) && ( _s.hDlgModeless[ iIndex ] == hDlg ) ) + { + if ( _s.pFunc[ iIndex ] != NULL ) + { + pFunc = _s.pFunc[ iIndex ]; + iType = _s.iType[ iIndex ]; + } + break; + } + } + + if ( pFunc ) + { + switch ( iType ) + { + case 1: // Function Name + { + pDynSym = ( PHB_DYNS ) pFunc; + hb_vmPushState(); + hb_vmPushSymbol( hb_dynsymSymbol( pDynSym ) ); + hb_vmPushNil(); + hb_vmPushLong( ( ULONG ) hDlg ); + hb_vmPushLong( ( UINT ) message ); + hb_vmPushLong( ( ULONG ) wParam ); + hb_vmPushLong( ( ULONG ) lParam ); + hb_vmDo( 4 ); + //bReturn = hb_itemGetNL( hb_stackReturnItem() ); + bReturn = hb_parnl( -1 ); + + hb_vmPopState(); + break; + } + + case 2: // Block + { + /* eval the codeblock */ + //if ( _s.pFunc[ iIndex ]->type == HB_IT_BLOCK ) + if ( hb_itemType( _s.pFunc[ iIndex ] ) == HB_IT_BLOCK ) + { + PHB_ITEM hihDlg, himessage, hiwParam, hilParam; + PHB_ITEM pReturn; + + //hihDlg.type = HB_IT_NIL; + hb_itemPutNL( &hihDlg, (ULONG) hDlg ); + + //himessage.type = HB_IT_NIL; + hb_itemPutNL( &himessage, (ULONG) message ); + + //hiwParam.type = HB_IT_NIL; + hb_itemPutNL( &hiwParam, (ULONG) wParam ); + + //hilParam.type = HB_IT_NIL; + hb_itemPutNL( &hilParam, (ULONG) lParam ); + + pReturn = hb_itemDo( (PHB_ITEM) _s.pFunc[ iIndex ], 4, &hihDlg, &himessage, &hiwParam, &hilParam ); + bReturn = hb_itemGetNL( pReturn ); + hb_itemRelease( pReturn ); + } + else + { + //internal error: missing codeblock + } + + + break; + } + } + } + + switch( message ) + { + case WM_COMMAND: + { + switch( LOWORD( wParam ) ) + { + case IDOK: + { + DestroyWindow( hDlg ); + bReturn = TRUE; + } + break; + + case IDCANCEL: + { + DestroyWindow( hDlg ); + bReturn = FALSE; + } + break; + } + } + break; + + case WM_CLOSE: + { + DestroyWindow( hDlg ); + bReturn = FALSE; + } + break; + + case WM_NCDESTROY: + { + if ( _s.pFunc[ iIndex ] != NULL && _s.iType[ iIndex ] == 2 ) + { + hb_itemRelease( ( PHB_ITEM ) _s.pFunc[ iIndex ] ); + } + _s.hDlgModeless[ iIndex ] = NULL; + _s.pFunc[ iIndex ] = NULL; + _s.iType[ iIndex ] = (int) NULL; + bReturn = FALSE; + } + break; + } + + return bReturn; +} + +//-------------------------------------------------------------------// + +HB_EXPORT BOOL CALLBACK hb_wvt_gtDlgProcModal( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) +{ + int iIndex, iType; + long int bReturn = FALSE ; + PHB_ITEM pFunc = NULL; + PHB_DYNS pDynSym; + int iFirst = ( int ) lParam; + + if ( iFirst > 0 && iFirst <= WVT_DLGMD_MAX ) + { + _s.hDlgModal[ iFirst-1 ] = hDlg ; + SendMessage( hDlg, WM_INITDIALOG, 0, 0 ); + return ( bReturn ); + } + + iType = ( int ) NULL; + + for ( iIndex = 0; iIndex < WVT_DLGMD_MAX; iIndex++ ) + { + if ( ( _s.hDlgModal[ iIndex ] != NULL ) && ( _s.hDlgModal[ iIndex ] == hDlg ) ) + { + if ( _s.pFuncModal[ iIndex ] != NULL ) + { + pFunc = _s.pFuncModal[ iIndex ]; + iType = _s.iTypeModal[ iIndex ]; + } + break; + } + } + + if ( pFunc ) + { + switch ( iType ) + { + case 1: // Function Name + { + pDynSym = ( PHB_DYNS ) pFunc; + hb_vmPushState(); + hb_vmPushSymbol( hb_dynsymSymbol( pDynSym ) ); + + hb_vmPushNil(); + hb_vmPushLong( ( ULONG ) hDlg ); + hb_vmPushLong( ( UINT ) message ); + hb_vmPushLong( ( ULONG ) wParam ); + hb_vmPushLong( ( ULONG ) lParam ); + hb_vmDo( 4 ); + //bReturn = hb_itemGetNL( hb_stackReturnItem() ); + bReturn = hb_parnl( -1 ); + + hb_vmPopState(); + break; + } + + case 2: // Block + { + /* eval the codeblock */ + if ( hb_itemType( _s.pFuncModal[ iIndex ] ) == HB_IT_BLOCK ) + { + PHB_ITEM hihDlg, himessage, hiwParam, hilParam; + PHB_ITEM pReturn; + + //hihDlg.type = HB_IT_NIL; + hb_itemPutNL( &hihDlg, (ULONG) hDlg ); + + //himessage.type = HB_IT_NIL; + hb_itemPutNL( &himessage, (ULONG) message ); + + //hiwParam.type = HB_IT_NIL; + hb_itemPutNL( &hiwParam, (ULONG) wParam ); + + //hilParam.type = HB_IT_NIL; + hb_itemPutNL( &hilParam, (ULONG) lParam ); + + pReturn = hb_itemDo( (PHB_ITEM) _s.pFuncModal[ iIndex ], 4, &hihDlg, &himessage, &hiwParam, &hilParam ); + bReturn = hb_itemGetNL( pReturn ); + hb_itemRelease( pReturn ); + } + else + { + //internal error: missing codeblock + } + + break; + } + } + } + + switch( message ) + { + case WM_COMMAND: + { + switch( LOWORD( wParam ) ) + { + case IDOK: + { + EndDialog( hDlg, IDOK ); + bReturn = TRUE; + } + break; + + case IDCANCEL: + { + EndDialog( hDlg, IDCANCEL ); + bReturn = FALSE; + } + break; + } + } + break; + + case WM_CLOSE: + { + EndDialog( hDlg, IDCANCEL ); + bReturn = FALSE; + } + break; + + case WM_NCDESTROY: + { + if ( _s.pFuncModal[ iIndex ] != NULL && _s.iTypeModal[ iIndex ] == 2 ) + { + hb_itemRelease( ( PHB_ITEM ) _s.pFuncModal[ iIndex ] ); + } + + _s.hDlgModal[ iIndex ] = NULL; + _s.pFuncModal[ iIndex ] = NULL; + _s.iTypeModal[ iIndex ] = ( int ) NULL; + bReturn = FALSE; + } + break; + } + + return bReturn; +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtCreateObjects( void ) +{ + LOGBRUSH lb; + + _s.penWhite = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 255,255,255 ) ); + _s.penBlack = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 0, 0, 0 ) ); + _s.penWhiteDim = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 205,205,205 ) ); + _s.penDarkGray = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 150,150,150 ) ); + _s.penGray = CreatePen( PS_SOLID, 0, ( COLORREF ) _COLORS[ 7 ] ); + _s.penNull = CreatePen( PS_NULL , 0, ( COLORREF ) _COLORS[ 7 ] ); + + _s.currentPen = CreatePen( PS_SOLID, 0, ( COLORREF ) RGB( 0, 0, 0 ) ); + + lb.lbStyle = BS_NULL; + lb.lbColor = RGB( 198,198,198 ); + lb.lbHatch = 0; + _s.currentBrush = CreateBrushIndirect( &lb ); + + lb.lbStyle = BS_HATCHED; + lb.lbColor = RGB( 210,210,210 ); + lb.lbHatch = HS_DIAGCROSS; // HS_BDIAGONAL; + _s.diagonalBrush = CreateBrushIndirect( &lb ); + + lb.lbStyle = BS_SOLID; + lb.lbColor = 0; // NULL; // RGB( 0,0,0 ); + lb.lbHatch = 0; + _s.solidBrush = CreateBrushIndirect( &lb ); + + lb.lbStyle = BS_SOLID; + lb.lbColor = _COLORS[ 7 ]; + lb.lbHatch = 0; + _s.wvtWhiteBrush= CreateBrushIndirect( &lb ); + +} + +//-------------------------------------------------------------------// + +static USHORT hb_wvt_gtCalcPixelHeight( void ) +{ + return( (USHORT)( _s.PTEXTSIZE.y *_GetScreenHeight() ) ); +} + +//-------------------------------------------------------------------// + +static USHORT hb_wvt_gtCalcPixelWidth( void ) +{ + return( (USHORT)( _s.PTEXTSIZE.x * _GetScreenWidth() ) ); +} + +//-------------------------------------------------------------------// + +static BOOL hb_wvt_gtAllocSpBuffer( USHORT col, USHORT row ) /* NO */ +{ + BOOL bRet = TRUE; + + _s.COLS = col; + _s.ROWS = row; + _s.BUFFERSIZE = col * row * sizeof( char ); + _s.pBuffer = _s.byBuffer ; + _s.pAttributes = _s.byAttributes; + memset( _s.pBuffer, ' ', _s.BUFFERSIZE ); + memset( _s.pAttributes,_s.background, _s.BUFFERSIZE ); + + return( bRet ); +} + +//-------------------------------------------------------------------// + +static BOOL hb_wvt_gtInitWindow( HWND hWnd, USHORT col, USHORT row ) /* DIFF */ +{ + BOOL bRet = hb_wvt_gtAllocSpBuffer( col, row ); + + hb_wvt_gtResetWindowSize( hWnd ); + + return( bRet ); +} + +//-------------------------------------------------------------------// + +static BOOL hb_wvt_gtValidWindowSize( 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 = (SHORT) ( rcWorkArea.right - rcWorkArea.left ); + maxHeight = (SHORT) ( rcWorkArea.bottom - rcWorkArea.top ); + + hdc = GetDC( _s.hWnd ); + hOldFont = ( HFONT ) SelectObject( hdc, hFont ); + GetTextMetrics( hdc, &tm ); + SelectObject( hdc, hOldFont ); // Put old font back + ReleaseDC( _s.hWnd, hdc ); + + width = iWidth < 0 ? -iWidth : (USHORT)( tm.tmAveCharWidth * cols ) ; + height = (USHORT)( tm.tmHeight * rows ); + + return( ( width <= maxWidth ) && ( height <= maxHeight ) ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtResetWindowSize( HWND hWnd ) +{ + HDC hdc; + HFONT hFont, hOldFont ; + USHORT diffWidth, diffHeight; + USHORT height, width; + RECT wi, ci; + TEXTMETRIC tm; + // HMENU hMenu; + RECT rcWorkArea; + int n; + + // set the font and get it's size to determine the size of the client area + // for the required number of rows and columns + // + hdc = GetDC( hWnd ); + hFont = hb_wvt_gtGetFont( _s.fontFace, _s.fontHeight, _s.fontWidth, _s.fontWeight, _s.fontQuality, _s.CodePage ); + + if ( _s.hFont ) + { + DeleteObject( _s.hFont ); + } + + _s.hFont = hFont ; + hOldFont = ( HFONT ) SelectObject( hdc, hFont ); + //if ( hOldFont ) + //{ + // DeleteObject( hOldFont ); + //} + GetTextMetrics( hdc, &tm ); + SetTextCharacterExtra( hdc,0 ); // do not add extra char spacing even if bold + SelectObject( hdc, hOldFont ); + ReleaseDC( hWnd, hdc ); + + // 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! + // + + _s.PTEXTSIZE.x = _s.fontWidth<0 ? -_s.fontWidth : tm.tmAveCharWidth; // For fixed FONT should == tm.tmMaxCharWidth + _s.PTEXTSIZE.y = tm.tmHeight; // but seems to be a problem on Win9X so + // assume proportional fonts always for Win9X +#if defined(HB_WINCE) + _s.FixedFont = FALSE; +#else + if (_s.fontWidth < 0 || _s.Win9X || ( tm.tmPitchAndFamily & TMPF_FIXED_PITCH ) || ( _s.PTEXTSIZE.x != tm.tmMaxCharWidth ) ) + { + _s.FixedFont = FALSE; + } + else + { + _s.FixedFont = TRUE ; + } +#endif + + for( n = 0 ; n < _GetScreenWidth() ; n++ ) // _s.FixedSize[] is used by ExtTextOut() to emulate + { // fixed font when a proportional font is used + _s.FixedSize[ n ] = _s.PTEXTSIZE.x; + } + + // resize the window to get the specified number of rows and columns + // + height = hb_wvt_gtCalcPixelHeight(); + width = hb_wvt_gtCalcPixelWidth(); + + GetWindowRect( hWnd, &wi ); + GetClientRect( hWnd, &ci ); + + diffWidth = ( SHORT )( ( wi.right - wi.left ) - ( ci.right ) ); + diffHeight = ( SHORT )( ( wi.bottom - wi.top ) - ( ci.bottom ) ); + width += diffWidth ; + height += diffHeight; + + // Centre the window within the CLIENT area on the screen + // but only if _s.CentreWindow == TRUE + // + if ( _s.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( hWnd, NULL, wi.left, wi.top, width, height, SWP_NOZORDER ); + + if ( _s.bGui ) + { + hb_wvt_gtInitGui(); + } +} + +//-------------------------------------------------------------------// + +static int hb_wvt_key_ansi_to_oem( int c ) +{ + char pszAnsi[4]; + char pszOem[4]; + + sprintf( pszAnsi, "%c", c ); + CharToOemBuffA( ( LPCSTR ) pszAnsi, ( LPSTR ) pszOem, 1 ); + c = (BYTE) * pszOem; + + return c; +} + +//----------------------------------------------------------------------// + +static void hb_wvt_gtInitGui( void ) +{ + _s.iGuiWidth = _GetScreenWidth() * _s.PTEXTSIZE.x ; + _s.iGuiHeight = _GetScreenHeight() * _s.PTEXTSIZE.y ; + + if ( _s.hGuiDC ) + { + DeleteDC( _s.hGuiDC ); + } + _s.hGuiDC = CreateCompatibleDC( _s.hdc ); + + if ( _s.hGuiBmp ) + { + DeleteObject( _s.hGuiBmp ); + } + _s.hGuiBmp = CreateCompatibleBitmap( _s.hdc, _s.iGuiWidth, _s.iGuiHeight ); + + SelectObject( _s.hGuiDC, _s.hGuiBmp ); + SetTextCharacterExtra( _s.hGuiDC,0 ); + SelectObject( _s.hGuiDC, _s.hFont ); +} + +//-------------------------------------------------------------------// + +static LRESULT CALLBACK hb_wvt_gtWndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) +{ + BOOL bRet; + + switch ( message ) + { + case WM_CREATE: + { + bRet = hb_wvt_gtInitWindow( hWnd, WVT_DEFAULT_COLS, WVT_DEFAULT_ROWS ); + return( bRet ); + } + + case WM_COMMAND: + { + hb_wvt_gtHandleMenuSelection( ( int ) LOWORD( wParam ) ); + return( 0 ); + } + + case WM_PAINT: + { + RECT updateRect; + /* WARNING!!! + * the GetUpdateRect call MUST be made BEFORE the BeginPaint call, since + * BeginPaint resets the update rectangle - don't move it or nothing is drawn! + */ + if ( GetUpdateRect( hWnd, &updateRect, FALSE ) ) + { + hb_wvt_gtPaintText( hWnd, updateRect ); + } + + return 0; + } + + case WM_MY_UPDATE_CARET: + { + hb_wvt_gtSetCaretPos(); + return( 0 ); + } + + case WM_SETFOCUS: + { + if ( _s.bGui ) + { + _s.bSetFocus = TRUE ; + _s.bKillFocus = FALSE; + } + + hb_wvt_gtCreateCaret() ; + + if ( _s.bGetFocus ) + { + if ( _s.pSymWVT_SETFOCUS ) + { + hb_vmPushState(); + hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_SETFOCUS ) ); + hb_vmPushNil(); + hb_vmPushLong( ( LONG ) hWnd ); + hb_vmDo( 1 ); + hb_vmPopState(); + } + } + else + { + _s.bGetFocus = TRUE; + } + return( 0 ); + } + + case WM_KILLFOCUS: + { + if ( _s.bGui ) + { + _s.bKillFocus = TRUE; + } + hb_wvt_gtKillCaret(); + + if ( _s.pSymWVT_KILLFOCUS ) + { + hb_vmPushState(); + hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_KILLFOCUS ) ); + hb_vmPushNil(); + hb_vmPushLong( ( LONG ) hWnd ); + hb_vmDo( 1 ); + hb_vmPopState(); + } + return( 0 ); + } + + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + case WM_CHAR: + case WM_SYSCHAR: + { + return hb_wvt_gtKeyEvent( hWnd, message, wParam, lParam ); + } + + case WM_QUERYENDSESSION: // Closing down computer + { + /* if we have set a shutdown command return false, + * so windows ( and our app )doesn't shutdown + * otherwise let the default handler take it + */ + /* + if ( hb_gtHandleShutdown() ) + { + return 0; + } + */ + break; + } + + case WM_CLOSE: // Clicked 'X' on system menu + { + // if an event has been set then return it otherwise fake an Alt+C + //hb_gtHandleClose(); + return( 0 ); + } + + case WM_QUIT: + case WM_DESTROY: + return( 0 ); + + case WM_RBUTTONDOWN: + case WM_LBUTTONDOWN: + case WM_RBUTTONUP: + case WM_LBUTTONUP: + case WM_RBUTTONDBLCLK: + case WM_LBUTTONDBLCLK: + case WM_MBUTTONDOWN: + case WM_MBUTTONUP: + case WM_MBUTTONDBLCLK: + case WM_MOUSEMOVE: + case WM_MOUSEWHEEL: + case WM_NCMOUSEMOVE: + { + hb_wvt_gtMouseEvent( hWnd, message, wParam, lParam ); + return( 0 ); + } + case WM_ENTERIDLE: + { + //hb_idleState( FALSE ); + hb_idleState(); + return( 0 ); + } + + case WM_TIMER: + { + if ( _s.pSymWVT_TIMER ) + { + hb_vmPushState(); + hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_TIMER ) ); + hb_vmPushNil(); + hb_vmPushLong( (LONG) wParam ); + hb_vmDo( 1 ); + hb_vmPopState(); + } + return( 0 ); + } + } + return( DefWindowProc( hWnd, message, wParam, lParam ) ); +} +//-------------------------------------------------------------------// + +static void hb_wvt_gtRestGuiState( LPRECT rect ) +{ + BitBlt( _s.hdc, rect->left, rect->top, rect->right - rect->left, rect->bottom - rect->top, + _s.hGuiDC, rect->left, rect->top, SRCCOPY ); +} + +//-------------------------------------------------------------------// + +static HWND hb_wvt_gtCreateWindow( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow ) +{ + HWND hWnd; + WNDCLASS wndclass; + + HB_SYMBOL_UNUSED( hPrevInstance ); + HB_SYMBOL_UNUSED( szCmdLine ); + + InitCommonControls(); + + wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS ; + wndclass.lpfnWndProc = hb_wvt_gtWndProc; + wndclass.cbClsExtra = 0; + wndclass.cbWndExtra = 0; + wndclass.hInstance = hInstance; + wndclass.hIcon = NULL; + wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ); + wndclass.hbrBackground = NULL; + wndclass.lpszMenuName = NULL; + wndclass.lpszClassName = szAppName; + + if ( ! RegisterClass( &wndclass ) ) + { + MessageBox( NULL, TEXT( "Failed to register class." ), + szAppName, MB_ICONERROR ); + return( 0 ); + } + + hWnd = CreateWindow( szAppName, //classname + TEXT( "XHARBOUR_WVT" ), //window name + WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX, //style + 0, //x + 0, //y + CW_USEDEFAULT, //width + CW_USEDEFAULT, //height + NULL, //window parent + NULL, //menu + hInstance, //instance + NULL ); //lpParam + + + if ( hWnd == NULL ) + { + MessageBox( NULL, TEXT( "Failed to create window." ), + TEXT( "XHARBOUR_WVT" ), MB_ICONERROR ); + } + + // If you wish to show window the way you want, put somewhere in your application + // ANNOUNCE HB_NOSTARTUPWINDOW + // If so compiled, then you need to issue Wvt_ShowWindow( SW_RESTORE ) + // at the point you desire in your code. + // + if ( hb_dynsymFind( "HB_NOSTARTUPWINDOW" ) != NULL ) + { + iCmdShow = SW_HIDE; + } + + ShowWindow( hWnd, iCmdShow ); + UpdateWindow( hWnd ); + + return( hWnd ) ; +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtCreateToolTipWindow( void ) /* NO */ +{ + INITCOMMONCONTROLSEX icex; + HWND hwndTT; + TOOLINFO ti; + + // Load the tooltip class from the DLL. + // + icex.dwSize = sizeof( icex ); + icex.dwICC = ICC_BAR_CLASSES; + + if( !InitCommonControlsEx( &icex ) ) + { + return; + } + + // Create the tooltip control. + // + hwndTT = CreateWindow( TOOLTIPS_CLASS, TEXT( "" ), + WS_POPUP | TTS_ALWAYSTIP , + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + NULL, + ( HMENU ) NULL, + ( HINSTANCE ) hb_hInstance, + NULL ); + + SetWindowPos( hwndTT, + HWND_TOPMOST, + 0, + 0, + 0, + 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE ); + + // Prepare TOOLINFO structure for use as tracking tooltip. + // + ti.cbSize = sizeof( TOOLINFO ); + ti.uFlags = TTF_SUBCLASS; + ti.hwnd = _s.hWnd; + ti.uId = 100000; + ti.hinst = ( HINSTANCE ) hb_hInstance; + ti.lpszText = HB_TCHAR_CONVTO( "" ); + ti.rect.left = ti.rect.top = ti.rect.bottom = ti.rect.right = 0; + + // Add the tool to the control, displaying an error if needed. + // + if( ! SendMessage( hwndTT, TTM_ADDTOOL, 0, ( LPARAM ) &ti ) ) + { + return ; + } + + _s.hWndTT = hwndTT; +} + +//-------------------------------------------------------------------// + +static DWORD hb_wvt_gtProcessMessages( void ) +{ + MSG msg; + int iIndex; + BOOL bProcessed; + + while ( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) + { + bProcessed = FALSE; + + for ( iIndex = 0; iIndex < WVT_DLGML_MAX; iIndex++ ) + { + if ( _s.hDlgModeless[ iIndex ] != 0 ) + { + if ( IsDialogMessage( _s.hDlgModeless[ iIndex ], &msg ) ) + { + bProcessed = TRUE; + break; + } + } + } + + if ( bProcessed == FALSE ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + } + return( msg.wParam ); +} + +//-------------------------------------------------------------------// + +POINT HB_EXPORT hb_wvt_gtGetXYFromColRow( USHORT col, USHORT row ) +{ + POINT xy; + + xy.x = ( col ) * _s.PTEXTSIZE.x; + xy.y = ( row ) * _s.PTEXTSIZE.y; + + return( xy ); +} + +//-------------------------------------------------------------------// +/* + * get the row and column from xy pixel client coordinates + * This works because we are using the FIXED system font + * + */ +static POINT hb_wvt_gtGetColRowFromXY( USHORT x, USHORT y ) /* NO */ +{ + POINT colrow; + + colrow.x = ( x/_s.PTEXTSIZE.x ); + colrow.y = ( y/_s.PTEXTSIZE.y ); + + return( colrow ); +} + +//-------------------------------------------------------------------// +/* + * return a rectangle with row and column data, corresponding to the XY pixel + * coordinates + * This works because we are using the FIXED system font + * + */ +static RECT hb_wvt_gtGetColRowFromXYRect( RECT xy ) /* NO */ +{ + RECT colrow; + + colrow.left = ( xy.left / _s.PTEXTSIZE.x ); + colrow.top = ( xy.top / _s.PTEXTSIZE.y ); // 23/07/2004 9:02a.m. + colrow.right = ( xy.right / _s.PTEXTSIZE.x - ( xy.right % _s.PTEXTSIZE.x ? 0 : 1 ) ); // Adjust for when rectangle + colrow.bottom = ( xy.bottom / _s.PTEXTSIZE.y - ( xy.bottom % _s.PTEXTSIZE.y ? 0 : 1 ) ); // EXACTLY overlaps characters + + return( colrow ); +} + +//-------------------------------------------------------------------// +/* + * return a rectangle with the XY pixel coordinates corresponding to + * the row and column data + * This works because we are using the FIXED system font + * + */ +static RECT hb_wvt_gtGetXYFromColRowRect( RECT colrow ) /* NO */ +{ + RECT xy; + + xy.left = ( colrow.left ) * _s.PTEXTSIZE.x; + xy.top = ( colrow.top ) * _s.PTEXTSIZE.y; + xy.right = ( colrow.right +1 ) * _s.PTEXTSIZE.x; + xy.bottom = ( colrow.bottom+1 ) * _s.PTEXTSIZE.y; + + return( xy ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtCreateCaret() /* NO */ +{ +//OutputDebugString( "hb_wvt_gtCreateCaret()" ); + // create and show the caret + // create an underline caret of height - _s.CaretSize + // + _s.CaretExist = CreateCaret( _s.hWnd, ( HBITMAP ) NULL, _s.PTEXTSIZE.x, _s.CaretSize ); + if ( _s.CaretExist && _s.displayCaret ) + { + hb_wvt_gtSetCaretPos(); + ShowCaret( _s.hWnd ); + } +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtKillCaret() +{ + if ( _s.CaretExist ) + { + DestroyCaret(); + _s.CaretExist = FALSE ; + } +} + +//-------------------------------------------------------------------// +/* + * hb_wvt_gtSetCaretPos converts col and row to x and y ( pixels ) and calls + * the Windows function SetCaretPos ( with the expected coordinates ) + */ +static BOOL hb_wvt_gtSetCaretPos() +{ + POINT xy; + + xy = hb_wvt_gtGetXYFromColRow( (SHORT) _s.caretPos.x, (SHORT) _s.caretPos.y ); + if ( _s.CaretSize > 0 ) + { + xy.y += ( _s.PTEXTSIZE.y - _s.CaretSize ); + } + if ( _s.CaretExist ) + { + SetCaretPos( xy.x, xy.y ); + } + return( TRUE ); +} + +//----------------------------------------------------------------------// + +static void hb_wvt_gtUpdateCaret( void ) +{ + int iRow, iCol, iStyle, iCaretSize; + + hb_gt_GetScrCursor( &iRow, &iCol, &iStyle ); + + if( iRow < 0 || iCol < 0 || iRow >= _s.ROWS || iCol >= _s.COLS ) + { + iCaretSize = 0; + } + else switch( iStyle ) + { + case SC_INSERT: + iCaretSize = _s.PTEXTSIZE.y >> 1; + break; + case SC_SPECIAL1: + iCaretSize = _s.PTEXTSIZE.y; + break; + case SC_SPECIAL2: + iCaretSize = - ( _s.PTEXTSIZE.y >> 1 ); + break; + case SC_NORMAL: + iCaretSize = 4; + break; + default: + iCaretSize = 0; + break; + } + + if( iCaretSize == 0 ) + { + if( _s.CaretExist && !_s.CaretHidden ) + { + HideCaret( _s.hWnd ); + _s.CaretHidden = TRUE; + } + } + else + { + if( iCaretSize != _s.CaretSize || !_s.CaretExist ) + { + _s.CaretSize = iCaretSize; + _s.CaretExist = CreateCaret( _s.hWnd, ( HBITMAP ) NULL, _s.PTEXTSIZE.x, + _s.CaretSize < 0 ? - _s.CaretSize : _s.CaretSize ); + } + if( _s.CaretExist ) + { + POINT xy; + xy = hb_wvt_gtGetXYFromColRow( ( SHORT ) iCol, ( SHORT ) iRow ); + SetCaretPos( xy.x, _s.CaretSize < 0 ? + xy.y : xy.y + _s.PTEXTSIZE.y - _s.CaretSize ); + ShowCaret( _s.hWnd ); + _s.CaretHidden = FALSE; + } + } +} +//-------------------------------------------------------------------// +/* + * hb_wvt_gtValidateRow checks the row bounds for the caret, wrapping if indicated + */ +static void hb_wvt_gtValidateRow( void ) +{ + if ( _s.caretPos.y < 0 ) + { + _s.caretPos.y = _GetScreenHeight()-1; + if ( _s.caretPos.x > 0 ) + { + _s.caretPos.x--; + } + else + { + _s.caretPos.x = _GetScreenWidth()-1; + } + } + else if ( _s.caretPos.y >= _GetScreenHeight() ) + { + _s.caretPos.y = 0; + if ( _s.caretPos.x < _GetScreenWidth()-1 ) + { + _s.caretPos.x++; + } + else + { + _s.caretPos.x = 0; + } + } +} + +//-------------------------------------------------------------------// +/* + * hb_wvt_gtValidateCol checks the column bounds for the caret, wrapping if indicated + */ +static void hb_wvt_gtValidateCol( void ) +{ + if ( _s.caretPos.x < 0 ) + { + _s.caretPos.x = _GetScreenWidth()-1; + if ( _s.caretPos.y > 0 ) + { + _s.caretPos.y--; + } + else + { + _s.caretPos.y = _GetScreenHeight()-1; + } + } + else if ( _s.caretPos.x >= _GetScreenWidth() ) + { + _s.caretPos.x = 0; + if ( _s.caretPos.y < _GetScreenHeight()-1 ) + { + _s.caretPos.y++; + } + else + { + _s.caretPos.y = 0; + } + } +} + +//-------------------------------------------------------------------// +/* + * hb_wvt_gtValidateCaret checks the bounds for the caret, wrapping if indicated + * before setting the caret position on the screen + */ +static void hb_wvt_gtValidateCaret( void ) /* NO SAME */ +{ + hb_wvt_gtValidateCol(); + hb_wvt_gtValidateRow(); + + // send message to window to display updated caret + // + SendMessage( _s.hWnd, WM_MY_UPDATE_CARET, 0, 0 ); +} + +//-------------------------------------------------------------------// +/* + * hb_wvt_gtGetIndexForTextBuffer takes a row and column, and returns the appropriate + * index into the screen Text buffer + */ +static USHORT hb_wvt_gtGetIndexForTextBuffer( USHORT col, USHORT row ) /* NO */ +{ + return( row * _GetScreenWidth() + col ); +} + +//-------------------------------------------------------------------// + /* + * hb_wvt_gtGetColRowForTextBuffer takes an index into the screen Text buffer + * and returns the corresponding row and column + */ +static POINT hb_wvt_gtGetColRowForTextBuffer( USHORT index ) /* NO */ +{ + POINT colrow; + colrow.x = index % _GetScreenWidth(); + colrow.y = index / _GetScreenWidth(); + + return( colrow ); +} + +//-------------------------------------------------------------------// +/* + * hb_wvt_gtTextOut converts col and row to x and y ( pixels ) and calls + * the Windows function TextOut with the expected coordinates + */ + /* DIFFERENT */ +static BOOL hb_wvt_gtTextOut( HDC hdc, USHORT col, USHORT row, LPCTSTR lpString, USHORT cbString ) +{ + BOOL Result ; + POINT xy; + RECT rClip; +// long nFontCX = _s.PTEXTSIZE.x; +// long nFontCY = _s.PTEXTSIZE.y; + if ( cbString > _GetScreenWidth() ) // make sure string is not too long + { + cbString = _GetScreenWidth(); + } + xy = hb_wvt_gtGetXYFromColRow( col, row ); + +// SetRect( &rClip, xy.x, xy.y, xy.x + cbString * nFontCX, xy.y + nFontCY ); + SetRect( &rClip, xy.x, xy.y, xy.x + cbString * _s.PTEXTSIZE.x, xy.y + _s.PTEXTSIZE.y ); + + if ( _s.FixedFont ) + { + Result = ExtTextOut( hdc, xy.x, xy.y, ETO_CLIPPED|ETO_OPAQUE, &rClip, lpString, cbString, NULL ); + } + else + { + Result = ExtTextOut( hdc, xy.x, xy.y, ETO_CLIPPED|ETO_OPAQUE, &rClip, lpString, cbString, _s.FixedSize ); + } + return( Result ) ; +} + +//----------------------------------------------------------------------// + +static void hb_wvt_gtPaintText( HWND hWnd, RECT updateRect ) +{ + PAINTSTRUCT ps; + HDC hdc; + USHORT irow; + RECT rcRect; + + if ( _s.bGui && _s.bKillFocus ) + { + hb_wvt_gtRestGuiState( &updateRect ); + ValidateRect( hWnd, &updateRect ); + return; + } + if ( _s.bGui && _s.bSetFocus ) + { + _s.bSetFocus = FALSE; + hb_wvt_gtRestGuiState( &updateRect ); + ValidateRect( hWnd, &updateRect ); + return; + } + + hdc = BeginPaint( hWnd, &ps ); + SelectObject( hdc, _s.hFont ); + if ( _s.bGui ) + { + SelectObject( _s.hGuiDC, _s.hFont ); + } + + if ( _s.pBuffer != NULL && _s.pAttributes != NULL ) + { + rcRect = hb_wvt_gtGetColRowFromXYRect( updateRect ); + + _s.rowStart = rcRect.top ; + _s.rowStop = rcRect.bottom ; + _s.colStart = rcRect.left ; + _s.colStop = rcRect.right ; + + for ( irow = _s.rowStart; irow <= _s.rowStop; irow++ ) + { + USHORT icol, index, startIndex, startCol, len; + BYTE oldAttrib, attrib; + LPTSTR text; + + icol = _s.colStart; + startCol = icol; + index = hb_wvt_gtGetIndexForTextBuffer( icol, irow ); + startIndex = index; + len = 0; + oldAttrib = *( _s.pAttributes + index ); + + while ( icol <= _s.colStop ) + { + if ( index >= _s.BUFFERSIZE ) + { + break; + } + attrib = *( _s.pAttributes + index ); + if ( attrib != oldAttrib ) + { + hb_wvt_gtSetColors( hdc, oldAttrib ); + + //text = HB_TCHAR_CONVNTO( ( const char* ) _s.pBuffer + startIndex, len ); + text = HB_TCHAR_CONVNTO( ( BYTE * ) _s.pBuffer + startIndex, len ); + //hb_wvt_gtTextOut( hdc, startCol, irow, ( char const * ) _s.pBuffer + startIndex, len ); + hb_wvt_gtTextOut( hdc, startCol, irow, text, len ); + + if ( _s.bGui ) + { + hb_wvt_gtSetColors( _s.hGuiDC, oldAttrib ); + //hb_wvt_gtTextOut( _s.hGuiDC, startCol, irow, ( char const * ) _s.pBuffer + startIndex, len ); + hb_wvt_gtTextOut( _s.hGuiDC, startCol, irow, text, len ); + } + HB_TCHAR_FREE( text ); + oldAttrib = attrib; + startIndex = index; + startCol = icol; + len = 0; + } + icol++; + len++; + index++; + } + hb_wvt_gtSetColors( hdc, oldAttrib ); + //text = HB_TCHAR_CONVNTO( ( const char* ) _s.pBuffer + startIndex, len ); + text = HB_TCHAR_CONVNTO( ( BYTE * ) _s.pBuffer + startIndex, len ); + hb_wvt_gtTextOut( hdc, startCol, irow, text, len ); + if ( _s.bGui ) + { + hb_wvt_gtSetColors( _s.hGuiDC, oldAttrib ); + hb_wvt_gtTextOut( _s.hGuiDC, startCol, irow, text, len ); + } + HB_TCHAR_FREE( text ); + } + } + + EndPaint( hWnd, &ps ); + + if ( _s.bPaint ) + { + if ( _s.pSymWVT_PAINT ) + { + hb_vmPushState(); + hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_PAINT ) ); + hb_vmPushNil(); + hb_vmDo( 0 ); + hb_vmPopState(); + } + } + else + { + _s.bPaint = TRUE; + } +} + +//-------------------------------------------------------------------// +// +// get for and background colours from attribute and set them for window +// +static BOOL hb_wvt_gtSetColors( HDC hdc, BYTE attr ) +{ + int fore = attr & 0x000F; + int back = ( attr & 0x00F0 )>>4; + + _s.foreground = _COLORS[ fore ]; + _s.background = _COLORS[ back ]; + + SetTextColor( hdc, _s.foreground ); + SetBkColor( hdc, _s.background ); + SetTextAlign( hdc, TA_LEFT ); + + return( TRUE ); +} + +//-------------------------------------------------------------------// +// +// compute invalid rect in pixels, from row and col +// +static void hb_wvt_gtSetInvalidRect( USHORT left, USHORT top, USHORT right, USHORT bottom ) +{ + RECT rect; + if ( _s.InvalidateWindow ) + { + rect.left = left; + rect.top = top; + rect.right = right; + rect.bottom = bottom; + + rect = hb_wvt_gtGetXYFromColRowRect( rect ); + + // check for wrapping + // + rect.left = min( rect.left, rect.right ); + rect.top = min( rect.top, rect.bottom ); + + rect.right = max( rect.left, rect.right ); + rect.bottom = max( rect.top, rect.bottom ); + + if ( _s.RectInvalid.left < 0 ) + { + memcpy( &_s.RectInvalid, &rect, sizeof( RECT ) ); + } + else + { + _s.RectInvalid.left = min( _s.RectInvalid.left , rect.left ); + _s.RectInvalid.top = min( _s.RectInvalid.top , rect.top ); + _s.RectInvalid.right = max( _s.RectInvalid.right , rect.right ); + _s.RectInvalid.bottom = max( _s.RectInvalid.bottom, rect.bottom ); + } + + hb_wvt_gtDoInvalidateRect() ; + } +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtDoInvalidateRect( void ) +{ + if ( HB_GT_FUNC( gt_DispCount() ) <= 0 && ( _s.RectInvalid.left != -1 ) ) + { + // InvalidateRect( _s.hWnd, &_s.RectInvalid, TRUE ); + InvalidateRect( _s.hWnd, &_s.RectInvalid, FALSE ); + _s.RectInvalid.left = -1 ; + hb_wvt_gtProcessMessages(); + } +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtTranslateKey( int key, int shiftkey, int altkey, int controlkey ) +{ + int nVirtKey = GetKeyState( VK_MENU ); + + if ( nVirtKey & 0x8000 ) // alt + key + { + hb_wvt_gtAddCharToInputQueue( altkey ); + } + else + { + nVirtKey = GetKeyState( VK_CONTROL ); + if ( nVirtKey & 0x8000 ) // control + key + { + hb_wvt_gtAddCharToInputQueue( controlkey ); + } + else + { + nVirtKey = GetKeyState( VK_SHIFT ); + if ( nVirtKey & 0x8000 ) // shift + key + { + hb_wvt_gtAddCharToInputQueue( shiftkey ); + } + else //just key + { + hb_wvt_gtAddCharToInputQueue( key ); + } + } + } +} + +//-------------------------------------------------------------------// +// +// font stuff +/* use the standard fixed oem font, unless the caller has requested set size fonts +*/ +static HFONT hb_wvt_gtGetFont( char * pszFace, int iHeight, int iWidth, int iWeight, int iQuality, int iCodePage ) +{ + HFONT hFont; + + if ( iHeight > 0 ) + { + LOGFONT logfont; + + logfont.lfEscapement = 0; + logfont.lfOrientation = 0; + logfont.lfWeight = iWeight ; + logfont.lfItalic = 0; + logfont.lfUnderline = 0; + logfont.lfStrikeOut = 0; + logfont.lfCharSet = iCodePage; // OEM_CHARSET; + logfont.lfOutPrecision = 0; + logfont.lfClipPrecision = 0; + logfont.lfQuality = 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 ); + + hFont = CreateFontIndirect( &logfont ); + } + else + { + hFont = ( HFONT ) GetStockObject( OEM_FIXED_FONT ); + } + return( hFont ); +} + +//-------------------------------------------------------------------// + +static void gt_hbInitStatics( void ) +{ + OSVERSIONINFO osvi ; + HINSTANCE h; + int iIndex; + LPTSTR msimg32 = HB_TCHAR_CONVTO( "msimg32.dll" ); + LPTSTR GradientFill = HB_TCHAR_CONVTO( "GradientFill" ); + + _s.ROWS = WVT_DEFAULT_ROWS; + _s.COLS = WVT_DEFAULT_COLS; + _s.foreground = WHITE; + _s.background = BLACK; + _s.BUFFERSIZE = 0; + _s.pAttributes = NULL; + _s.pBuffer = NULL; + _s.caretPos.x = 0; + _s.caretPos.y = 0; + _s.CaretExist = FALSE; + _s.CaretSize = 4; + _s.CaretHidden = FALSE; + _s.mousePos.x = 0; + _s.mousePos.y = 0; + _s.MouseMove = FALSE ; + _s.hWnd = NULL; + _s.keyPointerIn = 1; + _s.keyPointerOut = 0; + _s.displayCaret = TRUE; + _s.RectInvalid.left = -1 ; + + // THEESE are the default font parameters, if not changed by user + _s.PTEXTSIZE.x = 8; + _s.PTEXTSIZE.y = 16; + _s.fontHeight = 16; + _s.fontWidth = 8; + _s.fontWeight = FW_NORMAL; + _s.fontQuality = DEFAULT_QUALITY; + strcpy( _s.fontFace,"Terminal" ); + + _s.LastMenuEvent = 0; + _s.MenuKeyEvent = 1024; + _s.CentreWindow = TRUE; // Default is to always display window in centre of screen + _s.CodePage = GetACP() ; // Set code page to default system + + osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + GetVersionEx ( &osvi ); + _s.Win9X = ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ); + _s.AltF4Close = FALSE; + _s.InvalidateWindow = TRUE; + _s.EnableShortCuts = FALSE; + _s.pSymWVT_PAINT = hb_dynsymFind( "WVT_PAINT" ) ; + _s.pSymWVT_SETFOCUS = hb_dynsymFind( "WVT_SETFOCUS" ) ; + _s.pSymWVT_KILLFOCUS= hb_dynsymFind( "WVT_KILLFOCUS" ) ; + _s.pSymWVT_MOUSE = hb_dynsymFind( "WVT_MOUSE" ) ; + _s.pSymWVT_TIMER = hb_dynsymFind( "WVT_TIMER" ) ; + _s.pSymWVT_KEY = hb_dynsymFind( "WVT_KEY" ) ; + _s.rowStart = 0; + _s.rowStop = 0; + _s.colStart = 0; + _s.colStop = 0; + _s.bToolTipActive = FALSE; + + h = LoadLibraryEx( msimg32, NULL, 0 ); + HB_TCHAR_FREE( msimg32 ); + if ( h ) + { + _s.pfnGF = ( wvtGradientFill ) GetProcAddress( h, GradientFill ); + HB_TCHAR_FREE( GradientFill ); + if ( _s.pfnGF ) + { + _s.hMSImg32 = h; + } + } + + for ( iIndex = 0; iIndex < WVT_DLGML_MAX; iIndex++ ) + { + _s.hDlgModeless[ iIndex ] = NULL; + _s.pFunc[ iIndex ] = NULL; + _s.iType[ iIndex ] = ( int ) NULL; + } + for ( iIndex = 0; iIndex < WVT_DLGMD_MAX; iIndex++ ) + { + _s.hDlgModal[ iIndex ] = NULL; + _s.pFuncModal[ iIndex ] = NULL; + _s.iTypeModal[ iIndex ] = ( int ) NULL; + } + + _s.bGui = FALSE; + _s.bIgnoreWM_SYSCHAR = FALSE; + _s.bPaint = FALSE; + _s.bGetFocus = FALSE; + _s.bSetFocus = FALSE; + _s.bKillFocus = FALSE; +} + +//-------------------------------------------------------------------// +/* + * functions for handling the input queues for the mouse and keyboard + */ +void HB_EXPORT hb_wvt_gtAddCharToInputQueue ( int data ) +{ + int iNextPos; + + iNextPos = ( _s.keyPointerIn >= WVT_CHAR_QUEUE_SIZE - 1 ) ? 0 : _s.keyPointerIn+1 ; + if ( iNextPos != _s.keyPointerOut ) // Stop accepting characters once the buffer is full + { + _s.Keys[ _s.keyPointerIn ] = data ; + _s.keyPointerIn = iNextPos ; + } + + if ( _s.pSymWVT_KEY ) + { + hb_vmPushState(); + hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_KEY ) ); + hb_vmPushNil(); + hb_vmPushLong( ( LONG ) data ); + hb_vmDo( 1 ); + hb_vmPopState(); + } +} + +//-------------------------------------------------------------------// + +static BOOL hb_wvt_gtGetCharFromInputQueue ( int *c ) +{ + int iNextPos; + BOOL bRet = FALSE; + + *c = 0; + iNextPos = ( _s.keyPointerOut >= WVT_CHAR_QUEUE_SIZE - 1 ) ? 0 : _s.keyPointerOut+1 ; + if ( iNextPos != _s.keyPointerIn ) // No more events in queue ?? + { + *c = _s.Keys[ iNextPos ] ; + _s.keyPointerOut = iNextPos ; + bRet = TRUE; + } + + return( bRet ); +} + +//-------------------------------------------------------------------// + +static USHORT hb_wvt_gtGetMouseX ( void ) +{ + return( (SHORT) _s.mousePos.x ); +} + +//-------------------------------------------------------------------// + +static USHORT hb_wvt_gtGetMouseY ( void ) +{ + return( (SHORT) _s.mousePos.y ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtSetMouseX ( USHORT ix ) +{ + _s.mousePos.x = ix; +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtSetMouseY ( USHORT iy ) +{ + _s.mousePos.y = iy; +} + +//-------------------------------------------------------------------// +/* + * hb_wvt_gtSetStringInTextBuffer puts the string of the specified length into the TextBuffer at + * the specified caret position + * It then determines the invalid rectangle, so the string will be displayed + */ +static void hb_wvt_gtSetStringInTextBuffer( USHORT col, USHORT row, BYTE attr, BYTE *sBuffer, USHORT length ) +{ + POINT end; + USHORT index; + + // determine the index and put the string into the TextBuffer + // + index = hb_wvt_gtGetIndexForTextBuffer( col, row ); + if ( length + index <= _s.BUFFERSIZE ) + { + memcpy( ( _s.pBuffer+index ), sBuffer, length ); +// if ( attr != ' ' ) // if no attribute, don't overwrite +// { + memset( ( _s.pAttributes+index ), attr, length ); +// } + + // determine bounds of rect around character to refresh + // + end = hb_wvt_gtGetColRowForTextBuffer( index + ( length -1 ) ); //location of last char + hb_wvt_gtSetInvalidRect( (SHORT) col, (SHORT) row, (SHORT) end.x, (SHORT) end.y ); + } +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtSetCaretOn( BOOL bOn ) +{ + if ( _s.CaretExist ) + { + if ( bOn ) + { + hb_wvt_gtSetCaretPos(); + ShowCaret( _s.hWnd ); + } + else + { + HideCaret( _s.hWnd ); + } + } + _s.displayCaret = bOn; +} + +//-------------------------------------------------------------------// + +static void hb_wvt_gtHandleMenuSelection( int menuIndex ) +{ + _s.LastMenuEvent = menuIndex ; + hb_wvt_gtAddCharToInputQueue( _s.MenuKeyEvent ); +} + +//-------------------------------------------------------------------// + +static BOOL hb_wvt_gtKeyEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) +{ + switch( message ) + { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + { + BOOL bAlt = GetKeyState( VK_MENU ) & 0x8000; + _s.bIgnoreWM_SYSCHAR = FALSE; + + switch ( wParam ) + { + case VK_LEFT: + hb_wvt_gtTranslateKey( K_LEFT , K_SH_LEFT , K_ALT_LEFT , K_CTRL_LEFT ); + break; + case VK_RIGHT: + hb_wvt_gtTranslateKey( K_RIGHT, K_SH_RIGHT, K_ALT_RIGHT, K_CTRL_RIGHT ); + break; + case VK_UP: + hb_wvt_gtTranslateKey( K_UP , K_SH_UP , K_ALT_UP , K_CTRL_UP ); + break; + case VK_DOWN: + hb_wvt_gtTranslateKey( K_DOWN , K_SH_DOWN , K_ALT_DOWN , K_CTRL_DOWN ); + break; + case VK_HOME: + hb_wvt_gtTranslateKey( K_HOME , K_SH_HOME , K_ALT_HOME , K_CTRL_HOME ); + break; + case VK_END: + hb_wvt_gtTranslateKey( K_END , K_SH_END , K_ALT_END , K_CTRL_END ); + break; + case VK_DELETE: + hb_wvt_gtTranslateKey( K_DEL , K_SH_DEL , K_ALT_DEL , K_CTRL_DEL ); + break; + case VK_INSERT: + hb_wvt_gtTranslateKey( K_INS , K_SH_INS , K_ALT_INS , K_CTRL_INS ); + break; + case VK_PRIOR: + hb_wvt_gtTranslateKey( K_PGUP , K_SH_PGUP , K_ALT_PGUP , K_CTRL_PGUP ); + break; + case VK_NEXT: + hb_wvt_gtTranslateKey( K_PGDN , K_SH_PGDN , K_ALT_PGDN , K_CTRL_PGDN ); + break; + + case VK_F1: + hb_wvt_gtTranslateKey( K_F1 , K_SH_F1, K_ALT_F1 , K_CTRL_F1 ); + break; + case VK_F2: + hb_wvt_gtTranslateKey( K_F2 , K_SH_F2, K_ALT_F2 , K_CTRL_F2 ); + break; + case VK_F3: + hb_wvt_gtTranslateKey( K_F3 , K_SH_F3, K_ALT_F3 , K_CTRL_F3 ); + break; + case VK_F4: + { + if ( _s.AltF4Close && bAlt ) + { + return( DefWindowProc( hWnd, message, wParam, lParam ) ); + } + else + { + hb_wvt_gtTranslateKey( K_F4 , K_SH_F4, K_ALT_F4 , K_CTRL_F4 ); + } + break; + } + case VK_F5: + hb_wvt_gtTranslateKey( K_F5 , K_SH_F5, K_ALT_F5 , K_CTRL_F5 ); + break; + case VK_F6: + hb_wvt_gtTranslateKey( K_F6 , K_SH_F6, K_ALT_F6 , K_CTRL_F6 ); + break; + case VK_F7: + hb_wvt_gtTranslateKey( K_F7 , K_SH_F7, K_ALT_F7 , K_CTRL_F7 ); + break; + case VK_F8: + hb_wvt_gtTranslateKey( K_F8 , K_SH_F8, K_ALT_F8 , K_CTRL_F8 ); + break; + case VK_F9: + hb_wvt_gtTranslateKey( K_F9 , K_SH_F9, K_ALT_F9 , K_CTRL_F9 ); + break; + case VK_F10: + hb_wvt_gtTranslateKey( K_F10 , K_SH_F10,K_ALT_F10 , K_CTRL_F10 ); + break; + case VK_F11: + hb_wvt_gtTranslateKey( K_F11 , K_SH_F11,K_ALT_F11 , K_CTRL_F11 ); + break; + case VK_F12: + hb_wvt_gtTranslateKey( K_F12 , K_SH_F12,K_ALT_F12 , K_CTRL_F12 ); + break; + default: + { + BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; + BOOL bShift = GetKeyState( VK_SHIFT ) & 0x8000; + int iScanCode = HIWORD( lParam ) & 0xFF ; + + if ( bCtrl && iScanCode == 76 ) // CTRL_VK_NUMPAD5 ) + { + hb_wvt_gtAddCharToInputQueue( KP_CTRL_5 ); + } + else if ( bCtrl && wParam == VK_TAB ) // K_CTRL_TAB + { + if ( bShift ) + { + hb_wvt_gtAddCharToInputQueue( K_CTRL_SH_TAB ); + } + else + { + hb_wvt_gtAddCharToInputQueue( K_CTRL_TAB ); + } + } + else if ( iScanCode == 70 ) // Ctrl_Break key OR Scroll Lock Key + { + if ( bCtrl ) // Not scroll lock + { + hb_wvt_gtAddCharToInputQueue( HB_BREAK_FLAG ); // Pretend Alt+C pressed + _s.bIgnoreWM_SYSCHAR = TRUE; + } + else + { + DefWindowProc( hWnd, message, wParam, lParam ) ; // Let windows handle ScrollLock + } + } + else if ( bCtrl && iScanCode == 53 && bShift ) + { + hb_wvt_gtAddCharToInputQueue( K_CTRL_QUESTION ); + } + else if ( ( bAlt || bCtrl ) && ( + wParam == VK_MULTIPLY || wParam == VK_ADD || wParam == VK_SUBTRACT || wParam == VK_DIVIDE ) ) + { + if ( bAlt ) + { + _s.bIgnoreWM_SYSCHAR = TRUE; + } + switch ( wParam ) + { + case VK_MULTIPLY: + hb_wvt_gtTranslateKey( '*','*', KP_ALT_ASTERISK, KP_CTRL_ASTERISK ); + break; + case VK_ADD: + hb_wvt_gtTranslateKey( '+','+', KP_ALT_PLUS, KP_CTRL_PLUS ); + break; + case VK_SUBTRACT: + hb_wvt_gtTranslateKey( '-','-', KP_ALT_MINUS, KP_CTRL_MINUS ); + break; + case VK_DIVIDE: + hb_wvt_gtTranslateKey( '/','/', KP_ALT_SLASH, KP_CTRL_SLASH ); + break; + } + } + else if ( _s.EnableShortCuts ) + { + return( DefWindowProc( hWnd, message, wParam, lParam ) ); + } + } + } + return( 0 ); + } + + case WM_CHAR: + { + BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; + int iScanCode = HIWORD( lParam ) & 0xFF ; + int c = ( int ) wParam; + + if ( !_s.bIgnoreWM_SYSCHAR ) + { + if ( bCtrl && iScanCode == 28 ) // K_CTRL_RETURN + { + hb_wvt_gtAddCharToInputQueue( K_CTRL_RETURN ); + } + else if ( bCtrl && ( c >= 1 && c <= 26 ) ) // K_CTRL_A - Z + { + hb_wvt_gtAddCharToInputQueue( K_Ctrl[c-1] ); + } + else + { + switch ( c ) + { + // handle special characters + case VK_BACK: + hb_wvt_gtTranslateKey( K_BS, K_SH_BS, K_ALT_BS, K_CTRL_BS ); + break; + case VK_TAB: + hb_wvt_gtTranslateKey( K_TAB, K_SH_TAB, K_ALT_TAB, K_CTRL_TAB ); + break; + case VK_RETURN: + hb_wvt_gtTranslateKey( K_RETURN, K_SH_RETURN, K_ALT_RETURN, K_CTRL_RETURN ); + break; + case VK_ESCAPE: + hb_wvt_gtAddCharToInputQueue( K_ESC ); + break; + default: +#if defined(UNICODE) + if( _s.inCDP ) + c = hb_cdpGetChar( _s.inCDP, FALSE, ( USHORT ) c ); + else +#endif + if( _s.CodePage == OEM_CHARSET ) + { + c = hb_wvt_key_ansi_to_oem( c ); + } + hb_wvt_gtAddCharToInputQueue( c ); + break; + } + } + } + + _s.bIgnoreWM_SYSCHAR = FALSE; // As Suggested by Peter + return( 0 ); + } + + case WM_SYSCHAR: + { + if ( !_s.bIgnoreWM_SYSCHAR ) + { + int c, iScanCode = HIWORD( lParam ) & 0xFF ; + switch ( iScanCode ) + { + case 2: + c = K_ALT_1 ; + break; + case 3: + c = K_ALT_2 ; + break; + case 4: + c = K_ALT_3 ; + break; + case 5: + c = K_ALT_4 ; + break; + case 6: + c = K_ALT_5 ; + break; + case 7: + c = K_ALT_6 ; + break; + case 8: + c = K_ALT_7 ; + break; + case 9: + c = K_ALT_8 ; + break; + case 10: + c = K_ALT_9 ; + break; + case 11: + c = K_ALT_0 ; + break; + case 13: + c = K_ALT_EQUALS ; + break; + case 14: + c = K_ALT_BS ; + break; + case 16: + c = K_ALT_Q ; + break; + case 17: + c = K_ALT_W ; + break; + case 18: + c = K_ALT_E ; + break; + case 19: + c = K_ALT_R ; + break; + case 20: + c = K_ALT_T ; + break; + case 21: + c = K_ALT_Y ; + break; + case 22: + c = K_ALT_U ; + break; + case 23: + c = K_ALT_I ; + break; + case 24: + c = K_ALT_O ; + break; + case 25: + c = K_ALT_P ; + break; + case 30: + c = K_ALT_A ; + break; + case 31: + c = K_ALT_S ; + break; + case 32: + c = K_ALT_D ; + break; + case 33: + c = K_ALT_F ; + break; + case 34: + c = K_ALT_G ; + break; + case 35: + c = K_ALT_H ; + break; + case 36: + c = K_ALT_J ; + break; + case 37: + c = K_ALT_K ; + break; + case 38: + c = K_ALT_L ; + break; + case 44: + c = K_ALT_Z ; + break; + case 45: + c = K_ALT_X ; + break; + case 46: + c = K_ALT_C ; + break; + case 47: + c = K_ALT_V ; + break; + case 48: + c = K_ALT_B ; + break; + case 49: + c = K_ALT_N ; + break; + case 50: + c = K_ALT_M ; + break; + default: + c = ( int ) wParam ; + break; + } + hb_wvt_gtAddCharToInputQueue( c ); + } + _s.bIgnoreWM_SYSCHAR = FALSE; + } + } + return( 0 ); +} + +//----------------------------------------------------------------------// + +static void hb_wvt_gtMouseEvent( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) +{ + POINT xy, colrow ; + SHORT keyCode = 0; + SHORT keyState = 0; + ULONG lPopupRet ; + + HB_SYMBOL_UNUSED( hWnd ); + HB_SYMBOL_UNUSED( wParam ); + + if ( !b_MouseEnable ) + { + return; + } + else + { + if ( message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE ) + { + if ( ! _s.MouseMove ) + { + return; + } + } + + xy.x = LOWORD( lParam ); + xy.y = HIWORD( lParam ); + + colrow = hb_wvt_gtGetColRowFromXY( ( SHORT ) xy.x, ( SHORT ) xy.y ); + + hb_wvt_gtSetMouseX( ( SHORT ) colrow.x ); + hb_wvt_gtSetMouseY( ( SHORT ) colrow.y ); + + switch( message ) + { + case WM_LBUTTONDBLCLK: + keyCode = K_LDBLCLK; + break; + + case WM_RBUTTONDBLCLK: + keyCode = K_RDBLCLK; + break; + + case WM_LBUTTONDOWN: + keyCode = K_LBUTTONDOWN; + break; + + case WM_RBUTTONDOWN: + keyCode = K_RBUTTONDOWN; + break; + + case WM_RBUTTONUP: + if ( _s.hPopup ) + { + GetCursorPos( &xy ); + lPopupRet = TrackPopupMenu( _s.hPopup, TPM_CENTERALIGN + TPM_RETURNCMD, xy.x, xy.y, 0, hWnd, NULL ); + if ( lPopupRet ) + { + hb_wvt_gtAddCharToInputQueue( lPopupRet ); + } + return; + } + else + { + keyCode = K_RBUTTONUP; + break; + } + + case WM_LBUTTONUP: + keyCode = K_LBUTTONUP; + break; + + case WM_MBUTTONDOWN: + keyCode = K_MBUTTONDOWN; + break; + + case WM_MBUTTONUP: + keyCode = K_MBUTTONUP; + break; + + case WM_MBUTTONDBLCLK: + keyCode = K_MDBLCLK; + break; + + case WM_MOUSEMOVE: + keyState = wParam; + + if ( keyState == MK_LBUTTON ) + { + keyCode = K_MMLEFTDOWN; + } + else if ( keyState == MK_RBUTTON ) + { + keyCode = K_MMRIGHTDOWN; + } + else if ( keyState == MK_MBUTTON ) + { + keyCode = K_MMMIDDLEDOWN; + } + else + { + keyCode = K_MOUSEMOVE; + } + break; + + case WM_MOUSEWHEEL: + keyState = HIWORD( wParam ); + + if ( keyState > 0 ) + { + keyCode = K_MWFORWARD; + } + else + { + keyCode = K_MWBACKWARD; + } + break; + + case WM_NCMOUSEMOVE: + { + keyCode = K_NCMOUSEMOVE; + } + break; + } + + if ( _s.pSymWVT_MOUSE && keyCode != 0 ) + { + hb_vmPushState(); + //hb_vmPushSymbol( _s.pSymWVT_MOUSE->pSymbol ); + hb_vmPushSymbol( hb_dynsymSymbol( _s.pSymWVT_MOUSE ) ); + + hb_vmPushNil(); + hb_vmPushLong( ( SHORT ) keyCode ); + hb_vmPushLong( ( SHORT ) colrow.y ); + hb_vmPushLong( ( SHORT ) colrow.x ); + hb_vmPushLong( ( SHORT ) keyState ); + hb_vmDo( 4 ); + hb_vmPopState(); + } + + hb_wvt_gtAddCharToInputQueue( keyCode ); + } +} + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Exported functions for API calls +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtSetMenuKeyEvent( int iMenuKeyEvent ) +{ + int iOldEvent; + + iOldEvent = _s.MenuKeyEvent ; + if ( iMenuKeyEvent ) + { + _s.MenuKeyEvent = iMenuKeyEvent; + } + return( iOldEvent ); +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtSetCentreWindow( BOOL bCentre, BOOL bPaint ) +{ + BOOL bWasCentre; + + bWasCentre = _s.CentreWindow ; + _s.CentreWindow = bCentre; + if ( bPaint ) + { + hb_wvt_gtResetWindowSize( _s.hWnd ) ; + } + return( bWasCentre ); +} + +//-------------------------------------------------------------------// + +void HB_EXPORT hb_wvt_gtResetWindow( void ) +{ + hb_wvt_gtResetWindowSize( _s.hWnd ) ; +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtSetCodePage( int iCodePage ) +{ + int iOldCodePage; + + iOldCodePage = _s.CodePage ; + if ( iCodePage ) + { + _s.CodePage = iCodePage; + } + if ( iOldCodePage != iCodePage ) + { + hb_wvt_gtResetWindow(); + } + return( iOldCodePage ); +} + +//-------------------------------------------------------------------// + +int HB_EXPORT hb_wvt_gtGetLastMenuEvent( void ) +{ + return( _s.LastMenuEvent ); +} + +//-------------------------------------------------------------------// + +int HB_EXPORT hb_wvt_gtSetLastMenuEvent( int iLastMenuEvent ) +{ + int iRetval = _s.LastMenuEvent; + + _s.LastMenuEvent = iLastMenuEvent; + return( iRetval ); +} + +//-------------------------------------------------------------------// + +void HB_EXPORT hb_wvt_gtSetWindowTitle( char * title ) +{ + LPTSTR text = HB_TCHAR_CONVTO( title ); + SetWindowText( _s.hWnd, text ); + HB_TCHAR_FREE( text ); +} + +//-------------------------------------------------------------------// + +DWORD HB_EXPORT hb_wvt_gtSetWindowIcon( int icon, char *lpIconName ) +{ + HICON hIcon; + + if( lpIconName == NULL ) + { + hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, MAKEINTRESOURCE( icon ) ); + } + else + { + LPTSTR iconName = HB_TCHAR_CONVTO( lpIconName ); + hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, iconName ); + HB_TCHAR_FREE( iconName ); + } + + if ( hIcon ) + { + SendMessage( _s.hWnd, WM_SETICON, ICON_SMALL, ( LPARAM )hIcon ); // Set Title Bar ICON + SendMessage( _s.hWnd, WM_SETICON, ICON_BIG, ( LPARAM )hIcon ); // Set Task List Icon + } + return( ( DWORD ) hIcon ) ; +} + +//-------------------------------------------------------------------// + +DWORD HB_EXPORT hb_wvt_gtSetWindowIconFromFile( char *icon ) +{ + LPTSTR iconName = HB_TCHAR_CONVTO( icon ); + HICON hIcon = (HICON) LoadImage( ( HINSTANCE ) NULL, iconName, IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + + HB_TCHAR_FREE( iconName ); + + if ( hIcon ) + { + SendMessage( _s.hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) hIcon ); // Set Title Bar ICON + SendMessage( _s.hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) hIcon ); // Set Task List Icon + } + + return( ( DWORD ) hIcon ) ; +} + +//-------------------------------------------------------------------// + +int HB_EXPORT hb_wvt_gtGetWindowTitle( char * cTitle, int length ) +{ + //LPTSTR title = HB_TCHAR_CONVTO( cTitle ); + return( GetWindowText( _s.hWnd, HB_TCHAR_CONVTO( cTitle ), length ) ); +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtSetFont( char *fontFace, int height, int width, int Bold, int Quality ) +{ + int size; + BOOL bResult = FALSE ; + HFONT hFont; + LPTSTR fontName = HB_TCHAR_CONVTO( fontFace ); + + hFont = hb_wvt_gtGetFont( fontFace, height, width, Bold, Quality, _s.CodePage ); + HB_TCHAR_FREE( fontName ); + + // make sure the font could actually be created + // + if ( hFont ) + { + // make sure that the font will fit inside the + // window with the current _s.ROWS and _s.COLS setting + if ( hb_wvt_gtValidWindowSize( _GetScreenHeight(),_GetScreenWidth(), hFont, width ) ) + { + _s.fontHeight = height; + _s.fontWidth = width; + _s.fontWeight = Bold; + _s.fontQuality = Quality; + + size = strlen( fontFace ); + if ( ( size > 0 ) && ( size < LF_FACESIZE-1 ) ) + { + strcpy( _s.fontFace, fontFace ); + } + if ( _s.hWnd ) + { + // resize the window based on new fonts + // + hb_wvt_gtResetWindowSize( _s.hWnd ); + + // force resize of caret + // + hb_wvt_gtKillCaret(); + hb_wvt_gtCreateCaret(); + } + bResult= TRUE; + } + DeleteObject( hFont ); + } + return( bResult ); +} + +//-------------------------------------------------------------------// + +HWND HB_EXPORT hb_wvt_gtGetWindowHandle( void ) +{ + return( _s.hWnd ); +} + +//-------------------------------------------------------------------// + +void HB_EXPORT hb_wvt_gtPostMessage( int message ) +{ + SendMessage( _s.hWnd, WM_CHAR,message, 0 ); +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtSetWindowPos( int left, int top ) +{ + RECT wi; + GetWindowRect( _s.hWnd, &wi ); + return( SetWindowPos( _s.hWnd, NULL, left, top, ( wi.right-wi.left )+1, ( wi.bottom-wi.top )+1, SWP_NOZORDER ) ); +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtSetAltF4Close( BOOL bCanClose ) +{ + BOOL bWas; + bWas = _s.AltF4Close; + _s.AltF4Close = bCanClose; + return( bWas ); +} + +//-------------------------------------------------------------------// + +void HB_EXPORT hb_wvt_gtDoProcessMessages( void ) +{ + hb_wvt_gtProcessMessages(); +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtSetMouseMove( BOOL bHandleEvent ) +{ + BOOL bWas = _s.MouseMove; + _s.MouseMove = bHandleEvent; + return( bWas ); +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtEnableShortCuts( BOOL bEnable ) +{ + BOOL bWas = _s.EnableShortCuts; + _s.EnableShortCuts = bEnable; + return( bWas ); +} + +//-------------------------------------------------------------------// +// +// Courtesy - Augusto Infante - Thanks +// +HB_EXPORT IPicture * hb_wvt_gtLoadPictureFromResource( LPCSTR cResource, LPCSTR cSection ) +{ + HRSRC res; + LPVOID iPicture = NULL; + //LPTSTR resource = cResource; //HB_TCHAR_CPTO( cResource ); + //LPTSTR section = cSection; //HB_TCHAR_CPTO( cSection ); + + res = FindResource( ( HINSTANCE ) hb_hInstance, cResource, cSection ); + if ( res ) + { + IStream *iStream = NULL; + HGLOBAL mem = LoadResource( GetModuleHandle( NULL ), res ); + void *data = LockResource( mem ); + size_t nFileSize = SizeofResource( GetModuleHandle( NULL ), res ); + HGLOBAL hGlobal = GlobalAlloc( GMEM_MOVEABLE, nFileSize ); + LPVOID pvData = GlobalLock( hGlobal ); + + memcpy( pvData, data, nFileSize ); + + GlobalUnlock( hGlobal ); + + CreateStreamOnHGlobal( hGlobal, TRUE, &iStream ); + + OleLoadPicture( iStream, nFileSize, TRUE, ( REFIID ) &IID_IPicture, &iPicture ); + + FreeResource( mem ); + } + + //HB_TCHAR_FREE( resource ); + //HB_TCHAR_FREE( section ); + + return (IPicture *) iPicture; +} + +//--------------------------------------------------------------------// + +HB_EXPORT IPicture * hb_wvt_gtLoadPicture( char * cImage ) +{ + IStream *iStream; + LPVOID iPicture = NULL; + HGLOBAL hGlobal; + HANDLE hFile; + DWORD nFileSize; + DWORD nReadByte; + LPTSTR image = HB_TCHAR_CONVTO( cImage ); + + hFile = CreateFile( image, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL ); + if ( hFile != INVALID_HANDLE_VALUE ) + { + nFileSize = GetFileSize( hFile, NULL ); + + if ( nFileSize != INVALID_FILE_SIZE ) + { + hGlobal = GlobalAlloc( GPTR, nFileSize ); + + if ( hGlobal ) + { + if ( ReadFile( hFile, hGlobal, nFileSize, &nReadByte, NULL ) ) + { + CreateStreamOnHGlobal( hGlobal, TRUE, &iStream ); + OleLoadPicture( iStream, nFileSize, TRUE, (REFIID) &IID_IPicture, &iPicture ); + } + GlobalFree( hGlobal ); + } + } + CloseHandle( hFile ); + } + + HB_TCHAR_FREE( image ); + return ( IPicture * ) iPicture; +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtRenderPicture( int x1, int y1, int wd, int ht, IPicture * iPicture ) +{ + LONG lWidth,lHeight; + int x,y,xe,ye; + int c = x1 ; + int r = y1 ; + int dc = wd ; + int dr = ht ; + int tor = 0 ; + int toc = 0 ; + HRGN hrgn1; + POINT lpp; + BOOL bResult = FALSE; + + if ( iPicture ) + { + iPicture->lpVtbl->get_Width( iPicture,&lWidth ); + iPicture->lpVtbl->get_Height( iPicture,&lHeight ); + + if ( dc == 0 ) + { + dc = ( int ) ( ( float ) dr * lWidth / lHeight ); + } + if ( dr == 0 ) + { + dr = ( int ) ( ( float ) dc * lHeight / lWidth ); + } + if ( tor == 0 ) + { + tor = dr; + } + if ( toc == 0 ) + { + toc = dc; + } + x = c; + y = r; + xe = c + toc - 1; + ye = r + tor - 1; + + GetViewportOrgEx( _s.hdc, &lpp ); + + hrgn1 = CreateRectRgn( c+lpp.x, r+lpp.y, xe+lpp.x, ye+lpp.y ); + SelectClipRgn( _s.hdc, hrgn1 ); + + while ( x < xe ) + { + while ( y < ye ) + { + iPicture->lpVtbl->Render( iPicture, _s.hdc, x, y, dc, dr, 0, lHeight, lWidth, -lHeight, NULL ); + y += dr; + } + y = r; + x += dc; + } + + SelectClipRgn( _s.hdc, NULL ); + DeleteObject( hrgn1 ); + + if ( _s.bGui ) + { + x = c; + y = r; + xe = c + toc - 1; + ye = r + tor - 1; + + GetViewportOrgEx( _s.hGuiDC, &lpp ); + + hrgn1 = CreateRectRgn( c+lpp.x, r+lpp.y, xe+lpp.x, ye+lpp.y ); + SelectClipRgn( _s.hGuiDC, hrgn1 ); + + while ( x < xe ) + { + while ( y < ye ) + { + iPicture->lpVtbl->Render( iPicture, _s.hGuiDC, x, y, dc, dr, 0, lHeight, lWidth, -lHeight, NULL ); + y += dr; + } + y = r; + x += dc; + } + + SelectClipRgn( _s.hGuiDC, NULL ); + DeleteObject( hrgn1 ); + } + + bResult = TRUE ; + } + + return( bResult ); +} + +//-------------------------------------------------------------------// + +BOOL HB_EXPORT hb_wvt_gtDestroyPicture( IPicture * iPicture ) +{ + BOOL bResult = FALSE; + + if ( iPicture ) + { + iPicture->lpVtbl->Release( iPicture ); + bResult = TRUE; + } + return bResult; +} + +//-------------------------------------------------------------------// + +GLOBAL_DATA * hb_wvt_gtGetGlobalData( void ) +{ + return &_s; +} + +//-------------------------------------------------------------------// + +HB_EXPORT COLORREF hb_wvt_gtGetColorData( int iIndex ) +{ + return _COLORS[ iIndex ]; +} + +//-------------------------------------------------------------------// + +HB_EXPORT BOOL hb_wvt_gtSetColorData( int iIndex, COLORREF ulCr ) +{ + BOOL bResult = FALSE; + + if ( iIndex >= 0 && iIndex < 16 ) + { + _COLORS[ iIndex ] = ulCr; + bResult = TRUE; + } + return bResult; +} + +//-------------------------------------------------------------------// + +static int kbdShiftsState( void ) +{ + BYTE kbBuffer[ 256 ]; + int kbdShifts; + kbdShifts = 0; + GetKeyboardState( kbBuffer ); + if ( kbBuffer[ VK_SHIFT ] & 0x080 ) kbdShifts += GTI_KBD_SHIFT; + if ( kbBuffer[ VK_CONTROL ] & 0x080 ) kbdShifts += GTI_KBD_CTRL; + if ( kbBuffer[ VK_MENU ] & 0x080 ) kbdShifts += GTI_KBD_ALT; + if ( kbBuffer[ VK_LWIN ] & 0x080 ) kbdShifts += GTI_KBD_LWIN; + if ( kbBuffer[ VK_RWIN ] & 0x080 ) kbdShifts += GTI_KBD_RWIN; + if ( kbBuffer[ VK_APPS ] & 0x080 ) kbdShifts += GTI_KBD_MENU; + if ( kbBuffer[ VK_SCROLL ] & 0x01 ) kbdShifts += GTI_KBD_SCROLOCK; + if ( kbBuffer[ VK_NUMLOCK ] & 0x01 ) kbdShifts += GTI_KBD_NUMLOCK; + if ( kbBuffer[ VK_CAPITAL ] & 0x01 ) kbdShifts += GTI_KBD_CAPSLOCK; + return kbdShifts; +} + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// GT Specific Functions +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_Init( FHANDLE iFilenoStdin, FHANDLE iFilenoStdout, FHANDLE iFilenoStderr ) ) +{ + /* FSG: filename var for application name */ + PHB_FNAME pFileName; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Init()" ) ); + + /* stdin && stdout && stderr */ + s_iStdIn = iFilenoStdin; + s_iStdOut = iFilenoStdout; + s_iStdErr = iFilenoStderr; + + s_usOldCurStyle = s_usCursorStyle = SC_NORMAL; + + gt_hbInitStatics(); + + _s.hWnd = hb_wvt_gtCreateWindow( ( HINSTANCE ) hb_hInstance, ( HINSTANCE ) hb_hPrevInstance, "", hb_iCmdShow ); + if ( !_s.hWnd ) + { + hb_errRT_TERM( EG_CREATE, 10001, "WINAPI CreateWindow() failed", "hb_gt_Init()", 0, 0 ); + } + pFileName = hb_fsFNameSplit( hb_cmdargARGV()[0] ); + hb_wvt_gtSetWindowTitle( pFileName->szName ); + hb_xfree( pFileName ); + + hb_wvt_gtCreateObjects(); + _s.hdc = GetDC( _s.hWnd ); + _s.hCompDC = CreateCompatibleDC( _s.hdc ); + hb_wvt_gtInitGui(); + +#ifndef HB_CDP_SUPPORT_OFF + _s.hostCDP = hb_cdp_page; + _s.inCDP = hb_cdp_page; +#endif + + if( b_MouseEnable ) + { + //HB_GT_FUNC( mouse_Init() ); + hb_wvt_gtSetMouseX( 0 ); + hb_wvt_gtSetMouseY( 0 ); + } + + if( b_MouseEnable ) + { + hb_wvt_gtCreateToolTipWindow(); + } +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_Exit( void ) ) +{ + int i; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Exit()" ) ); + + if ( _s.hWnd ) + { + for ( i = 0; i < WVT_DLGML_MAX; i++ ) + { + if ( _s.hDlgModeless[ i ] ) + { + SendMessage( _s.hDlgModeless[ i ], WM_CLOSE, 0, 0 ); + } + } + + DeleteObject( ( HPEN ) _s.penWhite ); + DeleteObject( ( HPEN ) _s.penWhiteDim ); + DeleteObject( ( HPEN ) _s.penBlack ); + DeleteObject( ( HPEN ) _s.penDarkGray ); + DeleteObject( ( HPEN ) _s.penGray ); + DeleteObject( ( HPEN ) _s.penNull ); + DeleteObject( ( HPEN ) _s.currentPen ); + DeleteObject( ( HBRUSH ) _s.currentBrush ); + DeleteObject( ( HBRUSH ) _s.diagonalBrush ); + DeleteObject( ( HBRUSH ) _s.solidBrush ); + DeleteObject( ( HBRUSH ) _s.wvtWhiteBrush ); + + if ( _s.hdc ) + { + ReleaseDC( _s.hWnd, _s.hdc ); + } + + if ( _s.hCompDC ) + { + DeleteDC( _s.hCompDC ); + } + if ( _s.hGuiDC ) + { + DeleteDC( _s.hGuiDC ); + } + if ( _s.hGuiBmp ) + { + DeleteObject( _s.hGuiBmp ); + } + + + for ( i = 0; i < WVT_PICTURES_MAX; i++ ) + { + if ( _s.iPicture[ i ] ) + { + hb_wvt_gtDestroyPicture( _s.iPicture[ i ] ); + } + } + for ( i = 0; i < WVT_FONTS_MAX; i++ ) + { + if ( _s.hUserFonts[ i ] ) + { + DeleteObject( _s.hUserFonts[ i ] ); + } + } + for ( i = 0; i < WVT_PENS_MAX; i++ ) + { + if ( _s.hUserPens[ i ] ) + { + DeleteObject( _s.hUserPens[ i ] ); + } + } + if ( _s.hMSImg32 ) + { + FreeLibrary( _s.hMSImg32 ); + } + + DestroyWindow( _s.hWnd ); + } + UnregisterClass( szAppName,( HINSTANCE ) hb_hInstance ); + + if( b_MouseEnable ) + { + //HB_GT_FUNC( mouse_Exit() ); + } +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_ProcessMessages( void ) ) +{ + hb_wvt_gtProcessMessages(); +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_GetClipboard( char *szData, ULONG *pulMaxSize ) ) +{ + HGLOBAL hglb; + LPTSTR lptstr; + UINT uFormat = ( _s.CodePage == OEM_CHARSET ) ? CF_OEMTEXT : CF_TEXT; + + if ( ! IsClipboardFormatAvailable( uFormat ) ) + { + *pulMaxSize = 0; + return; + } + + if ( !OpenClipboard( NULL ) ) + { + *pulMaxSize = 0; + return; + } + + hglb = GetClipboardData( uFormat ); + if ( hglb != NULL ) + { + lptstr = ( LPTSTR ) GlobalLock( hglb ); + if ( lptstr != NULL ) + { + ULONG iLen = strlen( lptstr ); + + if ( *pulMaxSize == 0 || *pulMaxSize > iLen ) + { + *pulMaxSize = iLen; + } + + // still nothing ? + // + if ( *pulMaxSize == 0 ) + { + return; + } + + memcpy( szData, lptstr, *pulMaxSize ); + szData[ *pulMaxSize ] = '\0'; + + GlobalUnlock( hglb ); + } + } + CloseClipboard(); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( gt_SetClipboard( char *szData, ULONG ulSize ) ) +{ + LPTSTR lptstrCopy; + HGLOBAL hglbCopy; + UINT uFormat = ( _s.CodePage == OEM_CHARSET ) ? CF_OEMTEXT : CF_TEXT; + +/* This poses problems when some other application copies a bitmap on the + clipboard. The only way to set text to clipboard is made possible + only if another application copies some text on the clipboard. + + if ( !IsClipboardFormatAvailable( CF_TEXT ) ) + { + return; + } +*/ + + if ( ! OpenClipboard( NULL ) ) + { + return; + } + EmptyClipboard(); + + // Allocate a global memory object for the text. + // + hglbCopy = GlobalAlloc( GMEM_MOVEABLE, ( ulSize+1 ) * sizeof( TCHAR ) ); + if ( ! hglbCopy ) + { + CloseClipboard(); + return; + } + + // Lock the handle and copy the text to the buffer. + // + lptstrCopy = ( LPTSTR ) GlobalLock( hglbCopy ); // LPSTR + + memcpy( lptstrCopy, szData, ( ulSize+1 ) * sizeof( TCHAR ) ); + + lptstrCopy[ ulSize+1 ] = ( TCHAR ) 0; // null character + + GlobalUnlock( hglbCopy ); + + // Place the handle on the clipboard. + // + SetClipboardData( uFormat, hglbCopy ); + + CloseClipboard(); +} + +//-------------------------------------------------------------------// + +static ULONG HB_GT_FUNC( gt_GetClipboardSize( void ) ) +{ + HGLOBAL hglb; + LPTSTR lptstr; + UINT uFormat = ( _s.CodePage == OEM_CHARSET ) ? CF_OEMTEXT : CF_TEXT; + int ret; + + if ( !IsClipboardFormatAvailable( uFormat ) ) + { + return 0; + } + + if ( ! OpenClipboard( NULL ) ) + { + return 0; + } + + hglb = GetClipboardData( uFormat ); + ret = 0; + if ( hglb != NULL ) + { + lptstr = ( LPTSTR ) GlobalLock( hglb ); // LPSTR + if ( lptstr != NULL ) + { + ret = strlen( lptstr ); + GlobalUnlock( hglb ); + } + } + CloseClipboard(); + return ret; +} + +//-------------------------------------------------------------------// +// +// returns the number of displayable columns +// +static USHORT HB_GT_FUNC( gt_GetScreenWidth( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetScreenWidth()" ) ); + return _GetScreenWidth(); +} + +//-------------------------------------------------------------------// +// +// returns the number of displayable rows +// +static USHORT HB_GT_FUNC( gt_GetScreenHeight( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetScreenHeight()")); + return _GetScreenHeight(); +} + +//-------------------------------------------------------------------// + +static SHORT HB_GT_FUNC( gt_Col( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Col()" ) ); + return( (SHORT) _s.caretPos.x ); +} + +//-------------------------------------------------------------------// + +static SHORT HB_GT_FUNC( gt_Row( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Row()" ) ); + return( (SHORT) _s.caretPos.y ); +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_SetPos( int sRow, int sCol ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetPos( %hd, %hd )", sRow, sCol ) ); + + if ( sRow >= 0 && sRow< _GetScreenHeight() && sCol>=0 && sCol <= _GetScreenWidth() ) + { + _s.caretPos.x = sCol; + _s.caretPos.y = sRow; + hb_wvt_gtValidateCaret(); + } +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_GetPos( int * sRow, int * sCol ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetPos( %hd, %hd, %hd )", sRow, sCol, sMethod ) ); + + *sCol = _s.caretPos.x; + *sRow = _s.caretPos.y; +} + +//-------------------------------------------------------------------// +/* +static BOOL HB_GT_FUNC( gt_AdjustPos( BYTE * pStr, ULONG ulLen ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_AdjustPos( %s, %lu )", pStr, ulLen ) ); + + HB_SYMBOL_UNUSED( pStr ); + HB_SYMBOL_UNUSED( ulLen ); + + return( FALSE ); +} +*/ +//-------------------------------------------------------------------// + +static BOOL HB_GT_FUNC( gt_IsColor( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_IsColor()" ) ); + return( TRUE ); +} + +//-------------------------------------------------------------------// + +int HB_GT_FUNC( gt_GetCursorStyle( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetCursorStyle()" ) ); + return( s_usCursorStyle ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( gt_SetCursorStyle( int usStyle ) ) +{ + BOOL bCursorOn= TRUE; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetCursorStyle( %hu )", usStyle ) ); + + s_usCursorStyle = usStyle; + switch( usStyle ) + { + case SC_NONE: + _s.CaretSize = 0 ; + bCursorOn= FALSE; + break ; + case SC_INSERT: + _s.CaretSize = ( _s.PTEXTSIZE.y / 2 ) ; + break; + case SC_SPECIAL1: + _s.CaretSize = _s.PTEXTSIZE.y ; + break; + case SC_SPECIAL2: + _s.CaretSize = -( _s.PTEXTSIZE.y / 2 ) ; + break; + case SC_NORMAL: + default: + _s.CaretSize = 4 ; + break; + } + if ( bCursorOn ) + { + _s.CaretExist = CreateCaret( _s.hWnd, ( HBITMAP ) NULL, _s.PTEXTSIZE.x, _s.CaretSize ); + } + + hb_wvt_gtSetCaretOn( bCursorOn ); +} + +//-------------------------------------------------------------------// + +static int HB_GT_FUNC( gt_MaxCol( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_MaxCol()")); + return( ( int )_GetScreenWidth()-1 ); +} + +//-------------------------------------------------------------------// + +static int HB_GT_FUNC( gt_MaxRow( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_MaxRow()")); + return( ( int )_GetScreenHeight()-1 ); +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_DispBegin( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_DispBegin()" ) ); + ++s_uiDispCount; +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_DispEnd() ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_DispEnd()" ) ); + + if ( s_uiDispCount > 0 ) + { + --s_uiDispCount; + } + if ( s_uiDispCount<= 0 ) + { + hb_wvt_gtDoInvalidateRect(); + } +} + +//-------------------------------------------------------------------// + +static int HB_GT_FUNC( gt_DispCount() ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_DispCount()" ) ); + return( s_uiDispCount ); +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_Replicate( USHORT usRow, USHORT usCol, BYTE byAttr, BYTE byChar, ULONG ulLen ) ) +{ + BYTE ucBuff[ WVT_CHAR_BUFFER ], *byChars; + ULONG i; + BOOL bMalloc = FALSE; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Replicate( %hu, %hu, %i, %i, %lu )", usRow, usCol, byAttr, byChar, ulLen ) ); + + if ( ulLen > WVT_CHAR_BUFFER ) + { // Avoid allocating memory if possible + byChars = ( BYTE* ) hb_xgrab( ulLen ); + bMalloc= TRUE; + } + else + { + byChars = ucBuff ; + } + + for ( i = 0; i < ulLen; i++ ) + { + *( byChars+i ) = byChar; + } + + hb_wvt_gtSetStringInTextBuffer( (SHORT) usCol, (SHORT) usRow, byAttr, byChars, (SHORT) ulLen ); + if ( bMalloc ) + { + hb_xfree( byChars ); + } +} + +//-------------------------------------------------------------------// +/* +static int HB_GT_FUNC( gt_RectSize( USHORT rows, USHORT cols ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_RectSize()" ) ); + return( rows * cols * 2 ); +} +*/ +//-------------------------------------------------------------------// + +void hb_wvt_GetStringAttrib( USHORT top, USHORT left, USHORT bottom, USHORT right, BYTE * sBuffer, BYTE * sAttrib ) +{ + USHORT irow, icol, index, j; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetText( %hu, %hu, %hu, %hu, %p )", top, left, bottom, right, sBuffer ) ); + + j = 0; + for ( irow = top; irow <= bottom; irow++ ) + { + index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); + for ( icol = left; icol <= right; icol++ ) + { + if ( index >= _s.BUFFERSIZE ) + { + break; + } + else + { + sBuffer[ j ] = _s.pBuffer[ index ]; + sAttrib[ j ] = _s.pAttributes[ index ]; + index++; + j++; + } + } + } +} + +//----------------------------------------------------------------------// + +void hb_wvt_PutStringAttrib( USHORT top, USHORT left, USHORT bottom, USHORT right, BYTE * sBuffer, BYTE * sAttrib ) +{ + USHORT irow, icol, index, j; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetText( %hu, %hu, %hu, %hu, %p )", top, left, bottom, right, sBuffer ) ); + + j = 0; + for ( irow = top; irow <= bottom; irow++ ) + { + index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); + for ( icol = left; icol <= right; icol++ ) + { + if ( index >= _s.BUFFERSIZE ) + { + break; + } + else + { + _s.pBuffer[ index ] = sBuffer[ j ]; + _s.pAttributes[ index ] = sAttrib[ j ]; + j++; + index++; + } + } + } + hb_wvt_gtSetInvalidRect( left, top, right, bottom ); +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_GetText( int top, int left, int bottom, int right, BYTE * sBuffer ) ) +{ + USHORT irow, icol, index, j; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetText( %hu, %hu, %hu, %hu, %p )", top, left, bottom, right, sBuffer ) ); + + j = 0; + for ( irow = top; irow <= bottom; irow++ ) + { + index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); + for ( icol = left; icol <= right; icol++ ) + { + if ( index >= _s.BUFFERSIZE ) + { + break; + } + else + { + sBuffer[ j++ ] = _s.pBuffer[ index ]; + sBuffer[ j++ ] = _s.pAttributes[ index ]; + index++; + } + } + } +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_Puts( USHORT usRow, USHORT usCol, BYTE byAttr, BYTE *pbyStr, ULONG ulLen ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Puts( %hu, %hu, %d, %p, %hu )", usRow, usCol, ( int ) byAttr, pbyStr, ulLen ) ); + hb_wvt_gtSetStringInTextBuffer( (SHORT) usCol, (SHORT) usRow, byAttr, pbyStr, (SHORT) ulLen ); +} + +//-------------------------------------------------------------------// +// FOR RestScrn() +// +static void HB_GT_FUNC( gt_xPutText( int top, int left, int bottom, int right, BYTE * sBuffer ) ) +{ + USHORT irow, icol, index, j; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_XPutText( %hu, %hu, %hu, %hu, %s )", top, left, bottom, right, *sBuffer ) ); + + j = 0; + for ( irow = top; irow <= bottom; irow++ ) + { + index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); + for ( icol = left; icol <= right; icol++ ) + { + if ( index >= _s.BUFFERSIZE ) + { + break; + } + else + { + _s.pBuffer[ index ] = sBuffer[ j++ ]; + _s.pAttributes[ index ] = sBuffer[ j++ ]; + index++; + } + } + } + hb_wvt_gtSetInvalidRect( left, top, right, bottom ); +} + +//----------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_PutText( int top, int left, BYTE bColor, BYTE * pText, ULONG ulLen ) ) +{ + USHORT irow, icol, index, j, right; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_PutText( %hu, %hu, %hu, %hu, %p )", top, left, bottom, right, sBuffer ) ); + + j = 0; + irow = top; + right = left + ulLen - 1; + + index = hb_wvt_gtGetIndexForTextBuffer( left, irow ); + for ( icol = left; icol <= right; icol++ ) + { + if ( index >= _s.BUFFERSIZE ) + { + break; + } + else + { + _s.pBuffer[ index ] = pText[ j++ ]; + _s.pAttributes[ index ] = bColor; + index++; + } + } + hb_wvt_gtSetInvalidRect( left, top, right, top ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( gt_SetAttribute( int rowStart, int colStart, int rowStop, int colStop, BYTE attr ) ) +{ + USHORT irow, icol, index; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetAttribute( %hu, %hu, %hu, %hu, %d", rowStart, colStart, rowStop, colStop, ( int ) attr ) ); + + for ( irow = rowStart; irow <=rowStop; irow++ ) + { + index = hb_wvt_gtGetIndexForTextBuffer( colStart, irow ); + for ( icol = colStart; icol <= colStop; icol++ ) + { + if ( index >= _s.BUFFERSIZE ) + { + break; + } + else + { + _s.pAttributes[ index++ ] = attr; + } + } + } + hb_wvt_gtSetInvalidRect( colStart, rowStart, colStop, rowStop ); +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_SetAttributeCT( USHORT rowStart, USHORT colStart, USHORT rowStop, USHORT colStop, BYTE attr ) ) +{ + USHORT irow, icol, index; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetAttributeCT( %hu, %hu, %hu, %hu, %d", rowStart, colStart, rowStop, colStop, ( int ) attr ) ); + + for ( irow = rowStart; irow <=rowStop; irow++ ) + { + index = hb_wvt_gtGetIndexForTextBuffer( colStart, irow ); + for ( icol = colStart; icol <= colStop; icol++ ) + { + if ( index >= _s.BUFFERSIZE ) + { + break; + } + else + { + if ( _s.pAttributes[ index ] != attr && _s.pAttributes[ index ] ) + { + _s.pAttributes[ index++ ] = attr; + } + else + { + _s.pAttributes[ index++ ] = 0; + } + } + } + } + hb_wvt_gtSetInvalidRect( colStart, rowStart, colStop, rowStop ); +} + +//-------------------------------------------------------------------// +// +// copied from gtwin... +// +void HB_GT_FUNC( gt_Scroll( int usTop, int usLeft, int usBottom, int usRight, BYTE byAttr, BYTE byChar, int iRows, int iCols ) ) +{ + SHORT usSaveRow, usSaveCol; + BYTE ucBlank[ WVT_CHAR_BUFFER ], ucBuff[ WVT_CHAR_BUFFER * 2 ] ; + BYTE * fpBlank ; + BYTE * fpBuff ; + int iLength = ( usRight - usLeft ) + 1; + int iCount, iColOld, iColNew, iColSize; + BOOL bMalloc = FALSE; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Scroll( %hu, %hu, %hu, %hu, %d, %hd, %hd )", usTop, usLeft, usBottom, usRight, ( int ) byAttr, iRows, iCols ) ); + + if ( iLength > WVT_CHAR_BUFFER ) + { // Avoid allocating memory if possible + fpBlank = ( BYTE * ) hb_xgrab( iLength ); + fpBuff = ( BYTE * ) hb_xgrab( iLength * 2 ); + bMalloc = TRUE; + } + else + { + fpBlank = ucBlank ; + fpBuff = ucBuff ; + } + + memset( fpBlank, byChar /*' ' or hb_ctGetClearB()*/, iLength ); + + iColOld = iColNew = usLeft; + iColSize = iLength -1; + if( iCols >= 0 ) + { + iColOld += iCols; + iColSize -= iCols; + } + else + { + iColNew -= iCols; + iColSize += iCols; + } + // use the ScrollWindowEx() where possible ( Optimised for Terminal Server ) + // if both iCols & iRows are ZERO then the entire area is to be cleared and + // there is no advantage in using ScrollWindowEx() + // + _s.InvalidateWindow = HB_GT_FUNC( gt_DispCount() ) > 0 || ( !iRows && !iCols ) ; + + // if _s.InvalidateWindow is FALSE it is used to stop + // HB_GT_FUNC( gt_Puts() ) & HB_GT_FUNC( gt_PutText() ) + // from actually updating the screen. ScrollWindowEx() is used + // + if ( _s.InvalidateWindow ) + { + HB_GT_FUNC( gt_DispBegin() ); + } + + usSaveCol = HB_GT_FUNC( gt_Col() ) ; + usSaveRow = HB_GT_FUNC( gt_Row() ) ; + for( iCount = ( iRows >= 0 ? usTop : usBottom ); + ( iRows >= 0 ? iCount <= usBottom : iCount >= usTop ); + ( iRows >= 0 ? iCount++ : iCount-- ) ) + { + int iRowPos = iCount + iRows; + + /* Read the text to be scrolled into the current row */ + if( ( iRows || iCols ) && iRowPos <= usBottom && iRowPos >= usTop ) + { + HB_GT_FUNC( gt_GetText( iRowPos, iColOld, iRowPos, iColOld + iColSize, fpBuff ) ); + } + + /* Blank the scroll region in the current row */ + HB_GT_FUNC( gt_Puts( iCount, usLeft, byAttr, fpBlank, iLength ) ); + + /* Write the scrolled text to the current row */ + if( ( iRows || iCols ) && iRowPos <= usBottom && iRowPos >= usTop ) + { + // TO RESTORE + HB_GT_FUNC( gt_xPutText( iCount, iColNew, iCount, iColNew + iColSize, fpBuff ) ); + } + } + HB_GT_FUNC( gt_SetPos( usSaveRow, usSaveCol /*, 0 HB_GT_SET_POS_AFTER*/ ) ); + + if ( _s.InvalidateWindow ) + { + HB_GT_FUNC( gt_DispEnd() ); + } + else + { + RECT cr, crInvalid; + + cr.left = usLeft + ( iCols>0 ? 1 : 0 ) ; + cr.top = usTop + ( iRows>0 ? 1 : 0 ) ; + cr.right = usRight - ( iCols<0 ? 1 : 0 ) ; + cr.bottom = usBottom - ( iRows<0 ? 1 : 0 ) ; + + cr = hb_wvt_gtGetXYFromColRowRect( cr ); + ScrollWindowEx( _s.hWnd, -iCols * _s.PTEXTSIZE.x, -iRows *_s.PTEXTSIZE.y, &cr, NULL, NULL, &crInvalid, 0 ) ; + InvalidateRect( _s.hWnd, &crInvalid, FALSE ); + _s.InvalidateWindow = TRUE ; + } + + if ( bMalloc ) + { + hb_xfree( fpBlank ); + hb_xfree( fpBuff ); + } +} + +//-------------------------------------------------------------------// +// +// resize the ( existing ) window +// +BOOL HB_GT_FUNC( gt_SetMode( int row, int col ) ) +{ + BOOL bResult= FALSE; + HFONT hFont; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetMode( %hu, %hu )", row, col ) ); + + if ( row<= WVT_MAX_ROWS && col<= WVT_MAX_COLS ) + { + // Is the window already open + if ( _s.hWnd ) + { + hFont = hb_wvt_gtGetFont( _s.fontFace, _s.fontHeight, _s.fontWidth, _s.fontWeight, _s.fontQuality, _s.CodePage ); + if ( hFont ) + { + // make sure that the mode selected along with the current + // font settings will fit in the window + if ( hb_wvt_gtValidWindowSize( row,col, hFont, _s.fontWidth ) ) + { + bResult = hb_wvt_gtInitWindow( _s.hWnd, col, row ); + } + DeleteObject( hFont ); + } + } + else + { + hb_wvt_gtAllocSpBuffer( row, col ); + } + } + return( bResult ); +} + +//-------------------------------------------------------------------// + +static BOOL HB_GT_FUNC( gt_GetBlink( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_GetBlink()" ) ); + return( TRUE ); +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_SetBlink( BOOL bBlink ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_SetBlink( %d )", ( int ) bBlink ) ); + HB_SYMBOL_UNUSED( bBlink ); +} + +//-------------------------------------------------------------------// + +static char * HB_GT_FUNC( gt_Version( int iType ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_Version()" ) ); + + if ( iType == 0 ) + { + return HB_GT_DRVNAME( HB_GT_NAME ); + } + return "Harbour Terminal: Win32 buffered Graphical WVG"; +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_xPutch( USHORT iRow, USHORT iCol, BYTE bAttr, BYTE bChar ) ) +{ + USHORT index; + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_xPutch( %hu, %hu, %d, %i )", iRow, iCol, ( int ) bAttr, bChar ) ); + + index = hb_wvt_gtGetIndexForTextBuffer( iCol, iRow ); + if ( index < _s.BUFFERSIZE ) + { + _s.pBuffer[ index ] = bChar; + _s.pAttributes[ index ] = bAttr; + + // determine bounds of rect around character to refresh + // + hb_wvt_gtSetInvalidRect( iCol, iRow, iCol, iRow ); + } +} + +//-------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_Box( int Top, int Left, int Bottom, int Right, BYTE * szBox, BYTE byAttr ) ) +{ + SHORT Row; + SHORT Col; + SHORT Height; + SHORT Width; + USHORT sWidth = _GetScreenWidth(), + sHeight = _GetScreenHeight(); + + if( ( Left >= 0 && Left < sWidth ) || + ( Right >= 0 && Right < sWidth ) || + ( Top >= 0 && Top < sHeight ) || + ( Bottom >= 0 && Bottom < sHeight ) ) + { + /* Ensure that box is drawn from top left to bottom right. */ + if( Top > Bottom ) + { + Row = Top; + Top = Bottom; + Bottom = Row; + } + + if( Left > Right ) + { + Row = Left; + Left = Right; + Right = Row; + } + + /* Draw the box or line as specified */ + Height = Bottom - Top + 1; + Width = Right - Left + 1; + + HB_GT_FUNC( gt_DispBegin() ); + + if( Height > 1 && Width > 1 && Top >= 0 && Top < sHeight && Left >= 0 && Left < sWidth ) + { + HB_GT_FUNC( gt_xPutch( Top, Left, byAttr, szBox[ 0 ] ) ); /* Upper left corner */ + } + + Col = ( Width > 1 ? Left + 1 : Left ); + + if( Col < 0 ) + { + Width += Col; + Col = 0; + } + + if( Right >= sWidth ) + { + Width -= Right - sWidth; + } + + if( Col < Right && Col < sWidth && Top >= 0 && Top < sHeight ) + { + HB_GT_FUNC( gt_Replicate( Top, Col, byAttr, szBox[ 1 ], Width + ( (Right - Left) > 1 ? -2 : 0 ) )); /* Top line */ + } + + if( Height > 1 && (Right - Left) > 0 && Right < sWidth && Top >= 0 && Top < sHeight ) + { + HB_GT_FUNC( gt_xPutch( Top, Right, byAttr, szBox[ 2 ] ) ); /* Upper right corner */ + } + + if( szBox[ 8 ] && Height > 2 && Width > 2 ) + { + for( Row = Top + 1; Row < Bottom; Row++ ) + { + if( Row >= 0 && Row < sHeight ) + { + Col = Left; + + if( Col < 0 ) + { + Col = 0; /* The width was corrected earlier. */ + } + else + { + HB_GT_FUNC( gt_xPutch( Row, Col++, byAttr, szBox[ 7 ] ) ); /* Left side */ + } + + HB_GT_FUNC( gt_Replicate( Row, Col, byAttr, szBox[ 8 ], Width - 2 ) ); /* Fill */ + + if( Right < sWidth ) + { + HB_GT_FUNC( gt_xPutch( Row, Right, byAttr, szBox[ 3 ] )); /* Right side */ + } + } + } + } + else + { + for( Row = ( Width > 1 ? Top + 1 : Top ); Row < ( (Right - Left ) > 1 ? Bottom : Bottom + 1 ); Row++ ) + { + if( Row >= 0 && Row < sHeight ) + { + if( Left >= 0 && Left < sWidth ) + { + HB_GT_FUNC(gt_xPutch( Row, Left, byAttr, szBox[ 7 ] )); /* Left side */ + } + + if( ( Width > 1 || Left < 0 ) && Right < sWidth ) + { + HB_GT_FUNC(gt_xPutch( Row, Right, byAttr, szBox[ 3 ] )); /* Right side */ + } + } + } + } + + if( Height > 1 && Width > 1 ) + { + if( Left >= 0 && Bottom < sHeight ) + { + HB_GT_FUNC(gt_xPutch( Bottom, Left, byAttr, szBox[ 6 ] )); /* Bottom left corner */ + } + + Col = Left + 1; + + if( Col < 0 ) + { + Col = 0; /* The width was corrected earlier. */ + } + + if( Col <= Right && Bottom < sHeight ) + { + HB_GT_FUNC(gt_Replicate( Bottom, Col, byAttr, szBox[ 5 ], Width - 2 )); /* Bottom line */ + } + + if( Right < sWidth && Bottom < sHeight ) + { + HB_GT_FUNC(gt_xPutch( Bottom, Right, byAttr, szBox[ 4 ] )); /* Bottom right corner */ + } + } + + HB_GT_FUNC( gt_DispEnd() ); + } +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( gt_BoxD( int Top, int Left, int Bottom, int Right, BYTE * pbyFrame, BYTE byAttr ) ) +{ + HB_GT_FUNC( gt_Box( Top, Left, Bottom, Right, pbyFrame, byAttr ) ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( gt_BoxS( int Top, int Left, int Bottom, int Right, BYTE * pbyFrame, BYTE byAttr ) ) +{ + HB_GT_FUNC( gt_Box( Top, Left, Bottom, Right, pbyFrame, byAttr ) ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( gt_HorizLine( int Row, int Left, int Right, BYTE byChar, BYTE byAttr ) ) +{ + USHORT sWidth = _GetScreenWidth(); + + if( Row >= 0 && Row < sWidth ) + { + if( Left < 0 ) + { + Left = 0; + } + else if( Left >= sWidth ) + { + Left = sWidth - 1; + } + if( Right < 0 ) + { + Right = 0; + } + else if( Right >= sWidth ) + { + Right = sWidth - 1; + } + if( Left < Right ) + { + HB_GT_FUNC( gt_Replicate( Row, Left, byAttr, byChar, Right - Left + 1 ) ); + } + else + { + HB_GT_FUNC( gt_Replicate( Row, Right, byAttr, byChar, Left - Right + 1 ) ); + } + } +} + +//-------------------------------------------------------------------// +// +void HB_GT_FUNC( gt_VertLine( int Col, int Top, int Bottom, BYTE byChar, BYTE byAttr ) ) +{ + USHORT sWidth = _GetScreenWidth(); + USHORT sHeight = _GetScreenHeight(); + SHORT Row; + + if( Col >= 0 && Col < sWidth ) + { + if( Top < 0 ) + { + Top = 0; + } + else if( Top >= sHeight ) + { + Top = sHeight - 1; + } + if( Bottom < 0 ) + { + Bottom = 0; + } + else if( Bottom >= sHeight ) + { + Bottom = sHeight - 1; + } + if( Top <= Bottom ) + { + Row = Top; + } + else + { + Row = Bottom; + Bottom = Top; + } + + HB_GT_FUNC( gt_DispBegin() ); + + while( Row <= Bottom ) + { + HB_GT_FUNC( gt_xPutch( Row++, Col, byAttr, byChar ) ); + } + + HB_GT_FUNC( gt_DispEnd() ); + } +} + +//-------------------------------------------------------------------// + +BOOL HB_GT_FUNC( gt_Suspend() ) +{ + return( TRUE ); +} + +//-------------------------------------------------------------------// + +BOOL HB_GT_FUNC( gt_Resume() ) +{ + return( TRUE ); +} + +//-------------------------------------------------------------------// + +BOOL HB_GT_FUNC( gt_PreExt() ) +{ + return( TRUE ); +} + +//-------------------------------------------------------------------// + +BOOL HB_GT_FUNC( gt_PostExt() ) +{ + return( TRUE ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( gt_OutStd( BYTE * pbyStr, ULONG ulLen ) ) +{ + hb_fsWriteLarge( s_iStdOut, ( BYTE * ) pbyStr, ulLen ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( gt_OutErr( BYTE * pbyStr, ULONG ulLen ) ) +{ + hb_fsWriteLarge( s_iStdErr, ( BYTE * ) pbyStr, ulLen ); +} + +//-------------------------------------------------------------------// + +int HB_GT_FUNC( gt_ExtendedKeySupport() ) +{ + return( FALSE ); // Only use standard Clipper hey handling +} + +//-------------------------------------------------------------------// + +int HB_GT_FUNC( gt_ReadKey() ) +{ + int c = 0; + BOOL bKey; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_ReadKey( %d )", ( int ) eventmask ) ); + + hb_wvt_gtProcessMessages() ; + bKey = hb_wvt_gtGetCharFromInputQueue( &c ); + + return( bKey ? c : 0 ); +} + +//----------------------------------------------------------------------// + +static BOOL HB_GT_FUNC( gt_Info( int iType, PHB_GT_INFO pInfo ) ) +{ + int iVal; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Info(%d,%p)", iType, pInfo ) ); + + switch( iType ) + { + case GTI_FULLSCREEN: + case GTI_KBDSUPPORT: + case GTI_ISGRAPHIC: + pInfo->pResult = hb_itemPutL( pInfo->pResult, TRUE ); + break; + + case GTI_INPUTFD: + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, + ( UINT_PTR ) GetStdHandle( STD_INPUT_HANDLE ) ); + break; + + case GTI_OUTPUTFD: + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, + ( UINT_PTR ) GetStdHandle( STD_OUTPUT_HANDLE ) ); + break; + + case GTI_ERRORFD: + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, + ( UINT_PTR ) GetStdHandle( STD_ERROR_HANDLE ) ); + break; + + case GTI_FONTSIZE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.PTEXTSIZE.y ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 ) + { + HFONT hFont = hb_wvt_gtGetFont( _s.fontFace, iVal, _s.fontWidth, _s.fontWeight, _s.fontQuality, _s.CodePage ); + if ( hFont ) + { + _s.fontHeight = iVal; + if ( _s.hWnd ) + { + hb_wvt_gtResetWindowSize( _s.hWnd ); + hb_wvt_gtUpdateCaret(); + } + DeleteObject( hFont ); + } + } + break; + + case GTI_FONTWIDTH: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.fontWidth ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 ) + { + /* store font status for next operation on fontsize */ + _s.fontWidth = iVal; + } + break; + + case GTI_FONTNAME: + pInfo->pResult = hb_itemPutC( pInfo->pResult, _s.fontFace ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) /* TODO */ + { + hb_strncpy( _s.fontFace, hb_itemGetCPtr( pInfo->pNewVal ), LF_FACESIZE - 1 ); + } + break; + + case GTI_FONTWEIGHT: + switch( _s.fontWeight ) + { + case FW_THIN: + case FW_EXTRALIGHT: + case FW_LIGHT: + iVal = GTI_FONTW_THIN; + break; + + case FW_DONTCARE: + case FW_NORMAL: + case FW_MEDIUM: + iVal = GTI_FONTW_NORMAL; + break; + + case FW_SEMIBOLD: + case FW_BOLD: + case FW_EXTRABOLD: + case FW_HEAVY: + iVal = GTI_FONTW_BOLD; + break; + + default: + iVal = 0; + break; + } + pInfo->pResult = hb_itemPutNI( pInfo->pResult, iVal ); + if ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + /* store font status for next operation on fontsize */ + switch( hb_itemGetNI( pInfo->pNewVal ) ) + { + case GTI_FONTW_THIN: + _s.fontWeight = FW_LIGHT; + break; + case GTI_FONTW_NORMAL: + _s.fontWeight = FW_NORMAL; + break; + case GTI_FONTW_BOLD: + _s.fontWeight = FW_BOLD; + break; + } + } + break; + + case GTI_FONTQUALITY: + switch( _s.fontQuality ) + { + case ANTIALIASED_QUALITY: + iVal = GTI_FONTQ_HIGH; + break; + case DEFAULT_QUALITY: + case DRAFT_QUALITY: + iVal = GTI_FONTQ_NORMAL; + break; + case NONANTIALIASED_QUALITY: + case PROOF_QUALITY: + iVal = GTI_FONTQ_DRAFT; + break; + default: + iVal = 0; + break; + } + pInfo->pResult = hb_itemPutNI( pInfo->pResult, iVal ); + if ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + switch( hb_itemGetNI( pInfo->pNewVal ) ) + { + case GTI_FONTQ_HIGH: + _s.fontQuality = ANTIALIASED_QUALITY; + break; + case GTI_FONTQ_NORMAL: + _s.fontQuality = DEFAULT_QUALITY; + break; + case GTI_FONTQ_DRAFT: + _s.fontQuality = DRAFT_QUALITY; + break; + } + } + break; + + case GTI_SCREENHEIGHT: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.PTEXTSIZE.y * _s.ROWS ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 ) + { + HB_GT_FUNC( gt_SetMode( (int) ( iVal / _s.PTEXTSIZE.y ), _s.COLS ) ); + } + break; + + case GTI_SCREENWIDTH: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.PTEXTSIZE.x * _s.COLS ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 ) + { + HB_GT_FUNC( gt_SetMode( _s.ROWS, (int) ( iVal / _s.PTEXTSIZE.x ) ) ); + } + break; + + case GTI_DESKTOPWIDTH: + { + RECT rDesk; + HWND hDesk; + + hDesk = GetDesktopWindow(); + GetWindowRect( hDesk, &rDesk ); + pInfo->pResult = hb_itemPutNI( pInfo->pResult, rDesk.right - rDesk.left ); + break; + } + case GTI_DESKTOPHEIGHT: + { + RECT rDesk; + HWND hDesk = GetDesktopWindow(); + GetWindowRect( hDesk, &rDesk ); + pInfo->pResult = hb_itemPutNI( pInfo->pResult, rDesk.bottom - rDesk.top ); + break; + } + case GTI_DESKTOPCOLS: + { + RECT rDesk; + HWND hDesk; + hDesk = GetDesktopWindow(); + GetClientRect( hDesk, &rDesk ); + pInfo->pResult = hb_itemPutNI( pInfo->pResult, + ( rDesk.right - rDesk.left ) / _s.PTEXTSIZE.x ); + break; + } + case GTI_DESKTOPROWS: + { + RECT rDesk; + HWND hDesk; + hDesk = GetDesktopWindow(); + GetClientRect( hDesk, &rDesk ); + pInfo->pResult = hb_itemPutNI( pInfo->pResult, + ( rDesk.bottom - rDesk.top ) / _s.PTEXTSIZE.y ); + break; + } + case GTI_WINTITLE: + pInfo->pResult = hb_itemPutC( pInfo->pResult, "" ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + hb_wvt_gtSetWindowTitle( hb_itemGetCPtr( pInfo->pNewVal ) ); + } + break; + + case GTI_CODEPAGE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.CodePage ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 && iVal != _s.CodePage ) + { + _s.CodePage = iVal; + hb_wvt_gtResetWindowSize( _s.hWnd ); + } + break; + + case GTI_ICONFILE: + { + HICON hIcon = 0; + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + LPTSTR lpImage = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); + hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, lpImage, + IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + HB_TCHAR_FREE( lpImage ); + if ( hIcon ) + { + SendMessage( _s.hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) hIcon ); /* Set Title Bar Icon */ + SendMessage( _s.hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) hIcon ); /* Set Task List Icon */ + } + } + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( UINT_PTR ) hIcon ); + break; + } + + case GTI_ICONRES: + { + HICON hIcon = 0; + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + LPTSTR lpIcon = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); + hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, lpIcon ); + HB_TCHAR_FREE( lpIcon ); + } + else if ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, + MAKEINTRESOURCE( ( UINT_PTR ) + hb_itemGetNInt( pInfo->pNewVal ) ) ); + } + if ( hIcon ) + { + SendMessage( _s.hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) hIcon ); /* Set Title Bar Icon */ + SendMessage( _s.hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) hIcon ); /* Set Task List Icon */ + } + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( UINT_PTR ) hIcon ); + break; + } + case GTI_VIEWMAXWIDTH: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.COLS ); + break; + + case GTI_VIEWMAXHEIGHT: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, _s.ROWS ); + break; + + case GTI_KBDSHIFTS: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, kbdShiftsState() ); + /* TODO + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + kbdShiftsState( hb_itemGetNI( pInfo->pNewVal ) ); + break; + */ + + case GTI_CLIPBOARDDATA: + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + HB_GT_FUNC( gt_SetClipboard( hb_itemGetCPtr( pInfo->pNewVal ), + hb_itemGetCLen( pInfo->pNewVal ) ) ); + } + else + { + char *szClipboardData; + ULONG ulLen; + + HB_GT_FUNC( gt_GetClipboard( szClipboardData, &ulLen ) ); + if( szClipboardData ) + { + pInfo->pResult = hb_itemPutCPtr( pInfo->pResult, szClipboardData, ulLen ); + } + else + { + pInfo->pResult = hb_itemPutC( pInfo->pResult, "" ); + } + } + break; + + case GTI_CURSORBLINKRATE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, GetCaretBlinkTime() ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + SetCaretBlinkTime( hb_itemGetNI( pInfo->pNewVal ) ); + break; + + default: + return HB_GTSUPER_INFO( iType, pInfo ); + } + + return TRUE; +} + +//----------------------------------------------------------------------// + +/* ********** Graphics API ********** */ +/* + * NOTE: + * gfxPrimitive() parameters may have different meanings + * ie: - Desired color is 'iBottom' for PUTPIXEL and 'iRight' for CIRCLE + * - Red is iTop, Green iLeft and Blue is iBottom for MAKECOLOR + * + */ + +#define SetGFXContext() hPen=CreatePen(PS_SOLID,1,color); hOldPen=(HPEN) SelectObject(hdc,hPen); hBrush=(HBRUSH) CreateSolidBrush(color); hOldBrush=(HBRUSH) SelectObject(hdc,hBrush); bOut=TRUE + +int HB_GT_FUNC( gt_gfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor ) ) +{ + COLORREF color; + HPEN hPen, hOldPen; + HBRUSH hBrush, hOldBrush; + HDC hdc; + BOOL bOut = FALSE; + int iRet = 0; + + hdc = GetDC( _s.hWnd ); + + switch ( iType ) + { + case GFX_ACQUIRESCREEN: + case GFX_RELEASESCREEN: + return 1; + case GFX_MAKECOLOR: + return ( (int) ( (iTop << 16) | (iLeft << 8) | ( iBottom ) ) ); + case GFX_PUTPIXEL: + color = RGB( iBottom >> 16, ( iBottom & 0xFF00 ) >> 8, iBottom & 0xFF ); + SetGFXContext(); + + MoveToEx( hdc, iLeft, iTop, NULL ); + LineTo( hdc, iLeft, iTop ); + + iRet = 1; + break; + case GFX_LINE: + color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); + SetGFXContext(); + + MoveToEx( hdc, iLeft, iTop, NULL ); + LineTo( hdc, iRight, iBottom ); + + iRet = 1; + break; + case GFX_RECT: + { + RECT r; + r.left = iLeft; + r.top = iTop; + r.right = iRight; + r.bottom = iBottom; + + color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); + SetGFXContext(); + + FrameRect( hdc, &r, hBrush ); + + iRet = 1; + } + break; + case GFX_FILLEDRECT: + color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); + SetGFXContext(); + + Rectangle( hdc, iLeft, iTop, iRight, iBottom ); + + iRet = 1; + break; + case GFX_CIRCLE: + color = RGB( iRight >> 16, ( iRight & 0xFF00 ) >> 8, iRight & 0xFF ); + SetGFXContext(); + + Arc( hdc, iLeft - iBottom / 2, iTop - iBottom / 2, iLeft + iBottom / 2, iTop + iBottom / 2, 0, 0, 0, 0 ); + + iRet = 1; + break; + case GFX_FILLEDCIRCLE: + color = RGB( iRight >> 16, ( iRight & 0xFF00 ) >> 8, iRight & 0xFF ); + SetGFXContext(); + + Ellipse( hdc, iLeft - iBottom / 2, iTop - iBottom / 2, iLeft + iBottom / 2, iTop + iBottom / 2 ); + + iRet = 1; + break; + case GFX_ELLIPSE: + color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); + SetGFXContext(); + + Arc( hdc, iLeft - iRight / 2, iTop - iBottom / 2, iLeft + iRight / 2, iTop + iBottom / 2, 0, 0, 0, 0 ); + + iRet = 1; + break; + case GFX_FILLEDELLIPSE: + color = RGB( iColor >> 16, ( iColor & 0xFF00 ) >> 8, iColor & 0xFF ); + SetGFXContext(); + + Ellipse( hdc, iLeft - iRight / 2, iTop - iBottom / 2, iLeft + iRight / 2, iTop + iBottom / 2 ); + + iRet = 1; + break; + case GFX_FLOODFILL: + color = RGB( iBottom >> 16, ( iBottom & 0xFF00 ) >> 8, iBottom & 0xFF ); + SetGFXContext(); + + FloodFill( hdc, iLeft, iTop, iColor ); + + iRet = 1; + break; + } + + if ( bOut ) + { + SelectObject( hdc, hOldPen ); + SelectObject( hdc, hOldBrush ); + DeleteObject( hBrush ); + DeleteObject( hPen ); + } + + return iRet; +} + +void HB_GT_FUNC( gt_gfxText( int iTop, int iLeft, char *cBuf, int iColor, int iSize, int iWidth ) ) +{ + HB_SYMBOL_UNUSED( iTop ); + HB_SYMBOL_UNUSED( iLeft ); + HB_SYMBOL_UNUSED( cBuf ); + HB_SYMBOL_UNUSED( iColor ); + HB_SYMBOL_UNUSED( iSize ); + HB_SYMBOL_UNUSED( iWidth ); +} + +//----------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_Redraw( int iRow, int iCol, int iSize ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gtRedraw(%d, %d, %d)", iRow, iCol, iSize ) ); + + if ( _s.hWnd ) + { + RECT rect; + + rect.top = rect.bottom = ( SHORT ) iRow; + rect.left = ( SHORT ) iCol; + rect.right = ( SHORT ) ( iCol + iSize - 1 ); + + rect = hb_wvt_gtGetXYFromColRowRect( rect ); + + InvalidateRect( _s.hWnd, &rect, FALSE ); + } +} + +//----------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_Refresh( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gtRefresh()") ); + + HB_GTSUPER_REFRESH(); + + if ( _s.hWnd ) + { + SendMessage( _s.hWnd, WM_MY_UPDATE_CARET, 0, 0 ); + hb_wvt_gtProcessMessages(); + } +} + +//----------------------------------------------------------------------// + +static BOOL HB_GT_FUNC( gt_SetDispCP( char * pszTermCDP, char * pszHostCDP, BOOL fBox ) ) +{ + + HB_GTSUPER_SETDISPCP( pszTermCDP, pszHostCDP, fBox ); + +#ifndef HB_CDP_SUPPORT_OFF + /* + * 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 ) + { + if( hb_cdp_page ) + pszHostCDP = hb_cdp_page->id; + else if( pszTermCDP && *pszTermCDP ) + pszHostCDP = pszTermCDP; + } + if( pszHostCDP && *pszHostCDP ) + { + PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP ); + if( cdpHost ) + _s.hostCDP = cdpHost; + } +#endif + + return TRUE; +} + +//----------------------------------------------------------------------// + +static BOOL HB_GT_FUNC( gt_SetKeyCP( char * pszTermCDP, char * pszHostCDP ) ) +{ + HB_GTSUPER_SETKEYCP( pszTermCDP, pszHostCDP ); + +#ifndef HB_CDP_SUPPORT_OFF + /* + * 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 ) + { + if( hb_cdp_page ) + pszHostCDP = hb_cdp_page->id; + else if( pszTermCDP && *pszTermCDP ) + pszHostCDP = pszTermCDP; + } + if( pszHostCDP && *pszHostCDP ) + { + PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP ); + if( cdpHost ) + _s.inCDP = cdpHost; + } +#endif + + return TRUE; +} + +//-------------------------------------------------------------------// + +#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__) +static int hb_Inp9x( USHORT usPort ) +{ + USHORT usVal; + + HB_TRACE( HB_TR_DEBUG, ( "hb_Inp9x( %hu )", usPort ) ); + + #if defined( __BORLANDC__ ) || defined(__DMC__) + + _DX = usPort; + __emit__( 0xEC ); /* ASM IN AL, DX */ + __emit__( 0x32,0xE4 ); /* ASM XOR AH, AH */ + usVal = _AX; + + #elif defined( __XCC__ ) + __asm { + mov dx, usPort + xor ax, ax + in al, dx + mov usVal, ax + } + + #elif defined( __MINGW32__ ) +// __asm__ __volatile__ ("inb %w1,%b0":"=a" (usVal):"Nd" (usPort)); + + #elif defined( __WATCOMC__ ) + usVal = inp( usPort ); + + #else + usVal = _inp( usPort ); + + #endif + + return( usVal ); +} + +//----------------------------------------------------------------------// + +static int hb_Outp9x( USHORT usPort, USHORT usVal ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_Outp9x( %hu, %hu )", usPort, usVal ) ); + + #if defined( __BORLANDC__ ) || defined(__DMC__) + + _DX = usPort; + _AL = usVal; + __emit__( 0xEE ); /* ASM OUT DX, AL */ + + #elif defined( __XCC__ ) + __asm { + mov dx, usPort + mov ax, usVal + out dx, al + } + + #elif defined( __MINGW32__ ) +// __asm__ __volatile__ ("outb %b0,%w1": :"a" (usVal), "Nd" (usPort)); + + #elif defined( __WATCOMC__ ) + outp( usPort, usVal ); + + #else + _outp( usPort, usVal ); + + #endif + + return( usVal ); +} + +//----------------------------------------------------------------------// + +static void HB_GT_FUNC(gt_w9xTone( double dFreq, double dDurat )) +{ + INT uLSB,uMSB; + ULONG lAdjFreq; + + HB_TRACE( HB_TR_DEBUG, ("hb_gt_w9xtone(%lf, %lf)", dFreq, dDurat ) ); + + /* sync with internal clock with very small time period */ + hb_idleSleep( 0.01 ); + + /* Clipper ignores Tone() requests (but delays anyway) if Frequency is + less than < 20 hz (and so should we) to maintain compatibility .. */ + + if ( dFreq >= 20.0 ) + { + /* Setup Sound Control Port Registers and timer channel 2 */ + hb_Outp9x( 67, 182 ) ; + + lAdjFreq = ( ULONG ) ( 1193180 / dFreq ) ; + + if( ( LONG ) lAdjFreq < 0 ) + uLSB = lAdjFreq + 65536; + else + uLSB = lAdjFreq % 256; + + if( ( LONG ) lAdjFreq < 0 ) + uMSB = lAdjFreq + 65536; + else + uMSB = lAdjFreq / 256; + + + /* set the frequency (LSB,MSB) */ + + hb_Outp9x( 66, uLSB ); + hb_Outp9x( 66, uMSB ); + + /* Get current Port setting */ + /* enable Speaker Data & Timer gate bits */ + /* (00000011B is bitmask to enable sound) */ + /* Turn on Speaker - sound Tone for duration.. */ + + hb_Outp9x( 97, hb_Inp9x( 97 ) | 3 ); + + hb_idleSleep( dDurat ); + + /* Read back current Port value for Reset */ + /* disable Speaker Data & Timer gate bits */ + /* (11111100B is bitmask to disable sound) */ + /* Turn off the Speaker ! */ + + hb_Outp9x( 97, hb_Inp9x( 97 ) & 0xFC ); + + } + else + { + hb_idleSleep( dDurat ); + } +} +#endif + +//-------------------------------------------------------------------// +// +/* dDurat is in seconds */ +// +static void HB_GT_FUNC( gt_wNtTone( double dFreq, double dDurat ) ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_wNtTone(%lf, %lf)", dFreq, dDurat ) ); + + /* Clipper ignores Tone() requests (but delays anyway) if Frequency is + less than < 20 hz. Windows NT minimum is 37... */ + + /* sync with internal clock with very small time period */ + hb_idleSleep( 0.01 ); + + if ( dFreq >= 37.0 ) + { + Beep( (ULONG) dFreq, (ULONG) ( dDurat * 1000 ) ); /* Beep wants Milliseconds */ + } + else + { + hb_idleSleep( dDurat ); + } +} + +//-------------------------------------------------------------------// +// +/* dDuration is in 'Ticks' (18.2 per second) */ +// +void HB_GT_FUNC( gt_Tone( double dFrequency, double dDuration ) ) +{ + OSVERSIONINFO osv; + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_Tone(%lf, %lf)", dFrequency, dDuration)); + + /* + According to the Clipper NG, the duration in 'ticks' is truncated to the + interger portion ... Depending on the platform, xHarbour allows a finer + resolution, but the minimum is 1 tick (for compatibility) + */ + /* Convert from ticks to seconds */ + dDuration = ( HB_MIN( HB_MAX( 1.0, dDuration ), ULONG_MAX ) ) / 18.2; + + /* keep the frequency in an acceptable range */ + dFrequency = HB_MIN( HB_MAX( 0.0, dFrequency ), 32767.0 ); + + /* What version of Windows are you running? */ + osv.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + GetVersionEx( &osv ); + + /* If Windows 95 or 98, use w9xTone for BCC32, MSVC */ + if ( osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) + { + #if defined( __BORLANDC__ ) || defined( _MSC_VER ) || defined( __WATCOMC__ ) || defined(__MINGW32__) + HB_GT_FUNC( gt_w9xTone( dFrequency, dDuration ) ); + #else + HB_GT_FUNC( gt_wNtTone( dFrequency, dDuration ) ); + #endif + } + + /* If Windows NT or NT2k, use wNtTone, which provides TONE() + reset sequence support (new) */ + else if ( osv.dwPlatformId == VER_PLATFORM_WIN32_NT ) + { + HB_GT_FUNC( gt_wNtTone( dFrequency, dDuration ) ); + } +} + +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// + +static BOOL HB_GT_FUNC( gt_mouse_IsPresent( void ) ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gtmouse_IsPresent()")); + + return TRUE; +} + +//----------------------------------------------------------------------// + +static void HB_GT_FUNC( gt_mouse_GetPos( int * piRow, int * piCol ) ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gtmouse_GetPos(%p,%p)", piRow, piCol)); + + *piRow = _s.mousePos.y; + *piCol = _s.mousePos.x; +} + +//----------------------------------------------------------------------// + +static BOOL HB_GT_FUNC( gt_mouse_ButtonState( int iButton ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gtmouse_ButtonState(%i)", iButton ) ); + + 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_FUNC( gt_mouse_CountButton( void ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gtmouse_CountButton()") ); + return( GetSystemMetrics( SM_CMOUSEBUTTONS ) ) ; +} + +//----------------------------------------------------------------------// +/* +void HB_GT_FUNC( mouse_Init( void ) ) +{ + hb_wvt_gtSetMouseX( 0 ); + hb_wvt_gtSetMouseY( 0 ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( mouse_Exit( void ) ) +{ +} + +//-------------------------------------------------------------------// + +BOOL HB_GT_FUNC( mouse_IsPresent( void ) ) +{ + return( TRUE ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( mouse_Show( void ) ) +{ +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( mouse_Hide( void ) ) +{ +} + +//-------------------------------------------------------------------// + +int HB_GT_FUNC( mouse_Col( void ) ) +{ + return( hb_wvt_gtGetMouseX() ); +} + +//-------------------------------------------------------------------// + +int HB_GT_FUNC( mouse_Row( void ) ) +{ + return( hb_wvt_gtGetMouseY() ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( mouse_SetPos( int iRow, int iCol ) ) +{ + hb_wvt_gtSetMouseY( iRow ); + hb_wvt_gtSetMouseX( iCol ); +} + +//-------------------------------------------------------------------// + +BOOL HB_GT_FUNC( mouse_IsButtonPressed( int iButton ) ) +{ + BOOL bReturn = FALSE; + + if ( iButton == 0 ) + { + bReturn = GetKeyState( VK_LBUTTON ) & 0x8000; + } + else if ( iButton== 1 ) + { + bReturn = GetKeyState( VK_RBUTTON ) & 0x8000; + } + else if ( iButton == 2 ) + { + bReturn = GetKeyState( VK_MBUTTON ) & 0x8000; + } + + return( bReturn ); +} + +//-------------------------------------------------------------------// + +int HB_GT_FUNC( mouse_CountButton( void ) ) +{ + return( GetSystemMetrics( SM_CMOUSEBUTTONS ) ) ; +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( mouse_SetBounds( int iTop, int iLeft, int iBottom, int iRight ) ) +{ + HB_SYMBOL_UNUSED( iTop ); + HB_SYMBOL_UNUSED( iLeft ); + HB_SYMBOL_UNUSED( iBottom ); + HB_SYMBOL_UNUSED( iRight ); +} + +//-------------------------------------------------------------------// + +void HB_GT_FUNC( mouse_GetBounds( int * piTop, int * piLeft, int * piBottom, int * piRight ) ) +{ + HB_SYMBOL_UNUSED( piTop ); + HB_SYMBOL_UNUSED( piLeft ); + HB_SYMBOL_UNUSED( piBottom ); + HB_SYMBOL_UNUSED( piRight ); +} +*/ + +//----------------------------------------------------------------------// + +static BOOL hb_gt_FuncInit( PHB_GT_FUNCS gt_funcs ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gtFnInit( %p )", gt_funcs ) ); + + gt_funcs->Init = HB_GT_FUNC( gt_Init ); + //gt_funcs->AdjustPos = HB_GT_FUNC( gt_AdjustPos ); + //gt_funcs->Col = HB_GT_FUNC( gt_Col ); + gt_funcs->Box = HB_GT_FUNC( gt_Box ); + gt_funcs->BoxD = HB_GT_FUNC( gt_BoxD ); + gt_funcs->BoxS = HB_GT_FUNC( gt_BoxS ); + gt_funcs->DispBegin = HB_GT_FUNC( gt_DispBegin ); + gt_funcs->DispEnd = HB_GT_FUNC( gt_DispEnd ); + gt_funcs->DispCount = HB_GT_FUNC( gt_DispCount ); + gt_funcs->Exit = HB_GT_FUNC( gt_Exit ); + //gt_funcs->ExtendedKeySupport = HB_GT_FUNC( gt_ExtendedKeySupport ); + gt_funcs->GetBlink = HB_GT_FUNC( gt_GetBlink ); + //gt_funcs->GetClipboard = HB_GT_FUNC( gt_GetClipboard ); + //gt_funcs->GetClipboardSize = HB_GT_FUNC( gt_GetClipboardSize ); + gt_funcs->GetCursorStyle = HB_GT_FUNC( gt_GetCursorStyle ); + // PART OF GT BUT UNDEFINED // + gt_funcs->GetPos = HB_GT_FUNC( gt_GetPos ); + //gt_funcs->GetScreenWidth = HB_GT_FUNC( gt_GetScreenWidth ); + //gt_funcs->GetScreenHeight = HB_GT_FUNC( gt_GetScreenHeight ); + gt_funcs->MaxCol = HB_GT_FUNC( gt_MaxCol ); + gt_funcs->MaxRow = HB_GT_FUNC( gt_MaxRow ); + //gt_funcs->GetText = HB_GT_FUNC( gt_GetText ); + gt_funcs->HorizLine = HB_GT_FUNC( gt_HorizLine ); + gt_funcs->Info = HB_GT_FUNC( gt_Info ); + gt_funcs->IsColor = HB_GT_FUNC( gt_IsColor ); + gt_funcs->OutStd = HB_GT_FUNC( gt_OutStd ); + gt_funcs->OutErr = HB_GT_FUNC( gt_OutErr ); + gt_funcs->PostExt = HB_GT_FUNC( gt_PostExt ); + gt_funcs->PreExt = HB_GT_FUNC( gt_PreExt ); + //gt_funcs->ProcessMessages = HB_GT_FUNC( gt_ProcessMessages ); + //gt_funcs->Puts = HB_GT_FUNC( gt_Puts ); + //gt_funcs->PutChar = HB_GT_FUNC( gt_Puts ); + gt_funcs->PutText = HB_GT_FUNC( gt_PutText ); + gt_funcs->Redraw = HB_GT_FUNC( gt_Redraw ); // + + //gt_funcs->Refresh = HB_GT_FUNC( gt_Refresh ); // + + gt_funcs->ReadKey = HB_GT_FUNC( gt_ReadKey ); + gt_funcs->Rest = HB_GT_FUNC( gt_xPutText ); + gt_funcs->Resume = HB_GT_FUNC( gt_Resume ); + //gt_funcs->Replicate = HB_GT_FUNC( gt_Replicate ); + //gt_funcs->RectSize = HB_GT_FUNC( gt_RectSize ); + //gt_funcs->Row = HB_GT_FUNC( gt_Row ); + gt_funcs->Save = HB_GT_FUNC( gt_GetText ); + gt_funcs->SetAttribute = HB_GT_FUNC( gt_SetAttribute ); + gt_funcs->SetBlink = HB_GT_FUNC( gt_SetBlink ); + //gt_funcs->SetClipboard = HB_GT_FUNC( gt_SetClipboard ); + gt_funcs->SetCursorStyle = HB_GT_FUNC( gt_SetCursorStyle ); + gt_funcs->SetMode = HB_GT_FUNC( gt_SetMode ); + gt_funcs->SetPos = HB_GT_FUNC( gt_SetPos ); + gt_funcs->Scroll = HB_GT_FUNC( gt_Scroll ); + gt_funcs->Suspend = HB_GT_FUNC( gt_Suspend ); + gt_funcs->Tone = HB_GT_FUNC( gt_Tone ); + gt_funcs->Version = HB_GT_FUNC( gt_Version ); + gt_funcs->VertLine = HB_GT_FUNC( gt_VertLine ); + + gt_funcs->SetDispCP = HB_GT_FUNC( gt_SetDispCP ); + gt_funcs->SetKeyCP = HB_GT_FUNC( gt_SetKeyCP ); + + /* Graphics API */ + //gt_funcs->gfxPrimitive = HB_GT_FUNC( gt_gfxPrimitive ); + + gt_funcs->MouseIsPresent = HB_GT_FUNC( gt_mouse_IsPresent ); + gt_funcs->MouseGetPos = HB_GT_FUNC( gt_mouse_GetPos ); + gt_funcs->MouseButtonState = HB_GT_FUNC( gt_mouse_ButtonState ); + gt_funcs->MouseCountButton = HB_GT_FUNC( gt_mouse_CountButton ); + + return TRUE; +} + +//-------------------------------------------------------------------// +/* +static void HB_GT_FUNC( mouseFnInit( PHB_GT_FUNCS gt_funcs ) ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_mouseFnInit( %p )", gt_funcs ) ); + + gt_funcs->mouse_Init = HB_GT_FUNC( mouse_Init ); + gt_funcs->mouse_Exit = HB_GT_FUNC( mouse_Exit ); + gt_funcs->mouse_IsPresent = HB_GT_FUNC( mouse_IsPresent ); + gt_funcs->mouse_Show = HB_GT_FUNC( mouse_Show ); + gt_funcs->mouse_Hide = HB_GT_FUNC( mouse_Hide ); + gt_funcs->mouse_Col = HB_GT_FUNC( mouse_Col ); + gt_funcs->mouse_Row = HB_GT_FUNC( mouse_Row ); + gt_funcs->mouse_SetPos = HB_GT_FUNC( mouse_SetPos ); + gt_funcs->mouse_IsButtonPressed = HB_GT_FUNC( mouse_IsButtonPressed ); + gt_funcs->mouse_CountButton = HB_GT_FUNC( mouse_CountButton ); + gt_funcs->mouse_SetBounds = HB_GT_FUNC( mouse_SetBounds ); + gt_funcs->mouse_GetBounds = HB_GT_FUNC( mouse_GetBounds ); +} +*/ +//-------------------------------------------------------------------// + +static HB_GT_INIT gtInit = { HB_GT_DRVNAME( HB_GT_NAME ), + hb_gt_FuncInit, + HB_GTSUPER }; + +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 _MSC_VER >= 1010 + #pragma data_seg( ".CRT$XIY" ) + #pragma comment( linker, "/Merge:.CRT=.data" ) + #else + #pragma data_seg( "XIY" ) + #endif + static HB_$INITSYM hb_vm_auto__hb_startup_gt_Init_ = _hb_startup_gt_Init_; + #pragma data_seg() +#endif + +//-------------------------------------------------------------------// + diff --git a/harbour/contrib/gtwvg/gtwvt.h b/harbour/contrib/gtwvg/gtwvt.h index 452cd6ed3c..21a73de6cc 100644 --- a/harbour/contrib/gtwvg/gtwvt.h +++ b/harbour/contrib/gtwvg/gtwvt.h @@ -1,428 +1,428 @@ -/* - * Chr(36) + "Id" + Chr(36) - */ - -/* - * Harbour Project source code: - * Header File for Video subsystem for Win32 using GUI windows instead of Console - * Copyright 2003 Peter Rees - * Rees Software & Systems Ltd - * www - 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. - * - */ - -//-------------------------------------------------------------------// -#ifndef HB_WVT_H_ -//-------------------------------------------------------------------// - -#define HB_WVT_H_ - -//-------------------------------------------------------------------// - -/* NOTE: User programs should never call this layer directly! */ - -/* This definition has to be placed before #include "hbapigt.h" */ - -//-------------------------------------------------------------------// - -#define HB_GT_NAME WVG - -//-------------------------------------------------------------------// - -#ifndef CINTERFACE - #define CINTERFACE 1 -#endif - -#define NONAMELESSUNION - -//-------------------------------------------------------------------// - -#include "hbset.h" -#include "hbgtcore.h" -#include "hbinit.h" -#include "hbapicdp.h" -#include "hbapierr.h" -#include "hbapiitm.h" -#include "inkey.ch" -#include "error.ch" -#include "hbvm.h" -#include "hbgfxdef.ch" - -#include -#include -#include -#include - -#include -#include -#include -#if defined(__MINGW__) -# include -#endif -#include - -#include -#include - -//-------------------------------------------------------------------// - -#define WVT_CHAR_QUEUE_SIZE 128 -#define WVT_CHAR_BUFFER 1024 -#define WVT_MAX_ROWS 256 -#define WVT_MAX_COLS 256 - -#define WVT_PICTURES_MAX 50 -#define WVT_FONTS_MAX 50 -#define WVT_PENS_MAX 50 -#define WVT_DLGML_MAX 50 -#define WVT_DLGMD_MAX 50 - -//-------------------------------------------------------------------// - -#if defined( HB_WINCE ) -# define WVT_DEFAULT_ROWS 15 -# define WVT_DEFAULT_COLS 50 -# define WVT_DEFAULT_FONT_HEIGHT 12 -# define WVT_DEFAULT_FONT_WIDTH 8 -#else -# define WVT_DEFAULT_ROWS 25 -# define WVT_DEFAULT_COLS 80 -# define WVT_DEFAULT_FONT_HEIGHT 20 -# define WVT_DEFAULT_FONT_WIDTH 10 -#endif - -//-------------------------------------------------------------------// - -#define BLACK RGB( 0x0 ,0x0 ,0x0 ) -#define BLUE RGB( 0x0 ,0x0 ,0x85 ) -#define GREEN RGB( 0x0 ,0x85,0x0 ) -#define CYAN RGB( 0x0 ,0x85,0x85 ) -#define RED RGB( 0x85,0x0 ,0x0 ) -#define MAGENTA RGB( 0x85,0x0 ,0x85 ) -#define BROWN RGB( 0x85,0x85,0x0 ) -#define WHITE RGB( 0xC6,0xC6,0xC6 ) -#define LIGHT_GRAY RGB( 0x60,0x60,0x60 ) -#define BRIGHT_BLUE RGB( 0x00,0x00,0xFF ) -#define BRIGHT_GREEN RGB( 0x60,0xFF,0x60 ) -#define BRIGHT_CYAN RGB( 0x60,0xFF,0xFF ) -#define BRIGHT_RED RGB( 0xF8,0x00,0x26 ) -#define BRIGHT_MAGENTA RGB( 0xFF,0x60,0xFF ) -#define YELLOW RGB( 0xFF,0xFF,0x00 ) -#define BRIGHT_WHITE RGB( 0xFF,0xFF,0xFF ) - -//-------------------------------------------------------------------// - -#define WM_MY_UPDATE_CARET ( WM_USER + 0x0101 ) - -//-------------------------------------------------------------------// - -#if defined(__DMC__) - #if (_WIN32_IE >= 0x0300) - #if !defined(ICC_BAR_CLASSES) - #define ICC_BAR_CLASSES 0x00000004 - #endif - #if !defined(COLOR16) - typedef USHORT COLOR16; - #endif - #if !defined(TRIVERTEX) - typedef struct _TRIVERTEX { - LONG x; - LONG y; - COLOR16 Red; - COLOR16 Green; - COLOR16 Blue; - COLOR16 Alpha; - }TRIVERTEX,*PTRIVERTEX,*LPTRIVERTEX; - #endif - #if !defined( INITCOMMONCONTROLSEX ) - typedef struct tagINITCOMMONCONTROLSEX { - DWORD dwSize; // size of this structure - DWORD dwICC; // flags indicating which classes to be initialized - } INITCOMMONCONTROLSEX, *LPINITCOMMONCONTROLSEX; - #endif - #if !defined(InitCommonControlsEx) - WINCOMMCTRLAPI BOOL WINAPI InitCommonControlsEx(LPINITCOMMONCONTROLSEX); - #endif - #endif -#endif - -//-------------------------------------------------------------------// - -typedef BOOL ( WINAPI *wvtGradientFill ) ( - HDC hdc, - PTRIVERTEX pVertex, - ULONG dwNumVertex, - PVOID pMesh, - ULONG dwNumMesh, - ULONG dwMode ); - -//-------------------------------------------------------------------// - -typedef struct global_data -{ - POINT PTEXTSIZE; // size of the fixed width font - BOOL FixedFont; // TRUE if current font is a fixed font - int FixedSize[ WVT_MAX_COLS ]; // buffer for ExtTextOut() to emulate fixed pitch when Proportional font selected - USHORT ROWS; // number of displayable rows in window - USHORT COLS; // number of displayable columns in window - COLORREF foreground; // forground colour - COLORREF background; // background colour - - USHORT BUFFERSIZE; // size of the screen text buffer - BYTE byAttributes[ WVT_MAX_ROWS * WVT_MAX_COLS ]; // buffer with the attributes - BYTE byBuffer[ WVT_MAX_ROWS * WVT_MAX_COLS ]; // buffer with the text to be displayed on the screen - BYTE *pAttributes; // pointer to buffer - BYTE *pBuffer; // " " " - POINT caretPos; // the current caret position - BOOL CaretExist; // TRUE if a caret has been created - int CaretSize; - BOOL CaretHidden; - POINT mousePos; // the last mousedown position - BOOL MouseMove; // Flag to say whether to return mouse movement events - HWND hWnd; // the window handle - int Keys[ WVT_CHAR_QUEUE_SIZE ]; // Array to hold the characters & events - int keyPointerIn; // Offset into key array for character to be placed - int keyPointerOut; // Offset into key array of next character to read - BOOL displayCaret; // flag to indicate if caret is on - RECT RectInvalid; // Invalid rectangle if DISPBEGIN() active - HFONT hFont; - int fontHeight; // requested font height - int fontWidth ; // requested font width - int fontWeight; // Bold level - int fontQuality; - char fontFace[ LF_FACESIZE ]; // requested font face name LF_FACESIZE #defined in wingdi.h -// int closeEvent; // command to return ( in ReadKey ) on close -// int shutdownEvent; // command to return ( in ReadKey ) on shutdown - int LastMenuEvent; // Last menu item selected - int MenuKeyEvent; // User definable event number for windows menu command - BOOL CentreWindow; // True if window is to be Reset into centre of window - 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 InvalidateWindow; // Flag for controlling whether to use ScrollWindowEx() - BOOL EnableShortCuts; // Determines whether ALT key enables menu or system menu - 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 - HDC hdc; // Handle to Windows Device Context - 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; - int rowStart; // Holds nTop of last WM_PAINT rectangle returned by Wvt_GetPaintRect() - int rowStop; // Holds nBottom of last WM_PAINT rectangle - int colStart; // Holds nLeft of last WM_PAINT rectangle - int colStop; // Holds nRight of last WM_PAINT rectangle - HMENU hPopup; // Handle of context menu invokable with right click - IPicture *iPicture[ WVT_PICTURES_MAX ]; // Array to hold the Picture Streams to avoid recurring loading and unloading - HDC hCompDC; // Compatible DC to _s.hdc - HFONT hUserFonts[ WVT_FONTS_MAX ] ; // User defined font handles - HPEN hUserPens[ WVT_PENS_MAX ]; // User defined pens - HWND hWndTT; // Handle to hold tooltip information - BOOL bToolTipActive; // Flag to set whether tooltip is active or not - HINSTANCE hMSImg32; // Handle to the loaded library msimg32.dll - wvtGradientFill pfnGF; // Pointer to Address of the GradientFill function in MSImg32.dll - HWND hDlgModeless[ WVT_DLGML_MAX ]; // Handle to a modeless dialog - PHB_ITEM pFunc[ WVT_DLGML_MAX ]; // Function pointer for WndProc - /* TODO: pcbFunc is redundant and should be removed */ - PHB_ITEM pcbFunc[ WVT_DLGML_MAX ]; //codeblock for WndProc - int iType[ WVT_DLGML_MAX ]; // Type of Function Pointers - Function 1, Block 2, Method 3 - HWND hDlgModal[ WVT_DLGMD_MAX ];// Handle to a modeless dialog - PHB_ITEM pFuncModal[ WVT_DLGMD_MAX ]; // Function pointer for WndProc - /* TODO: pcbFuncModal is redundant and should be removed */ - PHB_ITEM pcbFuncModal[ WVT_DLGMD_MAX ]; // codeblock for WndProc - int iTypeModal[ WVT_DLGMD_MAX ]; // Type of Function Pointers - Function 1, Block 2, Method 3 - BOOL bGui; - HDC hGuiDC; - HBITMAP hGuiBmp; - int iGuiWidth; - int iGuiHeight; - - BOOL bIgnoreWM_SYSCHAR; - BOOL bPaint ; - BOOL bGetFocus ; - BOOL bSetFocus ; - BOOL bKillFocus ; - - PHB_CODEPAGE hostCDP; /* Host/HVM CodePage for unicode output translations */ - PHB_CODEPAGE inCDP; /* Host/HVM CodePage for unicode input translations */ - -} GLOBAL_DATA; - -typedef GLOBAL_DATA * LPGLOBAL_DATA; - -//-------------------------------------------------------------------// - -//POINT HB_EXPORT hb_wvt_gtGetXYFromColRow( USHORT col, USHORT row ); -POINT HB_EXPORT hb_wvt_gtGetXYFromColRow( USHORT col, USHORT row ); -BOOL HB_EXPORT hb_wvt_gtSetMenuKeyEvent( int iMenuKeyEvent ); -BOOL HB_EXPORT hb_wvt_gtSetCentreWindow( BOOL bCentre, BOOL bPaint ); -void HB_EXPORT hb_wvt_gtResetWindow( void ); -BOOL HB_EXPORT hb_wvt_gtSetCodePage( int iCodePage ); -int HB_EXPORT hb_wvt_gtGetLastMenuEvent( void ); -int HB_EXPORT hb_wvt_gtSetLastMenuEvent( int iLastMenuEvent ); -void HB_EXPORT hb_wvt_gtSetWindowTitle( char * title ); -DWORD HB_EXPORT hb_wvt_gtSetWindowIcon( int icon, char *lpicon ); -DWORD HB_EXPORT hb_wvt_gtSetWindowIconFromFile( char *icon ); -int HB_EXPORT hb_wvt_gtGetWindowTitle( char *title, int length ); -BOOL HB_EXPORT hb_wvt_gtSetFont( char *fontFace, int height, int width, int Bold, int Quality ); -//void HB_EXPORT hb_wvt_gtSetCloseEvent( int iEvent ); -//void HB_EXPORT hb_wvt_gtSetShutdownEvent( int iEvent ); -HWND HB_EXPORT hb_wvt_gtGetWindowHandle( void ); -void HB_EXPORT hb_wvt_gtPostMessage( int message ); -BOOL HB_EXPORT hb_wvt_gtSetWindowPos( int left, int top ); -BOOL HB_EXPORT hb_wvt_gtSetAltF4Close( BOOL bCanClose ); -void HB_EXPORT hb_wvt_gtDoProcessMessages( void ); -BOOL HB_EXPORT hb_wvt_gtSetMouseMove( BOOL bHandleEvent ); -BOOL HB_EXPORT hb_wvt_gtEnableShortCuts( BOOL bEnable ); -void HB_EXPORT hb_wvt_gtAddCharToInputQueue( int data ); -HB_EXPORT IPicture * hb_wvt_gtLoadPicture( char * image ); -HB_EXPORT IPicture * hb_wvt_gtLoadPictureFromResource( LPCSTR cResource, LPCSTR cSection ); -BOOL HB_EXPORT hb_wvt_gtRenderPicture( int x1, int y1, int wd, int ht, IPicture * iPicture ); -BOOL HB_EXPORT hb_wvt_gtDestroyPicture( IPicture * iPicture ); -COLORREF HB_EXPORT hb_wvt_gtGetColorData( int iIndex ); -BOOL HB_EXPORT hb_wvt_gtSetColorData( int iIndex, COLORREF ulCr ); -BOOL HB_EXPORT hb_wvt_DrawImage( HDC hdc, int x1, int y1, int wd, int ht, char * image ); - -LPWORD HB_EXPORT lpwAlign( LPWORD lpIn ); -int HB_EXPORT nCopyAnsiToWideChar( LPWORD lpWCStr, LPSTR lpAnsiIn ); -BOOL HB_EXPORT CALLBACK hb_wvt_gtDlgProcMLess( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ); -BOOL HB_EXPORT CALLBACK hb_wvt_gtDlgProcModal( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ); - -GLOBAL_DATA HB_EXPORT * hb_wvt_gtGetGlobalData( void ); - -void HB_EXPORT hb_wvt_wvtCore( void ); -void HB_EXPORT hb_wvt_wvtUtils( void ); - -//-------------------------------------------------------------------// - -#ifndef WM_MOUSEWHEEL - #define WM_MOUSEWHEEL 0x020A -#endif - -#ifndef INVALID_FILE_SIZE - #define INVALID_FILE_SIZE (DWORD)0xFFFFFFFF -#endif - -#ifndef CC_ANYCOLOR - #define CC_ANYCOLOR 0x00000100 -#endif - -#ifndef IDC_HAND - #define IDC_HAND MAKEINTRESOURCE(32649) -#endif - -#ifndef GRADIENT_FILL_RECT_H - #define GRADIENT_FILL_RECT_H 0x00 -#endif - -//----------------------------------------------------------------------// - -typedef enum -{ - GTO_POINT = 0, - GTO_LINE = 1, - GTO_SQUARE = 3, - GTO_RECTANGLE = 4, - GTO_CIRCLE = 5, - GTO_DISK = 7, - /* TODO: add other types */ - GTO_TEXT = 100, -} HB_gt_object_enum; - -/* Event subsystem */ - -typedef enum -{ - GTEVENT_RESIZE = 0, - GTEVENT_CLOSE = 1, - GTEVENT_ICONIZE = 2, - GTEVENT_MAXH = 3, - GTEVENT_MAXV = 4, - GTEVENT_MAXIMIZE = 5, - GTEVENT_DEICONIZE= 6, - GTEVENT_SHUTDOWN = 7 -} HB_gt_event_enum; - -typedef struct _tag_HB_GT_GCOLOR -{ - USHORT usAlpha; - USHORT usRed; - USHORT usGreen; - USHORT usBlue; -} HB_GT_GCOLOR; - -typedef struct _tag_HB_GT_COLDEF -{ - char *name; - HB_GT_GCOLOR color; -} HB_GT_COLDEF; - -//----------------------------------------------------------------------// - -#define K_SH_LEFT K_LEFT /* Shift-Left == Left */ -#define K_SH_UP K_UP /* Shift-Up == Up */ -#define K_SH_RIGHT K_RIGHT /* Shift-Right == Right */ -#define K_SH_DOWN K_DOWN /* Shift-Down == Down */ -#define K_SH_INS K_INS /* Shift-Ins == Ins */ -#define K_SH_DEL K_DEL /* Shift-Del == Del */ -#define K_SH_HOME K_HOME /* Shift-Home == Home */ -#define K_SH_END K_END /* Shift-End == End */ -#define K_SH_PGUP K_PGUP /* Shift-PgUp == PgUp */ -#define K_SH_PGDN K_PGDN /* Shift-PgDn == PgDn */ -#define K_SH_RETURN K_RETURN /* Shift-Enter == Enter */ -#define K_SH_ENTER K_ENTER /* Shift-Enter == Enter */ - -//-------------------------------------------------------------------// -#endif -//-------------------------------------------------------------------// - +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Header File for Video subsystem for Win32 using GUI windows instead of Console + * Copyright 2003 Peter Rees + * Rees Software & Systems Ltd + * www - 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. + * + */ + +//-------------------------------------------------------------------// +#ifndef HB_WVT_H_ +//-------------------------------------------------------------------// + +#define HB_WVT_H_ + +//-------------------------------------------------------------------// + +/* NOTE: User programs should never call this layer directly! */ + +/* This definition has to be placed before #include "hbapigt.h" */ + +//-------------------------------------------------------------------// + +#define HB_GT_NAME WVG + +//-------------------------------------------------------------------// + +#ifndef CINTERFACE + #define CINTERFACE 1 +#endif + +#define NONAMELESSUNION + +//-------------------------------------------------------------------// + +#include "hbset.h" +#include "hbgtcore.h" +#include "hbinit.h" +#include "hbapicdp.h" +#include "hbapierr.h" +#include "hbapiitm.h" +#include "inkey.ch" +#include "error.ch" +#include "hbvm.h" +#include "hbgfxdef.ch" + +#include +#include +#include +#include + +#include +#include +#include +#if defined(__MINGW__) +# include +#endif +#include + +#include +#include + +//-------------------------------------------------------------------// + +#define WVT_CHAR_QUEUE_SIZE 128 +#define WVT_CHAR_BUFFER 1024 +#define WVT_MAX_ROWS 256 +#define WVT_MAX_COLS 256 + +#define WVT_PICTURES_MAX 50 +#define WVT_FONTS_MAX 50 +#define WVT_PENS_MAX 50 +#define WVT_DLGML_MAX 50 +#define WVT_DLGMD_MAX 50 + +//-------------------------------------------------------------------// + +#if defined( HB_WINCE ) +# define WVT_DEFAULT_ROWS 15 +# define WVT_DEFAULT_COLS 50 +# define WVT_DEFAULT_FONT_HEIGHT 12 +# define WVT_DEFAULT_FONT_WIDTH 8 +#else +# define WVT_DEFAULT_ROWS 25 +# define WVT_DEFAULT_COLS 80 +# define WVT_DEFAULT_FONT_HEIGHT 20 +# define WVT_DEFAULT_FONT_WIDTH 10 +#endif + +//-------------------------------------------------------------------// + +#define BLACK RGB( 0x0 ,0x0 ,0x0 ) +#define BLUE RGB( 0x0 ,0x0 ,0x85 ) +#define GREEN RGB( 0x0 ,0x85,0x0 ) +#define CYAN RGB( 0x0 ,0x85,0x85 ) +#define RED RGB( 0x85,0x0 ,0x0 ) +#define MAGENTA RGB( 0x85,0x0 ,0x85 ) +#define BROWN RGB( 0x85,0x85,0x0 ) +#define WHITE RGB( 0xC6,0xC6,0xC6 ) +#define LIGHT_GRAY RGB( 0x60,0x60,0x60 ) +#define BRIGHT_BLUE RGB( 0x00,0x00,0xFF ) +#define BRIGHT_GREEN RGB( 0x60,0xFF,0x60 ) +#define BRIGHT_CYAN RGB( 0x60,0xFF,0xFF ) +#define BRIGHT_RED RGB( 0xF8,0x00,0x26 ) +#define BRIGHT_MAGENTA RGB( 0xFF,0x60,0xFF ) +#define YELLOW RGB( 0xFF,0xFF,0x00 ) +#define BRIGHT_WHITE RGB( 0xFF,0xFF,0xFF ) + +//-------------------------------------------------------------------// + +#define WM_MY_UPDATE_CARET ( WM_USER + 0x0101 ) + +//-------------------------------------------------------------------// + +#if defined(__DMC__) + #if (_WIN32_IE >= 0x0300) + #if !defined(ICC_BAR_CLASSES) + #define ICC_BAR_CLASSES 0x00000004 + #endif + #if !defined(COLOR16) + typedef USHORT COLOR16; + #endif + #if !defined(TRIVERTEX) + typedef struct _TRIVERTEX { + LONG x; + LONG y; + COLOR16 Red; + COLOR16 Green; + COLOR16 Blue; + COLOR16 Alpha; + }TRIVERTEX,*PTRIVERTEX,*LPTRIVERTEX; + #endif + #if !defined( INITCOMMONCONTROLSEX ) + typedef struct tagINITCOMMONCONTROLSEX { + DWORD dwSize; // size of this structure + DWORD dwICC; // flags indicating which classes to be initialized + } INITCOMMONCONTROLSEX, *LPINITCOMMONCONTROLSEX; + #endif + #if !defined(InitCommonControlsEx) + WINCOMMCTRLAPI BOOL WINAPI InitCommonControlsEx(LPINITCOMMONCONTROLSEX); + #endif + #endif +#endif + +//-------------------------------------------------------------------// + +typedef BOOL ( WINAPI *wvtGradientFill ) ( + HDC hdc, + PTRIVERTEX pVertex, + ULONG dwNumVertex, + PVOID pMesh, + ULONG dwNumMesh, + ULONG dwMode ); + +//-------------------------------------------------------------------// + +typedef struct global_data +{ + POINT PTEXTSIZE; // size of the fixed width font + BOOL FixedFont; // TRUE if current font is a fixed font + int FixedSize[ WVT_MAX_COLS ]; // buffer for ExtTextOut() to emulate fixed pitch when Proportional font selected + USHORT ROWS; // number of displayable rows in window + USHORT COLS; // number of displayable columns in window + COLORREF foreground; // forground colour + COLORREF background; // background colour + + USHORT BUFFERSIZE; // size of the screen text buffer + BYTE byAttributes[ WVT_MAX_ROWS * WVT_MAX_COLS ]; // buffer with the attributes + BYTE byBuffer[ WVT_MAX_ROWS * WVT_MAX_COLS ]; // buffer with the text to be displayed on the screen + BYTE *pAttributes; // pointer to buffer + BYTE *pBuffer; // " " " + POINT caretPos; // the current caret position + BOOL CaretExist; // TRUE if a caret has been created + int CaretSize; + BOOL CaretHidden; + POINT mousePos; // the last mousedown position + BOOL MouseMove; // Flag to say whether to return mouse movement events + HWND hWnd; // the window handle + int Keys[ WVT_CHAR_QUEUE_SIZE ]; // Array to hold the characters & events + int keyPointerIn; // Offset into key array for character to be placed + int keyPointerOut; // Offset into key array of next character to read + BOOL displayCaret; // flag to indicate if caret is on + RECT RectInvalid; // Invalid rectangle if DISPBEGIN() active + HFONT hFont; + int fontHeight; // requested font height + int fontWidth ; // requested font width + int fontWeight; // Bold level + int fontQuality; + char fontFace[ LF_FACESIZE ]; // requested font face name LF_FACESIZE #defined in wingdi.h +// int closeEvent; // command to return ( in ReadKey ) on close +// int shutdownEvent; // command to return ( in ReadKey ) on shutdown + int LastMenuEvent; // Last menu item selected + int MenuKeyEvent; // User definable event number for windows menu command + BOOL CentreWindow; // True if window is to be Reset into centre of window + 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 InvalidateWindow; // Flag for controlling whether to use ScrollWindowEx() + BOOL EnableShortCuts; // Determines whether ALT key enables menu or system menu + 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 + HDC hdc; // Handle to Windows Device Context + 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; + int rowStart; // Holds nTop of last WM_PAINT rectangle returned by Wvt_GetPaintRect() + int rowStop; // Holds nBottom of last WM_PAINT rectangle + int colStart; // Holds nLeft of last WM_PAINT rectangle + int colStop; // Holds nRight of last WM_PAINT rectangle + HMENU hPopup; // Handle of context menu invokable with right click + IPicture *iPicture[ WVT_PICTURES_MAX ]; // Array to hold the Picture Streams to avoid recurring loading and unloading + HDC hCompDC; // Compatible DC to _s.hdc + HFONT hUserFonts[ WVT_FONTS_MAX ] ; // User defined font handles + HPEN hUserPens[ WVT_PENS_MAX ]; // User defined pens + HWND hWndTT; // Handle to hold tooltip information + BOOL bToolTipActive; // Flag to set whether tooltip is active or not + HINSTANCE hMSImg32; // Handle to the loaded library msimg32.dll + wvtGradientFill pfnGF; // Pointer to Address of the GradientFill function in MSImg32.dll + HWND hDlgModeless[ WVT_DLGML_MAX ]; // Handle to a modeless dialog + PHB_ITEM pFunc[ WVT_DLGML_MAX ]; // Function pointer for WndProc + /* TODO: pcbFunc is redundant and should be removed */ + PHB_ITEM pcbFunc[ WVT_DLGML_MAX ]; //codeblock for WndProc + int iType[ WVT_DLGML_MAX ]; // Type of Function Pointers - Function 1, Block 2, Method 3 + HWND hDlgModal[ WVT_DLGMD_MAX ];// Handle to a modeless dialog + PHB_ITEM pFuncModal[ WVT_DLGMD_MAX ]; // Function pointer for WndProc + /* TODO: pcbFuncModal is redundant and should be removed */ + PHB_ITEM pcbFuncModal[ WVT_DLGMD_MAX ]; // codeblock for WndProc + int iTypeModal[ WVT_DLGMD_MAX ]; // Type of Function Pointers - Function 1, Block 2, Method 3 + BOOL bGui; + HDC hGuiDC; + HBITMAP hGuiBmp; + int iGuiWidth; + int iGuiHeight; + + BOOL bIgnoreWM_SYSCHAR; + BOOL bPaint ; + BOOL bGetFocus ; + BOOL bSetFocus ; + BOOL bKillFocus ; + + PHB_CODEPAGE hostCDP; /* Host/HVM CodePage for unicode output translations */ + PHB_CODEPAGE inCDP; /* Host/HVM CodePage for unicode input translations */ + +} GLOBAL_DATA; + +typedef GLOBAL_DATA * LPGLOBAL_DATA; + +//-------------------------------------------------------------------// + +//POINT HB_EXPORT hb_wvt_gtGetXYFromColRow( USHORT col, USHORT row ); +POINT HB_EXPORT hb_wvt_gtGetXYFromColRow( USHORT col, USHORT row ); +BOOL HB_EXPORT hb_wvt_gtSetMenuKeyEvent( int iMenuKeyEvent ); +BOOL HB_EXPORT hb_wvt_gtSetCentreWindow( BOOL bCentre, BOOL bPaint ); +void HB_EXPORT hb_wvt_gtResetWindow( void ); +BOOL HB_EXPORT hb_wvt_gtSetCodePage( int iCodePage ); +int HB_EXPORT hb_wvt_gtGetLastMenuEvent( void ); +int HB_EXPORT hb_wvt_gtSetLastMenuEvent( int iLastMenuEvent ); +void HB_EXPORT hb_wvt_gtSetWindowTitle( char * title ); +DWORD HB_EXPORT hb_wvt_gtSetWindowIcon( int icon, char *lpicon ); +DWORD HB_EXPORT hb_wvt_gtSetWindowIconFromFile( char *icon ); +int HB_EXPORT hb_wvt_gtGetWindowTitle( char *title, int length ); +BOOL HB_EXPORT hb_wvt_gtSetFont( char *fontFace, int height, int width, int Bold, int Quality ); +//void HB_EXPORT hb_wvt_gtSetCloseEvent( int iEvent ); +//void HB_EXPORT hb_wvt_gtSetShutdownEvent( int iEvent ); +HWND HB_EXPORT hb_wvt_gtGetWindowHandle( void ); +void HB_EXPORT hb_wvt_gtPostMessage( int message ); +BOOL HB_EXPORT hb_wvt_gtSetWindowPos( int left, int top ); +BOOL HB_EXPORT hb_wvt_gtSetAltF4Close( BOOL bCanClose ); +void HB_EXPORT hb_wvt_gtDoProcessMessages( void ); +BOOL HB_EXPORT hb_wvt_gtSetMouseMove( BOOL bHandleEvent ); +BOOL HB_EXPORT hb_wvt_gtEnableShortCuts( BOOL bEnable ); +void HB_EXPORT hb_wvt_gtAddCharToInputQueue( int data ); +HB_EXPORT IPicture * hb_wvt_gtLoadPicture( char * image ); +HB_EXPORT IPicture * hb_wvt_gtLoadPictureFromResource( LPCSTR cResource, LPCSTR cSection ); +BOOL HB_EXPORT hb_wvt_gtRenderPicture( int x1, int y1, int wd, int ht, IPicture * iPicture ); +BOOL HB_EXPORT hb_wvt_gtDestroyPicture( IPicture * iPicture ); +COLORREF HB_EXPORT hb_wvt_gtGetColorData( int iIndex ); +BOOL HB_EXPORT hb_wvt_gtSetColorData( int iIndex, COLORREF ulCr ); +BOOL HB_EXPORT hb_wvt_DrawImage( HDC hdc, int x1, int y1, int wd, int ht, char * image ); + +LPWORD HB_EXPORT lpwAlign( LPWORD lpIn ); +int HB_EXPORT nCopyAnsiToWideChar( LPWORD lpWCStr, LPSTR lpAnsiIn ); +BOOL HB_EXPORT CALLBACK hb_wvt_gtDlgProcMLess( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ); +BOOL HB_EXPORT CALLBACK hb_wvt_gtDlgProcModal( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ); + +GLOBAL_DATA HB_EXPORT * hb_wvt_gtGetGlobalData( void ); + +void HB_EXPORT hb_wvt_wvtCore( void ); +void HB_EXPORT hb_wvt_wvtUtils( void ); + +//-------------------------------------------------------------------// + +#ifndef WM_MOUSEWHEEL + #define WM_MOUSEWHEEL 0x020A +#endif + +#ifndef INVALID_FILE_SIZE + #define INVALID_FILE_SIZE (DWORD)0xFFFFFFFF +#endif + +#ifndef CC_ANYCOLOR + #define CC_ANYCOLOR 0x00000100 +#endif + +#ifndef IDC_HAND + #define IDC_HAND MAKEINTRESOURCE(32649) +#endif + +#ifndef GRADIENT_FILL_RECT_H + #define GRADIENT_FILL_RECT_H 0x00 +#endif + +//----------------------------------------------------------------------// + +typedef enum +{ + GTO_POINT = 0, + GTO_LINE = 1, + GTO_SQUARE = 3, + GTO_RECTANGLE = 4, + GTO_CIRCLE = 5, + GTO_DISK = 7, + /* TODO: add other types */ + GTO_TEXT = 100, +} HB_gt_object_enum; + +/* Event subsystem */ + +typedef enum +{ + GTEVENT_RESIZE = 0, + GTEVENT_CLOSE = 1, + GTEVENT_ICONIZE = 2, + GTEVENT_MAXH = 3, + GTEVENT_MAXV = 4, + GTEVENT_MAXIMIZE = 5, + GTEVENT_DEICONIZE= 6, + GTEVENT_SHUTDOWN = 7 +} HB_gt_event_enum; + +typedef struct _tag_HB_GT_GCOLOR +{ + USHORT usAlpha; + USHORT usRed; + USHORT usGreen; + USHORT usBlue; +} HB_GT_GCOLOR; + +typedef struct _tag_HB_GT_COLDEF +{ + char *name; + HB_GT_GCOLOR color; +} HB_GT_COLDEF; + +//----------------------------------------------------------------------// + +#define K_SH_LEFT K_LEFT /* Shift-Left == Left */ +#define K_SH_UP K_UP /* Shift-Up == Up */ +#define K_SH_RIGHT K_RIGHT /* Shift-Right == Right */ +#define K_SH_DOWN K_DOWN /* Shift-Down == Down */ +#define K_SH_INS K_INS /* Shift-Ins == Ins */ +#define K_SH_DEL K_DEL /* Shift-Del == Del */ +#define K_SH_HOME K_HOME /* Shift-Home == Home */ +#define K_SH_END K_END /* Shift-End == End */ +#define K_SH_PGUP K_PGUP /* Shift-PgUp == PgUp */ +#define K_SH_PGDN K_PGDN /* Shift-PgDn == PgDn */ +#define K_SH_RETURN K_RETURN /* Shift-Enter == Enter */ +#define K_SH_ENTER K_ENTER /* Shift-Enter == Enter */ + +//-------------------------------------------------------------------// +#endif +//-------------------------------------------------------------------// + diff --git a/harbour/contrib/gtwvg/wvtclass.prg b/harbour/contrib/gtwvg/wvtclass.prg index d743b2f2e2..a03b7e7c4b 100644 --- a/harbour/contrib/gtwvg/wvtclass.prg +++ b/harbour/contrib/gtwvg/wvtclass.prg @@ -1,3515 +1,3515 @@ -/* - * Chr(36) + "Id" + Chr(36) - */ - -/* - * Harbour Project source code: - * - * GUI Components - * Copyright 2007 Pritpal Bedi - * Based On: - * - * Video subsystem for Win32 using GUI windows instead of Console - * Copyright 2003 Peter Rees - * Rees Software & Systems Ltd - * - * - * 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. - * - */ -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Wvt*Classes -// 2004 -// Pritpal Bedi -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -#include 'hbclass.ch' -#include 'inkey.ch' -#include 'common.ch' -#include 'setcurs.ch' - -#include 'wvtwin.ch' -//#include 'xhb.ch' - -//-------------------------------------------------------------------// - -#define K_LBUTTONPRESSED 1021 -#define K_RBUTTONPRESSED 1022 -#define K_MBUTTONPRESSED 1023 - -#define K_SBLINEUP 1051 -#define K_SBLINEDOWN 1052 -#define K_SBPAGEUP 1053 -#define K_SBPAGEDOWN 1054 - -#define K_SBLINELEFT 1055 -#define K_SBLINERIGHT 1056 -#define K_SBPAGELEFT 1057 -#define K_SBPAGERIGHT 1058 - -#define K_SBTHUMBTRACKVERT 1059 -#define K_SBTHUMBTRACKHORZ 1060 - -//-------------------------------------------------------------------// - -#define OBJ_CHILD_OBJ 1 -#define OBJ_CHILD_EVENTS 2 -#define OBJ_CHILD_DATABLOCK 3 -#define OBJ_CHILD_REFRESHBLOCK 4 - -//-------------------------------------------------------------------// -// -// Class WvtDialog -// -//-------------------------------------------------------------------// - -CLASS wvtDialog - - // To hold previous settings - // - DATA nOldRows - DATA nOldCols - DATA aOldFont - DATA cOldTitle - DATA cOldColor - DATA nOldCursor - DATA aPalette - DATA cScreen - DATA aWvtScreen - DATA aOldPnt - DATA oldTooltipActive - DATA oldTooltipWidth - DATA oldTooltipBkColor - DATA oldTooltipTextColor - DATA oldMenuHandle - DATA oldMenuBlock - DATA lGui - - // Dialog Parameters - // - DATA nRows - DATA nCols - DATA cFont - DATA nFontHeight - DATA nFontWidth - DATA nFontBold - DATA nFontQuality - DATA cTitle - DATA cColor - - // Objects handelling - // - DATA aObjects INIT {} - DATA oCurObj - DATA oLastObj - DATA oObjOver - DATA oLastOver - DATA nCurObj INIT 1 - DATA nLastObj INIT 0 - DATA nObjOver INIT 0 - DATA nLastOver INIT -1 - DATA nUseObj - DATA oMenu - DATA aDialogKeys INIT {} - DATA cDialogID INIT '' - - // Tooltip Management - // - DATA nTooltipWidth - DATA nTooltipBkColor - DATA nTooltipTextColor - - // Miscellaneous - // - DATA ClassName INIT 'WVTDIALOG' - DATA cPaintBlockID - DATA nPaintID INIT 1 - DATA nObjID INIT 5000 - DATA nKey - DATA hFonts INIT {} - DATA lEventHandled - DATA lTabStops INIT .f. - - ACCESS nObjects INLINE len( ::aObjects ) - - DATA bOnCreate - - METHOD New() - METHOD Create() - METHOD Destroy() - METHOD AddObject( oObject ) INLINE aadd( ::aObjects, oObject ) - METHOD Execute() - METHOD MouseOver() - METHOD CreateObjects() - METHOD MaxRow() INLINE ::nRows - 1 - METHOD MaxCol() INLINE ::nCols - 1 - METHOD Eval() - METHOD Update() - METHOD OnTimer() INLINE aeval( ::aObjects, {|o| o:OnTimer() } ) - METHOD Event() - METHOD Inkey() - METHOD ActivateMenu() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( nRows, nCols, cTitle, cFont, nFontHeight, nFontWidth,nFontBold,nFontQuality ) CLASS wvtDialog - LOCAL fnt_:= Wvt_GetFontInfo() - - DEFAULT nRows TO 25 - DEFAULT nCols TO 80 - DEFAULT cTitle TO Wvt_GetTitle() - DEFAULT cFont TO fnt_[ 1 ] - DEFAULT nFontHeight TO fnt_[ 2 ] - DEFAULT nFontWidth TO fnt_[ 3 ] - DEFAULT nFontBold TO fnt_[ 4 ] - DEFAULT nFontQuality TO fnt_[ 5 ] - - if empty( cFont ) - cFont := fnt_[ 1 ] - endif - if empty( nFontHeight ) - nFontHeight := fnt_[ 2 ] - endif - if empty( nFontWidth ) - nFontWidth := fnt_[ 3 ] - endif - - ::nOldRows := MaxRow()+1 - ::nOldCols := MaxCol()+1 - ::aOldFont := Wvt_GetFontInfo() - ::cOldTitle := Wvt_GetTitle() - ::cOldColor := SetColor() - ::nOldCursor := SetCursor() - ::aPalette := Wvt_GetPalette() - - ::oldMenuHandle := Wvt_GetMenu() - ::oldMenuBlock := SetKey( Wvt_SetMenuKeyEvent() ) - - ::oldTooltipWidth := Wvt_GetTooltipWidth() - ::oldTooltipBkColor := Wvt_GetTooltipBkColor() - ::oldTooltipTextColor := Wvt_GetTooltipTextColor() - - ::nRows := nRows - ::nCols := nCols - ::cTitle := cTitle - ::cFont := cFont - ::nFontHeight := nFontHeight - ::nFontWidth := nFontWidth - ::nFontBold := nFontBold - ::nFontQuality := nFontQuality - - ::cPaintBlockID := strzero( Hb_Random( 99999998 ),8 ) - ::nObjOver := 0 - ::nKey := 0 - ::cColor := 'N/W' - ::nUseObj := 0 - ::lGui := Wvt_SetGui( .f. ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS wvtDialog - LOCAL aPalette, n, i, j // , cScr, cQry - - ::oldToolTipActive := Wvt_SetToolTipActive( .t. ) - if ::nTooltipWidth <> nil - Wvt_setTooltipWidth( ::nTooltipWidth ) - endif - if ::nTooltipBkColor <> nil - Wvt_SetTooltipBkColor( ::nTooltipBkColor ) - endif - if ::nTooltipTextColor <> nil - Wvt_SetTooltipTextColor( ::nTooltipTextColor ) - endif - - aPalette := Wvt_GetPalette() - aPalette[ 9 ] := RGB( 175,175,175 ) - Wvt_SetPalette( aPalette ) - - ::cScreen := SaveScreen( 0, 0, maxrow(), maxcol() ) - ::aWvtScreen := Wvt_SaveScreen( 0, 0, maxrow(), maxcol() ) - ::aOldPnt := WvtSetPaint( {} ) - - SetMode( ::nRows, ::nCols ) - do while .t. - if Wvt_SetFont( ::cFont, ::nFontHeight, ::nFontWidth, ::nFontBold, ::nFontQuality ) - exit - endif - ::nFontHeight-- - enddo - //Wvt_SetFont( ::cFont, ::nFontHeight, ::nFontWidth, ::nFontBold, ::nFontQuality ) - SetMode( ::nRows, ::nCols ) - - Wvt_SetTitle( ::cTitle ) - - SetColor( ::cColor ) - CLS - ::Eval( ::bOnCreate ) - - // Actually Create the Objects - ::CreateObjects() - - if len( ::aObjects ) > 0 - ::oCurObj := ::aObjects[ 1 ] - endif - - for i := 1 to len( ::aObjects ) - if !empty( ::aObjects[ i ]:aPaint ) - for j := 1 to len( ::aObjects[ i ]:aPaint ) - SetPaint( ::cPaintBlockID, ::nPaintID++, ; - ::aObjects[ i ]:aPaint[ j,1 ], ::aObjects[ i ]:aPaint[ j,2 ] ) - next - endif - next - WvtSetPaint( GetPaint( ::cPaintBlockID ) ) - - if ( n := ascan( ::aObjects, {|o| o:lTabStop } ) ) > 0 - ::lTabStops := .t. - endif - - ::Update() - - if HB_ISOBJECT( ::oMenu ) - Wvt_SetMenu( ::oMenu:hMenu ) - Wvt_DrawMenuBar() - SetKey( Wvt_SetMenuKeyEvent(), {|| ::ActivateMenu( ::oMenu ) } ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Destroy() CLASS wvtDialog - - if HB_ISOBJECT( ::oMenu ) - ::oMenu:Destroy() - endif - - aeval( ::aObjects, {|o| o:destroy() } ) - - Wvt_SetTooltip( 0,0,0,0,'' ) - Wvt_SetTooltipActive( ::oldToolTipActive ) - Wvt_setTooltipWidth( ::oldTooltipWidth ) - Wvt_SetTooltipBkColor( ::oldTooltipBkColor ) - Wvt_SetTooltipTextColor( ::oldTooltipTextColor ) - - // Here set mode is before setting the font - // - SetMode( ::nOldRows, ::nOldCols ) - Wvt_SetFont( ::aOldFont[ 1 ], ::aOldFont[ 2 ], ::aOldFont[ 3 ], ::aOldFont[ 4 ], ::aOldFont[ 5 ] ) - Wvt_SetTitle( ::cOldTitle ) - Wvt_SetPalette( ::aPalette ) - Wvt_SetPointer( WVT_IDC_ARROW ) - Wvt_SetMousePos( MRow(), MCol() ) - - SetColor( ::cOldColor ) - SetCursor( ::nOldCursor ) - - if ::oldMenuHandle <> nil .and. ::oldMenuHandle <> 0 - Wvt_SetMenu( ::oldMenuHandle ) - Wvt_DrawMenuBar() - endif - SetKey( Wvt_SetMenuKeyEvent(), ::oldMenuBlock ) - - RestScreen( 0, 0, maxrow(), maxcol(), ::cScreen ) - Wvt_RestScreen( 0, 0 ,maxrow(), maxcol(), ::aWvtScreen ) - PurgePaint( ::cPaintBlockID ) - WvtSetPaint( ::aOldPnt ) - Wvt_SetGui( ::lGui ) - - RETURN nil - -//-------------------------------------------------------------------// - -METHOD Event() CLASS wvtDialog - LOCAL nKey - - if ( nKey := inkey( 0.1, INKEY_ALL ) ) == 0 - if Wvt_IsLButtonPressed() - - nKey := K_LBUTTONPRESSED - - endif - endif - - RETURN ( nKey ) - -//-------------------------------------------------------------------// - -METHOD Execute() CLASS wvtDialog - - if ::nObjects == 0 - do while .t. - if inkey( 0.1 ) == K_ESC - exit - endif - enddo - else - do while ( ::Inkey() <> K_ESC ) - enddo - endif - - RETURN ::nKey - -//-------------------------------------------------------------------// - -METHOD Inkey() CLASS wvtDialog - LOCAL n, oObj, nID, i - - ::lEventHandled := .f. - ::nUseObj := 0 - - ::nKey := ::Event() - ::OnTimer() - - if ::nKey <> 0 - if ::nKey == K_ESC .or. ::nKey == K_CTRL_ENTER - return K_ESC - endif - - do case - - case ::nKey == K_TAB - if ::lTabStops - do while .t. - ::nCurObj++ - if ::nCurObj > ::nObjects - ::nCurObj := 1 - endif - if ::aObjects[ ::nCurObj ]:lTabStop - exit - endif - enddo - endif - - ::lEventHandled := .t. - - case ::nKey == K_SH_TAB - if ::lTabStops - do while .t. - ::nCurObj-- - if ::nCurObj < 1 - ::nCurObj := ::nObjects - endif - if ::aObjects[ ::nCurObj ]:lTabStop - exit - endif - enddo - endif - - ::lEventHandled := .t. - - case ::nKey == K_MOUSEMOVE .or. ::nKey == K_MMLEFTDOWN - ::MouseOver() - if ::nObjOver == 0 - Wvt_SetPointer( WVT_IDC_ARROW ) - elseif ::oObjOver:nPointer <> nil .and. ::oObjOver:lActive - Wvt_SetPointer( ::oObjOver:nPointer ) - else - Wvt_SetPointer( WVT_IDC_ARROW ) - endif - ::lEventHandled := .t. - - endcase - - if ::nKey == K_LBUTTONDOWN .or. ; - ::nKey == K_LBUTTONUP .or. ; - ::nKey == K_LDBLCLK .or. ; - ::nKey == K_MMLEFTDOWN .or. ; - ::nKey == K_LBUTTONPRESSED .or. ; - ::nKey == K_RBUTTONDOWN - - ::MouseOver() - - if ::nObjOver > 0 - if ::aObjects[ ::nObjOver ]:nType == DLG_OBJ_BUTTON .or. ; - ::aObjects[ ::nObjOver ]:nType == DLG_OBJ_TOOLBAR .or. ; - ::aObjects[ ::nObjOver ]:nType == DLG_OBJ_PUSHBUTTON .or. ; - ::aObjects[ ::nObjOver ]:nType == DLG_OBJ_SCROLLBAR - - oObj := ::aObjects[ ::nObjOver ] - if oObj:oParent:ClassName == 'WVTBROWSE' - nID := oObj:oParent:nID - if ( n := ascan( ::aObjects, {|o| o:nID == nID } ) ) > 0 - ::nCurObj := n - endif - endif - else - ::nCurObj := ::nObjOver - endif - ::nUseObj := ::nObjOver - - else - ::lEventHandled := .t. - - endif - endif - - if ::nLastOver <> ::nObjOver - if ::nLastOver > 0 - ::aObjects[ ::nLastOver ]:HoverOff() - endif - - ::nLastOver := ::nObjOver - - if ::nObjOver > 0 - ::oObjOver:HoverOn() - endif - - if ::nObjOver == 0 - Wvt_SetTooltip( 0,0,0,0,'' ) - - elseif ::oObjOver:lActive - ::oObjOver:SetTooltip() - - else - Wvt_SetTooltip( 0,0,0,0,'' ) - - endif - endif - - if ::nCurObj <> ::nLastObj - if ::nLastObj == 0 - ::aObjects[ ::nCurObj ]:Hilite() - - else - ::aObjects[ ::nLastObj ]:DeHilite() - ::aObjects[ ::nCurObj ]:Hilite() - - endif - - ::nLastObj := ::nCurObj - ::oCurObj := ::aObjects[ ::nCurObj ] - ::oLastObj := ::aObjects[ ::nCurObj ] - - if ::oCurObj:nType == DLG_OBJ_BROWSE - Select( ::oCurObj:cAlias ) - - endif - - ::Eval( ::oCurObj:bOnFocus, ::oCurObj ) - endif - - if ::nKey == K_LBUTTONDOWN - if ::nUseObj > 0 - if !( ::lEventHandled := ::aObjects[ ::nUseObj ]:LeftDown() ) - ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnLeftDown ) - - endif - endif - endif - - if ::nKey == K_LBUTTONUP - if ::nUseObj > 0 - if !( ::lEventHandled := ::aObjects[ ::nUseObj ]:LeftUp() ) - ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnLeftUp ) - - endif - endif - endif - - if ::nKey == K_MMLEFTDOWN - if ::nUseObj > 0 - if !( ::lEventHandled := ::aObjects[ ::nUseObj ]:MMLeftDown() ) - ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnMMLeftDown ) - - endif - endif - endif - - if ::nKey == K_LBUTTONPRESSED - if ::nUseObj > 0 - if !( ::lEventHandled := ::aObjects[ ::nUseObj ]:LeftPressed() ) - ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnLeftPressed ) - - endif - endif - endif - - if ::nKey == K_LDBLCLK - if ::nUseObj > 0 - ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnSelect ) - - endif - endif - - if ::nKey == K_RBUTTONDOWN .and. ::nUseObj > 0 - ::lEventHandled := ::aObjects[ ::nUseObj ]:ShowPopup() - endif - - if !( ::lEventHandled ) - if ::nCurObj > 0 - if !empty( ::aDialogKeys ) - if ( n := ascan( ::aDialogKeys, {|e_| e_[ 1 ] == ::nKey } ) ) > 0 - Eval( ::aDialogKeys[ n, 2 ], self, ::oCurObj ) - endif - endif - - ::lEventHandled := ::oCurObj:HandleEvent( ::nKey ) - - if ( ::lEventHandled ) - if ::oCurObj:nChildren > 0 - for i := 1 to ::oCurObj:nChildren - //if ( ::nKey IN ::oCurObj:aChildren[ i, OBJ_CHILD_EVENTS ] ) - if ascan( ::oCurObj:aChildren[ i, OBJ_CHILD_EVENTS ],::nKey ) > 0 - ::oCurObj:NotifyChild( i, ::nKey, ::oCurObj ) - endif - next - endif - endif - endif - endif - - if !( ::lEventHandled ) - if ISBLOCK( SetKey( ::nKey ) ) - Eval( SetKey( ::nKey ) ) - endif - endif - endif - - RETURN ( ::nKey ) - -//-------------------------------------------------------------------// - -METHOD MouseOver() CLASS wvtDialog - LOCAL mRow := MRow() - LOCAL mCol := MCol() - LOCAL nObj - - nObj := ascan( ::aObjects, ; - {|o| o:nType <> DLG_OBJ_STATIC .and. ; - o:nType <> DLG_OBJ_TOOLBAR .and. ; - mRow >= o:nTop .and. mRow <= o:nBottom .and. ; - mCol >= o:nLeft .and. mCol <= o:nRight } ) - - ::nObjOver := nObj - ::oObjOver := if( nObj > 0, ::aObjects[ nObj ], nil ) - if nObj > 0 - ::aObjects[ nObj ]:nmRow := mRow - ::aObjects[ nObj ]:nmCol := mCol - - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Update() CLASS wvtDialog - - Wvt_InvalidateRect( 0, 0, ::maxrow(), ::maxcol() ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD CreateObjects() CLASS wvtDialog - LOCAL i, nObjs - - nObjs := len( ::aObjects ) - - for i := 1 to nObjs - switch ::aObjects[ i ]:nType - - case DLG_OBJ_BROWSE - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_STATUSBAR - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_LABEL - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_TOOLBAR - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_BUTTON - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_PUSHBUTTON - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_IMAGE - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_STATIC - ::aObjects[ i ]:Create() - exit - /* - case DLG_OBJ_SCROLLBAR - ::aObjects[ i ]:Create() - exit - */ - case DLG_OBJ_GETS - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_BANNER - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_TEXTBOX - ::aObjects[ i ]:Create() - exit - case DLG_OBJ_PROGRESSBAR - ::aObjects[ i ]:Create() - exit - end - next - - RETURN self - -//-------------------------------------------------------------------// - -METHOD Eval( bBlock, p1,p2,p3,p4,p5 ) CLASS wvtDialog - LOCAL lRet - - if ( lRet := ISBLOCK( bBlock ) ) - eval( bBlock, p1,p2,p3,p4,p5 ) - endif - - RETURN lRet - -//-------------------------------------------------------------------// - -METHOD ActivateMenu() CLASS WvtDialog - LOCAL nMenu:= Wvt_GetLastMenuEvent() - LOCAL aMenuItem - - IF !EMPTY( nMenu ) - IF HB_ISOBJECT( ::oMenu ) - IF !EMPTY( aMenuItem := ::oMenu:FindMenuItemById( nMenu ) ) - IF HB_ISBLOCK( aMenuItem[ WVT_MENU_ACTION ] ) - EVAL( aMenuItem[ WVT_MENU_ACTION ] ) - ENDIF - ENDIF - ENDIF - ENDIF - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtObject -// -// Must never be used directly. It is parent class for all other objects! -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtObject - - DATA oParent - DATA nType - DATA nId - - DATA nTop - DATA nLeft - DATA nBottom - DATA nRight - DATA aPxlTLBR INIT {} - - DATA aObjects INIT {} - DATA aParent INIT {} - DATA aChildren INIT {} - DATA aPaint INIT {} - DATA bPaint - DATA ClassName INIT '' - - DATA nObjID INIT 900000 - DATA nPointer - DATA cargo - DATA xSettings - DATA cText - DATA cToolTip - DATA lActive INIT .t. - DATA lAnimate INIT .f. - DATA lTabStop INIT .t. - DATA hFont - - DATA aPopup INIT {} - DATA hPopup INIT nil - DATA nPopupItemID INIT 700000 - - DATA nMRow INIT 0 - DATA nMCol INIT 0 - DATA cColorHilite INIT 'W+/B*' - DATA cColorDehilite INIT 'W/N*' - - DATA nTextColor - DATA nBackColor - DATA nBackMode INIT 0 // OPAQUE 1-TRANSPARENT - DATA nTextColorHoverOn - DATA nTextColorHoverOff - DATA nBackColorHoverOn - DATA nBackColorHoverOff - DATA cFont - DATA nFontHeight - DATA nFontWidth - DATA nFontWeight - DATA nFontQuality - DATA nCharSet - DATA lItalic - DATA lUnderline - DATA lStrikeOut - DATA nAlignHorz - DATA nAlignVert - DATA nAngle - - ACCESS ToolTip INLINE if( ::cTooltip == nil, '', ::cTooltip ) - ASSIGN ToolTip( cTip ) INLINE ::cToolTip := cTip - - DATA bHandleEvent - DATA bOnCreate - DATA bOnSelect - DATA bOnFocus - DATA bOnRefresh - DATA bOnLeftUp - DATA bOnLeftDown - DATA bOnMMLeftDown - DATA bOnLeftPressed - DATA bTooltip - DATA bSaveSettings - DATA bRestSettings - DATA bOnHilite - DATA bOnDeHilite - - ACCESS nChildren INLINE len( ::aChildren ) - DATA nIndexOrder - - METHOD New() - METHOD Create() - METHOD Destroy() - - // To Avoid any runtime errors if a message is send to an object - // which does not implement these methods - // - METHOD PaintBlock() INLINE nil - METHOD Hilite() INLINE nil - METHOD DeHilite() INLINE nil - METHOD HandleEvent() INLINE .f. - - METHOD LeftDown() INLINE .f. - METHOD LeftUp() INLINE .f. - METHOD MMLeftDown INLINE .f. - METHOD LeftPressed INLINE .f. - - METHOD HoverOn() INLINE nil - METHOD HoverOff() INLINE nil - - METHOD OnTimer() INLINE nil - - METHOD SaveSettings() INLINE nil - METHOD RestSettings() INLINE nil - - METHOD SetToolTip() INLINE ; - Wvt_SetToolTip( ::nTop, ::nLeft, ::nBottom, ::nRight, ::Tooltip ) - - METHOD Refresh() INLINE ; - Wvt_InvalidateRect( ::nTop, ::nLeft, ::nTop, ::nLeft ) - - METHOD Eval( bBlock ) INLINE ; - if( ISBLOCK( bBlock ), Eval( bBlock, self ), nil ) - - METHOD CreatePopup() - METHOD ShowPopup() - METHOD Activate() INLINE nil - METHOD DeActivate() INLINE nil - - METHOD AddChild( aChild ) INLINE aadd( ::aChildren, aChild ) - METHOD AddParent( aParent ) INLINE aadd( ::aParent, aParent ) - - METHOD NotifyChild( /*nChild*/ ) INLINE nil - - ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nType, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtObject - - DEFAULT nID TO ++::nObjID - - ::oParent := oParent - ::nType := nType - ::nId := nID - ::nTop := nTop - ::nLeft := nLeft - ::nBottom := nBottom - ::nRight := nRight - - switch nType - - case DLG_OBJ_BROWSE - ::ClassName := 'WVTBROWSE' - exit - - case DLG_OBJ_STATIC - ::ClassName := 'WVTSTATIC' - ::lTabStop := .f. - exit - - case DLG_OBJ_GETS - ::ClassName := 'WVTGETS' - exit - - case DLG_OBJ_IMAGE - ::ClassName := 'WVTIMAGE' - ::lTabStop := .f. - exit - - case DLG_OBJ_PUSHBUTTON - ::ClassName := 'WVTPUSHBUTTON' - exit - - case DLG_OBJ_BUTTON - ::ClassName := 'WVTBUTTON' - ::lTabStop := .f. - exit - - case DLG_OBJ_TOOLBAR - ::ClassName := 'WVTTOOLBAR' - ::lTabStop := .f. - exit - - case DLG_OBJ_LABEL - ::ClassName := 'WVTLABEL' - ::lTabStop := .f. - exit - - case DLG_OBJ_SCROLLBAR - ::ClassName := 'WVTSCROLLBAR' - ::lTabStop := .f. - exit - - case DLG_OBJ_STATUSBAR - ::ClassName := 'WVTSTATUSBAR' - ::lTabStop := .f. - exit - - case DLG_OBJ_BANNER - ::ClassName := 'WVTBANNER' - ::lTabStop := .f. - exit - - case DLG_OBJ_TEXTBOX - ::ClassName := 'WVTTEXTBOX' - ::lTabStop := .f. - exit - - case DLG_OBJ_PROGRESSBAR - ::ClassName := 'WVTPROGRESSBAR' - ::lTabStop := .f. - exit - - end - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtObject - - ::Eval( ::bOnCreate ) - ::CreatePopup() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Destroy() CLASS WvtObject - - if ::hFont <> nil - Win_DeleteObject( ::hFont ) - ::hFont := nil - endif - - if ::hPopup <> nil - Wvt_DestroyMenu( ::hPopup ) - ::hPopup := nil - endif - - RETURN Nil - -//-------------------------------------------------------------------// - -METHOD CreatePopup() CLASS WvtObject - LOCAL i, nID - - if !empty( ::aPopup ) .and. ::hPopup == nil - ::hPopup := Wvt_CreatePopupMenu() - - for i := 1 to len( ::aPopup ) - - aSize( ::aPopup[ i ],3 ) - nID := ::nPopupItemID++ - ::aPopup[ i,3 ] := nID - - Wvt_AppendMenu( ::hPopup, MF_ENABLED + MF_STRING, nID, ::aPopup[ i,1 ] ) - next - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD ShowPopup() CLASS WvtObject - LOCAL lRet := .f., nRet, n, aPos - - if ::hPopup <> nil - aPos := Wvt_GetCursorPos() - - nRet := Wvt_TrackPopupMenu( ::hPopup, TPM_CENTERALIGN +TPM_RETURNCMD, ; - aPos[ 1 ], aPos[ 2 ], 0, Wvt_GetWindowHandle() ) - if nRet > 0 - if ( n := ascan( ::aPopup, {|e_| e_[ 3 ] == nRet } ) ) > 0 - lRet := .t. - - if ISBLOCK( ::aPopup[ n,2 ] ) - Eval( ::aPopup[ n,2 ] ) - endif - endif - endif - endif - - RETURN lRet - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtBrowse -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtBrowse FROM WvtObject - - DATA cAlias - DATA oBrw - DATA lHSBar INIT .t. - DATA lVSBar INIT .t. - DATA oHBar - DATA oVBar - DATA bTotalRecords - DATA bCurrentRecord - DATA bTotalColumns - DATA bCurrentColumn - - ACCESS cDesc INLINE if( ::cText == nil, '', ::cText ) - ASSIGN cDesc( cText ) INLINE ::cText := cText - - METHOD New() - METHOD Create() - METHOD PaintBlock() - METHOD Hilite() - METHOD DeHilite() - METHOD HandleEvent() - METHOD Refresh() - METHOD SetVBar() - METHOD SetHBar() - METHOD SetTooltip() - METHOD SaveSettings() - METHOD RestSettings() - METHOD NotifyChild() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtBrowse - - ::Super:New( oParent, DLG_OBJ_BROWSE, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtBrowse - - Select( ::cAlias ) - - ::nTop := ::oBrw:nTop-2 - ::nLeft := ::oBrw:nLeft-2 - ::nBottom := if( ::lHSBar, ::oBrw:nBottom, ::oBrw:nBottom+1 ) - ::nRight := if( ::lVSBar, ::oBrw:nRight , ::oBrw:nRight+2 ) - - ::PaintBlock( 1 ) - ::PaintBlock( 2 ) - ::PaintBlock( 3 ) - ::PaintBlock( 4 ) - - ::Super:Create() - - DEFAULT ::bTotalRecords TO {|| ( ::cAlias )->( OrdKeyCount() ) } - DEFAULT ::bCurrentRecord TO {|| ( ::cAlias )->( OrdKeyNo() ) } - ::SetVBar() - - DEFAULT ::bTotalColumns TO {|| ::oBrw:ColCount } - DEFAULT ::bCurrentColumn TO {|| ::oBrw:ColPos } - ::SetHBar() - - ::oBrw:ForceStable() - ::DeHilite() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetVBar() CLASS WvtBrowse - - if ::lVSBar - ::oVBar := WvtScrollBar():New( self, 999991, ; - ::oBrw:nTop, ::oBrw:nRight+1, ::oBrw:nBottom, ::oBrw:nRight+2 ) - ::oVBar:nBarType := WVT_SCROLLBAR_VERT - ::oVBar:bTotal := ::bTotalRecords - ::oVBar:bCurrent := ::bCurrentRecord - ::oVBar:aPxlBtnTop := { -2,2,0,0 } - ::oVBar:aPxlBtnBtm := { 0,2,2,0 } - ::oVBar:aPxlScroll := { 0,2,0,0 } - ::oVBar:Create() - - aadd( ::aPaint, { ::oVBar:bBtnLeftTop, ; - { WVT_BLOCK_BUTTON, ::oVBar:nBtn1Top, ::oVBar:nBtn1Left, ; - ::oVBar:nBtn1Bottom, ::oVBar:nBtn1Right } } ) - - aadd( ::aPaint, { ::oVBar:bBtnRightBottom, ; - { WVT_BLOCK_BUTTON, ::oVBar:nBtn2Top, ::oVBar:nBtn2Left, ; - ::oVBar:nBtn2Bottom, ::oVBar:nBtn2Right } } ) - - aadd( ::aPaint, { ::oVBar:bBtnScroll, ; - { WVT_BLOCK_BUTTON, ::oVBar:nSTop, ::oVBar:nSLeft, ; - ::oVBar:nSBottom, ::oVBar:nSRight } } ) - - ::oParent:AddObject( ::oVBar ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetHBar() CLASS WvtBrowse - - if ::lHSBar - ::oHBar := WvtScrollBar():New( self, 999990, ; - ::oBrw:nBottom+1, ::oBrw:nLeft, ::oBrw:nBottom+1, ::oBrw:nRight ) - ::oHBar:nBarType := 2 - ::oHBar:bTotal := ::bTotalColumns - ::oHBar:bCurrent := ::bCurrentColumn - ::oHBar:aPxlBtnLft := { 2,-2,0,0 } - ::oHBar:aPxlBtnRgt := { 2, 0,0,2 } - ::oHBar:aPxlScroll := { 2, 0,0,0 } - ::oHBar:Create() - - aadd( ::aPaint, { ::oHBar:bBtnLeftTop, ; - { WVT_BLOCK_BUTTON, ::oHBar:nBtn1Top, ::oHBar:nBtn1Left, ; - ::oHBar:nBtn1Bottom, ::oHBar:nBtn1Right } } ) - aadd( ::aPaint, { ::oHBar:bBtnRightBottom, ; - { WVT_BLOCK_BUTTON, ::oHBar:nBtn2Top, ::oHBar:nBtn2Left, ; - ::oHBar:nBtn2Bottom, ::oHBar:nBtn2Right } } ) - aadd( ::aPaint, { ::oHBar:bBtnScroll, ; - { WVT_BLOCK_BUTTON, ::oHBar:nSTop, ::oHBar:nSLeft, ; - ::oHBar:nSBottom, ::oHBar:nSRight } } ) - - ::oParent:AddObject( ::oHBar ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtBrowse - LOCAL nWorkArea := Select() - - if ISBLOCK( ::bOnRefresh ) - eval( ::bOnRefresh, self ) - else - Select( ::cAlias ) - - ::oBrw:RefreshAll() - ::oBrw:ForceStable() - - Select( nWorkArea ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HandleEvent( nKey ) CLASS WvtBrowse - Local lRet := .f. - - if valtype( ::bHandleEvent ) == 'B' - lRet := eval( ::bHandleEvent, self, ::oParent:cPaintBlockID, ::oBrw, nKey ) - endif - - RETURN lRet - -//-------------------------------------------------------------------// - -METHOD NotifyChild( nIndex, nKey, oCurObj ) CLASS WvtBrowse - Local xData, i - - if nIndex > 0 .and. nIndex <= len( ::aChildren ) - if valtype( ::aChildren[ nIndex, OBJ_CHILD_DATABLOCK ] ) == 'B' - xData := eval( ::aChildren[ nIndex, OBJ_CHILD_DATABLOCK ] ) - endif - - eval( ::aChildren[ nIndex, OBJ_CHILD_REFRESHBLOCK ], ; - ::aChildren[ nIndex, OBJ_CHILD_OBJ ],; - ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:oParent:cPaintBlockID, ; - ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:oBrw, ; - nKey, ; - xData ) - - if ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:nChildren > 0 - // Pretend if focus is current on this object - // - Eval( ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:bOnFocus, ::aChildren[ nIndex, OBJ_CHILD_OBJ ] ) - - for i := 1 to ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:nChildren - ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:NotifyChild( i, nKey, ::aChildren[ nIndex, OBJ_CHILD_OBJ ] ) - next - - // Restore previous environments - Eval( oCurObj:bOnFocus, oCurObj ) - endif - endif - - RETURN Self - -//----------------------------------------------------------------------// - -METHOD Hilite() CLASS WvtBrowse - LOCAL b := ::oBrw - - DispOutAt( b:nTop-2, b:nLeft-2, pad( ' '+::cDesc, b:nRight-b:nLeft+5 ), ::cColorHilite ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD DeHilite() CLASS WvtBrowse - LOCAL b := ::oBrw - - DispOutAt( b:nTop-2, b:nLeft-2, pad( ' '+::cDesc, b:nRight-b:nLeft+5 ), ::cColorDeHilite ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetTooltip() CLASS WvtBrowse - LOCAL cTip, nArea - - if ISBLOCK( ::bTooltip ) - ::SaveSettings() - nArea := Select( ::cAlias ) - - Select( ::cAlias ) - - cTip := Eval( ::bTooltip ) - - Select( nArea ) - - ::RestSettings() - endif - - if cTip <> nil - ::Tooltip := cTip - endif - - Wvt_SetTooltip( ::nTop, ::nLeft, ::nBottom, ::nRight, ::Tooltip ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SaveSettings CLASS WvtBrowse - - if ISBLOCK( ::bSaveSettings ) - ::xSettings := Eval( ::bSaveSettings, self ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD RestSettings() CLASS WvtBrowse - - if ::xSettings <> nil .and. ISBLOCK( ::bRestSettings ) - Eval( ::bRestSettings, self ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD PaintBlock( nPaintObj ) CLASS WvtBrowse - LOCAL bBlock, b := ::oBrw - - switch nPaintObj - - case 1 - bBlock := {|| Wvt_DrawBoxRaised( b:nTop-2,b:nLeft-2,b:nBottom+1,b:nRight+2 ) } - aadd( ::aPaint, { bBlock, { WVT_BLOCK_BOX, b:nTop-3,b:nLeft-3,b:nBottom+2,b:nRight+3 } } ) - exit - - case 2 - bBlock := {|| Wvt_DrawBoxRecessed( b:nTop,b:nLeft,b:nBottom,b:nRight ) } - aadd( ::aPaint, { bBlock, { WVT_BLOCK_BOX, b:nTop-1,b:nLeft-1,b:nBottom+1,b:nRight+1 } } ) - exit - - case 3 - bBlock := {|| Wvt_DrawGridHorz( b:nTop+3, b:nLeft, b:nRight, b:nBottom - b:nTop - 2 ) } - aadd( ::aPaint, { bBlock, { WVT_BLOCK_GRID_H, b:nTop+4, b:nLeft+1, b:nBottom-1, b:nRight-1 } } ) - exit - - case 4 - bBlock := {|| Wvt_DrawGridVert( b:nTop, b:nBottom, b:aColumnsSep, len( b:aColumnsSep ) ) } - aadd( ::aPaint, { bBlock, { WVT_BLOCK_GRID_V, b:nTop+1, b:nLeft+1, b:nBottom-1, b:nRight-1, b } } ) - exit - - end - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// WvtStatusBar -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtStatusBar FROM WvtObject - - DATA aPanels - DATA cColor - - METHOD New() - METHOD Create() - METHOD SetPanels() - METHOD SetText() - METHOD SetIcon() - METHOD Refresh() - METHOD Update( nPanel, cText ) - METHOD PaintBlock() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtStatusBar - - DEFAULT nTop TO oParent:MaxRow() - DEFAULT nLeft TO 0 - DEFAULT nBottom TO oParent:MaxRow() - DEFAULT nRight TO oParent:MaxCol() - - ::Super:New( oParent, DLG_OBJ_STATUSBAR, nID, nTop, nLeft, nBottom, nRight ) - - ::cColor := 'N/W' - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtStatusBar - - ::Refresh() - ::PaintBlock( DLG_OBJ_STATUSBAR, self ) - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD PaintBlock() CLASS WvtStatusBar - LOCAL a_:= {}, nPanels - - aeval( ::aPanels, {|o| aadd( a_,o:nTop ) , aadd( a_,o:nLeft ), ; - aadd( a_,o:nBottom ), aadd( a_,o:nRight ) } ) - - a_[ len( a_ ) ]++ - nPanels := len( ::aPanels ) - - ::bPaint := {|| Wvt_DrawStatusBar( nPanels, a_ ) } - aadd( ::aPaint, { ::bPaint,; - { WVT_BLOCK_STATUSBAR, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetPanels( aPanels ) CLASS WvtStatusBar - LOCAL i, oPanel, nID - LOCAL nLastCol := ::oParent:MaxCol() - - nID := 200000 - - ::aPanels := {} - - oPanel := WvtPanel():New( ::oParent, ++nID, ::nTop, 0 ) - - aadd( ::aPanels, oPanel ) - - if aPanels <> nil - for i := 1 to len( aPanels ) - if ::oParent:MaxCol() > aPanels[ i ] - oPanel := WvtPanel():New( ::oParent, ++nID, ::nTop, aPanels[ i ] ) - aadd( ::aPanels, oPanel ) - endif - next - endif - - atail( ::aPanels ):nRight := nLastCol - - for i := len( ::aPanels ) - 1 TO 1 STEP -1 - oPanel := ::aPanels[ i ] - oPanel:nRight := ::aPanels[ i+1 ]:nLeft - oPanel:cColor := ::cColor - next - - RETURN self - -//-------------------------------------------------------------------// - -METHOD Update( nPanel, cText, cColor ) - LOCAL oPanel - - if nPanel > 0 .and. nPanel <= len( ::aPanels ) - oPanel := ::aPanels[ nPanel ] - oPanel:Text := cText - oPanel:cColor := if( cColor == nil, 'N/W', cColor ) - oPanel:Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetText( nPanel, cText, cColor ) CLASS WvtStatusBar - LOCAL oPanel - - DEFAULT cColor TO ::cColor - - if nPanel > 0 .and. nPanel <= len( ::aPanels ) - oPanel := ::aPanels[ nPanel ] - oPanel:Text := cText - oPanel:cColor := cColor - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetIcon( nPanel, cIconFile ) CLASS WvtStatusBar - - if nPanel > 0 .and. nPanel <= len( ::aPanels ) - ::aPanels[ nPanel ]:cIconFile := cIconFile - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtStatusBar - LOCAL i - - for i := 1 to len( ::aPanels ) - ::aPanels[ i ]:Refresh() - next - - RETURN nil - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtPanel -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtPanel FROM WvtObject - - DATA cColor - DATA cTxt - DATA cIconFile - - ACCESS Text INLINE ::cTxt - ASSIGN Text( cText ) INLINE ::cTxt := pad( cText, ::nRight - ::nLeft-2 ) - - METHOD New() - METHOD Refresh() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nId, nTop, nLeft ) CLASS WvtPanel - - ::Super:New( oParent, DLG_OBJ_PANEL, nId, nTop, nLeft, nTop ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtPanel - - if ::Text <> nil - DispOutAt( ::nTop, ::nLeft+1, ::Text, ::cColor ) - endif - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtLabel -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtLabel FROM WvtObject - - ACCESS Text INLINE if( ::cText == nil, '', ::cText ) - ASSIGN Text( cTxt ) INLINE ::cText := if( cTxt == nil, '', cTxt ) - - METHOD New() - METHOD Create() - METHOD Configure() - METHOD Refresh() - METHOD HoverOn() - METHOD HoverOff() - METHOD SetText() - METHOD SetTextColor() - METHOD SetBackColor() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtLabel - - ::Super:New( oParent, DLG_OBJ_LABEL, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create( lConfg ) CLASS WvtLabel - - DEFAULT lConfg TO .f. - - DEFAULT ::nBottom TO ::nTop - DEFAULT ::nRight TO ::nLeft + len( ::Text ) - DEFAULT ::nTextColor TO RGB( 0,0,0 ) - - ::nTextColorHoverOff := ::nTextColor - ::nBackColorHoverOff := ::nBackColor - - ::hFont := Wvt_CreateFont( ::cFont, ::nFontHeight, ::nFontWidth, ::nFontWeight, ::lItalic,; - ::lUnderline, ::lStrikeout, ::nCharSet, ::nFontQuality, ::nAngle ) - if ::hFont <> 0 - if !( lConfg ) - ::bPaint := {|| Wvt_DrawLabelObj( ::nTop, ::nLeft, ::nBottom, ::nRight,; - ::Text, ::nAlignHorz, ::nAlignVert, ::nTextColor, ::nBackColor, ::hFont ) } - aadd( ::aPaint, { ::bPaint, { WVT_BLOCK_LABEL, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) - endif - endif - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtLabel - -Eval( ::bPaint ) - -RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetText( cTxt ) CLASS WvtLabel - - if valtype( cTxt ) == 'C' - ::Text := cTxt - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetTextColor( nRGB ) CLASS WvtLabel - - if valtype( nRGB ) == 'N' - ::nTextColor := nRGB - ::nTextColorHoverOff := nRGB - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetBackColor( nRGB ) CLASS WvtLabel - - if valtype( nRGB ) == 'N' - ::nBackColor := nRGB - ::nBackColorHoverOff := nRGB - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Configure() CLASS WvtLabel - - ::nTextColorHoverOff := ::nTextColor - ::nBackColorHoverOff := ::nBackColor - - if ::hFont <> 0 - Win_DeleteObject( ::hFont ) - endif - - ::hFont := Wvt_CreateFont( ::cFont, ::nFontHeight, ::nFontWidth, ::nFontWeight, ::lItalic,; - ::lUnderline, ::lStrikeout, ::nCharSet, ::nFontQuality, ::nAngle ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOn() CLASS WvtLabel - LOCAL lOn := .f. - - if ::nTextColorHoverOn <> nil - lOn := .t. - ::nTextColor := ::nTextColorHoverOn - endif - if ::nBackColorHoverOn <> nil - lOn := .t. - ::nBackColor := ::nBackColorHoverOn - endif - - if lOn - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOff() CLASS WvtLabel - LOCAL lOn := .f. - - if ::nTextColorHoverOn <> nil - lOn := .t. - ::nTextColor := ::nTextColorHoverOff - endif - if ::nBackColorHoverOn <> nil - lOn := .t. - ::nBackColor := ::nBackColorHoverOff - endif - - if lOn - ::Refresh() - endif - - Return Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtToolBar -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtToolBar FROM WvtObject - - DATA nPaintID - DATA aObjects INIT {} - DATA lHidden INIT .f. - DATA nCurButton INIT 0 - DATA lActive - DATA lFloating - DATA wScreen - DATA cScreen - DATA nBtnLeft INIT 0 - DATA nRGBSep INIT RGB( 150,150,150 ) - - ACCESS nButtons INLINE len( ::aButtons ) - - METHOD New() - METHOD Create() - METHOD Refresh() - METHOD AddButton() - METHOD PaintToolBar() - METHOD HoverOn() - METHOD HoverOff() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtToolBar - - nTop := 0 - nLeft := 0 - DEFAULT nBottom TO 1 - nRight := oParent:MaxCol() - - ::Super:New( oParent, DLG_OBJ_TOOLBAR, nID, nTop, nLeft, nBottom, nRight ) - - ::lActive := .t. - ::lFloating := .F. - ::nPaintID := ::oParent:nPaintID++ - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtToolBar - - if ::lFloating - ::lActive := .f. - ::lHidden := .t. - endif - - aeval( ::aObjects, {|o| o:lActive := ::lActive } ) - - ::bPaint := {|| ::PaintToolBar() } - aadd( ::aPaint, { ::bPaint,; - { WVT_BLOCK_TOOLBAR, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtToolBar - - if ::lFloating - DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, ' ', 'n/w' ) - else - Wvt_InvalidateRect( ::nTop, ::nLeft, ::nTop, ::nLeft ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD PaintToolBar() CLASS WvtToolBar - - if ( ::lActive ) - Wvt_DrawLine( ::nTop, ::nLeft, ::nBottom, ::nRight, 0, 1, 2, , , ::nRGBSep ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD AddButton( cFileImage, bBlock, cTooltip ) CLASS WvtToolBar - LOCAL oObj, nCol - - nCol := ( ::nBottom-::nTop+1 ) * 2 - - oObj := WvtToolButton():New( self ) - - oObj:lActive := ::lActive - oObj:nTop := ::nTop - oObj:nLeft := ::nBtnLeft + 1 - oObj:nBottom := ::nBottom - - if valtype( cFileImage ) == 'C' - oObj:nBtnType := TLB_BUTTON_TYPE_IMAGE - oObj:nRight := oObj:nLeft + nCol - 1 - oObj:cFileImage := cFileImage - oObj:bOnLeftUp := bBlock - oObj:Tooltip := cTooltip - else - oObj:nBtnType := TLB_BUTTON_TYPE_SEPARATOR - oObj:nRight := oObj:nLeft - endif - - aadd( ::aObjects, oObj ) - - ::nBtnLeft := oObj:nRight + 1 - ::nCurButton++ - - ::oParent:AddObject( oObj ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOn() - - if ::lFloating .and. ::lHidden - ::lHidden := .f. - ::lActive := .t. - // ::cScreen := SaveScreen( ::nTop, ::nLeft, ::nBottom, ::nRight ) - // ::wScreen := Wvt_SaveScreen( ::nTop, ::nLeft, ::nBottom, ::nRight ) - - aeval( ::aObjects, {|o| o:lActive := ::lActive } ) - - ::Refresh() - endif - - RETURN self - -//-------------------------------------------------------------------// - -METHOD HoverOff() - - if ::lFloating .and. !( ::lHidden ) - ::lHidden := .t. - ::lActive := .f. - aeval( ::aObjects, {|o| o:lActive := ::lActive } ) - // RestScreen( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cScreen ) - // Wvt_RestScreen( ::nTop, ::nLeft, ::nBottom, ::nRight, ::wScreen, .f. ) - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtToolButton -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtToolButton FROM WvtObject - - DATA cFileImage - DATA nCurState INIT 0 - DATA nBtnType INIT TLB_BUTTON_TYPE_IMAGE - DATA aPxlOffSet INIT { 0, -1, -3, 1 } - - METHOD New() - METHOD Create() - METHOD Refresh() - METHOD LeftDown() - METHOD LeftUp() - METHOD HoverOn() - METHOD HoverOff() - METHOD PaintButton() - - ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent ) CLASS WvtToolButton - - ::Super:New( oParent, DLG_OBJ_BUTTON ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtToolButton - - ::bPaint := {|| ::PaintButton() } - aadd( ::aPaint, { ::bPaint,; - { WVT_BLOCK_BUTTON, ::nTop, ::nLeft, ::nBottom, ::nRight }} ) - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtToolButton - - if ::lActive - Eval( ::bPaint ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD PaintButton() CLASS WvtToolButton - - if ::lActive - if ::nBtnType == TLB_BUTTON_TYPE_IMAGE - Wvt_DrawImage( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cFileImage, {4,4,-6,-4} ) - else - Wvt_DrawLine( ::nTop, ::nLeft, ::nBottom, ::nRight, 1, 1, , , , ::oParent:nRGBSep ) - endif - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD LeftDown() CLASS WvtToolButton - LOCAL lRet := .f. - - if ::lActive .and. ::nBtnType == TLB_BUTTON_TYPE_IMAGE - Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet, 2 ) - lRet := .t. - endif - - RETURN lRet - -//-------------------------------------------------------------------// - -METHOD LeftUp() CLASS WvtToolButton - LOCAL lRet := .f. - - if ::lActive .and. ::nBtnType == TLB_BUTTON_TYPE_IMAGE - Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet, 1 ) - Eval( ::bOnLeftUp ) - lRet := .t. - endif - - RETURN lRet - -//-------------------------------------------------------------------// - -METHOD HoverOn() CLASS WvtToolButton - - ::oParent:HoverOn() - - if ::lActive .and. ::nBtnType == TLB_BUTTON_TYPE_IMAGE - Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet, 1 ) - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOff() CLASS WvtToolButton - - ::oParent:HoverOff() - - if ::lActive .and. ::nBtnType == TLB_BUTTON_TYPE_IMAGE - Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight,::aPxlOffSet, 0 ) - endif - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtImage -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtImage FROM WvtObject - - DATA cImageFile - - ACCESS cImage INLINE ::cImageFile - ASSIGN cImage( cImg ) INLINE ::cImageFile := cImg - - METHOD New() - METHOD Create() - METHOD SetImage() - - ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtImage - - ::Super:New( oParent, DLG_OBJ_IMAGE, nId, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtImage - - ::bPaint := {|| if( file( ::cImage ), ; - Wvt_DrawImage( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cImage ),'' ) } - - aadd( ::aPaint, { ::bPaint,; - { WVT_BLOCK_IMAGE, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetImage( cImage ) CLASS WvtImage - - if cImage <> nil .and. file( cImage ) - ::cImageFile := cImage - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtStatic -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtStatic FROM WvtObject - - DATA nStatic - DATA nOrient - DATA nFormat - DATA nAlign - DATA nStyle - DATA nThick - DATA nColor - - DATA nfTop - DATA nfLeft - DATA nfBottom - DATA nfRight - - DATA nHorzVert INIT 0 - DATA aRGBb - DATA aRGBe - - DATA aPxlOffSet INIT {} - - METHOD New() - METHOD Create() - METHOD Refresh() - METHOD HoverOn() - METHOD HoverOff() - - ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtStatic - - ::Super:New( oParent, DLG_OBJ_STATIC, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtStatic - LOCAL lInside := .f. - - switch ::nStatic - - case WVT_STATIC_LINE - lInside := .t. - ::bPaint := {|| Wvt_DrawLine( ::nTop, ::nLeft, ::nBottom, ::nRight, ; - ::nOrient, ::nFormat, ::nAlign, ::nStyle, ::nThick, ::nColor ) } - exit - - case WVT_STATIC_BOXRAISED - ::bPaint := {|| Wvt_DrawBoxRaised( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_BOXRECESSED - ::bPaint := {|| Wvt_DrawBoxRecessed( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_BOXGROUP - ::bPaint := {|| Wvt_DrawBoxGroup( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_BOXGROUPRAISED - ::bPaint := {|| Wvt_DrawBoxGroupRaised( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_OUTLINE - ::bPaint := {|| Wvt_DrawOutline( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_RECTANGLE - lInside := .t. - ::bPaint := {|| Wvt_DrawRectangle( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_ROUNDRECT - lInside := .t. - ::bPaint := {|| Wvt_DrawRoundRect( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_FOCUSRECT - lInside := .t. - ::bPaint := {|| Wvt_DrawFocusRect( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_ELLIPSE - lInside := .t. - ::bPaint := {|| Wvt_DrawEllipse( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } - exit - - case WVT_STATIC_SHADEDRECT - lInside := .t. - ::bPaint := {|| Wvt_DrawShadedRect( ::nTop, ::nLeft, ::nBottom, ::nRight, ; - ::aPxlOffSet, ::nHorzVert, ::aRGBb, ::aRGBe ) } - exit - - end - - if lInside - ::nfTop := ::nTop - ::nfLeft := ::nLeft - ::nfBottom := ::nBottom - ::nfRight := ::nRight - else - ::nfTop := ::nTop - 1 - ::nfLeft := ::nLeft - 1 - ::nfBottom := ::nBottom + 1 - ::nfRight := ::nRight + 1 - endif - - aadd( ::aPaint, { ::bPaint,; - { WVT_BLOCK_STATIC, ::nfTop, ::nfLeft, ::nfBottom, ::nfRight }} ) - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOn() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOff() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtStatic - - Eval( ::bPaint ) - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtPushButton -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtPushButton FROM WvtObject - - DATA cCaption - DATA cFileImage - - ACCESS block INLINE ::bOnLeftUp - ASSIGN block( bBlock ) INLINE ::bOnLeftUp := bBlock - - METHOD New() - METHOD Create() - METHOD LeftDown() - METHOD LeftUp() - METHOD PaintButton() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtPushButton - - ::Super:New( oParent, DLG_OBJ_PUSHBUTTON, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtPushButton - - ::bPaint := {|| ::PaintButton() } - - aadd( ::aPaint, { ::bPaint,; - { WVT_BLOCK_BUTTON, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD PaintButton() CLASS WvtPushButton - - if ::cCaption == nil - Wvt_DrawImage( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cFileImage, { 4, 4,-4, -4 } ) - else - Wvt_DrawButton( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cCaption, , 4 ) - endif - Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, {0,0,0,0}, 1 ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD LeftDown() CLASS WvtPushButton - - Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight,{0,0,0,0} , 2 ) - - RETURN .t. - -//-------------------------------------------------------------------// - -METHOD LeftUp() CLASS WvtPushButton - - Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, {0,0,0,0}, 1 ) - ::Eval( ::bOnLeftUp ) - - RETURN .t. - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtGets -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtGets FROM WvtObject - - DATA aGetList INIT {} - DATA nLastGet INIT 1 - DATA nCurGet INIT 1 - DATA GetList INIT {} - DATA cDesc INIT '' - - METHOD New() - METHOD Create() - METHOD KillFocus() - METHOD SetFocus() - METHOD HandleEvent() - METHOD AddGets() - METHOD PaintBlock() - METHOD Read() - METHOD Hilite() - METHOD DeHilite() - METHOD GetData() - METHOD SetData() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtGets - - ::Super:New( oParent, DLG_OBJ_GETS, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtGets - LOCAL i, GetList - LOCAL nCurRow := row() - LOCAL nCurCol := Col() - - for i := 1 to len( ::aGetList ) - GetList := {} - - DEFAULT ::aGetList[ i,7 ] TO 'N/W*,N/W*,,,N/GR*' - DEFAULT ::aGetList[ i,5 ] TO {|| .T. } - DEFAULT ::aGetList[ i,6 ] TO {|| .T. } - - @ ::aGetList[ i,1 ], ::aGetList[ i,2 ] GET ::aGetList[ i,3 ] PICTURE ::aGetList[ i,4 ] COLOR ::aGetList[ i,7 ] - - aadd( ::GetList, GetList[ 1 ] ) - - ::GetList[ i ]:Display() - ::PaintBlock( i ) - next - SetPos( nCurRow, nCurCol ) - - ::Super:Create() - ::Dehilite() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD PaintBlock( nIndex ) CLASS WvtGets - LOCAL nLen, bPaint - - nLen := len( Transform( ::aGetList[ nIndex,3 ], ::aGetList[ nIndex,4 ] ) ) - - bPaint := {|| Wvt_DrawBoxGet( ::aGetList[ nIndex,1 ], ::aGetList[ nIndex,2 ], nLen ) } - - aadd( ::aPaint, { bPaint,; - { WVT_BLOCK_GETS, ::aGetList[ nIndex,1 ]-1, ::aGetList[ nIndex,2 ]-1, ; - ::aGetList[ nIndex,1 ]-1, ::aGetList[ nIndex,2 ]+nLen } } ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetFocus() CLASS WvtGets - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD KillFocus() CLASS WvtGets - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD AddGets( nRow, nCol, xVar, cPic, cColor, bValid, bWhen ) CLASS WvtGets - - aadd( ::aGetList, { nRow, nCol, xVar, cPic, bValid, bWhen, cColor } ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HandleEvent( nKey ) CLASS WvtGets - Local lRet := .f. - - do case - case nKey == K_LDBLCLK - ::Read() - lRet := .t. - endcase - - RETURN lRet - -//-------------------------------------------------------------------// - -METHOD Read() CLASS WvtGets - - ReadModal( ::GetList, ::nCurGet ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD GetData() CLASS WvtGets - LOCAL aData - - RETURN aData - -//-------------------------------------------------------------------// - -METHOD SetData( /*aData*/ ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Hilite() CLASS WvtGets - - DispOutAt( ::nTop, ::nLeft, pad( ' '+::cDesc, ::nRight-::nLeft+1 ), ::cColorHilite ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD DeHilite() CLASS WvtGets - - DispOutAt( ::nTop, ::nLeft, pad( ' '+::cDesc, ::nRight-::nLeft+1 ), ::cColorDeHilite ) - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtScrollBar -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtScrollBar FROM WvtObject - - DATA nBarType INIT WVT_SCROLLBAR_VERT - - DATA nTotal INIT 100 - DATA nCurrent INIT 1 - DATA nThumbPos INIT 0 - DATA nBlockNo INIT 1 - - DATA nSTop - DATA nSLeft - DATA nSBottom - DATA nSRight - - DATA nBtn1Top - DATA nBtn1Left - DATA nBtn1Bottom - DATA nBtn1Right - - DATA nBtn2Top - DATA nBtn2Left - DATA nBtn2Bottom - DATA nBtn2Right - - DATA bBtnLeftTop - DATA bBtnLeftTopDep - DATA bBtnRightBottom - DATA bBtnRightBottomDep - - DATA bBtnScroll - - DATA bTotal - DATA bCurrent - - DATA lHidden INIT .t. - - DATA aPxlBtnTop INIT {0,0,0,0} - DATA aPxlBtnLft INIT {0,0,0,0} - DATA aPxlBtnBtm INIT {0,0,0,0} - DATA aPxlBtnRgt INIT {0,0,0,0} - DATA aPxlScroll INIT {0,0,0,0} - - DATA lLeftDown INIT .f. - DATA lOnThumb INIT .f. - DATA lAnchored INIT .f. - DATA lOnLeftDown INIT .f. - - DATA nScrollUnits INIT 0 - - METHOD New() - METHOD Create() - METHOD Configure() - METHOD Refresh() - METHOD HandleEvent() - METHOD SetPos() - METHOD GetPos() - METHOD ThumbPos() - METHOD SetTooltip() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtScrollBar - - ::Super:New( oParent, DLG_OBJ_SCROLLBAR, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtScrollBar - - if ::nTop == nil .or. ::nLeft == nil - return nil - endif - - if ::nBarType == WVT_SCROLLBAR_VERT - DEFAULT ::nBottom TO ::nTop + 5 - DEFAULT ::nRight TO ::nLeft + 1 - - ::nRight := ::nLeft + 1 - ::nBottom := max( 7, ::nBottom ) - - ::nBtn1Top := ::nTop - ::nBtn1Left := ::nLeft - ::nBtn1Bottom := ::nTop - ::nBtn1Right := ::nRight - - ::nBtn2Top := ::nBottom - ::nBtn2Left := ::nLeft - ::nBtn2Bottom := ::nBottom - ::nBtn2Right := ::nRight - - ::nSTop := ::nTop + 1 - ::nSLeft := ::nLeft - ::nSBottom := ::nBottom - 1 - ::nSRight := ::nRight - - ::nScrollUnits := ::nSBottom - ::nSTop + 1 - - ::nTotal := Eval( ::bTotal ) - ::nCurrent := Eval( ::bCurrent ) - ::ThumbPos() - - ::bBtnLeftTop := ; - {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnTop,1 ) } - ::bBtnRightBottom := ; - {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnBtm,3 ) } - ::bBtnScroll := ; - {|| Wvt_DrawScrollThumbVert( ::nSTop ,::nSLeft ,::nSBottom,::nSRight,::aPxlScroll,; - ::nThumbPos ) } - ::bBtnLeftTopDep := ; - {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnTop,1,.t. ) } - ::bBtnRightBottomDep := ; - {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnBtm,3,.t. ) } - - else - DEFAULT ::nBottom TO ::nTop - DEFAULT ::nRight TO ::nLeft + 11 - - ::nBottom := ::nTop - ::nRight := max( 11, ::nRight ) - - ::nBtn1Top := ::nTop - ::nBtn1Left := ::nLeft - ::nBtn1Bottom := ::nBottom - ::nBtn1Right := ::nLeft + 1 - - ::nBtn2Top := ::nTop - ::nBtn2Left := ::nRight - 1 - ::nBtn2Bottom := ::nBottom - ::nBtn2Right := ::nRight - - ::nSTop := ::nTop - ::nSLeft := ::nLeft + 2 - ::nSBottom := ::nBottom - ::nSRight := ::nRight - 2 - - ::nScrollUnits := ::nSRight - ::nSLeft + 1 - - ::nTotal := Eval( ::bTotal ) - ::nCurrent := Eval( ::bCurrent ) - - ::ThumbPos() - - ::bBtnLeftTop := ; - {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnLft,2 ) } - ::bBtnRightBottom := ; - {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnRgt,4 ) } - ::bBtnScroll := ; - {|| Wvt_DrawScrollThumbHorz( ::nSTop,::nSLeft,::nSBottom,::nSRight,; - ::aPxlScroll,::nThumbPos ) } - ::bBtnLeftTopDep := ; - {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnLft,2,.t. ) } - ::bBtnRightBottomDep := ; - {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnRgt,4,.t. ) } - - endif - - ::bOnLeftUp := {|| ::HandleEvent( K_LBUTTONUP ) } - ::bOnLeftDown := {|| ::HandleEvent( K_LBUTTONDOWN ) } - ::bOnMMLeftDown := {|| ::HandleEvent( K_MMLEFTDOWN ) } - ::bOnLeftPressed := {|| ::HandleEvent( K_LBUTTONPRESSED ) } - - Eval( ::bBtnLeftTop ) - Eval( ::bBtnRightBottom ) - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Configure( nTop, nLeft, nBottom, nRight ) CLASS WvtScrollBar - - ::nTop := nTop - ::nLeft := nLeft - ::nBottom := nBottom - ::nRight := nRight - - ::Create() - ::Refresh() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtScrollBar - - Eval( ::bBtnScroll ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetPos( nTotal, nCurrent ) CLASS WvtScrollBar - - DEFAULT nTotal TO Eval( ::bTotal ) - DEFAULT nCurrent TO Eval( ::bCurrent ) - - ::nTotal := nTotal - ::nCurrent := nCurrent - - ::ThumbPos() - ::Refresh() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD ThumbPos() CLASS WvtScrollBar - LOCAL nNewPos := ::nThumbPos - LOCAL nRecPerUnit, nCurUnit - - if ::nBarType == WVT_SCROLLBAR_VERT - nRecPerUnit := ::nTotal / ::nScrollUnits - nCurUnit := int( ::nCurrent / nRecPerUnit ) - - if ::nCurrent == 1 - nCurUnit := 0 - elseif ::nCurrent == ::nTotal - nCurUnit := ::nScrollUnits - endif - nNewPos := ::nSTop + nCurUnit - - if nNewPos < ::nSTop - nNewPos := ::nSTop - elseif nNewPos > ::nSBottom - nNewPos := ::nSBottom - endif - - else - if ::nTotal < ::nScrollUnits - nCurUnit := ::nCurrent * int( ::nScrollUnits / ::nTotal ) - else - nRecPerUnit := ::nTotal / ::nScrollUnits - nCurUnit := int( ::nCurrent / nRecPerUnit ) - endif - - if ::nCurrent == 1 - nCurUnit := 0 - elseif ::nCurrent == ::nTotal - nCurUnit := ::nScrollUnits - endif - - nNewPos := ::nSLeft + nCurUnit - - if nNewPos < ::nSLeft - nNewPos := ::nSLeft - elseif nNewPos > ::nSRight - 1 - nNewPos := ::nSRight-1 - endif - - endif - - ::nThumbPos := nNewPos - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD GetPos() CLASS WvtScrollBar - - RETURN ::nCurrent - -//-------------------------------------------------------------------// - -METHOD SetTooltip() CLASS WvtScrollBar - - ::Tooltip := ltrim( str( ::nCurrent,12,0 ) ) + ' / ' + ; - ltrim( str( ::nTotal ,12,0 ) ) - - Wvt_SetToolTip( ::nTop, ::nLeft, ::nBottom, ::nRight, ::Tooltip ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HandleEvent( nKey ) CLASS WvtScrollBar - LOCAL nmRow, nmCol, nOff - LOCAL lHit := .F. - LOCAL mKeys_:={ K_LBUTTONDOWN, K_LBUTTONUP, K_MMLEFTDOWN, K_LBUTTONPRESSED } - - if ascan( mKeys_, nKey ) == 0 - return .f. - endif - - nmRow := MRow() - nmCol := MCol() - - do case - case ::nBarType == WVT_SCROLLBAR_VERT - lHit := .t. - - do case - case ::lAnchored .and. nKey == K_MMLEFTDOWN - if nmRow <> ::nThumbPos - nOff := ::nThumbPos - nmRow - if nOff > 0 - ::nThumbPos := max( ::nTop+1, nmRow ) - else - ::nThumbPos := min( ::nBottom-1, nmRow ) - endif - ::nCurrent := ( ::nTotal * ( ::nThumbPos - ::nTop ) / ::nScrollUnits ) - - if ::nCurrent > ::nTotal - ::nCurrent := ::nTotal - endif - if ::nCurrent < 1 - ::nCurrent := 1 - endif - - ::SetPos( ::nTotal, ::nCurrent ) - - ::SetTooltip() - Wvt_Keyboard( K_SBTHUMBTRACKVERT ) - else - lHit := .f. - endif - - case ::lAnchored .and. nKey == K_LBUTTONUP - ::lAnchored := .f. - - otherwise - lHit := .f. - - if nmCol >= ::nLeft .and. nmCol <= ::nRight - lHit := .t. - - do case - case nmRow == ::nThumbPos .and. nKey == K_LBUTTONDOWN - ::lAnchored := .t. - - case nKey == K_LBUTTONUP - if ( lHit := ::lOnLeftDown ) - do case - case nmRow == ::nTop - Eval( ::bBtnLeftTop ) - case nmRow == ::nBottom - Eval( ::bBtnRightBottom ) - case nmRow < ::nThumbPos .and. nmRow > ::nTop - case nmRow > ::nThumbPos .and. nmRow < ::nBottom - otherwise - lHit := .f. - endcase - if lHit - ::lOnLeftDown := .f. - endif - endif - - case nKey == K_LBUTTONPRESSED - if ( lHit := ::lOnLeftDown ) - do case - case nmRow == ::nTop - Wvt_Keyboard( K_SBLINEUP ) - case nmRow == ::nBottom - Wvt_Keyboard( K_SBLINEDOWN ) - case nmRow < ::nThumbPos .and. nmRow > ::nTop - Wvt_Keyboard( K_SBPAGEUP ) - case nmRow > ::nThumbPos .and. nmRow < ::nBottom - Wvt_Keyboard( K_SBPAGEDOWN ) - otherwise - lHit := .f. - endcase - endif - - case nKey == K_LBUTTONDOWN - do case - case nmRow == ::nTop - Eval( ::bBtnLeftTopDep ) - Wvt_Keyboard( K_SBLINEUP ) - case nmRow == ::nBottom - Eval( ::bBtnRightBottomDep ) - Wvt_Keyboard( K_SBLINEDOWN ) - case nmRow < ::nThumbPos .and. nmRow > ::nTop - Wvt_Keyboard( K_SBPAGEUP ) - case nmRow > ::nThumbPos .and. nmRow < ::nBottom - Wvt_Keyboard( K_SBPAGEDOWN ) - otherwise - lHit := .f. - endcase - if lHit - ::lOnLeftDown := .t. - endif - endcase - endif - - endcase - - case ::nBarType == WVT_SCROLLBAR_HORZ - do case - case ::lAnchored .and. nKey == K_MMLEFTDOWN - if ( lHit := ( nmCol < ::nThumbPos .or. nmCol > ::nThumbPos+1 ) ) - - nOff := ::nThumbPos - nmCol - if nOff > 0 - ::nThumbPos := max( ::nLeft+2, nmCol ) - else - ::nThumbPos := min( ::nRight-2, nmCol ) - endif - - ::nCurrent := ( ::nTotal * ( ::nThumbPos - ::nLeft+1 ) / ::nScrollUnits ) - - if ::nCurrent > ::nTotal - ::nCurrent := ::nTotal - endif - if ::nCurrent < 1 - ::nCurrent := 1 - endif - - ::SetPos( ::nTotal, ::nCurrent ) - - Wvt_Keyboard( K_SBTHUMBTRACKHORZ ) - endif - - case ::lAnchored .and. nKey == K_LBUTTONUP - ::lAnchored := .f. - lHit := .t. - - otherwise - - if ( lHit := nmRow == ::nTop .and. nmCol >= ::nLeft .and. nmCol <= ::nRight ) - - do case - case nKey == K_LBUTTONDOWN .and. nmCol >= ::nThumbPos .and. nmCol <= ::nThumbPos+1 - ::lAnchored := .t. - - case nKey == K_LBUTTONUP - - if ( lHit := ::lOnLeftDown ) - do case - case nmCol >= ::nLeft .and. nmCol <= ::nLeft+1 - Eval( ::bBtnLeftTop ) - case nmCol >= ::nRight-1 .and. nmCol <= ::nRight - Eval( ::bBtnRightBottom ) - case nmCol < ::nThumbPos - case nmCol > ::nThumbPos+1 - otherwise - lHit := .f. - endcase - if lHit - ::lOnLeftDown := .f. - endif - endif - - case nKey == K_LBUTTONPRESSED - if ( lHit := ::lOnLeftDown ) - do case - case nmCol == ::nLeft .or. nmCol == ::nLeft+1 - Wvt_Keyboard( K_SBLINELEFT ) - case nmCol == ::nRight .or. nmCol == ::nRight-1 - Wvt_Keyboard( K_SBLINERIGHT ) - case nmCol < ::nThumbPos - Wvt_Keyboard( K_SBPAGELEFT ) - case nmCol > ::nThumbPos+1 - Wvt_Keyboard( K_SBPAGERIGHT ) - otherwise - lHit := .f. - endcase - endif - - case nKey == K_LBUTTONDOWN - do case - case nmCol == ::nLeft .or. nmCol == ::nLeft+1 - Eval( ::bBtnLeftTopDep ) - Wvt_Keyboard( K_SBLINELEFT ) - case nmCol == ::nRight .or. nmCol == ::nRight-1 - Eval( ::bBtnRightBottomDep ) - Wvt_Keyboard( K_SBLINERIGHT ) - case nmCol < ::nThumbPos - Wvt_Keyboard( K_SBPAGELEFT ) - case nmCol > ::nThumbPos+1 - Wvt_Keyboard( K_SBPAGERIGHT ) - otherwise - lHit := .f. - endcase - if lHit - ::lOnLeftDown := .t. - endif - endcase - endif - endcase - endcase - - RETURN lHit - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// CLASS WvtBanner -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtBanner FROM WvtObject - - DATA nTimeDelay INIT 0.5 // One-half Second - DATA nDirection INIT 0 // LEFT 1-RIGHT - DATA nCharToSkip INIT 1 - DATA cText INIT '' - DATA cDispText INIT '' - DATA nTextLen INIT 0 - DATA nTextIndex INIT 0 - - DATA oLabel - - DATA nAlignVert INIT 2 // Center - - DATA nCurSeconds INIT 0 - DATA nCurAlign - - METHOD New() - METHOD Create() - METHOD Configure() - METHOD Refresh() - METHOD HoverOn() - METHOD HoverOff() - METHOD OnTimer() - METHOD SetText() - METHOD Destroy() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtBanner - - ::Super:New( oParent, DLG_OBJ_BANNER, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtBanner - - ::cDispText := ::cText - - ::oLabel := WvtLabel():New( ::oParent, , ::nTop, ::nLeft, ::nBottom, ::nRight ) - ::oLabel:Text := ::cDispText - ::oLabel:cFont := ::cFont - ::oLabel:nFontHeight := ::nFontHeight - ::oLabel:nFontWidth := ::nFontWidth - ::oLabel:nFontWeight := ::nFontWeight - ::oLabel:nFontQuality := ::nFontQuality - ::oLabel:lItalic := ::lItalic - ::oLabel:lStrikeout := ::lStrikeout - ::oLabel:lUnderline := ::lUnderline - ::oLabel:nAlignVert := ::nAlignVert - ::oLabel:nAlignHorz := if( ::nDirection == 0, 0, 1 ) - ::oLabel:nTextColor := ::nTextColor - ::oLabel:nBackColor := ::nBackColor - ::oLabel:nTextColorHoverOn := ::nTextColorHoverOn - ::oLabel:nBackColorHoverOn := ::nBackColorHoverOn - - ::oLabel:Create() - - ::nCurSeconds := Seconds() - ::nTextLen := len( ::cText ) - ::nTextIndex := if( ::nDirection == 0, 1, ::nTextLen ) - ::nCurAlign := ::nDirection - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Destroy() CLASS WvtBanner - - Win_DeleteObject( ::oLabel:hFont ) - - RETURN nil - -//-------------------------------------------------------------------// - -METHOD Configure() CLASS WvtBanner - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD OnTimer() CLASS WvtBanner - - ::Refresh() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetText( cText ) CLASS WvtBanner - - if cText <> nil - ::cText := cText - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtBanner - LOCAL nNewTime - - if abs( ( nNewTime := Seconds() ) - ::nCurSeconds ) >= ::nTimeDelay - ::nCurSeconds := nNewTime - - if ::nDirection == 0 - ::nTextIndex++ - if ::nTextIndex > ::nTextLen - ::nTextIndex := 1 - ::nCurAlign := if( ::nCurAlign == 0, 1, 0 ) - endif - - if ::nCurAlign == 0 // Left - ::cDispText := substr( ::cText,::nTextIndex ) - else // Right - ::cDispText := substr( ::cText, 1, ::nTextIndex ) - endif - else - ::nTextIndex-- - if ::nTextIndex < 0 - ::nTextIndex := ::nTextLen - ::nCurAlign := if( ::nCurAlign == 0, 1, 0 ) - endif - - if ::nCurAlign == 0 // Left - ::cDispText := substr( ::cText,::nTextIndex ) - else // Right - ::cDispText := substr( ::cText, 1, ::nTextIndex ) - endif - endif - - ::oLabel:nAlignHorz := ::nCurAlign - ::oLabel:SetText( ::cDispText ) - ::oLabel:Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOn() CLASS WvtBanner - - ::oLabel:HoverOn() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOff() CLASS WvtBanner - - ::oLabel:HoverOff() - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtTextBox -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtTextBox FROM WvtObject - - DATA cText INIT '' - - METHOD New() - METHOD Create() - METHOD Configure() - METHOD Refresh() - METHOD SetText() - METHOD HoverOn() - METHOD HoverOff() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtTextBox - - ::Super:New( oParent, DLG_OBJ_TEXTBOX, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtTextBox - - ::nTextColorHoverOff := ::nTextColor - - ::hFont := Wvt_CreateFont( ::cFont, ::nFontHeight, ::nFontWidth, ; - ::nFontWeight, ::lItalic, ::lUnderline, ::lStrikeout, ; - ::nCharSet, ::nFontQuality, 0 ) - - if ::hFont <> 0 - ::bPaint := {|| Wvt_DrawTextBox( ::nTop, ::nLeft, ::nBottom, ::nRight, ; - ::aPxlTLBR, ::cText, ::nAlignHorz, ::nAlignVert, ; - ::nTextColor, ::nBackColor, ::nBackMode, ::hFont ) } - - aadd( ::aPaint, { ::bPaint, { WVT_BLOCK_LABEL, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) - endif - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Refresh() CLASS WvtTextBox - - Eval( ::bPaint ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Configure() CLASS WvtTextBox - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD SetText( cText ) CLASS WvtTextBox - - if cText <> nil - ::cText := cText - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOn( /*cText*/ ) CLASS WvtTextBox - - if ::nTextColorHoverOn <> nil - ::nTextColor := ::nTextColorHoverOn - ::Refresh() - endif - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD HoverOff( /*cText*/ ) CLASS WvtTextBox - - if ::nTextColorHoverOn <> nil - ::nTextColor := ::nTextColorHoverOff - ::Refresh() - endif - -RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtProgressBar -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtProgressBar FROM WvtObject - - DATA cImage - DATA nDirection INIT 0 // 0-Left-Right,Top-Bottom 1-Right-Left,Bottom-Top - DATA nStyle INIT 0 - DATA lVertical INIT .f. - DATA lActive INIT .f. - - DATA nBarColor INIT RGB( 0,0,128 ) - DATA nCurrent INIT 0 - DATA nTotal INIT 1 - DATA nPercent INIT 0 - DATA cBackColor INIT 'W/W' - - DATA cScreen - - METHOD New() - METHOD Create() - METHOD Display() - METHOD Activate() - METHOD DeActivate() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtProgressBar - - ::Super:New( oParent, DLG_OBJ_PROGRESSBAR, nID, nTop, nLeft, nBottom, nRight ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Create() CLASS WvtProgressBar - - DEFAULT ::nTop TO 0 - DEFAULT ::nLeft TO 0 - DEFAULT ::nBottom TO if( ::lVertical, ::nTop + 9, ::nTop ) - DEFAULT ::nRight TO if( ::lVertical, ::nLeft + 1, ::nLeft + 19 ) - DEFAULT ::nTextColor TO RGB( 255,255,255 ) - DEFAULT ::nBackColor TO RGB( 198,198,198 ) - - ::bPaint := {|| ::Display() } - aadd( ::aPaint, { ::bPaint, { WVT_BLOCK_LABEL, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) - - ::Super:Create() - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Display( nCurrent, nTotal ) CLASS WvtProgressBar - - if !( ::lActive ) - return Self - endif - - DEFAULT nCurrent TO ::nCurrent - DEFAULT nTotal TO ::nTotal - - ::nCurrent := nCurrent - ::nTotal := nTotal - - if ::nCurrent > ::nTotal - ::nCurrent := ::nTotal - endif - - ::nPercent := int( ::nCurrent / ::nTotal * 100 ) - - Wvt_DrawProgressBar( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlTLBR, ::nPercent, ; - ::nBackColor, ::nBarColor, ::cImage, ::lVertical, ::nDirection ) - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Activate() CLASS WvtProgressBar - - ::cScreen := SaveScreen( ::nTop, ::nLeft, ::nBottom, ::nRight ) - DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, ' ', ::cBackColor ) - ::lActive := .t. - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD DeActivate() CLASS WvtProgressBar - - ::lActive := .f. - ::nCurrent := 0 - ::nTotal := 1 - RestScreen( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cScreen ) - ::cScreen := nil - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtMenu -// Peter Rees -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS wvtMenu - - METHOD Create( cCaption ) - METHOD AddItem( cCaption, bAction ) - METHOD DelAllItems() - METHOD DelItem( nItem ) - METHOD EnableItem( nItemNum ) - METHOD DisableItem( nItemNum ) - METHOD NumItems() - METHOD Destroy() - METHOD GetItem( nItemNum ) - METHOD FindMenuItemById( nId ) - METHOD DrawMenuBar() - - CLASSVAR MenuItemId INIT 1 - - VAR aItems - VAR hMenu - VAR Caption - VAR IdNumber - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD Create( cCaption ) CLASS wvtMenu - ::aItems := {} - - IF EMPTY( ::hMenu:= Wvt_CreateMenu() ) - //Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:Init()", "Create Menu Error", { cCaption, cCaption },"WVT.PRG" ) ) - ENDIF - ::Caption:= IIF( cCaption == NIL, "", cCaption ) - - RETURN(Self) - -//-------------------------------------------------------------------// - -METHOD Destroy() CLASS wvtMenu - - IF !EMPTY( ::hMenu ) - ::DelAllItems() - - IF !Wvt_DestroyMenu( ::hMenu ) - //Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:Destroy()", "Destroy menu FAILED", {},"WVT.PRG" ) ) - ENDIF - ::hMenu:= 0 - ENDIF - - RETURN( .T. ) - -//-------------------------------------------------------------------// - -METHOD AddItem(cCaption, bAction) CLASS wvtMenu - LOCAL lResult:= .F., aItem - - IF !EMPTY( ::hMenu ) .AND. ( !EMPTY( cCaption ) .OR. !EMPTY( bAction ) ) - IF HB_ISOBJECT( bAction ) - cCaption:= IIF(!EMPTY(cCaption),cCaption,bAction:Caption) - aItem:= {MF_POPUP,bAction:hMenu,cCaption,bAction} // bAction is a wvtMenu object reference - ELSEIF HB_ISBLOCK(bAction) - aItem:= {MF_STRING,::MenuItemId++,cCaption,bAction} // bAction is a code block to execute - ELSEIF cCaption[1]=="-" - aItem:= {MF_SEPARATOR,0,0,NIL} - ELSE - //Throw( ErrorNew( "wvtMenu", 3101, "wvtMenu:AddItem()", "Argument Error", { cCaption, bAction },"WVT.PRG" ) ) - ENDIF - - IF !Wvt_AppendMenu(::hMenu, aItem[WVT_MENU_TYPE],aItem[WVT_MENU_IDENTIFIER],aItem[WVT_MENU_CAPTION]) - //Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:AddItem()", "Add menu item", { cCaption, bAction },"WVT.PRG" ) ) - ENDIF - - AADD(::aItems, aItem) - lResult:= .T. - ENDIF - - RETURN( lResult ) - -//-------------------------------------------------------------------// - -METHOD DelAllItems() CLASS wvtMenu - LOCAL lResult:= .T., nItems - - nItems := ::NumItems() - DO WHILE nItems>0 .AND. lResult - lResult := ::DelItem( nItems ) - nItems-- - ENDDO - - RETURN ( lResult ) - -//-------------------------------------------------------------------// - -METHOD DelItem( nItemNum ) CLASS wvtMenu - LOCAL lResult:= .F. - - IF nItemNum > 0 .AND. nItemNum <= ::NumItems() - IF ::aItems[ nItemNum,WVT_MENU_TYPE ]== MF_POPUP - ::aItems[ nItemNum,WVT_MENU_MENUOBJ ]:Destroy() - ENDIF - - IF ( lResult:= Wvt_DeleteMenu(::hMenu, nItemNum-1,MF_BYPOSITION)) // Remember ZERO base - ADEL( ::aItems, nItemNum ) - ASIZE( ::aItems, LEN( ::aItems ) - 1 ) - ELSE - //Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:DelItem()", "Delete menu item FAILED", { nItemNum },"WVT.PRG" ) ) - ENDIF - ENDIF - - RETURN(lResult) - -//-------------------------------------------------------------------// - -METHOD EnableItem( nItemNum ) CLASS wvtMenu - LOCAL nPrevious:= -1 - - IF !EMPTY( ::hMenu ) && !EMPTY( nItemNum ) - nPrevious:= Wvt_EnableMenuItem( ::hMenu, nItemNum-1, MF_BYPOSITION + MF_ENABLED ) - ENDIF - - RETURN ( nPrevious ) - -//-------------------------------------------------------------------// - -METHOD DisableItem( nItemNum ) CLASS wvtMenu - LOCAL nPrevious:= -1 - - IF !EMPTY( ::hMenu ) && !EMPTY( nItemNum ) - nPrevious:= Wvt_EnableMenuItem( ::hMenu, nItemNum-1, MF_BYPOSITION + MF_GRAYED ) - ENDIF - - RETURN ( nPrevious ) - -//-------------------------------------------------------------------// - -METHOD NumItems() CLASS wvtMenu - - RETURN ( LEN( ::aItems ) ) - -//-------------------------------------------------------------------// - -METHOD GetItem( nItemNum ) CLASS wvtMenu - LOCAL nItems := ::NumItems(), aResult:= NIL - - IF nItemNum > 0 .AND. nItemNum <= nItems - aResult:= ::aItems[ nItemNum ] - ENDIF - - RETURN ( aResult ) - -//-------------------------------------------------------------------// - -METHOD FindMenuItemById( nId ) CLASS wvtMenu - LOCAL x, aResult:= {} - - IF !EMPTY( nId ) - x:= ::NumItems() - DO WHILE x > 0 .AND. EMPTY( aResult ) - IF ::aItems[ x,WVT_MENU_TYPE ] == MF_POPUP - aResult:= ::aItems[ x,WVT_MENU_MENUOBJ ]:FindMenuItemById( nId ) - ELSEIF ::aItems[ x,WVT_MENU_IDENTIFIER ] == nId - aResult := ::aItems[ x ] - ENDIF - x-- - ENDDO - ENDIF - - RETURN ( aResult ) - -//-------------------------------------------------------------------// - -METHOD DrawMenuBar() CLASS wvtMenu - - Wvt_DrawMenuBar() - - RETURN ( NIL ) - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Class WvtConsole -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -CLASS WvtConsole FROM WvtObject - - METHOD New() - METHOD Say() - METHOD Box() - -ENDCLASS - -//-------------------------------------------------------------------// - -METHOD New( oParent ) CLASS WvtConsole - - ::Super:New( oParent, DLG_OBJ_CONSOLE, , -1, -1, -1, -1 ) - - RETURN Self - -//-------------------------------------------------------------------// - -METHOD Say( nRow, nCol, xExp, cColor ) CLASS WvtConsole - LOCAL nCRow, nCCol, nCursor - - if nRow >=0 .and. nCol >= 0 .and. xExp <> nil - nCursor := SetCursor( SC_NONE ) - nCRow := Row() - nCCol := Col() - DispOutAt( nRow, nCol, xExp, cColor ) - SetPos( nCRow, nCCol ) - SetCursor( nCursor ) - endif - -RETURN Self - -//-------------------------------------------------------------------// - -METHOD Box( nRow, nCol, n2Row, n2Col, cBoxChars, cColor ) CLASS WvtConsole - - LOCAL nCRow, nCCol, nCursor - - if nRow >=0 .and. nCol >= 0 - nCursor := SetCursor( SC_NONE ) - nCRow := Row() - nCCol := Col() - DispBox( nRow, nCol, n2Row, n2Col, cBoxChars, cColor ) - SetPos( nCRow, nCCol ) - SetCursor( nCursor ) - endif - - RETURN Self - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * GUI Components + * Copyright 2007 Pritpal Bedi + * Based On: + * + * Video subsystem for Win32 using GUI windows instead of Console + * Copyright 2003 Peter Rees + * Rees Software & Systems Ltd + * + * + * 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. + * + */ +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Wvt*Classes +// 2004 +// Pritpal Bedi +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +#include 'hbclass.ch' +#include 'inkey.ch' +#include 'common.ch' +#include 'setcurs.ch' + +#include 'wvtwin.ch' +//#include 'xhb.ch' + +//-------------------------------------------------------------------// + +#define K_LBUTTONPRESSED 1021 +#define K_RBUTTONPRESSED 1022 +#define K_MBUTTONPRESSED 1023 + +#define K_SBLINEUP 1051 +#define K_SBLINEDOWN 1052 +#define K_SBPAGEUP 1053 +#define K_SBPAGEDOWN 1054 + +#define K_SBLINELEFT 1055 +#define K_SBLINERIGHT 1056 +#define K_SBPAGELEFT 1057 +#define K_SBPAGERIGHT 1058 + +#define K_SBTHUMBTRACKVERT 1059 +#define K_SBTHUMBTRACKHORZ 1060 + +//-------------------------------------------------------------------// + +#define OBJ_CHILD_OBJ 1 +#define OBJ_CHILD_EVENTS 2 +#define OBJ_CHILD_DATABLOCK 3 +#define OBJ_CHILD_REFRESHBLOCK 4 + +//-------------------------------------------------------------------// +// +// Class WvtDialog +// +//-------------------------------------------------------------------// + +CLASS wvtDialog + + // To hold previous settings + // + DATA nOldRows + DATA nOldCols + DATA aOldFont + DATA cOldTitle + DATA cOldColor + DATA nOldCursor + DATA aPalette + DATA cScreen + DATA aWvtScreen + DATA aOldPnt + DATA oldTooltipActive + DATA oldTooltipWidth + DATA oldTooltipBkColor + DATA oldTooltipTextColor + DATA oldMenuHandle + DATA oldMenuBlock + DATA lGui + + // Dialog Parameters + // + DATA nRows + DATA nCols + DATA cFont + DATA nFontHeight + DATA nFontWidth + DATA nFontBold + DATA nFontQuality + DATA cTitle + DATA cColor + + // Objects handelling + // + DATA aObjects INIT {} + DATA oCurObj + DATA oLastObj + DATA oObjOver + DATA oLastOver + DATA nCurObj INIT 1 + DATA nLastObj INIT 0 + DATA nObjOver INIT 0 + DATA nLastOver INIT -1 + DATA nUseObj + DATA oMenu + DATA aDialogKeys INIT {} + DATA cDialogID INIT '' + + // Tooltip Management + // + DATA nTooltipWidth + DATA nTooltipBkColor + DATA nTooltipTextColor + + // Miscellaneous + // + DATA ClassName INIT 'WVTDIALOG' + DATA cPaintBlockID + DATA nPaintID INIT 1 + DATA nObjID INIT 5000 + DATA nKey + DATA hFonts INIT {} + DATA lEventHandled + DATA lTabStops INIT .f. + + ACCESS nObjects INLINE len( ::aObjects ) + + DATA bOnCreate + + METHOD New() + METHOD Create() + METHOD Destroy() + METHOD AddObject( oObject ) INLINE aadd( ::aObjects, oObject ) + METHOD Execute() + METHOD MouseOver() + METHOD CreateObjects() + METHOD MaxRow() INLINE ::nRows - 1 + METHOD MaxCol() INLINE ::nCols - 1 + METHOD Eval() + METHOD Update() + METHOD OnTimer() INLINE aeval( ::aObjects, {|o| o:OnTimer() } ) + METHOD Event() + METHOD Inkey() + METHOD ActivateMenu() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( nRows, nCols, cTitle, cFont, nFontHeight, nFontWidth,nFontBold,nFontQuality ) CLASS wvtDialog + LOCAL fnt_:= Wvt_GetFontInfo() + + DEFAULT nRows TO 25 + DEFAULT nCols TO 80 + DEFAULT cTitle TO Wvt_GetTitle() + DEFAULT cFont TO fnt_[ 1 ] + DEFAULT nFontHeight TO fnt_[ 2 ] + DEFAULT nFontWidth TO fnt_[ 3 ] + DEFAULT nFontBold TO fnt_[ 4 ] + DEFAULT nFontQuality TO fnt_[ 5 ] + + if empty( cFont ) + cFont := fnt_[ 1 ] + endif + if empty( nFontHeight ) + nFontHeight := fnt_[ 2 ] + endif + if empty( nFontWidth ) + nFontWidth := fnt_[ 3 ] + endif + + ::nOldRows := MaxRow()+1 + ::nOldCols := MaxCol()+1 + ::aOldFont := Wvt_GetFontInfo() + ::cOldTitle := Wvt_GetTitle() + ::cOldColor := SetColor() + ::nOldCursor := SetCursor() + ::aPalette := Wvt_GetPalette() + + ::oldMenuHandle := Wvt_GetMenu() + ::oldMenuBlock := SetKey( Wvt_SetMenuKeyEvent() ) + + ::oldTooltipWidth := Wvt_GetTooltipWidth() + ::oldTooltipBkColor := Wvt_GetTooltipBkColor() + ::oldTooltipTextColor := Wvt_GetTooltipTextColor() + + ::nRows := nRows + ::nCols := nCols + ::cTitle := cTitle + ::cFont := cFont + ::nFontHeight := nFontHeight + ::nFontWidth := nFontWidth + ::nFontBold := nFontBold + ::nFontQuality := nFontQuality + + ::cPaintBlockID := strzero( Hb_Random( 99999998 ),8 ) + ::nObjOver := 0 + ::nKey := 0 + ::cColor := 'N/W' + ::nUseObj := 0 + ::lGui := Wvt_SetGui( .f. ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS wvtDialog + LOCAL aPalette, n, i, j // , cScr, cQry + + ::oldToolTipActive := Wvt_SetToolTipActive( .t. ) + if ::nTooltipWidth <> nil + Wvt_setTooltipWidth( ::nTooltipWidth ) + endif + if ::nTooltipBkColor <> nil + Wvt_SetTooltipBkColor( ::nTooltipBkColor ) + endif + if ::nTooltipTextColor <> nil + Wvt_SetTooltipTextColor( ::nTooltipTextColor ) + endif + + aPalette := Wvt_GetPalette() + aPalette[ 9 ] := RGB( 175,175,175 ) + Wvt_SetPalette( aPalette ) + + ::cScreen := SaveScreen( 0, 0, maxrow(), maxcol() ) + ::aWvtScreen := Wvt_SaveScreen( 0, 0, maxrow(), maxcol() ) + ::aOldPnt := WvtSetPaint( {} ) + + SetMode( ::nRows, ::nCols ) + do while .t. + if Wvt_SetFont( ::cFont, ::nFontHeight, ::nFontWidth, ::nFontBold, ::nFontQuality ) + exit + endif + ::nFontHeight-- + enddo + //Wvt_SetFont( ::cFont, ::nFontHeight, ::nFontWidth, ::nFontBold, ::nFontQuality ) + SetMode( ::nRows, ::nCols ) + + Wvt_SetTitle( ::cTitle ) + + SetColor( ::cColor ) + CLS + ::Eval( ::bOnCreate ) + + // Actually Create the Objects + ::CreateObjects() + + if len( ::aObjects ) > 0 + ::oCurObj := ::aObjects[ 1 ] + endif + + for i := 1 to len( ::aObjects ) + if !empty( ::aObjects[ i ]:aPaint ) + for j := 1 to len( ::aObjects[ i ]:aPaint ) + SetPaint( ::cPaintBlockID, ::nPaintID++, ; + ::aObjects[ i ]:aPaint[ j,1 ], ::aObjects[ i ]:aPaint[ j,2 ] ) + next + endif + next + WvtSetPaint( GetPaint( ::cPaintBlockID ) ) + + if ( n := ascan( ::aObjects, {|o| o:lTabStop } ) ) > 0 + ::lTabStops := .t. + endif + + ::Update() + + if HB_ISOBJECT( ::oMenu ) + Wvt_SetMenu( ::oMenu:hMenu ) + Wvt_DrawMenuBar() + SetKey( Wvt_SetMenuKeyEvent(), {|| ::ActivateMenu( ::oMenu ) } ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Destroy() CLASS wvtDialog + + if HB_ISOBJECT( ::oMenu ) + ::oMenu:Destroy() + endif + + aeval( ::aObjects, {|o| o:destroy() } ) + + Wvt_SetTooltip( 0,0,0,0,'' ) + Wvt_SetTooltipActive( ::oldToolTipActive ) + Wvt_setTooltipWidth( ::oldTooltipWidth ) + Wvt_SetTooltipBkColor( ::oldTooltipBkColor ) + Wvt_SetTooltipTextColor( ::oldTooltipTextColor ) + + // Here set mode is before setting the font + // + SetMode( ::nOldRows, ::nOldCols ) + Wvt_SetFont( ::aOldFont[ 1 ], ::aOldFont[ 2 ], ::aOldFont[ 3 ], ::aOldFont[ 4 ], ::aOldFont[ 5 ] ) + Wvt_SetTitle( ::cOldTitle ) + Wvt_SetPalette( ::aPalette ) + Wvt_SetPointer( WVT_IDC_ARROW ) + Wvt_SetMousePos( MRow(), MCol() ) + + SetColor( ::cOldColor ) + SetCursor( ::nOldCursor ) + + if ::oldMenuHandle <> nil .and. ::oldMenuHandle <> 0 + Wvt_SetMenu( ::oldMenuHandle ) + Wvt_DrawMenuBar() + endif + SetKey( Wvt_SetMenuKeyEvent(), ::oldMenuBlock ) + + RestScreen( 0, 0, maxrow(), maxcol(), ::cScreen ) + Wvt_RestScreen( 0, 0 ,maxrow(), maxcol(), ::aWvtScreen ) + PurgePaint( ::cPaintBlockID ) + WvtSetPaint( ::aOldPnt ) + Wvt_SetGui( ::lGui ) + + RETURN nil + +//-------------------------------------------------------------------// + +METHOD Event() CLASS wvtDialog + LOCAL nKey + + if ( nKey := inkey( 0.1, INKEY_ALL ) ) == 0 + if Wvt_IsLButtonPressed() + + nKey := K_LBUTTONPRESSED + + endif + endif + + RETURN ( nKey ) + +//-------------------------------------------------------------------// + +METHOD Execute() CLASS wvtDialog + + if ::nObjects == 0 + do while .t. + if inkey( 0.1 ) == K_ESC + exit + endif + enddo + else + do while ( ::Inkey() <> K_ESC ) + enddo + endif + + RETURN ::nKey + +//-------------------------------------------------------------------// + +METHOD Inkey() CLASS wvtDialog + LOCAL n, oObj, nID, i + + ::lEventHandled := .f. + ::nUseObj := 0 + + ::nKey := ::Event() + ::OnTimer() + + if ::nKey <> 0 + if ::nKey == K_ESC .or. ::nKey == K_CTRL_ENTER + return K_ESC + endif + + do case + + case ::nKey == K_TAB + if ::lTabStops + do while .t. + ::nCurObj++ + if ::nCurObj > ::nObjects + ::nCurObj := 1 + endif + if ::aObjects[ ::nCurObj ]:lTabStop + exit + endif + enddo + endif + + ::lEventHandled := .t. + + case ::nKey == K_SH_TAB + if ::lTabStops + do while .t. + ::nCurObj-- + if ::nCurObj < 1 + ::nCurObj := ::nObjects + endif + if ::aObjects[ ::nCurObj ]:lTabStop + exit + endif + enddo + endif + + ::lEventHandled := .t. + + case ::nKey == K_MOUSEMOVE .or. ::nKey == K_MMLEFTDOWN + ::MouseOver() + if ::nObjOver == 0 + Wvt_SetPointer( WVT_IDC_ARROW ) + elseif ::oObjOver:nPointer <> nil .and. ::oObjOver:lActive + Wvt_SetPointer( ::oObjOver:nPointer ) + else + Wvt_SetPointer( WVT_IDC_ARROW ) + endif + ::lEventHandled := .t. + + endcase + + if ::nKey == K_LBUTTONDOWN .or. ; + ::nKey == K_LBUTTONUP .or. ; + ::nKey == K_LDBLCLK .or. ; + ::nKey == K_MMLEFTDOWN .or. ; + ::nKey == K_LBUTTONPRESSED .or. ; + ::nKey == K_RBUTTONDOWN + + ::MouseOver() + + if ::nObjOver > 0 + if ::aObjects[ ::nObjOver ]:nType == DLG_OBJ_BUTTON .or. ; + ::aObjects[ ::nObjOver ]:nType == DLG_OBJ_TOOLBAR .or. ; + ::aObjects[ ::nObjOver ]:nType == DLG_OBJ_PUSHBUTTON .or. ; + ::aObjects[ ::nObjOver ]:nType == DLG_OBJ_SCROLLBAR + + oObj := ::aObjects[ ::nObjOver ] + if oObj:oParent:ClassName == 'WVTBROWSE' + nID := oObj:oParent:nID + if ( n := ascan( ::aObjects, {|o| o:nID == nID } ) ) > 0 + ::nCurObj := n + endif + endif + else + ::nCurObj := ::nObjOver + endif + ::nUseObj := ::nObjOver + + else + ::lEventHandled := .t. + + endif + endif + + if ::nLastOver <> ::nObjOver + if ::nLastOver > 0 + ::aObjects[ ::nLastOver ]:HoverOff() + endif + + ::nLastOver := ::nObjOver + + if ::nObjOver > 0 + ::oObjOver:HoverOn() + endif + + if ::nObjOver == 0 + Wvt_SetTooltip( 0,0,0,0,'' ) + + elseif ::oObjOver:lActive + ::oObjOver:SetTooltip() + + else + Wvt_SetTooltip( 0,0,0,0,'' ) + + endif + endif + + if ::nCurObj <> ::nLastObj + if ::nLastObj == 0 + ::aObjects[ ::nCurObj ]:Hilite() + + else + ::aObjects[ ::nLastObj ]:DeHilite() + ::aObjects[ ::nCurObj ]:Hilite() + + endif + + ::nLastObj := ::nCurObj + ::oCurObj := ::aObjects[ ::nCurObj ] + ::oLastObj := ::aObjects[ ::nCurObj ] + + if ::oCurObj:nType == DLG_OBJ_BROWSE + Select( ::oCurObj:cAlias ) + + endif + + ::Eval( ::oCurObj:bOnFocus, ::oCurObj ) + endif + + if ::nKey == K_LBUTTONDOWN + if ::nUseObj > 0 + if !( ::lEventHandled := ::aObjects[ ::nUseObj ]:LeftDown() ) + ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnLeftDown ) + + endif + endif + endif + + if ::nKey == K_LBUTTONUP + if ::nUseObj > 0 + if !( ::lEventHandled := ::aObjects[ ::nUseObj ]:LeftUp() ) + ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnLeftUp ) + + endif + endif + endif + + if ::nKey == K_MMLEFTDOWN + if ::nUseObj > 0 + if !( ::lEventHandled := ::aObjects[ ::nUseObj ]:MMLeftDown() ) + ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnMMLeftDown ) + + endif + endif + endif + + if ::nKey == K_LBUTTONPRESSED + if ::nUseObj > 0 + if !( ::lEventHandled := ::aObjects[ ::nUseObj ]:LeftPressed() ) + ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnLeftPressed ) + + endif + endif + endif + + if ::nKey == K_LDBLCLK + if ::nUseObj > 0 + ::lEventHandled := ::Eval( ::aObjects[ ::nUseObj ]:bOnSelect ) + + endif + endif + + if ::nKey == K_RBUTTONDOWN .and. ::nUseObj > 0 + ::lEventHandled := ::aObjects[ ::nUseObj ]:ShowPopup() + endif + + if !( ::lEventHandled ) + if ::nCurObj > 0 + if !empty( ::aDialogKeys ) + if ( n := ascan( ::aDialogKeys, {|e_| e_[ 1 ] == ::nKey } ) ) > 0 + Eval( ::aDialogKeys[ n, 2 ], self, ::oCurObj ) + endif + endif + + ::lEventHandled := ::oCurObj:HandleEvent( ::nKey ) + + if ( ::lEventHandled ) + if ::oCurObj:nChildren > 0 + for i := 1 to ::oCurObj:nChildren + //if ( ::nKey IN ::oCurObj:aChildren[ i, OBJ_CHILD_EVENTS ] ) + if ascan( ::oCurObj:aChildren[ i, OBJ_CHILD_EVENTS ],::nKey ) > 0 + ::oCurObj:NotifyChild( i, ::nKey, ::oCurObj ) + endif + next + endif + endif + endif + endif + + if !( ::lEventHandled ) + if ISBLOCK( SetKey( ::nKey ) ) + Eval( SetKey( ::nKey ) ) + endif + endif + endif + + RETURN ( ::nKey ) + +//-------------------------------------------------------------------// + +METHOD MouseOver() CLASS wvtDialog + LOCAL mRow := MRow() + LOCAL mCol := MCol() + LOCAL nObj + + nObj := ascan( ::aObjects, ; + {|o| o:nType <> DLG_OBJ_STATIC .and. ; + o:nType <> DLG_OBJ_TOOLBAR .and. ; + mRow >= o:nTop .and. mRow <= o:nBottom .and. ; + mCol >= o:nLeft .and. mCol <= o:nRight } ) + + ::nObjOver := nObj + ::oObjOver := if( nObj > 0, ::aObjects[ nObj ], nil ) + if nObj > 0 + ::aObjects[ nObj ]:nmRow := mRow + ::aObjects[ nObj ]:nmCol := mCol + + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Update() CLASS wvtDialog + + Wvt_InvalidateRect( 0, 0, ::maxrow(), ::maxcol() ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD CreateObjects() CLASS wvtDialog + LOCAL i, nObjs + + nObjs := len( ::aObjects ) + + for i := 1 to nObjs + switch ::aObjects[ i ]:nType + + case DLG_OBJ_BROWSE + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_STATUSBAR + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_LABEL + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_TOOLBAR + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_BUTTON + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_PUSHBUTTON + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_IMAGE + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_STATIC + ::aObjects[ i ]:Create() + exit + /* + case DLG_OBJ_SCROLLBAR + ::aObjects[ i ]:Create() + exit + */ + case DLG_OBJ_GETS + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_BANNER + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_TEXTBOX + ::aObjects[ i ]:Create() + exit + case DLG_OBJ_PROGRESSBAR + ::aObjects[ i ]:Create() + exit + end + next + + RETURN self + +//-------------------------------------------------------------------// + +METHOD Eval( bBlock, p1,p2,p3,p4,p5 ) CLASS wvtDialog + LOCAL lRet + + if ( lRet := ISBLOCK( bBlock ) ) + eval( bBlock, p1,p2,p3,p4,p5 ) + endif + + RETURN lRet + +//-------------------------------------------------------------------// + +METHOD ActivateMenu() CLASS WvtDialog + LOCAL nMenu:= Wvt_GetLastMenuEvent() + LOCAL aMenuItem + + IF !EMPTY( nMenu ) + IF HB_ISOBJECT( ::oMenu ) + IF !EMPTY( aMenuItem := ::oMenu:FindMenuItemById( nMenu ) ) + IF HB_ISBLOCK( aMenuItem[ WVT_MENU_ACTION ] ) + EVAL( aMenuItem[ WVT_MENU_ACTION ] ) + ENDIF + ENDIF + ENDIF + ENDIF + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtObject +// +// Must never be used directly. It is parent class for all other objects! +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtObject + + DATA oParent + DATA nType + DATA nId + + DATA nTop + DATA nLeft + DATA nBottom + DATA nRight + DATA aPxlTLBR INIT {} + + DATA aObjects INIT {} + DATA aParent INIT {} + DATA aChildren INIT {} + DATA aPaint INIT {} + DATA bPaint + DATA ClassName INIT '' + + DATA nObjID INIT 900000 + DATA nPointer + DATA cargo + DATA xSettings + DATA cText + DATA cToolTip + DATA lActive INIT .t. + DATA lAnimate INIT .f. + DATA lTabStop INIT .t. + DATA hFont + + DATA aPopup INIT {} + DATA hPopup INIT nil + DATA nPopupItemID INIT 700000 + + DATA nMRow INIT 0 + DATA nMCol INIT 0 + DATA cColorHilite INIT 'W+/B*' + DATA cColorDehilite INIT 'W/N*' + + DATA nTextColor + DATA nBackColor + DATA nBackMode INIT 0 // OPAQUE 1-TRANSPARENT + DATA nTextColorHoverOn + DATA nTextColorHoverOff + DATA nBackColorHoverOn + DATA nBackColorHoverOff + DATA cFont + DATA nFontHeight + DATA nFontWidth + DATA nFontWeight + DATA nFontQuality + DATA nCharSet + DATA lItalic + DATA lUnderline + DATA lStrikeOut + DATA nAlignHorz + DATA nAlignVert + DATA nAngle + + ACCESS ToolTip INLINE if( ::cTooltip == nil, '', ::cTooltip ) + ASSIGN ToolTip( cTip ) INLINE ::cToolTip := cTip + + DATA bHandleEvent + DATA bOnCreate + DATA bOnSelect + DATA bOnFocus + DATA bOnRefresh + DATA bOnLeftUp + DATA bOnLeftDown + DATA bOnMMLeftDown + DATA bOnLeftPressed + DATA bTooltip + DATA bSaveSettings + DATA bRestSettings + DATA bOnHilite + DATA bOnDeHilite + + ACCESS nChildren INLINE len( ::aChildren ) + DATA nIndexOrder + + METHOD New() + METHOD Create() + METHOD Destroy() + + // To Avoid any runtime errors if a message is send to an object + // which does not implement these methods + // + METHOD PaintBlock() INLINE nil + METHOD Hilite() INLINE nil + METHOD DeHilite() INLINE nil + METHOD HandleEvent() INLINE .f. + + METHOD LeftDown() INLINE .f. + METHOD LeftUp() INLINE .f. + METHOD MMLeftDown INLINE .f. + METHOD LeftPressed INLINE .f. + + METHOD HoverOn() INLINE nil + METHOD HoverOff() INLINE nil + + METHOD OnTimer() INLINE nil + + METHOD SaveSettings() INLINE nil + METHOD RestSettings() INLINE nil + + METHOD SetToolTip() INLINE ; + Wvt_SetToolTip( ::nTop, ::nLeft, ::nBottom, ::nRight, ::Tooltip ) + + METHOD Refresh() INLINE ; + Wvt_InvalidateRect( ::nTop, ::nLeft, ::nTop, ::nLeft ) + + METHOD Eval( bBlock ) INLINE ; + if( ISBLOCK( bBlock ), Eval( bBlock, self ), nil ) + + METHOD CreatePopup() + METHOD ShowPopup() + METHOD Activate() INLINE nil + METHOD DeActivate() INLINE nil + + METHOD AddChild( aChild ) INLINE aadd( ::aChildren, aChild ) + METHOD AddParent( aParent ) INLINE aadd( ::aParent, aParent ) + + METHOD NotifyChild( /*nChild*/ ) INLINE nil + + ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nType, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtObject + + DEFAULT nID TO ++::nObjID + + ::oParent := oParent + ::nType := nType + ::nId := nID + ::nTop := nTop + ::nLeft := nLeft + ::nBottom := nBottom + ::nRight := nRight + + switch nType + + case DLG_OBJ_BROWSE + ::ClassName := 'WVTBROWSE' + exit + + case DLG_OBJ_STATIC + ::ClassName := 'WVTSTATIC' + ::lTabStop := .f. + exit + + case DLG_OBJ_GETS + ::ClassName := 'WVTGETS' + exit + + case DLG_OBJ_IMAGE + ::ClassName := 'WVTIMAGE' + ::lTabStop := .f. + exit + + case DLG_OBJ_PUSHBUTTON + ::ClassName := 'WVTPUSHBUTTON' + exit + + case DLG_OBJ_BUTTON + ::ClassName := 'WVTBUTTON' + ::lTabStop := .f. + exit + + case DLG_OBJ_TOOLBAR + ::ClassName := 'WVTTOOLBAR' + ::lTabStop := .f. + exit + + case DLG_OBJ_LABEL + ::ClassName := 'WVTLABEL' + ::lTabStop := .f. + exit + + case DLG_OBJ_SCROLLBAR + ::ClassName := 'WVTSCROLLBAR' + ::lTabStop := .f. + exit + + case DLG_OBJ_STATUSBAR + ::ClassName := 'WVTSTATUSBAR' + ::lTabStop := .f. + exit + + case DLG_OBJ_BANNER + ::ClassName := 'WVTBANNER' + ::lTabStop := .f. + exit + + case DLG_OBJ_TEXTBOX + ::ClassName := 'WVTTEXTBOX' + ::lTabStop := .f. + exit + + case DLG_OBJ_PROGRESSBAR + ::ClassName := 'WVTPROGRESSBAR' + ::lTabStop := .f. + exit + + end + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtObject + + ::Eval( ::bOnCreate ) + ::CreatePopup() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Destroy() CLASS WvtObject + + if ::hFont <> nil + Win_DeleteObject( ::hFont ) + ::hFont := nil + endif + + if ::hPopup <> nil + Wvt_DestroyMenu( ::hPopup ) + ::hPopup := nil + endif + + RETURN Nil + +//-------------------------------------------------------------------// + +METHOD CreatePopup() CLASS WvtObject + LOCAL i, nID + + if !empty( ::aPopup ) .and. ::hPopup == nil + ::hPopup := Wvt_CreatePopupMenu() + + for i := 1 to len( ::aPopup ) + + aSize( ::aPopup[ i ],3 ) + nID := ::nPopupItemID++ + ::aPopup[ i,3 ] := nID + + Wvt_AppendMenu( ::hPopup, MF_ENABLED + MF_STRING, nID, ::aPopup[ i,1 ] ) + next + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD ShowPopup() CLASS WvtObject + LOCAL lRet := .f., nRet, n, aPos + + if ::hPopup <> nil + aPos := Wvt_GetCursorPos() + + nRet := Wvt_TrackPopupMenu( ::hPopup, TPM_CENTERALIGN +TPM_RETURNCMD, ; + aPos[ 1 ], aPos[ 2 ], 0, Wvt_GetWindowHandle() ) + if nRet > 0 + if ( n := ascan( ::aPopup, {|e_| e_[ 3 ] == nRet } ) ) > 0 + lRet := .t. + + if ISBLOCK( ::aPopup[ n,2 ] ) + Eval( ::aPopup[ n,2 ] ) + endif + endif + endif + endif + + RETURN lRet + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtBrowse +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtBrowse FROM WvtObject + + DATA cAlias + DATA oBrw + DATA lHSBar INIT .t. + DATA lVSBar INIT .t. + DATA oHBar + DATA oVBar + DATA bTotalRecords + DATA bCurrentRecord + DATA bTotalColumns + DATA bCurrentColumn + + ACCESS cDesc INLINE if( ::cText == nil, '', ::cText ) + ASSIGN cDesc( cText ) INLINE ::cText := cText + + METHOD New() + METHOD Create() + METHOD PaintBlock() + METHOD Hilite() + METHOD DeHilite() + METHOD HandleEvent() + METHOD Refresh() + METHOD SetVBar() + METHOD SetHBar() + METHOD SetTooltip() + METHOD SaveSettings() + METHOD RestSettings() + METHOD NotifyChild() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtBrowse + + ::Super:New( oParent, DLG_OBJ_BROWSE, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtBrowse + + Select( ::cAlias ) + + ::nTop := ::oBrw:nTop-2 + ::nLeft := ::oBrw:nLeft-2 + ::nBottom := if( ::lHSBar, ::oBrw:nBottom, ::oBrw:nBottom+1 ) + ::nRight := if( ::lVSBar, ::oBrw:nRight , ::oBrw:nRight+2 ) + + ::PaintBlock( 1 ) + ::PaintBlock( 2 ) + ::PaintBlock( 3 ) + ::PaintBlock( 4 ) + + ::Super:Create() + + DEFAULT ::bTotalRecords TO {|| ( ::cAlias )->( OrdKeyCount() ) } + DEFAULT ::bCurrentRecord TO {|| ( ::cAlias )->( OrdKeyNo() ) } + ::SetVBar() + + DEFAULT ::bTotalColumns TO {|| ::oBrw:ColCount } + DEFAULT ::bCurrentColumn TO {|| ::oBrw:ColPos } + ::SetHBar() + + ::oBrw:ForceStable() + ::DeHilite() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetVBar() CLASS WvtBrowse + + if ::lVSBar + ::oVBar := WvtScrollBar():New( self, 999991, ; + ::oBrw:nTop, ::oBrw:nRight+1, ::oBrw:nBottom, ::oBrw:nRight+2 ) + ::oVBar:nBarType := WVT_SCROLLBAR_VERT + ::oVBar:bTotal := ::bTotalRecords + ::oVBar:bCurrent := ::bCurrentRecord + ::oVBar:aPxlBtnTop := { -2,2,0,0 } + ::oVBar:aPxlBtnBtm := { 0,2,2,0 } + ::oVBar:aPxlScroll := { 0,2,0,0 } + ::oVBar:Create() + + aadd( ::aPaint, { ::oVBar:bBtnLeftTop, ; + { WVT_BLOCK_BUTTON, ::oVBar:nBtn1Top, ::oVBar:nBtn1Left, ; + ::oVBar:nBtn1Bottom, ::oVBar:nBtn1Right } } ) + + aadd( ::aPaint, { ::oVBar:bBtnRightBottom, ; + { WVT_BLOCK_BUTTON, ::oVBar:nBtn2Top, ::oVBar:nBtn2Left, ; + ::oVBar:nBtn2Bottom, ::oVBar:nBtn2Right } } ) + + aadd( ::aPaint, { ::oVBar:bBtnScroll, ; + { WVT_BLOCK_BUTTON, ::oVBar:nSTop, ::oVBar:nSLeft, ; + ::oVBar:nSBottom, ::oVBar:nSRight } } ) + + ::oParent:AddObject( ::oVBar ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetHBar() CLASS WvtBrowse + + if ::lHSBar + ::oHBar := WvtScrollBar():New( self, 999990, ; + ::oBrw:nBottom+1, ::oBrw:nLeft, ::oBrw:nBottom+1, ::oBrw:nRight ) + ::oHBar:nBarType := 2 + ::oHBar:bTotal := ::bTotalColumns + ::oHBar:bCurrent := ::bCurrentColumn + ::oHBar:aPxlBtnLft := { 2,-2,0,0 } + ::oHBar:aPxlBtnRgt := { 2, 0,0,2 } + ::oHBar:aPxlScroll := { 2, 0,0,0 } + ::oHBar:Create() + + aadd( ::aPaint, { ::oHBar:bBtnLeftTop, ; + { WVT_BLOCK_BUTTON, ::oHBar:nBtn1Top, ::oHBar:nBtn1Left, ; + ::oHBar:nBtn1Bottom, ::oHBar:nBtn1Right } } ) + aadd( ::aPaint, { ::oHBar:bBtnRightBottom, ; + { WVT_BLOCK_BUTTON, ::oHBar:nBtn2Top, ::oHBar:nBtn2Left, ; + ::oHBar:nBtn2Bottom, ::oHBar:nBtn2Right } } ) + aadd( ::aPaint, { ::oHBar:bBtnScroll, ; + { WVT_BLOCK_BUTTON, ::oHBar:nSTop, ::oHBar:nSLeft, ; + ::oHBar:nSBottom, ::oHBar:nSRight } } ) + + ::oParent:AddObject( ::oHBar ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtBrowse + LOCAL nWorkArea := Select() + + if ISBLOCK( ::bOnRefresh ) + eval( ::bOnRefresh, self ) + else + Select( ::cAlias ) + + ::oBrw:RefreshAll() + ::oBrw:ForceStable() + + Select( nWorkArea ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HandleEvent( nKey ) CLASS WvtBrowse + Local lRet := .f. + + if valtype( ::bHandleEvent ) == 'B' + lRet := eval( ::bHandleEvent, self, ::oParent:cPaintBlockID, ::oBrw, nKey ) + endif + + RETURN lRet + +//-------------------------------------------------------------------// + +METHOD NotifyChild( nIndex, nKey, oCurObj ) CLASS WvtBrowse + Local xData, i + + if nIndex > 0 .and. nIndex <= len( ::aChildren ) + if valtype( ::aChildren[ nIndex, OBJ_CHILD_DATABLOCK ] ) == 'B' + xData := eval( ::aChildren[ nIndex, OBJ_CHILD_DATABLOCK ] ) + endif + + eval( ::aChildren[ nIndex, OBJ_CHILD_REFRESHBLOCK ], ; + ::aChildren[ nIndex, OBJ_CHILD_OBJ ],; + ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:oParent:cPaintBlockID, ; + ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:oBrw, ; + nKey, ; + xData ) + + if ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:nChildren > 0 + // Pretend if focus is current on this object + // + Eval( ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:bOnFocus, ::aChildren[ nIndex, OBJ_CHILD_OBJ ] ) + + for i := 1 to ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:nChildren + ::aChildren[ nIndex, OBJ_CHILD_OBJ ]:NotifyChild( i, nKey, ::aChildren[ nIndex, OBJ_CHILD_OBJ ] ) + next + + // Restore previous environments + Eval( oCurObj:bOnFocus, oCurObj ) + endif + endif + + RETURN Self + +//----------------------------------------------------------------------// + +METHOD Hilite() CLASS WvtBrowse + LOCAL b := ::oBrw + + DispOutAt( b:nTop-2, b:nLeft-2, pad( ' '+::cDesc, b:nRight-b:nLeft+5 ), ::cColorHilite ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD DeHilite() CLASS WvtBrowse + LOCAL b := ::oBrw + + DispOutAt( b:nTop-2, b:nLeft-2, pad( ' '+::cDesc, b:nRight-b:nLeft+5 ), ::cColorDeHilite ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetTooltip() CLASS WvtBrowse + LOCAL cTip, nArea + + if ISBLOCK( ::bTooltip ) + ::SaveSettings() + nArea := Select( ::cAlias ) + + Select( ::cAlias ) + + cTip := Eval( ::bTooltip ) + + Select( nArea ) + + ::RestSettings() + endif + + if cTip <> nil + ::Tooltip := cTip + endif + + Wvt_SetTooltip( ::nTop, ::nLeft, ::nBottom, ::nRight, ::Tooltip ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SaveSettings CLASS WvtBrowse + + if ISBLOCK( ::bSaveSettings ) + ::xSettings := Eval( ::bSaveSettings, self ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD RestSettings() CLASS WvtBrowse + + if ::xSettings <> nil .and. ISBLOCK( ::bRestSettings ) + Eval( ::bRestSettings, self ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD PaintBlock( nPaintObj ) CLASS WvtBrowse + LOCAL bBlock, b := ::oBrw + + switch nPaintObj + + case 1 + bBlock := {|| Wvt_DrawBoxRaised( b:nTop-2,b:nLeft-2,b:nBottom+1,b:nRight+2 ) } + aadd( ::aPaint, { bBlock, { WVT_BLOCK_BOX, b:nTop-3,b:nLeft-3,b:nBottom+2,b:nRight+3 } } ) + exit + + case 2 + bBlock := {|| Wvt_DrawBoxRecessed( b:nTop,b:nLeft,b:nBottom,b:nRight ) } + aadd( ::aPaint, { bBlock, { WVT_BLOCK_BOX, b:nTop-1,b:nLeft-1,b:nBottom+1,b:nRight+1 } } ) + exit + + case 3 + bBlock := {|| Wvt_DrawGridHorz( b:nTop+3, b:nLeft, b:nRight, b:nBottom - b:nTop - 2 ) } + aadd( ::aPaint, { bBlock, { WVT_BLOCK_GRID_H, b:nTop+4, b:nLeft+1, b:nBottom-1, b:nRight-1 } } ) + exit + + case 4 + bBlock := {|| Wvt_DrawGridVert( b:nTop, b:nBottom, b:aColumnsSep, len( b:aColumnsSep ) ) } + aadd( ::aPaint, { bBlock, { WVT_BLOCK_GRID_V, b:nTop+1, b:nLeft+1, b:nBottom-1, b:nRight-1, b } } ) + exit + + end + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// WvtStatusBar +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtStatusBar FROM WvtObject + + DATA aPanels + DATA cColor + + METHOD New() + METHOD Create() + METHOD SetPanels() + METHOD SetText() + METHOD SetIcon() + METHOD Refresh() + METHOD Update( nPanel, cText ) + METHOD PaintBlock() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtStatusBar + + DEFAULT nTop TO oParent:MaxRow() + DEFAULT nLeft TO 0 + DEFAULT nBottom TO oParent:MaxRow() + DEFAULT nRight TO oParent:MaxCol() + + ::Super:New( oParent, DLG_OBJ_STATUSBAR, nID, nTop, nLeft, nBottom, nRight ) + + ::cColor := 'N/W' + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtStatusBar + + ::Refresh() + ::PaintBlock( DLG_OBJ_STATUSBAR, self ) + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD PaintBlock() CLASS WvtStatusBar + LOCAL a_:= {}, nPanels + + aeval( ::aPanels, {|o| aadd( a_,o:nTop ) , aadd( a_,o:nLeft ), ; + aadd( a_,o:nBottom ), aadd( a_,o:nRight ) } ) + + a_[ len( a_ ) ]++ + nPanels := len( ::aPanels ) + + ::bPaint := {|| Wvt_DrawStatusBar( nPanels, a_ ) } + aadd( ::aPaint, { ::bPaint,; + { WVT_BLOCK_STATUSBAR, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetPanels( aPanels ) CLASS WvtStatusBar + LOCAL i, oPanel, nID + LOCAL nLastCol := ::oParent:MaxCol() + + nID := 200000 + + ::aPanels := {} + + oPanel := WvtPanel():New( ::oParent, ++nID, ::nTop, 0 ) + + aadd( ::aPanels, oPanel ) + + if aPanels <> nil + for i := 1 to len( aPanels ) + if ::oParent:MaxCol() > aPanels[ i ] + oPanel := WvtPanel():New( ::oParent, ++nID, ::nTop, aPanels[ i ] ) + aadd( ::aPanels, oPanel ) + endif + next + endif + + atail( ::aPanels ):nRight := nLastCol + + for i := len( ::aPanels ) - 1 TO 1 STEP -1 + oPanel := ::aPanels[ i ] + oPanel:nRight := ::aPanels[ i+1 ]:nLeft + oPanel:cColor := ::cColor + next + + RETURN self + +//-------------------------------------------------------------------// + +METHOD Update( nPanel, cText, cColor ) + LOCAL oPanel + + if nPanel > 0 .and. nPanel <= len( ::aPanels ) + oPanel := ::aPanels[ nPanel ] + oPanel:Text := cText + oPanel:cColor := if( cColor == nil, 'N/W', cColor ) + oPanel:Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetText( nPanel, cText, cColor ) CLASS WvtStatusBar + LOCAL oPanel + + DEFAULT cColor TO ::cColor + + if nPanel > 0 .and. nPanel <= len( ::aPanels ) + oPanel := ::aPanels[ nPanel ] + oPanel:Text := cText + oPanel:cColor := cColor + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetIcon( nPanel, cIconFile ) CLASS WvtStatusBar + + if nPanel > 0 .and. nPanel <= len( ::aPanels ) + ::aPanels[ nPanel ]:cIconFile := cIconFile + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtStatusBar + LOCAL i + + for i := 1 to len( ::aPanels ) + ::aPanels[ i ]:Refresh() + next + + RETURN nil + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtPanel +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtPanel FROM WvtObject + + DATA cColor + DATA cTxt + DATA cIconFile + + ACCESS Text INLINE ::cTxt + ASSIGN Text( cText ) INLINE ::cTxt := pad( cText, ::nRight - ::nLeft-2 ) + + METHOD New() + METHOD Refresh() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nId, nTop, nLeft ) CLASS WvtPanel + + ::Super:New( oParent, DLG_OBJ_PANEL, nId, nTop, nLeft, nTop ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtPanel + + if ::Text <> nil + DispOutAt( ::nTop, ::nLeft+1, ::Text, ::cColor ) + endif + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtLabel +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtLabel FROM WvtObject + + ACCESS Text INLINE if( ::cText == nil, '', ::cText ) + ASSIGN Text( cTxt ) INLINE ::cText := if( cTxt == nil, '', cTxt ) + + METHOD New() + METHOD Create() + METHOD Configure() + METHOD Refresh() + METHOD HoverOn() + METHOD HoverOff() + METHOD SetText() + METHOD SetTextColor() + METHOD SetBackColor() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtLabel + + ::Super:New( oParent, DLG_OBJ_LABEL, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create( lConfg ) CLASS WvtLabel + + DEFAULT lConfg TO .f. + + DEFAULT ::nBottom TO ::nTop + DEFAULT ::nRight TO ::nLeft + len( ::Text ) + DEFAULT ::nTextColor TO RGB( 0,0,0 ) + + ::nTextColorHoverOff := ::nTextColor + ::nBackColorHoverOff := ::nBackColor + + ::hFont := Wvt_CreateFont( ::cFont, ::nFontHeight, ::nFontWidth, ::nFontWeight, ::lItalic,; + ::lUnderline, ::lStrikeout, ::nCharSet, ::nFontQuality, ::nAngle ) + if ::hFont <> 0 + if !( lConfg ) + ::bPaint := {|| Wvt_DrawLabelObj( ::nTop, ::nLeft, ::nBottom, ::nRight,; + ::Text, ::nAlignHorz, ::nAlignVert, ::nTextColor, ::nBackColor, ::hFont ) } + aadd( ::aPaint, { ::bPaint, { WVT_BLOCK_LABEL, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) + endif + endif + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtLabel + +Eval( ::bPaint ) + +RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetText( cTxt ) CLASS WvtLabel + + if valtype( cTxt ) == 'C' + ::Text := cTxt + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetTextColor( nRGB ) CLASS WvtLabel + + if valtype( nRGB ) == 'N' + ::nTextColor := nRGB + ::nTextColorHoverOff := nRGB + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetBackColor( nRGB ) CLASS WvtLabel + + if valtype( nRGB ) == 'N' + ::nBackColor := nRGB + ::nBackColorHoverOff := nRGB + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Configure() CLASS WvtLabel + + ::nTextColorHoverOff := ::nTextColor + ::nBackColorHoverOff := ::nBackColor + + if ::hFont <> 0 + Win_DeleteObject( ::hFont ) + endif + + ::hFont := Wvt_CreateFont( ::cFont, ::nFontHeight, ::nFontWidth, ::nFontWeight, ::lItalic,; + ::lUnderline, ::lStrikeout, ::nCharSet, ::nFontQuality, ::nAngle ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOn() CLASS WvtLabel + LOCAL lOn := .f. + + if ::nTextColorHoverOn <> nil + lOn := .t. + ::nTextColor := ::nTextColorHoverOn + endif + if ::nBackColorHoverOn <> nil + lOn := .t. + ::nBackColor := ::nBackColorHoverOn + endif + + if lOn + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOff() CLASS WvtLabel + LOCAL lOn := .f. + + if ::nTextColorHoverOn <> nil + lOn := .t. + ::nTextColor := ::nTextColorHoverOff + endif + if ::nBackColorHoverOn <> nil + lOn := .t. + ::nBackColor := ::nBackColorHoverOff + endif + + if lOn + ::Refresh() + endif + + Return Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtToolBar +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtToolBar FROM WvtObject + + DATA nPaintID + DATA aObjects INIT {} + DATA lHidden INIT .f. + DATA nCurButton INIT 0 + DATA lActive + DATA lFloating + DATA wScreen + DATA cScreen + DATA nBtnLeft INIT 0 + DATA nRGBSep INIT RGB( 150,150,150 ) + + ACCESS nButtons INLINE len( ::aButtons ) + + METHOD New() + METHOD Create() + METHOD Refresh() + METHOD AddButton() + METHOD PaintToolBar() + METHOD HoverOn() + METHOD HoverOff() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtToolBar + + nTop := 0 + nLeft := 0 + DEFAULT nBottom TO 1 + nRight := oParent:MaxCol() + + ::Super:New( oParent, DLG_OBJ_TOOLBAR, nID, nTop, nLeft, nBottom, nRight ) + + ::lActive := .t. + ::lFloating := .F. + ::nPaintID := ::oParent:nPaintID++ + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtToolBar + + if ::lFloating + ::lActive := .f. + ::lHidden := .t. + endif + + aeval( ::aObjects, {|o| o:lActive := ::lActive } ) + + ::bPaint := {|| ::PaintToolBar() } + aadd( ::aPaint, { ::bPaint,; + { WVT_BLOCK_TOOLBAR, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtToolBar + + if ::lFloating + DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, ' ', 'n/w' ) + else + Wvt_InvalidateRect( ::nTop, ::nLeft, ::nTop, ::nLeft ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD PaintToolBar() CLASS WvtToolBar + + if ( ::lActive ) + Wvt_DrawLine( ::nTop, ::nLeft, ::nBottom, ::nRight, 0, 1, 2, , , ::nRGBSep ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD AddButton( cFileImage, bBlock, cTooltip ) CLASS WvtToolBar + LOCAL oObj, nCol + + nCol := ( ::nBottom-::nTop+1 ) * 2 + + oObj := WvtToolButton():New( self ) + + oObj:lActive := ::lActive + oObj:nTop := ::nTop + oObj:nLeft := ::nBtnLeft + 1 + oObj:nBottom := ::nBottom + + if valtype( cFileImage ) == 'C' + oObj:nBtnType := TLB_BUTTON_TYPE_IMAGE + oObj:nRight := oObj:nLeft + nCol - 1 + oObj:cFileImage := cFileImage + oObj:bOnLeftUp := bBlock + oObj:Tooltip := cTooltip + else + oObj:nBtnType := TLB_BUTTON_TYPE_SEPARATOR + oObj:nRight := oObj:nLeft + endif + + aadd( ::aObjects, oObj ) + + ::nBtnLeft := oObj:nRight + 1 + ::nCurButton++ + + ::oParent:AddObject( oObj ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOn() + + if ::lFloating .and. ::lHidden + ::lHidden := .f. + ::lActive := .t. + // ::cScreen := SaveScreen( ::nTop, ::nLeft, ::nBottom, ::nRight ) + // ::wScreen := Wvt_SaveScreen( ::nTop, ::nLeft, ::nBottom, ::nRight ) + + aeval( ::aObjects, {|o| o:lActive := ::lActive } ) + + ::Refresh() + endif + + RETURN self + +//-------------------------------------------------------------------// + +METHOD HoverOff() + + if ::lFloating .and. !( ::lHidden ) + ::lHidden := .t. + ::lActive := .f. + aeval( ::aObjects, {|o| o:lActive := ::lActive } ) + // RestScreen( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cScreen ) + // Wvt_RestScreen( ::nTop, ::nLeft, ::nBottom, ::nRight, ::wScreen, .f. ) + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtToolButton +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtToolButton FROM WvtObject + + DATA cFileImage + DATA nCurState INIT 0 + DATA nBtnType INIT TLB_BUTTON_TYPE_IMAGE + DATA aPxlOffSet INIT { 0, -1, -3, 1 } + + METHOD New() + METHOD Create() + METHOD Refresh() + METHOD LeftDown() + METHOD LeftUp() + METHOD HoverOn() + METHOD HoverOff() + METHOD PaintButton() + + ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent ) CLASS WvtToolButton + + ::Super:New( oParent, DLG_OBJ_BUTTON ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtToolButton + + ::bPaint := {|| ::PaintButton() } + aadd( ::aPaint, { ::bPaint,; + { WVT_BLOCK_BUTTON, ::nTop, ::nLeft, ::nBottom, ::nRight }} ) + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtToolButton + + if ::lActive + Eval( ::bPaint ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD PaintButton() CLASS WvtToolButton + + if ::lActive + if ::nBtnType == TLB_BUTTON_TYPE_IMAGE + Wvt_DrawImage( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cFileImage, {4,4,-6,-4} ) + else + Wvt_DrawLine( ::nTop, ::nLeft, ::nBottom, ::nRight, 1, 1, , , , ::oParent:nRGBSep ) + endif + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD LeftDown() CLASS WvtToolButton + LOCAL lRet := .f. + + if ::lActive .and. ::nBtnType == TLB_BUTTON_TYPE_IMAGE + Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet, 2 ) + lRet := .t. + endif + + RETURN lRet + +//-------------------------------------------------------------------// + +METHOD LeftUp() CLASS WvtToolButton + LOCAL lRet := .f. + + if ::lActive .and. ::nBtnType == TLB_BUTTON_TYPE_IMAGE + Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet, 1 ) + Eval( ::bOnLeftUp ) + lRet := .t. + endif + + RETURN lRet + +//-------------------------------------------------------------------// + +METHOD HoverOn() CLASS WvtToolButton + + ::oParent:HoverOn() + + if ::lActive .and. ::nBtnType == TLB_BUTTON_TYPE_IMAGE + Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet, 1 ) + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOff() CLASS WvtToolButton + + ::oParent:HoverOff() + + if ::lActive .and. ::nBtnType == TLB_BUTTON_TYPE_IMAGE + Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight,::aPxlOffSet, 0 ) + endif + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtImage +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtImage FROM WvtObject + + DATA cImageFile + + ACCESS cImage INLINE ::cImageFile + ASSIGN cImage( cImg ) INLINE ::cImageFile := cImg + + METHOD New() + METHOD Create() + METHOD SetImage() + + ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtImage + + ::Super:New( oParent, DLG_OBJ_IMAGE, nId, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtImage + + ::bPaint := {|| if( file( ::cImage ), ; + Wvt_DrawImage( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cImage ),'' ) } + + aadd( ::aPaint, { ::bPaint,; + { WVT_BLOCK_IMAGE, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetImage( cImage ) CLASS WvtImage + + if cImage <> nil .and. file( cImage ) + ::cImageFile := cImage + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtStatic +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtStatic FROM WvtObject + + DATA nStatic + DATA nOrient + DATA nFormat + DATA nAlign + DATA nStyle + DATA nThick + DATA nColor + + DATA nfTop + DATA nfLeft + DATA nfBottom + DATA nfRight + + DATA nHorzVert INIT 0 + DATA aRGBb + DATA aRGBe + + DATA aPxlOffSet INIT {} + + METHOD New() + METHOD Create() + METHOD Refresh() + METHOD HoverOn() + METHOD HoverOff() + + ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtStatic + + ::Super:New( oParent, DLG_OBJ_STATIC, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtStatic + LOCAL lInside := .f. + + switch ::nStatic + + case WVT_STATIC_LINE + lInside := .t. + ::bPaint := {|| Wvt_DrawLine( ::nTop, ::nLeft, ::nBottom, ::nRight, ; + ::nOrient, ::nFormat, ::nAlign, ::nStyle, ::nThick, ::nColor ) } + exit + + case WVT_STATIC_BOXRAISED + ::bPaint := {|| Wvt_DrawBoxRaised( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_BOXRECESSED + ::bPaint := {|| Wvt_DrawBoxRecessed( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_BOXGROUP + ::bPaint := {|| Wvt_DrawBoxGroup( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_BOXGROUPRAISED + ::bPaint := {|| Wvt_DrawBoxGroupRaised( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_OUTLINE + ::bPaint := {|| Wvt_DrawOutline( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_RECTANGLE + lInside := .t. + ::bPaint := {|| Wvt_DrawRectangle( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_ROUNDRECT + lInside := .t. + ::bPaint := {|| Wvt_DrawRoundRect( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_FOCUSRECT + lInside := .t. + ::bPaint := {|| Wvt_DrawFocusRect( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_ELLIPSE + lInside := .t. + ::bPaint := {|| Wvt_DrawEllipse( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlOffSet ) } + exit + + case WVT_STATIC_SHADEDRECT + lInside := .t. + ::bPaint := {|| Wvt_DrawShadedRect( ::nTop, ::nLeft, ::nBottom, ::nRight, ; + ::aPxlOffSet, ::nHorzVert, ::aRGBb, ::aRGBe ) } + exit + + end + + if lInside + ::nfTop := ::nTop + ::nfLeft := ::nLeft + ::nfBottom := ::nBottom + ::nfRight := ::nRight + else + ::nfTop := ::nTop - 1 + ::nfLeft := ::nLeft - 1 + ::nfBottom := ::nBottom + 1 + ::nfRight := ::nRight + 1 + endif + + aadd( ::aPaint, { ::bPaint,; + { WVT_BLOCK_STATIC, ::nfTop, ::nfLeft, ::nfBottom, ::nfRight }} ) + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOn() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOff() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtStatic + + Eval( ::bPaint ) + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtPushButton +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtPushButton FROM WvtObject + + DATA cCaption + DATA cFileImage + + ACCESS block INLINE ::bOnLeftUp + ASSIGN block( bBlock ) INLINE ::bOnLeftUp := bBlock + + METHOD New() + METHOD Create() + METHOD LeftDown() + METHOD LeftUp() + METHOD PaintButton() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtPushButton + + ::Super:New( oParent, DLG_OBJ_PUSHBUTTON, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtPushButton + + ::bPaint := {|| ::PaintButton() } + + aadd( ::aPaint, { ::bPaint,; + { WVT_BLOCK_BUTTON, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD PaintButton() CLASS WvtPushButton + + if ::cCaption == nil + Wvt_DrawImage( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cFileImage, { 4, 4,-4, -4 } ) + else + Wvt_DrawButton( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cCaption, , 4 ) + endif + Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, {0,0,0,0}, 1 ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD LeftDown() CLASS WvtPushButton + + Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight,{0,0,0,0} , 2 ) + + RETURN .t. + +//-------------------------------------------------------------------// + +METHOD LeftUp() CLASS WvtPushButton + + Wvt_DrawToolButtonState( ::nTop, ::nLeft, ::nBottom, ::nRight, {0,0,0,0}, 1 ) + ::Eval( ::bOnLeftUp ) + + RETURN .t. + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtGets +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtGets FROM WvtObject + + DATA aGetList INIT {} + DATA nLastGet INIT 1 + DATA nCurGet INIT 1 + DATA GetList INIT {} + DATA cDesc INIT '' + + METHOD New() + METHOD Create() + METHOD KillFocus() + METHOD SetFocus() + METHOD HandleEvent() + METHOD AddGets() + METHOD PaintBlock() + METHOD Read() + METHOD Hilite() + METHOD DeHilite() + METHOD GetData() + METHOD SetData() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtGets + + ::Super:New( oParent, DLG_OBJ_GETS, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtGets + LOCAL i, GetList + LOCAL nCurRow := row() + LOCAL nCurCol := Col() + + for i := 1 to len( ::aGetList ) + GetList := {} + + DEFAULT ::aGetList[ i,7 ] TO 'N/W*,N/W*,,,N/GR*' + DEFAULT ::aGetList[ i,5 ] TO {|| .T. } + DEFAULT ::aGetList[ i,6 ] TO {|| .T. } + + @ ::aGetList[ i,1 ], ::aGetList[ i,2 ] GET ::aGetList[ i,3 ] PICTURE ::aGetList[ i,4 ] COLOR ::aGetList[ i,7 ] + + aadd( ::GetList, GetList[ 1 ] ) + + ::GetList[ i ]:Display() + ::PaintBlock( i ) + next + SetPos( nCurRow, nCurCol ) + + ::Super:Create() + ::Dehilite() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD PaintBlock( nIndex ) CLASS WvtGets + LOCAL nLen, bPaint + + nLen := len( Transform( ::aGetList[ nIndex,3 ], ::aGetList[ nIndex,4 ] ) ) + + bPaint := {|| Wvt_DrawBoxGet( ::aGetList[ nIndex,1 ], ::aGetList[ nIndex,2 ], nLen ) } + + aadd( ::aPaint, { bPaint,; + { WVT_BLOCK_GETS, ::aGetList[ nIndex,1 ]-1, ::aGetList[ nIndex,2 ]-1, ; + ::aGetList[ nIndex,1 ]-1, ::aGetList[ nIndex,2 ]+nLen } } ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetFocus() CLASS WvtGets + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD KillFocus() CLASS WvtGets + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD AddGets( nRow, nCol, xVar, cPic, cColor, bValid, bWhen ) CLASS WvtGets + + aadd( ::aGetList, { nRow, nCol, xVar, cPic, bValid, bWhen, cColor } ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HandleEvent( nKey ) CLASS WvtGets + Local lRet := .f. + + do case + case nKey == K_LDBLCLK + ::Read() + lRet := .t. + endcase + + RETURN lRet + +//-------------------------------------------------------------------// + +METHOD Read() CLASS WvtGets + + ReadModal( ::GetList, ::nCurGet ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD GetData() CLASS WvtGets + LOCAL aData + + RETURN aData + +//-------------------------------------------------------------------// + +METHOD SetData( /*aData*/ ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Hilite() CLASS WvtGets + + DispOutAt( ::nTop, ::nLeft, pad( ' '+::cDesc, ::nRight-::nLeft+1 ), ::cColorHilite ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD DeHilite() CLASS WvtGets + + DispOutAt( ::nTop, ::nLeft, pad( ' '+::cDesc, ::nRight-::nLeft+1 ), ::cColorDeHilite ) + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtScrollBar +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtScrollBar FROM WvtObject + + DATA nBarType INIT WVT_SCROLLBAR_VERT + + DATA nTotal INIT 100 + DATA nCurrent INIT 1 + DATA nThumbPos INIT 0 + DATA nBlockNo INIT 1 + + DATA nSTop + DATA nSLeft + DATA nSBottom + DATA nSRight + + DATA nBtn1Top + DATA nBtn1Left + DATA nBtn1Bottom + DATA nBtn1Right + + DATA nBtn2Top + DATA nBtn2Left + DATA nBtn2Bottom + DATA nBtn2Right + + DATA bBtnLeftTop + DATA bBtnLeftTopDep + DATA bBtnRightBottom + DATA bBtnRightBottomDep + + DATA bBtnScroll + + DATA bTotal + DATA bCurrent + + DATA lHidden INIT .t. + + DATA aPxlBtnTop INIT {0,0,0,0} + DATA aPxlBtnLft INIT {0,0,0,0} + DATA aPxlBtnBtm INIT {0,0,0,0} + DATA aPxlBtnRgt INIT {0,0,0,0} + DATA aPxlScroll INIT {0,0,0,0} + + DATA lLeftDown INIT .f. + DATA lOnThumb INIT .f. + DATA lAnchored INIT .f. + DATA lOnLeftDown INIT .f. + + DATA nScrollUnits INIT 0 + + METHOD New() + METHOD Create() + METHOD Configure() + METHOD Refresh() + METHOD HandleEvent() + METHOD SetPos() + METHOD GetPos() + METHOD ThumbPos() + METHOD SetTooltip() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtScrollBar + + ::Super:New( oParent, DLG_OBJ_SCROLLBAR, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtScrollBar + + if ::nTop == nil .or. ::nLeft == nil + return nil + endif + + if ::nBarType == WVT_SCROLLBAR_VERT + DEFAULT ::nBottom TO ::nTop + 5 + DEFAULT ::nRight TO ::nLeft + 1 + + ::nRight := ::nLeft + 1 + ::nBottom := max( 7, ::nBottom ) + + ::nBtn1Top := ::nTop + ::nBtn1Left := ::nLeft + ::nBtn1Bottom := ::nTop + ::nBtn1Right := ::nRight + + ::nBtn2Top := ::nBottom + ::nBtn2Left := ::nLeft + ::nBtn2Bottom := ::nBottom + ::nBtn2Right := ::nRight + + ::nSTop := ::nTop + 1 + ::nSLeft := ::nLeft + ::nSBottom := ::nBottom - 1 + ::nSRight := ::nRight + + ::nScrollUnits := ::nSBottom - ::nSTop + 1 + + ::nTotal := Eval( ::bTotal ) + ::nCurrent := Eval( ::bCurrent ) + ::ThumbPos() + + ::bBtnLeftTop := ; + {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnTop,1 ) } + ::bBtnRightBottom := ; + {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnBtm,3 ) } + ::bBtnScroll := ; + {|| Wvt_DrawScrollThumbVert( ::nSTop ,::nSLeft ,::nSBottom,::nSRight,::aPxlScroll,; + ::nThumbPos ) } + ::bBtnLeftTopDep := ; + {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnTop,1,.t. ) } + ::bBtnRightBottomDep := ; + {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnBtm,3,.t. ) } + + else + DEFAULT ::nBottom TO ::nTop + DEFAULT ::nRight TO ::nLeft + 11 + + ::nBottom := ::nTop + ::nRight := max( 11, ::nRight ) + + ::nBtn1Top := ::nTop + ::nBtn1Left := ::nLeft + ::nBtn1Bottom := ::nBottom + ::nBtn1Right := ::nLeft + 1 + + ::nBtn2Top := ::nTop + ::nBtn2Left := ::nRight - 1 + ::nBtn2Bottom := ::nBottom + ::nBtn2Right := ::nRight + + ::nSTop := ::nTop + ::nSLeft := ::nLeft + 2 + ::nSBottom := ::nBottom + ::nSRight := ::nRight - 2 + + ::nScrollUnits := ::nSRight - ::nSLeft + 1 + + ::nTotal := Eval( ::bTotal ) + ::nCurrent := Eval( ::bCurrent ) + + ::ThumbPos() + + ::bBtnLeftTop := ; + {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnLft,2 ) } + ::bBtnRightBottom := ; + {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnRgt,4 ) } + ::bBtnScroll := ; + {|| Wvt_DrawScrollThumbHorz( ::nSTop,::nSLeft,::nSBottom,::nSRight,; + ::aPxlScroll,::nThumbPos ) } + ::bBtnLeftTopDep := ; + {|| Wvt_DrawScrollButton( ::nBtn1Top,::nBtn1Left,::nBtn1Bottom,::nBtn1Right,::aPxlBtnLft,2,.t. ) } + ::bBtnRightBottomDep := ; + {|| Wvt_DrawScrollButton( ::nBtn2Top,::nBtn2Left,::nBtn2Bottom,::nBtn2Right,::aPxlBtnRgt,4,.t. ) } + + endif + + ::bOnLeftUp := {|| ::HandleEvent( K_LBUTTONUP ) } + ::bOnLeftDown := {|| ::HandleEvent( K_LBUTTONDOWN ) } + ::bOnMMLeftDown := {|| ::HandleEvent( K_MMLEFTDOWN ) } + ::bOnLeftPressed := {|| ::HandleEvent( K_LBUTTONPRESSED ) } + + Eval( ::bBtnLeftTop ) + Eval( ::bBtnRightBottom ) + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Configure( nTop, nLeft, nBottom, nRight ) CLASS WvtScrollBar + + ::nTop := nTop + ::nLeft := nLeft + ::nBottom := nBottom + ::nRight := nRight + + ::Create() + ::Refresh() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtScrollBar + + Eval( ::bBtnScroll ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetPos( nTotal, nCurrent ) CLASS WvtScrollBar + + DEFAULT nTotal TO Eval( ::bTotal ) + DEFAULT nCurrent TO Eval( ::bCurrent ) + + ::nTotal := nTotal + ::nCurrent := nCurrent + + ::ThumbPos() + ::Refresh() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD ThumbPos() CLASS WvtScrollBar + LOCAL nNewPos := ::nThumbPos + LOCAL nRecPerUnit, nCurUnit + + if ::nBarType == WVT_SCROLLBAR_VERT + nRecPerUnit := ::nTotal / ::nScrollUnits + nCurUnit := int( ::nCurrent / nRecPerUnit ) + + if ::nCurrent == 1 + nCurUnit := 0 + elseif ::nCurrent == ::nTotal + nCurUnit := ::nScrollUnits + endif + nNewPos := ::nSTop + nCurUnit + + if nNewPos < ::nSTop + nNewPos := ::nSTop + elseif nNewPos > ::nSBottom + nNewPos := ::nSBottom + endif + + else + if ::nTotal < ::nScrollUnits + nCurUnit := ::nCurrent * int( ::nScrollUnits / ::nTotal ) + else + nRecPerUnit := ::nTotal / ::nScrollUnits + nCurUnit := int( ::nCurrent / nRecPerUnit ) + endif + + if ::nCurrent == 1 + nCurUnit := 0 + elseif ::nCurrent == ::nTotal + nCurUnit := ::nScrollUnits + endif + + nNewPos := ::nSLeft + nCurUnit + + if nNewPos < ::nSLeft + nNewPos := ::nSLeft + elseif nNewPos > ::nSRight - 1 + nNewPos := ::nSRight-1 + endif + + endif + + ::nThumbPos := nNewPos + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD GetPos() CLASS WvtScrollBar + + RETURN ::nCurrent + +//-------------------------------------------------------------------// + +METHOD SetTooltip() CLASS WvtScrollBar + + ::Tooltip := ltrim( str( ::nCurrent,12,0 ) ) + ' / ' + ; + ltrim( str( ::nTotal ,12,0 ) ) + + Wvt_SetToolTip( ::nTop, ::nLeft, ::nBottom, ::nRight, ::Tooltip ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HandleEvent( nKey ) CLASS WvtScrollBar + LOCAL nmRow, nmCol, nOff + LOCAL lHit := .F. + LOCAL mKeys_:={ K_LBUTTONDOWN, K_LBUTTONUP, K_MMLEFTDOWN, K_LBUTTONPRESSED } + + if ascan( mKeys_, nKey ) == 0 + return .f. + endif + + nmRow := MRow() + nmCol := MCol() + + do case + case ::nBarType == WVT_SCROLLBAR_VERT + lHit := .t. + + do case + case ::lAnchored .and. nKey == K_MMLEFTDOWN + if nmRow <> ::nThumbPos + nOff := ::nThumbPos - nmRow + if nOff > 0 + ::nThumbPos := max( ::nTop+1, nmRow ) + else + ::nThumbPos := min( ::nBottom-1, nmRow ) + endif + ::nCurrent := ( ::nTotal * ( ::nThumbPos - ::nTop ) / ::nScrollUnits ) + + if ::nCurrent > ::nTotal + ::nCurrent := ::nTotal + endif + if ::nCurrent < 1 + ::nCurrent := 1 + endif + + ::SetPos( ::nTotal, ::nCurrent ) + + ::SetTooltip() + Wvt_Keyboard( K_SBTHUMBTRACKVERT ) + else + lHit := .f. + endif + + case ::lAnchored .and. nKey == K_LBUTTONUP + ::lAnchored := .f. + + otherwise + lHit := .f. + + if nmCol >= ::nLeft .and. nmCol <= ::nRight + lHit := .t. + + do case + case nmRow == ::nThumbPos .and. nKey == K_LBUTTONDOWN + ::lAnchored := .t. + + case nKey == K_LBUTTONUP + if ( lHit := ::lOnLeftDown ) + do case + case nmRow == ::nTop + Eval( ::bBtnLeftTop ) + case nmRow == ::nBottom + Eval( ::bBtnRightBottom ) + case nmRow < ::nThumbPos .and. nmRow > ::nTop + case nmRow > ::nThumbPos .and. nmRow < ::nBottom + otherwise + lHit := .f. + endcase + if lHit + ::lOnLeftDown := .f. + endif + endif + + case nKey == K_LBUTTONPRESSED + if ( lHit := ::lOnLeftDown ) + do case + case nmRow == ::nTop + Wvt_Keyboard( K_SBLINEUP ) + case nmRow == ::nBottom + Wvt_Keyboard( K_SBLINEDOWN ) + case nmRow < ::nThumbPos .and. nmRow > ::nTop + Wvt_Keyboard( K_SBPAGEUP ) + case nmRow > ::nThumbPos .and. nmRow < ::nBottom + Wvt_Keyboard( K_SBPAGEDOWN ) + otherwise + lHit := .f. + endcase + endif + + case nKey == K_LBUTTONDOWN + do case + case nmRow == ::nTop + Eval( ::bBtnLeftTopDep ) + Wvt_Keyboard( K_SBLINEUP ) + case nmRow == ::nBottom + Eval( ::bBtnRightBottomDep ) + Wvt_Keyboard( K_SBLINEDOWN ) + case nmRow < ::nThumbPos .and. nmRow > ::nTop + Wvt_Keyboard( K_SBPAGEUP ) + case nmRow > ::nThumbPos .and. nmRow < ::nBottom + Wvt_Keyboard( K_SBPAGEDOWN ) + otherwise + lHit := .f. + endcase + if lHit + ::lOnLeftDown := .t. + endif + endcase + endif + + endcase + + case ::nBarType == WVT_SCROLLBAR_HORZ + do case + case ::lAnchored .and. nKey == K_MMLEFTDOWN + if ( lHit := ( nmCol < ::nThumbPos .or. nmCol > ::nThumbPos+1 ) ) + + nOff := ::nThumbPos - nmCol + if nOff > 0 + ::nThumbPos := max( ::nLeft+2, nmCol ) + else + ::nThumbPos := min( ::nRight-2, nmCol ) + endif + + ::nCurrent := ( ::nTotal * ( ::nThumbPos - ::nLeft+1 ) / ::nScrollUnits ) + + if ::nCurrent > ::nTotal + ::nCurrent := ::nTotal + endif + if ::nCurrent < 1 + ::nCurrent := 1 + endif + + ::SetPos( ::nTotal, ::nCurrent ) + + Wvt_Keyboard( K_SBTHUMBTRACKHORZ ) + endif + + case ::lAnchored .and. nKey == K_LBUTTONUP + ::lAnchored := .f. + lHit := .t. + + otherwise + + if ( lHit := nmRow == ::nTop .and. nmCol >= ::nLeft .and. nmCol <= ::nRight ) + + do case + case nKey == K_LBUTTONDOWN .and. nmCol >= ::nThumbPos .and. nmCol <= ::nThumbPos+1 + ::lAnchored := .t. + + case nKey == K_LBUTTONUP + + if ( lHit := ::lOnLeftDown ) + do case + case nmCol >= ::nLeft .and. nmCol <= ::nLeft+1 + Eval( ::bBtnLeftTop ) + case nmCol >= ::nRight-1 .and. nmCol <= ::nRight + Eval( ::bBtnRightBottom ) + case nmCol < ::nThumbPos + case nmCol > ::nThumbPos+1 + otherwise + lHit := .f. + endcase + if lHit + ::lOnLeftDown := .f. + endif + endif + + case nKey == K_LBUTTONPRESSED + if ( lHit := ::lOnLeftDown ) + do case + case nmCol == ::nLeft .or. nmCol == ::nLeft+1 + Wvt_Keyboard( K_SBLINELEFT ) + case nmCol == ::nRight .or. nmCol == ::nRight-1 + Wvt_Keyboard( K_SBLINERIGHT ) + case nmCol < ::nThumbPos + Wvt_Keyboard( K_SBPAGELEFT ) + case nmCol > ::nThumbPos+1 + Wvt_Keyboard( K_SBPAGERIGHT ) + otherwise + lHit := .f. + endcase + endif + + case nKey == K_LBUTTONDOWN + do case + case nmCol == ::nLeft .or. nmCol == ::nLeft+1 + Eval( ::bBtnLeftTopDep ) + Wvt_Keyboard( K_SBLINELEFT ) + case nmCol == ::nRight .or. nmCol == ::nRight-1 + Eval( ::bBtnRightBottomDep ) + Wvt_Keyboard( K_SBLINERIGHT ) + case nmCol < ::nThumbPos + Wvt_Keyboard( K_SBPAGELEFT ) + case nmCol > ::nThumbPos+1 + Wvt_Keyboard( K_SBPAGERIGHT ) + otherwise + lHit := .f. + endcase + if lHit + ::lOnLeftDown := .t. + endif + endcase + endif + endcase + endcase + + RETURN lHit + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// CLASS WvtBanner +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtBanner FROM WvtObject + + DATA nTimeDelay INIT 0.5 // One-half Second + DATA nDirection INIT 0 // LEFT 1-RIGHT + DATA nCharToSkip INIT 1 + DATA cText INIT '' + DATA cDispText INIT '' + DATA nTextLen INIT 0 + DATA nTextIndex INIT 0 + + DATA oLabel + + DATA nAlignVert INIT 2 // Center + + DATA nCurSeconds INIT 0 + DATA nCurAlign + + METHOD New() + METHOD Create() + METHOD Configure() + METHOD Refresh() + METHOD HoverOn() + METHOD HoverOff() + METHOD OnTimer() + METHOD SetText() + METHOD Destroy() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtBanner + + ::Super:New( oParent, DLG_OBJ_BANNER, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtBanner + + ::cDispText := ::cText + + ::oLabel := WvtLabel():New( ::oParent, , ::nTop, ::nLeft, ::nBottom, ::nRight ) + ::oLabel:Text := ::cDispText + ::oLabel:cFont := ::cFont + ::oLabel:nFontHeight := ::nFontHeight + ::oLabel:nFontWidth := ::nFontWidth + ::oLabel:nFontWeight := ::nFontWeight + ::oLabel:nFontQuality := ::nFontQuality + ::oLabel:lItalic := ::lItalic + ::oLabel:lStrikeout := ::lStrikeout + ::oLabel:lUnderline := ::lUnderline + ::oLabel:nAlignVert := ::nAlignVert + ::oLabel:nAlignHorz := if( ::nDirection == 0, 0, 1 ) + ::oLabel:nTextColor := ::nTextColor + ::oLabel:nBackColor := ::nBackColor + ::oLabel:nTextColorHoverOn := ::nTextColorHoverOn + ::oLabel:nBackColorHoverOn := ::nBackColorHoverOn + + ::oLabel:Create() + + ::nCurSeconds := Seconds() + ::nTextLen := len( ::cText ) + ::nTextIndex := if( ::nDirection == 0, 1, ::nTextLen ) + ::nCurAlign := ::nDirection + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Destroy() CLASS WvtBanner + + Win_DeleteObject( ::oLabel:hFont ) + + RETURN nil + +//-------------------------------------------------------------------// + +METHOD Configure() CLASS WvtBanner + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD OnTimer() CLASS WvtBanner + + ::Refresh() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetText( cText ) CLASS WvtBanner + + if cText <> nil + ::cText := cText + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtBanner + LOCAL nNewTime + + if abs( ( nNewTime := Seconds() ) - ::nCurSeconds ) >= ::nTimeDelay + ::nCurSeconds := nNewTime + + if ::nDirection == 0 + ::nTextIndex++ + if ::nTextIndex > ::nTextLen + ::nTextIndex := 1 + ::nCurAlign := if( ::nCurAlign == 0, 1, 0 ) + endif + + if ::nCurAlign == 0 // Left + ::cDispText := substr( ::cText,::nTextIndex ) + else // Right + ::cDispText := substr( ::cText, 1, ::nTextIndex ) + endif + else + ::nTextIndex-- + if ::nTextIndex < 0 + ::nTextIndex := ::nTextLen + ::nCurAlign := if( ::nCurAlign == 0, 1, 0 ) + endif + + if ::nCurAlign == 0 // Left + ::cDispText := substr( ::cText,::nTextIndex ) + else // Right + ::cDispText := substr( ::cText, 1, ::nTextIndex ) + endif + endif + + ::oLabel:nAlignHorz := ::nCurAlign + ::oLabel:SetText( ::cDispText ) + ::oLabel:Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOn() CLASS WvtBanner + + ::oLabel:HoverOn() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOff() CLASS WvtBanner + + ::oLabel:HoverOff() + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtTextBox +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtTextBox FROM WvtObject + + DATA cText INIT '' + + METHOD New() + METHOD Create() + METHOD Configure() + METHOD Refresh() + METHOD SetText() + METHOD HoverOn() + METHOD HoverOff() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtTextBox + + ::Super:New( oParent, DLG_OBJ_TEXTBOX, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtTextBox + + ::nTextColorHoverOff := ::nTextColor + + ::hFont := Wvt_CreateFont( ::cFont, ::nFontHeight, ::nFontWidth, ; + ::nFontWeight, ::lItalic, ::lUnderline, ::lStrikeout, ; + ::nCharSet, ::nFontQuality, 0 ) + + if ::hFont <> 0 + ::bPaint := {|| Wvt_DrawTextBox( ::nTop, ::nLeft, ::nBottom, ::nRight, ; + ::aPxlTLBR, ::cText, ::nAlignHorz, ::nAlignVert, ; + ::nTextColor, ::nBackColor, ::nBackMode, ::hFont ) } + + aadd( ::aPaint, { ::bPaint, { WVT_BLOCK_LABEL, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) + endif + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Refresh() CLASS WvtTextBox + + Eval( ::bPaint ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Configure() CLASS WvtTextBox + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD SetText( cText ) CLASS WvtTextBox + + if cText <> nil + ::cText := cText + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOn( /*cText*/ ) CLASS WvtTextBox + + if ::nTextColorHoverOn <> nil + ::nTextColor := ::nTextColorHoverOn + ::Refresh() + endif + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD HoverOff( /*cText*/ ) CLASS WvtTextBox + + if ::nTextColorHoverOn <> nil + ::nTextColor := ::nTextColorHoverOff + ::Refresh() + endif + +RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtProgressBar +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtProgressBar FROM WvtObject + + DATA cImage + DATA nDirection INIT 0 // 0-Left-Right,Top-Bottom 1-Right-Left,Bottom-Top + DATA nStyle INIT 0 + DATA lVertical INIT .f. + DATA lActive INIT .f. + + DATA nBarColor INIT RGB( 0,0,128 ) + DATA nCurrent INIT 0 + DATA nTotal INIT 1 + DATA nPercent INIT 0 + DATA cBackColor INIT 'W/W' + + DATA cScreen + + METHOD New() + METHOD Create() + METHOD Display() + METHOD Activate() + METHOD DeActivate() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent, nID, nTop, nLeft, nBottom, nRight ) CLASS WvtProgressBar + + ::Super:New( oParent, DLG_OBJ_PROGRESSBAR, nID, nTop, nLeft, nBottom, nRight ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Create() CLASS WvtProgressBar + + DEFAULT ::nTop TO 0 + DEFAULT ::nLeft TO 0 + DEFAULT ::nBottom TO if( ::lVertical, ::nTop + 9, ::nTop ) + DEFAULT ::nRight TO if( ::lVertical, ::nLeft + 1, ::nLeft + 19 ) + DEFAULT ::nTextColor TO RGB( 255,255,255 ) + DEFAULT ::nBackColor TO RGB( 198,198,198 ) + + ::bPaint := {|| ::Display() } + aadd( ::aPaint, { ::bPaint, { WVT_BLOCK_LABEL, ::nTop, ::nLeft, ::nBottom, ::nRight } } ) + + ::Super:Create() + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Display( nCurrent, nTotal ) CLASS WvtProgressBar + + if !( ::lActive ) + return Self + endif + + DEFAULT nCurrent TO ::nCurrent + DEFAULT nTotal TO ::nTotal + + ::nCurrent := nCurrent + ::nTotal := nTotal + + if ::nCurrent > ::nTotal + ::nCurrent := ::nTotal + endif + + ::nPercent := int( ::nCurrent / ::nTotal * 100 ) + + Wvt_DrawProgressBar( ::nTop, ::nLeft, ::nBottom, ::nRight, ::aPxlTLBR, ::nPercent, ; + ::nBackColor, ::nBarColor, ::cImage, ::lVertical, ::nDirection ) + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Activate() CLASS WvtProgressBar + + ::cScreen := SaveScreen( ::nTop, ::nLeft, ::nBottom, ::nRight ) + DispBox( ::nTop, ::nLeft, ::nBottom, ::nRight, ' ', ::cBackColor ) + ::lActive := .t. + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD DeActivate() CLASS WvtProgressBar + + ::lActive := .f. + ::nCurrent := 0 + ::nTotal := 1 + RestScreen( ::nTop, ::nLeft, ::nBottom, ::nRight, ::cScreen ) + ::cScreen := nil + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtMenu +// Peter Rees +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS wvtMenu + + METHOD Create( cCaption ) + METHOD AddItem( cCaption, bAction ) + METHOD DelAllItems() + METHOD DelItem( nItem ) + METHOD EnableItem( nItemNum ) + METHOD DisableItem( nItemNum ) + METHOD NumItems() + METHOD Destroy() + METHOD GetItem( nItemNum ) + METHOD FindMenuItemById( nId ) + METHOD DrawMenuBar() + + CLASSVAR MenuItemId INIT 1 + + VAR aItems + VAR hMenu + VAR Caption + VAR IdNumber + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD Create( cCaption ) CLASS wvtMenu + ::aItems := {} + + IF EMPTY( ::hMenu:= Wvt_CreateMenu() ) + //Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:Init()", "Create Menu Error", { cCaption, cCaption },"WVT.PRG" ) ) + ENDIF + ::Caption:= IIF( cCaption == NIL, "", cCaption ) + + RETURN(Self) + +//-------------------------------------------------------------------// + +METHOD Destroy() CLASS wvtMenu + + IF !EMPTY( ::hMenu ) + ::DelAllItems() + + IF !Wvt_DestroyMenu( ::hMenu ) + //Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:Destroy()", "Destroy menu FAILED", {},"WVT.PRG" ) ) + ENDIF + ::hMenu:= 0 + ENDIF + + RETURN( .T. ) + +//-------------------------------------------------------------------// + +METHOD AddItem(cCaption, bAction) CLASS wvtMenu + LOCAL lResult:= .F., aItem + + IF !EMPTY( ::hMenu ) .AND. ( !EMPTY( cCaption ) .OR. !EMPTY( bAction ) ) + IF HB_ISOBJECT( bAction ) + cCaption:= IIF(!EMPTY(cCaption),cCaption,bAction:Caption) + aItem:= {MF_POPUP,bAction:hMenu,cCaption,bAction} // bAction is a wvtMenu object reference + ELSEIF HB_ISBLOCK(bAction) + aItem:= {MF_STRING,::MenuItemId++,cCaption,bAction} // bAction is a code block to execute + ELSEIF cCaption[1]=="-" + aItem:= {MF_SEPARATOR,0,0,NIL} + ELSE + //Throw( ErrorNew( "wvtMenu", 3101, "wvtMenu:AddItem()", "Argument Error", { cCaption, bAction },"WVT.PRG" ) ) + ENDIF + + IF !Wvt_AppendMenu(::hMenu, aItem[WVT_MENU_TYPE],aItem[WVT_MENU_IDENTIFIER],aItem[WVT_MENU_CAPTION]) + //Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:AddItem()", "Add menu item", { cCaption, bAction },"WVT.PRG" ) ) + ENDIF + + AADD(::aItems, aItem) + lResult:= .T. + ENDIF + + RETURN( lResult ) + +//-------------------------------------------------------------------// + +METHOD DelAllItems() CLASS wvtMenu + LOCAL lResult:= .T., nItems + + nItems := ::NumItems() + DO WHILE nItems>0 .AND. lResult + lResult := ::DelItem( nItems ) + nItems-- + ENDDO + + RETURN ( lResult ) + +//-------------------------------------------------------------------// + +METHOD DelItem( nItemNum ) CLASS wvtMenu + LOCAL lResult:= .F. + + IF nItemNum > 0 .AND. nItemNum <= ::NumItems() + IF ::aItems[ nItemNum,WVT_MENU_TYPE ]== MF_POPUP + ::aItems[ nItemNum,WVT_MENU_MENUOBJ ]:Destroy() + ENDIF + + IF ( lResult:= Wvt_DeleteMenu(::hMenu, nItemNum-1,MF_BYPOSITION)) // Remember ZERO base + ADEL( ::aItems, nItemNum ) + ASIZE( ::aItems, LEN( ::aItems ) - 1 ) + ELSE + //Throw( ErrorNew( "wvtMenu", 1000, "wvtMenu:DelItem()", "Delete menu item FAILED", { nItemNum },"WVT.PRG" ) ) + ENDIF + ENDIF + + RETURN(lResult) + +//-------------------------------------------------------------------// + +METHOD EnableItem( nItemNum ) CLASS wvtMenu + LOCAL nPrevious:= -1 + + IF !EMPTY( ::hMenu ) && !EMPTY( nItemNum ) + nPrevious:= Wvt_EnableMenuItem( ::hMenu, nItemNum-1, MF_BYPOSITION + MF_ENABLED ) + ENDIF + + RETURN ( nPrevious ) + +//-------------------------------------------------------------------// + +METHOD DisableItem( nItemNum ) CLASS wvtMenu + LOCAL nPrevious:= -1 + + IF !EMPTY( ::hMenu ) && !EMPTY( nItemNum ) + nPrevious:= Wvt_EnableMenuItem( ::hMenu, nItemNum-1, MF_BYPOSITION + MF_GRAYED ) + ENDIF + + RETURN ( nPrevious ) + +//-------------------------------------------------------------------// + +METHOD NumItems() CLASS wvtMenu + + RETURN ( LEN( ::aItems ) ) + +//-------------------------------------------------------------------// + +METHOD GetItem( nItemNum ) CLASS wvtMenu + LOCAL nItems := ::NumItems(), aResult:= NIL + + IF nItemNum > 0 .AND. nItemNum <= nItems + aResult:= ::aItems[ nItemNum ] + ENDIF + + RETURN ( aResult ) + +//-------------------------------------------------------------------// + +METHOD FindMenuItemById( nId ) CLASS wvtMenu + LOCAL x, aResult:= {} + + IF !EMPTY( nId ) + x:= ::NumItems() + DO WHILE x > 0 .AND. EMPTY( aResult ) + IF ::aItems[ x,WVT_MENU_TYPE ] == MF_POPUP + aResult:= ::aItems[ x,WVT_MENU_MENUOBJ ]:FindMenuItemById( nId ) + ELSEIF ::aItems[ x,WVT_MENU_IDENTIFIER ] == nId + aResult := ::aItems[ x ] + ENDIF + x-- + ENDDO + ENDIF + + RETURN ( aResult ) + +//-------------------------------------------------------------------// + +METHOD DrawMenuBar() CLASS wvtMenu + + Wvt_DrawMenuBar() + + RETURN ( NIL ) + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Class WvtConsole +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +CLASS WvtConsole FROM WvtObject + + METHOD New() + METHOD Say() + METHOD Box() + +ENDCLASS + +//-------------------------------------------------------------------// + +METHOD New( oParent ) CLASS WvtConsole + + ::Super:New( oParent, DLG_OBJ_CONSOLE, , -1, -1, -1, -1 ) + + RETURN Self + +//-------------------------------------------------------------------// + +METHOD Say( nRow, nCol, xExp, cColor ) CLASS WvtConsole + LOCAL nCRow, nCCol, nCursor + + if nRow >=0 .and. nCol >= 0 .and. xExp <> nil + nCursor := SetCursor( SC_NONE ) + nCRow := Row() + nCCol := Col() + DispOutAt( nRow, nCol, xExp, cColor ) + SetPos( nCRow, nCCol ) + SetCursor( nCursor ) + endif + +RETURN Self + +//-------------------------------------------------------------------// + +METHOD Box( nRow, nCol, n2Row, n2Col, cBoxChars, cColor ) CLASS WvtConsole + + LOCAL nCRow, nCCol, nCursor + + if nRow >=0 .and. nCol >= 0 + nCursor := SetCursor( SC_NONE ) + nCRow := Row() + nCCol := Col() + DispBox( nRow, nCol, n2Row, n2Col, cBoxChars, cColor ) + SetPos( nCRow, nCCol ) + SetCursor( nCursor ) + endif + + RETURN Self + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + diff --git a/harbour/contrib/gtwvg/wvtcore.c b/harbour/contrib/gtwvg/wvtcore.c index 1aa4143398..032080b1ee 100644 --- a/harbour/contrib/gtwvg/wvtcore.c +++ b/harbour/contrib/gtwvg/wvtcore.c @@ -1,2487 +1,2487 @@ -/* - * Chr(36) + "Id" + Chr(36) - */ - -/* - * Harbour Project source code: - * - * Copyright 2007 Pritpal Bedi - * Based on: - * - * Video subsystem for Win32 using GUI windows instead of Console - * Copyright 2003 Peter Rees - * Rees Software & Systems Ltd - * based on - * Bcc ConIO Video subsystem by - * Copyright 2002 Marek Paliwoda - * Copyright 2002 Przemyslaw Czerpak - * Video subsystem for Win32 compilers - * Copyright 1999-2000 Paul Tucker - * Copyright 2002 Przemysław Czerpak - * - * The following parts are Copyright of the individual authors. - * www - http://www.harbour-project.org - * - * - * Copyright 1999 David G. Holm - * hb_gt_Tone() - * - * See doc/license.txt for licensing terms. - * - * www - 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. - * - */ -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// GUI Drawing Functions -// Pritpal Bedi -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -#define HB_OS_WIN_32_USED - -//-------------------------------------------------------------------// - -#include "gtwvt.h" - -static GLOBAL_DATA *_s = NULL; - -static void hb_wvt_DrawBoxRaised( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); -static void hb_wvt_DrawBoxRecessed( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); -static void hb_wvt_DrawOutline( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); -static void hb_wvt_DrawBoxGet( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); -static void hb_wvt_DrawBoxGroup( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); -static void hb_wvt_DrawBoxGroupRaised( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); -static void hb_wvt_DrawToolButtonFlat( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); -static void hb_wvt_DrawToolButtonUp( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); -static void hb_wvt_DrawToolButtonDown( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); - -//-------------------------------------------------------------------// - -void HB_EXPORT hb_wvt_wvtCore( void ) -{ - _s = hb_wvt_gtGetGlobalData(); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CORE ) -{ - hb_wvt_wvtCore(); -} - -//-------------------------------------------------------------------// - -HB_EXPORT BOOL hb_wvt_DrawImage( HDC hdc, int x1, int y1, int wd, int ht, char * image ) -{ - IStream *iStream; - IPicture *iPicture; - HGLOBAL hGlobal; - HANDLE hFile; - DWORD nFileSize; - DWORD nReadByte; - LONG lWidth,lHeight; - int x,y,xe,ye; - int c = x1 ; - int r = y1 ; - int dc = wd ; - int dr = ht ; - int tor = 0 ; - int toc = 0 ; - HRGN hrgn1; - POINT lpp = { 0,0 }; - BOOL bResult = FALSE; - - hFile = CreateFile( image, GENERIC_READ, 0, NULL, OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL ); - if ( hFile != INVALID_HANDLE_VALUE ) - { - nFileSize = GetFileSize( hFile, NULL ); - - if ( nFileSize != INVALID_FILE_SIZE ) - { - hGlobal = GlobalAlloc( GPTR, nFileSize ); - - if ( hGlobal ) - { - if ( ReadFile( hFile, hGlobal, nFileSize, &nReadByte, NULL ) ) - { - CreateStreamOnHGlobal( hGlobal, TRUE, &iStream ); - OleLoadPicture( iStream, nFileSize, TRUE, (REFIID) &IID_IPicture, ( LPVOID* )&iPicture ); - - if ( iPicture ) - { - iPicture->lpVtbl->get_Width( iPicture,&lWidth ); - iPicture->lpVtbl->get_Height( iPicture,&lHeight ); - - if ( dc == 0 ) - { - dc = ( int ) ( ( float ) dr * lWidth / lHeight ); - } - if ( dr == 0 ) - { - dr = ( int ) ( ( float ) dc * lHeight / lWidth ); - } - if ( tor == 0 ) - { - tor = dr; - } - if ( toc == 0 ) - { - toc = dc; - } - x = c; - y = r; - xe = c + toc - 1; - ye = r + tor - 1; - - GetViewportOrgEx( hdc, &lpp ); - - hrgn1 = CreateRectRgn( c+lpp.x, r+lpp.y, xe+lpp.x, ye+lpp.y ); - SelectClipRgn( hdc, hrgn1 ); - - while ( x < xe ) - { - while ( y < ye ) - { - iPicture->lpVtbl->Render( iPicture, hdc, x, y, dc, dr, 0, - lHeight, lWidth, -lHeight, NULL ); - y += dr; - } - y = r; - x += dc; - } - - SelectClipRgn( hdc, NULL ); - DeleteObject( hrgn1 ); - - iPicture->lpVtbl->Release( iPicture ); - bResult = TRUE ; - } - } - GlobalFree( hGlobal ); - } - } - CloseHandle( hFile ); - } - return( bResult ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawBoxRaised( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - SelectObject( hdc, _s->penWhiteDim ); - MoveToEx( hdc, iLeft, iTop, NULL ); // Top Inner - LineTo( hdc, iRight, iTop ); - MoveToEx( hdc, iLeft, iTop, NULL ); // Left Inner - LineTo( hdc, iLeft, iBottom ); - - SelectObject( hdc, _s->penWhite ); - MoveToEx( hdc, iLeft-1, iTop-1, NULL ); // Top Outer - LineTo( hdc, iRight+1, iTop-1 ); - MoveToEx( hdc, iLeft-1, iTop-1, NULL ); // Left Outer - LineTo( hdc, iLeft-1, iBottom+1 ); - - SelectObject( hdc, _s->penDarkGray ); - MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom Inner - LineTo( hdc, iRight, iBottom ); - MoveToEx( hdc, iRight, iBottom, NULL ); // Right Inner - LineTo( hdc, iRight, iTop ); - - SelectObject( hdc, _s->penBlack ); - MoveToEx( hdc, iLeft-1, iBottom+1, NULL ); // Bottom Outer - LineTo( hdc, iRight+1+1, iBottom+1 ); - MoveToEx( hdc, iRight+1, iTop-1, NULL ); // Right Outer - LineTo( hdc, iRight+1, iBottom+1 ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawBoxRecessed( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - SelectObject( hdc, _s->penWhiteDim ); - MoveToEx( hdc, iRight, iTop, NULL ); // Right Inner - LineTo( hdc, iRight, iBottom ); - MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom Inner - LineTo( hdc, iRight, iBottom ); - - SelectObject( hdc, _s->penWhite ); - MoveToEx( hdc, iRight+1, iTop-1, NULL ); // Right Outer - LineTo( hdc, iRight + 1, iBottom + 1 ); - MoveToEx( hdc, iLeft - 1, iBottom + 1, NULL ); // Bottom Outer - LineTo( hdc, iRight + 2, iBottom + 1 ); - - SelectObject( hdc, _s->penBlack ); - MoveToEx( hdc, iLeft, iTop, NULL ); // Left Inner - LineTo( hdc, iLeft, iBottom ); - MoveToEx( hdc, iLeft, iTop, NULL ); // Top Inner - LineTo( hdc, iRight, iTop ); - - SelectObject( hdc, _s->penDarkGray ); - MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Left Outer - LineTo( hdc, iLeft - 1 , iBottom + 1 ); - MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Top Outer - LineTo( hdc, iRight + 1, iTop - 1 ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawOutline( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - MoveToEx( hdc, iLeft, iTop, NULL ); // Top - LineTo( hdc, iRight, iTop ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Left - LineTo( hdc, iLeft, iBottom ); - - MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom - LineTo( hdc, iRight, iBottom ); - - MoveToEx( hdc, iRight, iTop, NULL ); // Right - LineTo( hdc, iRight, iBottom + 1); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawBoxGet( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - SelectObject( hdc, _s->penBlack ); - MoveToEx( hdc, iLeft-1 , iTop-1, NULL ); // Top Inner - LineTo( hdc, iRight-1, iTop-1 ); - MoveToEx( hdc, iLeft-1 , iTop-1, NULL ); // Left Inner - LineTo( hdc, iLeft-1 , iBottom-1 ); - - SelectObject( hdc, _s->penDarkGray ); - MoveToEx( hdc, iLeft-2, iTop-2, NULL ); // Top Outer - LineTo( hdc, iRight , iTop-2 ); - MoveToEx( hdc, iLeft-2, iTop-2, NULL ); // Left Outer - LineTo( hdc, iLeft-2, iBottom ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawBoxGroup( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - SelectObject( hdc, _s->penDarkGray ); - - MoveToEx( hdc, iRight, iTop, NULL ); // Right Inner - LineTo( hdc, iRight, iBottom ); - - MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom Inner - LineTo( hdc, iRight, iBottom ); - - MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Left Outer - LineTo( hdc, iLeft - 1, iBottom + 1 ); - - MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Top Outer - LineTo( hdc, iRight + 1, iTop - 1 ); - - - SelectObject( hdc, _s->penWhite ); - - MoveToEx( hdc, iRight + 1, iTop, NULL ); // Right Outer - LineTo( hdc, iRight + 1, iBottom + 1 ); - - MoveToEx( hdc, iLeft -1, iBottom + 1, NULL ); // Bottom Outer - LineTo( hdc, iRight + 1 + 1, iBottom + 1); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Left Inner - LineTo( hdc, iLeft, iBottom ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Top Inner - LineTo( hdc, iRight, iTop ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawBoxGroupRaised( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - SelectObject( hdc, _s->penWhite ); - - MoveToEx( hdc, iRight, iTop, NULL ); // Right Inner - LineTo( hdc, iRight, iBottom ); - - MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom Inner - LineTo( hdc, iRight, iBottom ); - - MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Left Outer - LineTo( hdc, iLeft - 1, iBottom + 1 ); - - MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Top Outer - LineTo( hdc, iRight + 1, iTop - 1 ); - - SelectObject( hdc, _s->penDarkGray ); - - MoveToEx( hdc, iRight + 1, iTop, NULL ); // Right Outer - LineTo( hdc, iRight + 1, iBottom + 1 ); - - MoveToEx( hdc, iLeft -1, iBottom + 1, NULL ); // Bottom Outer - LineTo( hdc, iRight + 1 + 1, iBottom + 1); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Left Inner - LineTo( hdc, iLeft, iBottom ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Top Inner - LineTo( hdc, iRight, iTop ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawToolButtonFlat( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - SelectObject( hdc, _s->penGray ); - - MoveToEx( hdc, iRight, iTop, NULL ); // Right - LineTo( hdc, iRight, iBottom + 1); - - MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom - LineTo( hdc, iRight, iBottom ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Left - LineTo( hdc, iLeft, iBottom ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Top - LineTo( hdc, iRight, iTop ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawToolButtonUp( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - SelectObject( hdc, _s->penBlack ); - - MoveToEx( hdc, iRight, iTop, NULL ); // Right - LineTo( hdc, iRight, iBottom+1 ); - - MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom - LineTo( hdc, iRight, iBottom ); - - SelectObject( hdc, _s->penWhite ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Left - LineTo( hdc, iLeft, iBottom ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Top - LineTo( hdc, iRight, iTop ); -} - -//-------------------------------------------------------------------// - -static void hb_wvt_DrawToolButtonDown( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) -{ - SelectObject( hdc, _s->penWhite ); - - MoveToEx( hdc, iRight, iTop, NULL ); // Right - LineTo( hdc, iRight, iBottom+1 ); - - MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom - LineTo( hdc, iRight, iBottom ); - - SelectObject( hdc, _s->penBlack ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Left - LineTo( hdc, iLeft, iBottom ); - - MoveToEx( hdc, iLeft, iTop, NULL ); // Top - LineTo( hdc, iRight, iTop ); -} - -//-------------------------------------------------------------------// -// -// Wvt_SetPen( nPenStyle, nWidth, nColor ) -// -HB_FUNC( WVT_SETPEN ) -{ - int iPenWidth, iPenStyle; - COLORREF crColor; - HPEN hPen; - - if ( ISNIL( 1 ) ) - { - hb_retl( FALSE ); - } - - iPenStyle = hb_parni( 1 ) ; - iPenWidth = ISNIL( 2 ) ? 0 : hb_parni( 2 ); - crColor = ISNIL( 3 ) ? RGB( 0,0,0 ) : ( COLORREF ) hb_parnl( 3 ); - - hPen = CreatePen( iPenStyle, iPenWidth, crColor ); - - if ( hPen ) - { - if ( _s->currentPen ) - { - DeleteObject( _s->currentPen ); - } - _s->currentPen = hPen; - - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_SetBrush( nStyle, nColor, [ nHatch ] ) -// -HB_FUNC( WVT_SETBRUSH ) -{ - HBRUSH hBrush; - LOGBRUSH lb = { 0,0,0 }; - - if ( ISNIL( 1 ) ) - { - hb_retl( FALSE ); - } - - lb.lbStyle = hb_parnl( 1 ); - lb.lbColor = ISNIL( 2 ) ? RGB( 0,0,0 ) : ( COLORREF ) hb_parnl( 2 ) ; - lb.lbHatch = ISNIL( 3 ) ? 0 : hb_parnl( 3 ); - - hBrush = CreateBrushIndirect( &lb ); - - if ( hBrush ) - { - if ( _s->currentBrush ) - { - DeleteObject( _s->currentBrush ); - } - _s->currentBrush = hBrush; - - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawBoxGet( nRow, nCol, nWidth ) -// -HB_FUNC( WVT_DRAWBOXGET ) -{ - POINT xy = { 0,0 }; - POINT yz = { 0,0 }; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - yz = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ) + hb_parni( 3 ), hb_parni( 1 ) + 1 ); - - hb_wvt_DrawBoxGet( _s->hdc, xy.y, xy.x, yz.y, yz.x ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxGet( _s->hGuiDC, xy.y, xy.x, yz.y, yz.x ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawBoxRaised( nTop, nLeft, nBottom, nRight, aPxlOff ) -// -HB_FUNC( WVT_DRAWBOXRAISED ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - hb_wvt_DrawBoxRaised( _s->hdc, iTop-1, iLeft-1, iBottom+1, iRight+1 ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxRaised( _s->hGuiDC, iTop-1, iLeft-1, iBottom+1, iRight+1 ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawBoxRecessed( nTop, nLeft, nBottom, nRight, aPxlOff ) -// -HB_FUNC( WVT_DRAWBOXRECESSED ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - hb_wvt_DrawBoxRecessed( _s->hdc, iTop-1, iLeft-1, iBottom+1, iRight+1 ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxRecessed( _s->hGuiDC, iTop-1, iLeft-1, iBottom+1, iRight+1 ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawBoxGroup( nTop, nLeft, nBottom, nRight, aPxlOff ) -// -HB_FUNC( WVT_DRAWBOXGROUP ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - hb_wvt_DrawBoxGroup( _s->hdc, iTop, iLeft, iBottom, iRight ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxGroup( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawBoxRaised( nTop, nLeft, nBottom, nRight, aPxlOff ) -// -HB_FUNC( WVT_DRAWBOXGROUPRAISED ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - hb_wvt_DrawBoxGroupRaised( _s->hdc, iTop, iLeft, iBottom, iRight ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxGroupRaised( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawImage( nTop, nLeft, nBottom, nRight, cImage/nPictureSlot, aOffSet ) -// -HB_FUNC( WVT_DRAWIMAGE ) -{ - POINT xy = { 0,0 }; - int iLeft, iTop, iRight, iBottom; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y + hb_parni( 6,1 ); - iLeft = xy.x + hb_parni( 6,2 ) ; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); - iBottom = xy.y - 1 + hb_parni( 6,3 ); - iRight = xy.x - 1 + hb_parni( 6,4 ); - - if ( ISNUM( 5 ) ) - { - hb_wvt_gtRenderPicture( iLeft, iTop, ( iRight - iLeft ) + 1, ( iBottom - iTop ) + 1, _s->iPicture[ hb_parni( 5 )-1 ] ); - } - else - { - hb_wvt_DrawImage( _s->hdc, iLeft, iTop, ( iRight - iLeft ) + 1, ( iBottom - iTop ) + 1, hb_parcx( 5 ) ) ; - if ( _s->bGui ) - { - hb_wvt_DrawImage( _s->hGuiDC, iLeft, iTop, ( iRight - iLeft ) + 1, ( iBottom - iTop ) + 1, hb_parcx( 5 ) ) ; - } - } - - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// -// -// WVT_DRAWLABEL( nRow, nCol, cLabel, nAlign, nEscapement, nTextColor, nBkColor, -// cFontFace, , , , , ) -// -HB_FUNC( WVT_DRAWLABEL ) -{ - POINT xy = { 0,0 }; - HFONT hFont, hOldFont, hOldFontGui; - LOGFONT logfont;// = { 0 }; - - logfont.lfEscapement = ( ISNIL( 5 ) ? 0 : ( hb_parni( 5 ) * 10 ) ); - logfont.lfOrientation = 0; - logfont.lfWeight = ( ISNIL( 11 ) ? 0 : hb_parni( 11 ) ); - logfont.lfItalic = ( ISNIL( 14 ) ? 0 : hb_parl( 14 ) ); - logfont.lfUnderline = ( ISNIL( 15 ) ? 0 : hb_parl( 15 ) ); - logfont.lfStrikeOut = ( ISNIL( 16 ) ? 0 : hb_parl( 16 ) ); - logfont.lfCharSet = ( ISNIL( 13 ) ? _s->CodePage : hb_parni( 13 ) ); - logfont.lfOutPrecision = 0; - logfont.lfClipPrecision = 0; - logfont.lfQuality = ( ISNIL( 12 ) ? DEFAULT_QUALITY : hb_parni( 12 ) ); - logfont.lfPitchAndFamily = FF_DONTCARE; - logfont.lfHeight = ( ISNIL( 9 ) ? _s->fontHeight : hb_parni( 9 ) ); - logfont.lfWidth = ( ISNIL( 10 ) ? (_s->fontWidth < 0 ? -_s->fontWidth : _s->fontWidth ) : hb_parni( 10 ) ); - - strcpy( logfont.lfFaceName, ( ISNIL( 8 ) ? _s->fontFace : hb_parcx( 8 ) ) ); - - hFont = CreateFontIndirect( &logfont ); - if ( hFont ) - { - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - - SetBkColor( _s->hdc, ISNIL( 7 ) ? _s->background : ( COLORREF ) hb_parnl( 7 ) ); - SetTextColor( _s->hdc, ISNIL( 6 ) ? _s->foreground : ( COLORREF ) hb_parnl( 6 ) ); - SetTextAlign( _s->hdc, ( ISNIL( 4 ) ? TA_LEFT : hb_parni( 4 ) ) ); - hOldFont = SelectObject( _s->hdc, hFont ); - - ExtTextOut( _s->hdc, xy.x, xy.y, 0, NULL, hb_parcx( 3 ), strlen( hb_parcx( 3 ) ), NULL ); - - SelectObject( _s->hdc, hOldFont ); - - if ( _s->bGui ) - { - SetBkColor( _s->hGuiDC, ISNIL( 7 ) ? _s->background : ( COLORREF ) hb_parnl( 7 ) ); - SetTextColor( _s->hGuiDC, ISNIL( 6 ) ? _s->foreground : ( COLORREF ) hb_parnl( 6 ) ); - SetTextAlign( _s->hGuiDC, ( ISNIL( 4 ) ? TA_LEFT : hb_parni( 4 ) ) ); - hOldFontGui = SelectObject( _s->hGuiDC, hFont ); - - ExtTextOut( _s->hGuiDC, xy.x, xy.y, 0, NULL, hb_parcx( 3 ), strlen( hb_parcx( 3 ) ), NULL ); - - SelectObject( _s->hGuiDC, hOldFontGui ); - } - - DeleteObject( hFont ); - hb_retl( TRUE ); - } - - hb_retl( FALSE ); -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawOutline( nTop, nLeft, nBottom, nRight, nThick, nShape, nRGBColor ) -// -HB_FUNC( WVT_DRAWOUTLINE ) -{ - HPEN hPen, hOldPen, hOldPenGUI; - POINT xy = { 0,0 }; - int iTop, iLeft, iBottom, iRight; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y - 1; - iLeft = xy.x - 1; - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); - iBottom = xy.y; - iRight = xy.x; - - if ( ISNUM( 5 ) ) - { - hPen = CreatePen( hb_parni( 5 ), 0, ( ISNIL( 7 ) ? 0 : ( COLORREF ) hb_parnl( 7 ) ) ); - if ( hPen ) - { - hOldPen = (HPEN) SelectObject( _s->hdc, hPen ); - } - } - else - { - hPen = 0; - SelectObject( _s->hdc, _s->penBlack ); - } - - hb_wvt_DrawOutline( _s->hdc, iTop, iLeft, iBottom, iRight ); - if ( _s->bGui ) - { - if ( hPen ) - { - hOldPenGUI = (HPEN) SelectObject( _s->hGuiDC, hPen ); - } - else - { - hOldPenGUI = (HPEN) SelectObject( _s->hGuiDC, _s->penBlack ); - hb_wvt_DrawOutline( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); - } - } - - if ( hPen ) - { - SelectObject( _s->hdc, hOldPen ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hOldPenGUI ); - } - DeleteObject( hPen ); - } -} - -//-------------------------------------------------------------------// -// 1 2 3 4 5 6 7 8 9 10 11 -// Wvt_DrawLine( nTop, nLeft, nBottom, nRight, nOrient, nFormat, nAlign, nStyle, nThick, nColor, aPxlOff ) -// -HB_FUNC( WVT_DRAWLINE ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 11,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 11,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 11,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 11,4 ); - - int iOrient, iFormat, iAlign, iStyle, iThick; - int x, y, iOffset; - COLORREF cr; - HPEN hPen, hOldPen, hOldPenGUI; - - // Resolve Parameters - iOrient = ISNIL( 5 ) ? 0 : hb_parni( 5 ); - iFormat = ISNIL( 6 ) ? 0 : hb_parni( 6 ); - iAlign = ISNIL( 7 ) ? 0 : hb_parni( 7 ); - iStyle = ISNIL( 8 ) ? 0 : hb_parni( 8 ); - iThick = ISNIL( 9 ) ? 0 : hb_parni( 9 ); - cr = ISNIL(10 ) ? 0 : ( COLORREF ) hb_parnl( 10 ); - - x = iLeft ; - y = iTop ; - - switch ( iAlign ) - { - case 0: // Center - { - if ( iOrient == 0 ) // Horizontal - { - iOffset = ( ( iBottom - iTop ) / 2 ) ; - y = iTop + iOffset ; - } - else - { - iOffset = ( ( iRight - iLeft ) / 2 ) ; - x = iLeft + iOffset ; - } - } - break; - - case 1: // Top - break; - - case 2: // bottom - { - if ( iFormat == 0 || iFormat == 1 ) // Raised/Recessd - { - y = iBottom - 1; - } - else - { - y = iBottom; - } - } - break; - - case 3: // Left - break; - - case 4: // Right - { - if ( iFormat == 0 || iFormat == 1 ) // Raised/Recessd - { - x = iRight - 1; - } - else - { - x = iRight; - } - } - break; - } - - hPen = CreatePen( iStyle, iThick, cr ); - hOldPen = (HPEN) SelectObject( _s->hdc, hPen ); - if ( _s->bGui ) - { - hOldPenGUI = (HPEN) SelectObject( _s->hGuiDC, hPen ); - } - - switch ( iFormat ) - { - case 0: // Raised - { - if ( iOrient == 0 ) // Horizontal - { - SelectObject( _s->hdc, _s->penWhite ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, iRight, y ); - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y+1, NULL ); - LineTo( _s->hdc, iRight, y+1 ); - - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, _s->penWhite ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, iRight, y ); - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y+1, NULL ); - LineTo( _s->hGuiDC, iRight, y+1 ); - } - } - else // Vertical - { - SelectObject( _s->hdc, _s->penWhite ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, x, iBottom ); - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x+1, y, NULL ); - LineTo( _s->hdc, x+1, iBottom ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, _s->penWhite ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, x, iBottom ); - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x+1, y, NULL ); - LineTo( _s->hGuiDC, x+1, iBottom ); - } - } - } - break; - - case 1: // Recessed - { - if ( iOrient == 0 ) // Horizontal - { - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, iRight, y ); - SelectObject( _s->hdc, _s->penWhite ); - MoveToEx( _s->hdc, x, y+1, NULL ); - LineTo( _s->hdc, iRight, y+1 ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, iRight, y ); - SelectObject( _s->hGuiDC, _s->penWhite ); - MoveToEx( _s->hGuiDC, x, y+1, NULL ); - LineTo( _s->hGuiDC, iRight, y+1 ); - } - } - else // Vertical - { - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, x, iBottom ); - SelectObject( _s->hdc, _s->penWhite ); - MoveToEx( _s->hdc, x+1, y, NULL ); - LineTo( _s->hdc, x+1, iBottom ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, x, iBottom ); - SelectObject( _s->hGuiDC, _s->penWhite ); - MoveToEx( _s->hGuiDC, x+1, y, NULL ); - LineTo( _s->hGuiDC, x+1, iBottom ); - } - } - } - break; - - case 2: // Plain - { - if ( iOrient == 0 ) // Horizontal - { - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, iRight, y ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, iRight, y ); - } - } - else // Vertical - { - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, x, iBottom ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, x, iBottom ); - } - } - } - break; - } - - SelectObject( _s->hdc, hOldPen ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hOldPenGUI ); - } - DeleteObject( hPen ); - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// -// -// Inside the area requested! -// Wvt_DrawEllipse( nTop, nLeft, nBottom, nRight, aPxlOff ) -// -HB_FUNC( WVT_DRAWELLIPSE ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - SelectObject( _s->hdc, _s->currentBrush ); - SelectObject( _s->hdc, _s->currentPen ); - - hb_retl( Ellipse( _s->hdc, iLeft, iTop, iRight, iBottom ) ); - if ( _s->bGui ) - { - hb_retl( Ellipse( _s->hGuiDC, iLeft, iTop, iRight, iBottom ) ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawRectangle( nTop, nLeft, nBottom, nRight, aPxlOff ) -// -HB_FUNC( WVT_DRAWRECTANGLE ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - SelectObject( _s->hdc, _s->currentBrush ); - SelectObject( _s->hdc, _s->currentPen ); - - hb_retl( Rectangle( _s->hdc, iLeft, iTop, iRight, iBottom ) ); - if ( _s->bGui ) - { - hb_retl( Rectangle( _s->hGuiDC, iLeft, iTop, iRight, iBottom ) ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawRoundRect( nTop, nLeft, nBottom, nRight, aPxlOff, nRoundHeight, nRoundWidth ) -// -HB_FUNC( WVT_DRAWROUNDRECT ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - int iHt, iWd; - - iHt = ISNIL( 6 ) ? 0 : hb_parni( 6 ); - iWd = ISNIL( 7 ) ? 0 : hb_parni( 7 ); - - SelectObject( _s->hdc, _s->currentBrush ); - SelectObject( _s->hdc, _s->currentPen ); - - hb_retl( RoundRect( _s->hdc, iLeft, iTop, iRight, iBottom, iWd, iHt ) ); - if ( _s->bGui ) - { - hb_retl( RoundRect( _s->hGuiDC, iLeft, iTop, iRight, iBottom, iWd, iHt ) ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawFocusRect( nTop, nLeft, nBottom, nRight, aPxlOff ) -// -HB_FUNC( WVT_DRAWFOCUSRECT ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - RECT rc = { 0,0,0,0 }; - - rc.left = iLeft; - rc.top = iTop; - rc.right = iRight; - rc.bottom = iBottom; - - hb_retl( DrawFocusRect( _s->hdc, &rc ) ); - if ( _s->bGui ) - { - hb_retl( DrawFocusRect( _s->hGuiDC, &rc ) ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawColorRect( nTop, nLeft, nBottom, nRight, aPxlOff, nRGB ) -// -HB_FUNC( WVT_DRAWCOLORRECT ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - RECT rc = { 0,0,0,0 }; - HBRUSH hBrush; - - hBrush = CreateSolidBrush( ( COLORREF ) hb_parnl( 6 ) ); - - if ( hBrush ) - { - rc.left = iLeft; - rc.top = iTop; - rc.right = iRight; - rc.bottom = iBottom; - - hb_retl( FillRect( _s->hdc, &rc, hBrush ) ); - if ( _s->bGui ) - { - hb_retl( FillRect( _s->hGuiDC, &rc, hBrush ) ); - } - - DeleteObject( hBrush ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawGridHorz( nTop, nLeft, nRight, nRows ) -// -HB_FUNC( WVT_DRAWGRIDHORZ ) -{ - int iAtRow = hb_parni( 1 ); - int iRows = hb_parni( 4 ); - int i, y; - int iLeft, iRight; - - iLeft = ( hb_parni( 2 ) * _s->PTEXTSIZE.x ); - iRight = ( ( ( hb_parni( 3 ) + 1 ) * _s->PTEXTSIZE.x ) - 1 ); - - SelectObject( _s->hdc, _s->currentPen ); - - for ( i = 0; i < iRows; i++ ) - { - y = ( ( iAtRow ) * _s->PTEXTSIZE.y ); - - MoveToEx( _s->hdc, iLeft, y, NULL ); - LineTo( _s->hdc, iRight, y ); - - iAtRow++; - } - - if ( _s->bGui ) - { - iAtRow = hb_parni( 1 ); - - SelectObject( _s->hGuiDC, _s->currentPen ); - - for ( i = 0; i < iRows; i++ ) - { - y = ( ( iAtRow ) * _s->PTEXTSIZE.y ); - - MoveToEx( _s->hGuiDC, iLeft, y, NULL ); - LineTo( _s->hGuiDC, iRight, y ); - - iAtRow++; - } - } - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawGridVert( nTop, nBottom, aCols, nCols ) -// -HB_FUNC( WVT_DRAWGRIDVERT ) -{ - int iTop, iBottom, x, i, iCharHeight, iCharWidth; - int iTabs = hb_parni( 4 ); - - if ( ! iTabs ) - { - hb_retl( FALSE ); - } - - iCharWidth = _s->PTEXTSIZE.x; - iCharHeight = _s->PTEXTSIZE.y; - - iTop = ( hb_parni( 1 ) * iCharHeight ); - iBottom = ( ( hb_parni( 2 ) + 1 ) * iCharHeight ) - 1; - - SelectObject( _s->hdc, _s->currentPen ); - - for ( i = 1; i <= iTabs; i++ ) - { - x = ( hb_parni( 3,i ) * iCharWidth ); - - MoveToEx( _s->hdc, x, iTop, NULL ); - LineTo( _s->hdc, x, iBottom ); - } - - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, _s->currentPen ); - for ( i = 1; i <= iTabs; i++ ) - { - x = ( hb_parni( 3,i ) * iCharWidth ); - - MoveToEx( _s->hGuiDC, x, iTop, NULL ); - LineTo( _s->hGuiDC, x, iBottom ); - } - } - - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawButton( nTop, nLeft, nBottom, nRight, cText, cnImage, ; -// nFormat, nTextColor, nBkColor, nImageAt ) ; -// -HB_FUNC( WVT_DRAWBUTTON ) -{ - SIZE sz = { 0,0 }; - POINT xy = { 0,0 }; - RECT rc = { 0,0,0,0 }; - int iTop, iLeft, iBottom, iRight; - int iAlign; - int iTextHeight /*, iTextWidth */ ; - int iImageWidth, iImageHeight; - LOGBRUSH lb = { 0,0,0 }; - HBRUSH hBrush; - IPicture *iPicture; - - BOOL bText = ISCHAR( 5 ); - BOOL bImage = !( ISNIL( 6 ) ); - int iFormat = ISNIL( 7 ) ? 0 : hb_parni( 7 ); - COLORREF textColor = ISNIL( 8 ) ? hb_wvt_gtGetColorData( 0 ) : ( COLORREF ) hb_parnl( 8 ) ; - COLORREF bkColor = ISNIL( 9 ) ? hb_wvt_gtGetColorData( 7 ) : ( COLORREF ) hb_parnl( 9 ) ; - // int iImageAt = ISNIL( 10 ) ? 0 : hb_parni( 10 ); - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y; - iLeft = xy.x; - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); - iBottom = xy.y-1; - iRight = xy.x-1; - - lb.lbStyle = BS_SOLID; - lb.lbColor = bkColor; - lb.lbHatch = 0; - - hBrush = CreateBrushIndirect( &lb ); - - rc.left = iLeft ; - rc.top = iTop ; - rc.right = iRight + 1; - rc.bottom = iBottom + 1; - - FillRect( _s->hdc, &rc, hBrush ); - if ( _s->bGui ) - { - FillRect( _s->hGuiDC, &rc, hBrush ); - } - DeleteObject( hBrush ); - - switch ( iFormat ) - { - case 1: - hb_wvt_DrawBoxRecessed( _s->hdc, iTop+1, iLeft+1, iBottom-1, iRight-1 ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxRecessed( _s->hGuiDC, iTop+1, iLeft+1, iBottom-1, iRight-1 ); - } - break; - case 2: - break; - case 3: - hb_wvt_DrawOutline( _s->hdc, iTop, iLeft, iBottom, iRight ); - if ( _s->bGui ) - { - hb_wvt_DrawOutline( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); - } - break; - case 4: - break; - default: - hb_wvt_DrawBoxRaised( _s->hdc, iTop+1, iLeft+1, iBottom-1, iRight-1 ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxRaised( _s->hGuiDC, iTop+1, iLeft+1, iBottom-1, iRight-1 ); - } - break; - } - - if ( bText ) - { - ( HFONT ) SelectObject( _s->hdc, GetStockObject( DEFAULT_GUI_FONT ) ); - - GetTextExtentPoint32( _s->hdc, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), &sz ); - // iTextWidth = sz.cx; - iTextHeight = sz.cy; - - xy.x = iLeft + ( ( iRight - iLeft + 1 ) / 2 ) ; - - if ( bImage ) - { - xy.y = ( iBottom - 2 - iTextHeight ); - } - else - { - xy.y = iTop + ( ( iBottom - iTop + 1 - iTextHeight ) / 2 ) ; - } - - if ( iFormat == 1 ) - { - xy.x = xy.x + 2; - xy.y = xy.y + 2; - } - - iAlign = TA_CENTER + TA_TOP ; - - SetTextAlign( _s->hdc, iAlign ); - SetBkMode( _s->hdc, TRANSPARENT ); - SetTextColor( _s->hdc, textColor ); - - ExtTextOut( _s->hdc, xy.x, xy.y, 0, NULL, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), NULL ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, GetStockObject( DEFAULT_GUI_FONT ) ); - SetTextAlign( _s->hGuiDC, iAlign ); - SetBkMode( _s->hGuiDC, TRANSPARENT ); - SetTextColor( _s->hGuiDC, textColor ); - - ExtTextOut( _s->hGuiDC, xy.x, xy.y, 0, NULL, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), NULL ); - } - } - else - { - iTextHeight = -1; - } - - if ( bImage ) - { - iImageWidth = ( iRight - iLeft + 1 - 8 ); - iImageHeight = ( iBottom - iTop + 1 - 8 - iTextHeight ); - - if ( ISNUM( 6 ) ) - { - iPicture = _s->iPicture[ hb_parni( 6 ) - 1 ]; - hb_wvt_gtRenderPicture( iLeft+4, iTop+4, iImageWidth, iImageHeight, iPicture ); - } - else - { - hb_wvt_DrawImage( _s->hdc, iLeft+4, iTop+4, iImageWidth, iImageHeight, hb_parcx( 6 ) ); - if ( _s->bGui ) - { - hb_wvt_DrawImage( _s->hGuiDC, iLeft+4, iTop+4, iImageWidth, iImageHeight, hb_parcx( 6 ) ); - } - } - } - - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_DRAWSTATUSBAR ) -{ - int iPanels = hb_parni( 1 ); - int i, iNext; - int iTop, iLeft, iBottom, iRight; - POINT xy = { 0,0 }; - - iNext = 0; - - for ( i = 0; i < iPanels; i++ ) - { - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2, iNext+2 ), hb_parni( 2, iNext+1 ) ); - iTop = xy.y; - iLeft = xy.x + 1; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2, iNext+4 ), hb_parni( 2, iNext+3 )+1 ); - iBottom = xy.y - 1; - iRight = xy.x - 2; - - SelectObject( _s->hdc, _s->penWhite ); - - MoveToEx( _s->hdc, iRight, iTop, NULL ); // Right - LineTo( _s->hdc, iRight, iBottom ); - - MoveToEx( _s->hdc, iLeft, iBottom, NULL ); // Bottom - LineTo( _s->hdc, iRight, iBottom ); - - SelectObject( _s->hdc, _s->penDarkGray ); - - MoveToEx( _s->hdc, iLeft, iTop, NULL ); // Left - LineTo( _s->hdc, iLeft, iBottom ); - - MoveToEx( _s->hdc, iLeft, iTop, NULL ); // Top - LineTo( _s->hdc, iRight, iTop ); - - iNext = iNext + 4; - } - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2, 4 * iPanels ), hb_parni( 2, ( 4 * iPanels ) - 1 )+1 ); - iTop = xy.y - 2; - iLeft = xy.x - 2; - iBottom = iTop; - iRight = iLeft; - - SelectObject( _s->hdc, _s->penBlack ); - - MoveToEx( _s->hdc, iLeft-4, iBottom, NULL ); - LineTo( _s->hdc, iRight, iTop-4 ); - MoveToEx( _s->hdc, iLeft-7, iBottom, NULL ); - LineTo( _s->hdc, iRight, iTop-7 ); - MoveToEx( _s->hdc, iLeft-10, iBottom, NULL ); - LineTo( _s->hdc, iRight, iTop-10 ); - - SelectObject( _s->hdc, _s->penWhite ); - - MoveToEx( _s->hdc, iLeft-5, iBottom, NULL ); - LineTo( _s->hdc, iRight, iTop-5 ); - MoveToEx( _s->hdc, iLeft-8, iBottom, NULL ); - LineTo( _s->hdc, iRight, iTop-8 ); - MoveToEx( _s->hdc, iLeft-11, iBottom, NULL ); - LineTo( _s->hdc, iRight, iTop-11 ); -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawPicture( nTop, nLeft, nBottom, nRight, nSlot, aPxlOff ) -> lOk -// nSlot <= 20 aAdj == { 0,0,-2,-2 } To Adjust the pixels for { Top,Left,Bottom,Right } -// -HB_FUNC( WVT_DRAWPICTURE ) -{ - POINT xy = { 0,0 }; - int iTop, iLeft, iBottom, iRight; - int iSlot = hb_parni( 5 ) - 1; - - if ( iSlot < WVT_PICTURES_MAX ) - { - if ( _s->iPicture[ iSlot ] ) - { - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y + hb_parni( 6,1 ); - iLeft = xy.x + hb_parni( 6,2 ); - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); - iBottom = xy.y-1 + hb_parni( 6,3 ); - iRight = xy.x-1 + hb_parni( 6,4 ); - - hb_retl( hb_wvt_gtRenderPicture( iLeft, iTop, iRight - iLeft + 1, iBottom - iTop + 1, _s->iPicture[ iSlot ] ) ); - } - } -} - -//-------------------------------------------------------------------// -// -// WVT_DRAWLABELEX( nRow, nCol, cLabel, nAlign, nTextColor, nBkColor, nSlotFont ) -// -HB_FUNC( WVT_DRAWLABELEX ) -{ - POINT xy = { 0,0 }; - int iSlot = hb_parni( 7 ) - 1; - - if ( _s->hUserFonts[ iSlot ] ) - { - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - - SetBkColor( _s->hdc, ISNIL( 6 ) ? _s->background : ( COLORREF ) hb_parnl( 6 ) ); - SetTextColor( _s->hdc, ISNIL( 5 ) ? _s->foreground : ( COLORREF ) hb_parnl( 5 ) ); - SetTextAlign( _s->hdc, ( ISNIL( 4 ) ? TA_LEFT : hb_parni( 4 ) ) ); - ( HFONT ) SelectObject( _s->hdc, _s->hUserFonts[ iSlot ] ); - - ExtTextOut( _s->hdc, xy.x, xy.y, 0, NULL, hb_parcx( 3 ), strlen( hb_parcx( 3 ) ), NULL ); - if ( _s->bGui ) - { - SetBkColor( _s->hGuiDC, ISNIL( 6 ) ? _s->background : ( COLORREF ) hb_parnl( 6 ) ); - SetTextColor( _s->hGuiDC, ISNIL( 5 ) ? _s->foreground : ( COLORREF ) hb_parnl( 5 ) ); - SetTextAlign( _s->hGuiDC, ( ISNIL( 4 ) ? TA_LEFT : hb_parni( 4 ) ) ); - ( HFONT ) SelectObject( _s->hGuiDC, _s->hUserFonts[ iSlot ] ); - - ExtTextOut( _s->hGuiDC, xy.x, xy.y, 0, NULL, hb_parcx( 3 ), strlen( hb_parcx( 3 ) ), NULL ); - } - - hb_retl( TRUE ); - } - - hb_retl( FALSE ); -} - -//-------------------------------------------------------------------// -// 1 2 3 4 5 6 7 8 -// Wvt_DrawLine( nTop, nLeft, nBottom, nRight, nOrient, nFormat, nAlign, nSlotPen ) -// -HB_FUNC( WVT_DRAWLINEEX ) -{ - POINT xy = { 0,0 }; - int iTop, iLeft, iBottom, iRight, iOffset ; - int iOrient, iFormat, iAlign ; - int x, y; - HPEN hPen; - int iSlot = hb_parni( 8 ) - 1; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y; - iLeft = xy.x; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); - iBottom = xy.y-1; - iRight = xy.x-1; - - // Resolve Parameters - iOrient = ISNIL( 5 ) ? 0 : hb_parni( 5 ); - iFormat = ISNIL( 6 ) ? 0 : hb_parni( 6 ); - iAlign = ISNIL( 7 ) ? 0 : hb_parni( 7 ); - - x = iLeft ; - y = iTop ; - - switch ( iAlign ) - { - case 0: // Center - { - if ( iOrient == 0 ) // Horizontal - { - iOffset = ( ( iBottom - iTop ) / 2 ) ; - y = iTop + iOffset ; - } - else - { - iOffset = ( ( iRight - iLeft ) / 2 ) ; - x = iLeft + iOffset ; - } - } - break; - - case 1: // Top - break; - - case 2: // bottom - { - if ( iFormat == 0 || iFormat == 1 ) // Raised/Recessd - { - y = iBottom - 1; - } - else - { - y = iBottom; - } - } - break; - - case 3: // Left - break; - - case 4: // Right - { - if ( iFormat == 0 || iFormat == 1 ) // Raised/Recessd - { - x = iRight - 1; - } - else - { - x = iRight; - } - } - break; - } - - hPen = _s->hUserPens[ iSlot ]; - - switch ( iFormat ) - { - case 0: // Raised - { - if ( iOrient == 0 ) // Horizontal - { - SelectObject( _s->hdc, _s->penWhite ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, iRight, y ); - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y+1, NULL ); - LineTo( _s->hdc, iRight, y+1 ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, _s->penWhite ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, iRight, y ); - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y+1, NULL ); - LineTo( _s->hGuiDC, iRight, y+1 ); - } - } - else // Vertical - { - SelectObject( _s->hdc, _s->penWhite ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, x, iBottom ); - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x+1, y, NULL ); - LineTo( _s->hdc, x+1, iBottom ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, _s->penWhite ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, x, iBottom ); - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x+1, y, NULL ); - LineTo( _s->hGuiDC, x+1, iBottom ); - } - } - } - break; - - case 1: // Recessed - { - if ( iOrient == 0 ) // Horizontal - { - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, iRight, y ); - SelectObject( _s->hdc, _s->penWhite ); - MoveToEx( _s->hdc, x, y+1, NULL ); - LineTo( _s->hdc, iRight, y+1 ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, iRight, y ); - SelectObject( _s->hGuiDC, _s->penWhite ); - MoveToEx( _s->hGuiDC, x, y+1, NULL ); - LineTo( _s->hGuiDC, iRight, y+1 ); - } - } - else // Vertical - { - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, x, iBottom ); - SelectObject( _s->hdc, _s->penWhite ); - MoveToEx( _s->hdc, x+1, y, NULL ); - LineTo( _s->hdc, x+1, iBottom ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, x, iBottom ); - SelectObject( _s->hGuiDC, _s->penWhite ); - MoveToEx( _s->hGuiDC, x+1, y, NULL ); - LineTo( _s->hGuiDC, x+1, iBottom ); - } - } - } - break; - - case 2: // Plain - { - if ( iOrient == 0 ) // Horizontal - { - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, iRight, y ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, iRight, y ); - } - } - else // Vertical - { - SelectObject( _s->hdc, hPen ); - MoveToEx( _s->hdc, x, y, NULL ); - LineTo( _s->hdc, x, iBottom ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, hPen ); - MoveToEx( _s->hGuiDC, x, y, NULL ); - LineTo( _s->hGuiDC, x, iBottom ); - } - } - } - break; - } - - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawOutlineEx( nTop, nLeft, nBottom, nRight, nSlotPen ) -// -HB_FUNC( WVT_DRAWOUTLINEEX ) -{ - POINT xy = { 0,0 }; - int iTop, iLeft, iBottom, iRight; - int iSlot = hb_parni( 5 ) - 1; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y - 1; - iLeft = xy.x - 1; - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); - iBottom = xy.y; - iRight = xy.x; - - if ( _s->hUserPens[ iSlot ] ) - { - SelectObject( _s->hdc, _s->hUserPens[ iSlot ] ); - } - else - { - SelectObject( _s->hdc, _s->penBlack ); - } - - hb_wvt_DrawOutline( _s->hdc, iTop, iLeft, iBottom, iRight ); - if ( _s->bGui ) - { - hb_wvt_DrawOutline( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_LoadPicture( nSlot, cFilePic ) -// -HB_FUNC( WVT_LOADPICTURE ) -{ - IPicture * iPicture = hb_wvt_gtLoadPicture( hb_parcx( 2 ) ); - BOOL bResult = FALSE; - int iSlot = hb_parni( 1 ) - 1 ; - - if ( iPicture ) - { - if ( _s->iPicture[ iSlot ] ) - { - hb_wvt_gtDestroyPicture( _s->iPicture[ iSlot ] ); - } - - _s->iPicture[ iSlot ] = iPicture; - bResult = TRUE; - } - hb_retl( bResult ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_LOADPICTUREFROMRESOURCE ) -{ - IPicture * iPicture = hb_wvt_gtLoadPictureFromResource( hb_parcx( 2 ),hb_parcx( 3 ) ); - BOOL bResult = FALSE; - int iSlot = hb_parni( 1 ) - 1 ; - - if ( iPicture ) - { - if ( _s->iPicture[ iSlot ] ) - { - hb_wvt_gtDestroyPicture( _s->iPicture[ iSlot ] ); - } - - _s->iPicture[ iSlot ] = iPicture; - bResult = TRUE; - } - hb_retl( bResult ); -} - -//-------------------------------------------------------------------// -// -// Wvt_LoadFont( nSlotFont, cFontFace, nHeight, nWidth, nWeight, lItalic, lUnderline, lStrikeout, -// nCharSet, nQuality, nEscapement ) -// -HB_FUNC( WVT_LOADFONT ) -{ - LOGFONT logfont;// = { 0 }; - int iSlot = hb_parni( 1 ) - 1; - HFONT hFont; - - logfont.lfEscapement = ( ISNIL( 11 ) ? 0 : ( hb_parni( 11 ) * 10 ) ); - logfont.lfOrientation = 0; - logfont.lfWeight = ( ISNIL( 5 ) ? 0 : hb_parni( 5 ) ); - logfont.lfItalic = ( ISNIL( 6 ) ? 0 : hb_parl( 6 ) ); - logfont.lfUnderline = ( ISNIL( 7 ) ? 0 : hb_parl( 7 ) ); - logfont.lfStrikeOut = ( ISNIL( 8 ) ? 0 : hb_parl( 8 ) ); - logfont.lfCharSet = ( ISNIL( 9 ) ? _s->CodePage : hb_parni( 9 ) ); - logfont.lfOutPrecision = 0; - logfont.lfClipPrecision = 0; - logfont.lfQuality = ( ISNIL( 10 ) ? DEFAULT_QUALITY : hb_parni( 10 ) ); - logfont.lfPitchAndFamily = FF_DONTCARE; - logfont.lfHeight = ( ISNIL( 3 ) ? _s->fontHeight : hb_parni( 3 ) ); - logfont.lfWidth = ( ISNIL( 4 ) ? ( _s->fontWidth < 0 ? -_s->fontWidth : _s->fontWidth ) : hb_parni( 4 ) ); - - strcpy( logfont.lfFaceName, ( ISNIL( 2 ) ? _s->fontFace : hb_parcx( 2 ) ) ); - - hFont = CreateFontIndirect( &logfont ); - if ( hFont ) - { - if ( _s->hUserFonts[ iSlot ] ) - { - DeleteObject( _s->hUserFonts[ iSlot ] ); - } - _s->hUserFonts[ iSlot ] = hFont; - } -} - -//-------------------------------------------------------------------// -// -// Wvt_LoadPen( nSlot, nStyle, nWidth, nRGBColor ) -// -HB_FUNC( WVT_LOADPEN ) -{ - int iPenWidth, iPenStyle; - COLORREF crColor; - HPEN hPen; - int iSlot = hb_parni( 1 ) - 1; - - iPenStyle = ISNIL( 2 ) ? 0 : hb_parni( 2 ) ; - iPenWidth = ISNIL( 3 ) ? 0 : hb_parni( 3 ); - crColor = ISNIL( 4 ) ? RGB( 0,0,0 ) : ( COLORREF ) hb_parnl( 4 ); - - hPen = CreatePen( iPenStyle, iPenWidth, crColor ); - - if ( hPen ) - { - if ( _s->hUserPens[ iSlot ] ) - { - DeleteObject( _s->hUserPens[ iSlot ] ); - } - _s->hUserPens[ iSlot ] = hPen; - - hb_retl( TRUE ); - } - else - { - hb_retl( FALSE ); - } -} - -//-------------------------------------------------------------------// -// -// aScr := Wvt_SaveScreen( nTop, nLeft, nBottom, nRight ) -// -HB_FUNC( WVT_SAVESCREEN ) -{ - HBITMAP hBmp, oldBmp; - POINT xy = { 0,0 }; - int iTop, iLeft, iBottom, iRight, iWidth, iHeight; - PHB_ITEM info = hb_itemArrayNew( 3 ); - PHB_ITEM temp = hb_itemNew( NULL ); - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y; - iLeft = xy.x; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); - iBottom = xy.y-1; - iRight = xy.x-1; - - iWidth = iRight - iLeft + 1; - iHeight = iBottom - iTop + 1; - - hBmp = CreateCompatibleBitmap( _s->hdc, iWidth, iHeight ) ; - - oldBmp = (HBITMAP) SelectObject( _s->hCompDC, hBmp ); - BitBlt( _s->hCompDC, 0, 0, iWidth, iHeight, _s->hdc, iLeft, iTop, SRCCOPY ); - SelectObject( _s->hCompDC, oldBmp ); - - hb_arraySet( info, 1, hb_itemPutNI( temp, iWidth ) ); - hb_arraySet( info, 2, hb_itemPutNI( temp, iHeight ) ); - hb_arraySet( info, 3, hb_itemPutNL( temp, ( ULONG ) hBmp ) ); - hb_itemRelease( temp ); - - hb_itemReturn( info ); - hb_itemRelease( info ); -} - -//-------------------------------------------------------------------// -// -// Wvt_RestScreen( nTop, nLeft, nBottom, nRight, aScr, lDoNotDestroyBMP ) -// -HB_FUNC( WVT_RESTSCREEN ) -{ - POINT xy = { 0,0 }; - int iTop, iLeft, iBottom, iRight, iWidth, iHeight; - HBITMAP hBmp; - - BOOL bResult = FALSE; - BOOL bDoNotDestroyBMP = ISNIL( 6 ) ? FALSE : hb_parl( 6 ); - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y; - iLeft = xy.x; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); - iBottom = xy.y-1; - iRight = xy.x-1; - - iWidth = iRight - iLeft + 1 ; - iHeight = iBottom - iTop + 1 ; - - hBmp = (HBITMAP) SelectObject( _s->hCompDC, ( HBITMAP ) hb_parnl( 5,3 ) ); - if ( hBmp ) - { - if ( ( iWidth == hb_parni( 5,1 ) ) && ( iHeight == hb_parni( 5,2 ) ) ) - { - if ( BitBlt( _s->hdc, - iLeft, - iTop, - iWidth, - iHeight, - _s->hCompDC, - 0, - 0, - SRCCOPY ) ) - { - bResult = TRUE; - } - } - else - { - if ( StretchBlt( _s->hdc, - iLeft, - iTop, - iWidth, - iHeight, - _s->hCompDC, - 0, - 0, - hb_parni( 5,1 ), - hb_parni( 5,2 ), - SRCCOPY ) ) - { - bResult = TRUE; - } - } - } - - SelectObject( _s->hCompDC, hBmp ); - - if ( ! bDoNotDestroyBMP ) - { - DeleteObject( ( HBITMAP ) hb_parnl( 5,3 ) ); - } - - hb_retl( bResult ); -} - -//-------------------------------------------------------------------// -// -// Wvt_CreateFont( cFontFace, nHeight, nWidth, nWeight, lItalic, lUnderline, -// lStrikeout, nCharSet, nQuality, nEscapement ) -// -HB_FUNC( WVT_CREATEFONT ) -{ - LOGFONT logfont;// = { 0,0,0 }; - HFONT hFont; - - logfont.lfEscapement = ( ISNIL( 10 ) ? 0 : ( hb_parni( 10 ) * 10 ) ); - logfont.lfOrientation = 0; - logfont.lfWeight = ( ISNIL( 4 ) ? 0 : hb_parni( 4 ) ); - logfont.lfItalic = ( ISNIL( 5 ) ? 0 : hb_parl( 5 ) ); - logfont.lfUnderline = ( ISNIL( 6 ) ? 0 : hb_parl( 6 ) ); - logfont.lfStrikeOut = ( ISNIL( 7 ) ? 0 : hb_parl( 7 ) ); - logfont.lfCharSet = ( ISNIL( 8 ) ? _s->CodePage : hb_parni( 8 ) ); - logfont.lfOutPrecision = 0; - logfont.lfClipPrecision = 0; - logfont.lfQuality = ( ISNIL( 9 ) ? DEFAULT_QUALITY : hb_parni( 9 ) ); - logfont.lfPitchAndFamily = FF_DONTCARE; - logfont.lfHeight = ( ISNIL( 2 ) ? _s->fontHeight : hb_parni( 2 ) ); - logfont.lfWidth = ( ISNIL( 3 ) ? ( _s->fontWidth < 0 ? -_s->fontWidth : _s->fontWidth ) : hb_parni( 3 ) ); - - strcpy( logfont.lfFaceName, ( ISNIL( 1 ) ? _s->fontFace : hb_parcx( 1 ) ) ); - - hFont = CreateFontIndirect( &logfont ); - if ( hFont ) - { - hb_retnl( ( ULONG ) hFont ); - } - else - { - hb_retnl( 0 ); - } -} - -//-------------------------------------------------------------------// -// -// WVT_DRAWLABELOBJ( nTop, nLeft, nBottom, nRight, cLabel, nAlignHorz, nAlignVert, nTextColor, nBkColor, hFont ) -// -HB_FUNC( WVT_DRAWLABELOBJ ) -{ - POINT xy = { 0,0 }; - RECT rect = { 0,0,0,0 }; - int iTop, iLeft, iBottom, iRight, x, y; - int iAlignHorz, iAlignVert, iAlignH, iAlignV; - UINT uiOptions; - SIZE sz = { 0,0 }; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y; - iLeft = xy.x; - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); - iBottom = xy.y - 1; - iRight = xy.x - 1; - - iAlignHorz = ( ISNIL( 6 ) ? 0 : hb_parni( 6 ) ); - iAlignVert = ( ISNIL( 7 ) ? 0 : hb_parni( 7 ) ); - - SetTextColor( _s->hdc, ISNIL( 8 ) ? _s->foreground : ( COLORREF ) hb_parnl( 8 ) ); - SetBkColor( _s->hdc, ISNIL( 9 ) ? _s->background : ( COLORREF ) hb_parnl( 9 ) ); - ( HFONT ) SelectObject( _s->hdc, ( HFONT ) hb_parnl( 10 ) ); - - GetTextExtentPoint32( _s->hdc, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), &sz ); - - x = iLeft; - y = iTop; - - switch ( iAlignHorz ) - { - case 0: - { - iAlignH = TA_LEFT; - } - break; - case 1: - { - iAlignH = TA_RIGHT; - x = iRight; - } - break; - case 2: - { - iAlignH = TA_CENTER; - x = iLeft + ( ( iRight - iLeft + 1 ) / 2 ); - } - break; - } - - iAlignV = TA_TOP; - - switch ( iAlignVert ) - { - case 1: - { - y = iBottom - sz.cy; - } - break; - case 2: - { - y = iTop + ( ( iBottom - iTop + 1 - sz.cy ) / 2 ); - } - break; - } - - SetTextAlign( _s->hdc, iAlignH | iAlignV ); - - rect.top = iTop; - rect.left = iLeft; - rect.bottom = iBottom; - rect.right = iRight; - - uiOptions = ETO_CLIPPED | ETO_OPAQUE ; - - // Ground is Ready, Draw Text - // - ExtTextOut( _s->hdc, x, y, uiOptions, &rect, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), NULL ); - if ( _s->bGui ) - { - SetTextColor( _s->hGuiDC, ISNIL( 8 ) ? _s->foreground : ( COLORREF ) hb_parnl( 8 ) ); - SetBkColor( _s->hGuiDC, ISNIL( 9 ) ? _s->background : ( COLORREF ) hb_parnl( 9 ) ); - ( HFONT ) SelectObject( _s->hGuiDC, ( HFONT ) hb_parnl( 10 ) ); - SetTextAlign( _s->hGuiDC, iAlignH | iAlignV ); - - ExtTextOut( _s->hGuiDC, x, y, uiOptions, &rect, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), NULL ); - } - - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// -// nState 0 Flat, 1 Raised, 2 Recessed -// Wvt_DrawToolButtonState( nTop, nLeft, nBottom, nRight, aPxlOff, nState ) -// -HB_FUNC( WVT_DRAWTOOLBUTTONSTATE ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - switch ( hb_parni( 6 ) ) - { - case 0: // Flat - { - hb_wvt_DrawToolButtonFlat( _s->hdc, iTop, iLeft, iBottom, iRight ); - if ( _s->bGui ) - { - hb_wvt_DrawToolButtonFlat( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); - } - } - break; - - case 1: // Raised - { - hb_wvt_DrawToolButtonUp( _s->hdc, iTop, iLeft, iBottom, iRight ); - if ( _s->bGui ) - { - hb_wvt_DrawToolButtonUp( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); - } - } - break; - - case 2: // Recessed - { - hb_wvt_DrawToolButtonDown( _s->hdc, iTop, iLeft, iBottom, iRight ); - if ( _s->bGui ) - { - hb_wvt_DrawToolButtonDown( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); - } - } - break; - } - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawScrollButton( nTop, nLeft, nBottom, nRight, aOffPixels, nTLBR, lDepressed ) -// -HB_FUNC( WVT_DRAWSCROLLBUTTON ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - POINT * Point; - POINT xy = { 0,0 }; - int iHeight, iOff; - BOOL bDepressed = ISNIL( 7 ) ? FALSE : hb_parl( 7 ) ; - - Point = ( POINT * ) hb_xgrab( 3 * sizeof( POINT ) ); - iOff = 6; - - iHeight = iBottom - iTop + 1; - - if ( bDepressed ) - { - hb_wvt_DrawBoxRecessed( _s->hdc, iTop+1, iLeft+1, iBottom-2, iRight-2 ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxRecessed( _s->hGuiDC, iTop+1, iLeft+1, iBottom-2, iRight-2 ); - } - } - else - { - hb_wvt_DrawBoxRaised( _s->hdc, iTop+1, iLeft+1, iBottom-2, iRight-2 ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxRaised( _s->hGuiDC, iTop+1, iLeft+1, iBottom-2, iRight-2 ); - } - } - - switch ( hb_parni( 6 ) ) - { - case 1: // Top - { - xy.y = iTop + iOff - 1; - xy.x = iLeft + ( ( iRight - iLeft + 1 ) / 2 ); - Point[ 0 ] = xy ; - xy.y = iBottom - iOff - 1; - xy.x = iLeft + iOff - 1; - Point[ 1 ] = xy; - xy.x = iRight - iOff + 1; - Point[ 2 ] = xy; - } - break; - - case 2: // Left - { - xy.y = iTop + ( ( iBottom - iTop + 1 ) / 2 ); - xy.x = iLeft + iOff; - Point[ 0 ] = xy ; - xy.x = iRight - iOff - 1; - xy.y = iTop + iOff - 1; - Point[ 1 ] = xy; - xy.y = iBottom - iOff + 1; - Point[ 2 ] = xy; - } - break; - - case 3: // Bottom - { - xy.x = iLeft + ( ( iRight - iLeft + 1 ) / 2 ); - xy.y = iBottom - iOff; - Point[ 0 ] = xy ; - xy.x = iLeft + iOff - 1; - xy.y = iBottom - iHeight + iOff + 1; - Point[ 1 ] = xy; - xy.x = iRight - iOff + 1; - Point[ 2 ] = xy; - } - break; - - case 4: // Right - { - xy.x = iRight - iOff - 1; - xy.y = iTop + ( ( iBottom - iTop + 1 ) / 2 ); - Point[ 0 ] = xy ; - xy.x = iLeft + iOff + 1; - xy.y = iTop + iOff - 1; - Point[ 1 ] = xy; - xy.y = iBottom - iOff + 1; - Point[ 2 ] = xy; - } - break; - } - - SelectObject( _s->hdc, _s->solidBrush ); - Polygon( _s->hdc, Point, 3 ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, _s->solidBrush ); - Polygon( _s->hGuiDC, Point, 3 ); - } - - hb_xfree( Point ); -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawScrollbarThumbVert( nTop, nLeft, nBottom, nRight, aPxlOff, nThumbPos ) -// -HB_FUNC( WVT_DRAWSCROLLTHUMBVERT ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - int iTabTop, iTabLft, iTabBtm, iTabRgt; - - // Background - // - SetBkMode( _s->hdc, OPAQUE ); - SetBkColor( _s->hdc, RGB( 230,230,230 ) ); - SelectObject( _s->hdc, _s->diagonalBrush ); - SelectObject( _s->hdc, _s->penNull ); - Rectangle( _s->hdc, iLeft, iTop, iRight+1, iBottom+1 ); - if ( _s->bGui ) - { - SetBkMode( _s->hGuiDC, OPAQUE ); - SetBkColor( _s->hGuiDC, RGB( 230,230,230 ) ); - SelectObject( _s->hGuiDC, _s->diagonalBrush ); - SelectObject( _s->hGuiDC, _s->penNull ); - Rectangle( _s->hGuiDC, iLeft, iTop, iRight+1, iBottom+1 ); - } - - // Thumb - // - iTabTop = _s->PTEXTSIZE.y * hb_parni( 6 ); - iTabLft = iLeft; - iTabBtm = iTabTop + _s->PTEXTSIZE.y - 1; - iTabRgt = iRight; - - SelectObject( _s->hdc, _s->wvtWhiteBrush ); - SelectObject( _s->hdc, _s->penGray ); - Rectangle( _s->hdc, iTabLft, iTabTop, iTabRgt+1, iTabBtm ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, _s->wvtWhiteBrush ); - SelectObject( _s->hGuiDC, _s->penGray ); - Rectangle( _s->hGuiDC, iTabLft, iTabTop, iTabRgt+1, iTabBtm ); - } - - hb_wvt_DrawBoxRaised( _s->hdc, iTabTop+1, iTabLft+1, iTabBtm-2, iTabRgt-2 ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxRaised( _s->hGuiDC, iTabTop+1, iTabLft+1, iTabBtm-2, iTabRgt-2 ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawScrollbarThumbHorz( nTop, nLeft, nBottom, nRight, aPxlOff, nThumbPos ) -// -HB_FUNC( WVT_DRAWSCROLLTHUMBHORZ ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - int iThumbLeft, iThumbRight;; - - iThumbLeft = _s->PTEXTSIZE.x * hb_parni( 6 ); - iThumbRight = iThumbLeft + ( _s->PTEXTSIZE.x * 2 ) - 1; - - // Background - // - SetBkMode( _s->hdc, OPAQUE ); - SetBkColor( _s->hdc, RGB( 230,230,230 ) ); - SelectObject( _s->hdc, _s->diagonalBrush ); - SelectObject( _s->hdc, _s->penNull ); - Rectangle( _s->hdc, iLeft, iTop, iRight+1, iBottom+1 ); - if ( _s->bGui ) - { - SetBkMode( _s->hGuiDC, OPAQUE ); - SetBkColor( _s->hGuiDC, RGB( 230,230,230 ) ); - SelectObject( _s->hGuiDC, _s->diagonalBrush ); - SelectObject( _s->hGuiDC, _s->penNull ); - Rectangle( _s->hGuiDC, iLeft, iTop, iRight+1, iBottom+1 ); - } - - // Thumb - // - SelectObject( _s->hdc, _s->wvtWhiteBrush ); - SelectObject( _s->hdc, _s->penGray ); - Rectangle( _s->hdc, iThumbLeft, iTop, iThumbRight, iBottom ); - if ( _s->bGui ) - { - SelectObject( _s->hGuiDC, _s->wvtWhiteBrush ); - SelectObject( _s->hGuiDC, _s->penGray ); - Rectangle( _s->hGuiDC, iThumbLeft, iTop, iThumbRight, iBottom ); - } - - hb_wvt_DrawBoxRaised( _s->hdc, iTop+1, iThumbLeft+1, iBottom-2, iThumbRight-2 ); - if ( _s->bGui ) - { - hb_wvt_DrawBoxRaised( _s->hGuiDC, iTop+1, iThumbLeft+1, iBottom-2, iThumbRight-2 ); - } -} - -//#if WINVER > 0x500 -//-------------------------------------------------------------------// -// -// Wvt_DrawShadedRect( nTop, nLeft, nBottom, nRight, aPxlOff, nHorVert, aRGBb, aRGBe ) -// -HB_FUNC( WVT_DRAWSHADEDRECT ) -{ - BOOL bGF = FALSE; - - if ( _s->hMSImg32 ) - { - TRIVERTEX vert[ 2 ] ; - GRADIENT_RECT gRect = { 0,0 }; - - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - int iMode = ISNIL( 6 ) ? GRADIENT_FILL_RECT_H : hb_parni( 6 ) ; - - vert[ 0 ].x = iLeft; - vert[ 0 ].y = iTop; - vert[ 0 ].Red = hb_parni( 7,1 ); - vert[ 0 ].Green = hb_parni( 7,2 ); - vert[ 0 ].Blue = hb_parni( 7,3 ); - vert[ 0 ].Alpha = hb_parni( 7,4 ); - - vert[ 1 ].x = iRight; - vert[ 1 ].y = iBottom; - vert[ 1 ].Red = hb_parni( 8,1 ); - vert[ 1 ].Green = hb_parni( 8,2 ); - vert[ 1 ].Blue = hb_parni( 8,3 ); - vert[ 1 ].Alpha = hb_parni( 8,4 ); - - gRect.UpperLeft = 0; - gRect.LowerRight= 1; - - bGF = ( BOOL ) _s->pfnGF( _s->hdc, vert, 2, &gRect, 1, iMode ); - if ( _s->bGui ) - { - bGF = ( BOOL ) _s->pfnGF( _s->hGuiDC, vert, 2, &gRect, 1, iMode ); - } - } - hb_retl( bGF ); -} -//#endif - -//-------------------------------------------------------------------// -// -// Wvt_DrawTextBox( nTop, nLeft, nBottom, nRight, aPxlOff, cText, ; -// nAlignHorz, nAlignVert, nTextColor, nBackColor, ; -// nBackMode, hFont ) -// -HB_FUNC( WVT_DRAWTEXTBOX ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - - int iAlignHorz = ( ISNIL( 7 ) ? 0 : hb_parni( 7 ) ); - int iAlignH ; - - RECT rc = { 0,0,0,0 }; - - switch ( iAlignHorz ) - { - case 0: - { - iAlignH = DT_LEFT; - } - break; - case 1: - { - iAlignH = DT_RIGHT; - } - break; - case 2: - { - iAlignH = DT_CENTER; - } - break; - } - - rc.top = iTop; - rc.left = iLeft; - rc.bottom = iBottom; - rc.right = iRight; - - SetTextAlign( _s->hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP ); - SetTextColor( _s->hdc, ISNIL( 9 ) ? _s->foreground : ( COLORREF ) hb_parnl( 9 ) ); - SetBkColor( _s->hdc, ISNIL( 10 ) ? _s->background : ( COLORREF ) hb_parnl( 10 ) ); - SetBkMode( _s->hdc, ISNIL( 11 ) ? OPAQUE : hb_parni( 11 ) ); - ( HFONT ) SelectObject( _s->hdc, ( HFONT ) hb_parnl( 12 ) ); - - DrawText( _s->hdc, hb_parcx( 6 ), strlen( hb_parcx( 6 ) ), &rc, iAlignH | DT_WORDBREAK | DT_TOP ); - if ( _s->bGui ) - { - SetTextAlign( _s->hGuiDC, TA_TOP | TA_LEFT | TA_NOUPDATECP ); - SetTextColor( _s->hGuiDC, ISNIL( 9 ) ? _s->foreground : ( COLORREF ) hb_parnl( 9 ) ); - SetBkColor( _s->hGuiDC, ISNIL( 10 ) ? _s->background : ( COLORREF ) hb_parnl( 10 ) ); - SetBkMode( _s->hGuiDC, ISNIL( 11 ) ? OPAQUE : hb_parni( 11 ) ); - ( HFONT ) SelectObject( _s->hGuiDC, ( HFONT ) hb_parnl( 12 ) ); - - DrawText( _s->hGuiDC, hb_parcx( 6 ), strlen( hb_parcx( 6 ) ), &rc, iAlignH | DT_WORDBREAK | DT_TOP ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_DrawProgressBar( nTop, nLeft, nBottom, nRight, aPxlOff, nPercent,; -// nBackColor, nBarColor, cImage, lVertical, nDirection ) -// -HB_FUNC( WVT_DRAWPROGRESSBAR ) -{ - int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); - int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); - int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); - int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); - int iPercent, iBarUpto, iDirection; - BOOL bVertical, bImage; - COLORREF crBarColor; - HBRUSH hBrush; - LOGBRUSH lb = { 0,0,0 }; - RECT rc = { 0,0,0,0 }; - - iPercent = hb_parni( 6 ); - bImage = ISNIL( 9 ) ? FALSE : TRUE ; - bVertical = ISNIL( 10 ) ? FALSE : hb_parl( 10 ) ; - iDirection = ISNIL( 11 ) ? 0 : hb_parni( 11 ); - - if ( bVertical ) - { - if ( iDirection == 0 ) - { - iBarUpto = iTop + ( ( iBottom - iTop ) * iPercent / 100 ); - rc.top = iTop; - rc.left = iLeft; - rc.bottom = iBarUpto; - rc.right = iRight; - } - else - { - iBarUpto = iBottom - ( ( iBottom - iTop ) * iPercent / 100 ); - rc.top = iBarUpto; - rc.left = iLeft; - rc.bottom = iBottom; - rc.right = iRight; - } - } - else - { - if ( iDirection == 0 ) - { - iBarUpto = iLeft + ( ( iRight - iLeft ) * iPercent / 100 ); - rc.top = iTop; - rc.left = iLeft; - rc.bottom = iBottom; - rc.right = iBarUpto; - } - else - { - iBarUpto = iRight - ( ( iRight - iLeft ) * iPercent / 100 ); - rc.top = iTop; - rc.left = iBarUpto; - rc.bottom = iBottom; - rc.right = iRight; - } - } - - if ( bImage ) - { - hb_wvt_DrawImage( _s->hdc, rc.left, rc.top, rc.right-rc.left+1, rc.bottom-rc.top+1, hb_parc( 9 ) ); - if ( _s->bGui ) - { - hb_wvt_DrawImage( _s->hGuiDC, rc.left, rc.top, rc.right-rc.left+1, rc.bottom-rc.top+1, hb_parc( 9 ) ); - } - } - else - { - crBarColor = ISNIL( 8 ) ? hb_wvt_gtGetColorData( 0 ) : ( COLORREF ) hb_parnl( 8 ); - - lb.lbStyle = BS_SOLID; - lb.lbColor = crBarColor; - lb.lbHatch = 0; - - hBrush = CreateBrushIndirect( &lb ); - - rc.bottom++; - rc.right++; - - FillRect( _s->hdc, &rc, hBrush ); - if ( _s->bGui ) - { - FillRect( _s->hGuiDC, &rc, hBrush ); - } - DeleteObject( hBrush ); - } -} - -//-------------------------------------------------------------------// - - +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2007 Pritpal Bedi + * Based on: + * + * Video subsystem for Win32 using GUI windows instead of Console + * Copyright 2003 Peter Rees + * Rees Software & Systems Ltd + * based on + * Bcc ConIO Video subsystem by + * Copyright 2002 Marek Paliwoda + * Copyright 2002 Przemyslaw Czerpak + * Video subsystem for Win32 compilers + * Copyright 1999-2000 Paul Tucker + * Copyright 2002 Przemysław Czerpak + * + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * + * Copyright 1999 David G. Holm + * hb_gt_Tone() + * + * See doc/license.txt for licensing terms. + * + * www - 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. + * + */ +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// GUI Drawing Functions +// Pritpal Bedi +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +#define HB_OS_WIN_32_USED + +//-------------------------------------------------------------------// + +#include "gtwvt.h" + +static GLOBAL_DATA *_s = NULL; + +static void hb_wvt_DrawBoxRaised( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); +static void hb_wvt_DrawBoxRecessed( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); +static void hb_wvt_DrawOutline( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); +static void hb_wvt_DrawBoxGet( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); +static void hb_wvt_DrawBoxGroup( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); +static void hb_wvt_DrawBoxGroupRaised( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); +static void hb_wvt_DrawToolButtonFlat( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); +static void hb_wvt_DrawToolButtonUp( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); +static void hb_wvt_DrawToolButtonDown( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ); + +//-------------------------------------------------------------------// + +void HB_EXPORT hb_wvt_wvtCore( void ) +{ + _s = hb_wvt_gtGetGlobalData(); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CORE ) +{ + hb_wvt_wvtCore(); +} + +//-------------------------------------------------------------------// + +HB_EXPORT BOOL hb_wvt_DrawImage( HDC hdc, int x1, int y1, int wd, int ht, char * image ) +{ + IStream *iStream; + IPicture *iPicture; + HGLOBAL hGlobal; + HANDLE hFile; + DWORD nFileSize; + DWORD nReadByte; + LONG lWidth,lHeight; + int x,y,xe,ye; + int c = x1 ; + int r = y1 ; + int dc = wd ; + int dr = ht ; + int tor = 0 ; + int toc = 0 ; + HRGN hrgn1; + POINT lpp = { 0,0 }; + BOOL bResult = FALSE; + + hFile = CreateFile( image, GENERIC_READ, 0, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL ); + if ( hFile != INVALID_HANDLE_VALUE ) + { + nFileSize = GetFileSize( hFile, NULL ); + + if ( nFileSize != INVALID_FILE_SIZE ) + { + hGlobal = GlobalAlloc( GPTR, nFileSize ); + + if ( hGlobal ) + { + if ( ReadFile( hFile, hGlobal, nFileSize, &nReadByte, NULL ) ) + { + CreateStreamOnHGlobal( hGlobal, TRUE, &iStream ); + OleLoadPicture( iStream, nFileSize, TRUE, (REFIID) &IID_IPicture, ( LPVOID* )&iPicture ); + + if ( iPicture ) + { + iPicture->lpVtbl->get_Width( iPicture,&lWidth ); + iPicture->lpVtbl->get_Height( iPicture,&lHeight ); + + if ( dc == 0 ) + { + dc = ( int ) ( ( float ) dr * lWidth / lHeight ); + } + if ( dr == 0 ) + { + dr = ( int ) ( ( float ) dc * lHeight / lWidth ); + } + if ( tor == 0 ) + { + tor = dr; + } + if ( toc == 0 ) + { + toc = dc; + } + x = c; + y = r; + xe = c + toc - 1; + ye = r + tor - 1; + + GetViewportOrgEx( hdc, &lpp ); + + hrgn1 = CreateRectRgn( c+lpp.x, r+lpp.y, xe+lpp.x, ye+lpp.y ); + SelectClipRgn( hdc, hrgn1 ); + + while ( x < xe ) + { + while ( y < ye ) + { + iPicture->lpVtbl->Render( iPicture, hdc, x, y, dc, dr, 0, + lHeight, lWidth, -lHeight, NULL ); + y += dr; + } + y = r; + x += dc; + } + + SelectClipRgn( hdc, NULL ); + DeleteObject( hrgn1 ); + + iPicture->lpVtbl->Release( iPicture ); + bResult = TRUE ; + } + } + GlobalFree( hGlobal ); + } + } + CloseHandle( hFile ); + } + return( bResult ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawBoxRaised( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + SelectObject( hdc, _s->penWhiteDim ); + MoveToEx( hdc, iLeft, iTop, NULL ); // Top Inner + LineTo( hdc, iRight, iTop ); + MoveToEx( hdc, iLeft, iTop, NULL ); // Left Inner + LineTo( hdc, iLeft, iBottom ); + + SelectObject( hdc, _s->penWhite ); + MoveToEx( hdc, iLeft-1, iTop-1, NULL ); // Top Outer + LineTo( hdc, iRight+1, iTop-1 ); + MoveToEx( hdc, iLeft-1, iTop-1, NULL ); // Left Outer + LineTo( hdc, iLeft-1, iBottom+1 ); + + SelectObject( hdc, _s->penDarkGray ); + MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom Inner + LineTo( hdc, iRight, iBottom ); + MoveToEx( hdc, iRight, iBottom, NULL ); // Right Inner + LineTo( hdc, iRight, iTop ); + + SelectObject( hdc, _s->penBlack ); + MoveToEx( hdc, iLeft-1, iBottom+1, NULL ); // Bottom Outer + LineTo( hdc, iRight+1+1, iBottom+1 ); + MoveToEx( hdc, iRight+1, iTop-1, NULL ); // Right Outer + LineTo( hdc, iRight+1, iBottom+1 ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawBoxRecessed( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + SelectObject( hdc, _s->penWhiteDim ); + MoveToEx( hdc, iRight, iTop, NULL ); // Right Inner + LineTo( hdc, iRight, iBottom ); + MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom Inner + LineTo( hdc, iRight, iBottom ); + + SelectObject( hdc, _s->penWhite ); + MoveToEx( hdc, iRight+1, iTop-1, NULL ); // Right Outer + LineTo( hdc, iRight + 1, iBottom + 1 ); + MoveToEx( hdc, iLeft - 1, iBottom + 1, NULL ); // Bottom Outer + LineTo( hdc, iRight + 2, iBottom + 1 ); + + SelectObject( hdc, _s->penBlack ); + MoveToEx( hdc, iLeft, iTop, NULL ); // Left Inner + LineTo( hdc, iLeft, iBottom ); + MoveToEx( hdc, iLeft, iTop, NULL ); // Top Inner + LineTo( hdc, iRight, iTop ); + + SelectObject( hdc, _s->penDarkGray ); + MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Left Outer + LineTo( hdc, iLeft - 1 , iBottom + 1 ); + MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Top Outer + LineTo( hdc, iRight + 1, iTop - 1 ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawOutline( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + MoveToEx( hdc, iLeft, iTop, NULL ); // Top + LineTo( hdc, iRight, iTop ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Left + LineTo( hdc, iLeft, iBottom ); + + MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom + LineTo( hdc, iRight, iBottom ); + + MoveToEx( hdc, iRight, iTop, NULL ); // Right + LineTo( hdc, iRight, iBottom + 1); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawBoxGet( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + SelectObject( hdc, _s->penBlack ); + MoveToEx( hdc, iLeft-1 , iTop-1, NULL ); // Top Inner + LineTo( hdc, iRight-1, iTop-1 ); + MoveToEx( hdc, iLeft-1 , iTop-1, NULL ); // Left Inner + LineTo( hdc, iLeft-1 , iBottom-1 ); + + SelectObject( hdc, _s->penDarkGray ); + MoveToEx( hdc, iLeft-2, iTop-2, NULL ); // Top Outer + LineTo( hdc, iRight , iTop-2 ); + MoveToEx( hdc, iLeft-2, iTop-2, NULL ); // Left Outer + LineTo( hdc, iLeft-2, iBottom ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawBoxGroup( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + SelectObject( hdc, _s->penDarkGray ); + + MoveToEx( hdc, iRight, iTop, NULL ); // Right Inner + LineTo( hdc, iRight, iBottom ); + + MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom Inner + LineTo( hdc, iRight, iBottom ); + + MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Left Outer + LineTo( hdc, iLeft - 1, iBottom + 1 ); + + MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Top Outer + LineTo( hdc, iRight + 1, iTop - 1 ); + + + SelectObject( hdc, _s->penWhite ); + + MoveToEx( hdc, iRight + 1, iTop, NULL ); // Right Outer + LineTo( hdc, iRight + 1, iBottom + 1 ); + + MoveToEx( hdc, iLeft -1, iBottom + 1, NULL ); // Bottom Outer + LineTo( hdc, iRight + 1 + 1, iBottom + 1); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Left Inner + LineTo( hdc, iLeft, iBottom ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Top Inner + LineTo( hdc, iRight, iTop ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawBoxGroupRaised( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + SelectObject( hdc, _s->penWhite ); + + MoveToEx( hdc, iRight, iTop, NULL ); // Right Inner + LineTo( hdc, iRight, iBottom ); + + MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom Inner + LineTo( hdc, iRight, iBottom ); + + MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Left Outer + LineTo( hdc, iLeft - 1, iBottom + 1 ); + + MoveToEx( hdc, iLeft - 1, iTop - 1, NULL ); // Top Outer + LineTo( hdc, iRight + 1, iTop - 1 ); + + SelectObject( hdc, _s->penDarkGray ); + + MoveToEx( hdc, iRight + 1, iTop, NULL ); // Right Outer + LineTo( hdc, iRight + 1, iBottom + 1 ); + + MoveToEx( hdc, iLeft -1, iBottom + 1, NULL ); // Bottom Outer + LineTo( hdc, iRight + 1 + 1, iBottom + 1); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Left Inner + LineTo( hdc, iLeft, iBottom ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Top Inner + LineTo( hdc, iRight, iTop ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawToolButtonFlat( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + SelectObject( hdc, _s->penGray ); + + MoveToEx( hdc, iRight, iTop, NULL ); // Right + LineTo( hdc, iRight, iBottom + 1); + + MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom + LineTo( hdc, iRight, iBottom ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Left + LineTo( hdc, iLeft, iBottom ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Top + LineTo( hdc, iRight, iTop ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawToolButtonUp( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + SelectObject( hdc, _s->penBlack ); + + MoveToEx( hdc, iRight, iTop, NULL ); // Right + LineTo( hdc, iRight, iBottom+1 ); + + MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom + LineTo( hdc, iRight, iBottom ); + + SelectObject( hdc, _s->penWhite ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Left + LineTo( hdc, iLeft, iBottom ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Top + LineTo( hdc, iRight, iTop ); +} + +//-------------------------------------------------------------------// + +static void hb_wvt_DrawToolButtonDown( HDC hdc, int iTop, int iLeft, int iBottom, int iRight ) +{ + SelectObject( hdc, _s->penWhite ); + + MoveToEx( hdc, iRight, iTop, NULL ); // Right + LineTo( hdc, iRight, iBottom+1 ); + + MoveToEx( hdc, iLeft, iBottom, NULL ); // Bottom + LineTo( hdc, iRight, iBottom ); + + SelectObject( hdc, _s->penBlack ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Left + LineTo( hdc, iLeft, iBottom ); + + MoveToEx( hdc, iLeft, iTop, NULL ); // Top + LineTo( hdc, iRight, iTop ); +} + +//-------------------------------------------------------------------// +// +// Wvt_SetPen( nPenStyle, nWidth, nColor ) +// +HB_FUNC( WVT_SETPEN ) +{ + int iPenWidth, iPenStyle; + COLORREF crColor; + HPEN hPen; + + if ( ISNIL( 1 ) ) + { + hb_retl( FALSE ); + } + + iPenStyle = hb_parni( 1 ) ; + iPenWidth = ISNIL( 2 ) ? 0 : hb_parni( 2 ); + crColor = ISNIL( 3 ) ? RGB( 0,0,0 ) : ( COLORREF ) hb_parnl( 3 ); + + hPen = CreatePen( iPenStyle, iPenWidth, crColor ); + + if ( hPen ) + { + if ( _s->currentPen ) + { + DeleteObject( _s->currentPen ); + } + _s->currentPen = hPen; + + hb_retl( TRUE ); + } + else + { + hb_retl( FALSE ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_SetBrush( nStyle, nColor, [ nHatch ] ) +// +HB_FUNC( WVT_SETBRUSH ) +{ + HBRUSH hBrush; + LOGBRUSH lb = { 0,0,0 }; + + if ( ISNIL( 1 ) ) + { + hb_retl( FALSE ); + } + + lb.lbStyle = hb_parnl( 1 ); + lb.lbColor = ISNIL( 2 ) ? RGB( 0,0,0 ) : ( COLORREF ) hb_parnl( 2 ) ; + lb.lbHatch = ISNIL( 3 ) ? 0 : hb_parnl( 3 ); + + hBrush = CreateBrushIndirect( &lb ); + + if ( hBrush ) + { + if ( _s->currentBrush ) + { + DeleteObject( _s->currentBrush ); + } + _s->currentBrush = hBrush; + + hb_retl( TRUE ); + } + else + { + hb_retl( FALSE ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawBoxGet( nRow, nCol, nWidth ) +// +HB_FUNC( WVT_DRAWBOXGET ) +{ + POINT xy = { 0,0 }; + POINT yz = { 0,0 }; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + yz = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ) + hb_parni( 3 ), hb_parni( 1 ) + 1 ); + + hb_wvt_DrawBoxGet( _s->hdc, xy.y, xy.x, yz.y, yz.x ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxGet( _s->hGuiDC, xy.y, xy.x, yz.y, yz.x ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawBoxRaised( nTop, nLeft, nBottom, nRight, aPxlOff ) +// +HB_FUNC( WVT_DRAWBOXRAISED ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + hb_wvt_DrawBoxRaised( _s->hdc, iTop-1, iLeft-1, iBottom+1, iRight+1 ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxRaised( _s->hGuiDC, iTop-1, iLeft-1, iBottom+1, iRight+1 ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawBoxRecessed( nTop, nLeft, nBottom, nRight, aPxlOff ) +// +HB_FUNC( WVT_DRAWBOXRECESSED ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + hb_wvt_DrawBoxRecessed( _s->hdc, iTop-1, iLeft-1, iBottom+1, iRight+1 ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxRecessed( _s->hGuiDC, iTop-1, iLeft-1, iBottom+1, iRight+1 ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawBoxGroup( nTop, nLeft, nBottom, nRight, aPxlOff ) +// +HB_FUNC( WVT_DRAWBOXGROUP ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + hb_wvt_DrawBoxGroup( _s->hdc, iTop, iLeft, iBottom, iRight ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxGroup( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawBoxRaised( nTop, nLeft, nBottom, nRight, aPxlOff ) +// +HB_FUNC( WVT_DRAWBOXGROUPRAISED ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + hb_wvt_DrawBoxGroupRaised( _s->hdc, iTop, iLeft, iBottom, iRight ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxGroupRaised( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawImage( nTop, nLeft, nBottom, nRight, cImage/nPictureSlot, aOffSet ) +// +HB_FUNC( WVT_DRAWIMAGE ) +{ + POINT xy = { 0,0 }; + int iLeft, iTop, iRight, iBottom; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y + hb_parni( 6,1 ); + iLeft = xy.x + hb_parni( 6,2 ) ; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); + iBottom = xy.y - 1 + hb_parni( 6,3 ); + iRight = xy.x - 1 + hb_parni( 6,4 ); + + if ( ISNUM( 5 ) ) + { + hb_wvt_gtRenderPicture( iLeft, iTop, ( iRight - iLeft ) + 1, ( iBottom - iTop ) + 1, _s->iPicture[ hb_parni( 5 )-1 ] ); + } + else + { + hb_wvt_DrawImage( _s->hdc, iLeft, iTop, ( iRight - iLeft ) + 1, ( iBottom - iTop ) + 1, hb_parcx( 5 ) ) ; + if ( _s->bGui ) + { + hb_wvt_DrawImage( _s->hGuiDC, iLeft, iTop, ( iRight - iLeft ) + 1, ( iBottom - iTop ) + 1, hb_parcx( 5 ) ) ; + } + } + + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// +// +// WVT_DRAWLABEL( nRow, nCol, cLabel, nAlign, nEscapement, nTextColor, nBkColor, +// cFontFace, , , , , ) +// +HB_FUNC( WVT_DRAWLABEL ) +{ + POINT xy = { 0,0 }; + HFONT hFont, hOldFont, hOldFontGui; + LOGFONT logfont;// = { 0 }; + + logfont.lfEscapement = ( ISNIL( 5 ) ? 0 : ( hb_parni( 5 ) * 10 ) ); + logfont.lfOrientation = 0; + logfont.lfWeight = ( ISNIL( 11 ) ? 0 : hb_parni( 11 ) ); + logfont.lfItalic = ( ISNIL( 14 ) ? 0 : hb_parl( 14 ) ); + logfont.lfUnderline = ( ISNIL( 15 ) ? 0 : hb_parl( 15 ) ); + logfont.lfStrikeOut = ( ISNIL( 16 ) ? 0 : hb_parl( 16 ) ); + logfont.lfCharSet = ( ISNIL( 13 ) ? _s->CodePage : hb_parni( 13 ) ); + logfont.lfOutPrecision = 0; + logfont.lfClipPrecision = 0; + logfont.lfQuality = ( ISNIL( 12 ) ? DEFAULT_QUALITY : hb_parni( 12 ) ); + logfont.lfPitchAndFamily = FF_DONTCARE; + logfont.lfHeight = ( ISNIL( 9 ) ? _s->fontHeight : hb_parni( 9 ) ); + logfont.lfWidth = ( ISNIL( 10 ) ? (_s->fontWidth < 0 ? -_s->fontWidth : _s->fontWidth ) : hb_parni( 10 ) ); + + strcpy( logfont.lfFaceName, ( ISNIL( 8 ) ? _s->fontFace : hb_parcx( 8 ) ) ); + + hFont = CreateFontIndirect( &logfont ); + if ( hFont ) + { + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + + SetBkColor( _s->hdc, ISNIL( 7 ) ? _s->background : ( COLORREF ) hb_parnl( 7 ) ); + SetTextColor( _s->hdc, ISNIL( 6 ) ? _s->foreground : ( COLORREF ) hb_parnl( 6 ) ); + SetTextAlign( _s->hdc, ( ISNIL( 4 ) ? TA_LEFT : hb_parni( 4 ) ) ); + hOldFont = SelectObject( _s->hdc, hFont ); + + ExtTextOut( _s->hdc, xy.x, xy.y, 0, NULL, hb_parcx( 3 ), strlen( hb_parcx( 3 ) ), NULL ); + + SelectObject( _s->hdc, hOldFont ); + + if ( _s->bGui ) + { + SetBkColor( _s->hGuiDC, ISNIL( 7 ) ? _s->background : ( COLORREF ) hb_parnl( 7 ) ); + SetTextColor( _s->hGuiDC, ISNIL( 6 ) ? _s->foreground : ( COLORREF ) hb_parnl( 6 ) ); + SetTextAlign( _s->hGuiDC, ( ISNIL( 4 ) ? TA_LEFT : hb_parni( 4 ) ) ); + hOldFontGui = SelectObject( _s->hGuiDC, hFont ); + + ExtTextOut( _s->hGuiDC, xy.x, xy.y, 0, NULL, hb_parcx( 3 ), strlen( hb_parcx( 3 ) ), NULL ); + + SelectObject( _s->hGuiDC, hOldFontGui ); + } + + DeleteObject( hFont ); + hb_retl( TRUE ); + } + + hb_retl( FALSE ); +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawOutline( nTop, nLeft, nBottom, nRight, nThick, nShape, nRGBColor ) +// +HB_FUNC( WVT_DRAWOUTLINE ) +{ + HPEN hPen, hOldPen, hOldPenGUI; + POINT xy = { 0,0 }; + int iTop, iLeft, iBottom, iRight; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y - 1; + iLeft = xy.x - 1; + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); + iBottom = xy.y; + iRight = xy.x; + + if ( ISNUM( 5 ) ) + { + hPen = CreatePen( hb_parni( 5 ), 0, ( ISNIL( 7 ) ? 0 : ( COLORREF ) hb_parnl( 7 ) ) ); + if ( hPen ) + { + hOldPen = (HPEN) SelectObject( _s->hdc, hPen ); + } + } + else + { + hPen = 0; + SelectObject( _s->hdc, _s->penBlack ); + } + + hb_wvt_DrawOutline( _s->hdc, iTop, iLeft, iBottom, iRight ); + if ( _s->bGui ) + { + if ( hPen ) + { + hOldPenGUI = (HPEN) SelectObject( _s->hGuiDC, hPen ); + } + else + { + hOldPenGUI = (HPEN) SelectObject( _s->hGuiDC, _s->penBlack ); + hb_wvt_DrawOutline( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); + } + } + + if ( hPen ) + { + SelectObject( _s->hdc, hOldPen ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hOldPenGUI ); + } + DeleteObject( hPen ); + } +} + +//-------------------------------------------------------------------// +// 1 2 3 4 5 6 7 8 9 10 11 +// Wvt_DrawLine( nTop, nLeft, nBottom, nRight, nOrient, nFormat, nAlign, nStyle, nThick, nColor, aPxlOff ) +// +HB_FUNC( WVT_DRAWLINE ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 11,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 11,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 11,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 11,4 ); + + int iOrient, iFormat, iAlign, iStyle, iThick; + int x, y, iOffset; + COLORREF cr; + HPEN hPen, hOldPen, hOldPenGUI; + + // Resolve Parameters + iOrient = ISNIL( 5 ) ? 0 : hb_parni( 5 ); + iFormat = ISNIL( 6 ) ? 0 : hb_parni( 6 ); + iAlign = ISNIL( 7 ) ? 0 : hb_parni( 7 ); + iStyle = ISNIL( 8 ) ? 0 : hb_parni( 8 ); + iThick = ISNIL( 9 ) ? 0 : hb_parni( 9 ); + cr = ISNIL(10 ) ? 0 : ( COLORREF ) hb_parnl( 10 ); + + x = iLeft ; + y = iTop ; + + switch ( iAlign ) + { + case 0: // Center + { + if ( iOrient == 0 ) // Horizontal + { + iOffset = ( ( iBottom - iTop ) / 2 ) ; + y = iTop + iOffset ; + } + else + { + iOffset = ( ( iRight - iLeft ) / 2 ) ; + x = iLeft + iOffset ; + } + } + break; + + case 1: // Top + break; + + case 2: // bottom + { + if ( iFormat == 0 || iFormat == 1 ) // Raised/Recessd + { + y = iBottom - 1; + } + else + { + y = iBottom; + } + } + break; + + case 3: // Left + break; + + case 4: // Right + { + if ( iFormat == 0 || iFormat == 1 ) // Raised/Recessd + { + x = iRight - 1; + } + else + { + x = iRight; + } + } + break; + } + + hPen = CreatePen( iStyle, iThick, cr ); + hOldPen = (HPEN) SelectObject( _s->hdc, hPen ); + if ( _s->bGui ) + { + hOldPenGUI = (HPEN) SelectObject( _s->hGuiDC, hPen ); + } + + switch ( iFormat ) + { + case 0: // Raised + { + if ( iOrient == 0 ) // Horizontal + { + SelectObject( _s->hdc, _s->penWhite ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, iRight, y ); + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y+1, NULL ); + LineTo( _s->hdc, iRight, y+1 ); + + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, _s->penWhite ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, iRight, y ); + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y+1, NULL ); + LineTo( _s->hGuiDC, iRight, y+1 ); + } + } + else // Vertical + { + SelectObject( _s->hdc, _s->penWhite ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, x, iBottom ); + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x+1, y, NULL ); + LineTo( _s->hdc, x+1, iBottom ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, _s->penWhite ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, x, iBottom ); + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x+1, y, NULL ); + LineTo( _s->hGuiDC, x+1, iBottom ); + } + } + } + break; + + case 1: // Recessed + { + if ( iOrient == 0 ) // Horizontal + { + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, iRight, y ); + SelectObject( _s->hdc, _s->penWhite ); + MoveToEx( _s->hdc, x, y+1, NULL ); + LineTo( _s->hdc, iRight, y+1 ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, iRight, y ); + SelectObject( _s->hGuiDC, _s->penWhite ); + MoveToEx( _s->hGuiDC, x, y+1, NULL ); + LineTo( _s->hGuiDC, iRight, y+1 ); + } + } + else // Vertical + { + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, x, iBottom ); + SelectObject( _s->hdc, _s->penWhite ); + MoveToEx( _s->hdc, x+1, y, NULL ); + LineTo( _s->hdc, x+1, iBottom ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, x, iBottom ); + SelectObject( _s->hGuiDC, _s->penWhite ); + MoveToEx( _s->hGuiDC, x+1, y, NULL ); + LineTo( _s->hGuiDC, x+1, iBottom ); + } + } + } + break; + + case 2: // Plain + { + if ( iOrient == 0 ) // Horizontal + { + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, iRight, y ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, iRight, y ); + } + } + else // Vertical + { + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, x, iBottom ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, x, iBottom ); + } + } + } + break; + } + + SelectObject( _s->hdc, hOldPen ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hOldPenGUI ); + } + DeleteObject( hPen ); + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// +// +// Inside the area requested! +// Wvt_DrawEllipse( nTop, nLeft, nBottom, nRight, aPxlOff ) +// +HB_FUNC( WVT_DRAWELLIPSE ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + SelectObject( _s->hdc, _s->currentBrush ); + SelectObject( _s->hdc, _s->currentPen ); + + hb_retl( Ellipse( _s->hdc, iLeft, iTop, iRight, iBottom ) ); + if ( _s->bGui ) + { + hb_retl( Ellipse( _s->hGuiDC, iLeft, iTop, iRight, iBottom ) ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawRectangle( nTop, nLeft, nBottom, nRight, aPxlOff ) +// +HB_FUNC( WVT_DRAWRECTANGLE ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + SelectObject( _s->hdc, _s->currentBrush ); + SelectObject( _s->hdc, _s->currentPen ); + + hb_retl( Rectangle( _s->hdc, iLeft, iTop, iRight, iBottom ) ); + if ( _s->bGui ) + { + hb_retl( Rectangle( _s->hGuiDC, iLeft, iTop, iRight, iBottom ) ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawRoundRect( nTop, nLeft, nBottom, nRight, aPxlOff, nRoundHeight, nRoundWidth ) +// +HB_FUNC( WVT_DRAWROUNDRECT ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + int iHt, iWd; + + iHt = ISNIL( 6 ) ? 0 : hb_parni( 6 ); + iWd = ISNIL( 7 ) ? 0 : hb_parni( 7 ); + + SelectObject( _s->hdc, _s->currentBrush ); + SelectObject( _s->hdc, _s->currentPen ); + + hb_retl( RoundRect( _s->hdc, iLeft, iTop, iRight, iBottom, iWd, iHt ) ); + if ( _s->bGui ) + { + hb_retl( RoundRect( _s->hGuiDC, iLeft, iTop, iRight, iBottom, iWd, iHt ) ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawFocusRect( nTop, nLeft, nBottom, nRight, aPxlOff ) +// +HB_FUNC( WVT_DRAWFOCUSRECT ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + RECT rc = { 0,0,0,0 }; + + rc.left = iLeft; + rc.top = iTop; + rc.right = iRight; + rc.bottom = iBottom; + + hb_retl( DrawFocusRect( _s->hdc, &rc ) ); + if ( _s->bGui ) + { + hb_retl( DrawFocusRect( _s->hGuiDC, &rc ) ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawColorRect( nTop, nLeft, nBottom, nRight, aPxlOff, nRGB ) +// +HB_FUNC( WVT_DRAWCOLORRECT ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + RECT rc = { 0,0,0,0 }; + HBRUSH hBrush; + + hBrush = CreateSolidBrush( ( COLORREF ) hb_parnl( 6 ) ); + + if ( hBrush ) + { + rc.left = iLeft; + rc.top = iTop; + rc.right = iRight; + rc.bottom = iBottom; + + hb_retl( FillRect( _s->hdc, &rc, hBrush ) ); + if ( _s->bGui ) + { + hb_retl( FillRect( _s->hGuiDC, &rc, hBrush ) ); + } + + DeleteObject( hBrush ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawGridHorz( nTop, nLeft, nRight, nRows ) +// +HB_FUNC( WVT_DRAWGRIDHORZ ) +{ + int iAtRow = hb_parni( 1 ); + int iRows = hb_parni( 4 ); + int i, y; + int iLeft, iRight; + + iLeft = ( hb_parni( 2 ) * _s->PTEXTSIZE.x ); + iRight = ( ( ( hb_parni( 3 ) + 1 ) * _s->PTEXTSIZE.x ) - 1 ); + + SelectObject( _s->hdc, _s->currentPen ); + + for ( i = 0; i < iRows; i++ ) + { + y = ( ( iAtRow ) * _s->PTEXTSIZE.y ); + + MoveToEx( _s->hdc, iLeft, y, NULL ); + LineTo( _s->hdc, iRight, y ); + + iAtRow++; + } + + if ( _s->bGui ) + { + iAtRow = hb_parni( 1 ); + + SelectObject( _s->hGuiDC, _s->currentPen ); + + for ( i = 0; i < iRows; i++ ) + { + y = ( ( iAtRow ) * _s->PTEXTSIZE.y ); + + MoveToEx( _s->hGuiDC, iLeft, y, NULL ); + LineTo( _s->hGuiDC, iRight, y ); + + iAtRow++; + } + } + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawGridVert( nTop, nBottom, aCols, nCols ) +// +HB_FUNC( WVT_DRAWGRIDVERT ) +{ + int iTop, iBottom, x, i, iCharHeight, iCharWidth; + int iTabs = hb_parni( 4 ); + + if ( ! iTabs ) + { + hb_retl( FALSE ); + } + + iCharWidth = _s->PTEXTSIZE.x; + iCharHeight = _s->PTEXTSIZE.y; + + iTop = ( hb_parni( 1 ) * iCharHeight ); + iBottom = ( ( hb_parni( 2 ) + 1 ) * iCharHeight ) - 1; + + SelectObject( _s->hdc, _s->currentPen ); + + for ( i = 1; i <= iTabs; i++ ) + { + x = ( hb_parni( 3,i ) * iCharWidth ); + + MoveToEx( _s->hdc, x, iTop, NULL ); + LineTo( _s->hdc, x, iBottom ); + } + + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, _s->currentPen ); + for ( i = 1; i <= iTabs; i++ ) + { + x = ( hb_parni( 3,i ) * iCharWidth ); + + MoveToEx( _s->hGuiDC, x, iTop, NULL ); + LineTo( _s->hGuiDC, x, iBottom ); + } + } + + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawButton( nTop, nLeft, nBottom, nRight, cText, cnImage, ; +// nFormat, nTextColor, nBkColor, nImageAt ) ; +// +HB_FUNC( WVT_DRAWBUTTON ) +{ + SIZE sz = { 0,0 }; + POINT xy = { 0,0 }; + RECT rc = { 0,0,0,0 }; + int iTop, iLeft, iBottom, iRight; + int iAlign; + int iTextHeight /*, iTextWidth */ ; + int iImageWidth, iImageHeight; + LOGBRUSH lb = { 0,0,0 }; + HBRUSH hBrush; + IPicture *iPicture; + + BOOL bText = ISCHAR( 5 ); + BOOL bImage = !( ISNIL( 6 ) ); + int iFormat = ISNIL( 7 ) ? 0 : hb_parni( 7 ); + COLORREF textColor = ISNIL( 8 ) ? hb_wvt_gtGetColorData( 0 ) : ( COLORREF ) hb_parnl( 8 ) ; + COLORREF bkColor = ISNIL( 9 ) ? hb_wvt_gtGetColorData( 7 ) : ( COLORREF ) hb_parnl( 9 ) ; + // int iImageAt = ISNIL( 10 ) ? 0 : hb_parni( 10 ); + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y; + iLeft = xy.x; + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); + iBottom = xy.y-1; + iRight = xy.x-1; + + lb.lbStyle = BS_SOLID; + lb.lbColor = bkColor; + lb.lbHatch = 0; + + hBrush = CreateBrushIndirect( &lb ); + + rc.left = iLeft ; + rc.top = iTop ; + rc.right = iRight + 1; + rc.bottom = iBottom + 1; + + FillRect( _s->hdc, &rc, hBrush ); + if ( _s->bGui ) + { + FillRect( _s->hGuiDC, &rc, hBrush ); + } + DeleteObject( hBrush ); + + switch ( iFormat ) + { + case 1: + hb_wvt_DrawBoxRecessed( _s->hdc, iTop+1, iLeft+1, iBottom-1, iRight-1 ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxRecessed( _s->hGuiDC, iTop+1, iLeft+1, iBottom-1, iRight-1 ); + } + break; + case 2: + break; + case 3: + hb_wvt_DrawOutline( _s->hdc, iTop, iLeft, iBottom, iRight ); + if ( _s->bGui ) + { + hb_wvt_DrawOutline( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); + } + break; + case 4: + break; + default: + hb_wvt_DrawBoxRaised( _s->hdc, iTop+1, iLeft+1, iBottom-1, iRight-1 ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxRaised( _s->hGuiDC, iTop+1, iLeft+1, iBottom-1, iRight-1 ); + } + break; + } + + if ( bText ) + { + ( HFONT ) SelectObject( _s->hdc, GetStockObject( DEFAULT_GUI_FONT ) ); + + GetTextExtentPoint32( _s->hdc, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), &sz ); + // iTextWidth = sz.cx; + iTextHeight = sz.cy; + + xy.x = iLeft + ( ( iRight - iLeft + 1 ) / 2 ) ; + + if ( bImage ) + { + xy.y = ( iBottom - 2 - iTextHeight ); + } + else + { + xy.y = iTop + ( ( iBottom - iTop + 1 - iTextHeight ) / 2 ) ; + } + + if ( iFormat == 1 ) + { + xy.x = xy.x + 2; + xy.y = xy.y + 2; + } + + iAlign = TA_CENTER + TA_TOP ; + + SetTextAlign( _s->hdc, iAlign ); + SetBkMode( _s->hdc, TRANSPARENT ); + SetTextColor( _s->hdc, textColor ); + + ExtTextOut( _s->hdc, xy.x, xy.y, 0, NULL, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), NULL ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, GetStockObject( DEFAULT_GUI_FONT ) ); + SetTextAlign( _s->hGuiDC, iAlign ); + SetBkMode( _s->hGuiDC, TRANSPARENT ); + SetTextColor( _s->hGuiDC, textColor ); + + ExtTextOut( _s->hGuiDC, xy.x, xy.y, 0, NULL, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), NULL ); + } + } + else + { + iTextHeight = -1; + } + + if ( bImage ) + { + iImageWidth = ( iRight - iLeft + 1 - 8 ); + iImageHeight = ( iBottom - iTop + 1 - 8 - iTextHeight ); + + if ( ISNUM( 6 ) ) + { + iPicture = _s->iPicture[ hb_parni( 6 ) - 1 ]; + hb_wvt_gtRenderPicture( iLeft+4, iTop+4, iImageWidth, iImageHeight, iPicture ); + } + else + { + hb_wvt_DrawImage( _s->hdc, iLeft+4, iTop+4, iImageWidth, iImageHeight, hb_parcx( 6 ) ); + if ( _s->bGui ) + { + hb_wvt_DrawImage( _s->hGuiDC, iLeft+4, iTop+4, iImageWidth, iImageHeight, hb_parcx( 6 ) ); + } + } + } + + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_DRAWSTATUSBAR ) +{ + int iPanels = hb_parni( 1 ); + int i, iNext; + int iTop, iLeft, iBottom, iRight; + POINT xy = { 0,0 }; + + iNext = 0; + + for ( i = 0; i < iPanels; i++ ) + { + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2, iNext+2 ), hb_parni( 2, iNext+1 ) ); + iTop = xy.y; + iLeft = xy.x + 1; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2, iNext+4 ), hb_parni( 2, iNext+3 )+1 ); + iBottom = xy.y - 1; + iRight = xy.x - 2; + + SelectObject( _s->hdc, _s->penWhite ); + + MoveToEx( _s->hdc, iRight, iTop, NULL ); // Right + LineTo( _s->hdc, iRight, iBottom ); + + MoveToEx( _s->hdc, iLeft, iBottom, NULL ); // Bottom + LineTo( _s->hdc, iRight, iBottom ); + + SelectObject( _s->hdc, _s->penDarkGray ); + + MoveToEx( _s->hdc, iLeft, iTop, NULL ); // Left + LineTo( _s->hdc, iLeft, iBottom ); + + MoveToEx( _s->hdc, iLeft, iTop, NULL ); // Top + LineTo( _s->hdc, iRight, iTop ); + + iNext = iNext + 4; + } + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2, 4 * iPanels ), hb_parni( 2, ( 4 * iPanels ) - 1 )+1 ); + iTop = xy.y - 2; + iLeft = xy.x - 2; + iBottom = iTop; + iRight = iLeft; + + SelectObject( _s->hdc, _s->penBlack ); + + MoveToEx( _s->hdc, iLeft-4, iBottom, NULL ); + LineTo( _s->hdc, iRight, iTop-4 ); + MoveToEx( _s->hdc, iLeft-7, iBottom, NULL ); + LineTo( _s->hdc, iRight, iTop-7 ); + MoveToEx( _s->hdc, iLeft-10, iBottom, NULL ); + LineTo( _s->hdc, iRight, iTop-10 ); + + SelectObject( _s->hdc, _s->penWhite ); + + MoveToEx( _s->hdc, iLeft-5, iBottom, NULL ); + LineTo( _s->hdc, iRight, iTop-5 ); + MoveToEx( _s->hdc, iLeft-8, iBottom, NULL ); + LineTo( _s->hdc, iRight, iTop-8 ); + MoveToEx( _s->hdc, iLeft-11, iBottom, NULL ); + LineTo( _s->hdc, iRight, iTop-11 ); +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawPicture( nTop, nLeft, nBottom, nRight, nSlot, aPxlOff ) -> lOk +// nSlot <= 20 aAdj == { 0,0,-2,-2 } To Adjust the pixels for { Top,Left,Bottom,Right } +// +HB_FUNC( WVT_DRAWPICTURE ) +{ + POINT xy = { 0,0 }; + int iTop, iLeft, iBottom, iRight; + int iSlot = hb_parni( 5 ) - 1; + + if ( iSlot < WVT_PICTURES_MAX ) + { + if ( _s->iPicture[ iSlot ] ) + { + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y + hb_parni( 6,1 ); + iLeft = xy.x + hb_parni( 6,2 ); + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); + iBottom = xy.y-1 + hb_parni( 6,3 ); + iRight = xy.x-1 + hb_parni( 6,4 ); + + hb_retl( hb_wvt_gtRenderPicture( iLeft, iTop, iRight - iLeft + 1, iBottom - iTop + 1, _s->iPicture[ iSlot ] ) ); + } + } +} + +//-------------------------------------------------------------------// +// +// WVT_DRAWLABELEX( nRow, nCol, cLabel, nAlign, nTextColor, nBkColor, nSlotFont ) +// +HB_FUNC( WVT_DRAWLABELEX ) +{ + POINT xy = { 0,0 }; + int iSlot = hb_parni( 7 ) - 1; + + if ( _s->hUserFonts[ iSlot ] ) + { + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + + SetBkColor( _s->hdc, ISNIL( 6 ) ? _s->background : ( COLORREF ) hb_parnl( 6 ) ); + SetTextColor( _s->hdc, ISNIL( 5 ) ? _s->foreground : ( COLORREF ) hb_parnl( 5 ) ); + SetTextAlign( _s->hdc, ( ISNIL( 4 ) ? TA_LEFT : hb_parni( 4 ) ) ); + ( HFONT ) SelectObject( _s->hdc, _s->hUserFonts[ iSlot ] ); + + ExtTextOut( _s->hdc, xy.x, xy.y, 0, NULL, hb_parcx( 3 ), strlen( hb_parcx( 3 ) ), NULL ); + if ( _s->bGui ) + { + SetBkColor( _s->hGuiDC, ISNIL( 6 ) ? _s->background : ( COLORREF ) hb_parnl( 6 ) ); + SetTextColor( _s->hGuiDC, ISNIL( 5 ) ? _s->foreground : ( COLORREF ) hb_parnl( 5 ) ); + SetTextAlign( _s->hGuiDC, ( ISNIL( 4 ) ? TA_LEFT : hb_parni( 4 ) ) ); + ( HFONT ) SelectObject( _s->hGuiDC, _s->hUserFonts[ iSlot ] ); + + ExtTextOut( _s->hGuiDC, xy.x, xy.y, 0, NULL, hb_parcx( 3 ), strlen( hb_parcx( 3 ) ), NULL ); + } + + hb_retl( TRUE ); + } + + hb_retl( FALSE ); +} + +//-------------------------------------------------------------------// +// 1 2 3 4 5 6 7 8 +// Wvt_DrawLine( nTop, nLeft, nBottom, nRight, nOrient, nFormat, nAlign, nSlotPen ) +// +HB_FUNC( WVT_DRAWLINEEX ) +{ + POINT xy = { 0,0 }; + int iTop, iLeft, iBottom, iRight, iOffset ; + int iOrient, iFormat, iAlign ; + int x, y; + HPEN hPen; + int iSlot = hb_parni( 8 ) - 1; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y; + iLeft = xy.x; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); + iBottom = xy.y-1; + iRight = xy.x-1; + + // Resolve Parameters + iOrient = ISNIL( 5 ) ? 0 : hb_parni( 5 ); + iFormat = ISNIL( 6 ) ? 0 : hb_parni( 6 ); + iAlign = ISNIL( 7 ) ? 0 : hb_parni( 7 ); + + x = iLeft ; + y = iTop ; + + switch ( iAlign ) + { + case 0: // Center + { + if ( iOrient == 0 ) // Horizontal + { + iOffset = ( ( iBottom - iTop ) / 2 ) ; + y = iTop + iOffset ; + } + else + { + iOffset = ( ( iRight - iLeft ) / 2 ) ; + x = iLeft + iOffset ; + } + } + break; + + case 1: // Top + break; + + case 2: // bottom + { + if ( iFormat == 0 || iFormat == 1 ) // Raised/Recessd + { + y = iBottom - 1; + } + else + { + y = iBottom; + } + } + break; + + case 3: // Left + break; + + case 4: // Right + { + if ( iFormat == 0 || iFormat == 1 ) // Raised/Recessd + { + x = iRight - 1; + } + else + { + x = iRight; + } + } + break; + } + + hPen = _s->hUserPens[ iSlot ]; + + switch ( iFormat ) + { + case 0: // Raised + { + if ( iOrient == 0 ) // Horizontal + { + SelectObject( _s->hdc, _s->penWhite ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, iRight, y ); + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y+1, NULL ); + LineTo( _s->hdc, iRight, y+1 ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, _s->penWhite ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, iRight, y ); + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y+1, NULL ); + LineTo( _s->hGuiDC, iRight, y+1 ); + } + } + else // Vertical + { + SelectObject( _s->hdc, _s->penWhite ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, x, iBottom ); + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x+1, y, NULL ); + LineTo( _s->hdc, x+1, iBottom ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, _s->penWhite ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, x, iBottom ); + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x+1, y, NULL ); + LineTo( _s->hGuiDC, x+1, iBottom ); + } + } + } + break; + + case 1: // Recessed + { + if ( iOrient == 0 ) // Horizontal + { + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, iRight, y ); + SelectObject( _s->hdc, _s->penWhite ); + MoveToEx( _s->hdc, x, y+1, NULL ); + LineTo( _s->hdc, iRight, y+1 ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, iRight, y ); + SelectObject( _s->hGuiDC, _s->penWhite ); + MoveToEx( _s->hGuiDC, x, y+1, NULL ); + LineTo( _s->hGuiDC, iRight, y+1 ); + } + } + else // Vertical + { + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, x, iBottom ); + SelectObject( _s->hdc, _s->penWhite ); + MoveToEx( _s->hdc, x+1, y, NULL ); + LineTo( _s->hdc, x+1, iBottom ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, x, iBottom ); + SelectObject( _s->hGuiDC, _s->penWhite ); + MoveToEx( _s->hGuiDC, x+1, y, NULL ); + LineTo( _s->hGuiDC, x+1, iBottom ); + } + } + } + break; + + case 2: // Plain + { + if ( iOrient == 0 ) // Horizontal + { + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, iRight, y ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, iRight, y ); + } + } + else // Vertical + { + SelectObject( _s->hdc, hPen ); + MoveToEx( _s->hdc, x, y, NULL ); + LineTo( _s->hdc, x, iBottom ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, hPen ); + MoveToEx( _s->hGuiDC, x, y, NULL ); + LineTo( _s->hGuiDC, x, iBottom ); + } + } + } + break; + } + + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawOutlineEx( nTop, nLeft, nBottom, nRight, nSlotPen ) +// +HB_FUNC( WVT_DRAWOUTLINEEX ) +{ + POINT xy = { 0,0 }; + int iTop, iLeft, iBottom, iRight; + int iSlot = hb_parni( 5 ) - 1; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y - 1; + iLeft = xy.x - 1; + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); + iBottom = xy.y; + iRight = xy.x; + + if ( _s->hUserPens[ iSlot ] ) + { + SelectObject( _s->hdc, _s->hUserPens[ iSlot ] ); + } + else + { + SelectObject( _s->hdc, _s->penBlack ); + } + + hb_wvt_DrawOutline( _s->hdc, iTop, iLeft, iBottom, iRight ); + if ( _s->bGui ) + { + hb_wvt_DrawOutline( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_LoadPicture( nSlot, cFilePic ) +// +HB_FUNC( WVT_LOADPICTURE ) +{ + IPicture * iPicture = hb_wvt_gtLoadPicture( hb_parcx( 2 ) ); + BOOL bResult = FALSE; + int iSlot = hb_parni( 1 ) - 1 ; + + if ( iPicture ) + { + if ( _s->iPicture[ iSlot ] ) + { + hb_wvt_gtDestroyPicture( _s->iPicture[ iSlot ] ); + } + + _s->iPicture[ iSlot ] = iPicture; + bResult = TRUE; + } + hb_retl( bResult ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_LOADPICTUREFROMRESOURCE ) +{ + IPicture * iPicture = hb_wvt_gtLoadPictureFromResource( hb_parcx( 2 ),hb_parcx( 3 ) ); + BOOL bResult = FALSE; + int iSlot = hb_parni( 1 ) - 1 ; + + if ( iPicture ) + { + if ( _s->iPicture[ iSlot ] ) + { + hb_wvt_gtDestroyPicture( _s->iPicture[ iSlot ] ); + } + + _s->iPicture[ iSlot ] = iPicture; + bResult = TRUE; + } + hb_retl( bResult ); +} + +//-------------------------------------------------------------------// +// +// Wvt_LoadFont( nSlotFont, cFontFace, nHeight, nWidth, nWeight, lItalic, lUnderline, lStrikeout, +// nCharSet, nQuality, nEscapement ) +// +HB_FUNC( WVT_LOADFONT ) +{ + LOGFONT logfont;// = { 0 }; + int iSlot = hb_parni( 1 ) - 1; + HFONT hFont; + + logfont.lfEscapement = ( ISNIL( 11 ) ? 0 : ( hb_parni( 11 ) * 10 ) ); + logfont.lfOrientation = 0; + logfont.lfWeight = ( ISNIL( 5 ) ? 0 : hb_parni( 5 ) ); + logfont.lfItalic = ( ISNIL( 6 ) ? 0 : hb_parl( 6 ) ); + logfont.lfUnderline = ( ISNIL( 7 ) ? 0 : hb_parl( 7 ) ); + logfont.lfStrikeOut = ( ISNIL( 8 ) ? 0 : hb_parl( 8 ) ); + logfont.lfCharSet = ( ISNIL( 9 ) ? _s->CodePage : hb_parni( 9 ) ); + logfont.lfOutPrecision = 0; + logfont.lfClipPrecision = 0; + logfont.lfQuality = ( ISNIL( 10 ) ? DEFAULT_QUALITY : hb_parni( 10 ) ); + logfont.lfPitchAndFamily = FF_DONTCARE; + logfont.lfHeight = ( ISNIL( 3 ) ? _s->fontHeight : hb_parni( 3 ) ); + logfont.lfWidth = ( ISNIL( 4 ) ? ( _s->fontWidth < 0 ? -_s->fontWidth : _s->fontWidth ) : hb_parni( 4 ) ); + + strcpy( logfont.lfFaceName, ( ISNIL( 2 ) ? _s->fontFace : hb_parcx( 2 ) ) ); + + hFont = CreateFontIndirect( &logfont ); + if ( hFont ) + { + if ( _s->hUserFonts[ iSlot ] ) + { + DeleteObject( _s->hUserFonts[ iSlot ] ); + } + _s->hUserFonts[ iSlot ] = hFont; + } +} + +//-------------------------------------------------------------------// +// +// Wvt_LoadPen( nSlot, nStyle, nWidth, nRGBColor ) +// +HB_FUNC( WVT_LOADPEN ) +{ + int iPenWidth, iPenStyle; + COLORREF crColor; + HPEN hPen; + int iSlot = hb_parni( 1 ) - 1; + + iPenStyle = ISNIL( 2 ) ? 0 : hb_parni( 2 ) ; + iPenWidth = ISNIL( 3 ) ? 0 : hb_parni( 3 ); + crColor = ISNIL( 4 ) ? RGB( 0,0,0 ) : ( COLORREF ) hb_parnl( 4 ); + + hPen = CreatePen( iPenStyle, iPenWidth, crColor ); + + if ( hPen ) + { + if ( _s->hUserPens[ iSlot ] ) + { + DeleteObject( _s->hUserPens[ iSlot ] ); + } + _s->hUserPens[ iSlot ] = hPen; + + hb_retl( TRUE ); + } + else + { + hb_retl( FALSE ); + } +} + +//-------------------------------------------------------------------// +// +// aScr := Wvt_SaveScreen( nTop, nLeft, nBottom, nRight ) +// +HB_FUNC( WVT_SAVESCREEN ) +{ + HBITMAP hBmp, oldBmp; + POINT xy = { 0,0 }; + int iTop, iLeft, iBottom, iRight, iWidth, iHeight; + PHB_ITEM info = hb_itemArrayNew( 3 ); + PHB_ITEM temp = hb_itemNew( NULL ); + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y; + iLeft = xy.x; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); + iBottom = xy.y-1; + iRight = xy.x-1; + + iWidth = iRight - iLeft + 1; + iHeight = iBottom - iTop + 1; + + hBmp = CreateCompatibleBitmap( _s->hdc, iWidth, iHeight ) ; + + oldBmp = (HBITMAP) SelectObject( _s->hCompDC, hBmp ); + BitBlt( _s->hCompDC, 0, 0, iWidth, iHeight, _s->hdc, iLeft, iTop, SRCCOPY ); + SelectObject( _s->hCompDC, oldBmp ); + + hb_arraySet( info, 1, hb_itemPutNI( temp, iWidth ) ); + hb_arraySet( info, 2, hb_itemPutNI( temp, iHeight ) ); + hb_arraySet( info, 3, hb_itemPutNL( temp, ( ULONG ) hBmp ) ); + hb_itemRelease( temp ); + + hb_itemReturn( info ); + hb_itemRelease( info ); +} + +//-------------------------------------------------------------------// +// +// Wvt_RestScreen( nTop, nLeft, nBottom, nRight, aScr, lDoNotDestroyBMP ) +// +HB_FUNC( WVT_RESTSCREEN ) +{ + POINT xy = { 0,0 }; + int iTop, iLeft, iBottom, iRight, iWidth, iHeight; + HBITMAP hBmp; + + BOOL bResult = FALSE; + BOOL bDoNotDestroyBMP = ISNIL( 6 ) ? FALSE : hb_parl( 6 ); + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y; + iLeft = xy.x; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 ) + 1, hb_parni( 3 ) + 1 ); + iBottom = xy.y-1; + iRight = xy.x-1; + + iWidth = iRight - iLeft + 1 ; + iHeight = iBottom - iTop + 1 ; + + hBmp = (HBITMAP) SelectObject( _s->hCompDC, ( HBITMAP ) hb_parnl( 5,3 ) ); + if ( hBmp ) + { + if ( ( iWidth == hb_parni( 5,1 ) ) && ( iHeight == hb_parni( 5,2 ) ) ) + { + if ( BitBlt( _s->hdc, + iLeft, + iTop, + iWidth, + iHeight, + _s->hCompDC, + 0, + 0, + SRCCOPY ) ) + { + bResult = TRUE; + } + } + else + { + if ( StretchBlt( _s->hdc, + iLeft, + iTop, + iWidth, + iHeight, + _s->hCompDC, + 0, + 0, + hb_parni( 5,1 ), + hb_parni( 5,2 ), + SRCCOPY ) ) + { + bResult = TRUE; + } + } + } + + SelectObject( _s->hCompDC, hBmp ); + + if ( ! bDoNotDestroyBMP ) + { + DeleteObject( ( HBITMAP ) hb_parnl( 5,3 ) ); + } + + hb_retl( bResult ); +} + +//-------------------------------------------------------------------// +// +// Wvt_CreateFont( cFontFace, nHeight, nWidth, nWeight, lItalic, lUnderline, +// lStrikeout, nCharSet, nQuality, nEscapement ) +// +HB_FUNC( WVT_CREATEFONT ) +{ + LOGFONT logfont;// = { 0,0,0 }; + HFONT hFont; + + logfont.lfEscapement = ( ISNIL( 10 ) ? 0 : ( hb_parni( 10 ) * 10 ) ); + logfont.lfOrientation = 0; + logfont.lfWeight = ( ISNIL( 4 ) ? 0 : hb_parni( 4 ) ); + logfont.lfItalic = ( ISNIL( 5 ) ? 0 : hb_parl( 5 ) ); + logfont.lfUnderline = ( ISNIL( 6 ) ? 0 : hb_parl( 6 ) ); + logfont.lfStrikeOut = ( ISNIL( 7 ) ? 0 : hb_parl( 7 ) ); + logfont.lfCharSet = ( ISNIL( 8 ) ? _s->CodePage : hb_parni( 8 ) ); + logfont.lfOutPrecision = 0; + logfont.lfClipPrecision = 0; + logfont.lfQuality = ( ISNIL( 9 ) ? DEFAULT_QUALITY : hb_parni( 9 ) ); + logfont.lfPitchAndFamily = FF_DONTCARE; + logfont.lfHeight = ( ISNIL( 2 ) ? _s->fontHeight : hb_parni( 2 ) ); + logfont.lfWidth = ( ISNIL( 3 ) ? ( _s->fontWidth < 0 ? -_s->fontWidth : _s->fontWidth ) : hb_parni( 3 ) ); + + strcpy( logfont.lfFaceName, ( ISNIL( 1 ) ? _s->fontFace : hb_parcx( 1 ) ) ); + + hFont = CreateFontIndirect( &logfont ); + if ( hFont ) + { + hb_retnl( ( ULONG ) hFont ); + } + else + { + hb_retnl( 0 ); + } +} + +//-------------------------------------------------------------------// +// +// WVT_DRAWLABELOBJ( nTop, nLeft, nBottom, nRight, cLabel, nAlignHorz, nAlignVert, nTextColor, nBkColor, hFont ) +// +HB_FUNC( WVT_DRAWLABELOBJ ) +{ + POINT xy = { 0,0 }; + RECT rect = { 0,0,0,0 }; + int iTop, iLeft, iBottom, iRight, x, y; + int iAlignHorz, iAlignVert, iAlignH, iAlignV; + UINT uiOptions; + SIZE sz = { 0,0 }; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y; + iLeft = xy.x; + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); + iBottom = xy.y - 1; + iRight = xy.x - 1; + + iAlignHorz = ( ISNIL( 6 ) ? 0 : hb_parni( 6 ) ); + iAlignVert = ( ISNIL( 7 ) ? 0 : hb_parni( 7 ) ); + + SetTextColor( _s->hdc, ISNIL( 8 ) ? _s->foreground : ( COLORREF ) hb_parnl( 8 ) ); + SetBkColor( _s->hdc, ISNIL( 9 ) ? _s->background : ( COLORREF ) hb_parnl( 9 ) ); + ( HFONT ) SelectObject( _s->hdc, ( HFONT ) hb_parnl( 10 ) ); + + GetTextExtentPoint32( _s->hdc, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), &sz ); + + x = iLeft; + y = iTop; + + switch ( iAlignHorz ) + { + case 0: + { + iAlignH = TA_LEFT; + } + break; + case 1: + { + iAlignH = TA_RIGHT; + x = iRight; + } + break; + case 2: + { + iAlignH = TA_CENTER; + x = iLeft + ( ( iRight - iLeft + 1 ) / 2 ); + } + break; + } + + iAlignV = TA_TOP; + + switch ( iAlignVert ) + { + case 1: + { + y = iBottom - sz.cy; + } + break; + case 2: + { + y = iTop + ( ( iBottom - iTop + 1 - sz.cy ) / 2 ); + } + break; + } + + SetTextAlign( _s->hdc, iAlignH | iAlignV ); + + rect.top = iTop; + rect.left = iLeft; + rect.bottom = iBottom; + rect.right = iRight; + + uiOptions = ETO_CLIPPED | ETO_OPAQUE ; + + // Ground is Ready, Draw Text + // + ExtTextOut( _s->hdc, x, y, uiOptions, &rect, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), NULL ); + if ( _s->bGui ) + { + SetTextColor( _s->hGuiDC, ISNIL( 8 ) ? _s->foreground : ( COLORREF ) hb_parnl( 8 ) ); + SetBkColor( _s->hGuiDC, ISNIL( 9 ) ? _s->background : ( COLORREF ) hb_parnl( 9 ) ); + ( HFONT ) SelectObject( _s->hGuiDC, ( HFONT ) hb_parnl( 10 ) ); + SetTextAlign( _s->hGuiDC, iAlignH | iAlignV ); + + ExtTextOut( _s->hGuiDC, x, y, uiOptions, &rect, hb_parcx( 5 ), strlen( hb_parcx( 5 ) ), NULL ); + } + + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// +// nState 0 Flat, 1 Raised, 2 Recessed +// Wvt_DrawToolButtonState( nTop, nLeft, nBottom, nRight, aPxlOff, nState ) +// +HB_FUNC( WVT_DRAWTOOLBUTTONSTATE ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + switch ( hb_parni( 6 ) ) + { + case 0: // Flat + { + hb_wvt_DrawToolButtonFlat( _s->hdc, iTop, iLeft, iBottom, iRight ); + if ( _s->bGui ) + { + hb_wvt_DrawToolButtonFlat( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); + } + } + break; + + case 1: // Raised + { + hb_wvt_DrawToolButtonUp( _s->hdc, iTop, iLeft, iBottom, iRight ); + if ( _s->bGui ) + { + hb_wvt_DrawToolButtonUp( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); + } + } + break; + + case 2: // Recessed + { + hb_wvt_DrawToolButtonDown( _s->hdc, iTop, iLeft, iBottom, iRight ); + if ( _s->bGui ) + { + hb_wvt_DrawToolButtonDown( _s->hGuiDC, iTop, iLeft, iBottom, iRight ); + } + } + break; + } + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawScrollButton( nTop, nLeft, nBottom, nRight, aOffPixels, nTLBR, lDepressed ) +// +HB_FUNC( WVT_DRAWSCROLLBUTTON ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + POINT * Point; + POINT xy = { 0,0 }; + int iHeight, iOff; + BOOL bDepressed = ISNIL( 7 ) ? FALSE : hb_parl( 7 ) ; + + Point = ( POINT * ) hb_xgrab( 3 * sizeof( POINT ) ); + iOff = 6; + + iHeight = iBottom - iTop + 1; + + if ( bDepressed ) + { + hb_wvt_DrawBoxRecessed( _s->hdc, iTop+1, iLeft+1, iBottom-2, iRight-2 ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxRecessed( _s->hGuiDC, iTop+1, iLeft+1, iBottom-2, iRight-2 ); + } + } + else + { + hb_wvt_DrawBoxRaised( _s->hdc, iTop+1, iLeft+1, iBottom-2, iRight-2 ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxRaised( _s->hGuiDC, iTop+1, iLeft+1, iBottom-2, iRight-2 ); + } + } + + switch ( hb_parni( 6 ) ) + { + case 1: // Top + { + xy.y = iTop + iOff - 1; + xy.x = iLeft + ( ( iRight - iLeft + 1 ) / 2 ); + Point[ 0 ] = xy ; + xy.y = iBottom - iOff - 1; + xy.x = iLeft + iOff - 1; + Point[ 1 ] = xy; + xy.x = iRight - iOff + 1; + Point[ 2 ] = xy; + } + break; + + case 2: // Left + { + xy.y = iTop + ( ( iBottom - iTop + 1 ) / 2 ); + xy.x = iLeft + iOff; + Point[ 0 ] = xy ; + xy.x = iRight - iOff - 1; + xy.y = iTop + iOff - 1; + Point[ 1 ] = xy; + xy.y = iBottom - iOff + 1; + Point[ 2 ] = xy; + } + break; + + case 3: // Bottom + { + xy.x = iLeft + ( ( iRight - iLeft + 1 ) / 2 ); + xy.y = iBottom - iOff; + Point[ 0 ] = xy ; + xy.x = iLeft + iOff - 1; + xy.y = iBottom - iHeight + iOff + 1; + Point[ 1 ] = xy; + xy.x = iRight - iOff + 1; + Point[ 2 ] = xy; + } + break; + + case 4: // Right + { + xy.x = iRight - iOff - 1; + xy.y = iTop + ( ( iBottom - iTop + 1 ) / 2 ); + Point[ 0 ] = xy ; + xy.x = iLeft + iOff + 1; + xy.y = iTop + iOff - 1; + Point[ 1 ] = xy; + xy.y = iBottom - iOff + 1; + Point[ 2 ] = xy; + } + break; + } + + SelectObject( _s->hdc, _s->solidBrush ); + Polygon( _s->hdc, Point, 3 ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, _s->solidBrush ); + Polygon( _s->hGuiDC, Point, 3 ); + } + + hb_xfree( Point ); +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawScrollbarThumbVert( nTop, nLeft, nBottom, nRight, aPxlOff, nThumbPos ) +// +HB_FUNC( WVT_DRAWSCROLLTHUMBVERT ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + int iTabTop, iTabLft, iTabBtm, iTabRgt; + + // Background + // + SetBkMode( _s->hdc, OPAQUE ); + SetBkColor( _s->hdc, RGB( 230,230,230 ) ); + SelectObject( _s->hdc, _s->diagonalBrush ); + SelectObject( _s->hdc, _s->penNull ); + Rectangle( _s->hdc, iLeft, iTop, iRight+1, iBottom+1 ); + if ( _s->bGui ) + { + SetBkMode( _s->hGuiDC, OPAQUE ); + SetBkColor( _s->hGuiDC, RGB( 230,230,230 ) ); + SelectObject( _s->hGuiDC, _s->diagonalBrush ); + SelectObject( _s->hGuiDC, _s->penNull ); + Rectangle( _s->hGuiDC, iLeft, iTop, iRight+1, iBottom+1 ); + } + + // Thumb + // + iTabTop = _s->PTEXTSIZE.y * hb_parni( 6 ); + iTabLft = iLeft; + iTabBtm = iTabTop + _s->PTEXTSIZE.y - 1; + iTabRgt = iRight; + + SelectObject( _s->hdc, _s->wvtWhiteBrush ); + SelectObject( _s->hdc, _s->penGray ); + Rectangle( _s->hdc, iTabLft, iTabTop, iTabRgt+1, iTabBtm ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, _s->wvtWhiteBrush ); + SelectObject( _s->hGuiDC, _s->penGray ); + Rectangle( _s->hGuiDC, iTabLft, iTabTop, iTabRgt+1, iTabBtm ); + } + + hb_wvt_DrawBoxRaised( _s->hdc, iTabTop+1, iTabLft+1, iTabBtm-2, iTabRgt-2 ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxRaised( _s->hGuiDC, iTabTop+1, iTabLft+1, iTabBtm-2, iTabRgt-2 ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawScrollbarThumbHorz( nTop, nLeft, nBottom, nRight, aPxlOff, nThumbPos ) +// +HB_FUNC( WVT_DRAWSCROLLTHUMBHORZ ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + int iThumbLeft, iThumbRight;; + + iThumbLeft = _s->PTEXTSIZE.x * hb_parni( 6 ); + iThumbRight = iThumbLeft + ( _s->PTEXTSIZE.x * 2 ) - 1; + + // Background + // + SetBkMode( _s->hdc, OPAQUE ); + SetBkColor( _s->hdc, RGB( 230,230,230 ) ); + SelectObject( _s->hdc, _s->diagonalBrush ); + SelectObject( _s->hdc, _s->penNull ); + Rectangle( _s->hdc, iLeft, iTop, iRight+1, iBottom+1 ); + if ( _s->bGui ) + { + SetBkMode( _s->hGuiDC, OPAQUE ); + SetBkColor( _s->hGuiDC, RGB( 230,230,230 ) ); + SelectObject( _s->hGuiDC, _s->diagonalBrush ); + SelectObject( _s->hGuiDC, _s->penNull ); + Rectangle( _s->hGuiDC, iLeft, iTop, iRight+1, iBottom+1 ); + } + + // Thumb + // + SelectObject( _s->hdc, _s->wvtWhiteBrush ); + SelectObject( _s->hdc, _s->penGray ); + Rectangle( _s->hdc, iThumbLeft, iTop, iThumbRight, iBottom ); + if ( _s->bGui ) + { + SelectObject( _s->hGuiDC, _s->wvtWhiteBrush ); + SelectObject( _s->hGuiDC, _s->penGray ); + Rectangle( _s->hGuiDC, iThumbLeft, iTop, iThumbRight, iBottom ); + } + + hb_wvt_DrawBoxRaised( _s->hdc, iTop+1, iThumbLeft+1, iBottom-2, iThumbRight-2 ); + if ( _s->bGui ) + { + hb_wvt_DrawBoxRaised( _s->hGuiDC, iTop+1, iThumbLeft+1, iBottom-2, iThumbRight-2 ); + } +} + +//#if WINVER > 0x500 +//-------------------------------------------------------------------// +// +// Wvt_DrawShadedRect( nTop, nLeft, nBottom, nRight, aPxlOff, nHorVert, aRGBb, aRGBe ) +// +HB_FUNC( WVT_DRAWSHADEDRECT ) +{ + BOOL bGF = FALSE; + + if ( _s->hMSImg32 ) + { + TRIVERTEX vert[ 2 ] ; + GRADIENT_RECT gRect = { 0,0 }; + + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + int iMode = ISNIL( 6 ) ? GRADIENT_FILL_RECT_H : hb_parni( 6 ) ; + + vert[ 0 ].x = iLeft; + vert[ 0 ].y = iTop; + vert[ 0 ].Red = hb_parni( 7,1 ); + vert[ 0 ].Green = hb_parni( 7,2 ); + vert[ 0 ].Blue = hb_parni( 7,3 ); + vert[ 0 ].Alpha = hb_parni( 7,4 ); + + vert[ 1 ].x = iRight; + vert[ 1 ].y = iBottom; + vert[ 1 ].Red = hb_parni( 8,1 ); + vert[ 1 ].Green = hb_parni( 8,2 ); + vert[ 1 ].Blue = hb_parni( 8,3 ); + vert[ 1 ].Alpha = hb_parni( 8,4 ); + + gRect.UpperLeft = 0; + gRect.LowerRight= 1; + + bGF = ( BOOL ) _s->pfnGF( _s->hdc, vert, 2, &gRect, 1, iMode ); + if ( _s->bGui ) + { + bGF = ( BOOL ) _s->pfnGF( _s->hGuiDC, vert, 2, &gRect, 1, iMode ); + } + } + hb_retl( bGF ); +} +//#endif + +//-------------------------------------------------------------------// +// +// Wvt_DrawTextBox( nTop, nLeft, nBottom, nRight, aPxlOff, cText, ; +// nAlignHorz, nAlignVert, nTextColor, nBackColor, ; +// nBackMode, hFont ) +// +HB_FUNC( WVT_DRAWTEXTBOX ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + + int iAlignHorz = ( ISNIL( 7 ) ? 0 : hb_parni( 7 ) ); + int iAlignH ; + + RECT rc = { 0,0,0,0 }; + + switch ( iAlignHorz ) + { + case 0: + { + iAlignH = DT_LEFT; + } + break; + case 1: + { + iAlignH = DT_RIGHT; + } + break; + case 2: + { + iAlignH = DT_CENTER; + } + break; + } + + rc.top = iTop; + rc.left = iLeft; + rc.bottom = iBottom; + rc.right = iRight; + + SetTextAlign( _s->hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP ); + SetTextColor( _s->hdc, ISNIL( 9 ) ? _s->foreground : ( COLORREF ) hb_parnl( 9 ) ); + SetBkColor( _s->hdc, ISNIL( 10 ) ? _s->background : ( COLORREF ) hb_parnl( 10 ) ); + SetBkMode( _s->hdc, ISNIL( 11 ) ? OPAQUE : hb_parni( 11 ) ); + ( HFONT ) SelectObject( _s->hdc, ( HFONT ) hb_parnl( 12 ) ); + + DrawText( _s->hdc, hb_parcx( 6 ), strlen( hb_parcx( 6 ) ), &rc, iAlignH | DT_WORDBREAK | DT_TOP ); + if ( _s->bGui ) + { + SetTextAlign( _s->hGuiDC, TA_TOP | TA_LEFT | TA_NOUPDATECP ); + SetTextColor( _s->hGuiDC, ISNIL( 9 ) ? _s->foreground : ( COLORREF ) hb_parnl( 9 ) ); + SetBkColor( _s->hGuiDC, ISNIL( 10 ) ? _s->background : ( COLORREF ) hb_parnl( 10 ) ); + SetBkMode( _s->hGuiDC, ISNIL( 11 ) ? OPAQUE : hb_parni( 11 ) ); + ( HFONT ) SelectObject( _s->hGuiDC, ( HFONT ) hb_parnl( 12 ) ); + + DrawText( _s->hGuiDC, hb_parcx( 6 ), strlen( hb_parcx( 6 ) ), &rc, iAlignH | DT_WORDBREAK | DT_TOP ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_DrawProgressBar( nTop, nLeft, nBottom, nRight, aPxlOff, nPercent,; +// nBackColor, nBarColor, cImage, lVertical, nDirection ) +// +HB_FUNC( WVT_DRAWPROGRESSBAR ) +{ + int iTop = ( _s->PTEXTSIZE.y * hb_parni( 1 ) ) + hb_parni( 5,1 ); + int iLeft = ( _s->PTEXTSIZE.x * hb_parni( 2 ) ) + hb_parni( 5,2 ); + int iBottom = ( _s->PTEXTSIZE.y * ( hb_parni( 3 ) + 1 ) ) - 1 + hb_parni( 5,3 ); + int iRight = ( _s->PTEXTSIZE.x * ( hb_parni( 4 ) + 1 ) ) - 1 + hb_parni( 5,4 ); + int iPercent, iBarUpto, iDirection; + BOOL bVertical, bImage; + COLORREF crBarColor; + HBRUSH hBrush; + LOGBRUSH lb = { 0,0,0 }; + RECT rc = { 0,0,0,0 }; + + iPercent = hb_parni( 6 ); + bImage = ISNIL( 9 ) ? FALSE : TRUE ; + bVertical = ISNIL( 10 ) ? FALSE : hb_parl( 10 ) ; + iDirection = ISNIL( 11 ) ? 0 : hb_parni( 11 ); + + if ( bVertical ) + { + if ( iDirection == 0 ) + { + iBarUpto = iTop + ( ( iBottom - iTop ) * iPercent / 100 ); + rc.top = iTop; + rc.left = iLeft; + rc.bottom = iBarUpto; + rc.right = iRight; + } + else + { + iBarUpto = iBottom - ( ( iBottom - iTop ) * iPercent / 100 ); + rc.top = iBarUpto; + rc.left = iLeft; + rc.bottom = iBottom; + rc.right = iRight; + } + } + else + { + if ( iDirection == 0 ) + { + iBarUpto = iLeft + ( ( iRight - iLeft ) * iPercent / 100 ); + rc.top = iTop; + rc.left = iLeft; + rc.bottom = iBottom; + rc.right = iBarUpto; + } + else + { + iBarUpto = iRight - ( ( iRight - iLeft ) * iPercent / 100 ); + rc.top = iTop; + rc.left = iBarUpto; + rc.bottom = iBottom; + rc.right = iRight; + } + } + + if ( bImage ) + { + hb_wvt_DrawImage( _s->hdc, rc.left, rc.top, rc.right-rc.left+1, rc.bottom-rc.top+1, hb_parc( 9 ) ); + if ( _s->bGui ) + { + hb_wvt_DrawImage( _s->hGuiDC, rc.left, rc.top, rc.right-rc.left+1, rc.bottom-rc.top+1, hb_parc( 9 ) ); + } + } + else + { + crBarColor = ISNIL( 8 ) ? hb_wvt_gtGetColorData( 0 ) : ( COLORREF ) hb_parnl( 8 ); + + lb.lbStyle = BS_SOLID; + lb.lbColor = crBarColor; + lb.lbHatch = 0; + + hBrush = CreateBrushIndirect( &lb ); + + rc.bottom++; + rc.right++; + + FillRect( _s->hdc, &rc, hBrush ); + if ( _s->bGui ) + { + FillRect( _s->hGuiDC, &rc, hBrush ); + } + DeleteObject( hBrush ); + } +} + +//-------------------------------------------------------------------// + + diff --git a/harbour/contrib/gtwvg/wvtpaint.prg b/harbour/contrib/gtwvg/wvtpaint.prg index bda3b38665..8b6f515968 100644 --- a/harbour/contrib/gtwvg/wvtpaint.prg +++ b/harbour/contrib/gtwvg/wvtpaint.prg @@ -1,561 +1,561 @@ -/* - * Chr(36) + "Id" + Chr(36) - */ - -/* - * Harbour Project source code: - * - * Copyright 2004 Pritpal Bedi - * - * 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. - * - */ -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// WvtPaint.prg -// -// Routines to manage Wvt*Classes Gui Painting -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -#include 'wvtwin.ch' -#include 'common.ch' -//#include 'xhb.ch' - -//-------------------------------------------------------------------// - -static paint_:= { { '', {} } } - -//-------------------------------------------------------------------// -// -// This function must have to be defined in your appls -// -// function Wvt_Paint() - - // Call this function from this funtion - // - // WvtPaintObjects() - -// return nil - -//-------------------------------------------------------------------// - -function WvtPaintObjects() -LOCAL i, lExe, nLeft, nRight, b, tlbr_, aBlocks, nBlocks - -aBlocks := WvtSetPaint() - -if ( nBlocks := len( aBlocks ) ) > 0 - tlbr_:= Wvt_GetPaintRect() - - for i := 1 to nBlocks - lExe := .t. - - if aBlocks[ i,3 ] <> nil .and. !empty( aBlocks[ i,3 ] ) - // Check parameters against tlbr_ depending upon the - // type of object and attributes contained in aAttr - // - do case - case aBlocks[ i,3,1 ] == WVT_BLOCK_GRID_V - b := aBlocks[ i,3,6 ] - if len( b:aColumnsSep ) == 0 - lExe := .f. - else - nLeft := b:aColumnsSep[ 1 ] - nRight := b:aColumnsSep[ len( b:aColumnsSep ) ] - if !( tlbr_[ 1 ] <= aBlocks[ i,3,4 ] .and. ; // top < bottom - tlbr_[ 3 ] >= aBlocks[ i,3,2 ] .and. ; // bootm > top - tlbr_[ 2 ] <= nRight + 1 .and. ; // left < right - tlbr_[ 4 ] >= nLeft - 2 ) // right > left - lExe := .f. - endif - endif - - case aBlocks[ i,3,1 ] == WVT_BLOCK_GETS - if !( tlbr_[ 1 ] <= aBlocks[ i,3,4 ] .and. ; // top < bott - tlbr_[ 3 ] >= aBlocks[ i,3,2 ] .and. ; // bootm > top - tlbr_[ 2 ] <= aBlocks[ i,3,5 ] .and. ; // left < righ - tlbr_[ 4 ] >= aBlocks[ i,3,3 ] ) // right > left - lExe := .f. - endif - - otherwise - // If refreshing rectangle's top is less than objects' bottom - // and left is less than objects' right - // - if !( tlbr_[ 1 ] <= aBlocks[ i,3,4 ] .and. ; // top <= bottom - tlbr_[ 3 ] >= aBlocks[ i,3,2 ] .and. ; // bootm >= top - tlbr_[ 2 ] <= aBlocks[ i,3,5 ] .and. ; // left < right - tlbr_[ 4 ] >= aBlocks[ i,3,3 ] ) // right > left - lExe := .f. - endif - endcase - endif - - if lExe - eval( aBlocks[ i,2 ] ) - endif - next -endif - -return ( 0 ) - -//-------------------------------------------------------------------// - -function WvtSetPaint( a_ ) -local o -static s := {} - -o := s - -if a_ <> nil - s := a_ -endif - -return o - -//-------------------------------------------------------------------// - -function SetPaint( cID, nAction, xData, aAttr ) -local n, n1, oldData - -if xData <> nil - if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 - if ( n1 := ascan( paint_[ n,2 ], {|e_| e_[ 1 ] == nAction } ) ) > 0 - oldData := paint_[ n,2,n1,2 ] - paint_[ n,2,n1,2 ] := xData - paint_[ n,2,n1,3 ] := aAttr - else - aadd( paint_[ n,2 ], { nAction,xData,aAttr } ) - endif - else - aadd( paint_, { cID, {} } ) - n := len( paint_ ) - aadd( paint_[ n,2 ], { nAction, xData, aAttr } ) - endif -endif - -return oldData - -//-------------------------------------------------------------------// - -function GetPaint( cID ) -local n - -if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 - return paint_[ n,2 ] -endif - -return {} - -//-------------------------------------------------------------------// - -function DelPaint( cID, nAction ) -local xData, n1, n - -if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 - if ( n1 := ascan( paint_[ n,2 ], {|e_| e_[ 1 ] == nAction } ) ) > 0 - xData := paint_[ n,2,n1,2 ] - paint_[ n,2,n1,2 ] := {|| .t. } - endif -endif - -return xData - -//-------------------------------------------------------------------// - -function PurgePaint( cID,lDummy ) -local n, aPaint - -DEFAULT lDummy TO .f. - -if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 - aPaint := paint_[ n ] - ADel( paint_, n ) - aSize( paint_, len( paint_ ) - 1 ) -endif - -if lDummy - WvtSetPaint( {} ) -endif - -return ( aPaint ) - -//-------------------------------------------------------------------// - -function InsertPaint( cID, aPaint, lSet ) -local n - -DEFAULT lSet TO .f. - -if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 - paint_[ n ] := aPaint -else - aadd( paint_, aPaint ) -endif - -if lSet - WvtSetPaint( aPaint ) -endif - -return nil - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// RunTime Dialog Generation Routines -// -// Courtesy What32.lib -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -FUNCTION Wvt_MakeDlgTemplate( nTop, nLeft, nRows, nCols, aOffSet, cTitle, nStyle, ; - cFaceName, nPointSize, nWeight, lItalic, nHelpId, nExStyle ) - - LOCAL aDlg := { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} } - LOCAL aXY, nX, nY, nW, nH, nXM, nYM - LOCAL nBaseUnits, nBaseUnitsX, nBaseUnitsY - LOCAL aFont - - aFont := Wvt_GetFontInfo() - - DEFAULT aOffSet TO {} - - aSize( aOffSet,4 ) - - DEFAULT aOffSet[ 1 ] TO 0 - DEFAULT aOffSet[ 2 ] TO 0 - DEFAULT aOffSet[ 3 ] TO 0 - DEFAULT aOffSet[ 4 ] TO 0 - - nBaseUnits := Win_GetDialogBaseUnits() - nBaseUnitsX := Win_LoWord( nBaseUnits ) - nBaseUnitsY := Win_HiWord( nBaseUnits ) - - nW := aFont[ 7 ] * nCols + aOffSet[ 4 ] - nH := aFont[ 6 ] * nRows + aOffSet[ 3 ] - - // Position it exactly where user has requested - // - aXY := Wvt_ClientToScreen( nTop,nLeft ) - nX := aXY[ 1 ] + aOffSet[ 2 ] - nY := aXY[ 2 ] + aOffSet[ 1 ] - - // MSDN says DlgBaseUnits and Screen Coordinates has multiplier of 4,8 for x & Y. - // But in my practice, the values below are 99% accurate. - // I have tested it on many fonts but on 1280/800 resolution. - // Please feel free to experiment if you find thses values inappropriate. - // - nXM := 5.25 - nYM := 10.25 - - nX := ( nX * nXM / nBaseUnitsX ) - nY := ( nY * nYM / nBaseUnitsY ) - nW := ( nW * nXM / nBaseUnitsX ) - nH := ( nH * nYM / nBaseUnitsY ) - - If ValType( nStyle ) <> "N" - nStyle := + WS_CAPTION + WS_SYSMENU ; - + WS_GROUP + WS_TABSTOP + DS_SETFONT ; - + WS_THICKFRAME + WS_VISIBLE + WS_POPUP ; - + DS_3DLOOK - EndIf - - aAdd( aDlg[ 1 ] , If( Empty( nHelpId ), 0, nHelpId ) ) - aAdd( aDlg[ 1 ] , If( Empty( nExStyle ), 0, nExStyle ) ) - aAdd( aDlg[ 1 ] , nStyle ) - aAdd( aDlg[ 1 ] , 0 ) - aAdd( aDlg[ 1 ] , nX ) - aAdd( aDlg[ 1 ] , nY ) - aAdd( aDlg[ 1 ] , nW ) - aAdd( aDlg[ 1 ] , nH ) - aAdd( aDlg[ 1 ] , 0 ) - aAdd( aDlg[ 1 ] , 0 ) - aAdd( aDlg[ 1 ] , If( ValType( cTitle ) == "C", cTitle, "" ) ) - - //IF ( nStyle & DS_SETFONT ) == DS_SETFONT - if HB_INLINE( nStyle, DS_SETFONT ){ - hb_retnl( hb_parnl(1) & hb_parnl(2) ) ; - } - aAdd( aDlg[ 1 ], If( ValType( nPointSize ) == "N", nPointSize, 8 ) ) - aAdd( aDlg[ 1 ], If( ValType( nWeight ) == "N", nWeight , 400 ) ) - aAdd( aDlg[ 1 ], If( ValType( lItalic ) == "L", lItalic , .F. ) ) - aAdd( aDlg[ 1 ], If( ValType( cFaceName ) == "C", cFaceName , "MS Sans Serif" ) ) - EndIf - - Return( aDlg ) - -//-------------------------------------------------------------------// - -Function Wvt_AddDlgItem( aDlg, nTop, nLeft, nRows, nCols, aOffSet,; - cnId, cnDlgClass, nStyle, cText, nHelpId, nExStyle ) - LOCAL aXY, nX, nY, nW, nH, nXM, nYM - LOCAL nBaseUnits, nBaseUnitsX, nBaseUnitsY - LOCAL nBottom, nRight - - nBottom := nTop + nRows - 1 - nRight := nLeft + nCols - 1 - - DEFAULT aOffSet TO {} - - aSize( aOffSet,4 ) - - DEFAULT aOffSet[ 1 ] TO 0 - DEFAULT aOffSet[ 2 ] TO 0 - DEFAULT aOffSet[ 3 ] TO 0 - DEFAULT aOffSet[ 4 ] TO 0 - - nBaseUnits := Win_GetDialogBaseUnits() - nBaseUnitsX := Win_LoWord( nBaseUnits ) - nBaseUnitsY := Win_HiWord( nBaseUnits ) - - aXY := Wvt_GetXYFromRowCol( nTop, nLeft ) - nX := aXY[ 1 ] + aOffSet[ 2 ] - nY := aXY[ 2 ] + aOffSet[ 1 ] - - aXY := Wvt_GetXYFromRowCol( nBottom+1, nRight+1 ) - nW := aXY[ 1 ] + aOffSet[ 4 ] - nX - nH := aXY[ 2 ] + aOffSet[ 3 ] - nY - - nXM := 5.25 - nYM := 10.25 - - nX := ( nX * nXM / nBaseUnitsX ) - nY := ( nY * nYM / nBaseUnitsY ) - nW := ( nW * nXM / nBaseUnitsX ) - nH := ( nH * nYM / nBaseUnitsY ) - - aDlg[ 1,4 ]++ // item count - - aAdd( aDlg[ 2 ] , If( ValType( nHelpId ) == "N", nHelpId , 0 ) ) - aAdd( aDlg[ 3 ] , If( ValType( nExStyle ) == "N", nExStyle, 0 ) ) - aAdd( aDlg[ 4 ] , If( ValType( nStyle ) == "N", nStyle , WS_CHILD + WS_VISIBLE ) ) - aAdd( aDlg[ 5 ] , nX ) - aAdd( aDlg[ 6 ] , nY ) - aAdd( aDlg[ 7 ] , nW ) - aAdd( aDlg[ 8 ] , nH ) - aAdd( aDlg[ 9 ] , cnId ) - aAdd( aDlg[ 10 ] , cnDlgClass ) - aAdd( aDlg[ 11 ] , If( ValType( cText ) <> "C", If( ValType( cText ) == "N", cText, "" ) , cText ) ) - aAdd( aDlg[ 12 ] , 0 ) - - Return aDlg - -//-------------------------------------------------------------------// - -Function Wvt_CreateDialog( acnDlg, lOnTop, cbDlgProc, ncIcon, nTimerTicks, hMenu ) - LOCAL hDlg, cType, xTemplate, nDlgMode - - if valtype( cbDlgProc ) == 'C' - cbDlgProc := upper( cbDlgProc ) - endif - - hDlg := 0 - cType := Valtype( acnDlg ) - nDlgMode := if( cType == 'C', 0, if( cType == 'N', 1, 2 ) ) - - if cType == 'A' - xTemplate := Wvt__MakeDlgTemplate( acnDlg[ 1 ] , acnDlg[ 2 ] , acnDlg[ 3 ] , acnDlg[ 4 ] , ; - acnDlg[ 5 ] , acnDlg[ 6 ] , acnDlg[ 7 ] , acnDlg[ 8 ] , ; - acnDlg[ 9 ] , acnDlg[ 10 ] , acnDlg[ 11 ] , acnDlg[ 12 ] ) - else - xTemplate := acnDlg - endif - - hDlg := Wvt_CreateDialogDynamic( xTemplate, lOnTop, cbDlgProc, nDlgMode ) - - if hDlg <> 0 - if ncIcon <> nil - Wvt_DlgSetIcon( hDlg, ncIcon ) - - endif - - if valtype( nTimerTicks ) == 'N' - Win_SetTimer( hDlg, 1001, nTimerTicks ) - - endif - - if hMenu <> nil - Win_SetMenu( hDlg, hMenu ) - - endif - - endif - - Return hDlg - -//-------------------------------------------------------------------// - -Function Wvt_DialogBox( acnDlg, cbDlgProc, hWndParent ) - LOCAL nResult, cType, xTemplate, nDlgMode - - if valtype( cbDlgProc ) == 'C' - cbDlgProc := upper( cbDlgProc ) - endif - - cType := Valtype( acnDlg ) - nDlgMode := if( cType == 'C', 0, if( cType == 'N', 1, 2 ) ) - - if cType == 'A' - xTemplate := Wvt__MakeDlgTemplate( acnDlg[ 1 ] , acnDlg[ 2 ] , acnDlg[ 3 ] , acnDlg[ 4 ] , ; - acnDlg[ 5 ] , acnDlg[ 6 ] , acnDlg[ 7 ] , acnDlg[ 8 ] , ; - acnDlg[ 9 ] , acnDlg[ 10 ] , acnDlg[ 11 ] , acnDlg[ 12 ] ) - else - xTemplate := acnDlg - endif - - nResult := Wvt_CreateDialogModal( xTemplate, .f., cbDlgProc, nDlgMode, hWndParent ) - - Return nResult - -//-------------------------------------------------------------------// -/* Borrowed from What32 - -Wvt_GetOpenFileName( hWnd, @cPath, cTitle, aFilter, nFlags, cInitDir, cDefExt, nIndex ) - -hWnd: Handle to parent window -cPath: (optional) if OFN_ALLOWMULTISELECT the path is stored -cTitle: Window Title -aFilter: Array of Files Types i.e. { {'Data Bases','*.dbf'},{'Clipper','*.prg'} } -nFlags: OFN_* values default to OFN_EXPLORER -cInitDir: Initial directory -cDefExt: Default Extension i.e. 'DBF' -nIndex: Index position of types - -Returns: If OFN_ALLOWMULTISELECT - Array of files selected - else - FileName. - endif -*/ -FUNCTION WVT_GetOpenFileName( hWnd, cPath, cTitle, aFilter, nFlags, cIniDir, cDefExt, nIndex ) - local aFiles, cRet, cFile, n, x, c := '' - - IF aFilter == nil - aFilter := {} - END - IF ValType( aFilter ) == "A" - FOR n := 1 TO LEN( aFilter ) - c += aFilter[n][1] + chr(0) + aFilter[n][2] + chr(0) - NEXT - ENDIF - if WIN_AND( nFlags,OFN_ALLOWMULTISELECT ) > 0 - cFile := space( 32000 ) - ELSE - cFile := padr( trim( cPath ), 255, chr( 0 ) ) - END - - cRet := WVT__GetOpenFileName( hWnd, @cFile, cTitle, c, nFlags, cIniDir, cDefExt, @nIndex ) - - if WIN_AND( nFlags,OFN_ALLOWMULTISELECT ) > 0 - n := AT( CHR(0)+ CHR(0), cFile ) - cFile := LEFT( cFile,n ) - aFiles := {} - IF n == 0 // no double chr(0) user must have pressed cancel - RETURN( aFiles ) - END - x := AT( CHR( 0 ),cFile ) // fist null - cPath := LEFT( cFile,x ) - - cFile := STRTRAN( cFile,cPath ) - IF !EMPTY( cFile ) // user selected more than 1 file - c := '' - FOR n := 1 TO LEN( cFile ) - IF SUBSTR( cFile,n,1 ) == CHR( 0 ) - AADD( aFiles,STRTRAN( cPath, CHR( 0 ) ) +'\'+ c ) - c:='' - LOOP - END - c += SUBSTR( cFile,n,1 ) - NEXT - ELSE - /* - cFile:=cPath - x:=RAT('\',cFile) - cPath:=LEFT(cFile,x-1) - */ - aFiles := { STRTRAN( cPath, CHR( 0 ) ) } //STRTRAN(STRTRAN(cFile,cPath),'\')} - END - Return( aFiles ) - else - cRet := left( cRet, at( chr( 0 ), cRet ) -1 ) - end - - Return ( cRet ) - -//-------------------------------------------------------------------// -/* -Wvt_GetSaveFileName( hWnd, cFile, cTitle, aFilter, nFlags, cInitDir, cDefExt, nIndex) - -hWnd: Handle to parent window -cFile: (optional) Default FileName -cTitle: Window Title -aFilter: Array of Files Types i.e. { {'Data Bases','*.dbf'},{'Clipper','*.prg'} } -nFlags: OFN_* values default to OFN_EXPLORER -cInitDir: Initial directory -cDefExt: Default Extension i.e. 'DBF' -nIndex: Index position of types - -Returns: FileName. -*/ - -FUNCTION WVT_GetSaveFileName( hWnd, cFile, cTitle, aFilter, nFlags, cIniDir, cDefExt, nIndex ) - local n,c:='' - - IF aFilter == nil - aFilter := {} - END - - FOR n := 1 TO LEN( aFilter ) - c += aFilter[ n ][ 1 ]+chr( 0 )+aFilter[ n ][ 2 ]+chr( 0 ) - NEXT - cFile := WVT__GetSaveFileName( hWnd, cFile, cTitle, c, nFlags, cIniDir, cDefExt, @nIndex ) - - Return ( cFile ) - -//-------------------------------------------------------------------// - +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2004 Pritpal Bedi + * + * 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. + * + */ +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// WvtPaint.prg +// +// Routines to manage Wvt*Classes Gui Painting +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +#include 'wvtwin.ch' +#include 'common.ch' +//#include 'xhb.ch' + +//-------------------------------------------------------------------// + +static paint_:= { { '', {} } } + +//-------------------------------------------------------------------// +// +// This function must have to be defined in your appls +// +// function Wvt_Paint() + + // Call this function from this funtion + // + // WvtPaintObjects() + +// return nil + +//-------------------------------------------------------------------// + +function WvtPaintObjects() +LOCAL i, lExe, nLeft, nRight, b, tlbr_, aBlocks, nBlocks + +aBlocks := WvtSetPaint() + +if ( nBlocks := len( aBlocks ) ) > 0 + tlbr_:= Wvt_GetPaintRect() + + for i := 1 to nBlocks + lExe := .t. + + if aBlocks[ i,3 ] <> nil .and. !empty( aBlocks[ i,3 ] ) + // Check parameters against tlbr_ depending upon the + // type of object and attributes contained in aAttr + // + do case + case aBlocks[ i,3,1 ] == WVT_BLOCK_GRID_V + b := aBlocks[ i,3,6 ] + if len( b:aColumnsSep ) == 0 + lExe := .f. + else + nLeft := b:aColumnsSep[ 1 ] + nRight := b:aColumnsSep[ len( b:aColumnsSep ) ] + if !( tlbr_[ 1 ] <= aBlocks[ i,3,4 ] .and. ; // top < bottom + tlbr_[ 3 ] >= aBlocks[ i,3,2 ] .and. ; // bootm > top + tlbr_[ 2 ] <= nRight + 1 .and. ; // left < right + tlbr_[ 4 ] >= nLeft - 2 ) // right > left + lExe := .f. + endif + endif + + case aBlocks[ i,3,1 ] == WVT_BLOCK_GETS + if !( tlbr_[ 1 ] <= aBlocks[ i,3,4 ] .and. ; // top < bott + tlbr_[ 3 ] >= aBlocks[ i,3,2 ] .and. ; // bootm > top + tlbr_[ 2 ] <= aBlocks[ i,3,5 ] .and. ; // left < righ + tlbr_[ 4 ] >= aBlocks[ i,3,3 ] ) // right > left + lExe := .f. + endif + + otherwise + // If refreshing rectangle's top is less than objects' bottom + // and left is less than objects' right + // + if !( tlbr_[ 1 ] <= aBlocks[ i,3,4 ] .and. ; // top <= bottom + tlbr_[ 3 ] >= aBlocks[ i,3,2 ] .and. ; // bootm >= top + tlbr_[ 2 ] <= aBlocks[ i,3,5 ] .and. ; // left < right + tlbr_[ 4 ] >= aBlocks[ i,3,3 ] ) // right > left + lExe := .f. + endif + endcase + endif + + if lExe + eval( aBlocks[ i,2 ] ) + endif + next +endif + +return ( 0 ) + +//-------------------------------------------------------------------// + +function WvtSetPaint( a_ ) +local o +static s := {} + +o := s + +if a_ <> nil + s := a_ +endif + +return o + +//-------------------------------------------------------------------// + +function SetPaint( cID, nAction, xData, aAttr ) +local n, n1, oldData + +if xData <> nil + if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 + if ( n1 := ascan( paint_[ n,2 ], {|e_| e_[ 1 ] == nAction } ) ) > 0 + oldData := paint_[ n,2,n1,2 ] + paint_[ n,2,n1,2 ] := xData + paint_[ n,2,n1,3 ] := aAttr + else + aadd( paint_[ n,2 ], { nAction,xData,aAttr } ) + endif + else + aadd( paint_, { cID, {} } ) + n := len( paint_ ) + aadd( paint_[ n,2 ], { nAction, xData, aAttr } ) + endif +endif + +return oldData + +//-------------------------------------------------------------------// + +function GetPaint( cID ) +local n + +if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 + return paint_[ n,2 ] +endif + +return {} + +//-------------------------------------------------------------------// + +function DelPaint( cID, nAction ) +local xData, n1, n + +if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 + if ( n1 := ascan( paint_[ n,2 ], {|e_| e_[ 1 ] == nAction } ) ) > 0 + xData := paint_[ n,2,n1,2 ] + paint_[ n,2,n1,2 ] := {|| .t. } + endif +endif + +return xData + +//-------------------------------------------------------------------// + +function PurgePaint( cID,lDummy ) +local n, aPaint + +DEFAULT lDummy TO .f. + +if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 + aPaint := paint_[ n ] + ADel( paint_, n ) + aSize( paint_, len( paint_ ) - 1 ) +endif + +if lDummy + WvtSetPaint( {} ) +endif + +return ( aPaint ) + +//-------------------------------------------------------------------// + +function InsertPaint( cID, aPaint, lSet ) +local n + +DEFAULT lSet TO .f. + +if ( n := ascan( paint_, { |e_| e_[ 1 ] == cID } ) ) > 0 + paint_[ n ] := aPaint +else + aadd( paint_, aPaint ) +endif + +if lSet + WvtSetPaint( aPaint ) +endif + +return nil + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// RunTime Dialog Generation Routines +// +// Courtesy What32.lib +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +FUNCTION Wvt_MakeDlgTemplate( nTop, nLeft, nRows, nCols, aOffSet, cTitle, nStyle, ; + cFaceName, nPointSize, nWeight, lItalic, nHelpId, nExStyle ) + + LOCAL aDlg := { {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} } + LOCAL aXY, nX, nY, nW, nH, nXM, nYM + LOCAL nBaseUnits, nBaseUnitsX, nBaseUnitsY + LOCAL aFont + + aFont := Wvt_GetFontInfo() + + DEFAULT aOffSet TO {} + + aSize( aOffSet,4 ) + + DEFAULT aOffSet[ 1 ] TO 0 + DEFAULT aOffSet[ 2 ] TO 0 + DEFAULT aOffSet[ 3 ] TO 0 + DEFAULT aOffSet[ 4 ] TO 0 + + nBaseUnits := Win_GetDialogBaseUnits() + nBaseUnitsX := Win_LoWord( nBaseUnits ) + nBaseUnitsY := Win_HiWord( nBaseUnits ) + + nW := aFont[ 7 ] * nCols + aOffSet[ 4 ] + nH := aFont[ 6 ] * nRows + aOffSet[ 3 ] + + // Position it exactly where user has requested + // + aXY := Wvt_ClientToScreen( nTop,nLeft ) + nX := aXY[ 1 ] + aOffSet[ 2 ] + nY := aXY[ 2 ] + aOffSet[ 1 ] + + // MSDN says DlgBaseUnits and Screen Coordinates has multiplier of 4,8 for x & Y. + // But in my practice, the values below are 99% accurate. + // I have tested it on many fonts but on 1280/800 resolution. + // Please feel free to experiment if you find thses values inappropriate. + // + nXM := 5.25 + nYM := 10.25 + + nX := ( nX * nXM / nBaseUnitsX ) + nY := ( nY * nYM / nBaseUnitsY ) + nW := ( nW * nXM / nBaseUnitsX ) + nH := ( nH * nYM / nBaseUnitsY ) + + If ValType( nStyle ) <> "N" + nStyle := + WS_CAPTION + WS_SYSMENU ; + + WS_GROUP + WS_TABSTOP + DS_SETFONT ; + + WS_THICKFRAME + WS_VISIBLE + WS_POPUP ; + + DS_3DLOOK + EndIf + + aAdd( aDlg[ 1 ] , If( Empty( nHelpId ), 0, nHelpId ) ) + aAdd( aDlg[ 1 ] , If( Empty( nExStyle ), 0, nExStyle ) ) + aAdd( aDlg[ 1 ] , nStyle ) + aAdd( aDlg[ 1 ] , 0 ) + aAdd( aDlg[ 1 ] , nX ) + aAdd( aDlg[ 1 ] , nY ) + aAdd( aDlg[ 1 ] , nW ) + aAdd( aDlg[ 1 ] , nH ) + aAdd( aDlg[ 1 ] , 0 ) + aAdd( aDlg[ 1 ] , 0 ) + aAdd( aDlg[ 1 ] , If( ValType( cTitle ) == "C", cTitle, "" ) ) + + //IF ( nStyle & DS_SETFONT ) == DS_SETFONT + if HB_INLINE( nStyle, DS_SETFONT ){ + hb_retnl( hb_parnl(1) & hb_parnl(2) ) ; + } + aAdd( aDlg[ 1 ], If( ValType( nPointSize ) == "N", nPointSize, 8 ) ) + aAdd( aDlg[ 1 ], If( ValType( nWeight ) == "N", nWeight , 400 ) ) + aAdd( aDlg[ 1 ], If( ValType( lItalic ) == "L", lItalic , .F. ) ) + aAdd( aDlg[ 1 ], If( ValType( cFaceName ) == "C", cFaceName , "MS Sans Serif" ) ) + EndIf + + Return( aDlg ) + +//-------------------------------------------------------------------// + +Function Wvt_AddDlgItem( aDlg, nTop, nLeft, nRows, nCols, aOffSet,; + cnId, cnDlgClass, nStyle, cText, nHelpId, nExStyle ) + LOCAL aXY, nX, nY, nW, nH, nXM, nYM + LOCAL nBaseUnits, nBaseUnitsX, nBaseUnitsY + LOCAL nBottom, nRight + + nBottom := nTop + nRows - 1 + nRight := nLeft + nCols - 1 + + DEFAULT aOffSet TO {} + + aSize( aOffSet,4 ) + + DEFAULT aOffSet[ 1 ] TO 0 + DEFAULT aOffSet[ 2 ] TO 0 + DEFAULT aOffSet[ 3 ] TO 0 + DEFAULT aOffSet[ 4 ] TO 0 + + nBaseUnits := Win_GetDialogBaseUnits() + nBaseUnitsX := Win_LoWord( nBaseUnits ) + nBaseUnitsY := Win_HiWord( nBaseUnits ) + + aXY := Wvt_GetXYFromRowCol( nTop, nLeft ) + nX := aXY[ 1 ] + aOffSet[ 2 ] + nY := aXY[ 2 ] + aOffSet[ 1 ] + + aXY := Wvt_GetXYFromRowCol( nBottom+1, nRight+1 ) + nW := aXY[ 1 ] + aOffSet[ 4 ] - nX + nH := aXY[ 2 ] + aOffSet[ 3 ] - nY + + nXM := 5.25 + nYM := 10.25 + + nX := ( nX * nXM / nBaseUnitsX ) + nY := ( nY * nYM / nBaseUnitsY ) + nW := ( nW * nXM / nBaseUnitsX ) + nH := ( nH * nYM / nBaseUnitsY ) + + aDlg[ 1,4 ]++ // item count + + aAdd( aDlg[ 2 ] , If( ValType( nHelpId ) == "N", nHelpId , 0 ) ) + aAdd( aDlg[ 3 ] , If( ValType( nExStyle ) == "N", nExStyle, 0 ) ) + aAdd( aDlg[ 4 ] , If( ValType( nStyle ) == "N", nStyle , WS_CHILD + WS_VISIBLE ) ) + aAdd( aDlg[ 5 ] , nX ) + aAdd( aDlg[ 6 ] , nY ) + aAdd( aDlg[ 7 ] , nW ) + aAdd( aDlg[ 8 ] , nH ) + aAdd( aDlg[ 9 ] , cnId ) + aAdd( aDlg[ 10 ] , cnDlgClass ) + aAdd( aDlg[ 11 ] , If( ValType( cText ) <> "C", If( ValType( cText ) == "N", cText, "" ) , cText ) ) + aAdd( aDlg[ 12 ] , 0 ) + + Return aDlg + +//-------------------------------------------------------------------// + +Function Wvt_CreateDialog( acnDlg, lOnTop, cbDlgProc, ncIcon, nTimerTicks, hMenu ) + LOCAL hDlg, cType, xTemplate, nDlgMode + + if valtype( cbDlgProc ) == 'C' + cbDlgProc := upper( cbDlgProc ) + endif + + hDlg := 0 + cType := Valtype( acnDlg ) + nDlgMode := if( cType == 'C', 0, if( cType == 'N', 1, 2 ) ) + + if cType == 'A' + xTemplate := Wvt__MakeDlgTemplate( acnDlg[ 1 ] , acnDlg[ 2 ] , acnDlg[ 3 ] , acnDlg[ 4 ] , ; + acnDlg[ 5 ] , acnDlg[ 6 ] , acnDlg[ 7 ] , acnDlg[ 8 ] , ; + acnDlg[ 9 ] , acnDlg[ 10 ] , acnDlg[ 11 ] , acnDlg[ 12 ] ) + else + xTemplate := acnDlg + endif + + hDlg := Wvt_CreateDialogDynamic( xTemplate, lOnTop, cbDlgProc, nDlgMode ) + + if hDlg <> 0 + if ncIcon <> nil + Wvt_DlgSetIcon( hDlg, ncIcon ) + + endif + + if valtype( nTimerTicks ) == 'N' + Win_SetTimer( hDlg, 1001, nTimerTicks ) + + endif + + if hMenu <> nil + Win_SetMenu( hDlg, hMenu ) + + endif + + endif + + Return hDlg + +//-------------------------------------------------------------------// + +Function Wvt_DialogBox( acnDlg, cbDlgProc, hWndParent ) + LOCAL nResult, cType, xTemplate, nDlgMode + + if valtype( cbDlgProc ) == 'C' + cbDlgProc := upper( cbDlgProc ) + endif + + cType := Valtype( acnDlg ) + nDlgMode := if( cType == 'C', 0, if( cType == 'N', 1, 2 ) ) + + if cType == 'A' + xTemplate := Wvt__MakeDlgTemplate( acnDlg[ 1 ] , acnDlg[ 2 ] , acnDlg[ 3 ] , acnDlg[ 4 ] , ; + acnDlg[ 5 ] , acnDlg[ 6 ] , acnDlg[ 7 ] , acnDlg[ 8 ] , ; + acnDlg[ 9 ] , acnDlg[ 10 ] , acnDlg[ 11 ] , acnDlg[ 12 ] ) + else + xTemplate := acnDlg + endif + + nResult := Wvt_CreateDialogModal( xTemplate, .f., cbDlgProc, nDlgMode, hWndParent ) + + Return nResult + +//-------------------------------------------------------------------// +/* Borrowed from What32 + +Wvt_GetOpenFileName( hWnd, @cPath, cTitle, aFilter, nFlags, cInitDir, cDefExt, nIndex ) + +hWnd: Handle to parent window +cPath: (optional) if OFN_ALLOWMULTISELECT the path is stored +cTitle: Window Title +aFilter: Array of Files Types i.e. { {'Data Bases','*.dbf'},{'Clipper','*.prg'} } +nFlags: OFN_* values default to OFN_EXPLORER +cInitDir: Initial directory +cDefExt: Default Extension i.e. 'DBF' +nIndex: Index position of types + +Returns: If OFN_ALLOWMULTISELECT + Array of files selected + else + FileName. + endif +*/ +FUNCTION WVT_GetOpenFileName( hWnd, cPath, cTitle, aFilter, nFlags, cIniDir, cDefExt, nIndex ) + local aFiles, cRet, cFile, n, x, c := '' + + IF aFilter == nil + aFilter := {} + END + IF ValType( aFilter ) == "A" + FOR n := 1 TO LEN( aFilter ) + c += aFilter[n][1] + chr(0) + aFilter[n][2] + chr(0) + NEXT + ENDIF + if WIN_AND( nFlags,OFN_ALLOWMULTISELECT ) > 0 + cFile := space( 32000 ) + ELSE + cFile := padr( trim( cPath ), 255, chr( 0 ) ) + END + + cRet := WVT__GetOpenFileName( hWnd, @cFile, cTitle, c, nFlags, cIniDir, cDefExt, @nIndex ) + + if WIN_AND( nFlags,OFN_ALLOWMULTISELECT ) > 0 + n := AT( CHR(0)+ CHR(0), cFile ) + cFile := LEFT( cFile,n ) + aFiles := {} + IF n == 0 // no double chr(0) user must have pressed cancel + RETURN( aFiles ) + END + x := AT( CHR( 0 ),cFile ) // fist null + cPath := LEFT( cFile,x ) + + cFile := STRTRAN( cFile,cPath ) + IF !EMPTY( cFile ) // user selected more than 1 file + c := '' + FOR n := 1 TO LEN( cFile ) + IF SUBSTR( cFile,n,1 ) == CHR( 0 ) + AADD( aFiles,STRTRAN( cPath, CHR( 0 ) ) +'\'+ c ) + c:='' + LOOP + END + c += SUBSTR( cFile,n,1 ) + NEXT + ELSE + /* + cFile:=cPath + x:=RAT('\',cFile) + cPath:=LEFT(cFile,x-1) + */ + aFiles := { STRTRAN( cPath, CHR( 0 ) ) } //STRTRAN(STRTRAN(cFile,cPath),'\')} + END + Return( aFiles ) + else + cRet := left( cRet, at( chr( 0 ), cRet ) -1 ) + end + + Return ( cRet ) + +//-------------------------------------------------------------------// +/* +Wvt_GetSaveFileName( hWnd, cFile, cTitle, aFilter, nFlags, cInitDir, cDefExt, nIndex) + +hWnd: Handle to parent window +cFile: (optional) Default FileName +cTitle: Window Title +aFilter: Array of Files Types i.e. { {'Data Bases','*.dbf'},{'Clipper','*.prg'} } +nFlags: OFN_* values default to OFN_EXPLORER +cInitDir: Initial directory +cDefExt: Default Extension i.e. 'DBF' +nIndex: Index position of types + +Returns: FileName. +*/ + +FUNCTION WVT_GetSaveFileName( hWnd, cFile, cTitle, aFilter, nFlags, cIniDir, cDefExt, nIndex ) + local n,c:='' + + IF aFilter == nil + aFilter := {} + END + + FOR n := 1 TO LEN( aFilter ) + c += aFilter[ n ][ 1 ]+chr( 0 )+aFilter[ n ][ 2 ]+chr( 0 ) + NEXT + cFile := WVT__GetSaveFileName( hWnd, cFile, cTitle, c, nFlags, cIniDir, cDefExt, @nIndex ) + + Return ( cFile ) + +//-------------------------------------------------------------------// + diff --git a/harbour/contrib/gtwvg/wvtutils.c b/harbour/contrib/gtwvg/wvtutils.c index 0f741e8038..5fb34ec9dc 100644 --- a/harbour/contrib/gtwvg/wvtutils.c +++ b/harbour/contrib/gtwvg/wvtutils.c @@ -1,2418 +1,2418 @@ -/* - * Chr(36) + "Id" + Chr(36) - */ - -/* - * Harbour Project source code: - * Video subsystem for Win32 using GUI windows instead of Console - * - * Copyright 2007 Pritpal Bedi - * based on: - * - * Copyright 2003 Peter Rees - * Rees Software & Systems Ltd - * based on - * Bcc ConIO Video subsystem by - * Copyright 2002 Marek Paliwoda - * Copyright 2002 Przemyslaw Czerpak - * Video subsystem for Win32 compilers - * Copyright 1999-2000 Paul Tucker - * Copyright 2002 Przemysław Czerpak - * - * The following parts are Copyright of the individual authors. - * www - http://www.harbour-project.org - * - * - * Copyright 1999 David G. Holm - * hb_gt_Tone() - * - * See doc/license.txt for licensing terms. - * - * www - 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. - * - */ - -//-------------------------------------------------------------------// - -#define HB_OS_WIN_32_USED - -//-------------------------------------------------------------------// - -#include "gtwvt.h" - -/* workaround for missing declaration in MinGW32 */ -#if !defined(TTM_SETTITLE) && defined(TTM_SETTITLEA) - #define TTM_SETTITLE TTM_SETTITLEA -#endif - -//-------------------------------------------------------------------// - -static GLOBAL_DATA *_s = NULL; - -//-------------------------------------------------------------------// - -HB_EXTERN_BEGIN - -extern HANDLE hb_hInstance; - -extern BOOL wvt_Array2Rect(PHB_ITEM aRect, RECT *rc ); -extern PHB_ITEM wvt_Rect2Array( RECT *rc ); -extern BOOL wvt_Array2Point(PHB_ITEM aPoint, POINT *pt ); -extern PHB_ITEM wvt_Point2Array( POINT *pt ); -extern BOOL wvt_Array2Size(PHB_ITEM aSize, SIZE *siz ); -extern PHB_ITEM wvt_Size2Array( SIZE *siz ); -extern void wvt_Rect2ArrayEx( RECT *rc ,PHB_ITEM aRect ); -extern void wvt_Point2ArrayEx( POINT *pt , PHB_ITEM aPoint); -extern void wvt_Size2ArrayEx( SIZE *siz ,PHB_ITEM aSize ); - -HB_EXTERN_END - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Pritpal Bedi -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -void HB_EXPORT hb_wvt_wvtUtils( void ) -{ - _s = hb_wvt_gtGetGlobalData(); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_UTILS ) -{ - hb_wvt_wvtUtils(); -} - -//-------------------------------------------------------------------// -// -// Wvt_ChooseFont( cFontName, nHeight, nWidth, nWeight, nQuality, ; -// lItalic, lUnderline, lStrikeout ) -// -HB_FUNC( WVT_CHOOSEFONT ) -{ - CHOOSEFONT cf;// = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - LOGFONT lf;// = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; - LONG PointSize = 0; - - if ( ! ISNIL( 2 ) ) - { - PointSize = -MulDiv( ( LONG ) hb_parnl( 2 ), GetDeviceCaps( _s->hdc, LOGPIXELSY ), 72 ) ; - } - - lf.lfHeight = PointSize; - lf.lfWidth = ISNIL( 3 ) ? 0 : hb_parni( 3 ); - lf.lfWeight = ISNIL( 4 ) ? 0 : hb_parni( 4 ); - lf.lfItalic = ISNIL( 6 ) ? 0 : hb_parl( 6 ); - lf.lfUnderline = ISNIL( 7 ) ? 0 : hb_parl( 7 ); - lf.lfStrikeOut = ISNIL( 8 ) ? 0 : hb_parl( 8 ); - lf.lfCharSet = DEFAULT_CHARSET; - lf.lfQuality = ISNIL( 5 ) ? DEFAULT_QUALITY : hb_parni( 5 ); - lf.lfPitchAndFamily = FF_DONTCARE; - if ( ISCHAR( 1 ) ) - { - strcpy( lf.lfFaceName, hb_parc( 1 ) ); - } - - cf.lStructSize = sizeof( CHOOSEFONT ); - cf.hwndOwner = _s->hWnd; - cf.hDC = ( HDC ) NULL; - cf.lpLogFont = &lf; - cf.iPointSize = 0; - cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_SHOWHELP | CF_INITTOLOGFONTSTRUCT ; - cf.rgbColors = RGB( 0,0,0 ); - cf.lCustData = 0L; - cf.lpfnHook = ( LPCFHOOKPROC ) NULL; - cf.lpTemplateName = ( LPSTR ) NULL; - cf.hInstance = ( HINSTANCE ) NULL; - cf.lpszStyle = ( LPSTR ) NULL; - cf.nFontType = SCREEN_FONTTYPE; - cf.nSizeMin = 0; - cf.nSizeMax = 0; - - if ( ChooseFont( &cf ) ) - { - PointSize = -MulDiv( lf.lfHeight, 72, GetDeviceCaps( _s->hdc, LOGPIXELSY ) ) ; - - hb_reta( 8 ); - - hb_storc( lf.lfFaceName , -1, 1 ); - hb_stornl( ( LONG ) PointSize, -1, 2 ); - hb_storni( lf.lfWidth , -1, 3 ); - hb_storni( lf.lfWeight , -1, 4 ); - hb_storni( lf.lfQuality , -1, 5 ); - hb_storl( lf.lfItalic , -1, 6 ); - hb_storl( lf.lfUnderline , -1, 7 ); - hb_storl( lf.lfStrikeOut , -1, 8 ); - } - else - { - hb_reta( 8 ); - - hb_storc( "" , -1, 1 ); - hb_stornl( ( LONG ) 0, -1, 2 ); - hb_storni( 0 , -1, 3 ); - hb_storni( 0 , -1, 4 ); - hb_storni( 0 , -1, 5 ); - hb_storl( 0 , -1, 6 ); - hb_storl( 0 , -1, 7 ); - hb_storl( 0 , -1, 8 ); - } - - return ; -} - -//-------------------------------------------------------------------// -// -// Wvt_ChooseColor( nRGBInit, aRGB16, nFlags ) => nRGBSelected -// -HB_FUNC( WVT_CHOOSECOLOR ) -{ - CHOOSECOLOR cc ; - COLORREF crCustClr[ 16 ] ; - int i ; - - for( i = 0 ; i < 16 ; i++ ) - { - crCustClr[ i ] = ( ISARRAY( 2 ) ? ( COLORREF ) hb_parnl( 2, i+1 ) : GetSysColor( COLOR_BTNFACE ) ) ; - } - - cc.lStructSize = sizeof( CHOOSECOLOR ) ; - cc.hwndOwner = _s->hWnd ; - cc.rgbResult = ISNIL( 1 ) ? 0 : ( COLORREF ) hb_parnl( 1 ) ; - cc.lpCustColors = crCustClr ; - cc.Flags = ( WORD ) ( ISNIL( 3 ) ? CC_ANYCOLOR | CC_RGBINIT | CC_FULLOPEN : hb_parnl( 3 ) ); - - if ( ChooseColor( &cc ) ) - { - hb_retnl( cc.rgbResult ) ; - } - else - { - hb_retnl( -1 ); - } -} - -//-------------------------------------------------------------------// -// -// Wvt_MessageBox( cMessage, cTitle, nIcon, hWnd ) -// -HB_FUNC( WVT_MESSAGEBOX ) -{ - hb_retni( MessageBox( _s->hWnd, hb_parc( 1 ), hb_parc( 2 ), ISNIL( 3 ) ? MB_OK : hb_parni( 3 ) ) ) ; -} - -//-------------------------------------------------------------------// -//#if _WIN32_IE > 0x400 -//-------------------------------------------------------------------// -// -// Tooltips -// -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTOOLTIPACTIVE ) -{ - BOOL bActive = _s->bToolTipActive; - - if ( ! ISNIL( 1 ) ) - { - _s->bToolTipActive = hb_parl( 1 ); - } - - hb_retl( bActive ); -} - -//-------------------------------------------------------------------// -// -// Wvt_SetToolTip( nTop, nLeft, nBottom, nRight, cToolText ) -// -HB_FUNC( WVT_SETTOOLTIP ) -{ - TOOLINFO ti;// = { 0,0,0,0,0,0,0,0 }; - POINT xy = { 0,0 }; - int iTop, iLeft, iBottom, iRight; - - if ( ! _s->bToolTipActive ) - { - return; - } - - ti.cbSize = sizeof( TOOLINFO ); - ti.hwnd = _s->hWnd; - ti.uId = 100000; - - if ( SendMessage( _s->hWndTT, TTM_GETTOOLINFO, 0, ( LPARAM ) &ti ) ) - { - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - iTop = xy.y; - iLeft = xy.x; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); - iBottom = xy.y - 1; - iRight = xy.x - 1; - - ti.lpszText = hb_parc( 5 ); - ti.rect.left = iLeft; - ti.rect.top = iTop; - ti.rect.right = iRight; - ti.rect.bottom = iBottom; - - SendMessage( _s->hWndTT, TTM_SETTOOLINFO, 0, ( LPARAM ) &ti ); - } -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTOOLTIPTEXT ) -{ - TOOLINFO ti; - - ti.cbSize = sizeof( TOOLINFO ); - ti.hwnd = _s->hWnd; - ti.uId = 100000; - - if ( SendMessage( _s->hWndTT, TTM_GETTOOLINFO, 0, ( LPARAM ) &ti ) ) - { - ti.lpszText = hb_parc( 1 ); - SendMessage( _s->hWndTT, TTM_UPDATETIPTEXT, 0, ( LPARAM ) &ti ); - } -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTOOLTIPMARGIN ) -{ - /* - RECT rc = { 0,0,0,0 }; - int iTtm = TTM_SETMARGIN; - - rc.left = hb_parni( 2 ); - rc.top = hb_parni( 1 ); - rc.right = hb_parni( 4 ); - rc.bottom = hb_parni( 3 ); - - SendMessage( _s->hWndTT, iTtm, 0, ( LPARAM ) &rc ); - */ -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTOOLTIPWIDTH ) -{ - /* - int iTipWidth = SendMessage( _s->hWndTT, TTM_GETMAXTIPWIDTH, 0, 0 ); - - if ( ISNUM( 1 ) ) - { - SendMessage( _s->hWndTT, TTM_SETMAXTIPWIDTH, 0, ( LPARAM ) ( int ) hb_parni( 1 ) ); - } - - hb_retni( iTipWidth ); - */ -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTOOLTIPBKCOLOR ) -{ - /* - COLORREF cr = SendMessage( _s->hWndTT, TTM_GETTIPBKCOLOR, 0, 0 ); - - if ( ISNUM( 1 ) ) - { - SendMessage( _s->hWndTT, TTM_SETTIPBKCOLOR, ( WPARAM ) ( COLORREF ) hb_parnl( 1 ), 0 ); - } - hb_retnl( ( COLORREF ) cr ); - */ -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTOOLTIPTEXTCOLOR ) -{ - /* - COLORREF cr = SendMessage( _s->hWndTT, TTM_GETTIPTEXTCOLOR, 0, 0 ); - - if ( ISNUM( 1 ) ) - { - SendMessage( _s->hWndTT, TTM_SETTIPTEXTCOLOR, ( WPARAM ) ( COLORREF ) hb_parnl( 1 ), 0 ); - } - - hb_retnl( ( COLORREF ) cr ); - */ -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTOOLTIPTITLE ) -{ - /* - int iIcon; - - if ( ! ISNIL( 2 ) ) - { - iIcon = ISNIL( 1 ) ? 0 : hb_parni( 1 ); - if ( iIcon > 3 ) - { - iIcon = 0 ; - } - SendMessage( _s->hWndTT, TTM_SETTITLE, ( WPARAM ) iIcon, ( LPARAM ) hb_parc( 2 ) ); - } - */ -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETTOOLTIPWIDTH ) -{ - //hb_retni( SendMessage( _s->hWndTT, TTM_GETMAXTIPWIDTH, 0, 0 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETTOOLTIPBKCOLOR ) -{ - //hb_retnl( ( COLORREF ) SendMessage( _s->hWndTT, TTM_GETTIPBKCOLOR, 0, 0 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETTOOLTIPTEXTCOLOR ) -{ - //hb_retnl( ( COLORREF ) SendMessage( _s->hWndTT, TTM_GETTIPTEXTCOLOR, 0, 0 ) ); -} - -//-------------------------------------------------------------------// -//#endif -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETGUI ) -{ - BOOL bGui = _s->bGui; - - if ( ! ISNIL( 1 ) ) - { - _s->bGui = hb_parl( 1 ); - } - - hb_retl( bGui ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTIMER ) -{ - hb_retl( SetTimer( _s->hWnd, hb_parni( 1 ), hb_parni( 2 ), NULL ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_KILLTIMER ) -{ - hb_retl( KillTimer( _s->hWnd, hb_parni( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETONTOP ) -{ - RECT rect = { 0,0,0,0 }; - - GetWindowRect( _s->hWnd, &rect ); - - hb_retl( SetWindowPos( _s->hWnd, HWND_TOPMOST, - rect.left, - rect.top, - 0, - 0, - SWP_NOSIZE + SWP_NOMOVE + SWP_NOACTIVATE ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETASNORMAL ) -{ - RECT rect = { 0,0,0,0 }; - - GetWindowRect( _s->hWnd, &rect ); - - hb_retl( SetWindowPos( _s->hWnd, HWND_NOTOPMOST, - rect.left, - rect.top, - 0, - 0, - SWP_NOSIZE + SWP_NOMOVE + SWP_NOACTIVATE ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_MINIMIZE ) -{ - ShowWindow( _s->hWnd, SW_MINIMIZE ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_MAXIMIZE ) -{ - ShowWindow( _s->hWnd, SW_RESTORE ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETMOUSEPOS ) -{ - POINT xy = { 0,0 }; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - - if ( ClientToScreen( _s->hWnd, &xy ) ) - { - hb_retl( SetCursorPos( xy.x, xy.y + ( _s->PTEXTSIZE.y / 2 ) ) ); - } - else - { - hb_retl( FALSE ); - } -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETPAINTRECT ) -{ - PHB_ITEM info = hb_itemArrayNew( 4 ); - PHB_ITEM temp = hb_itemNew( NULL ); - - hb_arraySet( info, 1, hb_itemPutNI( temp, _s->rowStart ) ); - hb_arraySet( info, 2, hb_itemPutNI( temp, _s->colStart ) ); - hb_arraySet( info, 3, hb_itemPutNI( temp, _s->rowStop ) ); - hb_arraySet( info, 4, hb_itemPutNI( temp, _s->colStop ) ); - - hb_itemRelease( temp ); - hb_itemReturn( info ); - hb_itemRelease( info ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETPOINTER ) -{ - int iCursor = hb_parni( 1 ); - HCURSOR hCursor; - - switch ( iCursor ) - { - case 1: - hCursor = LoadCursor( NULL, IDC_ARROW ); - break; - - case 2: - hCursor = LoadCursor( NULL, IDC_IBEAM ); - break; - - case 3: - hCursor = LoadCursor( NULL, IDC_WAIT ); - break; - - case 4: - hCursor = LoadCursor( NULL, IDC_CROSS ); - break; - - case 5: - hCursor = LoadCursor( NULL, IDC_UPARROW ); - break; - - case 6: - hCursor = LoadCursor( NULL, IDC_SIZE ); - break; - - case 7: - hCursor = LoadCursor( NULL, IDC_ICON ); - break; - - case 8: - hCursor = LoadCursor( NULL, IDC_SIZENWSE ); - break; - - case 9: - hCursor = LoadCursor( NULL, IDC_SIZENESW ); - break; - - case 10: - hCursor = LoadCursor( NULL, IDC_SIZEWE ); - break; - - case 11: - hCursor = LoadCursor( NULL, IDC_SIZENS ); - break; - - case 12: - hCursor = LoadCursor( NULL, IDC_SIZEALL ); - break; - - case 13: - hCursor = LoadCursor( NULL, IDC_NO ); - break; - - case 14: - hCursor = LoadCursor( NULL, IDC_HAND ); - break; - - case 15: - hCursor = LoadCursor( NULL, IDC_APPSTARTING ); - break; - - case 16: - hCursor = LoadCursor( NULL, IDC_HELP ); - break; - - default: - hCursor = LoadCursor( NULL, IDC_ARROW ); - break; - } - - SetClassLong( _s->hWnd, GCL_HCURSOR, ( DWORD ) hCursor ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETFONT ) -{ - hb_retl( hb_wvt_gtSetFont( - ISNIL( 1 ) ? _s->fontFace : hb_parc( 1 ), - ISNIL( 2 ) ? _s->fontHeight : hb_parni( 2 ), - ISNIL( 3 ) ? _s->fontWidth : hb_parni( 3 ), - ISNIL( 4 ) ? _s->fontWeight : hb_parni( 4 ), - ISNIL( 5 ) ? _s->fontQuality: hb_parni( 5 ) - ) ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETICON ) -{ - if ( ISNUM( 1 ) || ISCHAR( 2 ) ) - { - hb_retnl( hb_wvt_gtSetWindowIcon( hb_parni( 1 ), hb_parc( 2 ) ) ) ; - } - else - { - hb_retnl( hb_wvt_gtSetWindowIconFromFile( hb_parc( 1 ) ) ) ; - } -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETTITLE ) -{ - hb_wvt_gtSetWindowTitle( hb_parc( 1 ) ) ; - return ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETWINDOWPOS ) -{ - hb_wvt_gtSetWindowPos( hb_parni( 1 ), hb_parni( 2 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETWINDOWHANDLE ) -{ - hb_retnl( ( LONG ) hb_wvt_gtGetWindowHandle() ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETCODEPAGE ) -{ - hb_retni( hb_wvt_gtSetCodePage( hb_parni( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CENTERWINDOW ) -{ - hb_retl( hb_wvt_gtSetCentreWindow( - ISNIL( 1 ) ? TRUE : hb_parl( 1 ), - ISNIL( 2 ) ? FALSE : hb_parl( 2 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETMOUSEMOVE ) -{ - if ( ISNIL( 1 ) ) - { - hb_retl( _s->MouseMove ); - } - else - { - hb_retl( hb_wvt_gtSetMouseMove( hb_parl( 1 ) ) ); - } -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETXYFROMROWCOL ) -{ - PHB_ITEM info = hb_itemArrayNew( 2 ); - PHB_ITEM temp = hb_itemNew( NULL ); - POINT xy = { 0,0 }; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - - hb_arraySet( info, 1, hb_itemPutNL( temp, xy.x ) ); - hb_arraySet( info, 2, hb_itemPutNL( temp, xy.y ) ); - - hb_itemRelease( temp ); - hb_itemReturn( info ); - hb_itemRelease( info ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETFONTINFO ) -{ - PHB_ITEM info = hb_itemArrayNew( 7 ); - PHB_ITEM temp = hb_itemNew( NULL ); - - hb_arraySet( info, 1, hb_itemPutC( temp, _s->fontFace ) ); - hb_arraySet( info, 2, hb_itemPutNL( temp, _s->fontHeight ) ); - hb_arraySet( info, 3, hb_itemPutNL( temp, _s->fontWidth ) ); - hb_arraySet( info, 4, hb_itemPutNL( temp, _s->fontWeight ) ); - hb_arraySet( info, 5, hb_itemPutNL( temp, _s->fontQuality ) ); - hb_arraySet( info, 6, hb_itemPutNL( temp, _s->PTEXTSIZE.y ) ); - hb_arraySet( info, 7, hb_itemPutNL( temp, _s->PTEXTSIZE.x ) ); - - hb_itemRelease( temp ); - hb_itemReturn( info ); - hb_itemRelease( info ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETPALETTE ) -{ - PHB_ITEM info = hb_itemArrayNew( 16 ); - PHB_ITEM temp = hb_itemNew( NULL ); - int i; - - for ( i = 0; i < 16; i++ ) - { - hb_arraySet( info, i+1, hb_itemPutNL( temp, hb_wvt_gtGetColorData( i ) ) ); - } - hb_itemRelease( temp ); - hb_itemReturn( info ); - hb_itemRelease( info ); -} - -//-------------------------------------------------------------------// -// -// Wvt_SetPalette( aRGBValues ) -> An array of 16 elements with RGB values -// -HB_FUNC( WVT_SETPALETTE ) -{ - int i; - - for ( i = 0; i < 16; i++ ) - { - hb_wvt_gtSetColorData( i, hb_parnl( 1, i+1 ) ); - } -} - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Peter Rees -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETMENU ) -{ - SetMenu( _s->hWnd, ( HMENU ) hb_parni( 1 ) ) ; - - hb_wvt_gtResetWindow(); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETPOPUPMENU ) -{ - HMENU hPopup = _s->hPopup ; - - _s->hPopup = ( HMENU ) hb_parnl( 1 ); - if ( hPopup ) - { - hb_retnl( ( LONG ) hPopup ); - } -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CREATEMENU ) -{ - hb_retnl( ( LONG ) CreateMenu() ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CREATEPOPUPMENU ) -{ - hb_retnl( ( LONG ) CreatePopupMenu() ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_APPENDMENU ) -{ - char ucBuf[ 256 ]; - int i,iLen ; - LPCTSTR lpszCaption; - - if ( ISCHAR( 4 ) ) - { - iLen = hb_parclen( 4 ); - if ( iLen > 0 && iLen < 256 ) // Translate '~' to '&' - { - lpszCaption = hb_parc( 4 ) ; - for ( i = 0; i < iLen; i++ ) - { - ucBuf[ i ] = ( *lpszCaption == '~' ) ? '&' : *lpszCaption ; - lpszCaption++; - } - ucBuf[ iLen ]= '\0'; - lpszCaption = ucBuf ; - } - else - { - lpszCaption = hb_parc( 4 ) ; - } - } - else - { - lpszCaption = ( LPCTSTR ) hb_parni( 4 ) ; // It is a SEPARATOR or Submenu - } - - hb_retl( AppendMenu( ( HMENU ) hb_parnl( 1 ), ( UINT ) hb_parni( 2 ), ( UINT_PTR ) hb_parni( 3 ), ( LPCTSTR ) lpszCaption ) ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_DELETEMENU ) -{ - hb_retl( DeleteMenu( ( HMENU ) hb_parnl( 1 ), ( UINT ) hb_parni( 2 ), ( UINT ) hb_parni( 3 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_DESTROYMENU ) -{ - hb_retl( DestroyMenu( ( HMENU ) hb_parnl( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_ENABLEMENUITEM ) -{ - hb_retni( EnableMenuItem( ( HMENU ) hb_parnl( 1 ), ( UINT ) hb_parni( 2 ), ( UINT ) hb_parni( 3 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETLASTMENUEVENT ) -{ - hb_retni( hb_wvt_gtGetLastMenuEvent() ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETLASTMENUEVENT ) -{ - hb_retni( hb_wvt_gtSetLastMenuEvent( hb_parni(1) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETMENUKEYEVENT ) -{ - int iEvent = 0; - - if ( ISNUM( 1 ) ) - { - iEvent = hb_parnl( 1 ) ; - } - - hb_retni( hb_wvt_gtSetMenuKeyEvent( iEvent ) ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_DRAWMENUBAR ) -{ - DrawMenuBar( _s->hWnd ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETSCREENWIDTH ) -{ - hb_retni( GetSystemMetrics( SM_CXSCREEN ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETSCREENHEIGHT ) -{ - hb_retni( GetSystemMetrics( SM_CYSCREEN ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETWINDOWCENTRE ) -{ - hb_wvt_gtSetCentreWindow( hb_parl( 1 ), hb_parl( 2 ) ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETALTF4CLOSE ) -{ - hb_retl( hb_wvt_gtSetAltF4Close( hb_parl( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_PROCESSMESSAGES ) -{ - hb_wvt_gtDoProcessMessages(); - - hb_retl( 1 ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETTITLE ) -{ - BYTE ucText[ 1024 ]; - - hb_wvt_gtGetWindowTitle( ( char* ) ucText, 1023 ); - - hb_retc( ( char* ) ucText ) ; -} - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Author.....: Francesco Saverio Giudice -// Syntax.....: Wvt_GetRGBColor( nColor ) --> nRGBColor -// Description: Return the RGB values passing the color positional value -// 0=Black, 1=Blue, etc -// as returned from hb_ColorToN() -// Creat. Date: 2004/01/15 -// Last Modif.: 2004/01/15 -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETRGBCOLOR ) -{ - int iColor; - if ( !ISNIL( 1 ) ) - { - iColor = hb_parni( 1 ); - if ( iColor >= 0 && iColor < 16 ) /* Test bound error */ - { - hb_retnl( hb_wvt_gtGetColorData( iColor ) ); - } - } -} - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Giancarlo Niccolai -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETCLIPBOARD ) -{ - HGLOBAL hglb; - LPTSTR lptstr; - - if ( !IsClipboardFormatAvailable( CF_TEXT ) ) - { - hb_ret(); - } - - if ( !OpenClipboard( NULL ) ) - { - hb_ret(); - } - - hglb = GetClipboardData( CF_TEXT ); - if ( hglb != NULL ) - { - lptstr = ( LPSTR ) GlobalLock( hglb ); - if ( lptstr != NULL ) - { - hb_retc( lptstr ); - GlobalUnlock( hglb ); - } - } - CloseClipboard(); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SETCLIPBOARD ) -{ - LPTSTR lptstrCopy; - HGLOBAL hglbCopy; - char * cText; - int nLen; - - if ( !IsClipboardFormatAvailable( CF_TEXT ) ) - { - hb_retl( FALSE ); - return; - } - - // Check params - // - if ( ! ISCHAR( 1 ) ) - { - hb_retl( FALSE ); - return; - } - - if ( ! OpenClipboard( NULL ) ) - { - hb_retl( FALSE ); - return; - } - EmptyClipboard(); - - // Get text from PRG - // - cText = hb_parc( 1 ); - nLen = hb_parclen( 1 ); - - // Allocate a global memory object for the text. - // - hglbCopy = GlobalAlloc( GMEM_MOVEABLE, ( nLen+1 ) * sizeof( TCHAR ) ); - if ( hglbCopy == NULL ) - { - CloseClipboard(); - hb_retl( FALSE ); - return; - } - - // Lock the handle and copy the text to the buffer. - // - lptstrCopy = ( LPSTR ) GlobalLock( hglbCopy ); - memcpy( lptstrCopy, cText, ( nLen+1 ) * sizeof( TCHAR ) ); - lptstrCopy[ nLen+1 ] = ( TCHAR ) 0; // null character - GlobalUnlock( hglbCopy ); - - // Place the handle on the clipboard. - // - SetClipboardData( CF_TEXT, hglbCopy ); - - CloseClipboard(); - hb_retl( TRUE ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_PASTEFROMCLIPBOARD ) -{ - HGLOBAL hglb; - LPTSTR lptstr; - ULONG ul; - - if ( !IsClipboardFormatAvailable( CF_TEXT ) ) - { - hb_ret(); - } - - if ( !OpenClipboard( NULL ) ) - { - hb_ret(); - } - - hglb = GetClipboardData( CF_TEXT ); - if ( hglb != NULL ) - { - lptstr = ( LPSTR ) GlobalLock( hglb ); - if ( lptstr != NULL ) - { - for ( ul=0; ul < GlobalSize( hglb ); ul++ ) - { - hb_wvt_gtAddCharToInputQueue( ( int ) lptstr[ ul ] ); - } - GlobalUnlock( hglb ) ; - } - } - CloseClipboard(); -} - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -HB_FUNC( WVT_KEYBOARD ) -{ - hb_wvt_gtAddCharToInputQueue( hb_parnl( 1 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_INVALIDATERECT ) -{ - RECT rc = { 0,0,0,0 }; - POINT xy = { 0,0 }; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - rc.top = xy.y; - rc.left = xy.x; - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); - rc.bottom = xy.y - 1; - rc.right = xy.x - 1; - - InvalidateRect( _s->hWnd, &rc, TRUE ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_ISLBUTTONPRESSED ) -{ - hb_retl( GetKeyState( VK_LBUTTON ) & 0x8000 ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CLIENTTOSCREEN ) -{ - PHB_ITEM info = hb_itemArrayNew( 2 ); - PHB_ITEM temp = hb_itemNew( NULL ); - POINT xy = { 0,0 }; - - xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); - - ClientToScreen( _s->hWnd, &xy ); - - hb_arraySet( info, 1, hb_itemPutNL( temp, xy.x ) ); - hb_arraySet( info, 2, hb_itemPutNL( temp, xy.y ) ); - - hb_itemRelease( temp ); - hb_itemReturn( info ); - hb_itemRelease( info ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETCURSORPOS ) -{ - POINT xy = { 0,0 }; - PHB_ITEM info = hb_itemArrayNew( 2 ); - PHB_ITEM temp = hb_itemNew( NULL ); - - GetCursorPos( &xy ); - - hb_arraySet( info, 1, hb_itemPutNI( temp, xy.x ) ); - hb_arraySet( info, 2, hb_itemPutNI( temp, xy.y ) ); - - hb_itemRelease( temp ); - hb_itemReturn( info ); - hb_itemRelease( info ); - } - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_TRACKPOPUPMENU ) -{ - POINT xy = { 0,0 }; - - GetCursorPos( &xy ); - - hb_retnl( TrackPopupMenu( ( HMENU ) hb_parnl( 1 ) , - TPM_CENTERALIGN | TPM_RETURNCMD , - xy.x , - xy.y , - 0 , - _s->hWnd , - NULL ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_GETMENU ) -{ - hb_retnl( ( ULONG ) GetMenu( _s->hWnd ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_SHOWWINDOW ) -{ - ShowWindow( _s->hWnd, hb_parni( 1 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_UPDATEWINDOW ) -{ - UpdateWindow( _s->hWnd ); -} - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Dialogs -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CREATEDIALOGDYNAMIC ) -{ - PHB_ITEM pFirst = hb_param( 3,HB_IT_ANY ); - PHB_ITEM pFunc = NULL ; - PHB_DYNS pExecSym; - HWND hDlg ; - int iIndex; - int iType; - int iResource = hb_parni( 4 ); - - /* check if we still have room for a new dialog */ - for ( iIndex = 0; iIndex < WVT_DLGML_MAX; iIndex++ ) - { - if ( _s->hDlgModeless[ iIndex ] == NULL ) - { - break; - } - } - - if ( iIndex >= WVT_DLGML_MAX ) - { - /* no more room */ - hb_retnl( (ULONG) NULL ); - return; - } - - if ( HB_IS_BLOCK( pFirst ) ) - { - /* pFunc is pointing to stored code block (later) */ - pFunc = hb_itemNew( pFirst ); - iType = 2; - } - else if( hb_itemType( pFirst ) == HB_IT_STRING ) - { - #ifdef __XHARBOUR__ - hb_dynsymLock(); - #endif - pExecSym = hb_dynsymFindName( hb_itemGetC( pFirst ) ); - #ifdef __XHARBOUR__ - hb_dynsymUnlock(); - #endif - if ( pExecSym ) - { - pFunc = ( PHB_ITEM ) pExecSym; - } - iType = 1; - } - - { - if ( ISNUM( 3 ) ) - { - hDlg = CreateDialogIndirect( ( HINSTANCE ) hb_hInstance, - ( LPDLGTEMPLATE ) hb_parc( 1 ), - hb_parl( 2 ) ? _s->hWnd : NULL, - ( DLGPROC ) hb_parnl( 3 ) ); - } - else - { - switch ( iResource ) - { - case 0: - { - hDlg = CreateDialog( ( HINSTANCE ) hb_hInstance, - hb_parc( 1 ), - hb_parl( 2 ) ? _s->hWnd : NULL, - (DLGPROC) hb_wvt_gtDlgProcMLess ); - } - break; - - case 1: - { - hDlg = CreateDialog( ( HINSTANCE ) hb_hInstance, - MAKEINTRESOURCE( ( WORD ) hb_parni( 1 ) ), - hb_parl( 2 ) ? _s->hWnd : NULL, - (DLGPROC) hb_wvt_gtDlgProcMLess ); - } - break; - - case 2: - { - hDlg = CreateDialogIndirect( ( HINSTANCE ) hb_hInstance, - ( LPDLGTEMPLATE ) hb_parc( 1 ), - hb_parl( 2 ) ? _s->hWnd : NULL, - (DLGPROC) hb_wvt_gtDlgProcMLess ); - } - break; - } - } - - if ( hDlg ) - { - _s->hDlgModeless[ iIndex ] = hDlg; - - if ( pFunc ) - { - /* if codeblock, store the codeblock and lock it there */ - if (HB_IS_BLOCK( pFirst )) - { - _s->pcbFunc[ iIndex ] = pFunc; - } - - _s->pFunc[ iIndex ] = pFunc; - _s->iType[ iIndex ] = iType; - } - else - { - _s->pFunc[ iIndex ] = NULL; - _s->iType[ iIndex ] = 0; - } - SendMessage( hDlg, WM_INITDIALOG, 0, 0 ); - } - else - { - //if codeblock item created earlier, release it - if (iType==2 && pFunc) - { - hb_itemRelease( pFunc ); - } - _s->hDlgModeless[ iIndex ] = NULL; - } - } - - hb_retnl( ( ULONG ) hDlg ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CREATEDIALOGMODAL ) -{ - PHB_ITEM pFirst = hb_param( 3,HB_IT_ANY ); - PHB_ITEM pFunc = NULL ; - PHB_DYNS pExecSym; - int iIndex; - int iResource = hb_parni( 4 ); - int iResult = 0; - HWND hParent = ISNIL( 5 ) ? _s->hWnd : ( HWND ) hb_parnl( 5 ); - - /* check if we still have room for a new dialog */ - for ( iIndex = 0; iIndex < WVT_DLGMD_MAX; iIndex++ ) - { - if ( _s->hDlgModal[ iIndex ] == NULL ) - { - break; - } - } - - if ( iIndex >= WVT_DLGMD_MAX ) - { - /* no more room */ - hb_retni( ( int ) NULL ); - return; - } - - if ( HB_IS_BLOCK( pFirst ) ) - { - /* pFunc is pointing to stored code block (later) */ - - _s->pcbFuncModal[ iIndex ] = hb_itemNew( pFirst ); - - pFunc = _s->pcbFuncModal[ iIndex ]; - _s->pFuncModal[ iIndex ] = pFunc; - _s->iTypeModal[ iIndex ] = 2; - } - else if( hb_itemType( pFirst ) == HB_IT_STRING ) - { - #ifdef __XHARBOUR__ - hb_dynsymLock(); - #endif - pExecSym = hb_dynsymFindName( hb_itemGetC( pFirst ) ); - #ifdef __XHARBOUR__ - hb_dynsymUnlock(); - #endif - if ( pExecSym ) - { - pFunc = ( PHB_ITEM ) pExecSym; - } - _s->pFuncModal[ iIndex ] = pFunc; - _s->iTypeModal[ iIndex ] = 1; - } - - switch ( iResource ) - { - case 0: - { - iResult = DialogBoxParam( ( HINSTANCE ) hb_hInstance, - hb_parc( 1 ), - hParent, - (DLGPROC) hb_wvt_gtDlgProcModal, - ( LPARAM ) ( DWORD ) iIndex+1 ); - } - break; - - case 1: - { - iResult = DialogBoxParam( ( HINSTANCE ) hb_hInstance, - MAKEINTRESOURCE( ( WORD ) hb_parni( 1 ) ), - hParent, - (DLGPROC) hb_wvt_gtDlgProcModal, - ( LPARAM ) ( DWORD ) iIndex+1 ); - } - break; - - case 2: - { - iResult = DialogBoxIndirectParam( ( HINSTANCE ) hb_hInstance, - ( LPDLGTEMPLATE ) hb_parc( 1 ), - hParent, - (DLGPROC) hb_wvt_gtDlgProcModal, - ( LPARAM ) ( DWORD ) iIndex+1 ); - } - break; - } - - hb_retni( iResult ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT__MAKEDLGTEMPLATE ) -{ - WORD *p, *pdlgtemplate ; - WORD nItems = hb_parni( 1, 4 ) ; - int i, nchar ; - DWORD lStyle ; - - // Parameters: 12 arrays - // 1 for DLG template - // 11 for item properties - - // 64k allow to build up to 255 items on the dialog - // - pdlgtemplate = p = ( PWORD ) LocalAlloc( LPTR, 65534 ) ; - - //--------------- - - lStyle = hb_parnl(1,3) ; - - // start to fill in the dlgtemplate information. addressing by WORDs - - *p++ = 1 ; // version - *p++ = 0xFFFF ; // signature - *p++ = LOWORD ( hb_parnl(1,1) ) ; // Help Id - *p++ = HIWORD ( hb_parnl(1,1) ) ; - - *p++ = LOWORD ( hb_parnl(1,2) ) ; // ext. style - *p++ = HIWORD ( hb_parnl(1,2) ) ; - - *p++ = LOWORD (lStyle) ; - *p++ = HIWORD (lStyle) ; - - *p++ = (WORD) nItems ; // NumberOfItems - *p++ = (short) hb_parni(1,5) ; // x - *p++ = (short) hb_parni(1,6) ; // y - *p++ = (short) hb_parni(1,7) ; // cx - *p++ = (short) hb_parni(1,8) ; // cy - *p++ = (short) 0 ; // Menu (ignored for now.) - *p++ = (short) 0x00 ; // Class also ignored - - if ( hb_parinfa( 1,11 ) == HB_IT_STRING ) - { - nchar = nCopyAnsiToWideChar( p, TEXT( hb_parc( 1,11 ) ) ) ; - p += nchar ; - } - else - { - *p++ =0 ; - } - // add in the wPointSize and szFontName here iff the DS_SETFONT bit on - - if ( ( lStyle & DS_SETFONT ) ) - { - *p++ = (short) hb_parni(1,12) ; - *p++ = (short) hb_parni(1,13) ; - *p++ = (short) hb_parni(1,14) ; - - nchar = nCopyAnsiToWideChar( p, TEXT( hb_parc(1,15) ) ) ; - p += nchar ; - } ; - - //--------------- - // Now, for the items - - for ( i = 1 ; i <= nItems ; i++ ) { - // make sure each item starts on a DWORD boundary - p = lpwAlign (p) ; - - *p++ = LOWORD ( hb_parnl(2,i) ) ; // help id - *p++ = HIWORD ( hb_parnl(2,i) ) ; - - *p++ = LOWORD ( hb_parnl(3,i) ) ; // ext. style - *p++ = HIWORD ( hb_parnl(3,i) ) ; - - *p++ = LOWORD ( hb_parnl(4,i) ) ; // style - *p++ = HIWORD ( hb_parnl(4,i) ) ; - - *p++ = (short) hb_parni(5,i) ; // x - *p++ = (short) hb_parni(6,i) ; // y - *p++ = (short) hb_parni(7,i) ; // cx - *p++ = (short) hb_parni(8,i) ; // cy - - *p++ = LOWORD ( hb_parnl(9,i) ) ; // id - *p++ = HIWORD ( hb_parnl(9,i) ) ; // id // 0; - - if ( hb_parinfa( 10,i ) == HB_IT_STRING ) - { - nchar = nCopyAnsiToWideChar( p, TEXT( hb_parc( 10,i ) ) ) ; // class - p += nchar ; - } - else - { - *p++ = 0xFFFF ; - *p++ = (WORD) hb_parni(10,i) ; - } - - if ( hb_parinfa( 11,i ) == HB_IT_STRING ) - { - nchar = nCopyAnsiToWideChar( p, ( LPSTR ) hb_parc( 11,i ) ) ; // text - p += nchar ; - } - else - { - *p++ = 0xFFFF ; - *p++ = (WORD) hb_parni(11,i) ; - } - - *p++ = 0x00 ; // extras ( in array 12 ) - } ; - - p = lpwAlign( p ) ; - - hb_retclen( ( LPSTR ) pdlgtemplate, ( ( ULONG ) p - ( ULONG ) pdlgtemplate ) ) ; - - LocalFree( LocalHandle( pdlgtemplate ) ) ; -} - -//-------------------------------------------------------------------// -// -// Helper routine. Take an input pointer, return closest -// pointer that is aligned on a DWORD (4 byte) boundary. -// -HB_EXPORT LPWORD lpwAlign( LPWORD lpIn ) -{ - ULONG ul; - ul = ( ULONG ) lpIn; - ul += 3; - ul >>=2; - ul <<=2; - return ( LPWORD ) ul; -} - -//----------------------------------------------------------------------------- - -HB_EXPORT int nCopyAnsiToWideChar( LPWORD lpWCStr, LPSTR lpAnsiIn ) -{ - int nChar = 0; - - do - { - *lpWCStr++ = ( WORD ) *lpAnsiIn; - nChar++; - } - while ( *lpAnsiIn++ ); - - return nChar; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_LBADDSTRING ) -{ - SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), LB_ADDSTRING, 0, ( LPARAM )( LPSTR ) hb_parc( 3 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_LBGETCOUNT ) -{ - hb_retnl( SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), LB_GETCOUNT, 0, 0 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_LBDELETESTRING ) -{ - SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), LB_DELETESTRING, hb_parni( 3 ), 0 ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_LBSETCURSEL ) -{ - SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), LB_SETCURSEL, hb_parni( 3 ), 0 ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CBADDSTRING ) -{ - SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), CB_ADDSTRING, 0, ( LPARAM )( LPSTR ) hb_parc( 3 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WVT_CBSETCURSEL ) -{ - SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), CB_SETCURSEL, hb_parni( 3 ), 0 ); -} - -//-------------------------------------------------------------------// -// -// Wvt_DlgSetIcon( hDlg, ncIcon ) -// -HB_FUNC( WVT_DLGSETICON ) -{ - HICON hIcon; - - if ( ISNUM( 2 ) ) - { - hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, MAKEINTRESOURCE( hb_parni( 2 ) ) ); - } - else - { - hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 2 ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); - } - - if ( hIcon ) - { - SendMessage( ( HWND ) hb_parnl( 1 ), WM_SETICON, ICON_SMALL, ( LPARAM ) hIcon ); // Set Title Bar ICON - SendMessage( ( HWND ) hb_parnl( 1 ), WM_SETICON, ICON_BIG, ( LPARAM ) hIcon ); // Set Task List Icon - } - - if ( hIcon ) - { - hb_retnl( ( ULONG ) hIcon ); - } -} - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -// -// Direct WinApi Functions - Prefixed WIN_*() -// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SENDMESSAGE ) -{ - char *cText ; - - if( ISBYREF( 4 ) ) - { - cText = ( char* ) hb_xgrab( hb_parcsiz( 4 ) ); - hb_xmemcpy( cText, hb_parc( 4 ), hb_parcsiz( 4 ) ); - } - - hb_retnl( ( ULONG ) SendMessage( ( HWND ) hb_parnl( 1 ), - ( UINT ) hb_parni( 2 ), - ( ISNIL( 3 ) ? 0 : ( WPARAM ) hb_parnl( 3 ) ), - ( ISNIL( 4 ) ? 0 : ( ISBYREF( 4 ) ? ( LPARAM ) ( LPSTR ) cText : - ( ISCHAR( 4 ) ? ( LPARAM )( LPSTR ) hb_parc( 4 ) : - ( LPARAM ) hb_parnl( 4 ) ) ) ) ) - ); - - if ( ISBYREF( 4 ) ) - { - hb_storclen( cText, hb_parcsiz( 4 ), 4 ); - hb_xfree( cText ); - } -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SENDDLGITEMMESSAGE ) -{ - char *cText; - PHB_ITEM pText = hb_param( 5, HB_IT_STRING ); - - if( pText ) - { - cText = ( char* ) hb_xgrab( hb_itemGetCLen( pText ) + 1 ); - hb_xmemcpy( cText, hb_itemGetC( pText ), hb_itemGetCLen( pText ) + 1 ); - } - else - { - cText = NULL; - } - - hb_retnl( ( LONG ) SendDlgItemMessage( ( HWND ) hb_parnl( 1 ) , - ( int ) hb_parni( 2 ) , - ( UINT ) hb_parni( 3 ) , - ( ISNIL( 4 ) ? 0 : ( WPARAM ) hb_parnl( 4 ) ), - ( cText ? ( LPARAM ) cText : ( LPARAM ) hb_parnl( 5 ) ) - ) - ); - - if( pText ) - { - hb_storclen( cText, hb_itemGetCLen( pText ), 5 ) ; - } - - if( cText ) - { - hb_xfree( cText ); - } -} - -//-------------------------------------------------------------------// -// -// WIN_SetTimer( hWnd, nIdentifier, nTimeOut ) -// -HB_FUNC( WIN_SETTIMER ) -{ - hb_retl( SetTimer( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), hb_parni( 3 ), NULL ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SETFOCUS ) -{ - SetFocus( ( HWND ) hb_parnl( 1 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SETTEXTCOLOR ) -{ - hb_retnl( ( ULONG ) SetTextColor( ( HDC ) hb_parnl( 1 ), ( COLORREF ) hb_parnl( 2 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SETBKCOLOR ) -{ - hb_retnl( ( ULONG ) SetBkColor( ( HDC ) hb_parnl( 1 ), ( COLORREF ) hb_parnl( 2 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SETBKMODE ) -{ - hb_retni( ( int ) SetBkMode( ( HDC ) hb_parnl( 1 ), hb_parni( 2 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_GETSTOCKOBJECT ) -{ - hb_retnl( ( ULONG ) GetStockObject( hb_parnl( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_DELETEOBJECT ) -{ - hb_retl( DeleteObject( ( HGDIOBJ ) hb_parnl( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SELECTOBJECT ) -{ - hb_retnl( ( ULONG ) SelectObject( ( HDC ) hb_parnl( 1 ), ( HGDIOBJ ) hb_parnl( 2 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_LOWORD ) -{ - hb_retnl( LOWORD( hb_parnl( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_HIWORD ) -{ - hb_retnl( HIWORD( hb_parnl( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_MULDIV ) -{ - hb_retni( MulDiv( hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_GETDIALOGBASEUNITS ) -{ - hb_retnl( ( LONG ) GetDialogBaseUnits() ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SETMENU ) -{ - SetMenu( ( HWND ) hb_parnl( 1 ), ( HMENU ) hb_parni( 2 ) ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SETDLGITEMTEXT ) -{ - SetDlgItemText( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), hb_parc( 3 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_GETDLGITEMTEXT ) -{ - USHORT iLen = SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), WM_GETTEXTLENGTH, 0, 0 ) + 1 ; - char *cText = ( char* ) hb_xgrab( iLen ); - - GetDlgItemText( ( HWND ) hb_parnl( 1 ), // handle of dialog box - hb_parni( 2 ), // identifier of control - ( LPTSTR ) cText, // address of buffer for text - iLen // maximum size of string - ); - - hb_retc( cText ); - hb_xfree( cText ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_CHECKDLGBUTTON ) -{ - hb_retl( CheckDlgButton( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), - ( UINT )( ISNUM( 3 ) ? hb_parni( 3 ) : hb_parl( 3 ) ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_ISDLGBUTTONCHECKED ) -{ - hb_retni( IsDlgButtonChecked( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ) ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_CHECKRADIOBUTTON ) -{ - hb_retl( CheckRadioButton( ( HWND ) hb_parnl( 1 ), // handle of dialog box - hb_parni( 2 ), // identifier of first radio button in group - hb_parni( 3 ), // identifier of last radio button in group - hb_parni( 4 ) // identifier of radio button to select - ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_GETDLGITEM ) -{ - hb_retnl( ( ULONG ) GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_MESSAGEBOX ) -{ - hb_retni( MessageBox( ( HWND ) hb_parnl( 1 ), hb_parc( 2 ), hb_parc( 3 ), ISNIL( 4 ) ? MB_OK : hb_parni( 4 ) ) ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_INVALIDATERECT ) -{ - InvalidateRect( ( HWND ) hb_parnl( 1 ), NULL, TRUE ); -} - -//-------------------------------------------------------------------// -// -// Win_LoadIcon( ncIcon ) -// -HB_FUNC( WIN_LOADICON ) -{ - HICON hIcon; - - if ( ISNUM( 1 ) ) - { - hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, MAKEINTRESOURCE( hb_parni( 1 ) ) ); - } - else - { - hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 1 ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); - } - - hb_retnl( ( ULONG ) hIcon ) ; -} - -//-------------------------------------------------------------------// -// -// Win_LoadImage( ncImage, nSource ) -> hImage -// nSource == 0 ResourceIdByNumber -// nSource == 1 ResourceIdByName -// nSource == 2 ImageFromDiskFile -// -HB_FUNC( WIN_LOADIMAGE ) -{ - HBITMAP hImage; - int iSource = hb_parni( 2 ); - - switch ( iSource ) - { - case 0: - { - hImage = LoadBitmap( ( HINSTANCE ) hb_hInstance, MAKEINTRESOURCE( hb_parni( 1 ) ) ); - } - break; - - case 1: - { - hImage = LoadBitmap( ( HINSTANCE ) hb_hInstance, hb_parc( 1 ) ); - } - break; - - case 2: - { - hImage = ( HBITMAP ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 1 ), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); - } - break; - } - - hb_retnl( ( ULONG ) hImage ) ; -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_GETCLIENTRECT ) -{ - RECT rc = { 0,0,0,0 }; - PHB_ITEM info = hb_itemArrayNew( 4 ); - PHB_ITEM temp = hb_itemNew( NULL ); - - GetClientRect( ( HWND ) hb_parnl( 1 ), &rc ); - - hb_arraySet( info, 1, hb_itemPutNI( temp, rc.left ) ); - hb_arraySet( info, 2, hb_itemPutNI( temp, rc.top ) ); - hb_arraySet( info, 3, hb_itemPutNI( temp, rc.right ) ); - hb_arraySet( info, 4, hb_itemPutNI( temp, rc.bottom ) ); - - hb_itemRelease( temp ); - hb_itemReturn( info ); - hb_itemRelease( info ); -} - -//-------------------------------------------------------------------// -// -// Win_DrawImage( hdc, nLeft, nTop, nWidth, nHeight, cImage ) in Pixels -// -HB_FUNC( WIN_DRAWIMAGE ) -{ - hb_retl( hb_wvt_DrawImage( ( HDC ) hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ), - hb_parni( 4 ), hb_parni( 5 ), hb_parc( 6 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_GETDC ) -{ - hb_retnl( ( ULONG ) GetDC( ( HWND ) hb_parnl( 1 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_RELEASEDC ) -{ - hb_retl( ReleaseDC( ( HWND ) hb_parnl( 1 ), ( HDC ) hb_parnl( 2 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_RECTANGLE ) -{ - Rectangle( ( HDC ) hb_parnl( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_CREATEBRUSH ) -{ - LOGBRUSH lb = { 0,0,0 }; - - lb.lbStyle = hb_parni( 1 ); - lb.lbColor = ISNIL( 2 ) ? RGB( 0,0,0 ) : ( COLORREF ) hb_parnl( 2 ) ; - lb.lbHatch = ISNIL( 3 ) ? 0 : hb_parni( 3 ); - - hb_retnl( ( ULONG ) CreateBrushIndirect( &lb ) ); -} - -//-------------------------------------------------------------------// -// -// Win_DrawText( hDC, cText, aRect, nFormat ) -// -HB_FUNC( WIN_DRAWTEXT ) -{ - RECT rc = { 0,0,0,0 }; - - rc.left = hb_parni( 3,1 ); - rc.top = hb_parni( 3,2 ); - rc.right = hb_parni( 3,3 ); - rc.bottom = hb_parni( 3,4 ); - - hb_retl( DrawText( ( HDC ) hb_parnl( 1 ), hb_parc( 2 ), strlen( hb_parc( 2 ) ), &rc, hb_parni( 4 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_GETWINDOWRECT ) -{ - RECT rc; - PHB_ITEM info = hb_itemArrayNew( 4 ); - PHB_ITEM temp = hb_itemNew( NULL ); - - GetWindowRect( ( HWND ) hb_parnl( 1 ), &rc ); - - hb_arraySet( info, 1, hb_itemPutNI( temp, rc.left ) ); - hb_arraySet( info, 2, hb_itemPutNI( temp, rc.top ) ); - hb_arraySet( info, 3, hb_itemPutNI( temp, rc.right ) ); - hb_arraySet( info, 4, hb_itemPutNI( temp, rc.bottom ) ); - - hb_itemRelease( temp ); - hb_itemReturn( info ); - hb_itemRelease( info ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_MOVEWINDOW ) -{ - MoveWindow( (HWND) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ), hb_parnl( 5 ), hb_parl( 6 ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SETPARENT ) -{ - hb_retnl( ( long ) SetParent( (HWND) hb_parnl( 1 ), (HWND) hb_parnl( 2 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_SETWINDOWLONG ) -{ - hb_retnl( SetWindowLong( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), hb_parnl( 3 ) ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_ISWINDOW ) -{ - hb_retl( IsWindow( (HWND) hb_parnl( 1 ) ) ); -} - -//----------------------------------------------------------------------// - -HB_FUNC( WVT_GETFONTHANDLE ) -{ - HFONT hFont; - int iSlot = hb_parni( 1 )-1; - - if ( iSlot >= 0 && iSlot < WVT_PICTURES_MAX ) - { - hFont = _s->hUserFonts[ iSlot ]; - } - - hb_retnl( ( ULONG ) hFont ); -} - -//----------------------------------------------------------------------// - -HB_FUNC( WIN_CLIENTTOSCREEN ) -{ - POINT Point ; - PHB_ITEM pArray = hb_param( 2 , HB_IT_ARRAY ); - - if ( wvt_Array2Point( pArray ,&Point ) ) - { - if ( ClientToScreen( (HWND) hb_parnl( 1 ), &Point ) ) - { - wvt_Point2ArrayEx( &Point, pArray ); - hb_retl( TRUE ) ; - } - else - { - hb_retl( FALSE ) ; - } - } - else - { - hb_retl( FALSE ) ; - } -} - -//----------------------------------------------------------------------// - -HB_FUNC( WIN_SCREENTOCLIENT ) -{ - POINT Point ; - PHB_ITEM pArray = hb_param( 2 , HB_IT_ARRAY ); - - if ( wvt_Array2Point( pArray, &Point ) ) - { - if( ScreenToClient( (HWND) hb_parnl( 1 ), &Point ) > 0 ) - { - wvt_Point2ArrayEx( &Point, pArray ); - hb_retl( TRUE ) ; - } - else - { - hb_retl( FALSE ) ; - } - } - else - { - hb_retl( FALSE ) ; - } -} - -//----------------------------------------------------------------------// -//----------------------------------------------------------------------// -//----------------------------------------------------------------------// -// -// Utility Functions - Not API -// -//----------------------------------------------------------------------// -//----------------------------------------------------------------------// -//----------------------------------------------------------------------// - -BOOL wvt_Array2Rect(PHB_ITEM aRect, RECT *rc ) -{ - if (HB_IS_ARRAY(aRect) && hb_arrayLen(aRect) == 4) { - rc->left = hb_arrayGetNL(aRect,1); - rc->top = hb_arrayGetNL(aRect,2); - rc->right = hb_arrayGetNL(aRect,3); - rc->bottom = hb_arrayGetNL(aRect,4); - return TRUE ; - } - return FALSE; -} - -//----------------------------------------------------------------------// - -PHB_ITEM wvt_Rect2Array( RECT *rc ) -{ - PHB_ITEM aRect = hb_itemArrayNew( 4 ); - PHB_ITEM element = hb_itemNew( NULL ); - - hb_arraySet(aRect, 1, hb_itemPutNL( element, rc->left )); - hb_arraySet(aRect, 2, hb_itemPutNL( element, rc->top )); - hb_arraySet(aRect, 3, hb_itemPutNL( element, rc->right )); - hb_arraySet(aRect, 4, hb_itemPutNL( element, rc->bottom )); - hb_itemRelease(element); - return aRect; -} - - -//----------------------------------------------------------------------// - -BOOL wvt_Array2Point(PHB_ITEM aPoint, POINT *pt ) -{ - if (HB_IS_ARRAY(aPoint) && hb_arrayLen(aPoint) == 2) { - pt->x = hb_arrayGetNL(aPoint,1); - pt->y = hb_arrayGetNL(aPoint,2); - return TRUE ; - } - return FALSE; -} - -//----------------------------------------------------------------------// - -PHB_ITEM wvt_Point2Array( POINT *pt ) -{ - PHB_ITEM aPoint = hb_itemArrayNew(2); - PHB_ITEM element = hb_itemNew(NULL); - - hb_arraySet(aPoint, 1, hb_itemPutNL(element, pt->x)); - hb_arraySet(aPoint, 2, hb_itemPutNL(element, pt->y)); - hb_itemRelease(element); - return aPoint; -} - -//----------------------------------------------------------------------// - -BOOL wvt_Array2Size(PHB_ITEM aSize, SIZE *siz ) -{ - if (HB_IS_ARRAY(aSize) && hb_arrayLen(aSize) == 2) { - siz->cx = hb_arrayGetNL(aSize,1); - siz->cy = hb_arrayGetNL(aSize,2); - return TRUE ; - } - return FALSE; -} - -//----------------------------------------------------------------------// - -PHB_ITEM wvt_Size2Array( SIZE *siz ) -{ - PHB_ITEM aSize = hb_itemArrayNew(2); - PHB_ITEM element = hb_itemNew(NULL); - - hb_arraySet(aSize, 1, hb_itemPutNL(element, siz->cx)); - hb_arraySet(aSize, 2, hb_itemPutNL(element, siz->cy)); - hb_itemRelease(element); - return aSize; -} - -//----------------------------------------------------------------------// - -void wvt_Rect2ArrayEx( RECT *rc ,PHB_ITEM aRect ) -{ - PHB_ITEM element = hb_itemNew(NULL); - - hb_arraySet(aRect, 1, hb_itemPutNL(element, rc->left)); - hb_arraySet(aRect, 2, hb_itemPutNL(element, rc->top)); - hb_arraySet(aRect, 3, hb_itemPutNL(element, rc->right)); - hb_arraySet(aRect, 4, hb_itemPutNL(element, rc->bottom)); - hb_itemRelease(element); -} - -//----------------------------------------------------------------------// - -void wvt_Point2ArrayEx( POINT *pt, PHB_ITEM aPoint) -{ - - PHB_ITEM element = hb_itemNew(NULL); - - hb_arraySet(aPoint, 1, hb_itemPutNL(element, pt->x)); - hb_arraySet(aPoint, 2, hb_itemPutNL(element, pt->y)); - hb_itemRelease(element); -} - -//----------------------------------------------------------------------// - -void wvt_Size2ArrayEx( SIZE *siz, PHB_ITEM aSize ) -{ - PHB_ITEM element = hb_itemNew(NULL); - - hb_arraySet(aSize, 1, hb_itemPutNL(element, siz->cx)); - hb_arraySet(aSize, 2, hb_itemPutNL(element, siz->cy)); - hb_itemRelease(element); -} - -//----------------------------------------------------------------------// - -HB_FUNC( WVT__GETOPENFILENAME ) -{ - int size = ( ISNIL( 2 ) ? 1024 : hb_parcsiz( 2 ) ); - OPENFILENAME ofn ; - - char * szFileName = ( char* ) hb_xgrab( size ); - - strcpy( szFileName, ( ISNIL( 2 ) ? "" : hb_parc( 2 ) ) ); - - ZeroMemory( &ofn, sizeof( ofn ) ); - - ofn.hInstance = GetModuleHandle( NULL ) ; - ofn.lStructSize = sizeof( ofn ); - ofn.hwndOwner = ISNIL (1) ? GetActiveWindow() : ( HWND ) hb_parnl( 1 ) ; - ofn.lpstrTitle = ISNIL (3) ? NULL : hb_parc ( 3 ) ; - ofn.lpstrFilter = ISNIL (4) ? NULL : hb_parc ( 4 ); - ofn.Flags = ISNIL (5) ? OFN_SHOWHELP|OFN_NOCHANGEDIR : hb_parnl( 5 ) ; - ofn.lpstrInitialDir = ISNIL (6) ? NULL : hb_parc ( 6 ); - ofn.lpstrDefExt = ISNIL (7) ? NULL : hb_parc ( 7 ); - ofn.nFilterIndex = ISNIL (8) ? 0 : (int) hb_parni( 8 ); - ofn.lpstrFile = szFileName; - ofn.nMaxFile = size; - - if( GetOpenFileName( &ofn ) ) - { - hb_stornl( ofn.nFilterIndex, 8 ); - hb_storclen( szFileName, size, 2 ) ; - hb_retclen( ( char * ) ofn.lpstrFile, size ); - } - else - { - hb_retc( "" ); - } - hb_xfree( szFileName ); -} - -//----------------------------------------------------------------------// - -HB_FUNC( WVT__GETSAVEFILENAME ) -{ - HINSTANCE hInstance; - OPENFILENAME ofn; - char szFileName[ MAX_PATH+1 ] ; - - hInstance = GetModuleHandle( NULL ); - - strcpy( szFileName, hb_parc( 2 ) ); - - ZeroMemory( &ofn, sizeof( ofn ) ); - - ofn.hInstance = hInstance ; - ofn.lStructSize = sizeof( ofn ); - ofn.hwndOwner = ISNIL (1) ? GetActiveWindow() : (HWND) hb_parnl( 1 ); - ofn.lpstrTitle = hb_parc (3); - ofn.lpstrFilter = hb_parc (4); - ofn.Flags = (ISNIL (5) ? OFN_FILEMUSTEXIST|OFN_EXPLORER|OFN_NOCHANGEDIR : hb_parnl( 4 ) ); - ofn.lpstrInitialDir = hb_parc (6); - ofn.lpstrDefExt = hb_parc (7); - ofn.nFilterIndex = hb_parni(8); - ofn.lpstrFile = szFileName; - ofn.nMaxFile = MAX_PATH; - - if( GetSaveFileName( &ofn ) ) - { - hb_stornl( ofn.nFilterIndex, 8 ); - hb_retc( ofn.lpstrFile ); - } - else - { - hb_retc( "" ); - } -} -//----------------------------------------------------------------------// - -HB_FUNC( WIN_AND ) -{ - hb_retnl( hb_parnl(1) & hb_parnl(2) ) ; -} - -//----------------------------------------------------------------------// - -HB_FUNC( WIN_OR ) -{ - hb_retnl( hb_parnl(1) | hb_parnl(2) ) ; -} - -//----------------------------------------------------------------------// - -HB_FUNC( WIN_NOT ) -{ - hb_retnl( ~( hb_parnl(1) ) ) ; -} - -//----------------------------------------------------------------------// - -HB_FUNC( WIN_TRACKPOPUPMENU ) -{ - HMENU hMenu = ( HMENU ) hb_parnl( 1 ); - UINT uFlags = ISNIL( 2 ) ? TPM_CENTERALIGN | TPM_RETURNCMD : hb_parnl( 2 ); - HWND hWnd = ISNIL( 3 ) ? GetActiveWindow() : ( HWND ) hb_parnl( 3 ); - - POINT xy = { 0,0 }; - - GetCursorPos( &xy ); - - hb_retnl( TrackPopupMenu( hMenu, uFlags, xy.x, xy.y, 0, hWnd, NULL ) ); -} - -//-------------------------------------------------------------------// - -HB_FUNC( WIN_CHOOSECOLOR ) -{ - CHOOSECOLOR cc ; - COLORREF crCustClr[ 16 ] ; - int i ; - - for( i = 0 ; i < 16 ; i++ ) - { - crCustClr[ i ] = ( ISARRAY( 2 ) ? ( COLORREF ) hb_parnl( 2, i+1 ) : GetSysColor( COLOR_BTNFACE ) ) ; - } - - cc.lStructSize = sizeof( CHOOSECOLOR ) ; - cc.hwndOwner = ISNIL( 4 ) ? NULL : (HWND) hb_parnl( 4 ); - cc.rgbResult = ISNIL( 1 ) ? 0 : ( COLORREF ) hb_parnl( 1 ) ; - cc.lpCustColors = crCustClr ; - cc.Flags = ( WORD ) ( ISNIL( 3 ) ? CC_ANYCOLOR | CC_RGBINIT | CC_FULLOPEN : hb_parnl( 3 ) ); - - if ( ChooseColor( &cc ) ) - { - hb_retnl( cc.rgbResult ) ; - } - else - { - hb_retnl( -1 ); - } -} - -//-------------------------------------------------------------------// - - +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Video subsystem for Win32 using GUI windows instead of Console + * + * Copyright 2007 Pritpal Bedi + * based on: + * + * Copyright 2003 Peter Rees + * Rees Software & Systems Ltd + * based on + * Bcc ConIO Video subsystem by + * Copyright 2002 Marek Paliwoda + * Copyright 2002 Przemyslaw Czerpak + * Video subsystem for Win32 compilers + * Copyright 1999-2000 Paul Tucker + * Copyright 2002 Przemysław Czerpak + * + * The following parts are Copyright of the individual authors. + * www - http://www.harbour-project.org + * + * + * Copyright 1999 David G. Holm + * hb_gt_Tone() + * + * See doc/license.txt for licensing terms. + * + * www - 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. + * + */ + +//-------------------------------------------------------------------// + +#define HB_OS_WIN_32_USED + +//-------------------------------------------------------------------// + +#include "gtwvt.h" + +/* workaround for missing declaration in MinGW32 */ +#if !defined(TTM_SETTITLE) && defined(TTM_SETTITLEA) + #define TTM_SETTITLE TTM_SETTITLEA +#endif + +//-------------------------------------------------------------------// + +static GLOBAL_DATA *_s = NULL; + +//-------------------------------------------------------------------// + +HB_EXTERN_BEGIN + +extern HANDLE hb_hInstance; + +extern BOOL wvt_Array2Rect(PHB_ITEM aRect, RECT *rc ); +extern PHB_ITEM wvt_Rect2Array( RECT *rc ); +extern BOOL wvt_Array2Point(PHB_ITEM aPoint, POINT *pt ); +extern PHB_ITEM wvt_Point2Array( POINT *pt ); +extern BOOL wvt_Array2Size(PHB_ITEM aSize, SIZE *siz ); +extern PHB_ITEM wvt_Size2Array( SIZE *siz ); +extern void wvt_Rect2ArrayEx( RECT *rc ,PHB_ITEM aRect ); +extern void wvt_Point2ArrayEx( POINT *pt , PHB_ITEM aPoint); +extern void wvt_Size2ArrayEx( SIZE *siz ,PHB_ITEM aSize ); + +HB_EXTERN_END + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Pritpal Bedi +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +void HB_EXPORT hb_wvt_wvtUtils( void ) +{ + _s = hb_wvt_gtGetGlobalData(); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_UTILS ) +{ + hb_wvt_wvtUtils(); +} + +//-------------------------------------------------------------------// +// +// Wvt_ChooseFont( cFontName, nHeight, nWidth, nWeight, nQuality, ; +// lItalic, lUnderline, lStrikeout ) +// +HB_FUNC( WVT_CHOOSEFONT ) +{ + CHOOSEFONT cf;// = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + LOGFONT lf;// = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0 }; + LONG PointSize = 0; + + if ( ! ISNIL( 2 ) ) + { + PointSize = -MulDiv( ( LONG ) hb_parnl( 2 ), GetDeviceCaps( _s->hdc, LOGPIXELSY ), 72 ) ; + } + + lf.lfHeight = PointSize; + lf.lfWidth = ISNIL( 3 ) ? 0 : hb_parni( 3 ); + lf.lfWeight = ISNIL( 4 ) ? 0 : hb_parni( 4 ); + lf.lfItalic = ISNIL( 6 ) ? 0 : hb_parl( 6 ); + lf.lfUnderline = ISNIL( 7 ) ? 0 : hb_parl( 7 ); + lf.lfStrikeOut = ISNIL( 8 ) ? 0 : hb_parl( 8 ); + lf.lfCharSet = DEFAULT_CHARSET; + lf.lfQuality = ISNIL( 5 ) ? DEFAULT_QUALITY : hb_parni( 5 ); + lf.lfPitchAndFamily = FF_DONTCARE; + if ( ISCHAR( 1 ) ) + { + strcpy( lf.lfFaceName, hb_parc( 1 ) ); + } + + cf.lStructSize = sizeof( CHOOSEFONT ); + cf.hwndOwner = _s->hWnd; + cf.hDC = ( HDC ) NULL; + cf.lpLogFont = &lf; + cf.iPointSize = 0; + cf.Flags = CF_SCREENFONTS | CF_EFFECTS | CF_SHOWHELP | CF_INITTOLOGFONTSTRUCT ; + cf.rgbColors = RGB( 0,0,0 ); + cf.lCustData = 0L; + cf.lpfnHook = ( LPCFHOOKPROC ) NULL; + cf.lpTemplateName = ( LPSTR ) NULL; + cf.hInstance = ( HINSTANCE ) NULL; + cf.lpszStyle = ( LPSTR ) NULL; + cf.nFontType = SCREEN_FONTTYPE; + cf.nSizeMin = 0; + cf.nSizeMax = 0; + + if ( ChooseFont( &cf ) ) + { + PointSize = -MulDiv( lf.lfHeight, 72, GetDeviceCaps( _s->hdc, LOGPIXELSY ) ) ; + + hb_reta( 8 ); + + hb_storc( lf.lfFaceName , -1, 1 ); + hb_stornl( ( LONG ) PointSize, -1, 2 ); + hb_storni( lf.lfWidth , -1, 3 ); + hb_storni( lf.lfWeight , -1, 4 ); + hb_storni( lf.lfQuality , -1, 5 ); + hb_storl( lf.lfItalic , -1, 6 ); + hb_storl( lf.lfUnderline , -1, 7 ); + hb_storl( lf.lfStrikeOut , -1, 8 ); + } + else + { + hb_reta( 8 ); + + hb_storc( "" , -1, 1 ); + hb_stornl( ( LONG ) 0, -1, 2 ); + hb_storni( 0 , -1, 3 ); + hb_storni( 0 , -1, 4 ); + hb_storni( 0 , -1, 5 ); + hb_storl( 0 , -1, 6 ); + hb_storl( 0 , -1, 7 ); + hb_storl( 0 , -1, 8 ); + } + + return ; +} + +//-------------------------------------------------------------------// +// +// Wvt_ChooseColor( nRGBInit, aRGB16, nFlags ) => nRGBSelected +// +HB_FUNC( WVT_CHOOSECOLOR ) +{ + CHOOSECOLOR cc ; + COLORREF crCustClr[ 16 ] ; + int i ; + + for( i = 0 ; i < 16 ; i++ ) + { + crCustClr[ i ] = ( ISARRAY( 2 ) ? ( COLORREF ) hb_parnl( 2, i+1 ) : GetSysColor( COLOR_BTNFACE ) ) ; + } + + cc.lStructSize = sizeof( CHOOSECOLOR ) ; + cc.hwndOwner = _s->hWnd ; + cc.rgbResult = ISNIL( 1 ) ? 0 : ( COLORREF ) hb_parnl( 1 ) ; + cc.lpCustColors = crCustClr ; + cc.Flags = ( WORD ) ( ISNIL( 3 ) ? CC_ANYCOLOR | CC_RGBINIT | CC_FULLOPEN : hb_parnl( 3 ) ); + + if ( ChooseColor( &cc ) ) + { + hb_retnl( cc.rgbResult ) ; + } + else + { + hb_retnl( -1 ); + } +} + +//-------------------------------------------------------------------// +// +// Wvt_MessageBox( cMessage, cTitle, nIcon, hWnd ) +// +HB_FUNC( WVT_MESSAGEBOX ) +{ + hb_retni( MessageBox( _s->hWnd, hb_parc( 1 ), hb_parc( 2 ), ISNIL( 3 ) ? MB_OK : hb_parni( 3 ) ) ) ; +} + +//-------------------------------------------------------------------// +//#if _WIN32_IE > 0x400 +//-------------------------------------------------------------------// +// +// Tooltips +// +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTOOLTIPACTIVE ) +{ + BOOL bActive = _s->bToolTipActive; + + if ( ! ISNIL( 1 ) ) + { + _s->bToolTipActive = hb_parl( 1 ); + } + + hb_retl( bActive ); +} + +//-------------------------------------------------------------------// +// +// Wvt_SetToolTip( nTop, nLeft, nBottom, nRight, cToolText ) +// +HB_FUNC( WVT_SETTOOLTIP ) +{ + TOOLINFO ti;// = { 0,0,0,0,0,0,0,0 }; + POINT xy = { 0,0 }; + int iTop, iLeft, iBottom, iRight; + + if ( ! _s->bToolTipActive ) + { + return; + } + + ti.cbSize = sizeof( TOOLINFO ); + ti.hwnd = _s->hWnd; + ti.uId = 100000; + + if ( SendMessage( _s->hWndTT, TTM_GETTOOLINFO, 0, ( LPARAM ) &ti ) ) + { + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + iTop = xy.y; + iLeft = xy.x; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); + iBottom = xy.y - 1; + iRight = xy.x - 1; + + ti.lpszText = hb_parc( 5 ); + ti.rect.left = iLeft; + ti.rect.top = iTop; + ti.rect.right = iRight; + ti.rect.bottom = iBottom; + + SendMessage( _s->hWndTT, TTM_SETTOOLINFO, 0, ( LPARAM ) &ti ); + } +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTOOLTIPTEXT ) +{ + TOOLINFO ti; + + ti.cbSize = sizeof( TOOLINFO ); + ti.hwnd = _s->hWnd; + ti.uId = 100000; + + if ( SendMessage( _s->hWndTT, TTM_GETTOOLINFO, 0, ( LPARAM ) &ti ) ) + { + ti.lpszText = hb_parc( 1 ); + SendMessage( _s->hWndTT, TTM_UPDATETIPTEXT, 0, ( LPARAM ) &ti ); + } +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTOOLTIPMARGIN ) +{ + /* + RECT rc = { 0,0,0,0 }; + int iTtm = TTM_SETMARGIN; + + rc.left = hb_parni( 2 ); + rc.top = hb_parni( 1 ); + rc.right = hb_parni( 4 ); + rc.bottom = hb_parni( 3 ); + + SendMessage( _s->hWndTT, iTtm, 0, ( LPARAM ) &rc ); + */ +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTOOLTIPWIDTH ) +{ + /* + int iTipWidth = SendMessage( _s->hWndTT, TTM_GETMAXTIPWIDTH, 0, 0 ); + + if ( ISNUM( 1 ) ) + { + SendMessage( _s->hWndTT, TTM_SETMAXTIPWIDTH, 0, ( LPARAM ) ( int ) hb_parni( 1 ) ); + } + + hb_retni( iTipWidth ); + */ +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTOOLTIPBKCOLOR ) +{ + /* + COLORREF cr = SendMessage( _s->hWndTT, TTM_GETTIPBKCOLOR, 0, 0 ); + + if ( ISNUM( 1 ) ) + { + SendMessage( _s->hWndTT, TTM_SETTIPBKCOLOR, ( WPARAM ) ( COLORREF ) hb_parnl( 1 ), 0 ); + } + hb_retnl( ( COLORREF ) cr ); + */ +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTOOLTIPTEXTCOLOR ) +{ + /* + COLORREF cr = SendMessage( _s->hWndTT, TTM_GETTIPTEXTCOLOR, 0, 0 ); + + if ( ISNUM( 1 ) ) + { + SendMessage( _s->hWndTT, TTM_SETTIPTEXTCOLOR, ( WPARAM ) ( COLORREF ) hb_parnl( 1 ), 0 ); + } + + hb_retnl( ( COLORREF ) cr ); + */ +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTOOLTIPTITLE ) +{ + /* + int iIcon; + + if ( ! ISNIL( 2 ) ) + { + iIcon = ISNIL( 1 ) ? 0 : hb_parni( 1 ); + if ( iIcon > 3 ) + { + iIcon = 0 ; + } + SendMessage( _s->hWndTT, TTM_SETTITLE, ( WPARAM ) iIcon, ( LPARAM ) hb_parc( 2 ) ); + } + */ +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETTOOLTIPWIDTH ) +{ + //hb_retni( SendMessage( _s->hWndTT, TTM_GETMAXTIPWIDTH, 0, 0 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETTOOLTIPBKCOLOR ) +{ + //hb_retnl( ( COLORREF ) SendMessage( _s->hWndTT, TTM_GETTIPBKCOLOR, 0, 0 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETTOOLTIPTEXTCOLOR ) +{ + //hb_retnl( ( COLORREF ) SendMessage( _s->hWndTT, TTM_GETTIPTEXTCOLOR, 0, 0 ) ); +} + +//-------------------------------------------------------------------// +//#endif +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETGUI ) +{ + BOOL bGui = _s->bGui; + + if ( ! ISNIL( 1 ) ) + { + _s->bGui = hb_parl( 1 ); + } + + hb_retl( bGui ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTIMER ) +{ + hb_retl( SetTimer( _s->hWnd, hb_parni( 1 ), hb_parni( 2 ), NULL ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_KILLTIMER ) +{ + hb_retl( KillTimer( _s->hWnd, hb_parni( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETONTOP ) +{ + RECT rect = { 0,0,0,0 }; + + GetWindowRect( _s->hWnd, &rect ); + + hb_retl( SetWindowPos( _s->hWnd, HWND_TOPMOST, + rect.left, + rect.top, + 0, + 0, + SWP_NOSIZE + SWP_NOMOVE + SWP_NOACTIVATE ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETASNORMAL ) +{ + RECT rect = { 0,0,0,0 }; + + GetWindowRect( _s->hWnd, &rect ); + + hb_retl( SetWindowPos( _s->hWnd, HWND_NOTOPMOST, + rect.left, + rect.top, + 0, + 0, + SWP_NOSIZE + SWP_NOMOVE + SWP_NOACTIVATE ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_MINIMIZE ) +{ + ShowWindow( _s->hWnd, SW_MINIMIZE ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_MAXIMIZE ) +{ + ShowWindow( _s->hWnd, SW_RESTORE ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETMOUSEPOS ) +{ + POINT xy = { 0,0 }; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + + if ( ClientToScreen( _s->hWnd, &xy ) ) + { + hb_retl( SetCursorPos( xy.x, xy.y + ( _s->PTEXTSIZE.y / 2 ) ) ); + } + else + { + hb_retl( FALSE ); + } +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETPAINTRECT ) +{ + PHB_ITEM info = hb_itemArrayNew( 4 ); + PHB_ITEM temp = hb_itemNew( NULL ); + + hb_arraySet( info, 1, hb_itemPutNI( temp, _s->rowStart ) ); + hb_arraySet( info, 2, hb_itemPutNI( temp, _s->colStart ) ); + hb_arraySet( info, 3, hb_itemPutNI( temp, _s->rowStop ) ); + hb_arraySet( info, 4, hb_itemPutNI( temp, _s->colStop ) ); + + hb_itemRelease( temp ); + hb_itemReturn( info ); + hb_itemRelease( info ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETPOINTER ) +{ + int iCursor = hb_parni( 1 ); + HCURSOR hCursor; + + switch ( iCursor ) + { + case 1: + hCursor = LoadCursor( NULL, IDC_ARROW ); + break; + + case 2: + hCursor = LoadCursor( NULL, IDC_IBEAM ); + break; + + case 3: + hCursor = LoadCursor( NULL, IDC_WAIT ); + break; + + case 4: + hCursor = LoadCursor( NULL, IDC_CROSS ); + break; + + case 5: + hCursor = LoadCursor( NULL, IDC_UPARROW ); + break; + + case 6: + hCursor = LoadCursor( NULL, IDC_SIZE ); + break; + + case 7: + hCursor = LoadCursor( NULL, IDC_ICON ); + break; + + case 8: + hCursor = LoadCursor( NULL, IDC_SIZENWSE ); + break; + + case 9: + hCursor = LoadCursor( NULL, IDC_SIZENESW ); + break; + + case 10: + hCursor = LoadCursor( NULL, IDC_SIZEWE ); + break; + + case 11: + hCursor = LoadCursor( NULL, IDC_SIZENS ); + break; + + case 12: + hCursor = LoadCursor( NULL, IDC_SIZEALL ); + break; + + case 13: + hCursor = LoadCursor( NULL, IDC_NO ); + break; + + case 14: + hCursor = LoadCursor( NULL, IDC_HAND ); + break; + + case 15: + hCursor = LoadCursor( NULL, IDC_APPSTARTING ); + break; + + case 16: + hCursor = LoadCursor( NULL, IDC_HELP ); + break; + + default: + hCursor = LoadCursor( NULL, IDC_ARROW ); + break; + } + + SetClassLong( _s->hWnd, GCL_HCURSOR, ( DWORD ) hCursor ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETFONT ) +{ + hb_retl( hb_wvt_gtSetFont( + ISNIL( 1 ) ? _s->fontFace : hb_parc( 1 ), + ISNIL( 2 ) ? _s->fontHeight : hb_parni( 2 ), + ISNIL( 3 ) ? _s->fontWidth : hb_parni( 3 ), + ISNIL( 4 ) ? _s->fontWeight : hb_parni( 4 ), + ISNIL( 5 ) ? _s->fontQuality: hb_parni( 5 ) + ) ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETICON ) +{ + if ( ISNUM( 1 ) || ISCHAR( 2 ) ) + { + hb_retnl( hb_wvt_gtSetWindowIcon( hb_parni( 1 ), hb_parc( 2 ) ) ) ; + } + else + { + hb_retnl( hb_wvt_gtSetWindowIconFromFile( hb_parc( 1 ) ) ) ; + } +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETTITLE ) +{ + hb_wvt_gtSetWindowTitle( hb_parc( 1 ) ) ; + return ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETWINDOWPOS ) +{ + hb_wvt_gtSetWindowPos( hb_parni( 1 ), hb_parni( 2 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETWINDOWHANDLE ) +{ + hb_retnl( ( LONG ) hb_wvt_gtGetWindowHandle() ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETCODEPAGE ) +{ + hb_retni( hb_wvt_gtSetCodePage( hb_parni( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CENTERWINDOW ) +{ + hb_retl( hb_wvt_gtSetCentreWindow( + ISNIL( 1 ) ? TRUE : hb_parl( 1 ), + ISNIL( 2 ) ? FALSE : hb_parl( 2 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETMOUSEMOVE ) +{ + if ( ISNIL( 1 ) ) + { + hb_retl( _s->MouseMove ); + } + else + { + hb_retl( hb_wvt_gtSetMouseMove( hb_parl( 1 ) ) ); + } +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETXYFROMROWCOL ) +{ + PHB_ITEM info = hb_itemArrayNew( 2 ); + PHB_ITEM temp = hb_itemNew( NULL ); + POINT xy = { 0,0 }; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + + hb_arraySet( info, 1, hb_itemPutNL( temp, xy.x ) ); + hb_arraySet( info, 2, hb_itemPutNL( temp, xy.y ) ); + + hb_itemRelease( temp ); + hb_itemReturn( info ); + hb_itemRelease( info ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETFONTINFO ) +{ + PHB_ITEM info = hb_itemArrayNew( 7 ); + PHB_ITEM temp = hb_itemNew( NULL ); + + hb_arraySet( info, 1, hb_itemPutC( temp, _s->fontFace ) ); + hb_arraySet( info, 2, hb_itemPutNL( temp, _s->fontHeight ) ); + hb_arraySet( info, 3, hb_itemPutNL( temp, _s->fontWidth ) ); + hb_arraySet( info, 4, hb_itemPutNL( temp, _s->fontWeight ) ); + hb_arraySet( info, 5, hb_itemPutNL( temp, _s->fontQuality ) ); + hb_arraySet( info, 6, hb_itemPutNL( temp, _s->PTEXTSIZE.y ) ); + hb_arraySet( info, 7, hb_itemPutNL( temp, _s->PTEXTSIZE.x ) ); + + hb_itemRelease( temp ); + hb_itemReturn( info ); + hb_itemRelease( info ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETPALETTE ) +{ + PHB_ITEM info = hb_itemArrayNew( 16 ); + PHB_ITEM temp = hb_itemNew( NULL ); + int i; + + for ( i = 0; i < 16; i++ ) + { + hb_arraySet( info, i+1, hb_itemPutNL( temp, hb_wvt_gtGetColorData( i ) ) ); + } + hb_itemRelease( temp ); + hb_itemReturn( info ); + hb_itemRelease( info ); +} + +//-------------------------------------------------------------------// +// +// Wvt_SetPalette( aRGBValues ) -> An array of 16 elements with RGB values +// +HB_FUNC( WVT_SETPALETTE ) +{ + int i; + + for ( i = 0; i < 16; i++ ) + { + hb_wvt_gtSetColorData( i, hb_parnl( 1, i+1 ) ); + } +} + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Peter Rees +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETMENU ) +{ + SetMenu( _s->hWnd, ( HMENU ) hb_parni( 1 ) ) ; + + hb_wvt_gtResetWindow(); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETPOPUPMENU ) +{ + HMENU hPopup = _s->hPopup ; + + _s->hPopup = ( HMENU ) hb_parnl( 1 ); + if ( hPopup ) + { + hb_retnl( ( LONG ) hPopup ); + } +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CREATEMENU ) +{ + hb_retnl( ( LONG ) CreateMenu() ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CREATEPOPUPMENU ) +{ + hb_retnl( ( LONG ) CreatePopupMenu() ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_APPENDMENU ) +{ + char ucBuf[ 256 ]; + int i,iLen ; + LPCTSTR lpszCaption; + + if ( ISCHAR( 4 ) ) + { + iLen = hb_parclen( 4 ); + if ( iLen > 0 && iLen < 256 ) // Translate '~' to '&' + { + lpszCaption = hb_parc( 4 ) ; + for ( i = 0; i < iLen; i++ ) + { + ucBuf[ i ] = ( *lpszCaption == '~' ) ? '&' : *lpszCaption ; + lpszCaption++; + } + ucBuf[ iLen ]= '\0'; + lpszCaption = ucBuf ; + } + else + { + lpszCaption = hb_parc( 4 ) ; + } + } + else + { + lpszCaption = ( LPCTSTR ) hb_parni( 4 ) ; // It is a SEPARATOR or Submenu + } + + hb_retl( AppendMenu( ( HMENU ) hb_parnl( 1 ), ( UINT ) hb_parni( 2 ), ( UINT_PTR ) hb_parni( 3 ), ( LPCTSTR ) lpszCaption ) ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_DELETEMENU ) +{ + hb_retl( DeleteMenu( ( HMENU ) hb_parnl( 1 ), ( UINT ) hb_parni( 2 ), ( UINT ) hb_parni( 3 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_DESTROYMENU ) +{ + hb_retl( DestroyMenu( ( HMENU ) hb_parnl( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_ENABLEMENUITEM ) +{ + hb_retni( EnableMenuItem( ( HMENU ) hb_parnl( 1 ), ( UINT ) hb_parni( 2 ), ( UINT ) hb_parni( 3 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETLASTMENUEVENT ) +{ + hb_retni( hb_wvt_gtGetLastMenuEvent() ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETLASTMENUEVENT ) +{ + hb_retni( hb_wvt_gtSetLastMenuEvent( hb_parni(1) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETMENUKEYEVENT ) +{ + int iEvent = 0; + + if ( ISNUM( 1 ) ) + { + iEvent = hb_parnl( 1 ) ; + } + + hb_retni( hb_wvt_gtSetMenuKeyEvent( iEvent ) ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_DRAWMENUBAR ) +{ + DrawMenuBar( _s->hWnd ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETSCREENWIDTH ) +{ + hb_retni( GetSystemMetrics( SM_CXSCREEN ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETSCREENHEIGHT ) +{ + hb_retni( GetSystemMetrics( SM_CYSCREEN ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETWINDOWCENTRE ) +{ + hb_wvt_gtSetCentreWindow( hb_parl( 1 ), hb_parl( 2 ) ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETALTF4CLOSE ) +{ + hb_retl( hb_wvt_gtSetAltF4Close( hb_parl( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_PROCESSMESSAGES ) +{ + hb_wvt_gtDoProcessMessages(); + + hb_retl( 1 ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETTITLE ) +{ + BYTE ucText[ 1024 ]; + + hb_wvt_gtGetWindowTitle( ( char* ) ucText, 1023 ); + + hb_retc( ( char* ) ucText ) ; +} + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Author.....: Francesco Saverio Giudice +// Syntax.....: Wvt_GetRGBColor( nColor ) --> nRGBColor +// Description: Return the RGB values passing the color positional value +// 0=Black, 1=Blue, etc +// as returned from hb_ColorToN() +// Creat. Date: 2004/01/15 +// Last Modif.: 2004/01/15 +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETRGBCOLOR ) +{ + int iColor; + if ( !ISNIL( 1 ) ) + { + iColor = hb_parni( 1 ); + if ( iColor >= 0 && iColor < 16 ) /* Test bound error */ + { + hb_retnl( hb_wvt_gtGetColorData( iColor ) ); + } + } +} + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Giancarlo Niccolai +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETCLIPBOARD ) +{ + HGLOBAL hglb; + LPTSTR lptstr; + + if ( !IsClipboardFormatAvailable( CF_TEXT ) ) + { + hb_ret(); + } + + if ( !OpenClipboard( NULL ) ) + { + hb_ret(); + } + + hglb = GetClipboardData( CF_TEXT ); + if ( hglb != NULL ) + { + lptstr = ( LPSTR ) GlobalLock( hglb ); + if ( lptstr != NULL ) + { + hb_retc( lptstr ); + GlobalUnlock( hglb ); + } + } + CloseClipboard(); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SETCLIPBOARD ) +{ + LPTSTR lptstrCopy; + HGLOBAL hglbCopy; + char * cText; + int nLen; + + if ( !IsClipboardFormatAvailable( CF_TEXT ) ) + { + hb_retl( FALSE ); + return; + } + + // Check params + // + if ( ! ISCHAR( 1 ) ) + { + hb_retl( FALSE ); + return; + } + + if ( ! OpenClipboard( NULL ) ) + { + hb_retl( FALSE ); + return; + } + EmptyClipboard(); + + // Get text from PRG + // + cText = hb_parc( 1 ); + nLen = hb_parclen( 1 ); + + // Allocate a global memory object for the text. + // + hglbCopy = GlobalAlloc( GMEM_MOVEABLE, ( nLen+1 ) * sizeof( TCHAR ) ); + if ( hglbCopy == NULL ) + { + CloseClipboard(); + hb_retl( FALSE ); + return; + } + + // Lock the handle and copy the text to the buffer. + // + lptstrCopy = ( LPSTR ) GlobalLock( hglbCopy ); + memcpy( lptstrCopy, cText, ( nLen+1 ) * sizeof( TCHAR ) ); + lptstrCopy[ nLen+1 ] = ( TCHAR ) 0; // null character + GlobalUnlock( hglbCopy ); + + // Place the handle on the clipboard. + // + SetClipboardData( CF_TEXT, hglbCopy ); + + CloseClipboard(); + hb_retl( TRUE ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_PASTEFROMCLIPBOARD ) +{ + HGLOBAL hglb; + LPTSTR lptstr; + ULONG ul; + + if ( !IsClipboardFormatAvailable( CF_TEXT ) ) + { + hb_ret(); + } + + if ( !OpenClipboard( NULL ) ) + { + hb_ret(); + } + + hglb = GetClipboardData( CF_TEXT ); + if ( hglb != NULL ) + { + lptstr = ( LPSTR ) GlobalLock( hglb ); + if ( lptstr != NULL ) + { + for ( ul=0; ul < GlobalSize( hglb ); ul++ ) + { + hb_wvt_gtAddCharToInputQueue( ( int ) lptstr[ ul ] ); + } + GlobalUnlock( hglb ) ; + } + } + CloseClipboard(); +} + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +HB_FUNC( WVT_KEYBOARD ) +{ + hb_wvt_gtAddCharToInputQueue( hb_parnl( 1 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_INVALIDATERECT ) +{ + RECT rc = { 0,0,0,0 }; + POINT xy = { 0,0 }; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + rc.top = xy.y; + rc.left = xy.x; + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 4 )+1, hb_parni( 3 )+1 ); + rc.bottom = xy.y - 1; + rc.right = xy.x - 1; + + InvalidateRect( _s->hWnd, &rc, TRUE ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_ISLBUTTONPRESSED ) +{ + hb_retl( GetKeyState( VK_LBUTTON ) & 0x8000 ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CLIENTTOSCREEN ) +{ + PHB_ITEM info = hb_itemArrayNew( 2 ); + PHB_ITEM temp = hb_itemNew( NULL ); + POINT xy = { 0,0 }; + + xy = hb_wvt_gtGetXYFromColRow( hb_parni( 2 ), hb_parni( 1 ) ); + + ClientToScreen( _s->hWnd, &xy ); + + hb_arraySet( info, 1, hb_itemPutNL( temp, xy.x ) ); + hb_arraySet( info, 2, hb_itemPutNL( temp, xy.y ) ); + + hb_itemRelease( temp ); + hb_itemReturn( info ); + hb_itemRelease( info ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETCURSORPOS ) +{ + POINT xy = { 0,0 }; + PHB_ITEM info = hb_itemArrayNew( 2 ); + PHB_ITEM temp = hb_itemNew( NULL ); + + GetCursorPos( &xy ); + + hb_arraySet( info, 1, hb_itemPutNI( temp, xy.x ) ); + hb_arraySet( info, 2, hb_itemPutNI( temp, xy.y ) ); + + hb_itemRelease( temp ); + hb_itemReturn( info ); + hb_itemRelease( info ); + } + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_TRACKPOPUPMENU ) +{ + POINT xy = { 0,0 }; + + GetCursorPos( &xy ); + + hb_retnl( TrackPopupMenu( ( HMENU ) hb_parnl( 1 ) , + TPM_CENTERALIGN | TPM_RETURNCMD , + xy.x , + xy.y , + 0 , + _s->hWnd , + NULL ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_GETMENU ) +{ + hb_retnl( ( ULONG ) GetMenu( _s->hWnd ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_SHOWWINDOW ) +{ + ShowWindow( _s->hWnd, hb_parni( 1 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_UPDATEWINDOW ) +{ + UpdateWindow( _s->hWnd ); +} + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Dialogs +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CREATEDIALOGDYNAMIC ) +{ + PHB_ITEM pFirst = hb_param( 3,HB_IT_ANY ); + PHB_ITEM pFunc = NULL ; + PHB_DYNS pExecSym; + HWND hDlg ; + int iIndex; + int iType; + int iResource = hb_parni( 4 ); + + /* check if we still have room for a new dialog */ + for ( iIndex = 0; iIndex < WVT_DLGML_MAX; iIndex++ ) + { + if ( _s->hDlgModeless[ iIndex ] == NULL ) + { + break; + } + } + + if ( iIndex >= WVT_DLGML_MAX ) + { + /* no more room */ + hb_retnl( (ULONG) NULL ); + return; + } + + if ( HB_IS_BLOCK( pFirst ) ) + { + /* pFunc is pointing to stored code block (later) */ + pFunc = hb_itemNew( pFirst ); + iType = 2; + } + else if( hb_itemType( pFirst ) == HB_IT_STRING ) + { + #ifdef __XHARBOUR__ + hb_dynsymLock(); + #endif + pExecSym = hb_dynsymFindName( hb_itemGetC( pFirst ) ); + #ifdef __XHARBOUR__ + hb_dynsymUnlock(); + #endif + if ( pExecSym ) + { + pFunc = ( PHB_ITEM ) pExecSym; + } + iType = 1; + } + + { + if ( ISNUM( 3 ) ) + { + hDlg = CreateDialogIndirect( ( HINSTANCE ) hb_hInstance, + ( LPDLGTEMPLATE ) hb_parc( 1 ), + hb_parl( 2 ) ? _s->hWnd : NULL, + ( DLGPROC ) hb_parnl( 3 ) ); + } + else + { + switch ( iResource ) + { + case 0: + { + hDlg = CreateDialog( ( HINSTANCE ) hb_hInstance, + hb_parc( 1 ), + hb_parl( 2 ) ? _s->hWnd : NULL, + (DLGPROC) hb_wvt_gtDlgProcMLess ); + } + break; + + case 1: + { + hDlg = CreateDialog( ( HINSTANCE ) hb_hInstance, + MAKEINTRESOURCE( ( WORD ) hb_parni( 1 ) ), + hb_parl( 2 ) ? _s->hWnd : NULL, + (DLGPROC) hb_wvt_gtDlgProcMLess ); + } + break; + + case 2: + { + hDlg = CreateDialogIndirect( ( HINSTANCE ) hb_hInstance, + ( LPDLGTEMPLATE ) hb_parc( 1 ), + hb_parl( 2 ) ? _s->hWnd : NULL, + (DLGPROC) hb_wvt_gtDlgProcMLess ); + } + break; + } + } + + if ( hDlg ) + { + _s->hDlgModeless[ iIndex ] = hDlg; + + if ( pFunc ) + { + /* if codeblock, store the codeblock and lock it there */ + if (HB_IS_BLOCK( pFirst )) + { + _s->pcbFunc[ iIndex ] = pFunc; + } + + _s->pFunc[ iIndex ] = pFunc; + _s->iType[ iIndex ] = iType; + } + else + { + _s->pFunc[ iIndex ] = NULL; + _s->iType[ iIndex ] = 0; + } + SendMessage( hDlg, WM_INITDIALOG, 0, 0 ); + } + else + { + //if codeblock item created earlier, release it + if (iType==2 && pFunc) + { + hb_itemRelease( pFunc ); + } + _s->hDlgModeless[ iIndex ] = NULL; + } + } + + hb_retnl( ( ULONG ) hDlg ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CREATEDIALOGMODAL ) +{ + PHB_ITEM pFirst = hb_param( 3,HB_IT_ANY ); + PHB_ITEM pFunc = NULL ; + PHB_DYNS pExecSym; + int iIndex; + int iResource = hb_parni( 4 ); + int iResult = 0; + HWND hParent = ISNIL( 5 ) ? _s->hWnd : ( HWND ) hb_parnl( 5 ); + + /* check if we still have room for a new dialog */ + for ( iIndex = 0; iIndex < WVT_DLGMD_MAX; iIndex++ ) + { + if ( _s->hDlgModal[ iIndex ] == NULL ) + { + break; + } + } + + if ( iIndex >= WVT_DLGMD_MAX ) + { + /* no more room */ + hb_retni( ( int ) NULL ); + return; + } + + if ( HB_IS_BLOCK( pFirst ) ) + { + /* pFunc is pointing to stored code block (later) */ + + _s->pcbFuncModal[ iIndex ] = hb_itemNew( pFirst ); + + pFunc = _s->pcbFuncModal[ iIndex ]; + _s->pFuncModal[ iIndex ] = pFunc; + _s->iTypeModal[ iIndex ] = 2; + } + else if( hb_itemType( pFirst ) == HB_IT_STRING ) + { + #ifdef __XHARBOUR__ + hb_dynsymLock(); + #endif + pExecSym = hb_dynsymFindName( hb_itemGetC( pFirst ) ); + #ifdef __XHARBOUR__ + hb_dynsymUnlock(); + #endif + if ( pExecSym ) + { + pFunc = ( PHB_ITEM ) pExecSym; + } + _s->pFuncModal[ iIndex ] = pFunc; + _s->iTypeModal[ iIndex ] = 1; + } + + switch ( iResource ) + { + case 0: + { + iResult = DialogBoxParam( ( HINSTANCE ) hb_hInstance, + hb_parc( 1 ), + hParent, + (DLGPROC) hb_wvt_gtDlgProcModal, + ( LPARAM ) ( DWORD ) iIndex+1 ); + } + break; + + case 1: + { + iResult = DialogBoxParam( ( HINSTANCE ) hb_hInstance, + MAKEINTRESOURCE( ( WORD ) hb_parni( 1 ) ), + hParent, + (DLGPROC) hb_wvt_gtDlgProcModal, + ( LPARAM ) ( DWORD ) iIndex+1 ); + } + break; + + case 2: + { + iResult = DialogBoxIndirectParam( ( HINSTANCE ) hb_hInstance, + ( LPDLGTEMPLATE ) hb_parc( 1 ), + hParent, + (DLGPROC) hb_wvt_gtDlgProcModal, + ( LPARAM ) ( DWORD ) iIndex+1 ); + } + break; + } + + hb_retni( iResult ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT__MAKEDLGTEMPLATE ) +{ + WORD *p, *pdlgtemplate ; + WORD nItems = hb_parni( 1, 4 ) ; + int i, nchar ; + DWORD lStyle ; + + // Parameters: 12 arrays + // 1 for DLG template + // 11 for item properties + + // 64k allow to build up to 255 items on the dialog + // + pdlgtemplate = p = ( PWORD ) LocalAlloc( LPTR, 65534 ) ; + + //--------------- + + lStyle = hb_parnl(1,3) ; + + // start to fill in the dlgtemplate information. addressing by WORDs + + *p++ = 1 ; // version + *p++ = 0xFFFF ; // signature + *p++ = LOWORD ( hb_parnl(1,1) ) ; // Help Id + *p++ = HIWORD ( hb_parnl(1,1) ) ; + + *p++ = LOWORD ( hb_parnl(1,2) ) ; // ext. style + *p++ = HIWORD ( hb_parnl(1,2) ) ; + + *p++ = LOWORD (lStyle) ; + *p++ = HIWORD (lStyle) ; + + *p++ = (WORD) nItems ; // NumberOfItems + *p++ = (short) hb_parni(1,5) ; // x + *p++ = (short) hb_parni(1,6) ; // y + *p++ = (short) hb_parni(1,7) ; // cx + *p++ = (short) hb_parni(1,8) ; // cy + *p++ = (short) 0 ; // Menu (ignored for now.) + *p++ = (short) 0x00 ; // Class also ignored + + if ( hb_parinfa( 1,11 ) == HB_IT_STRING ) + { + nchar = nCopyAnsiToWideChar( p, TEXT( hb_parc( 1,11 ) ) ) ; + p += nchar ; + } + else + { + *p++ =0 ; + } + // add in the wPointSize and szFontName here iff the DS_SETFONT bit on + + if ( ( lStyle & DS_SETFONT ) ) + { + *p++ = (short) hb_parni(1,12) ; + *p++ = (short) hb_parni(1,13) ; + *p++ = (short) hb_parni(1,14) ; + + nchar = nCopyAnsiToWideChar( p, TEXT( hb_parc(1,15) ) ) ; + p += nchar ; + } ; + + //--------------- + // Now, for the items + + for ( i = 1 ; i <= nItems ; i++ ) { + // make sure each item starts on a DWORD boundary + p = lpwAlign (p) ; + + *p++ = LOWORD ( hb_parnl(2,i) ) ; // help id + *p++ = HIWORD ( hb_parnl(2,i) ) ; + + *p++ = LOWORD ( hb_parnl(3,i) ) ; // ext. style + *p++ = HIWORD ( hb_parnl(3,i) ) ; + + *p++ = LOWORD ( hb_parnl(4,i) ) ; // style + *p++ = HIWORD ( hb_parnl(4,i) ) ; + + *p++ = (short) hb_parni(5,i) ; // x + *p++ = (short) hb_parni(6,i) ; // y + *p++ = (short) hb_parni(7,i) ; // cx + *p++ = (short) hb_parni(8,i) ; // cy + + *p++ = LOWORD ( hb_parnl(9,i) ) ; // id + *p++ = HIWORD ( hb_parnl(9,i) ) ; // id // 0; + + if ( hb_parinfa( 10,i ) == HB_IT_STRING ) + { + nchar = nCopyAnsiToWideChar( p, TEXT( hb_parc( 10,i ) ) ) ; // class + p += nchar ; + } + else + { + *p++ = 0xFFFF ; + *p++ = (WORD) hb_parni(10,i) ; + } + + if ( hb_parinfa( 11,i ) == HB_IT_STRING ) + { + nchar = nCopyAnsiToWideChar( p, ( LPSTR ) hb_parc( 11,i ) ) ; // text + p += nchar ; + } + else + { + *p++ = 0xFFFF ; + *p++ = (WORD) hb_parni(11,i) ; + } + + *p++ = 0x00 ; // extras ( in array 12 ) + } ; + + p = lpwAlign( p ) ; + + hb_retclen( ( LPSTR ) pdlgtemplate, ( ( ULONG ) p - ( ULONG ) pdlgtemplate ) ) ; + + LocalFree( LocalHandle( pdlgtemplate ) ) ; +} + +//-------------------------------------------------------------------// +// +// Helper routine. Take an input pointer, return closest +// pointer that is aligned on a DWORD (4 byte) boundary. +// +HB_EXPORT LPWORD lpwAlign( LPWORD lpIn ) +{ + ULONG ul; + ul = ( ULONG ) lpIn; + ul += 3; + ul >>=2; + ul <<=2; + return ( LPWORD ) ul; +} + +//----------------------------------------------------------------------------- + +HB_EXPORT int nCopyAnsiToWideChar( LPWORD lpWCStr, LPSTR lpAnsiIn ) +{ + int nChar = 0; + + do + { + *lpWCStr++ = ( WORD ) *lpAnsiIn; + nChar++; + } + while ( *lpAnsiIn++ ); + + return nChar; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_LBADDSTRING ) +{ + SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), LB_ADDSTRING, 0, ( LPARAM )( LPSTR ) hb_parc( 3 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_LBGETCOUNT ) +{ + hb_retnl( SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), LB_GETCOUNT, 0, 0 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_LBDELETESTRING ) +{ + SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), LB_DELETESTRING, hb_parni( 3 ), 0 ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_LBSETCURSEL ) +{ + SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), LB_SETCURSEL, hb_parni( 3 ), 0 ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CBADDSTRING ) +{ + SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), CB_ADDSTRING, 0, ( LPARAM )( LPSTR ) hb_parc( 3 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WVT_CBSETCURSEL ) +{ + SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), CB_SETCURSEL, hb_parni( 3 ), 0 ); +} + +//-------------------------------------------------------------------// +// +// Wvt_DlgSetIcon( hDlg, ncIcon ) +// +HB_FUNC( WVT_DLGSETICON ) +{ + HICON hIcon; + + if ( ISNUM( 2 ) ) + { + hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, MAKEINTRESOURCE( hb_parni( 2 ) ) ); + } + else + { + hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 2 ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + } + + if ( hIcon ) + { + SendMessage( ( HWND ) hb_parnl( 1 ), WM_SETICON, ICON_SMALL, ( LPARAM ) hIcon ); // Set Title Bar ICON + SendMessage( ( HWND ) hb_parnl( 1 ), WM_SETICON, ICON_BIG, ( LPARAM ) hIcon ); // Set Task List Icon + } + + if ( hIcon ) + { + hb_retnl( ( ULONG ) hIcon ); + } +} + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +// +// Direct WinApi Functions - Prefixed WIN_*() +// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SENDMESSAGE ) +{ + char *cText ; + + if( ISBYREF( 4 ) ) + { + cText = ( char* ) hb_xgrab( hb_parcsiz( 4 ) ); + hb_xmemcpy( cText, hb_parc( 4 ), hb_parcsiz( 4 ) ); + } + + hb_retnl( ( ULONG ) SendMessage( ( HWND ) hb_parnl( 1 ), + ( UINT ) hb_parni( 2 ), + ( ISNIL( 3 ) ? 0 : ( WPARAM ) hb_parnl( 3 ) ), + ( ISNIL( 4 ) ? 0 : ( ISBYREF( 4 ) ? ( LPARAM ) ( LPSTR ) cText : + ( ISCHAR( 4 ) ? ( LPARAM )( LPSTR ) hb_parc( 4 ) : + ( LPARAM ) hb_parnl( 4 ) ) ) ) ) + ); + + if ( ISBYREF( 4 ) ) + { + hb_storclen( cText, hb_parcsiz( 4 ), 4 ); + hb_xfree( cText ); + } +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SENDDLGITEMMESSAGE ) +{ + char *cText; + PHB_ITEM pText = hb_param( 5, HB_IT_STRING ); + + if( pText ) + { + cText = ( char* ) hb_xgrab( hb_itemGetCLen( pText ) + 1 ); + hb_xmemcpy( cText, hb_itemGetC( pText ), hb_itemGetCLen( pText ) + 1 ); + } + else + { + cText = NULL; + } + + hb_retnl( ( LONG ) SendDlgItemMessage( ( HWND ) hb_parnl( 1 ) , + ( int ) hb_parni( 2 ) , + ( UINT ) hb_parni( 3 ) , + ( ISNIL( 4 ) ? 0 : ( WPARAM ) hb_parnl( 4 ) ), + ( cText ? ( LPARAM ) cText : ( LPARAM ) hb_parnl( 5 ) ) + ) + ); + + if( pText ) + { + hb_storclen( cText, hb_itemGetCLen( pText ), 5 ) ; + } + + if( cText ) + { + hb_xfree( cText ); + } +} + +//-------------------------------------------------------------------// +// +// WIN_SetTimer( hWnd, nIdentifier, nTimeOut ) +// +HB_FUNC( WIN_SETTIMER ) +{ + hb_retl( SetTimer( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), hb_parni( 3 ), NULL ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SETFOCUS ) +{ + SetFocus( ( HWND ) hb_parnl( 1 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SETTEXTCOLOR ) +{ + hb_retnl( ( ULONG ) SetTextColor( ( HDC ) hb_parnl( 1 ), ( COLORREF ) hb_parnl( 2 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SETBKCOLOR ) +{ + hb_retnl( ( ULONG ) SetBkColor( ( HDC ) hb_parnl( 1 ), ( COLORREF ) hb_parnl( 2 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SETBKMODE ) +{ + hb_retni( ( int ) SetBkMode( ( HDC ) hb_parnl( 1 ), hb_parni( 2 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_GETSTOCKOBJECT ) +{ + hb_retnl( ( ULONG ) GetStockObject( hb_parnl( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_DELETEOBJECT ) +{ + hb_retl( DeleteObject( ( HGDIOBJ ) hb_parnl( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SELECTOBJECT ) +{ + hb_retnl( ( ULONG ) SelectObject( ( HDC ) hb_parnl( 1 ), ( HGDIOBJ ) hb_parnl( 2 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_LOWORD ) +{ + hb_retnl( LOWORD( hb_parnl( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_HIWORD ) +{ + hb_retnl( HIWORD( hb_parnl( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_MULDIV ) +{ + hb_retni( MulDiv( hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_GETDIALOGBASEUNITS ) +{ + hb_retnl( ( LONG ) GetDialogBaseUnits() ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SETMENU ) +{ + SetMenu( ( HWND ) hb_parnl( 1 ), ( HMENU ) hb_parni( 2 ) ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SETDLGITEMTEXT ) +{ + SetDlgItemText( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), hb_parc( 3 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_GETDLGITEMTEXT ) +{ + USHORT iLen = SendMessage( GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ), WM_GETTEXTLENGTH, 0, 0 ) + 1 ; + char *cText = ( char* ) hb_xgrab( iLen ); + + GetDlgItemText( ( HWND ) hb_parnl( 1 ), // handle of dialog box + hb_parni( 2 ), // identifier of control + ( LPTSTR ) cText, // address of buffer for text + iLen // maximum size of string + ); + + hb_retc( cText ); + hb_xfree( cText ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_CHECKDLGBUTTON ) +{ + hb_retl( CheckDlgButton( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), + ( UINT )( ISNUM( 3 ) ? hb_parni( 3 ) : hb_parl( 3 ) ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_ISDLGBUTTONCHECKED ) +{ + hb_retni( IsDlgButtonChecked( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ) ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_CHECKRADIOBUTTON ) +{ + hb_retl( CheckRadioButton( ( HWND ) hb_parnl( 1 ), // handle of dialog box + hb_parni( 2 ), // identifier of first radio button in group + hb_parni( 3 ), // identifier of last radio button in group + hb_parni( 4 ) // identifier of radio button to select + ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_GETDLGITEM ) +{ + hb_retnl( ( ULONG ) GetDlgItem( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_MESSAGEBOX ) +{ + hb_retni( MessageBox( ( HWND ) hb_parnl( 1 ), hb_parc( 2 ), hb_parc( 3 ), ISNIL( 4 ) ? MB_OK : hb_parni( 4 ) ) ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_INVALIDATERECT ) +{ + InvalidateRect( ( HWND ) hb_parnl( 1 ), NULL, TRUE ); +} + +//-------------------------------------------------------------------// +// +// Win_LoadIcon( ncIcon ) +// +HB_FUNC( WIN_LOADICON ) +{ + HICON hIcon; + + if ( ISNUM( 1 ) ) + { + hIcon = LoadIcon( ( HINSTANCE ) hb_hInstance, MAKEINTRESOURCE( hb_parni( 1 ) ) ); + } + else + { + hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 1 ), IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + } + + hb_retnl( ( ULONG ) hIcon ) ; +} + +//-------------------------------------------------------------------// +// +// Win_LoadImage( ncImage, nSource ) -> hImage +// nSource == 0 ResourceIdByNumber +// nSource == 1 ResourceIdByName +// nSource == 2 ImageFromDiskFile +// +HB_FUNC( WIN_LOADIMAGE ) +{ + HBITMAP hImage; + int iSource = hb_parni( 2 ); + + switch ( iSource ) + { + case 0: + { + hImage = LoadBitmap( ( HINSTANCE ) hb_hInstance, MAKEINTRESOURCE( hb_parni( 1 ) ) ); + } + break; + + case 1: + { + hImage = LoadBitmap( ( HINSTANCE ) hb_hInstance, hb_parc( 1 ) ); + } + break; + + case 2: + { + hImage = ( HBITMAP ) LoadImage( ( HINSTANCE ) NULL, hb_parc( 1 ), IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE ); + } + break; + } + + hb_retnl( ( ULONG ) hImage ) ; +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_GETCLIENTRECT ) +{ + RECT rc = { 0,0,0,0 }; + PHB_ITEM info = hb_itemArrayNew( 4 ); + PHB_ITEM temp = hb_itemNew( NULL ); + + GetClientRect( ( HWND ) hb_parnl( 1 ), &rc ); + + hb_arraySet( info, 1, hb_itemPutNI( temp, rc.left ) ); + hb_arraySet( info, 2, hb_itemPutNI( temp, rc.top ) ); + hb_arraySet( info, 3, hb_itemPutNI( temp, rc.right ) ); + hb_arraySet( info, 4, hb_itemPutNI( temp, rc.bottom ) ); + + hb_itemRelease( temp ); + hb_itemReturn( info ); + hb_itemRelease( info ); +} + +//-------------------------------------------------------------------// +// +// Win_DrawImage( hdc, nLeft, nTop, nWidth, nHeight, cImage ) in Pixels +// +HB_FUNC( WIN_DRAWIMAGE ) +{ + hb_retl( hb_wvt_DrawImage( ( HDC ) hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ), + hb_parni( 4 ), hb_parni( 5 ), hb_parc( 6 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_GETDC ) +{ + hb_retnl( ( ULONG ) GetDC( ( HWND ) hb_parnl( 1 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_RELEASEDC ) +{ + hb_retl( ReleaseDC( ( HWND ) hb_parnl( 1 ), ( HDC ) hb_parnl( 2 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_RECTANGLE ) +{ + Rectangle( ( HDC ) hb_parnl( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), hb_parni( 5 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_CREATEBRUSH ) +{ + LOGBRUSH lb = { 0,0,0 }; + + lb.lbStyle = hb_parni( 1 ); + lb.lbColor = ISNIL( 2 ) ? RGB( 0,0,0 ) : ( COLORREF ) hb_parnl( 2 ) ; + lb.lbHatch = ISNIL( 3 ) ? 0 : hb_parni( 3 ); + + hb_retnl( ( ULONG ) CreateBrushIndirect( &lb ) ); +} + +//-------------------------------------------------------------------// +// +// Win_DrawText( hDC, cText, aRect, nFormat ) +// +HB_FUNC( WIN_DRAWTEXT ) +{ + RECT rc = { 0,0,0,0 }; + + rc.left = hb_parni( 3,1 ); + rc.top = hb_parni( 3,2 ); + rc.right = hb_parni( 3,3 ); + rc.bottom = hb_parni( 3,4 ); + + hb_retl( DrawText( ( HDC ) hb_parnl( 1 ), hb_parc( 2 ), strlen( hb_parc( 2 ) ), &rc, hb_parni( 4 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_GETWINDOWRECT ) +{ + RECT rc; + PHB_ITEM info = hb_itemArrayNew( 4 ); + PHB_ITEM temp = hb_itemNew( NULL ); + + GetWindowRect( ( HWND ) hb_parnl( 1 ), &rc ); + + hb_arraySet( info, 1, hb_itemPutNI( temp, rc.left ) ); + hb_arraySet( info, 2, hb_itemPutNI( temp, rc.top ) ); + hb_arraySet( info, 3, hb_itemPutNI( temp, rc.right ) ); + hb_arraySet( info, 4, hb_itemPutNI( temp, rc.bottom ) ); + + hb_itemRelease( temp ); + hb_itemReturn( info ); + hb_itemRelease( info ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_MOVEWINDOW ) +{ + MoveWindow( (HWND) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ), hb_parnl( 5 ), hb_parl( 6 ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SETPARENT ) +{ + hb_retnl( ( long ) SetParent( (HWND) hb_parnl( 1 ), (HWND) hb_parnl( 2 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_SETWINDOWLONG ) +{ + hb_retnl( SetWindowLong( ( HWND ) hb_parnl( 1 ), hb_parni( 2 ), hb_parnl( 3 ) ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_ISWINDOW ) +{ + hb_retl( IsWindow( (HWND) hb_parnl( 1 ) ) ); +} + +//----------------------------------------------------------------------// + +HB_FUNC( WVT_GETFONTHANDLE ) +{ + HFONT hFont; + int iSlot = hb_parni( 1 )-1; + + if ( iSlot >= 0 && iSlot < WVT_PICTURES_MAX ) + { + hFont = _s->hUserFonts[ iSlot ]; + } + + hb_retnl( ( ULONG ) hFont ); +} + +//----------------------------------------------------------------------// + +HB_FUNC( WIN_CLIENTTOSCREEN ) +{ + POINT Point ; + PHB_ITEM pArray = hb_param( 2 , HB_IT_ARRAY ); + + if ( wvt_Array2Point( pArray ,&Point ) ) + { + if ( ClientToScreen( (HWND) hb_parnl( 1 ), &Point ) ) + { + wvt_Point2ArrayEx( &Point, pArray ); + hb_retl( TRUE ) ; + } + else + { + hb_retl( FALSE ) ; + } + } + else + { + hb_retl( FALSE ) ; + } +} + +//----------------------------------------------------------------------// + +HB_FUNC( WIN_SCREENTOCLIENT ) +{ + POINT Point ; + PHB_ITEM pArray = hb_param( 2 , HB_IT_ARRAY ); + + if ( wvt_Array2Point( pArray, &Point ) ) + { + if( ScreenToClient( (HWND) hb_parnl( 1 ), &Point ) > 0 ) + { + wvt_Point2ArrayEx( &Point, pArray ); + hb_retl( TRUE ) ; + } + else + { + hb_retl( FALSE ) ; + } + } + else + { + hb_retl( FALSE ) ; + } +} + +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +// +// Utility Functions - Not API +// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// + +BOOL wvt_Array2Rect(PHB_ITEM aRect, RECT *rc ) +{ + if (HB_IS_ARRAY(aRect) && hb_arrayLen(aRect) == 4) { + rc->left = hb_arrayGetNL(aRect,1); + rc->top = hb_arrayGetNL(aRect,2); + rc->right = hb_arrayGetNL(aRect,3); + rc->bottom = hb_arrayGetNL(aRect,4); + return TRUE ; + } + return FALSE; +} + +//----------------------------------------------------------------------// + +PHB_ITEM wvt_Rect2Array( RECT *rc ) +{ + PHB_ITEM aRect = hb_itemArrayNew( 4 ); + PHB_ITEM element = hb_itemNew( NULL ); + + hb_arraySet(aRect, 1, hb_itemPutNL( element, rc->left )); + hb_arraySet(aRect, 2, hb_itemPutNL( element, rc->top )); + hb_arraySet(aRect, 3, hb_itemPutNL( element, rc->right )); + hb_arraySet(aRect, 4, hb_itemPutNL( element, rc->bottom )); + hb_itemRelease(element); + return aRect; +} + + +//----------------------------------------------------------------------// + +BOOL wvt_Array2Point(PHB_ITEM aPoint, POINT *pt ) +{ + if (HB_IS_ARRAY(aPoint) && hb_arrayLen(aPoint) == 2) { + pt->x = hb_arrayGetNL(aPoint,1); + pt->y = hb_arrayGetNL(aPoint,2); + return TRUE ; + } + return FALSE; +} + +//----------------------------------------------------------------------// + +PHB_ITEM wvt_Point2Array( POINT *pt ) +{ + PHB_ITEM aPoint = hb_itemArrayNew(2); + PHB_ITEM element = hb_itemNew(NULL); + + hb_arraySet(aPoint, 1, hb_itemPutNL(element, pt->x)); + hb_arraySet(aPoint, 2, hb_itemPutNL(element, pt->y)); + hb_itemRelease(element); + return aPoint; +} + +//----------------------------------------------------------------------// + +BOOL wvt_Array2Size(PHB_ITEM aSize, SIZE *siz ) +{ + if (HB_IS_ARRAY(aSize) && hb_arrayLen(aSize) == 2) { + siz->cx = hb_arrayGetNL(aSize,1); + siz->cy = hb_arrayGetNL(aSize,2); + return TRUE ; + } + return FALSE; +} + +//----------------------------------------------------------------------// + +PHB_ITEM wvt_Size2Array( SIZE *siz ) +{ + PHB_ITEM aSize = hb_itemArrayNew(2); + PHB_ITEM element = hb_itemNew(NULL); + + hb_arraySet(aSize, 1, hb_itemPutNL(element, siz->cx)); + hb_arraySet(aSize, 2, hb_itemPutNL(element, siz->cy)); + hb_itemRelease(element); + return aSize; +} + +//----------------------------------------------------------------------// + +void wvt_Rect2ArrayEx( RECT *rc ,PHB_ITEM aRect ) +{ + PHB_ITEM element = hb_itemNew(NULL); + + hb_arraySet(aRect, 1, hb_itemPutNL(element, rc->left)); + hb_arraySet(aRect, 2, hb_itemPutNL(element, rc->top)); + hb_arraySet(aRect, 3, hb_itemPutNL(element, rc->right)); + hb_arraySet(aRect, 4, hb_itemPutNL(element, rc->bottom)); + hb_itemRelease(element); +} + +//----------------------------------------------------------------------// + +void wvt_Point2ArrayEx( POINT *pt, PHB_ITEM aPoint) +{ + + PHB_ITEM element = hb_itemNew(NULL); + + hb_arraySet(aPoint, 1, hb_itemPutNL(element, pt->x)); + hb_arraySet(aPoint, 2, hb_itemPutNL(element, pt->y)); + hb_itemRelease(element); +} + +//----------------------------------------------------------------------// + +void wvt_Size2ArrayEx( SIZE *siz, PHB_ITEM aSize ) +{ + PHB_ITEM element = hb_itemNew(NULL); + + hb_arraySet(aSize, 1, hb_itemPutNL(element, siz->cx)); + hb_arraySet(aSize, 2, hb_itemPutNL(element, siz->cy)); + hb_itemRelease(element); +} + +//----------------------------------------------------------------------// + +HB_FUNC( WVT__GETOPENFILENAME ) +{ + int size = ( ISNIL( 2 ) ? 1024 : hb_parcsiz( 2 ) ); + OPENFILENAME ofn ; + + char * szFileName = ( char* ) hb_xgrab( size ); + + strcpy( szFileName, ( ISNIL( 2 ) ? "" : hb_parc( 2 ) ) ); + + ZeroMemory( &ofn, sizeof( ofn ) ); + + ofn.hInstance = GetModuleHandle( NULL ) ; + ofn.lStructSize = sizeof( ofn ); + ofn.hwndOwner = ISNIL (1) ? GetActiveWindow() : ( HWND ) hb_parnl( 1 ) ; + ofn.lpstrTitle = ISNIL (3) ? NULL : hb_parc ( 3 ) ; + ofn.lpstrFilter = ISNIL (4) ? NULL : hb_parc ( 4 ); + ofn.Flags = ISNIL (5) ? OFN_SHOWHELP|OFN_NOCHANGEDIR : hb_parnl( 5 ) ; + ofn.lpstrInitialDir = ISNIL (6) ? NULL : hb_parc ( 6 ); + ofn.lpstrDefExt = ISNIL (7) ? NULL : hb_parc ( 7 ); + ofn.nFilterIndex = ISNIL (8) ? 0 : (int) hb_parni( 8 ); + ofn.lpstrFile = szFileName; + ofn.nMaxFile = size; + + if( GetOpenFileName( &ofn ) ) + { + hb_stornl( ofn.nFilterIndex, 8 ); + hb_storclen( szFileName, size, 2 ) ; + hb_retclen( ( char * ) ofn.lpstrFile, size ); + } + else + { + hb_retc( "" ); + } + hb_xfree( szFileName ); +} + +//----------------------------------------------------------------------// + +HB_FUNC( WVT__GETSAVEFILENAME ) +{ + HINSTANCE hInstance; + OPENFILENAME ofn; + char szFileName[ MAX_PATH+1 ] ; + + hInstance = GetModuleHandle( NULL ); + + strcpy( szFileName, hb_parc( 2 ) ); + + ZeroMemory( &ofn, sizeof( ofn ) ); + + ofn.hInstance = hInstance ; + ofn.lStructSize = sizeof( ofn ); + ofn.hwndOwner = ISNIL (1) ? GetActiveWindow() : (HWND) hb_parnl( 1 ); + ofn.lpstrTitle = hb_parc (3); + ofn.lpstrFilter = hb_parc (4); + ofn.Flags = (ISNIL (5) ? OFN_FILEMUSTEXIST|OFN_EXPLORER|OFN_NOCHANGEDIR : hb_parnl( 4 ) ); + ofn.lpstrInitialDir = hb_parc (6); + ofn.lpstrDefExt = hb_parc (7); + ofn.nFilterIndex = hb_parni(8); + ofn.lpstrFile = szFileName; + ofn.nMaxFile = MAX_PATH; + + if( GetSaveFileName( &ofn ) ) + { + hb_stornl( ofn.nFilterIndex, 8 ); + hb_retc( ofn.lpstrFile ); + } + else + { + hb_retc( "" ); + } +} +//----------------------------------------------------------------------// + +HB_FUNC( WIN_AND ) +{ + hb_retnl( hb_parnl(1) & hb_parnl(2) ) ; +} + +//----------------------------------------------------------------------// + +HB_FUNC( WIN_OR ) +{ + hb_retnl( hb_parnl(1) | hb_parnl(2) ) ; +} + +//----------------------------------------------------------------------// + +HB_FUNC( WIN_NOT ) +{ + hb_retnl( ~( hb_parnl(1) ) ) ; +} + +//----------------------------------------------------------------------// + +HB_FUNC( WIN_TRACKPOPUPMENU ) +{ + HMENU hMenu = ( HMENU ) hb_parnl( 1 ); + UINT uFlags = ISNIL( 2 ) ? TPM_CENTERALIGN | TPM_RETURNCMD : hb_parnl( 2 ); + HWND hWnd = ISNIL( 3 ) ? GetActiveWindow() : ( HWND ) hb_parnl( 3 ); + + POINT xy = { 0,0 }; + + GetCursorPos( &xy ); + + hb_retnl( TrackPopupMenu( hMenu, uFlags, xy.x, xy.y, 0, hWnd, NULL ) ); +} + +//-------------------------------------------------------------------// + +HB_FUNC( WIN_CHOOSECOLOR ) +{ + CHOOSECOLOR cc ; + COLORREF crCustClr[ 16 ] ; + int i ; + + for( i = 0 ; i < 16 ; i++ ) + { + crCustClr[ i ] = ( ISARRAY( 2 ) ? ( COLORREF ) hb_parnl( 2, i+1 ) : GetSysColor( COLOR_BTNFACE ) ) ; + } + + cc.lStructSize = sizeof( CHOOSECOLOR ) ; + cc.hwndOwner = ISNIL( 4 ) ? NULL : (HWND) hb_parnl( 4 ); + cc.rgbResult = ISNIL( 1 ) ? 0 : ( COLORREF ) hb_parnl( 1 ) ; + cc.lpCustColors = crCustClr ; + cc.Flags = ( WORD ) ( ISNIL( 3 ) ? CC_ANYCOLOR | CC_RGBINIT | CC_FULLOPEN : hb_parnl( 3 ) ); + + if ( ChooseColor( &cc ) ) + { + hb_retnl( cc.rgbResult ) ; + } + else + { + hb_retnl( -1 ); + } +} + +//-------------------------------------------------------------------// + + diff --git a/harbour/contrib/gtwvg/wvtwin.ch b/harbour/contrib/gtwvg/wvtwin.ch index 5d68838509..08aa6a0aeb 100644 --- a/harbour/contrib/gtwvg/wvtwin.ch +++ b/harbour/contrib/gtwvg/wvtwin.ch @@ -1,1235 +1,1235 @@ -/* - * Chr(36) + "Id" + Chr(36) - */ - -/* - * Harbour Project source code: - * Header file for the WVT*Classes - * - * Copyright 2004 Pritpal Bedi - * www - http://www.xharbour.org 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. - * - */ -//-------------------------------------------------------------------// -// -// GTWVT Specific -// -//-------------------------------------------------------------------// -// -// Wvt_DrawButton() constants -// -#define WVT_BTN_FORMAT_RAISED 0 // Default -#define WVT_BTN_FORMAT_RECESSED 1 -#define WVT_BTN_FORMAT_FLAT 2 -#define WVT_BTN_FORMAT_OUTLINED 3 - -#define WVT_BTN_IMAGE_TOP 0 // Default -#define WVT_BTN_IMAGE_LEFT 1 -#define WVT_BTN_IMAGE_BOTTOM 2 -#define WVT_BTN_IMAGE_RIGHT 3 - -//-------------------------------------------------------------------// -// -// Wvt_DrawLine( nTop, nLeft, nBottom, nRight, nOrient, nFormat,; -// nAlign, nStyle, nThick, nColor ) -// -// nOrient -#define WVT_LINE_HORZ 0 // Default -#define WVT_LINE_VERT 1 - -// nFormat -#define WVT_LINE_RAISED 0 // Default -#define WVT_LINE_RECESSED 1 -#define WVT_LINE_PLAIN 2 - -// nAlign -#define WVT_LINE_CENTER 0 // Default -#define WVT_LINE_TOP 1 -#define WVT_LINE_BOTTOM 2 -#define WVT_LINE_LEFT 3 -#define WVT_LINE_RIGHT 4 - -// nStyle -#define WVT_LINE_SOLID 0 // Default -#define WVT_LINE_DASH 1 -#define WVT_LINE_DOT 2 -#define WVT_LINE_DASHDOT 3 -#define WVT_LINE_DASHDOTDOT 4 - -//-------------------------------------------------------------------// -// -// Standard Mouse Pointer Shape Constants -// -#define WVT_IDC_ARROW 1 -#define WVT_IDC_IBEAM 2 -#define WVT_IDC_WAIT 3 -#define WVT_IDC_CROSS 4 -#define WVT_IDC_UPARROW 5 -#define WVT_IDC_SIZE 6 -#define WVT_IDC_ICON 7 -#define WVT_IDC_SIZENWSE 8 -#define WVT_IDC_SIZENESW 9 -#define WVT_IDC_SIZEWE 10 -#define WVT_IDC_SIZENS 11 -#define WVT_IDC_SIZEALL 12 -#define WVT_IDC_NO 13 -#define WVT_IDC_HAND 14 -#define WVT_IDC_APPSTARTING 15 -#define WVT_IDC_HELP 16 - -//-------------------------------------------------------------------// - -#define WVT_BLOCK_IMAGE 1 -#define WVT_BLOCK_BOX 2 -#define WVT_BLOCK_LABEL 3 -#define WVT_BLOCK_GRID_V 4 -#define WVT_BLOCK_GRID_H 5 -#define WVT_BLOCK_BUTTON 6 -#define WVT_BLOCK_GETS 7 -#define WVT_BLOCK_LINE 8 -#define WVT_BLOCK_STATUSBAR 9 -#define WVT_BLOCK_TOOLBAR 10 -#define WVT_BLOCK_STATIC 11 - -//-------------------------------------------------------------------// - -#define DLG_OBJ_BROWSE 1 -#define DLG_OBJ_PICTURE 2 -#define DLG_OBJ_LINE 3 -#define DLG_OBJ_RECT 4 -#define DLG_OBJ_GETS 5 -#define DLG_OBJ_BUTTON 6 -#define DLG_OBJ_STATUSBAR 7 -#define DLG_OBJ_PANEL 8 -#define DLG_OBJ_LABEL 9 -#define DLG_OBJ_STATIC 10 -#define DLG_OBJ_TOOLBAR 11 -#define DLG_OBJ_IMAGE 12 -#define DLG_OBJ_PUSHBUTTON 13 -#define DLG_OBJ_CONSOLE 14 -#define DLG_OBJ_SCROLLBAR 15 -#define DLG_OBJ_BANNER 16 -#define DLG_OBJ_TEXTBOX 17 -#define DLG_OBJ_PROGRESSBAR 18 - -//-------------------------------------------------------------------// - -#define TLB_BUTTON_TYPE_IMAGE 0 -#define TLB_BUTTON_TYPE_SEPARATOR 1 -#define TLB_BUTTON_TYPE_TEXT 2 - -//-------------------------------------------------------------------// - -#define WVT_STATIC_LINE 1 -#define WVT_STATIC_BOXRAISED 2 -#define WVT_STATIC_BOXRECESSED 3 -#define WVT_STATIC_BOXGROUP 4 -#define WVT_STATIC_BOXGROUPRAISED 5 -#define WVT_STATIC_RECTANGLE 6 -#define WVT_STATIC_ROUNDRECT 7 -#define WVT_STATIC_FOCUSRECT 8 -#define WVT_STATIC_OUTLINE 9 -#define WVT_STATIC_ELLIPSE 10 -#define WVT_STATIC_SHADEDRECT 11 - -#define WVT_SCROLLBAR_VERT 1 -#define WVT_SCROLLBAR_HORZ 2 - -#define WVT_SCROLLBUTTON_TOP 1 -#define WVT_SCROLLBUTTON_LEFT 2 -#define WVT_SCROLLBUTTON_BOTTOM 3 -#define WVT_SCROLLBUTTON_RIGHT 4 -#define WVT_SCROLL_THUMB 5 - -//-------------------------------------------------------------------// -// -// wvtmenu defines . Peter Rees -// -#define WVT_MENU_TYPE 1 -#define WVT_MENU_IDENTIFIER 2 -#define WVT_MENU_CAPTION 3 -#define WVT_MENU_ACTION 4 -#define WVT_MENU_MENUOBJ 4 - -//-------------------------------------------------------------------// - -#define ISBLOCK( x ) valtype( x ) == 'B' - -#define RGB( nR,nG,nB ) ( nR + ( nG * 256 ) + ( nB * 256 * 256 ) ) - -//-------------------------------------------------------------------// -// -// Windows Specific -// -//-------------------------------------------------------------------// -// -// Menu Manipulation Constants -// -#define MF_INSERT 0 -#define MF_CHANGE 128 -#define MF_APPEND 256 -#define MF_DELETE 512 -#define MF_REMOVE 4096 - -#define MF_BYCOMMAND 0 -#define MF_BYPOSITION 1024 - -#define MF_SEPARATOR 2048 - -#define MF_ENABLED 0 -#define MF_GRAYED 1 -#define MF_DISABLED 2 - -#define MF_UNCHECKED 0 -#define MF_CHECKED 8 -#define MF_USECHECKBITMAPS 512 - -#define MF_STRING 0 -#define MF_BITMAP 4 -#define MF_OWNERDRAW 256 - -#define MF_POPUP 16 -#define MF_MENUBARBREAK 32 -#define MF_MENUBREAK 64 - -#define MF_UNHILITE 0 -#define MF_HILITE 128 - -//-------------------------------------------------------------------// - -#define TPM_LEFTBUTTON 0x0000 -#define TPM_RIGHTBUTTON 0x0002 - -#define TPM_LEFTALIGN 0x0000 -#define TPM_CENTERALIGN 0x0004 -#define TPM_RIGHTALIGN 0x0008 - -#define TPM_TOPALIGN 0x0000 -#define TPM_VCENTERALIGN 0x0010 -#define TPM_BOTTOMALIGN 0x0020 - -#define TPM_HORIZONTAL 0x0000 /* Horz alignment matters more */ -#define TPM_VERTICAL 0x0040 /* Vert alignment matters more */ -#define TPM_NONOTIFY 0x0080 /* Don't send any notification msgs */ -#define TPM_RETURNCMD 0x0100 - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * ShowWindow() Commands - */ -#define SW_HIDE 0 -#define SW_SHOWNORMAL 1 -#define SW_NORMAL 1 -#define SW_SHOWMINIMIZED 2 -#define SW_SHOWMAXIMIZED 3 -#define SW_MAXIMIZE 3 -#define SW_SHOWNOACTIVATE 4 -#define SW_SHOW 5 -#define SW_MINIMIZE 6 -#define SW_SHOWMINNOACTIVE 7 -#define SW_SHOWNA 8 -#define SW_RESTORE 9 -#define SW_SHOWDEFAULT 10 -#define SW_FORCEMINIMIZE 11 -#define SW_MAX 11 - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * Window Messages - */ -#define WM_USER 1024 - -#define WM_CREATE 1 -#define WM_DESTROY 2 -#define WM_MOVE 3 -#define WM_SIZE 5 -#define WM_ACTIVATE 6 -#define WM_SETFOCUS 7 -#define WM_KILLFOCUS 8 -#define WM_ENABLE 10 -#define WM_SETREDRAW 11 -#define WM_SETTEXT 12 -#define WM_GETTEXT 13 -#define WM_GETTEXTLENGTH 14 -#define WM_PAINT 15 -#define WM_CLOSE 16 // 0x0010 -#define WM_QUIT 18 // 0x0012 -#define WM_ERASEBKGND 20 // 0x0014 -#define WM_SYSCOLORCHANGE 21 // 0x0015 -#define WM_SHOWWINDOW 24 // 0x0018 -#define WM_WININICHANGE 26 // 0x001A -#define WM_DEVMODECHANGE 27 // 0x001B -#define WM_ACTIVATEAPP 28 // 0x001C -#define WM_FONTCHANGE 29 // 0x001D -#define WM_TIMECHANGE 30 // 0x001E -#define WM_CANCELMODE 31 // 0x001F -#define WM_SETCURSOR 32 // 0x0020 -#define WM_MOUSEACTIVATE 33 // 0x0021 -#define WM_CHILDACTIVATE 34 // 0x0022 -#define WM_QUEUESYNC 35 // 0x0023 -#define WM_GETMINMAXINFO 36 - -#define WM_PAINTICON 38 -#define WM_ICONERASEBKGND 39 -#define WM_NEXTDLGCTL 40 -#define WM_SPOOLERSTATUS 42 -#define WM_DRAWITEM 43 // 0x002B -#define WM_MEASUREITEM 44 -#define WM_DELETEITEM 45 -#define WM_VKEYTOITEM 46 -#define WM_CHARTOITEM 47 -#define WM_SETFONT 48 -#define WM_GETFONT 49 -#define WM_SETHOTKEY 50 -#define WM_GETHOTKEY 51 -#define WM_QUERYDRAGICON 55 -#define WM_COMPAREITEM 57 -#define WM_GETOBJECT 61 -#define WM_COMPACTING 65 // 0x0041 -#define WM_COMMNOTIFY 68 // 0x0044 /* no longer suported */ -#define WM_WINDOWPOSCHANGING 70 // 0x0046 -#define WM_WINDOWPOSCHANGED 71 // 0x0047 -#define WM_POWER 72 -#define WM_NOTIFY 78 // 0x004E -#define WM_INPUTLANGCHANGEREQUEST 79 // 0x0050 -#define WM_INPUTLANGCHANGE 80 // 0x0051 -#define WM_TCARD 81 // 0x0052 -#define WM_HELP 82 // 0x0053 -#define WM_USERCHANGED 83 // 0x0054 -#define WM_NOTIFYFORMAT 84 // 0x0055 - -#define WM_CONTEXTMENU 123 // 0x007B -#define WM_STYLECHANGING 124 // 0x007C -#define WM_STYLECHANGED 125 // 0x007D -#define WM_DISPLAYCHANGE 126 // 0x007E -#define WM_GETICON 127 // 0x007F -#define WM_SETICON 128 // 0x0080 - -#define WM_NCCREATE 129 -#define WM_NCDESTROY 130 -#define WM_NCCALCSIZE 131 -#define WM_NCHITTEST 132 -#define WM_NCPAINT 133 -#define WM_NCACTIVATE 134 -#define WM_GETDLGCODE 135 - -#define WM_NCMOUSEMOVE 160 -#define WM_NCLBUTTONDOWN 161 -#define WM_NCLBUTTONUP 162 - -#define WM_NCLBUTTONDBLCLK 163 - -#define WM_NCRBUTTONDOWN 164 -#define WM_NCRBUTTONUP 165 -#define WM_NCRBUTTONDBLCLK 166 -#define WM_NCMBUTTONDOWN 167 -#define WM_NCMBUTTONUP 168 -#define WM_NCMBUTTONDBLCLK 169 - -#define WM_KEYDOWN 256 // 0x0100 -#define WM_KEYUP 257 // 0x0101 - -#define WM_KEYFIRST 256 -#define WM_CHAR 258 -#define WM_DEADCHAR 259 -#define WM_SYSKEYDOWN 260 -#define WM_SYSKEYUP 261 -#define WM_SYSCHAR 262 -#define WM_SYSDEADCHAR 263 -#define WM_KEYLAST 264 - -#define WM_INITDIALOG 272 -#define WM_COMMAND 273 -#define WM_SYSCOMMAND 274 -#define WM_TIMER 275 -#define WM_HSCROLL 276 -#define WM_VSCROLL 277 - -#define WM_INITMENUPOPUP 279 -#define WM_MENUSELECT 287 -#define WM_MENUCOMMAND 294 - -#define WM_CTLCOLORMSGBOX 306 -#define WM_CTLCOLOREDIT 307 -#define WM_CTLCOLORLISTBOX 308 -#define WM_CTLCOLORBTN 309 -#define WM_CTLCOLORDLG 310 -#define WM_CTLCOLORSCROLLBAR 311 -#define WM_CTLCOLORSTATIC 312 - -#define WM_MOUSEFIRST 512 -#define WM_MOUSEMOVE 512 -#define WM_LBUTTONDOWN 513 -#define WM_LBUTTONUP 514 -#define WM_LBUTTONDBLCLK 515 -#define WM_RBUTTONDOWN 516 -#define WM_RBUTTONUP 517 -#define WM_RBUTTONDBLCLK 518 -#define WM_MBUTTONDOWN 519 -#define WM_MBUTTONUP 520 -#define WM_MBUTTONDBLCLK 521 -#define WM_MOUSEWHEEL 522 -#define WM_XBUTTONDOWN 523 -#define WM_XBUTTONUP 524 -#define WM_XBUTTONDBLCLK 525 - -#define WM_PARENTNOTIFY 528 -#define WM_ENTERMENULOOP 529 -#define WM_EXITMENULOOP 530 - -#define WM_NEXTMENU 531 -#define WM_SIZING 532 -#define WM_CAPTURECHANGED 533 -#define WM_MOVING 534 -#define WM_POWERBROADCAST 536 - -#define WM_MDICREATE 544 -#define WM_MDIDESTROY 545 -#define WM_MDIACTIVATE 546 -#define WM_MDIRESTORE 547 -#define WM_MDINEXT 548 -#define WM_MDIMAXIMIZE 549 -#define WM_MDITILE 550 -#define WM_MDICASCADE 551 -#define WM_MDIICONARRANGE 552 -#define WM_MDIGETACTIVE 553 - -#define WM_MDISETMENU 560 -#define WM_ENTERSIZEMOVE 561 -#define WM_EXITSIZEMOVE 562 -#define WM_DROPFILES 563 -#define WM_MDIREFRESHMENU 564 - -#define WM_CUT 768 -#define WM_COPY 769 -#define WM_PASTE 770 -#define WM_CLEAR 771 -#define WM_UNDO 772 -#define WM_RENDERFORMAT 773 -#define WM_RENDERALLFORMATS 774 -#define WM_DESTROYCLIPBOARD 775 -#define WM_DRAWCLIPBOARD 776 -#define WM_PAINTCLIPBOARD 777 -#define WM_VSCROLLCLIPBOARD 778 -#define WM_SIZECLIPBOARD 779 -#define WM_ASKCBFORMATNAME 780 -#define WM_CHANGECBCHAIN 781 -#define WM_HSCROLLCLIPBOARD 782 -#define WM_QUERYNEWPALETTE 783 -#define WM_PALETTEISCHANGING 784 -#define WM_PALETTECHANGED 785 -#define WM_HOTKEY 786 - -//-------------------------------------------------------------------// -/* - * Window Styles - */ -#define WS_OVERLAPPED 0 -#define WS_POPUP 2147483648 // 0x80000000L -#define WS_CHILD 1073741824 // 0x40000000L -#define WS_MINIMIZE 536870912 // 0x20000000L -#define WS_VISIBLE 268435456 // 0x10000000L -#define WS_DISABLED 134217728 // 0x08000000L -#define WS_BORDER 8388608 // 0x00800000L -#define WS_DLGFRAME 4194304 // 0x00400000L -#define WS_VSCROLL 2097152 // 0x00200000L -#define WS_HSCROLL 1048576 // 0x00100000L -#define WS_SYSMENU 524288 // 0x00080000L -#define WS_THICKFRAME 262144 // 0x00040000L -#define WS_GROUP 131072 // 0x00020000L -#define WS_TABSTOP 65536 // 0x00010000L -#define WS_CLIPSIBLINGS 67108864 -#define WS_CLIPCHILDREN 33554432 -#define WS_MAXIMIZE 16777216 -#define WS_CAPTION 12582912 /* WS_BORDER | WS_DLGFRAME */ - -#define WS_MINIMIZEBOX 131072 -#define WS_MAXIMIZEBOX 65536 - -#define WS_TILED WS_OVERLAPPED -#define WS_ICONIC WS_MINIMIZE -#define WS_SIZEBOX WS_THICKFRAME -#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW - -#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED + ; - WS_CAPTION + ; - WS_SYSMENU + ; - WS_THICKFRAME + ; - WS_MINIMIZEBOX + ; - WS_MAXIMIZEBOX ) - -//-------------------------------------------------------------------// -/* - * Extended Window Styles - */ -#define WS_EX_DLGMODALFRAME 1 // 0x00000001L -#define WS_EX_NOPARENTNOTIFY 4 // 0x00000004L -#define WS_EX_TOPMOST 8 // 0x00000008L -#define WS_EX_ACCEPTFILES 16 // 0x00000010L -#define WS_EX_TRANSPARENT 32 // 0x00000020L -#define WS_EX_MDICHILD 64 // 0x00000040L -#define WS_EX_TOOLWINDOW 128 // 0x00000080L -#define WS_EX_WINDOWEDGE 256 // 0x00000100L -#define WS_EX_CLIENTEDGE 512 // 0x00000200L -#define WS_EX_CONTEXTHELP 1024 // 0x00000400L - -#define WS_EX_RIGHT 4096 // 0x00001000L -#define WS_EX_LEFT 0 // 0x00000000L -#define WS_EX_RTLREADING 8192 // 0x00002000L -#define WS_EX_LTRREADING 0 // 0x00000000L -#define WS_EX_LEFTSCROLLBAR 16384 // 0x00004000L -#define WS_EX_RIGHTSCROLLBAR 0 // 0x00000000L - -#define WS_EX_CONTROLPARENT 65536 // 0x00010000L -#define WS_EX_STATICEDGE 131072 // 0x00020000L -#define WS_EX_APPWINDOW 262144 // 0x00040000L - -#define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE + WS_EX_CLIENTEDGE) -#define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE + WS_EX_TOOLWINDOW + WS_EX_TOPMOST) - -#define WS_EX_LAYERED 524288 // 0x00080000 -#define WS_EX_NOINHERITLAYOUT 1048576 // 0x00100000L // Disable inheritence of mirroring by children -#define WS_EX_LAYOUTRTL 4194304 // 0x00400000L // Right to left mirroring -#define WS_EX_NOACTIVATE 134217728 // 0x08000000L - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * Dialog styles - */ -#define DS_ABSALIGN 1 // 0x01 -#define DS_SYSMODAL 2 // 0x02 -#define DS_3DLOOK 4 // 0x04 -#define DS_FIXEDSYS 8 // 0x08 -#define DS_NOFAILCREATE 16 // 0x10 -#define DS_LOCALEDIT 32 // 0x20 -#define DS_SETFONT 64 // 0x40 -#define DS_MODALFRAME 128 // 0x80 -#define DS_NOIDLEMSG 256 // 0x100 -#define DS_CONTROL 1024 // 0x400 -#define DS_CENTER 2048 // 0x800 -#define DS_CENTERMOUSE 4096 // 0x1000 -#define DS_CONTEXTHELP 8192 // 0x2000 - -//-------------------------------------------------------------------// -/* - * Dialog Box Command IDs - */ -#define IDOK 1 -#define IDCANCEL 2 -#define IDABORT 3 -#define IDRETRY 4 -#define IDIGNORE 5 -#define IDYES 6 -#define IDNO 7 -#define IDTRYAGAIN 10 // (WINVER >= 0x0500) -#define IDCONTINUE 11 // (WINVER >= 0x0500) - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * Button Control Styles - */ -#define BS_PUSHBUTTON 0 // 0x00000000L -#define BS_DEFPUSHBUTTON 1 // 0x00000001L -#define BS_CHECKBOX 2 // 0x00000002L -#define BS_AUTOCHECKBOX 3 // 0x00000003L -#define BS_RADIOBUTTON 4 // 0x00000004L -#define BS_3STATE 5 // 0x00000005L -#define BS_AUTO3STATE 6 // 0x00000006L -#define BS_GROUPBOX 7 // 0x00000007L -#define BS_USERBUTTON 8 // 0x00000008L -#define BS_AUTORADIOBUTTON 9 // 0x00000009L -#define BS_OWNERDRAW 11 // 0x0000000BL -#define BS_LEFTTEXT 32 // 0x00000020L - -//-------------------------------------------------------------------// -/* - * User Button Notification Codes - */ -#define BN_CLICKED 0 -#define BN_PAINT 1 -#define BN_HILITE 2 -#define BN_UNHILITE 3 -#define BN_DISABLE 4 -#define BN_DOUBLECLICKED 5 -#define BN_PUSHED BN_HILITE -#define BN_UNPUSHED BN_UNHILITE -#define BN_DBLCLK BN_DOUBLECLICKED -#define BN_SETFOCUS 6 -#define BN_KILLFOCUS 7 - -//-------------------------------------------------------------------// -/* - * Button Control Messages - */ -#define BM_GETCHECK 240 -#define BM_SETCHECK 241 -#define BM_GETSTATE 242 -#define BM_SETSTATE 243 -#define BM_SETSTYLE 244 -#define BM_CLICK 245 -#define BM_GETIMAGE 246 -#define BM_SETIMAGE 247 - -#define BST_UNCHECKED 0 -#define BST_CHECKED 1 -#define BST_INDETERMINATE 2 -#define BST_PUSHED 4 -#define BST_FOCUS 8 - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * Edit Control Styles - */ -#define ES_LEFT 0 -#define ES_CENTER 1 -#define ES_RIGHT 2 -#define ES_MULTILINE 4 -#define ES_UPPERCASE 8 -#define ES_LOWERCASE 16 -#define ES_PASSWORD 32 -#define ES_AUTOVSCROLL 64 -#define ES_AUTOHSCROLL 128 -#define ES_NOHIDESEL 256 -#define ES_OEMCONVERT 1024 -#define ES_READONLY 2048 -#define ES_WANTRETURN 4096 -#define ES_NUMBER 8192 - -//-------------------------------------------------------------------// -/* - * Edit Control Notification Codes - */ -#define EN_SETFOCUS 256 // 0x0100 -#define EN_KILLFOCUS 512 // 0x0200 -#define EN_CHANGE 768 // 0x0300 -#define EN_UPDATE 1024 // 0x0400 -#define EN_ERRSPACE 1280 // 0x0500 -#define EN_MAXTEXT 1281 // 0x0501 -#define EN_HSCROLL 1537 // 0x0601 -#define EN_VSCROLL 1538 // 0x0602 - -//----------------------------------------------------------------------// -/* - * Edit Control Messages - */ -#define EM_GETSEL 176 -#define EM_SETSEL 177 -#define EM_GETRECT 178 -#define EM_SETRECT 179 -#define EM_SETRECTNP 180 -#define EM_SCROLL 181 -#define EM_LINESCROLL 182 -#define EM_SCROLLCARET 183 -#define EM_GETMODIFY 184 -#define EM_SETMODIFY 185 -#define EM_GETLINECOUNT 186 -#define EM_LINEINDEX 187 -#define EM_SETHANDLE 188 -#define EM_GETHANDLE 189 -#define EM_GETTHUMB 190 -#define EM_LINELENGTH 193 -#define EM_REPLACESEL 194 -#define EM_GETLINE 196 -#define EM_LIMITTEXT 197 -#define EM_CANUNDO 198 -#define EM_UNDO 199 -#define EM_FMTLINES 200 -#define EM_LINEFROMCHAR 201 -#define EM_SETTABSTOPS 203 -#define EM_SETPASSWORDCHAR 204 -#define EM_EMPTYUNDOBUFFER 205 -#define EM_GETFIRSTVISIBLELINE 206 -#define EM_SETREADONLY 207 -#define EM_SETWORDBREAKPROC 208 -#define EM_GETWORDBREAKPROC 209 -#define EM_GETPASSWORDCHAR 210 -#define EM_SETMARGINS 211 -#define EM_GETMARGINS 212 -#define EM_SETLIMITTEXT EM_LIMITTEXT -#define EM_GETLIMITTEXT 213 -#define EM_POSFROMCHAR 214 -#define EM_CHARFROMPOS 215 - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * Combo Box styles - */ -#define CBS_SIMPLE 1 // 0x0001L -#define CBS_DROPDOWN 2 // 0x0002L -#define CBS_DROPDOWNLIST 3 // 0x0003L -#define CBS_OWNERDRAWFIXED 16 // 0x0010L -#define CBS_OWNERDRAWVARIABLE 32 // 0x0020L -#define CBS_AUTOHSCROLL 64 // 0x0040L -#define CBS_OEMCONVERT 128 // 0x0080L -#define CBS_SORT 256 // 0x0100L -#define CBS_HASSTRINGS 512 // 0x0200L -#define CBS_NOINTEGRALHEIGHT 1024 // 0x0400L -#define CBS_DISABLENOSCROLL 2048 // 0x0800L -#define CBS_UPPERCASE 8192 // 0x2000L -#define CBS_LOWERCASE 16384 // 0x4000L - -//-------------------------------------------------------------------// -/* - * Combo Box Notification Codes - */ -#define CBN_ERRSPACE (-1) -#define CBN_SELCHANGE 1 -#define CBN_DBLCLK 2 -#define CBN_SETFOCUS 3 -#define CBN_KILLFOCUS 4 -#define CBN_EDITCHANGE 5 -#define CBN_EDITUPDATE 6 -#define CBN_DROPDOWN 7 -#define CBN_CLOSEUP 8 -#define CBN_SELENDOK 9 -#define CBN_SELENDCANCEL 10 - -//-------------------------------------------------------------------// -/* - * Combo Box messages - */ -#define CB_GETEDITSEL 320 -#define CB_LIMITTEXT 321 -#define CB_SETEDITSEL 322 -#define CB_ADDSTRING 323 -#define CB_DELETESTRING 324 -#define CB_DIR 325 -#define CB_GETCOUNT 326 -#define CB_GETCURSEL 327 -#define CB_GETLBTEXT 328 -#define CB_GETLBTEXTLEN 329 -#define CB_INSERTSTRING 330 -#define CB_RESETCONTENT 331 -#define CB_FINDSTRING 332 -#define CB_SELECTSTRING 333 -#define CB_SETCURSEL 334 -#define CB_SHOWDROPDOWN 335 -#define CB_GETITEMDATA 336 -#define CB_SETITEMDATA 337 -#define CB_GETDROPPEDCONTROLRECT 338 -#define CB_SETITEMHEIGHT 339 -#define CB_GETITEMHEIGHT 340 -#define CB_SETEXTENDEDUI 341 -#define CB_GETEXTENDEDUI 342 -#define CB_GETDROPPEDSTATE 343 -#define CB_FINDSTRINGEXACT 344 -#define CB_SETLOCALE 345 -#define CB_GETLOCALE 346 -#define CB_GETTOPINDEX 347 -#define CB_SETTOPINDEX 348 -#define CB_GETHORIZONTALEXTENT 349 -#define CB_SETHORIZONTALEXTENT 350 -#define CB_GETDROPPEDWIDTH 351 -#define CB_SETDROPPEDWIDTH 352 -#define CB_INITSTORAGE 353 - -//-------------------------------------------------------------------// -/* - * Combo Box return Values - */ -#define CB_OKAY 0 -#define CB_ERR (-1) -#define CB_ERRSPACE (-2) - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * Static Control Constants - */ -#define SS_LEFT 0 // 0x00000000L -#define SS_CENTER 1 // 0x00000001L -#define SS_RIGHT 2 // 0x00000002L -#define SS_ICON 3 // 0x00000003L -#define SS_BLACKRECT 4 // 0x00000004L -#define SS_GRAYRECT 5 // 0x00000005L -#define SS_WHITERECT 6 // 0x00000006L -#define SS_BLACKFRAME 7 // 0x00000007L -#define SS_GRAYFRAME 8 // 0x00000008L -#define SS_WHITEFRAME 9 // 0x00000009L -#define SS_USERITEM 10 // 0x0000000AL -#define SS_SIMPLE 11 // 0x0000000BL -#define SS_LEFTNOWORDWRAP 12 // 0x0000000CL -#define SS_OWNERDRAW 13 // 0x0000000DL -#define SS_BITMAP 14 // 0x0000000EL -#define SS_ENHMETAFILE 15 // 0x0000000FL -#define SS_ETCHEDHORZ 16 // 0x00000010L -#define SS_ETCHEDVERT 17 // 0x00000011L -#define SS_ETCHEDFRAME 18 // 0x00000012L -#define SS_TYPEMASK 31 // 0x0000001FL -#define SS_NOPREFIX 128 // Don't do "&" character translation -#define SS_NOTIFY 256 // 0x00000100L -#define SS_CENTERIMAGE 512 // 0x00000200L -#define SS_RIGHTJUST 1024 // 0x00000400L -#define SS_REALSIZEIMAGE 2048 // 0x00000800L -#define SS_SUNKEN 4096 // 0x00001000L - -#define SS_ENDELLIPSIS 16384 -#define SS_PATHELLIPSIS 32768 -#define SS_WORDELLIPSIS 49152 -#define SS_ELLIPSISMASK 49152 - -//-------------------------------------------------------------------// -/* - * Static Control Mesages - */ -#define STM_SETICON 368 -#define STM_GETICON 369 -#define STM_SETIMAGE 370 -#define STM_GETIMAGE 371 - -#define STN_CLICKED 0 -#define STN_DBLCLK 1 -#define STN_ENABLE 2 -#define STN_DISABLE 3 - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * Listbox messages - */ -#define LB_ADDSTRING 384 -#define LB_INSERTSTRING 385 -#define LB_DELETESTRING 386 -#define LB_SELITEMRANGEEX 387 -#define LB_RESETCONTENT 388 -#define LB_SETSEL 389 -#define LB_SETCURSEL 390 -#define LB_GETSEL 391 -#define LB_GETCURSEL 392 -#define LB_GETTEXT 393 -#define LB_GETTEXTLEN 394 -#define LB_GETCOUNT 395 -#define LB_SELECTSTRING 396 -#define LB_DIR 397 -#define LB_GETTOPINDEX 398 -#define LB_FINDSTRING 399 -#define LB_GETSELCOUNT 400 -#define LB_GETSELITEMS 401 -#define LB_SETTABSTOPS 402 -#define LB_GETHORIZONTALEXTENT 403 -#define LB_SETHORIZONTALEXTENT 404 -#define LB_SETCOLUMNWIDTH 405 -#define LB_ADDFILE 406 -#define LB_SETTOPINDEX 407 -#define LB_GETITEMRECT 408 -#define LB_GETITEMDATA 409 -#define LB_SETITEMDATA 410 -#define LB_SELITEMRANGE 411 -#define LB_SETANCHORINDEX 412 -#define LB_GETANCHORINDEX 413 -#define LB_SETCARETINDEX 414 -#define LB_GETCARETINDEX 415 -#define LB_SETITEMHEIGHT 416 -#define LB_GETITEMHEIGHT 417 -#define LB_FINDSTRINGEXACT 418 -#define LB_SETLOCALE 421 -#define LB_GETLOCALE 422 -#define LB_SETCOUNT 423 -#define LB_INITSTORAGE 424 -#define LB_ITEMFROMPOINT 425 - -//-------------------------------------------------------------------// -/* - * Listbox Styles - */ -#define LBS_NOTIFY 1 -#define LBS_SORT 2 -#define LBS_NOREDRAW 4 -#define LBS_MULTIPLESEL 8 -#define LBS_OWNERDRAWFIXED 16 -#define LBS_OWNERDRAWVARIABLE 32 -#define LBS_HASSTRINGS 64 -#define LBS_USETABSTOPS 128 -#define LBS_NOINTEGRALHEIGHT 256 -#define LBS_MULTICOLUMN 512 -#define LBS_WANTKEYBOARDINPUT 1024 -#define LBS_EXTENDEDSEL 2048 -#define LBS_DISABLENOSCROLL 4096 -#define LBS_NODATA 8192 -#define LBS_NOSEL 16384 -#define LBS_STANDARD ( LBS_NOTIFY + LBS_SORT + WS_VSCROLL + WS_BORDER ) - -//-------------------------------------------------------------------// -/* - * Listbox Notification Codes - */ -#define LBN_ERRSPACE (-2) -#define LBN_SELCHANGE 1 -#define LBN_DBLCLK 2 -#define LBN_SELCANCEL 3 -#define LBN_SETFOCUS 4 -#define LBN_KILLFOCUS 5 - -//-------------------------------------------------------------------// -//-------------------------------------------------------------------// -/* - * MessageBox() Flags - */ -#define MB_OK 0 -#define MB_OKCANCEL 1 -#define MB_ABORTRETRYIGNORE 2 -#define MB_YESNOCANCEL 3 -#define MB_YESNO 4 -#define MB_RETRYCANCEL 5 -#define MB_CANCELTRYCONTINUE 6 - -#define MB_ICONHAND 16 -#define MB_ICONQUESTION 32 -#define MB_ICONEXCLAMATION 48 -#define MB_ICONASTERISK 64 - -#define MB_USERICON 128 -#define MB_ICONWARNING MB_ICONEXCLAMATION -#define MB_ICONERROR MB_ICONHAND - -#define MB_ICONINFORMATION MB_ICONASTERISK -#define MB_ICONSTOP MB_ICONHAND - -#define MB_DEFBUTTON1 0 -#define MB_DEFBUTTON2 256 -#define MB_DEFBUTTON3 512 -#define MB_DEFBUTTON4 768 - -#define MB_APPLMODAL 0 -#define MB_SYSTEMMODAL 4096 -#define MB_TASKMODAL 8192 -#define MB_HELP 16384 // Help Button - -#define MB_NOFOCUS 32768 -#define MB_SETFOREGROUND 65536 -#define MB_DEFAULT_DESKTOP_ONLY 131072 - -#define MB_TOPMOST 262144 -#define MB_RIGHT 524288 -#define MB_RTLREADING 1048576 - -#define MB_TYPEMASK 15 -#define MB_ICONMASK 240 -#define MB_DEFMASK 3840 -#define MB_MODEMASK 12288 -#define MB_MISCMASK 49152 - -//-------------------------------------------------------------------// -/* - * Stock Logical Objects - */ -#define WHITE_BRUSH 0 -#define LTGRAY_BRUSH 1 -#define GRAY_BRUSH 2 -#define DKGRAY_BRUSH 3 -#define BLACK_BRUSH 4 -#define NULL_BRUSH 5 -#define HOLLOW_BRUSH NULL_BRUSH - -#define WHITE_PEN 6 -#define BLACK_PEN 7 -#define NULL_PEN 8 - -#define OEM_FIXED_FONT 10 -#define ANSI_FIXED_FONT 11 -#define ANSI_VAR_FONT 12 -#define SYSTEM_FONT 13 -#define DEVICE_DEFAULT_FONT 14 -#define DEFAULT_PALETTE 15 -#define SYSTEM_FIXED_FONT 16 -#define DEFAULT_GUI_FONT 17 - -//-------------------------------------------------------------------// -/* - * WM_SETICON / WM_GETICON Type Codes - */ -#define ICON_SMALL 0 -#define ICON_BIG 1 - -//-------------------------------------------------------------------// - -#define IMAGE_BITMAP 0 -#define IMAGE_ICON 1 -#define IMAGE_CURSOR 2 -#define IMAGE_ENHMETAFILE 3 - -//-------------------------------------------------------------------// -/* - * DrawText() Format Flags - */ -#define DT_TOP 0 -#define DT_LEFT 0 -#define DT_CENTER 1 -#define DT_RIGHT 2 -#define DT_VCENTER 4 -#define DT_BOTTOM 8 -#define DT_WORDBREAK 16 -#define DT_SINGLELINE 32 -#define DT_EXPANDTABS 64 -#define DT_TABSTOP 128 -#define DT_NOCLIP 256 -#define DT_EXTERNALLEADING 512 -#define DT_CALCRECT 1024 -#define DT_NOPREFIX 2048 -#define DT_INTERNAL 4096 -#define DT_EDITCONTROL 8192 -#define DT_PATH_ELLIPSIS 16384 -#define DT_END_ELLIPSIS 32768 -#define DT_MODIFYSTRING 65536 -#define DT_RTLREADING 131072 -#define DT_WORD_ELLIPSIS 262144 -#define DT_NOFULLWIDTHCHARBREAK 524288 -#define DT_HIDEPREFIX 1048576 -#define DT_PREFIXONLY 2097152 - -//-------------------------------------------------------------------// -// Brush Styles -#define BS_SOLID 0 -#define BS_NULL 1 -#define BS_HOLLOW BS_NULL -#define BS_HATCHED 2 -#define BS_PATTERN 3 -#define BS_INDEXED 4 -#define BS_DIBPATTERN 5 -#define BS_DIBPATTERNPT 6 -#define BS_PATTERN8X8 7 -#define BS_DIBPATTERN8X8 8 -#define BS_MONOPATTERN 9 - -// Hatch Styles -#define HS_HORIZONTAL 0 // ----- -#define HS_VERTICAL 1 // ||||| -#define HS_FDIAGONAL 2 // \\\\\ -#define HS_BDIAGONAL 3 // ///// -#define HS_CROSS 4 // +++++ -#define HS_DIAGCROSS 5 // xxxxx - -// Pen Styles -#define PS_SOLID 0 -#define PS_DASH 1 // ------- -#define PS_DOT 2 // ....... -#define PS_DASHDOT 3 // _._._._ -#define PS_DASHDOTDOT 4 // _.._.._ -#define PS_NULL 5 -#define PS_INSIDEFRAME 6 -#define PS_USERSTYLE 7 -#define PS_ALTERNATE 8 -#define PS_STYLE_MASK 15 - -#define PS_ENDCAP_ROUND 0 -#define PS_ENDCAP_SQUARE 256 -#define PS_ENDCAP_FLAT 512 -#define PS_ENDCAP_MASK 3840 - -#define PS_JOIN_ROUND 0 -#define PS_JOIN_BEVEL 4096 -#define PS_JOIN_MITER 8192 -#define PS_JOIN_MASK 61440 - -#define PS_COSMETIC 0 -#define PS_GEOMETRIC 65536 -#define PS_TYPE_MASK 983040 - -//-------------------------------------------------------------------// -// font weight values -#define FW_DONTCARE 0 -#define FW_THIN 100 -#define FW_EXTRALIGHT 200 -#define FW_ULTRALIGHT 200 -#define FW_LIGHT 300 -#define FW_NORMAL 400 -#define FW_REGULAR 400 -#define FW_MEDIUM 500 -#define FW_SEMIBOLD 600 -#define FW_DEMIBOLD 600 -#define FW_BOLD 700 -#define FW_EXTRABOLD 800 -#define FW_ULTRABOLD 800 -#define FW_HEAVY 900 -#define FW_BLACK 900 - -//-------------------------------------------------------------------// -// font quality values -#define DEFAULT_QUALITY 0 -#define DRAFT_QUALITY 1 -#define PROOF_QUALITY 2 -#define NONANTIALIASED_QUALITY 3 // (WINVER >= 0x0400) -#define ANTIALISED_QUALITY 4 // (WINVER >= 0x0400) - -//-------------------------------------------------------------------// -// flags (CHOOSECOLOR structure) -#define CC_RGBINIT 1 // 0x00000001 -#define CC_FULLOPEN 2 // 0x00000002 -#define CC_PREVENTFULLOPEN 4 // 0x00000004 -#define CC_SHOWHELP 8 // 0x00000008 -#define CC_ENABLEHOOK 16 // 0x00000010 -#define CC_ENABLETEMPLATE 32 // 0x00000020 -#define CC_ENABLETEMPLATEHANDLE 64 // 0x00000040 -#define CC_SOLIDCOLOR 128 // 0x00000080 // WINVER >= 0x0400 -#define CC_ANYCOLOR 256 // 0x00000100 // WINVER >= 0x0400 - -//-------------------------------------------------------------------// -/* - * Window field offsets for GetWindowLong() - */ -#define GWL_WNDPROC (-4) -#define GWL_HINSTANCE (-6) -#define GWL_HWNDPARENT (-8) -#define GWL_STYLE (-16) -#define GWL_EXSTYLE (-20) -#define GWL_USERDATA (-21) -#define GWL_ID (-12) - -#define DWL_MSGRESULT 0 -#define DWL_DLGPROC 4 -#define DWL_USER 8 - -//--------------------------------------------------------------------// -/* - * Virtual Key Codes - */ -#define VK_LBUTTON 1 -#define VK_RBUTTON 2 -#define VK_CANCEL 3 -#define VK_MBUTTON 4 -#define VK_BACK 8 -#define VK_TAB 9 -#define VK_CLEAR 12 -#define VK_RETURN 13 -#define VK_SHIFT 16 -#define VK_CONTROL 17 -#define VK_MENU 18 -#define VK_PAUSE 19 -#define VK_CAPITAL 20 -#define VK_ESCAPE 27 -#define VK_SPACE 32 -#define VK_PRIOR 33 -#define VK_NEXT 34 -#define VK_END 35 -#define VK_HOME 36 -#define VK_LEFT 37 -#define VK_UP 38 -#define VK_RIGHT 39 -#define VK_DOWN 40 -#define VK_SELECT 41 -#define VK_PRINT 42 -#define VK_EXECUTE 43 -#define VK_SNAPSHOT 44 -#define VK_INSERT 45 -#define VK_DELETE 46 -#define VK_HELP 47 -#define VK_NUMPAD0 96 -#define VK_NUMPAD1 97 -#define VK_NUMPAD2 98 -#define VK_NUMPAD3 99 -#define VK_NUMPAD4 100 -#define VK_NUMPAD5 101 -#define VK_NUMPAD6 102 -#define VK_NUMPAD7 103 -#define VK_NUMPAD8 104 -#define VK_NUMPAD9 105 -#define VK_MULTIPLY 106 -#define VK_ADD 107 -#define VK_SEPARATOR 108 -#define VK_SUBTRACT 109 -#define VK_DECIMAL 110 -#define VK_DIVIDE 111 -#define VK_F1 112 -#define VK_F2 113 -#define VK_F3 114 -#define VK_F4 115 -#define VK_F5 116 -#define VK_F6 117 -#define VK_F7 118 -#define VK_F8 119 -#define VK_F9 120 -#define VK_F10 121 -#define VK_F11 122 -#define VK_F12 123 -#define VK_F13 124 -#define VK_F14 125 -#define VK_F15 126 -#define VK_F16 127 -#define VK_F17 128 -#define VK_F18 129 -#define VK_F19 130 -#define VK_F20 131 -#define VK_F21 132 -#define VK_F22 133 -#define VK_F23 134 -#define VK_F24 135 -#define VK_NUMLOCK 144 -#define VK_SCROLL 145 - -//----------------------------------------------------------------------// -/* - * File Open/Save Dialog Constants - */ -#define OFN_READONLY 1 -#define OFN_OVERWRITEPROMPT 2 -#define OFN_HIDEREADONLY 4 -#define OFN_NOCHANGEDIR 8 -#define OFN_SHOWHELP 16 -#define OFN_ENABLEHOOK 32 -#define OFN_ENABLETEMPLATE 64 -#define OFN_ENABLETEMPLATEHANDLE 128 -#define OFN_NOVALIDATE 256 -#define OFN_ALLOWMULTISELECT 512 -#define OFN_EXTENSIONDIFFERENT 1024 -#define OFN_PATHMUSTEXIST 2048 -#define OFN_FILEMUSTEXIST 4096 -#define OFN_CREATEPROMPT 8192 -#define OFN_SHAREAWARE 16384 -#define OFN_NOREADONLYRETURN 32768 -#define OFN_NOTESTFILECREATE 65536 -#define OFN_NONETWORKBUTTON 131072 -#define OFN_NOLONGNAMES 262144 // force no long names for 4.x modules -#define OFN_EXPLORER 524288 // new look commdlg -#define OFN_NODEREFERENCELINKS 1048576 -#define OFN_LONGNAMES 2097152 // force long names for 3.x modules -#define OFN_ENABLEINCLUDENOTIFY 4194304 // send include message to callback -#define OFN_ENABLESIZING 8388608 -#define OFN_DONTADDTORECENT 33554432 -#define OFN_FORCESHOWHIDDEN 268435456 // Show All files including System and hidden files - -//----------------------------------------------------------------------// +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Header file for the WVT*Classes + * + * Copyright 2004 Pritpal Bedi + * www - http://www.xharbour.org 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. + * + */ +//-------------------------------------------------------------------// +// +// GTWVT Specific +// +//-------------------------------------------------------------------// +// +// Wvt_DrawButton() constants +// +#define WVT_BTN_FORMAT_RAISED 0 // Default +#define WVT_BTN_FORMAT_RECESSED 1 +#define WVT_BTN_FORMAT_FLAT 2 +#define WVT_BTN_FORMAT_OUTLINED 3 + +#define WVT_BTN_IMAGE_TOP 0 // Default +#define WVT_BTN_IMAGE_LEFT 1 +#define WVT_BTN_IMAGE_BOTTOM 2 +#define WVT_BTN_IMAGE_RIGHT 3 + +//-------------------------------------------------------------------// +// +// Wvt_DrawLine( nTop, nLeft, nBottom, nRight, nOrient, nFormat,; +// nAlign, nStyle, nThick, nColor ) +// +// nOrient +#define WVT_LINE_HORZ 0 // Default +#define WVT_LINE_VERT 1 + +// nFormat +#define WVT_LINE_RAISED 0 // Default +#define WVT_LINE_RECESSED 1 +#define WVT_LINE_PLAIN 2 + +// nAlign +#define WVT_LINE_CENTER 0 // Default +#define WVT_LINE_TOP 1 +#define WVT_LINE_BOTTOM 2 +#define WVT_LINE_LEFT 3 +#define WVT_LINE_RIGHT 4 + +// nStyle +#define WVT_LINE_SOLID 0 // Default +#define WVT_LINE_DASH 1 +#define WVT_LINE_DOT 2 +#define WVT_LINE_DASHDOT 3 +#define WVT_LINE_DASHDOTDOT 4 + +//-------------------------------------------------------------------// +// +// Standard Mouse Pointer Shape Constants +// +#define WVT_IDC_ARROW 1 +#define WVT_IDC_IBEAM 2 +#define WVT_IDC_WAIT 3 +#define WVT_IDC_CROSS 4 +#define WVT_IDC_UPARROW 5 +#define WVT_IDC_SIZE 6 +#define WVT_IDC_ICON 7 +#define WVT_IDC_SIZENWSE 8 +#define WVT_IDC_SIZENESW 9 +#define WVT_IDC_SIZEWE 10 +#define WVT_IDC_SIZENS 11 +#define WVT_IDC_SIZEALL 12 +#define WVT_IDC_NO 13 +#define WVT_IDC_HAND 14 +#define WVT_IDC_APPSTARTING 15 +#define WVT_IDC_HELP 16 + +//-------------------------------------------------------------------// + +#define WVT_BLOCK_IMAGE 1 +#define WVT_BLOCK_BOX 2 +#define WVT_BLOCK_LABEL 3 +#define WVT_BLOCK_GRID_V 4 +#define WVT_BLOCK_GRID_H 5 +#define WVT_BLOCK_BUTTON 6 +#define WVT_BLOCK_GETS 7 +#define WVT_BLOCK_LINE 8 +#define WVT_BLOCK_STATUSBAR 9 +#define WVT_BLOCK_TOOLBAR 10 +#define WVT_BLOCK_STATIC 11 + +//-------------------------------------------------------------------// + +#define DLG_OBJ_BROWSE 1 +#define DLG_OBJ_PICTURE 2 +#define DLG_OBJ_LINE 3 +#define DLG_OBJ_RECT 4 +#define DLG_OBJ_GETS 5 +#define DLG_OBJ_BUTTON 6 +#define DLG_OBJ_STATUSBAR 7 +#define DLG_OBJ_PANEL 8 +#define DLG_OBJ_LABEL 9 +#define DLG_OBJ_STATIC 10 +#define DLG_OBJ_TOOLBAR 11 +#define DLG_OBJ_IMAGE 12 +#define DLG_OBJ_PUSHBUTTON 13 +#define DLG_OBJ_CONSOLE 14 +#define DLG_OBJ_SCROLLBAR 15 +#define DLG_OBJ_BANNER 16 +#define DLG_OBJ_TEXTBOX 17 +#define DLG_OBJ_PROGRESSBAR 18 + +//-------------------------------------------------------------------// + +#define TLB_BUTTON_TYPE_IMAGE 0 +#define TLB_BUTTON_TYPE_SEPARATOR 1 +#define TLB_BUTTON_TYPE_TEXT 2 + +//-------------------------------------------------------------------// + +#define WVT_STATIC_LINE 1 +#define WVT_STATIC_BOXRAISED 2 +#define WVT_STATIC_BOXRECESSED 3 +#define WVT_STATIC_BOXGROUP 4 +#define WVT_STATIC_BOXGROUPRAISED 5 +#define WVT_STATIC_RECTANGLE 6 +#define WVT_STATIC_ROUNDRECT 7 +#define WVT_STATIC_FOCUSRECT 8 +#define WVT_STATIC_OUTLINE 9 +#define WVT_STATIC_ELLIPSE 10 +#define WVT_STATIC_SHADEDRECT 11 + +#define WVT_SCROLLBAR_VERT 1 +#define WVT_SCROLLBAR_HORZ 2 + +#define WVT_SCROLLBUTTON_TOP 1 +#define WVT_SCROLLBUTTON_LEFT 2 +#define WVT_SCROLLBUTTON_BOTTOM 3 +#define WVT_SCROLLBUTTON_RIGHT 4 +#define WVT_SCROLL_THUMB 5 + +//-------------------------------------------------------------------// +// +// wvtmenu defines . Peter Rees +// +#define WVT_MENU_TYPE 1 +#define WVT_MENU_IDENTIFIER 2 +#define WVT_MENU_CAPTION 3 +#define WVT_MENU_ACTION 4 +#define WVT_MENU_MENUOBJ 4 + +//-------------------------------------------------------------------// + +#define ISBLOCK( x ) valtype( x ) == 'B' + +#define RGB( nR,nG,nB ) ( nR + ( nG * 256 ) + ( nB * 256 * 256 ) ) + +//-------------------------------------------------------------------// +// +// Windows Specific +// +//-------------------------------------------------------------------// +// +// Menu Manipulation Constants +// +#define MF_INSERT 0 +#define MF_CHANGE 128 +#define MF_APPEND 256 +#define MF_DELETE 512 +#define MF_REMOVE 4096 + +#define MF_BYCOMMAND 0 +#define MF_BYPOSITION 1024 + +#define MF_SEPARATOR 2048 + +#define MF_ENABLED 0 +#define MF_GRAYED 1 +#define MF_DISABLED 2 + +#define MF_UNCHECKED 0 +#define MF_CHECKED 8 +#define MF_USECHECKBITMAPS 512 + +#define MF_STRING 0 +#define MF_BITMAP 4 +#define MF_OWNERDRAW 256 + +#define MF_POPUP 16 +#define MF_MENUBARBREAK 32 +#define MF_MENUBREAK 64 + +#define MF_UNHILITE 0 +#define MF_HILITE 128 + +//-------------------------------------------------------------------// + +#define TPM_LEFTBUTTON 0x0000 +#define TPM_RIGHTBUTTON 0x0002 + +#define TPM_LEFTALIGN 0x0000 +#define TPM_CENTERALIGN 0x0004 +#define TPM_RIGHTALIGN 0x0008 + +#define TPM_TOPALIGN 0x0000 +#define TPM_VCENTERALIGN 0x0010 +#define TPM_BOTTOMALIGN 0x0020 + +#define TPM_HORIZONTAL 0x0000 /* Horz alignment matters more */ +#define TPM_VERTICAL 0x0040 /* Vert alignment matters more */ +#define TPM_NONOTIFY 0x0080 /* Don't send any notification msgs */ +#define TPM_RETURNCMD 0x0100 + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * ShowWindow() Commands + */ +#define SW_HIDE 0 +#define SW_SHOWNORMAL 1 +#define SW_NORMAL 1 +#define SW_SHOWMINIMIZED 2 +#define SW_SHOWMAXIMIZED 3 +#define SW_MAXIMIZE 3 +#define SW_SHOWNOACTIVATE 4 +#define SW_SHOW 5 +#define SW_MINIMIZE 6 +#define SW_SHOWMINNOACTIVE 7 +#define SW_SHOWNA 8 +#define SW_RESTORE 9 +#define SW_SHOWDEFAULT 10 +#define SW_FORCEMINIMIZE 11 +#define SW_MAX 11 + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * Window Messages + */ +#define WM_USER 1024 + +#define WM_CREATE 1 +#define WM_DESTROY 2 +#define WM_MOVE 3 +#define WM_SIZE 5 +#define WM_ACTIVATE 6 +#define WM_SETFOCUS 7 +#define WM_KILLFOCUS 8 +#define WM_ENABLE 10 +#define WM_SETREDRAW 11 +#define WM_SETTEXT 12 +#define WM_GETTEXT 13 +#define WM_GETTEXTLENGTH 14 +#define WM_PAINT 15 +#define WM_CLOSE 16 // 0x0010 +#define WM_QUIT 18 // 0x0012 +#define WM_ERASEBKGND 20 // 0x0014 +#define WM_SYSCOLORCHANGE 21 // 0x0015 +#define WM_SHOWWINDOW 24 // 0x0018 +#define WM_WININICHANGE 26 // 0x001A +#define WM_DEVMODECHANGE 27 // 0x001B +#define WM_ACTIVATEAPP 28 // 0x001C +#define WM_FONTCHANGE 29 // 0x001D +#define WM_TIMECHANGE 30 // 0x001E +#define WM_CANCELMODE 31 // 0x001F +#define WM_SETCURSOR 32 // 0x0020 +#define WM_MOUSEACTIVATE 33 // 0x0021 +#define WM_CHILDACTIVATE 34 // 0x0022 +#define WM_QUEUESYNC 35 // 0x0023 +#define WM_GETMINMAXINFO 36 + +#define WM_PAINTICON 38 +#define WM_ICONERASEBKGND 39 +#define WM_NEXTDLGCTL 40 +#define WM_SPOOLERSTATUS 42 +#define WM_DRAWITEM 43 // 0x002B +#define WM_MEASUREITEM 44 +#define WM_DELETEITEM 45 +#define WM_VKEYTOITEM 46 +#define WM_CHARTOITEM 47 +#define WM_SETFONT 48 +#define WM_GETFONT 49 +#define WM_SETHOTKEY 50 +#define WM_GETHOTKEY 51 +#define WM_QUERYDRAGICON 55 +#define WM_COMPAREITEM 57 +#define WM_GETOBJECT 61 +#define WM_COMPACTING 65 // 0x0041 +#define WM_COMMNOTIFY 68 // 0x0044 /* no longer suported */ +#define WM_WINDOWPOSCHANGING 70 // 0x0046 +#define WM_WINDOWPOSCHANGED 71 // 0x0047 +#define WM_POWER 72 +#define WM_NOTIFY 78 // 0x004E +#define WM_INPUTLANGCHANGEREQUEST 79 // 0x0050 +#define WM_INPUTLANGCHANGE 80 // 0x0051 +#define WM_TCARD 81 // 0x0052 +#define WM_HELP 82 // 0x0053 +#define WM_USERCHANGED 83 // 0x0054 +#define WM_NOTIFYFORMAT 84 // 0x0055 + +#define WM_CONTEXTMENU 123 // 0x007B +#define WM_STYLECHANGING 124 // 0x007C +#define WM_STYLECHANGED 125 // 0x007D +#define WM_DISPLAYCHANGE 126 // 0x007E +#define WM_GETICON 127 // 0x007F +#define WM_SETICON 128 // 0x0080 + +#define WM_NCCREATE 129 +#define WM_NCDESTROY 130 +#define WM_NCCALCSIZE 131 +#define WM_NCHITTEST 132 +#define WM_NCPAINT 133 +#define WM_NCACTIVATE 134 +#define WM_GETDLGCODE 135 + +#define WM_NCMOUSEMOVE 160 +#define WM_NCLBUTTONDOWN 161 +#define WM_NCLBUTTONUP 162 + +#define WM_NCLBUTTONDBLCLK 163 + +#define WM_NCRBUTTONDOWN 164 +#define WM_NCRBUTTONUP 165 +#define WM_NCRBUTTONDBLCLK 166 +#define WM_NCMBUTTONDOWN 167 +#define WM_NCMBUTTONUP 168 +#define WM_NCMBUTTONDBLCLK 169 + +#define WM_KEYDOWN 256 // 0x0100 +#define WM_KEYUP 257 // 0x0101 + +#define WM_KEYFIRST 256 +#define WM_CHAR 258 +#define WM_DEADCHAR 259 +#define WM_SYSKEYDOWN 260 +#define WM_SYSKEYUP 261 +#define WM_SYSCHAR 262 +#define WM_SYSDEADCHAR 263 +#define WM_KEYLAST 264 + +#define WM_INITDIALOG 272 +#define WM_COMMAND 273 +#define WM_SYSCOMMAND 274 +#define WM_TIMER 275 +#define WM_HSCROLL 276 +#define WM_VSCROLL 277 + +#define WM_INITMENUPOPUP 279 +#define WM_MENUSELECT 287 +#define WM_MENUCOMMAND 294 + +#define WM_CTLCOLORMSGBOX 306 +#define WM_CTLCOLOREDIT 307 +#define WM_CTLCOLORLISTBOX 308 +#define WM_CTLCOLORBTN 309 +#define WM_CTLCOLORDLG 310 +#define WM_CTLCOLORSCROLLBAR 311 +#define WM_CTLCOLORSTATIC 312 + +#define WM_MOUSEFIRST 512 +#define WM_MOUSEMOVE 512 +#define WM_LBUTTONDOWN 513 +#define WM_LBUTTONUP 514 +#define WM_LBUTTONDBLCLK 515 +#define WM_RBUTTONDOWN 516 +#define WM_RBUTTONUP 517 +#define WM_RBUTTONDBLCLK 518 +#define WM_MBUTTONDOWN 519 +#define WM_MBUTTONUP 520 +#define WM_MBUTTONDBLCLK 521 +#define WM_MOUSEWHEEL 522 +#define WM_XBUTTONDOWN 523 +#define WM_XBUTTONUP 524 +#define WM_XBUTTONDBLCLK 525 + +#define WM_PARENTNOTIFY 528 +#define WM_ENTERMENULOOP 529 +#define WM_EXITMENULOOP 530 + +#define WM_NEXTMENU 531 +#define WM_SIZING 532 +#define WM_CAPTURECHANGED 533 +#define WM_MOVING 534 +#define WM_POWERBROADCAST 536 + +#define WM_MDICREATE 544 +#define WM_MDIDESTROY 545 +#define WM_MDIACTIVATE 546 +#define WM_MDIRESTORE 547 +#define WM_MDINEXT 548 +#define WM_MDIMAXIMIZE 549 +#define WM_MDITILE 550 +#define WM_MDICASCADE 551 +#define WM_MDIICONARRANGE 552 +#define WM_MDIGETACTIVE 553 + +#define WM_MDISETMENU 560 +#define WM_ENTERSIZEMOVE 561 +#define WM_EXITSIZEMOVE 562 +#define WM_DROPFILES 563 +#define WM_MDIREFRESHMENU 564 + +#define WM_CUT 768 +#define WM_COPY 769 +#define WM_PASTE 770 +#define WM_CLEAR 771 +#define WM_UNDO 772 +#define WM_RENDERFORMAT 773 +#define WM_RENDERALLFORMATS 774 +#define WM_DESTROYCLIPBOARD 775 +#define WM_DRAWCLIPBOARD 776 +#define WM_PAINTCLIPBOARD 777 +#define WM_VSCROLLCLIPBOARD 778 +#define WM_SIZECLIPBOARD 779 +#define WM_ASKCBFORMATNAME 780 +#define WM_CHANGECBCHAIN 781 +#define WM_HSCROLLCLIPBOARD 782 +#define WM_QUERYNEWPALETTE 783 +#define WM_PALETTEISCHANGING 784 +#define WM_PALETTECHANGED 785 +#define WM_HOTKEY 786 + +//-------------------------------------------------------------------// +/* + * Window Styles + */ +#define WS_OVERLAPPED 0 +#define WS_POPUP 2147483648 // 0x80000000L +#define WS_CHILD 1073741824 // 0x40000000L +#define WS_MINIMIZE 536870912 // 0x20000000L +#define WS_VISIBLE 268435456 // 0x10000000L +#define WS_DISABLED 134217728 // 0x08000000L +#define WS_BORDER 8388608 // 0x00800000L +#define WS_DLGFRAME 4194304 // 0x00400000L +#define WS_VSCROLL 2097152 // 0x00200000L +#define WS_HSCROLL 1048576 // 0x00100000L +#define WS_SYSMENU 524288 // 0x00080000L +#define WS_THICKFRAME 262144 // 0x00040000L +#define WS_GROUP 131072 // 0x00020000L +#define WS_TABSTOP 65536 // 0x00010000L +#define WS_CLIPSIBLINGS 67108864 +#define WS_CLIPCHILDREN 33554432 +#define WS_MAXIMIZE 16777216 +#define WS_CAPTION 12582912 /* WS_BORDER | WS_DLGFRAME */ + +#define WS_MINIMIZEBOX 131072 +#define WS_MAXIMIZEBOX 65536 + +#define WS_TILED WS_OVERLAPPED +#define WS_ICONIC WS_MINIMIZE +#define WS_SIZEBOX WS_THICKFRAME +#define WS_TILEDWINDOW WS_OVERLAPPEDWINDOW + +#define WS_OVERLAPPEDWINDOW (WS_OVERLAPPED + ; + WS_CAPTION + ; + WS_SYSMENU + ; + WS_THICKFRAME + ; + WS_MINIMIZEBOX + ; + WS_MAXIMIZEBOX ) + +//-------------------------------------------------------------------// +/* + * Extended Window Styles + */ +#define WS_EX_DLGMODALFRAME 1 // 0x00000001L +#define WS_EX_NOPARENTNOTIFY 4 // 0x00000004L +#define WS_EX_TOPMOST 8 // 0x00000008L +#define WS_EX_ACCEPTFILES 16 // 0x00000010L +#define WS_EX_TRANSPARENT 32 // 0x00000020L +#define WS_EX_MDICHILD 64 // 0x00000040L +#define WS_EX_TOOLWINDOW 128 // 0x00000080L +#define WS_EX_WINDOWEDGE 256 // 0x00000100L +#define WS_EX_CLIENTEDGE 512 // 0x00000200L +#define WS_EX_CONTEXTHELP 1024 // 0x00000400L + +#define WS_EX_RIGHT 4096 // 0x00001000L +#define WS_EX_LEFT 0 // 0x00000000L +#define WS_EX_RTLREADING 8192 // 0x00002000L +#define WS_EX_LTRREADING 0 // 0x00000000L +#define WS_EX_LEFTSCROLLBAR 16384 // 0x00004000L +#define WS_EX_RIGHTSCROLLBAR 0 // 0x00000000L + +#define WS_EX_CONTROLPARENT 65536 // 0x00010000L +#define WS_EX_STATICEDGE 131072 // 0x00020000L +#define WS_EX_APPWINDOW 262144 // 0x00040000L + +#define WS_EX_OVERLAPPEDWINDOW (WS_EX_WINDOWEDGE + WS_EX_CLIENTEDGE) +#define WS_EX_PALETTEWINDOW (WS_EX_WINDOWEDGE + WS_EX_TOOLWINDOW + WS_EX_TOPMOST) + +#define WS_EX_LAYERED 524288 // 0x00080000 +#define WS_EX_NOINHERITLAYOUT 1048576 // 0x00100000L // Disable inheritence of mirroring by children +#define WS_EX_LAYOUTRTL 4194304 // 0x00400000L // Right to left mirroring +#define WS_EX_NOACTIVATE 134217728 // 0x08000000L + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * Dialog styles + */ +#define DS_ABSALIGN 1 // 0x01 +#define DS_SYSMODAL 2 // 0x02 +#define DS_3DLOOK 4 // 0x04 +#define DS_FIXEDSYS 8 // 0x08 +#define DS_NOFAILCREATE 16 // 0x10 +#define DS_LOCALEDIT 32 // 0x20 +#define DS_SETFONT 64 // 0x40 +#define DS_MODALFRAME 128 // 0x80 +#define DS_NOIDLEMSG 256 // 0x100 +#define DS_CONTROL 1024 // 0x400 +#define DS_CENTER 2048 // 0x800 +#define DS_CENTERMOUSE 4096 // 0x1000 +#define DS_CONTEXTHELP 8192 // 0x2000 + +//-------------------------------------------------------------------// +/* + * Dialog Box Command IDs + */ +#define IDOK 1 +#define IDCANCEL 2 +#define IDABORT 3 +#define IDRETRY 4 +#define IDIGNORE 5 +#define IDYES 6 +#define IDNO 7 +#define IDTRYAGAIN 10 // (WINVER >= 0x0500) +#define IDCONTINUE 11 // (WINVER >= 0x0500) + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * Button Control Styles + */ +#define BS_PUSHBUTTON 0 // 0x00000000L +#define BS_DEFPUSHBUTTON 1 // 0x00000001L +#define BS_CHECKBOX 2 // 0x00000002L +#define BS_AUTOCHECKBOX 3 // 0x00000003L +#define BS_RADIOBUTTON 4 // 0x00000004L +#define BS_3STATE 5 // 0x00000005L +#define BS_AUTO3STATE 6 // 0x00000006L +#define BS_GROUPBOX 7 // 0x00000007L +#define BS_USERBUTTON 8 // 0x00000008L +#define BS_AUTORADIOBUTTON 9 // 0x00000009L +#define BS_OWNERDRAW 11 // 0x0000000BL +#define BS_LEFTTEXT 32 // 0x00000020L + +//-------------------------------------------------------------------// +/* + * User Button Notification Codes + */ +#define BN_CLICKED 0 +#define BN_PAINT 1 +#define BN_HILITE 2 +#define BN_UNHILITE 3 +#define BN_DISABLE 4 +#define BN_DOUBLECLICKED 5 +#define BN_PUSHED BN_HILITE +#define BN_UNPUSHED BN_UNHILITE +#define BN_DBLCLK BN_DOUBLECLICKED +#define BN_SETFOCUS 6 +#define BN_KILLFOCUS 7 + +//-------------------------------------------------------------------// +/* + * Button Control Messages + */ +#define BM_GETCHECK 240 +#define BM_SETCHECK 241 +#define BM_GETSTATE 242 +#define BM_SETSTATE 243 +#define BM_SETSTYLE 244 +#define BM_CLICK 245 +#define BM_GETIMAGE 246 +#define BM_SETIMAGE 247 + +#define BST_UNCHECKED 0 +#define BST_CHECKED 1 +#define BST_INDETERMINATE 2 +#define BST_PUSHED 4 +#define BST_FOCUS 8 + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * Edit Control Styles + */ +#define ES_LEFT 0 +#define ES_CENTER 1 +#define ES_RIGHT 2 +#define ES_MULTILINE 4 +#define ES_UPPERCASE 8 +#define ES_LOWERCASE 16 +#define ES_PASSWORD 32 +#define ES_AUTOVSCROLL 64 +#define ES_AUTOHSCROLL 128 +#define ES_NOHIDESEL 256 +#define ES_OEMCONVERT 1024 +#define ES_READONLY 2048 +#define ES_WANTRETURN 4096 +#define ES_NUMBER 8192 + +//-------------------------------------------------------------------// +/* + * Edit Control Notification Codes + */ +#define EN_SETFOCUS 256 // 0x0100 +#define EN_KILLFOCUS 512 // 0x0200 +#define EN_CHANGE 768 // 0x0300 +#define EN_UPDATE 1024 // 0x0400 +#define EN_ERRSPACE 1280 // 0x0500 +#define EN_MAXTEXT 1281 // 0x0501 +#define EN_HSCROLL 1537 // 0x0601 +#define EN_VSCROLL 1538 // 0x0602 + +//----------------------------------------------------------------------// +/* + * Edit Control Messages + */ +#define EM_GETSEL 176 +#define EM_SETSEL 177 +#define EM_GETRECT 178 +#define EM_SETRECT 179 +#define EM_SETRECTNP 180 +#define EM_SCROLL 181 +#define EM_LINESCROLL 182 +#define EM_SCROLLCARET 183 +#define EM_GETMODIFY 184 +#define EM_SETMODIFY 185 +#define EM_GETLINECOUNT 186 +#define EM_LINEINDEX 187 +#define EM_SETHANDLE 188 +#define EM_GETHANDLE 189 +#define EM_GETTHUMB 190 +#define EM_LINELENGTH 193 +#define EM_REPLACESEL 194 +#define EM_GETLINE 196 +#define EM_LIMITTEXT 197 +#define EM_CANUNDO 198 +#define EM_UNDO 199 +#define EM_FMTLINES 200 +#define EM_LINEFROMCHAR 201 +#define EM_SETTABSTOPS 203 +#define EM_SETPASSWORDCHAR 204 +#define EM_EMPTYUNDOBUFFER 205 +#define EM_GETFIRSTVISIBLELINE 206 +#define EM_SETREADONLY 207 +#define EM_SETWORDBREAKPROC 208 +#define EM_GETWORDBREAKPROC 209 +#define EM_GETPASSWORDCHAR 210 +#define EM_SETMARGINS 211 +#define EM_GETMARGINS 212 +#define EM_SETLIMITTEXT EM_LIMITTEXT +#define EM_GETLIMITTEXT 213 +#define EM_POSFROMCHAR 214 +#define EM_CHARFROMPOS 215 + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * Combo Box styles + */ +#define CBS_SIMPLE 1 // 0x0001L +#define CBS_DROPDOWN 2 // 0x0002L +#define CBS_DROPDOWNLIST 3 // 0x0003L +#define CBS_OWNERDRAWFIXED 16 // 0x0010L +#define CBS_OWNERDRAWVARIABLE 32 // 0x0020L +#define CBS_AUTOHSCROLL 64 // 0x0040L +#define CBS_OEMCONVERT 128 // 0x0080L +#define CBS_SORT 256 // 0x0100L +#define CBS_HASSTRINGS 512 // 0x0200L +#define CBS_NOINTEGRALHEIGHT 1024 // 0x0400L +#define CBS_DISABLENOSCROLL 2048 // 0x0800L +#define CBS_UPPERCASE 8192 // 0x2000L +#define CBS_LOWERCASE 16384 // 0x4000L + +//-------------------------------------------------------------------// +/* + * Combo Box Notification Codes + */ +#define CBN_ERRSPACE (-1) +#define CBN_SELCHANGE 1 +#define CBN_DBLCLK 2 +#define CBN_SETFOCUS 3 +#define CBN_KILLFOCUS 4 +#define CBN_EDITCHANGE 5 +#define CBN_EDITUPDATE 6 +#define CBN_DROPDOWN 7 +#define CBN_CLOSEUP 8 +#define CBN_SELENDOK 9 +#define CBN_SELENDCANCEL 10 + +//-------------------------------------------------------------------// +/* + * Combo Box messages + */ +#define CB_GETEDITSEL 320 +#define CB_LIMITTEXT 321 +#define CB_SETEDITSEL 322 +#define CB_ADDSTRING 323 +#define CB_DELETESTRING 324 +#define CB_DIR 325 +#define CB_GETCOUNT 326 +#define CB_GETCURSEL 327 +#define CB_GETLBTEXT 328 +#define CB_GETLBTEXTLEN 329 +#define CB_INSERTSTRING 330 +#define CB_RESETCONTENT 331 +#define CB_FINDSTRING 332 +#define CB_SELECTSTRING 333 +#define CB_SETCURSEL 334 +#define CB_SHOWDROPDOWN 335 +#define CB_GETITEMDATA 336 +#define CB_SETITEMDATA 337 +#define CB_GETDROPPEDCONTROLRECT 338 +#define CB_SETITEMHEIGHT 339 +#define CB_GETITEMHEIGHT 340 +#define CB_SETEXTENDEDUI 341 +#define CB_GETEXTENDEDUI 342 +#define CB_GETDROPPEDSTATE 343 +#define CB_FINDSTRINGEXACT 344 +#define CB_SETLOCALE 345 +#define CB_GETLOCALE 346 +#define CB_GETTOPINDEX 347 +#define CB_SETTOPINDEX 348 +#define CB_GETHORIZONTALEXTENT 349 +#define CB_SETHORIZONTALEXTENT 350 +#define CB_GETDROPPEDWIDTH 351 +#define CB_SETDROPPEDWIDTH 352 +#define CB_INITSTORAGE 353 + +//-------------------------------------------------------------------// +/* + * Combo Box return Values + */ +#define CB_OKAY 0 +#define CB_ERR (-1) +#define CB_ERRSPACE (-2) + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * Static Control Constants + */ +#define SS_LEFT 0 // 0x00000000L +#define SS_CENTER 1 // 0x00000001L +#define SS_RIGHT 2 // 0x00000002L +#define SS_ICON 3 // 0x00000003L +#define SS_BLACKRECT 4 // 0x00000004L +#define SS_GRAYRECT 5 // 0x00000005L +#define SS_WHITERECT 6 // 0x00000006L +#define SS_BLACKFRAME 7 // 0x00000007L +#define SS_GRAYFRAME 8 // 0x00000008L +#define SS_WHITEFRAME 9 // 0x00000009L +#define SS_USERITEM 10 // 0x0000000AL +#define SS_SIMPLE 11 // 0x0000000BL +#define SS_LEFTNOWORDWRAP 12 // 0x0000000CL +#define SS_OWNERDRAW 13 // 0x0000000DL +#define SS_BITMAP 14 // 0x0000000EL +#define SS_ENHMETAFILE 15 // 0x0000000FL +#define SS_ETCHEDHORZ 16 // 0x00000010L +#define SS_ETCHEDVERT 17 // 0x00000011L +#define SS_ETCHEDFRAME 18 // 0x00000012L +#define SS_TYPEMASK 31 // 0x0000001FL +#define SS_NOPREFIX 128 // Don't do "&" character translation +#define SS_NOTIFY 256 // 0x00000100L +#define SS_CENTERIMAGE 512 // 0x00000200L +#define SS_RIGHTJUST 1024 // 0x00000400L +#define SS_REALSIZEIMAGE 2048 // 0x00000800L +#define SS_SUNKEN 4096 // 0x00001000L + +#define SS_ENDELLIPSIS 16384 +#define SS_PATHELLIPSIS 32768 +#define SS_WORDELLIPSIS 49152 +#define SS_ELLIPSISMASK 49152 + +//-------------------------------------------------------------------// +/* + * Static Control Mesages + */ +#define STM_SETICON 368 +#define STM_GETICON 369 +#define STM_SETIMAGE 370 +#define STM_GETIMAGE 371 + +#define STN_CLICKED 0 +#define STN_DBLCLK 1 +#define STN_ENABLE 2 +#define STN_DISABLE 3 + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * Listbox messages + */ +#define LB_ADDSTRING 384 +#define LB_INSERTSTRING 385 +#define LB_DELETESTRING 386 +#define LB_SELITEMRANGEEX 387 +#define LB_RESETCONTENT 388 +#define LB_SETSEL 389 +#define LB_SETCURSEL 390 +#define LB_GETSEL 391 +#define LB_GETCURSEL 392 +#define LB_GETTEXT 393 +#define LB_GETTEXTLEN 394 +#define LB_GETCOUNT 395 +#define LB_SELECTSTRING 396 +#define LB_DIR 397 +#define LB_GETTOPINDEX 398 +#define LB_FINDSTRING 399 +#define LB_GETSELCOUNT 400 +#define LB_GETSELITEMS 401 +#define LB_SETTABSTOPS 402 +#define LB_GETHORIZONTALEXTENT 403 +#define LB_SETHORIZONTALEXTENT 404 +#define LB_SETCOLUMNWIDTH 405 +#define LB_ADDFILE 406 +#define LB_SETTOPINDEX 407 +#define LB_GETITEMRECT 408 +#define LB_GETITEMDATA 409 +#define LB_SETITEMDATA 410 +#define LB_SELITEMRANGE 411 +#define LB_SETANCHORINDEX 412 +#define LB_GETANCHORINDEX 413 +#define LB_SETCARETINDEX 414 +#define LB_GETCARETINDEX 415 +#define LB_SETITEMHEIGHT 416 +#define LB_GETITEMHEIGHT 417 +#define LB_FINDSTRINGEXACT 418 +#define LB_SETLOCALE 421 +#define LB_GETLOCALE 422 +#define LB_SETCOUNT 423 +#define LB_INITSTORAGE 424 +#define LB_ITEMFROMPOINT 425 + +//-------------------------------------------------------------------// +/* + * Listbox Styles + */ +#define LBS_NOTIFY 1 +#define LBS_SORT 2 +#define LBS_NOREDRAW 4 +#define LBS_MULTIPLESEL 8 +#define LBS_OWNERDRAWFIXED 16 +#define LBS_OWNERDRAWVARIABLE 32 +#define LBS_HASSTRINGS 64 +#define LBS_USETABSTOPS 128 +#define LBS_NOINTEGRALHEIGHT 256 +#define LBS_MULTICOLUMN 512 +#define LBS_WANTKEYBOARDINPUT 1024 +#define LBS_EXTENDEDSEL 2048 +#define LBS_DISABLENOSCROLL 4096 +#define LBS_NODATA 8192 +#define LBS_NOSEL 16384 +#define LBS_STANDARD ( LBS_NOTIFY + LBS_SORT + WS_VSCROLL + WS_BORDER ) + +//-------------------------------------------------------------------// +/* + * Listbox Notification Codes + */ +#define LBN_ERRSPACE (-2) +#define LBN_SELCHANGE 1 +#define LBN_DBLCLK 2 +#define LBN_SELCANCEL 3 +#define LBN_SETFOCUS 4 +#define LBN_KILLFOCUS 5 + +//-------------------------------------------------------------------// +//-------------------------------------------------------------------// +/* + * MessageBox() Flags + */ +#define MB_OK 0 +#define MB_OKCANCEL 1 +#define MB_ABORTRETRYIGNORE 2 +#define MB_YESNOCANCEL 3 +#define MB_YESNO 4 +#define MB_RETRYCANCEL 5 +#define MB_CANCELTRYCONTINUE 6 + +#define MB_ICONHAND 16 +#define MB_ICONQUESTION 32 +#define MB_ICONEXCLAMATION 48 +#define MB_ICONASTERISK 64 + +#define MB_USERICON 128 +#define MB_ICONWARNING MB_ICONEXCLAMATION +#define MB_ICONERROR MB_ICONHAND + +#define MB_ICONINFORMATION MB_ICONASTERISK +#define MB_ICONSTOP MB_ICONHAND + +#define MB_DEFBUTTON1 0 +#define MB_DEFBUTTON2 256 +#define MB_DEFBUTTON3 512 +#define MB_DEFBUTTON4 768 + +#define MB_APPLMODAL 0 +#define MB_SYSTEMMODAL 4096 +#define MB_TASKMODAL 8192 +#define MB_HELP 16384 // Help Button + +#define MB_NOFOCUS 32768 +#define MB_SETFOREGROUND 65536 +#define MB_DEFAULT_DESKTOP_ONLY 131072 + +#define MB_TOPMOST 262144 +#define MB_RIGHT 524288 +#define MB_RTLREADING 1048576 + +#define MB_TYPEMASK 15 +#define MB_ICONMASK 240 +#define MB_DEFMASK 3840 +#define MB_MODEMASK 12288 +#define MB_MISCMASK 49152 + +//-------------------------------------------------------------------// +/* + * Stock Logical Objects + */ +#define WHITE_BRUSH 0 +#define LTGRAY_BRUSH 1 +#define GRAY_BRUSH 2 +#define DKGRAY_BRUSH 3 +#define BLACK_BRUSH 4 +#define NULL_BRUSH 5 +#define HOLLOW_BRUSH NULL_BRUSH + +#define WHITE_PEN 6 +#define BLACK_PEN 7 +#define NULL_PEN 8 + +#define OEM_FIXED_FONT 10 +#define ANSI_FIXED_FONT 11 +#define ANSI_VAR_FONT 12 +#define SYSTEM_FONT 13 +#define DEVICE_DEFAULT_FONT 14 +#define DEFAULT_PALETTE 15 +#define SYSTEM_FIXED_FONT 16 +#define DEFAULT_GUI_FONT 17 + +//-------------------------------------------------------------------// +/* + * WM_SETICON / WM_GETICON Type Codes + */ +#define ICON_SMALL 0 +#define ICON_BIG 1 + +//-------------------------------------------------------------------// + +#define IMAGE_BITMAP 0 +#define IMAGE_ICON 1 +#define IMAGE_CURSOR 2 +#define IMAGE_ENHMETAFILE 3 + +//-------------------------------------------------------------------// +/* + * DrawText() Format Flags + */ +#define DT_TOP 0 +#define DT_LEFT 0 +#define DT_CENTER 1 +#define DT_RIGHT 2 +#define DT_VCENTER 4 +#define DT_BOTTOM 8 +#define DT_WORDBREAK 16 +#define DT_SINGLELINE 32 +#define DT_EXPANDTABS 64 +#define DT_TABSTOP 128 +#define DT_NOCLIP 256 +#define DT_EXTERNALLEADING 512 +#define DT_CALCRECT 1024 +#define DT_NOPREFIX 2048 +#define DT_INTERNAL 4096 +#define DT_EDITCONTROL 8192 +#define DT_PATH_ELLIPSIS 16384 +#define DT_END_ELLIPSIS 32768 +#define DT_MODIFYSTRING 65536 +#define DT_RTLREADING 131072 +#define DT_WORD_ELLIPSIS 262144 +#define DT_NOFULLWIDTHCHARBREAK 524288 +#define DT_HIDEPREFIX 1048576 +#define DT_PREFIXONLY 2097152 + +//-------------------------------------------------------------------// +// Brush Styles +#define BS_SOLID 0 +#define BS_NULL 1 +#define BS_HOLLOW BS_NULL +#define BS_HATCHED 2 +#define BS_PATTERN 3 +#define BS_INDEXED 4 +#define BS_DIBPATTERN 5 +#define BS_DIBPATTERNPT 6 +#define BS_PATTERN8X8 7 +#define BS_DIBPATTERN8X8 8 +#define BS_MONOPATTERN 9 + +// Hatch Styles +#define HS_HORIZONTAL 0 // ----- +#define HS_VERTICAL 1 // ||||| +#define HS_FDIAGONAL 2 // \\\\\ +#define HS_BDIAGONAL 3 // ///// +#define HS_CROSS 4 // +++++ +#define HS_DIAGCROSS 5 // xxxxx + +// Pen Styles +#define PS_SOLID 0 +#define PS_DASH 1 // ------- +#define PS_DOT 2 // ....... +#define PS_DASHDOT 3 // _._._._ +#define PS_DASHDOTDOT 4 // _.._.._ +#define PS_NULL 5 +#define PS_INSIDEFRAME 6 +#define PS_USERSTYLE 7 +#define PS_ALTERNATE 8 +#define PS_STYLE_MASK 15 + +#define PS_ENDCAP_ROUND 0 +#define PS_ENDCAP_SQUARE 256 +#define PS_ENDCAP_FLAT 512 +#define PS_ENDCAP_MASK 3840 + +#define PS_JOIN_ROUND 0 +#define PS_JOIN_BEVEL 4096 +#define PS_JOIN_MITER 8192 +#define PS_JOIN_MASK 61440 + +#define PS_COSMETIC 0 +#define PS_GEOMETRIC 65536 +#define PS_TYPE_MASK 983040 + +//-------------------------------------------------------------------// +// font weight values +#define FW_DONTCARE 0 +#define FW_THIN 100 +#define FW_EXTRALIGHT 200 +#define FW_ULTRALIGHT 200 +#define FW_LIGHT 300 +#define FW_NORMAL 400 +#define FW_REGULAR 400 +#define FW_MEDIUM 500 +#define FW_SEMIBOLD 600 +#define FW_DEMIBOLD 600 +#define FW_BOLD 700 +#define FW_EXTRABOLD 800 +#define FW_ULTRABOLD 800 +#define FW_HEAVY 900 +#define FW_BLACK 900 + +//-------------------------------------------------------------------// +// font quality values +#define DEFAULT_QUALITY 0 +#define DRAFT_QUALITY 1 +#define PROOF_QUALITY 2 +#define NONANTIALIASED_QUALITY 3 // (WINVER >= 0x0400) +#define ANTIALISED_QUALITY 4 // (WINVER >= 0x0400) + +//-------------------------------------------------------------------// +// flags (CHOOSECOLOR structure) +#define CC_RGBINIT 1 // 0x00000001 +#define CC_FULLOPEN 2 // 0x00000002 +#define CC_PREVENTFULLOPEN 4 // 0x00000004 +#define CC_SHOWHELP 8 // 0x00000008 +#define CC_ENABLEHOOK 16 // 0x00000010 +#define CC_ENABLETEMPLATE 32 // 0x00000020 +#define CC_ENABLETEMPLATEHANDLE 64 // 0x00000040 +#define CC_SOLIDCOLOR 128 // 0x00000080 // WINVER >= 0x0400 +#define CC_ANYCOLOR 256 // 0x00000100 // WINVER >= 0x0400 + +//-------------------------------------------------------------------// +/* + * Window field offsets for GetWindowLong() + */ +#define GWL_WNDPROC (-4) +#define GWL_HINSTANCE (-6) +#define GWL_HWNDPARENT (-8) +#define GWL_STYLE (-16) +#define GWL_EXSTYLE (-20) +#define GWL_USERDATA (-21) +#define GWL_ID (-12) + +#define DWL_MSGRESULT 0 +#define DWL_DLGPROC 4 +#define DWL_USER 8 + +//--------------------------------------------------------------------// +/* + * Virtual Key Codes + */ +#define VK_LBUTTON 1 +#define VK_RBUTTON 2 +#define VK_CANCEL 3 +#define VK_MBUTTON 4 +#define VK_BACK 8 +#define VK_TAB 9 +#define VK_CLEAR 12 +#define VK_RETURN 13 +#define VK_SHIFT 16 +#define VK_CONTROL 17 +#define VK_MENU 18 +#define VK_PAUSE 19 +#define VK_CAPITAL 20 +#define VK_ESCAPE 27 +#define VK_SPACE 32 +#define VK_PRIOR 33 +#define VK_NEXT 34 +#define VK_END 35 +#define VK_HOME 36 +#define VK_LEFT 37 +#define VK_UP 38 +#define VK_RIGHT 39 +#define VK_DOWN 40 +#define VK_SELECT 41 +#define VK_PRINT 42 +#define VK_EXECUTE 43 +#define VK_SNAPSHOT 44 +#define VK_INSERT 45 +#define VK_DELETE 46 +#define VK_HELP 47 +#define VK_NUMPAD0 96 +#define VK_NUMPAD1 97 +#define VK_NUMPAD2 98 +#define VK_NUMPAD3 99 +#define VK_NUMPAD4 100 +#define VK_NUMPAD5 101 +#define VK_NUMPAD6 102 +#define VK_NUMPAD7 103 +#define VK_NUMPAD8 104 +#define VK_NUMPAD9 105 +#define VK_MULTIPLY 106 +#define VK_ADD 107 +#define VK_SEPARATOR 108 +#define VK_SUBTRACT 109 +#define VK_DECIMAL 110 +#define VK_DIVIDE 111 +#define VK_F1 112 +#define VK_F2 113 +#define VK_F3 114 +#define VK_F4 115 +#define VK_F5 116 +#define VK_F6 117 +#define VK_F7 118 +#define VK_F8 119 +#define VK_F9 120 +#define VK_F10 121 +#define VK_F11 122 +#define VK_F12 123 +#define VK_F13 124 +#define VK_F14 125 +#define VK_F15 126 +#define VK_F16 127 +#define VK_F17 128 +#define VK_F18 129 +#define VK_F19 130 +#define VK_F20 131 +#define VK_F21 132 +#define VK_F22 133 +#define VK_F23 134 +#define VK_F24 135 +#define VK_NUMLOCK 144 +#define VK_SCROLL 145 + +//----------------------------------------------------------------------// +/* + * File Open/Save Dialog Constants + */ +#define OFN_READONLY 1 +#define OFN_OVERWRITEPROMPT 2 +#define OFN_HIDEREADONLY 4 +#define OFN_NOCHANGEDIR 8 +#define OFN_SHOWHELP 16 +#define OFN_ENABLEHOOK 32 +#define OFN_ENABLETEMPLATE 64 +#define OFN_ENABLETEMPLATEHANDLE 128 +#define OFN_NOVALIDATE 256 +#define OFN_ALLOWMULTISELECT 512 +#define OFN_EXTENSIONDIFFERENT 1024 +#define OFN_PATHMUSTEXIST 2048 +#define OFN_FILEMUSTEXIST 4096 +#define OFN_CREATEPROMPT 8192 +#define OFN_SHAREAWARE 16384 +#define OFN_NOREADONLYRETURN 32768 +#define OFN_NOTESTFILECREATE 65536 +#define OFN_NONETWORKBUTTON 131072 +#define OFN_NOLONGNAMES 262144 // force no long names for 4.x modules +#define OFN_EXPLORER 524288 // new look commdlg +#define OFN_NODEREFERENCELINKS 1048576 +#define OFN_LONGNAMES 2097152 // force long names for 3.x modules +#define OFN_ENABLEINCLUDENOTIFY 4194304 // send include message to callback +#define OFN_ENABLESIZING 8388608 +#define OFN_DONTADDTORECENT 33554432 +#define OFN_FORCESHOWHIDDEN 268435456 // Show All files including System and hidden files + +//----------------------------------------------------------------------// diff --git a/harbour/contrib/xhb/hbcomprs.c b/harbour/contrib/xhb/hbcomprs.c index 8d159d9a5b..efe822dab7 100644 --- a/harbour/contrib/xhb/hbcomprs.c +++ b/harbour/contrib/xhb/hbcomprs.c @@ -3043,6 +3043,7 @@ uIntf *v) /* working area: values in order of bit length */ int y; /* number of dummy codes added */ uInt z; /* number of entries in current table */ + memset( &r, '\0', sizeof( r ) ); /* Generate counts for each bit length */ p = c; diff --git a/harbour/contrib/xhb/hbcomprs.h b/harbour/contrib/xhb/hbcomprs.h index 5026ca75c2..7a2b7d985f 100644 --- a/harbour/contrib/xhb/hbcomprs.h +++ b/harbour/contrib/xhb/hbcomprs.h @@ -126,7 +126,8 @@ #endif /* Old Borland C incorrectly complains about missing returns: */ -#if defined(__BORLANDC__) && (__BORLANDC__ < 0x500) +#if ( defined(__BORLANDC__) && (__BORLANDC__ < 0x500) ) || \ + defined( __POCC__ ) || defined( __XCC__ ) # if !defined(NEED_DUMMY_RETURN) # define NEED_DUMMY_RETURN # endif diff --git a/harbour/harbour-ce-spec b/harbour/harbour-ce-spec index b53902a540..79e224e753 100644 --- a/harbour/harbour-ce-spec +++ b/harbour/harbour-ce-spec @@ -165,6 +165,7 @@ make -r -i install [ "%{?_without_odbc:1}" ] && rm -f $HB_LIB_INSTALL/libhbodbc.a [ "%{?_with_allegro:1}" ] || rm -f $HB_LIB_INSTALL/libgtalleg.a +[ "%{?_with_adsrdd:1}" ] || rm -f $HB_LIB_INSTALL/librddads.a # Keep the size of the libraries to a minimim. ${CCPREFIX}strip --strip-debug $HB_LIB_INSTALL/* diff --git a/harbour/harbour-w32-spec b/harbour/harbour-w32-spec index 60c82a68f1..cc17cf7e8d 100644 --- a/harbour/harbour-w32-spec +++ b/harbour/harbour-w32-spec @@ -165,6 +165,7 @@ make -r -i install [ "%{?_without_odbc:1}" ] && rm -f $HB_LIB_INSTALL/libhbodbc.a [ "%{?_with_allegro:1}" ] || rm -f $HB_LIB_INSTALL/libgtalleg.a +[ "%{?_with_adsrdd:1}" ] || rm -f $HB_LIB_INSTALL/librddads.a # Keep the size of the libraries to a minimim. ${CCPREFIX}strip --strip-debug $HB_LIB_INSTALL/* diff --git a/harbour/make_rpmce.sh b/harbour/make_rpmce.sh index 37070cf392..0de042519e 100755 --- a/harbour/make_rpmce.sh +++ b/harbour/make_rpmce.sh @@ -67,6 +67,12 @@ do shift done +if [ -f /usr/local/ads/acesdk/ace.h ] || + [ -f ${HOME}/ads/acesdk/ace.h ] +then + INST_PARAM="${INST_PARAM} --with adsrdd" +fi + TOINST_LST="" for i in ${NEED_RPM} do diff --git a/harbour/make_rpmw32.sh b/harbour/make_rpmw32.sh index 3a927ecae6..599c983e9e 100755 --- a/harbour/make_rpmw32.sh +++ b/harbour/make_rpmw32.sh @@ -89,6 +89,12 @@ do shift done +if [ -f /usr/local/ads/acesdk/ace.h ] || + [ -f ${HOME}/ads/acesdk/ace.h ] +then + INST_PARAM="${INST_PARAM} --with adsrdd" +fi + TOINST_LST="" for i in ${NEED_RPM} do