diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 45dab03153..e3bffe2099 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,4 +1,4 @@ -/* +/* * $Id$ */ @@ -8,6 +8,31 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-11-16 23:22 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/gtwvg/gtwvg.c + ! Resizing: some recent changes reverted back. + ; TODO: reversal in GTWVT also. It breaks some pre-initialization issues. + + * harbour/contrib/gtwvg/wvgax.prg + ! Better detection if COM object fails to be created. + + + harbour/contrib/gtwvg/wvggui.c + + harbour/contrib/gtwvg/wvggui.h + + Initial commit of pure GUI GT based on GTWVG named WGU. + ; Subject to heavy changes onwards. + WGU will become the basis of WvgDialog() plus inherited + sub-classes. + + * harbour/contrib/gtwvg/makefile + * harbour/contrib/gtwvg/common.mak + + Added new files. + + * harbour/contrib/gtwvg/tests/demowvg.prg + + Now is working properly. + It now opens in new thread if it is odd and as usual if even. + + + ! Just to have experiments on WGU GT. + 2008-11-16 23:05 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * contrib/gtwvg/wvgsink.c * Minor cleanup to hb_strncat() (it's best to use diff --git a/harbour/contrib/gtwvg/Makefile b/harbour/contrib/gtwvg/Makefile index c9cf23cd6e..a5051f9f75 100644 --- a/harbour/contrib/gtwvg/Makefile +++ b/harbour/contrib/gtwvg/Makefile @@ -14,6 +14,7 @@ C_SOURCES=\ wvgutils.c \ wvgwin.c \ wvgsink.c \ + wvggui.c \ PRG_SOURCES=\ wvgclass.prg \ diff --git a/harbour/contrib/gtwvg/common.mak b/harbour/contrib/gtwvg/common.mak index 31726d1994..302f50967a 100644 --- a/harbour/contrib/gtwvg/common.mak +++ b/harbour/contrib/gtwvg/common.mak @@ -23,6 +23,7 @@ LIB_OBJS = \ $(OBJ_DIR)wvgutils$(OBJEXT) \ $(OBJ_DIR)wvgsink$(OBJEXT) \ $(OBJ_DIR)wvgwin$(OBJEXT) \ + $(OBJ_DIR)wvggui$(OBJEXT) \ all: \ $(LIB_PATH) \ diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index b33ca63568..af3069f025 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -835,18 +835,12 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT ) /* * set the font and get it's size to determine the size of the client area * for the required number of rows and columns . - * No need to call hb_gt_wvt_GetFont() if font is already existant [prtpal 20081108] */ - if( !pWVT->hFont ) - { - hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, + hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, pWVT->fontWeight, pWVT->fontQuality, pWVT->CodePage ); - pWVT->hFont = hFont; - } - else - { - hFont = pWVT->hFont; - } + if( pWVT->hFont ) + DeleteObject( pWVT->hFont ); + pWVT->hFont = hFont; hdc = GetDC( pWVT->hWnd ); hOldFont = ( HFONT ) SelectObject( hdc, hFont ); @@ -897,7 +891,7 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT ) if( wi.left < 0 || wi.top < 0 ) { - #if 0 // IMO not required [pritpal] + #if 1 // IMO not required [pritpal] if( hb_gt_wvt_IsSizeChanged( pWVT ) ) { hb_gt_wvt_AddCharToInputQueue( pWVT, HB_K_RESIZE ); @@ -2258,27 +2252,12 @@ static BOOL hb_gt_wvt_SetMode( PHB_GT pGT, int iRow, int iCol ) pWVT = HB_GTWVT_GET( pGT ); - /* Only execute if iRow|iCol is different then previous settings [pritpal 20081108]*/ - if( iRow <= WVT_MAX_ROWS && iCol <= WVT_MAX_COLS && ( iRow != pWVT->ROWS || iCol != pWVT->COLS ) ) + if( iRow <= WVT_MAX_ROWS && iCol <= WVT_MAX_COLS ) { if( pWVT->hWnd ) /* Is the window already open */ { - /* SETMODE() is supposed to retain the same font as is current */ - /* So no need to recreate it if one is already created [pritpal 20081108] */ - HFONT hFont; - BOOL bCreated; - - if( !pWVT->hFont ) - { - hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, + HFONT hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, pWVT->fontWeight, pWVT->fontQuality, pWVT->CodePage ); - bCreated = TRUE; - } - else - { - hFont = pWVT->hFont; - bCreated = FALSE; - } if( hFont ) { @@ -2290,8 +2269,7 @@ static BOOL hb_gt_wvt_SetMode( PHB_GT pGT, int iRow, int iCol ) { fResult = hb_gt_wvt_InitWindow( pWVT, iRow, iCol ); } - if( bCreated ) - DeleteObject( hFont ); + DeleteObject( hFont ); HB_GTSELF_REFRESH( pGT ); } } @@ -2422,20 +2400,7 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) int iVal; HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Info(%p,%d,%p)", pGT, iType, pInfo ) ); - /* - if( pInfo->pGT && hb_itemType( pInfo->pGT ) & HB_IT_POINTER ) - { - pGT = hb_gt_ItemBase( pInfo->pGT ); - if( pGT ) - hb_gt_BaseFree( pGT ); - else - pGT = pGTx; - } - if( !pGT ) - { - pGT = pGTx; - } - */ + pWVT = HB_GTWVT_GET( pGT ); switch( iType ) diff --git a/harbour/contrib/gtwvg/tests/demowvg.prg b/harbour/contrib/gtwvg/tests/demowvg.prg index 4aa1dfa8f1..fd1da89458 100644 --- a/harbour/contrib/gtwvg/tests/demowvg.prg +++ b/harbour/contrib/gtwvg/tests/demowvg.prg @@ -196,15 +196,15 @@ PROCEDURE Main( cDSN ) #define btnFBDown WVT_BTN_FORMAT_RECESSED #define btnFBUp WVT_BTN_FORMAT_FLAT - WvtSetObjects( { OBJ_TYPE_BUTTON, 1, nBtnRow, 6,nBtnRow+1, 9, ; - {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH,btnFDisp ) },; - {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH,btnFMOver ) },; - {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH,btnFBDown ) },; - {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH,btnFBUp ) ,; + WvtSetObjects( { OBJ_TYPE_BUTTON, 1, nBtnRow, 6, nBtnRow+1, 9, ; + {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH, btnFDisp ) },; + {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH, btnFMOver ) },; + {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH, btnFBDown ) },; + {|| Wvt_DrawButton( nBtnRow, 6,nBtnRow+1, 9, ,IMAGE_VOUCH, btnFBUp ) ,; eval( SetKey( K_F2 ) ) } ; } ) - WvtSetObjects( { OBJ_TYPE_BUTTON, 2, nBtnRow,11,nBtnRow+1,14, ; + WvtSetObjects( { OBJ_TYPE_BUTTON, 2, nBtnRow,11, nBtnRow+1,14, ; {|| Wvt_DrawButton( nBtnRow,11,nBtnRow+1,14, ,IMAGE_BROWSE, btnFDisp ) },; {|| Wvt_DrawButton( nBtnRow,11,nBtnRow+1,14, ,IMAGE_BROWSE, btnFMOver ) },; {|| Wvt_DrawButton( nBtnRow,11,nBtnRow+1,14, ,IMAGE_BROWSE, btnFBDown ) },; @@ -212,7 +212,7 @@ PROCEDURE Main( cDSN ) eval( SetKey( K_F5 ) ) } ; } ) - WvtSetObjects( { OBJ_TYPE_BUTTON, 3, nBtnRow,16,nBtnRow+1,19, ; + WvtSetObjects( { OBJ_TYPE_BUTTON, 3, nBtnRow,16, nBtnRow+1,19, ; {|| Wvt_DrawButton( nBtnRow,16,nBtnRow+1,19,"Expand",IMAGE_NOTES,btnFDisp ) },; {|| Wvt_DrawButton( nBtnRow,16,nBtnRow+1,19,"Expand",IMAGE_NOTES,btnFMOver ) },; {|| Wvt_DrawButton( nBtnRow,16,nBtnRow+1,19,"Expand",IMAGE_NOTES,btnFBDown ) },; @@ -220,7 +220,7 @@ PROCEDURE Main( cDSN ) eval( SetKey( K_F3 ) ) } ; } ) - WvtSetObjects( { OBJ_TYPE_BUTTON, 4, nBtnRow,21,nBtnRow+1,24, ; + WvtSetObjects( { OBJ_TYPE_BUTTON, 4, nBtnRow,21, nBtnRow+1,24, ; {|| Wvt_DrawButton( nBtnRow,21,nBtnRow+1,24,"Shrink", , btnFDisp , rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; {|| Wvt_DrawButton( nBtnRow,21,nBtnRow+1,24,"Shrink", , btnFMOver, rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; {|| Wvt_DrawButton( nBtnRow,21,nBtnRow+1,24,"Shrink", , btnFBDown, rgb( 100,22,241 ), rgb( 0,100,0 ) ) },; @@ -228,7 +228,7 @@ PROCEDURE Main( cDSN ) eval( SetKey( K_F4 ) ) } ; } ) - WvtSetObjects( { OBJ_TYPE_BUTTON, 5, nBtnRow,26,nBtnRow+1,29, ; + WvtSetObjects( { OBJ_TYPE_BUTTON, 5, nBtnRow,26, nBtnRow+1,29, ; {|| Wvt_DrawButton( nBtnRow,26,nBtnRow+1,29,"Minimize",IMAGE_TOOLS, btnFDisp ) },; {|| Wvt_DrawButton( nBtnRow,26,nBtnRow+1,29,"Minimize",IMAGE_TOOLS, btnFMOver ) },; {|| Wvt_DrawButton( nBtnRow,26,nBtnRow+1,29,"Minimize",IMAGE_TOOLS, btnFBDown ) },; @@ -236,7 +236,7 @@ PROCEDURE Main( cDSN ) eval( SetKey( K_F6 ) ) },; } ) - WvtSetObjects( { OBJ_TYPE_BUTTON, 6, nBtnRow,31,nBtnRow+1,34, ; + WvtSetObjects( { OBJ_TYPE_BUTTON, 6, nBtnRow,31, nBtnRow+1,34, ; {|| Wvt_DrawButton( nBtnRow,31,nBtnRow+1,34,"Partial",IMAGE_HELP, btnFDisp ) },; {|| Wvt_DrawButton( nBtnRow,31,nBtnRow+1,34,"Partial",IMAGE_HELP, btnFMOver ) },; {|| Wvt_DrawButton( nBtnRow,31,nBtnRow+1,34,"Partial",IMAGE_HELP, btnFBDown ) },; @@ -299,13 +299,16 @@ PROCEDURE Main( cDSN ) Function HB_GTSYS() REQUEST HB_GT_WVG_DEFAULT REQUEST HB_GT_WVT + REQUEST HB_GT_WGU Return NIL //------------------------------------------------------------------// PROCEDURE WvtConsoleGets() IF hb_mtvm() - Hb_ThreadStart( {|| hb_gtReload( 'WVT' ), ; - WvtNextGetsConsole(); + Hb_ThreadStart( {|oCrt| hb_gtReload( 'WVT' ) , ; + oCrt := hb_gtSelect(), ; + WvtNextGetsConsole() , ; + oCrt := NIL ; } ) ENDIF @@ -356,9 +359,7 @@ PROCEDURE WvtNextGets() ENDIF RETURN - //----------------------------------------------------------------------// - PROCEDURE WvtNextGets_X() LOCAL aLastPaint, clr @@ -445,7 +446,6 @@ PROCEDURE WvtNextGets_X() Wvt_RestScreen( wvtScr ) SetPos( nRow, nCol ) RETURN - //-------------------------------------------------------------------// FUNCTION WvtSetKeys( lSet ) @@ -963,9 +963,7 @@ STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd ) endcase RETURN lRet - //-------------------------------------------------------------------// - STATIC FUNCTION BrwOnEvent( oWvtBrw, cPaintID, oBrowse, nKey ) LOCAL lRet := .t., lRefAll := .f. @@ -1069,9 +1067,7 @@ STATIC FUNCTION BrwOnEvent( oWvtBrw, cPaintID, oBrowse, nKey ) endif RETURN lRet - //-------------------------------------------------------------------// - STATIC FUNCTION CfgMyBrowse( aFields, cUseAlias, aTLBR, cDesc, oParent, cColorSpec, nID ) LOCAL info_, oWvtBrw, oBrowse, i, bBlock LOCAL aPopup := {} @@ -1120,9 +1116,7 @@ STATIC FUNCTION CfgMyBrowse( aFields, cUseAlias, aTLBR, cDesc, oParent, cColorSp oWvtBrw:bHandleEvent := {|oWvtBrw,cPaintID,oBrowse,nKey| BrwOnEvent( oWvtBrw,cPaintID,oBrowse,nKey ) } RETURN oWvtBrw - //-------------------------------------------------------------------// - FUNCTION WvtPartialScreen() LOCAL scr := SaveScreen( 7,20,15,60 ) LOCAL wvtScr := Wvt_SaveScreen( 0, 0, MaxRow(), MaxCol() ) @@ -1163,9 +1157,7 @@ FUNCTION WvtPartialScreen() Wvt_SetPopupMenu( hPopup ) RETURN NIL - //-------------------------------------------------------------------// - function WvtLines() LOCAL scr := SaveScreen( 0,0,maxrow(),maxcol() ) LOCAL clr := SetColor( "N/W" ) @@ -1224,17 +1216,13 @@ function WvtLines() RestScreen( 0,0,maxrow(),maxcol(), scr ) RETURN nil - //-------------------------------------------------------------------// - FUNCTION DispStatusMsg( cMsg ) Wvt_DrawLabel( MaxRow(), 60, cMsg, 6, , 0, rgb(198,198,198), "Arial", 18, , 900 ) RETURN .t. - //-------------------------------------------------------------------// - FUNCTION ClearStatusMsg() LOCAL nRow := Row() LOCAL nCol := Col() @@ -1244,9 +1232,7 @@ FUNCTION ClearStatusMsg() SetPos( nRow, nCol ) RETURN .t. - //-------------------------------------------------------------------// - FUNCTION Popups( nID, lDestroy ) LOCAL hPop, hPop1 LOCAL nPrompt := MF_ENABLED+MF_STRING @@ -1314,9 +1300,7 @@ FUNCTION Popups( nID, lDestroy ) hPop_[ nID ] := hPop RETURN Wvt_SetPopupMenu( hPop_[ nID ] ) - //-------------------------------------------------------------------// - FUNCTION WvtPictures( nSlot,cFilePic ) if nSlot != nil .and. nSlot <= 20 .and. file( cFilePic ) @@ -1328,9 +1312,7 @@ FUNCTION WvtPictures( nSlot,cFilePic ) endif RETURN nil - //-------------------------------------------------------------------// - FUNCTION WvtExePicture( nTop, nLeft, nBottom, nRight, nSlot, aOffset ) if pic_[ nSlot ] != nil @@ -1338,9 +1320,7 @@ FUNCTION WvtExePicture( nTop, nLeft, nBottom, nRight, nSlot, aOffset ) endif RETURN nil - //-------------------------------------------------------------------// - FUNCTION CreateMainMenu() LOCAL oMenu LOCAL g_oMenuBar := wvtMenu():new():create() @@ -1385,6 +1365,8 @@ FUNCTION CreateMainMenu() oMenu:AddItem( "Slide Show" ,{|| DlgSlideShow() } ) oMenu:AddItem( "-") oMenu:AddItem( "Dialog Scond" ,{|| DynDialog_1() } ) + oMenu:AddItem( "-") + oMenu:AddItem( "An Experiment",{|| Experiment_1() } ) g_oMenuBar:addItem( "",oMenu) oMenu := wvtMenu():new():create() @@ -1401,9 +1383,7 @@ FUNCTION CreateMainMenu() g_oMenuBar:addItem( "",oMenu) RETURN g_oMenuBar - //-------------------------------------------------------------------// - STATIC FUNCTION ActivateMenu( oMenu ) LOCAL nMenu := Wvt_GetLastMenuEvent() LOCAL aMenuItem @@ -1420,10 +1400,34 @@ STATIC FUNCTION ActivateMenu( oMenu ) ENDIF RETURN ( NIL ) - //-------------------------------------------------------------------// - STATIC FUNCTION MyDialogOne() + Local bBlock + + static n := 0 + + if hb_mtvm() + n++ + if n%2 == 0 + MyDialogOne_X() + else + bBlock := { |oCrt| ; + hb_gtReload( 'WVG' ) ,; + oCrt := WvgCrt():New( , , { -1,-1 }, { 54,184 }, , .f. ), ; + oCrt:fontName := 'Courier',; + oCrt:fontHeight := 13 ,; + oCrt:fontWidth := 0 ,; + oCrt:Create() ,; + MyDialogOne_X( oCrt ) ; + } + hb_threadStart( bBlock ) + endif + else + MyDialogOne_X() + endif + RETURN Nil +//----------------------------------------------------------------------// +STATIC FUNCTION MyDialogOne_X( oCrt ) LOCAL aObjects:= WvtSetBlocks( {} ) Local nWinRows, nWinCols, cWinTitle, cFont, nHeight, nWidth Local oDlg, obj_, oBar, d_, nN, cUseAlias @@ -1456,7 +1460,8 @@ STATIC FUNCTION MyDialogOne() aadd( aImg_, "v_index.bmp" ) aadd( aImg_, "v_notes1.bmp" ) aadd( aImg_, "v_selct1.bmp" ) - + ? '.' + Wvt_ShowWindow( 1 ) nWinRows := 55 nWinCols := 185 cWinTitle := "WvtGui Dialog One" @@ -2306,7 +2311,7 @@ Static Function ExeActiveX( oCrt, nActiveX ) oCom:CLSID := 'file://C:\harbour\contrib\gtwvg\tests\myharu.pdf' case nActiveX == 4 - hb_gtInfo( HB_GTI_WINTITLE, 'RM Chart [ F12:Attributes F11:Other Charts ]' ) + hb_gtInfo( HB_GTI_WINTITLE, 'RM Chart [ Attributes Next Charts ]' ) oCom:CLSID := 'RMChart.RMChartX' // RMChart does not have event interface. @@ -2316,205 +2321,205 @@ Static Function ExeActiveX( oCrt, nActiveX ) endcase oCom:create() + if hb_isObject( oCom ) - // After :CREATE() Messages - // - if nActiveX == 1 - oCom:AddressBar := .t. - oCom:Navigate( 'http://www.harbour.vouch.info' ) + // After :CREATE() Messages + // + if nActiveX == 1 + oCom:AddressBar := .t. + oCom:Navigate( 'http://www.harbour.vouch.info' ) - elseif nActiveX == 4 - ConfigureRMChart( oCom ) + elseif nActiveX == 4 + ConfigureRMChart( oCom ) - oCom:Draw( .t. ) - oCom:Draw2Clipboard() + oCom:Draw( .t. ) + oCom:Draw2Clipboard() - endif + endif - do while !( lEnd ) - nKey := inkey() + do while !( lEnd ) + nKey := inkey() - if nKey == HB_K_RESIZE - Resize( oCom ) - - elseif nKey == K_F12 - if nActiveX == 1 - oCom:Navigate( 'www.vouch.info' ) - - elseif nActiveX == 4 - oCom:RMCBackColor := 23456142 - oCom:RMCStyle := 1 - oCom:RMCUserWatermark := 'Vouch' - - //oCom:AddRegion() - oCom:Region(1):SetProperties( 5.0,5.0,-5.0,-5.0 ) - - oCom:Draw( .t. ) - endif - - elseif nKey == K_F11 - if nActiveX == 4 - nTurn++ - if nTurn > 6 - nTurn := 1 - endif - sData := '' - - do case - case nTurn == 1 - hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] ' + 'Stacked Bars' ) - SetMode( 30,100 ) - - sData += "00003600|00004450|000051|000061|000073|00008-6972|00009412|00011Tahoma|100011|10" - sData += "0035|1000410|10005-5|10006-5|1000911|100101|100111|100181|100200|1002150000|1002" - sData += "211|100238|100331|100341|100356|100378|100411|100468|100484|100494|10051-6972|10" - sData += "052-16777216|10053-1828|100541|100558|10056-16777216|10057-16777216|10060-167772" - sData += "16|10061-16777216|1006315|10064-32|100652|10066-16776961|10180this is the footer" - sData += "|10181Example of stacked bars|10182Apples*Pears*Cherries*Strawberries|10183 $|10" - sData += "184This is an optional axis text, sized 9 points and bold\9b|10187Label Nr. 1*La" - sData += "bel Nr. 2*Label Nr. 3*Label Nr. 4*Label Nr. 5*Label Nr. 6|10196This is an option" - sData += "al label axis text|110011|110023|110033|110045|110055|11006-1|1100923|110131|110" - sData += "14-1|110171|11019-16777077|1102111|110221|110236|1105310000*10000*16000*12000*20" - sData += "000*10000|120011|120023|120033|120045|120055|12006-1|1200927|120131|12014-1|1201" - sData += "71|12019-16751616|1202111|120221|120236|120535000*7000*4000*15000*10000*10000|13" - sData += "0011|130023|130033|130045|130055|13006-1|1300982|130131|13014-1|130171|13019-838" - sData += "8608|1302111|130221|130236|1305310000*3000*12000*10000*5000*20000|140011|140023|" - sData += "140033|140045|140055|14006-1|1400925|140131|14014-1|140171|14019-4684277|1402111" - sData += "|140221|140236|140535000*9000*12000*6000*10000*5000" - - case nTurn == 2 - hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Floating Bars' ) - SetMode( 20,90 ) - - sData += "00003550|00004300|000051|000073|00008-2894893|00009412|00011Tahoma|100011|100035" - sData += "|100045|10005-5|10006-5|1000911|100101|100111|100131|100181|100201|1002113|10022" - sData += "13|100238|100331|100341|100356|100378|100411|100468|100482|10052-16777216|10053-" - sData += "1120086|100544|100555|10056-16777216|10057-16777216|10060-16777216|10061-1677721" - sData += "6|1006316|10064-5383962|100652|10066-16777011|10181Birth of a Killer App|10182Sc" - sData += "hedule*Reality|10187Design*Development*Testing*Bug Fixing*Documentation*Marketin" - sData += "g|1020104/01*04/02*04/03*04/04*04/05*04/06*04/07*04/08*04/09*04/10*04/11*04/12*0" - sData += "5/01|110011|110026|110044|110101|110131|11019-6751336|1102111|110221|1102312|110" - sData += "531*3*4*6*6*4*7*4*9*3*10*3|120011|120026|120044|120101|120132|12019-47872|120211" - sData += "1|120221|1202312|120531*.5*1.5*10.5*12*1*12*1*12.5*.5*2*11" - - case nTurn == 3 - hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Four Regions' ) - SetMode( 40,120 ) - - sData += "00003700|00004500|000054|000061|000071|00008-984833|00009412|00011Tahoma|100011|" - sData += "100032|100042|10005348|10006248|1000910|100101|100111|100181|100200|10021100|100" - sData += "2211|100238|100331|100341|100355|100378|100481|100491|10051-984833|10052-1677721" - sData += "6|10053-657956|100541|100558|10056-16777216|10057-16777216|10060-16777216|10061-" - sData += "16777216|10187Label 1*Label 2*Label 3*Label 4*Label 5|110011|110021|110031|11004" - sData += "6|110056|11006-1|110091|110131|11014-1|110171|1102111|110221|110235|1105330*40*7" - sData += "0*60*20|200011|20003352|200042|20005-2|20006248|2000910|200101|200111|200181|200" - sData += "200|20021100|2002211|200238|200331|200341|200355|200378|200484|200491|20051-9848" - sData += "33|20052-16777216|20053-657956|200544|200555|20056-16777216|20057-16777216|20060" - sData += "-16777216|20061-16777216|20187Label 1*Label 2*Label 3*Label 4*Label 5|210011|210" - sData += "023|210033|210045|210055|21006-1|210091|210101|210131|21014-1|210171|2102111|210" - sData += "221|210235|2105320*10*15*25*30|220011|220023|220033|220045|220055|22006-1|220091" - sData += "|220101|220131|22014-1|220171|2202111|220221|220235|2205325*30*10*20*15|230011|2" - sData += "30023|230033|230045|230055|23006-1|230091|230101|230131|23014-1|230171|2302111|2" - sData += "30221|230235|2305310*20*40*20*30|240011|240023|240033|240045|240055|24006-1|2400" - sData += "91|240101|240131|24014-1|240171|2402111|240221|240235|2405340*30*20*30*20|300011" - sData += "|300032|30004252|30005348|30006-2|3000910|300101|300181|300481|300491|30051-9848" - sData += "33|30052-16777216|30053-657956|310011|3100251|310031|3100454|310054|310071|31009" - sData += "1|310121|310151|310161|310171|310182|310211|310221|310235|3105330*50*20*40*60|40" - sData += "0011|40003352|40004252|40005-2|40006-2|4000910|400101|400111|400131|400181|40020" - sData += "100|40021250|4002211|400238|400281|400292|400300|400310|400322|400331|400341|400" - sData += "3510|400378|400482|400492|40051-984833|40052-16777216|40053-984833|400541|400558" - sData += "|40056-16776961|40057-16777216|400592|40060-16777216|40061-16777216|40183$ |4018" - sData += "5 %|410011|410021|410031|410043|410053|41006-1|4100950|410131|41014-1|410171|410" - sData += "19-10496|4102111|410221|4102310|41053240*230*220*180*170*160*145*130*125*115|420" - sData += "011|4200221|420035|4200422|420052|420061|420071|4200963|420111|420121|420131|420" - sData += "171|42019-16744448|4202115|420221|4202310|420261|420538.1*6.2*4.3*2.2*1.2*3.1*5." - sData += "2*11.4*7.3*4.2" - - case nTurn == 4 - hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'10 Biggest Companies' ) - SetMode( 25,90 ) - - sData += "00003670|00004450|000051|000061|000071|00008-10185235|00009412|00011Tahoma|10001" - sData += "1|100035|1000410|10005-5|10006-5|1000912|100101|100111|100131|100181|10020100000" - sData += "|10021250000|1002211|100239|100281|100292|100300|100310|100322|100331|100341|100" - sData += "3510|100378|100482|100492|10051-32944|10052-1296|10053-983041|100541|100558|1005" - sData += "6-1828|10057-16777216|100592|10060-1828|10061-16777216|10180data source: F.A.Z|1" - sData += "0181The world's 10 biggest industrial companies 2003|10183$ |10184Total turnover" - sData += " in Mill. Dollar|10185 %|10186Net operating margin|10187Exxon Mobil*Royal Dutch " - sData += "/ Shell*BP*General Motors*Daimler Chrysler*Ford Motor*Toyota Motor*General Elect" - sData += "ric*TOTAL*Chevron Texaco|110011|110021|110031|110043|110053|11006-1|1100950|1101" - sData += "31|11014-1|110171|11019-10496|1102111|110221|1102310|11053242365*235598*232571*1" - sData += "85524*170457*164196*149321*132797*130067*119703|120011|1200221|120035|1200422|12" - sData += "0052|120061|120071|1200970|120111|120121|120131|1201421|120171|12019-16744448|12" - sData += "02115|120221|1202310|120261|120538.9*4.1*4.4*2.1*.3*.3*5.9*11.3*6.7*6" - - case nTurn == 5 - hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Grouped Bars' ) - SetMode( 25,80 ) - - sData += "00003600|00004450|000051|000061|000075|00008-2|00009412|00010paper.jpg|00011Taho" - sData += "ma|100011|100035|100045|10005-5|10006-5|1000910|100101|100111|100181|100200|1002" - sData += "1100|1002211|100238|100331|100341|100355|100378|100468|100484|10053-2|100541|100" - sData += "558|100631|100651|10182First quarter*Second quarter*Third quarter*Fourth quarter" - sData += "|101872000*2001*2002*2003*2004|110011|110022|110044|110131|1102111|110221|110235" - sData += "|1105330*20*40*60*10|120011|120022|120044|120131|1202111|120221|120235|1205330*2" - sData += "0*50*70*60|130011|130022|130044|130131|1302111|130221|130235|1305340*10*30*20*80" - sData += "|140011|140022|140044|140131|1402111|140221|140235|1405370*50*80*40*30" - - case nTurn == 6 - hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Flow Chart' ) - SetMode( 30,50 ) - - sData += "00003305|00004400|000051|00008-984833|00009412|00011Tahoma|100011|100035|100045|" - sData += "10005-5|10006-5|10180\7C|010011|010051|010072|010081|0101050|0101125|01012100|01" - sData += "01325|01014-5952982|01015-5952982|01016255|010191|0102010|01026Start|01030-256|0" - sData += "10012|010054|0100721|01014-16776961|010222|01024100*100|0102550*75|01026|010272|" - sData += "010293|010013|010051|010071|010081|0101050|0101175|01012100|0101325|01014-669788" - sData += "2|01015-6697882|01016255|010191|0102010|01026i = 1|01030-16777216|010014|010054|" - sData += "0100721|01014-16776961|010222|01024100*100|01025100*150|01026|010272|010293|0100" - sData += "15|010051|010073|010081|0101050|01011150|01012100|0101350|01014-65536|01015-6553" - sData += "6|01016255|010191|0102010|01026i = 39?|01030-256|010016|010054|0100721|01014-167" - sData += "76961|010222|01024100*100|01025200*225|01026|010272|010293|010017|010051|010071|" - sData += "010081|0101050|01011225|01012100|0101325|01014-6697882|01015-6697882|01016255|01" - sData += "0191|0102010|01026i = i + 1|01030-16777216|010018|010054|0100721|01014-16776961" - sData += "|010222|01024100*100|01025250*275|01026|010272|010293|010019|010051|010073|01008" - sData += "1|0101050|01011275|01012100|0101350|01014-65536|01015-65536|01016255|010191|0102" - sData += "010|01026i <= 100|01030-256|0100110|010054|0100721|01014-16776961|010222|0102410" - sData += "0*100|01025325*350|01026|010272|010293|0100111|010051|010072|010081|0101050|0101" - sData += "1350|01012100|0101325|01014-5952982|01015-5952982|01016255|010191|0102010|01026S" - sData += "top|01030-256|0100113|010054|0100721|01014-16776961|010222|01024150*200|01025175" - sData += "*175|01026|010272|010293|0100114|010051|010081|01010145|01011157|0101250|01014-1" - sData += "6776961|01015-5383962|01016255|010191|0102010|01026yes|01030-16777216|0100115|01" - sData += "0051|010071|010081|01010200|01011162|01012100|0101325|01014-6697882|01015-669788" - sData += "2|01016255|010191|0102010|01026i = 69|01030-16777216|0100116|010054|0100721|0101" - sData += "4-16776961|010224|0102450*10*10*100|01025300*300*125*125|01026|010272|010293|010" - sData += "0117|010054|0100721|01014-16776961|010223|01024250*250*100|01025162*125*125|0102" - sData += "6|010272|010293|0100118|010051|010081|01010100|01011200|0101250|0101325|01014-16" - sData += "776961|01016255|010191|0102010|01026no|01030-16777216|0100119|010051|010081|0101" - sData += "010|01011280|0101240|01014-16776961|01016255|010191|0102010|01026yes|01030-16777" - sData += "216|0100120|010051|010081|01010100|01011322|0101250|01014-16776961|01016255|0101" - sData += "91|0102010|01026no|01030-16777216|0100120|010051|010079|01010180|01011280|010121" - sData += "20|01013100|01015-39322|010191|010209|01026RMChart is not a flowchart tool. This" - sData += " is just an example for the use of CustomObjects!|01030-256" - - endcase - - oCom:Reset() - oCom:RMCFile := sData - oCom:Draw( .t. ) + if nKey == HB_K_RESIZE Resize( oCom ) + elseif nKey == K_F12 + if nActiveX == 1 + oCom:Navigate( 'www.vouch.info' ) + + elseif nActiveX == 4 + oCom:RMCBackColor := 23456142 + oCom:RMCStyle := 2 + oCom:RMCUserWatermark := 'Vouch' + + oCom:Region(1):SetProperties( 5.0,5.0,-5.0,-5.0 ) + + oCom:Draw( .t. ) + endif + + elseif nKey == K_F11 + if nActiveX == 4 + nTurn++ + if nTurn > 6 + nTurn := 1 + endif + sData := '' + + do case + case nTurn == 1 + hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] ' + 'Stacked Bars' ) + SetMode( 30,100 ) + + sData += "00003600|00004450|000051|000061|000073|00008-6972|00009412|00011Tahoma|100011|10" + sData += "0035|1000410|10005-5|10006-5|1000911|100101|100111|100181|100200|1002150000|1002" + sData += "211|100238|100331|100341|100356|100378|100411|100468|100484|100494|10051-6972|10" + sData += "052-16777216|10053-1828|100541|100558|10056-16777216|10057-16777216|10060-167772" + sData += "16|10061-16777216|1006315|10064-32|100652|10066-16776961|10180this is the footer" + sData += "|10181Example of stacked bars|10182Apples*Pears*Cherries*Strawberries|10183 $|10" + sData += "184This is an optional axis text, sized 9 points and bold\9b|10187Label Nr. 1*La" + sData += "bel Nr. 2*Label Nr. 3*Label Nr. 4*Label Nr. 5*Label Nr. 6|10196This is an option" + sData += "al label axis text|110011|110023|110033|110045|110055|11006-1|1100923|110131|110" + sData += "14-1|110171|11019-16777077|1102111|110221|110236|1105310000*10000*16000*12000*20" + sData += "000*10000|120011|120023|120033|120045|120055|12006-1|1200927|120131|12014-1|1201" + sData += "71|12019-16751616|1202111|120221|120236|120535000*7000*4000*15000*10000*10000|13" + sData += "0011|130023|130033|130045|130055|13006-1|1300982|130131|13014-1|130171|13019-838" + sData += "8608|1302111|130221|130236|1305310000*3000*12000*10000*5000*20000|140011|140023|" + sData += "140033|140045|140055|14006-1|1400925|140131|14014-1|140171|14019-4684277|1402111" + sData += "|140221|140236|140535000*9000*12000*6000*10000*5000" + + case nTurn == 2 + hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Floating Bars' ) + SetMode( 20,90 ) + + sData += "00003550|00004300|000051|000073|00008-2894893|00009412|00011Tahoma|100011|100035" + sData += "|100045|10005-5|10006-5|1000911|100101|100111|100131|100181|100201|1002113|10022" + sData += "13|100238|100331|100341|100356|100378|100411|100468|100482|10052-16777216|10053-" + sData += "1120086|100544|100555|10056-16777216|10057-16777216|10060-16777216|10061-1677721" + sData += "6|1006316|10064-5383962|100652|10066-16777011|10181Birth of a Killer App|10182Sc" + sData += "hedule*Reality|10187Design*Development*Testing*Bug Fixing*Documentation*Marketin" + sData += "g|1020104/01*04/02*04/03*04/04*04/05*04/06*04/07*04/08*04/09*04/10*04/11*04/12*0" + sData += "5/01|110011|110026|110044|110101|110131|11019-6751336|1102111|110221|1102312|110" + sData += "531*3*4*6*6*4*7*4*9*3*10*3|120011|120026|120044|120101|120132|12019-47872|120211" + sData += "1|120221|1202312|120531*.5*1.5*10.5*12*1*12*1*12.5*.5*2*11" + + case nTurn == 3 + hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Four Regions' ) + SetMode( 40,120 ) + + sData += "00003700|00004500|000054|000061|000071|00008-984833|00009412|00011Tahoma|100011|" + sData += "100032|100042|10005348|10006248|1000910|100101|100111|100181|100200|10021100|100" + sData += "2211|100238|100331|100341|100355|100378|100481|100491|10051-984833|10052-1677721" + sData += "6|10053-657956|100541|100558|10056-16777216|10057-16777216|10060-16777216|10061-" + sData += "16777216|10187Label 1*Label 2*Label 3*Label 4*Label 5|110011|110021|110031|11004" + sData += "6|110056|11006-1|110091|110131|11014-1|110171|1102111|110221|110235|1105330*40*7" + sData += "0*60*20|200011|20003352|200042|20005-2|20006248|2000910|200101|200111|200181|200" + sData += "200|20021100|2002211|200238|200331|200341|200355|200378|200484|200491|20051-9848" + sData += "33|20052-16777216|20053-657956|200544|200555|20056-16777216|20057-16777216|20060" + sData += "-16777216|20061-16777216|20187Label 1*Label 2*Label 3*Label 4*Label 5|210011|210" + sData += "023|210033|210045|210055|21006-1|210091|210101|210131|21014-1|210171|2102111|210" + sData += "221|210235|2105320*10*15*25*30|220011|220023|220033|220045|220055|22006-1|220091" + sData += "|220101|220131|22014-1|220171|2202111|220221|220235|2205325*30*10*20*15|230011|2" + sData += "30023|230033|230045|230055|23006-1|230091|230101|230131|23014-1|230171|2302111|2" + sData += "30221|230235|2305310*20*40*20*30|240011|240023|240033|240045|240055|24006-1|2400" + sData += "91|240101|240131|24014-1|240171|2402111|240221|240235|2405340*30*20*30*20|300011" + sData += "|300032|30004252|30005348|30006-2|3000910|300101|300181|300481|300491|30051-9848" + sData += "33|30052-16777216|30053-657956|310011|3100251|310031|3100454|310054|310071|31009" + sData += "1|310121|310151|310161|310171|310182|310211|310221|310235|3105330*50*20*40*60|40" + sData += "0011|40003352|40004252|40005-2|40006-2|4000910|400101|400111|400131|400181|40020" + sData += "100|40021250|4002211|400238|400281|400292|400300|400310|400322|400331|400341|400" + sData += "3510|400378|400482|400492|40051-984833|40052-16777216|40053-984833|400541|400558" + sData += "|40056-16776961|40057-16777216|400592|40060-16777216|40061-16777216|40183$ |4018" + sData += "5 %|410011|410021|410031|410043|410053|41006-1|4100950|410131|41014-1|410171|410" + sData += "19-10496|4102111|410221|4102310|41053240*230*220*180*170*160*145*130*125*115|420" + sData += "011|4200221|420035|4200422|420052|420061|420071|4200963|420111|420121|420131|420" + sData += "171|42019-16744448|4202115|420221|4202310|420261|420538.1*6.2*4.3*2.2*1.2*3.1*5." + sData += "2*11.4*7.3*4.2" + + case nTurn == 4 + hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'10 Biggest Companies' ) + SetMode( 25,90 ) + + sData += "00003670|00004450|000051|000061|000071|00008-10185235|00009412|00011Tahoma|10001" + sData += "1|100035|1000410|10005-5|10006-5|1000912|100101|100111|100131|100181|10020100000" + sData += "|10021250000|1002211|100239|100281|100292|100300|100310|100322|100331|100341|100" + sData += "3510|100378|100482|100492|10051-32944|10052-1296|10053-983041|100541|100558|1005" + sData += "6-1828|10057-16777216|100592|10060-1828|10061-16777216|10180data source: F.A.Z|1" + sData += "0181The world's 10 biggest industrial companies 2003|10183$ |10184Total turnover" + sData += " in Mill. Dollar|10185 %|10186Net operating margin|10187Exxon Mobil*Royal Dutch " + sData += "/ Shell*BP*General Motors*Daimler Chrysler*Ford Motor*Toyota Motor*General Elect" + sData += "ric*TOTAL*Chevron Texaco|110011|110021|110031|110043|110053|11006-1|1100950|1101" + sData += "31|11014-1|110171|11019-10496|1102111|110221|1102310|11053242365*235598*232571*1" + sData += "85524*170457*164196*149321*132797*130067*119703|120011|1200221|120035|1200422|12" + sData += "0052|120061|120071|1200970|120111|120121|120131|1201421|120171|12019-16744448|12" + sData += "02115|120221|1202310|120261|120538.9*4.1*4.4*2.1*.3*.3*5.9*11.3*6.7*6" + + case nTurn == 5 + hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Grouped Bars' ) + SetMode( 25,80 ) + + sData += "00003600|00004450|000051|000061|000075|00008-2|00009412|00010paper.jpg|00011Taho" + sData += "ma|100011|100035|100045|10005-5|10006-5|1000910|100101|100111|100181|100200|1002" + sData += "1100|1002211|100238|100331|100341|100355|100378|100468|100484|10053-2|100541|100" + sData += "558|100631|100651|10182First quarter*Second quarter*Third quarter*Fourth quarter" + sData += "|101872000*2001*2002*2003*2004|110011|110022|110044|110131|1102111|110221|110235" + sData += "|1105330*20*40*60*10|120011|120022|120044|120131|1202111|120221|120235|1205330*2" + sData += "0*50*70*60|130011|130022|130044|130131|1302111|130221|130235|1305340*10*30*20*80" + sData += "|140011|140022|140044|140131|1402111|140221|140235|1405370*50*80*40*30" + + case nTurn == 6 + hb_gtInfo( HB_GTI_WINTITLE,'RMChart [ Next:F11 ] '+'Flow Chart' ) + SetMode( 30,50 ) + + sData += "00003305|00004400|000051|00008-984833|00009412|00011Tahoma|100011|100035|100045|" + sData += "10005-5|10006-5|10180\7C|010011|010051|010072|010081|0101050|0101125|01012100|01" + sData += "01325|01014-5952982|01015-5952982|01016255|010191|0102010|01026Start|01030-256|0" + sData += "10012|010054|0100721|01014-16776961|010222|01024100*100|0102550*75|01026|010272|" + sData += "010293|010013|010051|010071|010081|0101050|0101175|01012100|0101325|01014-669788" + sData += "2|01015-6697882|01016255|010191|0102010|01026i = 1|01030-16777216|010014|010054|" + sData += "0100721|01014-16776961|010222|01024100*100|01025100*150|01026|010272|010293|0100" + sData += "15|010051|010073|010081|0101050|01011150|01012100|0101350|01014-65536|01015-6553" + sData += "6|01016255|010191|0102010|01026i = 39?|01030-256|010016|010054|0100721|01014-167" + sData += "76961|010222|01024100*100|01025200*225|01026|010272|010293|010017|010051|010071|" + sData += "010081|0101050|01011225|01012100|0101325|01014-6697882|01015-6697882|01016255|01" + sData += "0191|0102010|01026i = i + 1|01030-16777216|010018|010054|0100721|01014-16776961" + sData += "|010222|01024100*100|01025250*275|01026|010272|010293|010019|010051|010073|01008" + sData += "1|0101050|01011275|01012100|0101350|01014-65536|01015-65536|01016255|010191|0102" + sData += "010|01026i <= 100|01030-256|0100110|010054|0100721|01014-16776961|010222|0102410" + sData += "0*100|01025325*350|01026|010272|010293|0100111|010051|010072|010081|0101050|0101" + sData += "1350|01012100|0101325|01014-5952982|01015-5952982|01016255|010191|0102010|01026S" + sData += "top|01030-256|0100113|010054|0100721|01014-16776961|010222|01024150*200|01025175" + sData += "*175|01026|010272|010293|0100114|010051|010081|01010145|01011157|0101250|01014-1" + sData += "6776961|01015-5383962|01016255|010191|0102010|01026yes|01030-16777216|0100115|01" + sData += "0051|010071|010081|01010200|01011162|01012100|0101325|01014-6697882|01015-669788" + sData += "2|01016255|010191|0102010|01026i = 69|01030-16777216|0100116|010054|0100721|0101" + sData += "4-16776961|010224|0102450*10*10*100|01025300*300*125*125|01026|010272|010293|010" + sData += "0117|010054|0100721|01014-16776961|010223|01024250*250*100|01025162*125*125|0102" + sData += "6|010272|010293|0100118|010051|010081|01010100|01011200|0101250|0101325|01014-16" + sData += "776961|01016255|010191|0102010|01026no|01030-16777216|0100119|010051|010081|0101" + sData += "010|01011280|0101240|01014-16776961|01016255|010191|0102010|01026yes|01030-16777" + sData += "216|0100120|010051|010081|01010100|01011322|0101250|01014-16776961|01016255|0101" + sData += "91|0102010|01026no|01030-16777216|0100120|010051|010079|01010180|01011280|010121" + sData += "20|01013100|01015-39322|010191|010209|01026RMChart is not a flowchart tool. This" + sData += " is just an example for the use of CustomObjects!|01030-256" + + endcase + + oCom:Reset() + oCom:RMCFile := sData + oCom:Draw( .t. ) + Resize( oCom ) + + endif + endif - endif - - if nKey == 27 - exit - endif - enddo - - oCom:Destroy() + if nKey == 27 + exit + endif + enddo + oCom:Destroy() + endif Return nil //----------------------------------------------------------------------// Function ConfigureRMChart( RMChart ) @@ -2615,3 +2620,26 @@ Static Function DoModalWindow() Return nil //----------------------------------------------------------------------// +Function Experiment_1() + hb_threadStart( {|| ExperimentWGU() } ) + Return nil +//----------------------------------------------------------------------// +Static Function ExperimentWGU() + Local nKey + + hb_gtReload( 'WGU' ) + //hb_gtInfo( HB_GTI_RESIZABLE, .f. ) + hb_gtInfo( HB_GTI_WINTITLE, 'WGU Dialog Under GT Control' ) + + do while .t. + nKey := inkey( 0.1 ) + if nKey <> 0 +//hb_toOutDebug( 'inkey == %i rows=%i cols=%i', nKey, maxrow(), maxcol() ) + endif + if nKey == 27 + exit + endif + enddo + Return NIL +//----------------------------------------------------------------------// + diff --git a/harbour/contrib/gtwvg/wvgax.prg b/harbour/contrib/gtwvg/wvgax.prg index 6028d15364..0ac09e211e 100644 --- a/harbour/contrib/gtwvg/wvgax.prg +++ b/harbour/contrib/gtwvg/wvgax.prg @@ -175,6 +175,11 @@ METHOD Create( oParent, oOwner, aPos, aSize, aPresParams, lVisible, cCLSID, cLic ::hObj := HB_AX_AtlAxGetControl( "ATLAXWin", ::hContainer, ::CLSID, ::Id, ; ::aPos[ 1 ], ::aPos[ 2 ], ::aSize[ 1 ], ::aSize[ 2 ], ::style, ::exStyle, @hx ) + + if ::hObj == 0 + Return NIL + endif + ::hWnd := hx IF ::hObj <> 0 .AND. !Empty( ::hEvents ) diff --git a/harbour/contrib/gtwvg/wvggui.c b/harbour/contrib/gtwvg/wvggui.c new file mode 100644 index 0000000000..7589a6ad01 --- /dev/null +++ b/harbour/contrib/gtwvg/wvggui.c @@ -0,0 +1,2712 @@ +/* + * $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 Przemyslaw Czerpak + * + * Copyright 2006 Przemyslaw Czerpak + * Adopted to new GT API + * + * 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 + * + */ +#if 1 + +#define HB_OS_WIN_32_USED + +#include "wvggui.h" + +static int s_GtId; +static HB_GT_FUNCS SuperTable; +#define HB_GTSUPER (&SuperTable) +#define HB_GTID_PTR (&s_GtId) + +#define HB_GTWVT_GET(p) ( ( PHB_GTWVT ) HB_GTLOCAL( p ) ) + +static HB_CRITICAL_NEW( s_wvtMtx ); +#define HB_WVT_LOCK hb_threadEnterCriticalSection( &s_wvtMtx ); +#define HB_WVT_UNLOCK hb_threadLeaveCriticalSection( &s_wvtMtx ); + +static PHB_GTWVT s_wvtWindows[ WVT_MAX_WINDOWS ]; +static int s_wvtCount = 0; + +static const TCHAR s_szClassName[] = TEXT( "Harbour_WVGGUI_Class" ); + +static const 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 LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ); + +static void hb_gt_wvt_RegisterClass( HINSTANCE hInstance ) +{ + WNDCLASS wndclass; + + memset( &wndclass, 0, sizeof( WNDCLASS ) ); + wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; + wndclass.lpfnWndProc = hb_gt_wvt_WndProc; +/* wndclass.cbClsExtra = 0; */ +/* wndclass.cbWndExtra = 0; */ + wndclass.hInstance = hInstance; +/* wndclass.hIcon = NULL; */ + wndclass.hCursor = LoadCursor( NULL, IDC_ARROW ); + wndclass.hbrBackground = ( HBRUSH ) ( COLOR_BTNFACE + 1 ); +/* wndclass.lpszMenuName = NULL; */ + wndclass.lpszClassName = s_szClassName; + + if( ! RegisterClass( &wndclass ) ) + { + int iError = GetLastError(); + if( iError != 1410 ) + { + hb_errInternal( 10001, "Failed to register WVT window class", NULL, NULL ); + } + } +} + +static PHB_GTWVT hb_gt_wvt_Find( HWND hWnd ) +{ + int iCount = s_wvtCount, iPos = 0; + PHB_GTWVT pWVT = NULL; + + HB_WVT_LOCK + + while( iCount && iPos < WVT_MAX_WINDOWS ) + { + if( s_wvtWindows[ iPos ] ) + { + if( s_wvtWindows[ iPos ]->hWnd == hWnd ) + { + pWVT = s_wvtWindows[ iPos ]; + break; + } + --iCount; + } + ++iPos; + } + + HB_WVT_UNLOCK + + return pWVT; +} + +static BOOL hb_gt_wvt_Alloc( PHB_GTWVT pWVT ) +{ + BOOL fOK = FALSE; + + HB_WVT_LOCK + + if( s_wvtCount < WVT_MAX_WINDOWS ) + { + int iPos = 0; + do + { + if( s_wvtWindows[ iPos ] == NULL ) + { + s_wvtWindows[ iPos ] = pWVT; + pWVT->iHandle = iPos; + if( ++s_wvtCount == 1 ) + hb_gt_wvt_RegisterClass( pWVT->hInstance ); + fOK = TRUE; + break; + } + ++iPos; + } + while( iPos < WVT_MAX_WINDOWS ); + } + + HB_WVT_UNLOCK + + return fOK; +} + +static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) +{ + HB_WVT_LOCK + + s_wvtWindows[ pWVT->iHandle ] = NULL; + + if( --s_wvtCount == 0 ) + { + if( pWVT->hInstance ) + UnregisterClass( s_szClassName, pWVT->hInstance ); + } + + HB_WVT_UNLOCK + + // Detach PRG callback + pWVT->pSymWVT_PAINT = NULL; + pWVT->pSymWVT_SETFOCUS = NULL; + pWVT->pSymWVT_KILLFOCUS = NULL; + pWVT->pSymWVT_MOUSE = NULL; + pWVT->pSymWVT_TIMER = NULL; + pWVT->pSymWVT_KEY = NULL; + + hb_itemRelease( pWVT->pPP->pParentGT ); + hb_xfree( pWVT->pPP ); + + if( pWVT->hWnd ) + DestroyWindow( pWVT->hWnd ); + + if( pWVT->hIcon && pWVT->bIconToFree ) + DestroyIcon( pWVT->hIcon ); + + hb_xfree( pWVT ); +} + +static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) +{ + PHB_GTWVT pWVT; + OSVERSIONINFO osvi; + + osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); + GetVersionEx( &osvi ); + + pWVT = ( PHB_GTWVT ) hb_xgrab( sizeof( HB_GTWVT ) ); + memset( pWVT, 0, sizeof( HB_GTWVT ) ); + pWVT->pGT = pGT; + + if( !hb_gt_wvt_Alloc( pWVT ) ) + { + hb_xfree( pWVT ); + return NULL; + } + + pWVT->hInstance = ( HINSTANCE ) hInstance; + pWVT->iCmdShow = iCmdShow; + + pWVT->ROWS = WVT_DEFAULT_ROWS; + pWVT->COLS = WVT_DEFAULT_COLS; + + /* THESE are the default font parameters, if not changed by user */ + pWVT->PTEXTSIZE.x = WVT_DEFAULT_FONT_WIDTH; + pWVT->PTEXTSIZE.y = WVT_DEFAULT_FONT_HEIGHT; + pWVT->fontWidth = WVT_DEFAULT_FONT_WIDTH; + pWVT->fontHeight = WVT_DEFAULT_FONT_HEIGHT; + pWVT->fontWeight = FW_NORMAL; + pWVT->fontQuality = DEFAULT_QUALITY; + hb_strncpy( pWVT->fontFace, WVT_DEFAULT_FONT_NAME, sizeof( pWVT->fontFace ) - 1 ); + + pWVT->MousePos.x = 0; + pWVT->MousePos.y = 0; + pWVT->MouseMove = TRUE; + pWVT->hWnd = NULL; + pWVT->keyPointerIn = 0; + pWVT->keyPointerOut = 0; + pWVT->keyLast = 0; + + pWVT->CentreWindow = TRUE; /* Default is to always display window in centre of screen */ + pWVT->CodePage = OEM_CHARSET; /* GetACP(); - set code page to default system */ + + pWVT->Win9X = ( osvi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ); + pWVT->AltF4Close = FALSE; + + pWVT->IgnoreWM_SYSCHAR = FALSE; + + pWVT->bMaximized = FALSE; + pWVT->bResizable = TRUE; + pWVT->bClosable = TRUE; + + pWVT->pPP = ( HB_GT_PARAMS * ) hb_xgrab( sizeof( HB_GT_PARAMS ) ); + pWVT->pPP->style = WS_THICKFRAME|WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX; + pWVT->pPP->exStyle = 0; + pWVT->pPP->x = 0; + pWVT->pPP->y = 0; + pWVT->pPP->width = 600; + pWVT->pPP->height = 400; + pWVT->pPP->pParentGT = NULL; + pWVT->pPP->bVisible = FALSE; + pWVT->pPP->bConfigured = FALSE; + pWVT->pPP->bRowCols = FALSE; + +#ifndef HB_CDP_SUPPORT_OFF + pWVT->hostCDP = hb_vmCDP(); +#if defined( UNICODE ) + pWVT->inCDP = hb_vmCDP(); +#else + { + int i; + for( i = 0; i < 256; ++i ) + pWVT->chrTransTbl[ i ] = pWVT->keyTransTbl[ i ] = ( BYTE ) i; + } +#endif +#endif + + pWVT->bResizing = FALSE; + + return pWVT; +} + +static int hb_gt_wvt_FireEvent( PHB_GTWVT pWVT, int nEvent, PHB_ITEM pParams ) +{ + int nResult = 0; /* Unhandled */ + + if( pWVT->pGT->pNotifierBlock ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pEvent = hb_itemPutNI( NULL, nEvent ); + + nResult = hb_itemGetNI( hb_vmEvalBlockV( ( PHB_ITEM ) pWVT->pGT->pNotifierBlock, 2, pEvent, pParams ) ); + + hb_itemRelease( pEvent ); + + hb_vmRequestRestore(); + } + } + + return nResult; +} + +/* + * use the standard fixed oem font, unless the caller has requested set size fonts + */ +static HFONT hb_gt_wvt_GetFont( const char * pszFace, int iHeight, int iWidth, int iWeight, int iQuality, int iCodePage ) +{ + if( iHeight > 0 ) + { + LOGFONT logfont; + + memset( &logfont, 0, sizeof( LOGFONT ) ); + logfont.lfEscapement = 0; + logfont.lfOrientation = 0; + logfont.lfWeight = iWeight; + logfont.lfItalic = 0; + logfont.lfUnderline = 0; + logfont.lfStrikeOut = 0; + logfont.lfCharSet = ( BYTE ) iCodePage; /* OEM_CHARSET */ + logfont.lfOutPrecision = 0; + logfont.lfClipPrecision = 0; + logfont.lfQuality = ( BYTE ) iQuality; /* DEFAULT_QUALITY, DRAFT_QUALITY or PROOF_QUALITY */ + logfont.lfPitchAndFamily = FIXED_PITCH | FF_MODERN; /* all mapping depends on fixed width fonts! */ + logfont.lfHeight = iHeight; + logfont.lfWidth = iWidth < 0 ? -iWidth : iWidth; + + HB_TCHAR_CPTO( logfont.lfFaceName, pszFace, sizeof( logfont.lfFaceName ) - 1 ); + + return CreateFontIndirect( &logfont ); + } + else + return ( HFONT ) GetStockObject( OEM_FIXED_FONT /* SYSTEM_FIXED_FONT */ ); +} + +static RECT hb_gt_wvt_GetXYFromColRowRect( PHB_GTWVT pWVT, RECT colrow ) +{ + RECT xy; + + xy.left = colrow.left * pWVT->PTEXTSIZE.x; + xy.top = colrow.top * pWVT->PTEXTSIZE.y; + xy.right = ( colrow.right + 1 ) * pWVT->PTEXTSIZE.x; + xy.bottom = ( colrow.bottom + 1 ) * pWVT->PTEXTSIZE.y; + + return xy; +} + +/* + * functions for handling the input queues for the mouse and keyboard + */ +static void hb_gt_wvt_AddCharToInputQueue( PHB_GTWVT pWVT, int iKey ) +{ + int iPos = pWVT->keyPointerIn; + + if( iKey == K_MOUSEMOVE || iKey == K_NCMOUSEMOVE ) + { + /* Clipper strips repeated mouse movemnt - let's do the same */ + if( pWVT->keyLast == iKey && pWVT->keyPointerIn != pWVT->keyPointerOut ) + return; + } + + /* + * When the buffer is full new event overwrite the last one + * in the buffer - it's Clipper behavior, [druzus] + */ + pWVT->Keys[ iPos ] = pWVT->keyLast = iKey; + if( ++iPos >= WVT_CHAR_QUEUE_SIZE ) + iPos = 0; + if( iPos != pWVT->keyPointerOut ) + pWVT->keyPointerIn = iPos; + + if( pWVT->pSymWVT_KEY ) + { + if( hb_vmRequestReenter() ) + { + hb_vmPushDynSym( pWVT->pSymWVT_KEY ); + hb_vmPushNil(); + hb_vmPushInteger( iKey ); + hb_vmDo( 1 ); + hb_vmRequestRestore(); + } + } + /* Fire event to be trapped by the application */ + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + hb_itemPutNI( pEvParams, iKey ); + hb_gt_wvt_FireEvent( pWVT, HB_GTE_KEYBOARD, pEvParams ); + hb_itemRelease( pEvParams ); + } +} + +static BOOL hb_gt_wvt_GetCharFromInputQueue( PHB_GTWVT pWVT, int * iKey ) +{ + if( pWVT->keyPointerOut != pWVT->keyPointerIn ) + { + *iKey = pWVT->Keys[ pWVT->keyPointerOut ]; + if( ++pWVT->keyPointerOut >= WVT_CHAR_QUEUE_SIZE ) + { + pWVT->keyPointerOut = 0; + } + return TRUE; + } + + *iKey = 0; + return FALSE; +} + +static void hb_gt_wvt_TranslateKey( PHB_GTWVT pWVT, int key, int shiftkey, int altkey, int controlkey ) +{ + int nVirtKey = GetKeyState( VK_MENU ); + + if( nVirtKey & 0x8000 ) /* alt + key */ + { + hb_gt_wvt_AddCharToInputQueue( pWVT, altkey ); + } + else + { + nVirtKey = GetKeyState( VK_CONTROL ); + if( nVirtKey & 0x8000 ) /* control + key */ + { + hb_gt_wvt_AddCharToInputQueue( pWVT, controlkey ); + } + else + { + nVirtKey = GetKeyState( VK_SHIFT ); + if( nVirtKey & 0x8000 ) /* shift + key */ + hb_gt_wvt_AddCharToInputQueue( pWVT, shiftkey ); + else /* just key */ + hb_gt_wvt_AddCharToInputQueue( pWVT, key ); + } + } +} + +static int hb_gt_wvt_key_ansi_to_oem( int c ) +{ + BYTE pszAnsi[ 2 ]; + BYTE pszOem[ 2 ]; + + pszAnsi[ 0 ] = ( BYTE ) c; + pszAnsi[ 1 ] = 0; + CharToOemBuffA( ( LPCSTR ) pszAnsi, ( LPSTR ) pszOem, 1 ); + + return * pszOem; +} + +static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT ) +{ + HDC hdc; + HFONT hFont, hOldFont; + USHORT height, width; + RECT wi, ci; + TEXTMETRIC tm; + 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 . + * No need to call hb_gt_wvt_GetFont() if font is already existant [prtpal 20081108] + */ + if( !pWVT->hFont ) + { + hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, + pWVT->fontWeight, pWVT->fontQuality, pWVT->CodePage ); + pWVT->hFont = hFont; + } + else + { + hFont = pWVT->hFont; + } + + hdc = GetDC( pWVT->hWnd ); + hOldFont = ( HFONT ) SelectObject( hdc, hFont ); + GetTextMetrics( hdc, &tm ); + SetTextCharacterExtra( hdc, 0 ); /* do not add extra char spacing even if bold */ + SelectObject( hdc, hOldFont ); + ReleaseDC( pWVT->hWnd, hdc ); + + /* + * 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! + */ + + pWVT->PTEXTSIZE.x = pWVT->fontWidth < 0 ? -pWVT->fontWidth : + tm.tmAveCharWidth; /* For fixed FONT should == tm.tmMaxCharWidth */ + pWVT->PTEXTSIZE.y = tm.tmHeight; /* but seems to be a problem on Win9X so */ + /* assume proportional fonts always for Win9X */ +#if defined(HB_WINCE) + pWVT->FixedFont = FALSE; +#else + pWVT->FixedFont = !pWVT->Win9X && pWVT->fontWidth >= 0 && + ( tm.tmPitchAndFamily & TMPF_FIXED_PITCH ) == 0 && + ( pWVT->PTEXTSIZE.x == tm.tmMaxCharWidth ); +#endif + + /* pWVT->FixedSize[] is used by ExtTextOut() to emulate + fixed font when a proportional font is used */ + for( n = 0; n < pWVT->COLS; n++ ) + pWVT->FixedSize[ n ] = pWVT->PTEXTSIZE.x; + + /* resize the window to get the specified number of rows and columns */ + GetWindowRect( pWVT->hWnd, &wi ); + GetClientRect( pWVT->hWnd, &ci ); + + height = ( USHORT ) ( pWVT->PTEXTSIZE.y * pWVT->ROWS ); + width = ( USHORT ) ( pWVT->PTEXTSIZE.x * pWVT->COLS ); + + width += ( USHORT ) ( wi.right - wi.left - ci.right ); + height += ( USHORT ) ( wi.bottom - wi.top - ci.bottom ); + + /* Center the window within the CLIENT area on the screen + but only if pWVT->CentreWindow == TRUE */ + if( pWVT->CentreWindow && SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWorkArea, 0 ) ) + { + wi.left = rcWorkArea.left + ( ( rcWorkArea.right - rcWorkArea.left - width ) / 2 ); + wi.top = rcWorkArea.top + ( ( rcWorkArea.bottom - rcWorkArea.top - height ) / 2 ); + } + + if( wi.left < 0 || wi.top < 0 ) + { + #if 0 // IMO not required [pritpal] + if( hb_gt_wvt_IsSizeChanged( pWVT ) ) + { + hb_gt_wvt_AddCharToInputQueue( pWVT, HB_K_RESIZE ); + } + #endif + + /* resize the window to get the specified number of rows and columns */ + GetWindowRect( pWVT->hWnd, &wi ); + GetClientRect( pWVT->hWnd, &ci ); + + height = ( USHORT ) ( pWVT->PTEXTSIZE.y * pWVT->ROWS ); + width = ( USHORT ) ( pWVT->PTEXTSIZE.x * pWVT->COLS ); + + width += ( USHORT ) ( wi.right - wi.left - ci.right ); + height += ( USHORT ) ( wi.bottom - wi.top - ci.bottom ); + + /* Center the window within the CLIENT area on the screen + but only if pWVT->CentreWindow == TRUE */ + if( pWVT->CentreWindow && SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWorkArea, 0 ) ) + { + wi.left = rcWorkArea.left + ( ( rcWorkArea.right - rcWorkArea.left - width ) / 2 ); + wi.top = rcWorkArea.top + ( ( rcWorkArea.bottom - rcWorkArea.top - height ) / 2 ); + } + } + + SetWindowPos( pWVT->hWnd, NULL, wi.left, wi.top, width, height, SWP_NOZORDER ); + + HB_GTSELF_EXPOSEAREA( pWVT->pGT, 0, 0, pWVT->ROWS, pWVT->COLS ); +} + +static void hb_gt_wvt_SetWindowTitle( HWND hWnd, const char * title ) +{ + LPTSTR text = HB_TCHAR_CONVTO( title ); + SetWindowText( hWnd, text ); + HB_TCHAR_FREE( text ); +} + +static BOOL hb_gt_wvt_GetWindowTitle( HWND hWnd, char ** title ) +{ + TCHAR buffer[WVT_MAX_TITLE_SIZE]; + int iResult; + + iResult = GetWindowText( hWnd, buffer, WVT_MAX_TITLE_SIZE ); + if( iResult > 0 ) + { + *title = ( char * ) hb_xgrab( iResult + 1 ); + HB_TCHAR_GETFROM( *title, buffer, iResult ); + ( *title )[ iResult ] = '\0'; + return TRUE; + } + + *title = NULL; + return FALSE; +} + +static BOOL hb_gt_wvt_SetWindowSize( PHB_GTWVT pWVT, int iRow, int iCol ) +{ + if( HB_GTSELF_RESIZE( pWVT->pGT, iRow, iCol ) ) + { + pWVT->ROWS = ( USHORT ) iRow; + pWVT->COLS = ( USHORT ) iCol; + return TRUE; + } + + return FALSE; +} + +static BOOL hb_gt_wvt_InitWindow( PHB_GTWVT pWVT, int iRow, int iCol ) +{ + BOOL fRet = hb_gt_wvt_SetWindowSize( pWVT, iRow, iCol ); + + hb_gt_wvt_ResetWindowSize( pWVT ); + + return fRet; +} + +static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, LPARAM lParam ) +{ + POINT xy; + SHORT keyCode = 0; + SHORT keyState; + + HB_SYMBOL_UNUSED( wParam ); + + if( ! pWVT->MouseMove && ( message == WM_MOUSEMOVE || message == WM_NCMOUSEMOVE ) ) + return; + + xy.x = LOWORD( lParam ); + xy.y = HIWORD( lParam ); + + 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: + 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 = ( SHORT ) wParam; + + switch( keyState ) + { + case MK_LBUTTON: + keyCode = K_MMLEFTDOWN; + break; + case MK_RBUTTON: + keyCode = K_MMRIGHTDOWN; + break; + case MK_MBUTTON: + keyCode = K_MMMIDDLEDOWN; + break; + default: + keyCode = K_MOUSEMOVE; + } + if( !pWVT->bTracking ) + { + TRACKMOUSEEVENT tmi; + tmi.cbSize = sizeof( TRACKMOUSEEVENT ); + tmi.dwFlags = TME_LEAVE | TME_HOVER ; + tmi.hwndTrack = pWVT->hWnd; + tmi.dwHoverTime = 1; + pWVT->bTracking = _TrackMouseEvent( &tmi ); + } + break; + } + } + case WM_MOUSEWHEEL: + keyState = HIWORD( wParam ); + keyCode = keyState > 0 ? K_MWFORWARD : K_MWBACKWARD; + break; + + case WM_NCMOUSEMOVE: + keyCode = K_NCMOUSEMOVE; + break; + } + + if( keyCode != 0 ) + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + + hb_gt_wvt_AddCharToInputQueue( pWVT, keyCode ); + + hb_arrayNew( pEvParams, 6 ); + hb_arraySetNL( pEvParams, 1, message ); + hb_arraySetNI( pEvParams, 2, keyCode ); + hb_arraySetNI( pEvParams, 3, xy.x ); + hb_arraySetNI( pEvParams, 4, xy.y ); + hb_arraySetNI( pEvParams, 5, xy.y ); + hb_arraySetNI( pEvParams, 6, xy.x ); + + hb_gt_wvt_FireEvent( pWVT, HB_GTE_MOUSE, pEvParams ); + hb_itemRelease( pEvParams ); + } +} + +static BOOL hb_gt_wvt_KeyEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, LPARAM lParam ) +{ + switch( message ) + { + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + { + BOOL bAlt = GetKeyState( VK_MENU ) & 0x8000; + + pWVT->IgnoreWM_SYSCHAR = FALSE; + + switch( wParam ) + { + case VK_LEFT: + hb_gt_wvt_TranslateKey( pWVT, K_LEFT , K_SH_LEFT , K_ALT_LEFT , K_CTRL_LEFT ); + break; + case VK_RIGHT: + hb_gt_wvt_TranslateKey( pWVT, K_RIGHT, K_SH_RIGHT, K_ALT_RIGHT, K_CTRL_RIGHT ); + break; + case VK_UP: + hb_gt_wvt_TranslateKey( pWVT, K_UP , K_SH_UP , K_ALT_UP , K_CTRL_UP ); + break; + case VK_DOWN: + hb_gt_wvt_TranslateKey( pWVT, K_DOWN , K_SH_DOWN , K_ALT_DOWN , K_CTRL_DOWN ); + break; + case VK_HOME: + hb_gt_wvt_TranslateKey( pWVT, K_HOME , K_SH_HOME , K_ALT_HOME , K_CTRL_HOME ); + break; + case VK_END: + hb_gt_wvt_TranslateKey( pWVT, K_END , K_SH_END , K_ALT_END , K_CTRL_END ); + break; + case VK_DELETE: + hb_gt_wvt_TranslateKey( pWVT, K_DEL , K_SH_DEL , K_ALT_DEL , K_CTRL_DEL ); + break; + case VK_INSERT: + hb_gt_wvt_TranslateKey( pWVT, K_INS , K_SH_INS , K_ALT_INS , K_CTRL_INS ); + break; + case VK_PRIOR: + hb_gt_wvt_TranslateKey( pWVT, K_PGUP , K_SH_PGUP , K_ALT_PGUP , K_CTRL_PGUP ); + break; + case VK_NEXT: + hb_gt_wvt_TranslateKey( pWVT, K_PGDN , K_SH_PGDN , K_ALT_PGDN , K_CTRL_PGDN ); + break; + + case VK_F1: + hb_gt_wvt_TranslateKey( pWVT, K_F1 , K_SH_F1, K_ALT_F1 , K_CTRL_F1 ); + break; + case VK_F2: + hb_gt_wvt_TranslateKey( pWVT, K_F2 , K_SH_F2, K_ALT_F2 , K_CTRL_F2 ); + break; + case VK_F3: + hb_gt_wvt_TranslateKey( pWVT, K_F3 , K_SH_F3, K_ALT_F3 , K_CTRL_F3 ); + break; + case VK_F4: + if( pWVT->AltF4Close && bAlt ) + return DefWindowProc( pWVT->hWnd, message, wParam, lParam ) != 0; + hb_gt_wvt_TranslateKey( pWVT, K_F4 , K_SH_F4, K_ALT_F4 , K_CTRL_F4 ); + break; + case VK_F5: + hb_gt_wvt_TranslateKey( pWVT, K_F5 , K_SH_F5, K_ALT_F5 , K_CTRL_F5 ); + break; + case VK_F6: + hb_gt_wvt_TranslateKey( pWVT, K_F6 , K_SH_F6, K_ALT_F6 , K_CTRL_F6 ); + break; + case VK_F7: + hb_gt_wvt_TranslateKey( pWVT, K_F7 , K_SH_F7, K_ALT_F7 , K_CTRL_F7 ); + break; + case VK_F8: + hb_gt_wvt_TranslateKey( pWVT, K_F8 , K_SH_F8, K_ALT_F8 , K_CTRL_F8 ); + break; + case VK_F9: + hb_gt_wvt_TranslateKey( pWVT, K_F9 , K_SH_F9, K_ALT_F9 , K_CTRL_F9 ); + break; + case VK_F10: + hb_gt_wvt_TranslateKey( pWVT, K_F10 , K_SH_F10,K_ALT_F10 , K_CTRL_F10 ); + break; + case VK_F11: + hb_gt_wvt_TranslateKey( pWVT, K_F11 , K_SH_F11,K_ALT_F11 , K_CTRL_F11 ); + break; + case VK_F12: + hb_gt_wvt_TranslateKey( pWVT, 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_gt_wvt_AddCharToInputQueue( pWVT, KP_CTRL_5 ); + } + else if( bCtrl && wParam == VK_TAB ) /* K_CTRL_TAB */ + { + hb_gt_wvt_AddCharToInputQueue( pWVT, bShift ? K_CTRL_SH_TAB : K_CTRL_TAB ); + } + else if( iScanCode == 70 ) /* Ctrl_Break key OR Scroll Lock Key */ + { + if( bCtrl ) /* Not scroll lock */ + { + hb_gt_wvt_AddCharToInputQueue( pWVT, HB_BREAK_FLAG ); /* Pretend Alt+C pressed */ + pWVT->IgnoreWM_SYSCHAR = TRUE; + } + else + { + DefWindowProc( pWVT->hWnd, message, wParam, lParam ); /* Let windows handle ScrollLock */ + } + } + else if( bCtrl && iScanCode == 53 && bShift ) + { + hb_gt_wvt_AddCharToInputQueue( pWVT, K_CTRL_QUESTION ); + } + else if( ( bAlt || bCtrl ) && ( + wParam == VK_MULTIPLY || wParam == VK_ADD || + wParam == VK_SUBTRACT || wParam == VK_DIVIDE ) ) + { + if( bAlt ) + pWVT->IgnoreWM_SYSCHAR = TRUE; + + switch( wParam ) + { + case VK_MULTIPLY: + hb_gt_wvt_TranslateKey( pWVT, '*', '*', KP_ALT_ASTERISK, KP_CTRL_ASTERISK ); + break; + case VK_ADD: + hb_gt_wvt_TranslateKey( pWVT, '+', '+', KP_ALT_PLUS, KP_CTRL_PLUS ); + break; + case VK_SUBTRACT: + hb_gt_wvt_TranslateKey( pWVT, '-', '-', KP_ALT_MINUS, KP_CTRL_MINUS ); + break; + case VK_DIVIDE: + hb_gt_wvt_TranslateKey( pWVT, '/', '/', KP_ALT_SLASH, KP_CTRL_SLASH ); + break; + } + } + else if( pWVT->EnableShortCuts ) + { + return DefWindowProc( pWVT->hWnd, message, wParam, lParam ) != 0; + } + } + } + break; + } + + case WM_CHAR: + { + BOOL bCtrl = GetKeyState( VK_CONTROL ) & 0x8000; + int iScanCode = HIWORD( lParam ) & 0xFF; + int c = ( int ) wParam; + + if( !pWVT->IgnoreWM_SYSCHAR ) + { + if( bCtrl && iScanCode == 28 ) /* K_CTRL_RETURN */ + { + hb_gt_wvt_AddCharToInputQueue( pWVT, K_CTRL_RETURN ); + } + else if( bCtrl && ( c >= 1 && c <= 26 ) ) /* K_CTRL_A - Z */ + { + hb_gt_wvt_AddCharToInputQueue( pWVT, K_Ctrl[ c - 1 ] ); + } + else + { + switch( c ) + { + /* handle special characters */ + case VK_BACK: + hb_gt_wvt_TranslateKey( pWVT, K_BS, K_SH_BS, K_ALT_BS, K_CTRL_BS ); + break; + case VK_TAB: + hb_gt_wvt_TranslateKey( pWVT, K_TAB, K_SH_TAB, K_ALT_TAB, K_CTRL_TAB ); + break; + case VK_RETURN: + hb_gt_wvt_TranslateKey( pWVT, K_RETURN, K_SH_RETURN, K_ALT_RETURN, K_CTRL_RETURN ); + break; + case VK_ESCAPE: + hb_gt_wvt_AddCharToInputQueue( pWVT, K_ESC ); + break; + default: + if( pWVT->inCDP ) + { +#if defined( UNICODE ) + c = hb_cdpGetChar( pWVT->inCDP, FALSE, ( USHORT ) c ); +#else + if( c > 0 && c <= 255 && pWVT->keyTransTbl[ c ] ) + c = pWVT->keyTransTbl[ c ]; +#endif + } + else if( pWVT->CodePage == OEM_CHARSET ) + c = hb_gt_wvt_key_ansi_to_oem( c ); + hb_gt_wvt_AddCharToInputQueue( pWVT, c ); + break; + } + } + } + pWVT->IgnoreWM_SYSCHAR = FALSE; /* As Suggested by Peter */ + break; + } + + case WM_SYSCHAR: + { + if( !pWVT->IgnoreWM_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_gt_wvt_AddCharToInputQueue( pWVT, c ); + } + pWVT->IgnoreWM_SYSCHAR = FALSE; + } + } + + return 0; +} + +static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam ) +{ + PHB_GTWVT pWVT = hb_gt_wvt_Find( hWnd ); + + if( pWVT ) switch( message ) + { + case WM_CREATE: + return hb_gt_wvt_InitWindow( pWVT, pWVT->ROWS, pWVT->COLS ); + + case WM_PAINT: + return DefWindowProc( hWnd, message, wParam, lParam );; + + case WM_SETFOCUS: + if( pWVT->bGetFocus ) + { + if( pWVT->pSymWVT_SETFOCUS ) + { + if( hb_vmRequestReenter() ) + { + hb_vmPushDynSym( pWVT->pSymWVT_SETFOCUS ); + hb_vmPushNil(); + hb_vmPushNumInt( ( HB_LONG ) ( HB_PTRDIFF ) hWnd ); + hb_vmDo( 1 ); + hb_vmRequestRestore(); + } + } + } + else + { + pWVT->bGetFocus = TRUE; + } + return 0; + + case WM_KILLFOCUS: + if( pWVT->pSymWVT_KILLFOCUS ) + { + if( hb_vmRequestReenter() ) + { + hb_vmPushDynSym( pWVT->pSymWVT_KILLFOCUS ); + hb_vmPushNil(); + hb_vmPushNumInt( ( HB_LONG ) ( HB_PTRDIFF ) hWnd ); + hb_vmDo( 1 ); + hb_vmRequestRestore(); + } + } + return 0; + + case WM_KEYDOWN: + case WM_SYSKEYDOWN: + case WM_CHAR: + case WM_SYSCHAR: + return hb_gt_wvt_KeyEvent( pWVT, message, wParam, lParam ); + + case WM_RBUTTONDOWN: + case WM_LBUTTONDOWN: + case WM_RBUTTONUP: + 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_gt_wvt_MouseEvent( pWVT, message, wParam, lParam ); + return 0; + + case WM_QUERYENDSESSION: /* Closing down computer */ + hb_vmRequestQuit(); + return 0; + + case WM_CLOSE: /* Clicked 'X' on system menu */ + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + if( hb_gt_wvt_FireEvent( pWVT, HB_GTE_CLOSE, pEvParams ) == 0 ) + { + PHB_ITEM pItem = hb_itemPutL( NULL, TRUE ); + hb_setSetItem( HB_SET_CANCEL, pItem ); + hb_itemRelease( pItem ); + hb_vmRequestCancel(); + } + hb_itemRelease( pEvParams ); + return 0; + } + case WM_QUIT: + case WM_DESTROY: + return 0; + + case WM_ENTERIDLE: + /* FSG - 12/05/2004 - Signal than i'm on idle */ + hb_idleState(); + return 0; + + /* Pritpal Bedi - 06 Jun 2008 */ + case WM_ACTIVATE: + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + hb_gt_wvt_FireEvent( pWVT, ( LOWORD( wParam ) == WA_INACTIVE ? HB_GTE_KILLFOCUS : HB_GTE_SETFOCUS ), pEvParams ); + hb_itemRelease( pEvParams ); + return 0; + } + + case WM_SIZE: + // Fire Event + return 0; + + case WM_SYSCOMMAND: + switch( wParam ) + { + case SC_MAXIMIZE: + { + pWVT->bMaximized = TRUE; + } + } + break; + + case WM_TIMER: + if( pWVT->pSymWVT_TIMER ) + { + if( hb_vmRequestReenter() ) + { + hb_vmPushDynSym( pWVT->pSymWVT_TIMER ); + hb_vmPushNil(); + hb_vmPushNumInt( wParam ); + hb_vmDo( 1 ); + hb_vmRequestRestore(); + } + } + return 0; + + case HB_MSG_NOTIFYICON: + if( lParam == WM_RBUTTONUP ) + { + NOTIFYICONDATA tnid ; + tnid.cbSize = sizeof( NOTIFYICONDATA ) ; + tnid.hWnd = hWnd; + tnid.uID = HB_ID_NOTIFYICON; + tnid.uCallbackMessage = HB_MSG_NOTIFYICON; + tnid.hIcon = NULL; + Shell_NotifyIcon( NIM_DELETE, &tnid ); + ShowWindow( hWnd, SW_RESTORE ); + } + return 0; + + case WM_COMMAND: + + return 0; + + case WM_MOUSEHOVER: + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + + hb_arrayNew( pEvParams, 6 ); + hb_arraySetNI( pEvParams, 1, message ); + hb_arraySetNI( pEvParams, 2, 0 ); + hb_arraySetNI( pEvParams, 3, LOWORD( lParam ) ); + hb_arraySetNI( pEvParams, 4, HIWORD( lParam ) ); + + hb_gt_wvt_FireEvent( pWVT, HB_GTE_MOUSE, pEvParams ); + + hb_itemRelease( pEvParams ); + return 0; + } + case WM_MOUSELEAVE: + { + PHB_ITEM pEvParams = hb_itemNew( NULL ); + + hb_arrayNew( pEvParams, 2 ); + hb_arraySetNI( pEvParams, 1, message ); + hb_arraySetNI( pEvParams, 2, 0 ); + + hb_gt_wvt_FireEvent( pWVT, HB_GTE_MOUSE, pEvParams ); + + hb_itemRelease( pEvParams ); + pWVT->bTracking = FALSE; + return DefWindowProc( hWnd, message, wParam, lParam );; + } + } + + return DefWindowProc( hWnd, message, wParam, lParam ); +} + +static DWORD hb_gt_wvt_ProcessMessages( PHB_GTWVT pWVT ) +{ + MSG msg; + + HB_SYMBOL_UNUSED( pWVT ); + while( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + + return ( DWORD ) msg.wParam; +} + +static BOOL hb_gt_wvt_ValidWindowSize( HWND hWnd, int rows, int cols, HFONT hFont, int iWidth ) +{ + HDC hdc; + HFONT hOldFont; + USHORT width, height, maxWidth, maxHeight; + TEXTMETRIC tm; + RECT rcWorkArea; + + SystemParametersInfo( SPI_GETWORKAREA,0, &rcWorkArea, 0 ); + + maxWidth = ( USHORT ) ( rcWorkArea.right - rcWorkArea.left ); + maxHeight = ( USHORT ) ( rcWorkArea.bottom - rcWorkArea.top ); + + hdc = GetDC( hWnd ); + hOldFont = ( HFONT ) SelectObject( hdc, hFont ); + GetTextMetrics( hdc, &tm ); + SelectObject( hdc, hOldFont ); /* Put old font back */ + ReleaseDC( hWnd, hdc ); + + width = ( USHORT ) ( iWidth < 0 ? -iWidth : tm.tmAveCharWidth * cols ); /* Total pixel width this setting would take */ + height = ( USHORT ) ( tm.tmHeight * rows ); /* Total pixel height this setting would take */ + + return ( width <= maxWidth ) && ( height <= maxHeight ); +} + +static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT ) +{ + HWND hWnd, hWndParent; + LPTSTR szAppName; + + szAppName = HB_TCHAR_CONVTO( hb_cmdargARGV()[ 0 ] ); + + hWndParent = NULL; + + if( pWVT->pPP->bConfigured ) + { + PHB_GT pGTp = hb_gt_ItemBase( pWVT->pPP->pParentGT ); + if( pGTp ) + { + PHB_GTWVT pWVTp = HB_GTWVT_GET( pGTp ); + hWndParent = pWVTp->hWnd; + hb_gt_BaseFree( pGTp ); + + if( hWndParent ) + { + RECT rc; + POINT pt; + + GetClientRect( hWndParent, &rc ); + pt.x = rc.left + pWVT->pPP->x; + pt.y = rc.top + pWVT->pPP->y; + + ClientToScreen( hWndParent, &pt ); + + pWVT->pPP->x = pt.x; + pWVT->pPP->y = pt.y; + } + } + if( pWVT->pPP->y < 0 ) + pWVT->CentreWindow = TRUE; + } + + hWnd = CreateWindowEx( + pWVT->pPP->exStyle, /* extended style */ + s_szClassName, /* classname */ + szAppName, /* window name */ + pWVT->pPP->style, /* style */ + pWVT->pPP->x, /* x */ + pWVT->pPP->y, /* y */ + pWVT->pPP->width, /* width */ + pWVT->pPP->height, /* height */ + hWndParent, /* window parent */ + NULL, /* menu */ + pWVT->hInstance, /* instance */ + NULL ); /* lpParam */ + + HB_TCHAR_FREE( szAppName ); + return hWnd; +} + +static BOOL hb_gt_wvt_CreateConsoleWindow( PHB_GTWVT pWVT ) +{ + if( !pWVT->hWnd ) + { + pWVT->hWnd = hb_gt_wvt_CreateWindow( pWVT ); + if( !pWVT->hWnd ) + hb_errInternal( 10001, "Failed to create WVT window", NULL, NULL ); + + hb_gt_wvt_InitWindow( pWVT, pWVT->ROWS, pWVT->COLS ); + + /* Set icon */ + if( pWVT->hIcon ) + { + SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) pWVT->hIcon ); + SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) pWVT->hIcon ); + } + + /* Set default window title */ + { + PHB_FNAME pFileName = hb_fsFNameSplit( hb_cmdargARGV()[ 0 ] ); + hb_gt_wvt_SetWindowTitle( pWVT->hWnd, pFileName->szName ); + hb_xfree( pFileName ); + } + + ShowWindow( pWVT->hWnd, SW_NORMAL ); + UpdateWindow( pWVT->hWnd ); + } + + return TRUE; +} + +/* ********************************************************************** */ +/* + * GT Specific Functions + */ +/* ********************************************************************** */ + +static void hb_gt_wvt_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr ) +{ + HANDLE hInstance; + int iCmdShow; + PHB_GTWVT pWVT; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Init(%p,%p,%p,%p)", pGT, ( void * ) ( HB_PTRDIFF ) hFilenoStdin, ( void * ) ( HB_PTRDIFF ) hFilenoStdout, ( void * ) ( HB_PTRDIFF ) hFilenoStderr ) ); + + if( ! hb_winmainArgGet( &hInstance, NULL, &iCmdShow ) ) + hb_errInternal( 10001, "It's not a GUI program", NULL, NULL ); + + pWVT = hb_gt_wvt_New( pGT, ( HINSTANCE ) hInstance, iCmdShow ); + if( !pWVT ) + hb_errInternal( 10001, "Maximum number of WVT windows reached, cannot create another one", NULL, NULL ); + + HB_GTLOCAL( pGT ) = ( void * ) pWVT; + + /* SUPER GT initialization */ + HB_GTSUPER_INIT( pGT, hFilenoStdin, hFilenoStdout, hFilenoStderr ); + HB_GTSELF_RESIZE( pGT, pWVT->ROWS, pWVT->COLS ); + HB_GTSELF_SEMICOLD( pGT ); + + hb_gt_wvt_CreateConsoleWindow( pWVT ); + hb_gt_wvt_ProcessMessages( pWVT ); +} + +/* ********************************************************************** */ + +static void hb_gt_wvt_Exit( PHB_GT pGT ) +{ + PHB_GTWVT pWVT; + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_wvt_Exit(%p)", pGT)); + + pWVT = HB_GTWVT_GET( pGT ); + HB_GTSUPER_EXIT( pGT ); + + if( pWVT ) + { + hb_gt_wvt_Free( pWVT ); + } +} + +/* ********************************************************************** */ + +static BOOL hb_gt_wvt_SetMode( PHB_GT pGT, int iRow, int iCol ) +{ + PHB_GTWVT pWVT; + BOOL fResult = FALSE; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_SetMode(%p,%d,%d)", pGT, iRow, iCol ) ); + + pWVT = HB_GTWVT_GET( pGT ); + + /* Only execute if iRow|iCol is different then previous settings [pritpal 20081108]*/ + if( iRow <= WVT_MAX_ROWS && iCol <= WVT_MAX_COLS && ( iRow != pWVT->ROWS || iCol != pWVT->COLS ) ) + { + if( pWVT->hWnd ) /* Is the window already open */ + { + /* SETMODE() is supposed to retain the same font as is current */ + /* So no need to recreate it if one is already created [pritpal 20081108] */ + HFONT hFont; + BOOL bCreated; + + if( !pWVT->hFont ) + { + hFont = hb_gt_wvt_GetFont( pWVT->fontFace, pWVT->fontHeight, pWVT->fontWidth, + pWVT->fontWeight, pWVT->fontQuality, pWVT->CodePage ); + bCreated = TRUE; + } + else + { + hFont = pWVT->hFont; + bCreated = FALSE; + } + + if( hFont ) + { + /* + * make sure that the mode selected along with the current + * font settings will fit in the window + */ + if( hb_gt_wvt_ValidWindowSize( pWVT->hWnd, iRow, iCol, hFont, pWVT->fontWidth ) ) + { + fResult = hb_gt_wvt_InitWindow( pWVT, iRow, iCol ); + } + if( bCreated ) + DeleteObject( hFont ); + HB_GTSELF_REFRESH( pGT ); + } + } + else + { + hb_gt_wvt_SetWindowSize( pWVT, iRow, iCol ); + HB_GTSELF_SEMICOLD( pGT ); + } + } + + return fResult; +} + +/* ********************************************************************** */ + +static BOOL hb_gt_wvt_PutChar( PHB_GT pGT, int iRow, int iCol, + BYTE bColor, BYTE bAttr, USHORT usChar ) +{ + if( HB_GTSUPER_PUTCHAR( pGT, iRow, iCol, bColor, bAttr, usChar ) ) + { + HB_GTSELF_TOUCHCELL( pGT, iRow, iCol ); + return TRUE; + } + return FALSE; +} + +/* ********************************************************************** */ + +static const char * hb_gt_wvt_Version( PHB_GT pGT, int iType ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Version(%p,%d)", pGT, iType ) ); + + HB_SYMBOL_UNUSED( pGT ); + + if( iType == 0 ) + return HB_GT_DRVNAME( HB_GT_NAME ); + + return "Harbour Terminal: Windows GUI console (WVG)"; +} + +/* ********************************************************************** */ + +static int hb_gt_wvt_ReadKey( PHB_GT pGT, int iEventMask ) +{ + PHB_GTWVT pWVT; + int c = 0; + BOOL fKey; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_ReadKey(%p,%d)", pGT, iEventMask ) ); + + HB_SYMBOL_UNUSED( iEventMask ); /* we ignore the eventmask! */ + + pWVT = HB_GTWVT_GET( pGT ); + + if( pWVT->hWnd ) /* Is the window already open */ + hb_gt_wvt_ProcessMessages( pWVT ); + + fKey = hb_gt_wvt_GetCharFromInputQueue( pWVT, &c ); + + return fKey ? c : 0; +} + +/* ********************************************************************** */ +/* dDuration is in 'Ticks' (18.2 per second) */ +static void hb_gt_wvt_Tone( PHB_GT pGT, double dFrequency, double dDuration ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_wvt_Tone(%p,%lf,%lf)", pGT, dFrequency, dDuration)); + + HB_SYMBOL_UNUSED( pGT ); + + hb_gt_w32_tone( dFrequency, dDuration ); +} + +/* ********************************************************************** */ + +static BOOL hb_gt_wvt_mouse_IsPresent( PHB_GT pGT ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_wvt_mouse_IsPresent(%p)", pGT)); + + HB_SYMBOL_UNUSED( pGT ); + + return TRUE; +} + +static void hb_gt_wvt_mouse_GetPos( PHB_GT pGT, int * piRow, int * piCol ) +{ + PHB_GTWVT pWVT; + + HB_TRACE(HB_TR_DEBUG, ("hb_gt_wvt_mouse_GetPos(%p,%p,%p)", pGT, piRow, piCol)); + + pWVT = HB_GTWVT_GET( pGT ); + *piRow = pWVT->MousePos.y; + *piCol = pWVT->MousePos.x; +} + +static BOOL hb_gt_wvt_mouse_ButtonState( PHB_GT pGT, int iButton ) +{ + HB_TRACE( HB_TR_DEBUG, ("hb_gt_wvt_mouse_ButtonState(%p,%i)", pGT, iButton) ); + + HB_SYMBOL_UNUSED( pGT ); + + switch( iButton ) + { + case 0: + return ( GetKeyState( VK_LBUTTON ) & 0x8000 ) != 0; + case 1: + return ( GetKeyState( VK_RBUTTON ) & 0x8000 ) != 0; + case 2: + return ( GetKeyState( VK_MBUTTON ) & 0x8000 ) != 0; + } + return FALSE; +} + +static int hb_gt_wvt_mouse_CountButton( PHB_GT pGT ) +{ + HB_TRACE( HB_TR_DEBUG, ("hb_gt_wvt_mouse_CountButton(%p)", pGT) ); + + HB_SYMBOL_UNUSED( pGT ); + + return GetSystemMetrics( SM_CMOUSEBUTTONS ); +} + +/* ********************************************************************** */ + +static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) +{ + PHB_GTWVT pWVT; + int iVal; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Info(%p,%d,%p)", pGT, iType, pInfo ) ); + /* + if( pInfo->pGT && hb_itemType( pInfo->pGT ) & HB_IT_POINTER ) + { + pGT = hb_gt_ItemBase( pInfo->pGT ); + if( pGT ) + hb_gt_BaseFree( pGT ); + else + pGT = pGTx; + } + if( !pGT ) + { + pGT = pGTx; + } + */ + pWVT = HB_GTWVT_GET( pGT ); + + switch( iType ) + { + case HB_GTI_FULLSCREEN: + case HB_GTI_KBDSUPPORT: + case HB_GTI_ISGRAPHIC: + pInfo->pResult = hb_itemPutL( pInfo->pResult, TRUE ); + break; + + case HB_GTI_ISUNICODE: +#if defined( UNICODE ) + pInfo->pResult = hb_itemPutL( pInfo->pResult, TRUE ); +#else + pInfo->pResult = hb_itemPutL( pInfo->pResult, FALSE ); +#endif + break; + + case HB_GTI_INPUTFD: + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, + ( HB_PTRDIFF ) GetStdHandle( STD_INPUT_HANDLE ) ); + break; + + case HB_GTI_OUTPUTFD: + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, + ( HB_PTRDIFF ) GetStdHandle( STD_OUTPUT_HANDLE ) ); + break; + + case HB_GTI_ERRORFD: + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, + ( HB_PTRDIFF ) GetStdHandle( STD_ERROR_HANDLE ) ); + break; + + case HB_GTI_SETFONT: + pInfo->pResult = hb_itemPutL( pInfo->pResult, FALSE ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY ) + { + HFONT hFont = hb_gt_wvt_GetFont( hb_arrayGetCPtr( pInfo->pNewVal, 1 ), + hb_arrayGetNI( pInfo->pNewVal, 2 ), + hb_arrayGetNI( pInfo->pNewVal, 3 ), + hb_arrayGetNI( pInfo->pNewVal, 4 ), + hb_arrayGetNI( pInfo->pNewVal, 5 ), + pWVT->CodePage ); + if( hFont ) + { + if( hb_gt_wvt_ValidWindowSize( pWVT->hWnd, pWVT->ROWS, pWVT->COLS, hFont, hb_arrayGetNI( pInfo->pNewVal, 3 ) ) ) + { + pInfo->pResult = hb_itemPutL( pInfo->pResult, TRUE ); + + hb_strncpy( pWVT->fontFace, hb_arrayGetCPtr( pInfo->pNewVal, 1 ), sizeof( pWVT->fontFace ) - 1 ); + pWVT->fontHeight = hb_arrayGetNI( pInfo->pNewVal, 2 ); + pWVT->fontWidth = hb_arrayGetNI( pInfo->pNewVal, 3 ); + pWVT->fontWeight = hb_arrayGetNI( pInfo->pNewVal, 4 ); + pWVT->fontQuality = hb_arrayGetNI( pInfo->pNewVal, 5 ); + if( pWVT->hWnd ) + { + hb_gt_wvt_ResetWindowSize( pWVT ); + HB_GTSELF_REFRESH( pGT ); + } + } + DeleteObject( hFont ); + } + } + break; + + case HB_GTI_FONTSIZE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->PTEXTSIZE.y ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 ) + { + HFONT hFont = hb_gt_wvt_GetFont( pWVT->fontFace, iVal, pWVT->fontWidth, pWVT->fontWeight, pWVT->fontQuality, pWVT->CodePage ); + + if( hFont ) + { + pWVT->fontHeight = iVal; + if( pWVT->hWnd ) + { + hb_gt_wvt_ResetWindowSize( pWVT ); + HB_GTSELF_REFRESH( pGT ); + } + DeleteObject( hFont ); + } + } + break; + + case HB_GTI_FONTWIDTH: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->fontWidth ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + pWVT->fontWidth = hb_itemGetNI( pInfo->pNewVal ); + + break; + + case HB_GTI_FONTNAME: + pInfo->pResult = hb_itemPutC( pInfo->pResult, pWVT->fontFace ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + hb_strncpy( pWVT->fontFace, hb_itemGetCPtr( pInfo->pNewVal ), sizeof( pWVT->fontFace ) - 1 ); + } + break; + + case HB_GTI_FONTWEIGHT: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->fontWeight ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + pWVT->fontWeight = hb_itemGetNI( pInfo->pNewVal ); + + break; + + case HB_GTI_FONTQUALITY: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->fontQuality ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + pWVT->fontQuality = hb_itemGetNI( pInfo->pNewVal ); + + break; + + case HB_GTI_SCREENHEIGHT: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->PTEXTSIZE.y * pWVT->ROWS ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 ) + { + HB_GTSELF_SETMODE( pGT, ( USHORT ) ( iVal / pWVT->PTEXTSIZE.y ), pWVT->COLS ); + } + break; + + case HB_GTI_SCREENWIDTH: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->PTEXTSIZE.x * pWVT->COLS ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 ) + { + HB_GTSELF_SETMODE( pGT, pWVT->ROWS, ( USHORT ) ( iVal / pWVT->PTEXTSIZE.x ) ); + } + break; + + case HB_GTI_DESKTOPWIDTH: + { + RECT rDesk; + HWND hDesk; + + hDesk = GetDesktopWindow(); + GetWindowRect( hDesk, &rDesk ); + pInfo->pResult = hb_itemPutNI( pInfo->pResult, rDesk.right - rDesk.left ); + break; + } + case HB_GTI_DESKTOPHEIGHT: + { + RECT rDesk; + HWND hDesk = GetDesktopWindow(); + GetWindowRect( hDesk, &rDesk ); + pInfo->pResult = hb_itemPutNI( pInfo->pResult, rDesk.bottom - rDesk.top ); + break; + } + case HB_GTI_DESKTOPCOLS: + { + RECT rDesk; + HWND hDesk; + hDesk = GetDesktopWindow(); + GetClientRect( hDesk, &rDesk ); + pInfo->pResult = hb_itemPutNI( pInfo->pResult, + ( rDesk.right - rDesk.left ) / pWVT->PTEXTSIZE.x ); + break; + } + case HB_GTI_DESKTOPROWS: + { + RECT rDesk; + HWND hDesk; + hDesk = GetDesktopWindow(); + GetClientRect( hDesk, &rDesk ); + pInfo->pResult = hb_itemPutNI( pInfo->pResult, + ( rDesk.bottom - rDesk.top ) / pWVT->PTEXTSIZE.y ); + break; + } + case HB_GTI_WINTITLE: + if( pWVT->hWnd ) + { + char * szTitle = NULL; + if( hb_gt_wvt_GetWindowTitle( pWVT->hWnd, &szTitle ) ) + pInfo->pResult = hb_itemPutCPtr2( pInfo->pResult, szTitle ); + else + pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + hb_gt_wvt_SetWindowTitle( pWVT->hWnd, hb_itemGetCPtr( pInfo->pNewVal ) ); + } + break; + + case HB_GTI_CODEPAGE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->CodePage ); + iVal = hb_itemGetNI( pInfo->pNewVal ); + if( iVal > 0 && iVal != pWVT->CodePage ) + { + pWVT->CodePage = iVal; + if( pWVT->hWnd ) + hb_gt_wvt_ResetWindowSize( pWVT ); + } + break; + + case HB_GTI_ICONFILE: + { + if( ( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) ) + { + HICON hIconToFree = ( pWVT->hIcon && pWVT->bIconToFree ) ? pWVT->hIcon : NULL; + LPTSTR lpImage; + + lpImage = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); + pWVT->bIconToFree = TRUE; + pWVT->hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, lpImage, + IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + HB_TCHAR_FREE( lpImage ); + if( pWVT->hWnd ) + { + SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) pWVT->hIcon ); /* Set Title Bar Icon */ + SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) pWVT->hIcon ); /* Set Task List Icon */ + } + + if( hIconToFree ) + DestroyIcon( hIconToFree ); + } + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( HB_PTRDIFF ) pWVT->hIcon ); + break; + } + + case HB_GTI_ICONRES: + { + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + HICON hIconToFree = ( pWVT->hIcon && pWVT->bIconToFree ) ? pWVT->hIcon : NULL; + LPTSTR lpIcon; + + lpIcon = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) ); + pWVT->bIconToFree = FALSE; + pWVT->hIcon = LoadIcon( pWVT->hInstance, lpIcon ); + HB_TCHAR_FREE( lpIcon ); + + if( pWVT->hWnd ) + { + SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) pWVT->hIcon ); /* Set Title Bar Icon */ + SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) pWVT->hIcon ); /* Set Task List Icon */ + } + + if( hIconToFree ) + DestroyIcon( hIconToFree ); + } + else if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + HICON hIconToFree = ( pWVT->hIcon && pWVT->bIconToFree ) ? pWVT->hIcon : NULL; + + pWVT->bIconToFree = FALSE; + pWVT->hIcon = LoadIcon( pWVT->hInstance, + MAKEINTRESOURCE( ( HB_LONG ) + hb_itemGetNInt( pInfo->pNewVal ) ) ); + + if( pWVT->hWnd ) + { + SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_SMALL, ( LPARAM ) pWVT->hIcon ); /* Set Title Bar Icon */ + SendNotifyMessage( pWVT->hWnd, WM_SETICON, ICON_BIG , ( LPARAM ) pWVT->hIcon ); /* Set Task List Icon */ + } + + if( hIconToFree ) + DestroyIcon( hIconToFree ); + } + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( HB_PTRDIFF ) pWVT->hIcon ); + break; + } + + case HB_GTI_VIEWMAXWIDTH: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->COLS ); + break; + + case HB_GTI_VIEWMAXHEIGHT: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->ROWS ); + break; + + case HB_GTI_KBDSHIFTS: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, hb_gt_w32_getKbdState() ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + hb_gt_w32_setKbdState( hb_itemGetNI( pInfo->pNewVal ) ); + break; + + case HB_GTI_CLIPBOARDDATA: + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + hb_gt_w32_setClipboard( pWVT->CodePage == OEM_CHARSET ? + CF_OEMTEXT : CF_TEXT, + hb_itemGetCPtr( pInfo->pNewVal ), + hb_itemGetCLen( pInfo->pNewVal ) ); + } + else + { + char * szClipboardData; + ULONG ulLen; + if( hb_gt_w32_getClipboard( pWVT->CodePage == OEM_CHARSET ? + CF_OEMTEXT : CF_TEXT, + &szClipboardData, &ulLen ) ) + { + pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, + szClipboardData, + ulLen ); + } + else + { + pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL ); + } + } + break; + + case HB_GTI_CURSORBLINKRATE: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, GetCaretBlinkTime() ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + SetCaretBlinkTime( hb_itemGetNI( pInfo->pNewVal ) ); + break; + + case HB_GTI_SCREENSIZE: + { + int iX, iY; + + if( !pInfo->pResult ) + { + pInfo->pResult = hb_itemNew( NULL ); + } + hb_arrayNew( pInfo->pResult, 2 ); + hb_arraySetNI( pInfo->pResult, 2, pWVT->PTEXTSIZE.y * pWVT->ROWS ); + hb_arraySetNI( pInfo->pResult, 1, pWVT->PTEXTSIZE.x * pWVT->COLS ); + iY = hb_arrayGetNI( pInfo->pNewVal,2 ); + iX = hb_arrayGetNI( pInfo->pNewVal,1 ); + + if( iY > 0 ) + { + BOOL bOldCentre = pWVT->CentreWindow; + pWVT->CentreWindow = pWVT->bMaximized ? TRUE : FALSE; + HB_GTSELF_SETMODE( pGT, ( USHORT ) ( iY / pWVT->PTEXTSIZE.y ), ( USHORT ) ( iX / pWVT->PTEXTSIZE.x ) ); + pWVT->CentreWindow = bOldCentre; + } + break; + } + case HB_GTI_RESIZABLE: + pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->bResizable ); + if( pInfo->pNewVal ) + { + BOOL bNewValue = hb_itemGetL( pInfo->pNewVal ); + if( bNewValue != pWVT->bResizable ) + { + pWVT->bResizable = bNewValue; + if( pWVT->hWnd ) + { +#if (defined(_MSC_VER) && (_MSC_VER <= 1200 || defined(HB_WINCE)) || defined(__DMC__)) && !defined(HB_ARCH_64BIT) + LONG style; +#else + LONG_PTR style; +#endif + if( pWVT->bResizable ) + style = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_MAXIMIZEBOX|WS_THICKFRAME; + else + style = WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_BORDER; + +#if (defined(_MSC_VER) && (_MSC_VER <= 1200 || defined(HB_WINCE)) || defined(__DMC__)) && !defined(HB_ARCH_64BIT) + SetWindowLong( pWVT->hWnd, GWL_STYLE, style ); +#else + SetWindowLongPtr( pWVT->hWnd, GWL_STYLE, style ); +#endif + SetWindowPos( pWVT->hWnd, NULL, 0, 0, 0, 0, + SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_DEFERERASE ); + ShowWindow( pWVT->hWnd, SW_HIDE ); + ShowWindow( pWVT->hWnd, SW_NORMAL ); + } + } + } + break; + + case HB_GTI_CLOSABLE: + pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->bClosable ); + if( pInfo->pNewVal ) + { + BOOL bNewValue = hb_itemGetL( pInfo->pNewVal ); + if( bNewValue != pWVT->bClosable ) + { + if( pWVT->hWnd ) + { + HMENU hSysMenu = GetSystemMenu( pWVT->hWnd, FALSE ); + if( hSysMenu ) + { + EnableMenuItem( hSysMenu, SC_CLOSE, MF_BYCOMMAND | ( bNewValue ? MF_ENABLED : MF_GRAYED ) ); + pWVT->bClosable = bNewValue; + } + } + else + pWVT->bClosable = bNewValue; + } + } + break; + + case HB_GTI_SETPOS_XY: + case HB_GTI_SETPOS_ROWCOL: + if( pWVT->hWnd && ( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) && + ( hb_itemType( pInfo->pNewVal2 ) & HB_IT_NUMERIC ) ) + { + int x, y; + RECT rect = { 0,0,0,0 }; + GetWindowRect( pWVT->hWnd, &rect ); + + if( iType == HB_GTI_SETPOS_ROWCOL ) + { + y = hb_itemGetNI( pInfo->pNewVal ) * pWVT->PTEXTSIZE.y; + x = hb_itemGetNI( pInfo->pNewVal2 ) * pWVT->PTEXTSIZE.x; + } + else + { + x = hb_itemGetNI( pInfo->pNewVal ); + y = hb_itemGetNI( pInfo->pNewVal2 ); + } + hb_retl( SetWindowPos( pWVT->hWnd, NULL, + x, + y, + rect.right - rect.left, + rect.bottom - rect.top, + SWP_NOSIZE | SWP_NOZORDER ) ); + } + break; + + case HB_GTI_SPEC: + { + int iMessage = hb_itemGetNI( pInfo->pNewVal ); + switch( iMessage ) + { + case HB_GTS_WINDOWHANDLE: + if( pWVT->hWnd ) + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, ( HB_PTRDIFF ) pWVT->hWnd ); + break; + + case HB_GTS_CENTERWINDOW: + { + pInfo->pResult = hb_itemPutL( pInfo->pResult, pWVT->CentreWindow ); + if( pInfo->pNewVal2 ) + { + pWVT->CentreWindow = hb_arrayGetL( pInfo->pNewVal2, 1 ); + if( hb_arrayGetL( pInfo->pNewVal2, 2 ) ) + { + if( pWVT->hWnd ) + hb_gt_wvt_ResetWindowSize( pWVT ); + } + } + break; + } + case HB_GTS_PROCESSMESSAGES: + if( pWVT->hWnd ) + hb_gt_wvt_ProcessMessages( pWVT ); + break; + + case HB_GTS_KEYBOARD: + if( hb_itemType( pInfo->pNewVal2 ) & HB_IT_NUMERIC ) + hb_gt_wvt_AddCharToInputQueue( pWVT, hb_itemGetNI( pInfo->pNewVal2 ) ); + break; + + case HB_GTS_RESETWINDOW: + if( pWVT->hWnd ) + hb_gt_wvt_ResetWindowSize( pWVT ); + break; + + case HB_GTS_SETTIMER: + if( hb_itemType( pInfo->pNewVal2 ) & HB_IT_ARRAY ) + SetTimer( pWVT->hWnd, hb_arrayGetNI( pInfo->pNewVal2, 1 ), hb_arrayGetNI( pInfo->pNewVal2, 2 ), NULL ); + break; + + case HB_GTS_KILLTIMER: + if( pWVT->hWnd ) + { + if( hb_itemType( pInfo->pNewVal2 ) & HB_IT_NUMERIC ) + KillTimer( pWVT->hWnd, hb_itemGetNI( pInfo->pNewVal2 ) ); + } + break; + + case HB_GTS_SETPOSITION: + { + if( pWVT->hWnd && ( hb_itemType( pInfo->pNewVal2 ) & HB_IT_ARRAY ) ) + { + RECT rect = { 0,0,0,0 }; + GetWindowRect( pWVT->hWnd, &rect ); + hb_retl( SetWindowPos( pWVT->hWnd, NULL, + hb_arrayGetNI( pInfo->pNewVal2, 1 ), + hb_arrayGetNI( pInfo->pNewVal2, 2 ), + rect.right - rect.left, + rect.bottom - rect.top, + SWP_NOSIZE + SWP_NOZORDER ) ); + } + break; + } + case HB_GTS_SHOWWINDOW: + if( pWVT->hWnd ) + { + if( hb_itemType( pInfo->pNewVal2 ) & HB_IT_NUMERIC ) + ShowWindow( pWVT->hWnd, hb_itemGetNI( pInfo->pNewVal2 ) ); + } + break; + + case HB_GTS_UPDATEWINDOW: + if( pWVT->hWnd ) + UpdateWindow( pWVT->hWnd ); + break; + + case HB_GTS_SYSTRAYICON: + { + if( pWVT->hWnd && ( hb_itemType( pInfo->pNewVal2 ) & HB_IT_ARRAY ) ) + { + int mode = hb_arrayGetNI( pInfo->pNewVal2, 1 ); + int iIconType = hb_arrayGetNI( pInfo->pNewVal2, 2 ); + HICON hIcon = 0; + NOTIFYICONDATA tnid ; + + if( iIconType == 0 ) + { + LPTSTR lpImage = HB_TCHAR_CONVTO( hb_arrayGetCPtr( pInfo->pNewVal2, 3 ) ); + hIcon = ( HICON ) LoadImage( ( HINSTANCE ) NULL, lpImage, + IMAGE_ICON, 0, 0, LR_LOADFROMFILE ); + HB_TCHAR_FREE( lpImage ); + } + else if( iIconType == 1 ) + { + LPTSTR lpIcon = HB_TCHAR_CONVTO( hb_arrayGetCPtr( pInfo->pNewVal2, 3 ) ); + hIcon = LoadIcon( pWVT->hInstance, lpIcon ); + HB_TCHAR_FREE( lpIcon ); + } + else if( iIconType == 2 ) + { + hIcon = LoadIcon( pWVT->hInstance, + MAKEINTRESOURCE( ( HB_LONG ) + hb_arrayGetNInt( pInfo->pNewVal2, 3 ) ) ); + } + tnid.cbSize = sizeof( NOTIFYICONDATA ) ; + tnid.hWnd = pWVT->hWnd; + tnid.uID = HB_ID_NOTIFYICON; + tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; + tnid.uCallbackMessage = HB_MSG_NOTIFYICON; + tnid.hIcon = hIcon ; + + HB_TCHAR_CPTO( tnid.szTip, hb_arrayGetCPtr( pInfo->pNewVal2, 4 ), sizeof( tnid.szTip ) - 1 ); + + Shell_NotifyIcon( mode, &tnid ) ; + + if( hIcon ) + DestroyIcon( hIcon ); + + ShowWindow( pWVT->hWnd, SW_HIDE ); + } + break; + } + + case HB_GTS_WNDSTATE: + { + if( pWVT->hWnd ) + { + int iSpec = hb_itemGetNI( pInfo->pNewVal2 ); + + switch( iSpec ) + { + case HB_GTS_WS_SETONTOP: + { + RECT rect = { 0,0,0,0 }; + GetWindowRect( pWVT->hWnd, &rect ); + hb_retl( SetWindowPos( pWVT->hWnd, HWND_TOPMOST, + rect.left, + rect.top, + 0, + 0, + SWP_NOSIZE + SWP_NOMOVE + SWP_NOACTIVATE ) ); + break; + } + case HB_GTS_WS_SETASNORMAL: + { + RECT rect = { 0,0,0,0 }; + GetWindowRect( pWVT->hWnd, &rect ); + hb_retl( SetWindowPos( pWVT->hWnd, HWND_NOTOPMOST, + rect.left, + rect.top, + 0, + 0, + SWP_NOSIZE + SWP_NOMOVE + SWP_NOACTIVATE ) ); + break; + } + + case HB_GTS_WS_MINIMIZED: + SendNotifyMessage( pWVT->hWnd, WM_SYSCOMMAND, SC_MINIMIZE, 0 ); + break; + + case HB_GTS_WS_MAXIMIZED: + if( pWVT->bResizable ) + SendNotifyMessage( pWVT->hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 ); + else + ShowWindow( pWVT->hWnd, SW_RESTORE ); + break; + + case HB_GTS_WS_HIDDEN: + ShowWindow( pWVT->hWnd, SW_HIDE ); + break; + + case HB_GTS_WS_NORMAL: + ShowWindow( pWVT->hWnd, SW_SHOWNORMAL ); + break; + } + } + break; + } + case HB_GTS_FACTOR: + { + if( pWVT->hWnd ) + { +#if ( _WIN32_WINNT >= 0x0500 ) + if ( pWVT->pfnLayered ) + { + SetWindowLong( pWVT->hWnd, + GWL_EXSTYLE, + GetWindowLong( pWVT->hWnd, GWL_EXSTYLE ) | WS_EX_LAYERED ); + + pWVT->pfnLayered( pWVT->hWnd, + RGB( 255,255,255 ), + hb_itemGetNI( pInfo->pNewVal2 ), + /*LWA_COLORKEY|*/ LWA_ALPHA ); + } +#endif + } + break; + } + } + break; + } + case HB_GTI_PRESPARAMS: + if ( ! pWVT->hWnd ) + { + if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY ) + { + int iParam = hb_arrayLen( pInfo->pNewVal ); + if( iParam == HB_GTI_PP_SIZE ) + { + PHB_ITEM pSome; + + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_EXSTYLE ); + if( hb_itemType( pSome ) & HB_IT_NUMERIC ) + { + pWVT->pPP->exStyle = hb_itemGetNInt( pSome ); + } + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_STYLE ); + if( hb_itemType( pSome ) & HB_IT_NUMERIC ) + { + pWVT->pPP->style = hb_itemGetNInt( pSome ); + } + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_X ); + if( hb_itemType( pSome ) & HB_IT_NUMERIC ) + { + pWVT->pPP->x = hb_itemGetNInt( pSome ); + } + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_Y ); + if( hb_itemType( pSome ) & HB_IT_NUMERIC ) + { + pWVT->pPP->y = hb_itemGetNInt( pSome ); + } + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_WIDTH ); + if( hb_itemType( pSome ) & HB_IT_NUMERIC ) + { + pWVT->pPP->width = hb_itemGetNInt( pSome ); + } + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_HEIGHT ); + if( hb_itemType( pSome ) & HB_IT_NUMERIC ) + { + pWVT->pPP->height = hb_itemGetNInt( pSome ); + } + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_PARENT ); + if( hb_itemType( pSome ) & HB_IT_POINTER ) + { + pWVT->pPP->pParentGT = hb_itemNew( hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_PARENT ) ); + } + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_VISIBLE ); + if( hb_itemType( pSome ) & HB_IT_LOGICAL ) + { + pWVT->pPP->bVisible = hb_itemGetL( pSome ); + } + pSome = hb_arrayGetItemPtr( pInfo->pNewVal, HB_GTI_PP_ROWCOLS ); + if( hb_itemType( pSome ) & HB_IT_LOGICAL ) + { + pWVT->pPP->bRowCols = hb_itemGetL( pSome ); + } + + /* Flag that caller configured itself */ + pWVT->pPP->bConfigured = TRUE; + pWVT->CentreWindow = FALSE; + } + } + } + break; + + case HB_GTI_ENABLE: + { + PHB_GT pGTp = hb_gt_ItemBase( pInfo->pNewVal ); + if( pGTp ) + { + PHB_GTWVT pWVTp = HB_GTWVT_GET( pGTp ); + EnableWindow( pWVTp->hWnd, TRUE ); + hb_gt_BaseFree( pGTp ); + } + break; + } + case HB_GTI_DISABLE: + { + PHB_GT pGTp = hb_gt_ItemBase( pInfo->pNewVal ); + if( pGTp ) + { + PHB_GTWVT pWVTp = HB_GTWVT_GET( pGTp ); + EnableWindow( pWVTp->hWnd, FALSE ); + hb_gt_BaseFree( pGTp ); + } + break; + } + case HB_GTI_SETFOCUS: + { + PHB_GT pGTp = hb_gt_ItemBase( pInfo->pNewVal ); + if( pGTp ) + { + PHB_GTWVT pWVTp = HB_GTWVT_GET( pGTp ); + SetFocus( pWVTp->hWnd ); + hb_gt_BaseFree( pGTp ); + } + break; + } + + default: + return HB_GTSUPER_INFO( pGT, iType, pInfo ); + } + + return TRUE; +} + +/* ********************************************************************** */ + +static void hb_gt_wvt_Redraw( PHB_GT pGT, int iRow, int iCol, int iSize ) +{ + PHB_GTWVT pWVT; + + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_wvt_Redraw(%p,%d,%d,%d)", pGT, iRow, iCol, iSize ) ); + + pWVT = HB_GTWVT_GET( pGT ); + if( pWVT ) + { + if( pWVT->hWnd ) + { + RECT rect; + + rect.top = rect.bottom = ( SHORT ) iRow; + rect.left = ( SHORT ) iCol; + rect.right = ( SHORT ) ( iCol + iSize - 1 ); + + rect = hb_gt_wvt_GetXYFromColRowRect( pWVT, rect ); + + InvalidateRect( pWVT->hWnd, &rect, FALSE ); + } + else + pWVT->fInit = TRUE; + } +} + +/* ********************************************************************** */ + +static void hb_gt_wvt_Refresh( PHB_GT pGT ) +{ + PHB_GTWVT pWVT; + + HB_TRACE( HB_TR_DEBUG, ("hb_gt_wvt_Refresh(%p)", pGT) ); + + HB_GTSUPER_REFRESH( pGT ); + + pWVT = HB_GTWVT_GET( pGT ); + if( pWVT ) + { + if( !pWVT->hWnd && pWVT->fInit ) + hb_gt_wvt_CreateConsoleWindow( pWVT ); + + if( pWVT->hWnd ) + { + hb_gt_wvt_ProcessMessages( pWVT ); + } + } +} + +/* ********************************************************************** */ + +static BOOL hb_gt_wvt_SetDispCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP, BOOL fBox ) +{ + HB_GTSUPER_SETDISPCP( pGT, pszTermCDP, pszHostCDP, fBox ); + +#ifndef HB_CDP_SUPPORT_OFF + +#if defined( UNICODE ) + /* + * We are displaying text in U16 so pszTermCDP is unimportant. + * We only have to know what is the internal application codepage + * to make proper translation + */ + if( !pszHostCDP || !*pszHostCDP ) + pszHostCDP = hb_cdpID(); + + if( pszHostCDP && *pszHostCDP ) + { + PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP ); + if( cdpHost ) + HB_GTWVT_GET( pGT )->hostCDP = cdpHost; + } + +#else + + if( !pszHostCDP ) + pszHostCDP = hb_cdpID(); + if( !pszTermCDP ) + pszTermCDP = pszHostCDP; + + if( pszTermCDP && pszHostCDP ) + { + PHB_GTWVT pWVT = HB_GTWVT_GET( pGT ); + PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), + cdpHost = hb_cdpFind( pszHostCDP ); + int i; + + for( i = 0; i < 256; ++i ) + pWVT->chrTransTbl[ i ] = ( BYTE ) i; + + if( cdpTerm && cdpHost && cdpTerm != cdpHost && + cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) + { + for( i = 0; i < cdpHost->nChars; ++i ) + { + pWVT->chrTransTbl[ ( BYTE ) cdpHost->CharsUpper[ i ] ] = + ( BYTE ) cdpTerm->CharsUpper[ i ]; + pWVT->chrTransTbl[ ( BYTE ) cdpHost->CharsLower[ i ] ] = + ( BYTE ) cdpTerm->CharsLower[ i ]; + } + } + } + +#endif + +#endif + + return TRUE; +} + +static BOOL hb_gt_wvt_SetKeyCP( PHB_GT pGT, const char * pszTermCDP, const char * pszHostCDP ) +{ + HB_GTSUPER_SETKEYCP( pGT, pszTermCDP, pszHostCDP ); + +#ifndef HB_CDP_SUPPORT_OFF + +#if defined( UNICODE ) + /* + * We are receiving WM_CHAR events in U16 so pszTermCDP is unimportant. + * We only have to know what is the internal application codepage + * to make proper translation + */ + if( !pszHostCDP || !*pszHostCDP ) + pszHostCDP = hb_cdpID(); + + if( pszHostCDP && *pszHostCDP ) + { + PHB_CODEPAGE cdpHost = hb_cdpFind( pszHostCDP ); + if( cdpHost ) + HB_GTWVT_GET( pGT )->inCDP = cdpHost; + } + +#else + + if( !pszHostCDP ) + pszHostCDP = hb_cdpID(); + if( !pszTermCDP ) + pszTermCDP = pszHostCDP; + + if( pszTermCDP && pszHostCDP ) + { + PHB_GTWVT pWVT = HB_GTWVT_GET( pGT ); + PHB_CODEPAGE cdpTerm = hb_cdpFind( pszTermCDP ), + cdpHost = hb_cdpFind( pszHostCDP ); + int i; + + for( i = 0; i < 256; ++i ) + pWVT->keyTransTbl[ i ] = ( BYTE ) i; + + if( cdpTerm && cdpHost && cdpTerm != cdpHost && + cdpTerm->nChars && cdpTerm->nChars == cdpHost->nChars ) + { + for( i = 0; i < cdpHost->nChars; ++i ) + { + pWVT->keyTransTbl[ ( BYTE ) cdpTerm->CharsUpper[ i ] ] = + ( BYTE ) cdpHost->CharsUpper[ i ]; + pWVT->keyTransTbl[ ( BYTE ) cdpTerm->CharsLower[ i ] ] = + ( BYTE ) cdpHost->CharsLower[ i ]; + } + } + + pWVT->inCDP = cdpTerm; + } +#endif + +#endif + + return TRUE; +} + + +/* ********************************************************************** */ + +static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_FuncInit(%p)", pFuncTable)); + + pFuncTable->Init = hb_gt_wvt_Init; + pFuncTable->Exit = hb_gt_wvt_Exit; + pFuncTable->SetMode = hb_gt_wvt_SetMode; + pFuncTable->Redraw = hb_gt_wvt_Redraw; + pFuncTable->Refresh = hb_gt_wvt_Refresh; + pFuncTable->Version = hb_gt_wvt_Version; + pFuncTable->Tone = hb_gt_wvt_Tone; + pFuncTable->Info = hb_gt_wvt_Info; + pFuncTable->SetDispCP = hb_gt_wvt_SetDispCP; + pFuncTable->SetKeyCP = hb_gt_wvt_SetKeyCP; + + pFuncTable->PutChar = hb_gt_wvt_PutChar; + + pFuncTable->ReadKey = hb_gt_wvt_ReadKey; + + pFuncTable->MouseIsPresent = hb_gt_wvt_mouse_IsPresent; + pFuncTable->MouseGetPos = hb_gt_wvt_mouse_GetPos; + pFuncTable->MouseButtonState = hb_gt_wvt_mouse_ButtonState; + pFuncTable->MouseCountButton = hb_gt_wvt_mouse_CountButton; + + return TRUE; +} + +/* ********************************************************************** */ + +static const HB_GT_INIT gtInit = { HB_GT_DRVNAME( HB_GT_NAME ), + hb_gt_FuncInit, + HB_GTSUPER, + HB_GTID_PTR }; + +HB_GT_ANNOUNCE( HB_GT_NAME ) + +HB_CALL_ON_STARTUP_BEGIN( _hb_startup_gt_Init_ ) + hb_gtRegister( >Init ); +HB_CALL_ON_STARTUP_END( _hb_startup_gt_Init_ ) + +#if defined( HB_PRAGMA_STARTUP ) + #pragma startup _hb_startup_gt_Init_ +#elif defined( HB_MSC_STARTUP ) + #if defined( HB_OS_WIN_64 ) + #pragma section( HB_MSC_START_SEGMENT, long, read ) + #endif + #pragma data_seg( HB_MSC_START_SEGMENT ) + static HB_$INITSYM hb_vm_auto__hb_startup_gt_Init_ = _hb_startup_gt_Init_; + #pragma data_seg() +#endif + +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +//----------------------------------------------------------------------// +#if 0 +/* NOTE: User programs should never call this layer directly! */ + +#define HB_GT_NAME GUI + +#define HB_OS_WIN_32_USED +#include "hbgtcore.h" +#include "hbinit.h" +#include "hbapiitm.h" + +/* *********************************************************************** */ + +static int s_GtId; +static HB_GT_FUNCS SuperTable; +#define HB_GTSUPER (&SuperTable) +#define HB_GTID_PTR (&s_GtId) + +/* *********************************************************************** */ + +static const char * hb_gt_gui_Version( PHB_GT pGT, int iType ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_gui_Version(%p,%d)", pGT, iType ) ); + + HB_SYMBOL_UNUSED( pGT ); + + if ( iType == 0 ) + return HB_GT_DRVNAME( HB_GT_NAME ); + + return "Harbour Terminal: Windows dummy console for GUI programs"; +} + +/* *********************************************************************** */ +/* dDuration is in 'Ticks' (18.2 per second) */ +static void hb_gt_gui_Tone( PHB_GT pGT, double dFrequency, double dDuration ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_gui_Tone(%p,%lf,%lf)", pGT, dFrequency, dDuration)); + +#if defined( HB_OS_WIN_32 ) + HB_SYMBOL_UNUSED( pGT ); + hb_gt_w32_tone( dFrequency, dDuration ); +#else + HB_GTSUPER_TONE( pGT, dFrequency, dDuration ); +#endif +} + +/* *********************************************************************** */ + +static BOOL hb_gt_gui_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) +{ + HB_TRACE( HB_TR_DEBUG, ( "hb_gt_gui_Info(%p,%d,%p)", pGT, iType, pInfo ) ); + + switch( iType ) + { +#if defined( HB_OS_WIN_32 ) + case HB_GTI_CLIPBOARDDATA: + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + { + hb_gt_w32_setClipboard( CF_TEXT, hb_itemGetCPtr( pInfo->pNewVal ), + hb_itemGetCLen( pInfo->pNewVal ) ); + } + else + { + char * szClipboardData; + ULONG ulLen; + + if( hb_gt_w32_getClipboard( CF_TEXT, &szClipboardData, &ulLen ) ) + { + pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, + szClipboardData, ulLen ); + } + else + { + pInfo->pResult = hb_itemPutC( pInfo->pResult, NULL ); + } + } + break; + + case HB_GTI_KBDSHIFTS: + pInfo->pResult = hb_itemPutNI( pInfo->pResult, hb_gt_w32_getKbdState() ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + hb_gt_w32_setKbdState( hb_itemGetNI( pInfo->pNewVal ) ); + break; +#endif + default: + return HB_GTSUPER_INFO( pGT, iType, pInfo ); + } + + return TRUE; +} + +/* *********************************************************************** */ + +static BOOL hb_gt_FuncInit( PHB_GT_FUNCS pFuncTable ) +{ + HB_TRACE(HB_TR_DEBUG, ("hb_gt_FuncInit(%p)", pFuncTable)); + + pFuncTable->Version = hb_gt_gui_Version; + pFuncTable->Tone = hb_gt_gui_Tone; + pFuncTable->Info = hb_gt_gui_Info; + + return TRUE; +} + +/* ********************************************************************** */ + +static const HB_GT_INIT gtInit = { HB_GT_DRVNAME( HB_GT_NAME ), + hb_gt_FuncInit, + HB_GTSUPER, + HB_GTID_PTR }; + +HB_GT_ANNOUNCE( HB_GT_NAME ) + +HB_CALL_ON_STARTUP_BEGIN( _hb_startup_gt_Init_ ) + hb_gtRegister( >Init ); +HB_CALL_ON_STARTUP_END( _hb_startup_gt_Init_ ) + +#if defined( HB_PRAGMA_STARTUP ) + #pragma startup _hb_startup_gt_Init_ +#elif defined( HB_MSC_STARTUP ) + #if defined( HB_OS_WIN_64 ) + #pragma section( HB_MSC_START_SEGMENT, long, read ) + #endif + #pragma data_seg( HB_MSC_START_SEGMENT ) + static HB_$INITSYM hb_vm_auto__hb_startup_gt_Init_ = _hb_startup_gt_Init_; + #pragma data_seg() +#endif +//----------------------------------------------------------------------// +#endif // GUI +//----------------------------------------------------------------------// +#endif +//----------------------------------------------------------------------// diff --git a/harbour/contrib/gtwvg/wvggui.h b/harbour/contrib/gtwvg/wvggui.h new file mode 100644 index 0000000000..b31dcc0f9e --- /dev/null +++ b/harbour/contrib/gtwvg/wvggui.h @@ -0,0 +1,474 @@ +/* + * $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_ + +#define HB_GT_NAME WGU + +//-------------------------------------------------------------------// + +#ifndef _WIN32_IE + #define _WIN32_IE 0x0400 +#endif + +#ifndef CINTERFACE + #define CINTERFACE 1 +#endif + +#define NONAMELESSUNION + +//-------------------------------------------------------------------// + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#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 "hbthread.h" +#include "hbgfxdef.ch" + +#include "hbgtwvg.ch" + +//----------------------------------------------------------------------// + +#define WVT_CHAR_QUEUE_SIZE 128 +#define WVT_MAX_TITLE_SIZE 128 +#define WVT_MAX_ROWS 256 +#define WVT_MAX_COLS 512 +#define WVT_MAX_WINDOWS 256 +#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 16 +# define WVT_DEFAULT_FONT_WIDTH 8 +#endif +#define WVT_DEFAULT_FONT_NAME "Courier New" + +#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 ) + +#define SYS_EV_MARK 1000 +#define HB_MSG_NOTIFYICON ( WM_USER+1399 ) +#define HB_ID_NOTIFYICON 99 + +//-------------------------------------------------------------------// +#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(__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 + + typedef struct _GRADIENT_RECT { + ULONG UpperLeft; + ULONG LowerRight; + } GRADIENT_RECT,*PGRADIENT_RECT,*LPGRADIENT_RECT; + + #ifndef TTM_SETTIPBKCOLOR + #define TTM_SETTIPBKCOLOR (WM_USER + 19) + #endif + #ifndef TTM_SETTIPTEXTCOLOR + #define TTM_SETTIPTEXTCOLOR (WM_USER + 20) + #endif + #ifndef TTM_GETTIPBKCOLOR + #define TTM_GETTIPBKCOLOR (WM_USER + 22) + #endif + #ifndef TTM_GETTIPTEXTCOLOR + #define TTM_GETTIPTEXTCOLOR (WM_USER + 23) + #endif + #ifndef TTM_SETMAXTIPWIDTH + #define TTM_SETMAXTIPWIDTH (WM_USER + 24) + #endif + #ifndef TTM_GETMAXTIPWIDTH + #define TTM_GETMAXTIPWIDTH (WM_USER + 25) + #endif + #ifndef TTM_SETMARGIN + #define TTM_SETMARGIN (WM_USER + 26) + #endif + +#endif + +#if defined( __cplusplus ) && ( defined( __BORLANDC__ ) || defined( _MSC_VER ) ) +# define HB_ID_REF( type, id ) id +#else +# define HB_ID_REF( type, id ) ( ( type ) &id ) +#endif + +#if defined(__BORLANDC__) +#if __BORLANDC__ == 0x0550 +#ifdef __cplusplus +extern "C" { STDAPI OleLoadPicture(LPSTREAM,LONG,BOOL,REFIID,PVOID*); } +#else +STDAPI OleLoadPicture(LPSTREAM,LONG,BOOL,REFIID,PVOID*); +#endif +#endif +#endif /* __BORLANDC__ */ + +//-------------------------------------------------------------------// + +typedef BOOL ( WINAPI *wvtGradientFill ) ( + HDC hdc, + PTRIVERTEX pVertex, + ULONG dwNumVertex, + PVOID pMesh, + ULONG dwNumMesh, + ULONG dwMode ); + +typedef BOOL ( WINAPI *wvtSetLayeredWindowAttributes )( + HWND hwnd, + COLORREF crKey, + BYTE bAlpha, + DWORD dwFlags ); + +//-------------------------------------------------------------------// + +typedef struct +{ + DWORD exStyle; + DWORD style; + int x; + int y; + int width; + int height; + PHB_ITEM pParentGT; + BOOL bVisible; + BOOL bRowCols; + BOOL bConfigured; + +} HB_GT_PARAMS, * PHB_GT_PARAMS; + +typedef struct +{ + HPEN penWhite; // White pen to draw GDI elements + HPEN penBlack; // Black pen to draw GDI elements + HPEN penWhiteDim; // White dim pen to draw GDI elements + HPEN penDarkGray; // Dark gray pen to draw GDI elements + HPEN penGray; // Gray pen equivilant to Clipper White + HPEN penNull; // Null pen + HPEN currentPen; // Handle to current pen settable at runtime + HBRUSH currentBrush; // Handle to current brush settable by runtime + HBRUSH diagonalBrush; // Handle to diaoganl brush to draw scrollbars + HBRUSH solidBrush; // Handle to solid brush + HBRUSH wvtWhiteBrush; // Wvt specific White colored brush + IPicture *iPicture[ WVT_PICTURES_MAX ]; // Array to hold the Picture Streams to avoid recurring loading and unloading + HFONT hUserFonts[ WVT_FONTS_MAX ] ; // User defined font handles + HPEN hUserPens[ WVT_PENS_MAX ]; // User defined pens + HINSTANCE hMSImg32; // Handle to the loaded library msimg32.dll + wvtGradientFill pfnGF; // Pointer to Address of the GradientFill function in MSImg32.dll + wvtSetLayeredWindowAttributes pfnLayered;// Pointer to set Windows attribute - transparency. + +} HB_GUIDATA, * PHB_GUIDATA; + +typedef struct +{ + PHB_GT pGT; /* core GT pointer */ + int iHandle; /* window number */ + + HINSTANCE hInstance; + int iCmdShow; + + USHORT ROWS; /* number of displayable rows in window */ + USHORT COLS; /* number of displayable columns in window */ + + POINT MousePos; /* the last mouse position */ + BOOL MouseMove; /* Flag to say whether to return mouse movement events */ + + 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 */ + int keyLast; /* last inkey code value in buffer */ + + 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 */ + int fontHeight; /* requested font height */ + int fontWidth; /* requested font width */ + int fontWeight; /* Bold level */ + int fontQuality; /* requested font quality */ + char fontFace[ LF_FACESIZE ]; /* requested font face name LF_FACESIZE #defined in wingdi.h */ + HFONT hFont; /* current font handle */ + + HWND hWnd; /* the window handle */ + BOOL fInit; /* logical variable indicating that window should be open */ + + PHB_CODEPAGE hostCDP; /* Host/HVM CodePage for unicode output translations */ + PHB_CODEPAGE inCDP; /* Host/HVM CodePage for unicode input translations */ +#if !defined(UNICODE) + BYTE keyTransTbl[ 256 ]; + BYTE chrTransTbl[ 256 ]; +#endif + + HICON hIcon; /* Title Bar and Task List icon. Can be NULL. */ + BOOL bIconToFree; /* Do we need to free this icon when it's not NULL? */ + + int CodePage; /* Code page to use for display characters */ + BOOL Win9X; /* Flag to say if running on Win9X not NT/2000/XP */ + BOOL AltF4Close; /* Can use Alt+F4 to close application */ + BOOL CentreWindow; /* True if window is to be Reset into centre of window */ + + BOOL IgnoreWM_SYSCHAR; + + BOOL bMaximized; /* Flag is set when window has been maximized */ + BOOL bResizable; + BOOL bClosable; + + // To Be Split in 2 Structures <1 GUI dynamic> <2 GUI fixed> // + + 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 + + int iFactor; // Transparency factor 0~255 + + HDC hdc; // Handle to Windows Device Context + HDC hCompDC; // Compatible DC to _s.hdc + + int LastMenuEvent; // Last menu item selected + int MenuKeyEvent; // User definable event number for windows menu command + BOOL InvalidateWindow; // Flag for controlling whether to use ScrollWindowEx() + BOOL EnableShortCuts; // Determines whether ALT key enables menu or system menu + + BOOL bPaint; + BOOL bGetFocus; + BOOL bSetFocus; + BOOL bKillFocus; + + PHB_DYNS pSymWVT_PAINT; // Stores pointer to WVT_PAINT function + PHB_DYNS pSymWVT_SETFOCUS; // Stores pointer to WVT_SETFOCUS function + PHB_DYNS pSymWVT_KILLFOCUS; // Stores pointer to WVT_KILLFOCUS function + PHB_DYNS pSymWVT_MOUSE; // Stores pointer to WVT_MOUSE function + PHB_DYNS pSymWVT_TIMER; // Stores pointer to WVT_TIMER function + PHB_DYNS pSymWVT_KEY; + + HINSTANCE hMSImg32; // Handle to the loaded library msimg32.dll + wvtGradientFill pfnGF; // Pointer to Address of the GradientFill function in MSImg32.dll + HINSTANCE hUser32; // Handle to the loaded library user32.dll + wvtSetLayeredWindowAttributes pfnLayered;// Pointer to set Windows attribute - transparency. + + PHB_GT_PARAMS pPP; // Presentation Parameters + + BOOL bTracking; // To track if mouse has eneter or left the window area + + BOOL bResizing; // To know when it is in resizing mode + +} HB_GTWVT, * PHB_GTWVT; + +//----------------------------------------------------------------------// + +#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 + +#ifndef GCLP_HCURSOR + #define GCLP_HCURSOR (-12) +#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; + +//----------------------------------------------------------------------// + +/* xHarbour compatible definitions */ +#if !defined( K_SH_LEFT ) +#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 + +#ifndef WM_MOUSEWHEEL +# define WM_MOUSEWHEEL 0x020A +#endif + +//----------------------------------------------------------------------// +void HB_EXPORT hb_ToOutDebug( const char * sTraceMsg, ... ); +//----------------------------------------------------------------------// +#if 0 +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 ); +#endif +#endif /* HB_WVT_H_ */