diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d82ea347fa..5f429c3d2b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,7 +17,18 @@ past entries belonging to these authors: Viktor Szakats. */ +2009-05-31 13:41 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/gtwvg/gtwvg.c + ! Some artifacts related with modal windows. + Now it correctly calculates the width/height and initial row/col position. + It now honors correctly parent GT's font size. + * harbour/contrib/gtwvg/wvgdatar.prg + * harbour/contrib/gtwvg/wvgscrlb.prg + * harbour/contrib/gtwvg/wvgtabpg.prg + * harbour/contrib/gtwvg/wvgwnd.prg + ! Numerics to Pointer fixes. + 2009-05-31 19:40 UTC+0200 Petr Chornyj (myorg63 at mail.ru) * harbour/include/std.ch ! fixed typo of last commit diff --git a/harbour/contrib/gtwvg/gtwvg.c b/harbour/contrib/gtwvg/gtwvg.c index 1cc7dd646d..06ad653cfb 100644 --- a/harbour/contrib/gtwvg/gtwvg.c +++ b/harbour/contrib/gtwvg/gtwvg.c @@ -2345,6 +2345,23 @@ static void hb_gt_wvt_ShowWindow( PHB_GTWVT pWVT ) ShowWindow( pWVT->hWnd, iCmdShow ); } +static void hb_gt_wvt_GetBorders( HWND hWnd, int * iBorderLeft, int * iTitlebarHeight, int * iDTWidth, int * iDTHeight ) +{ + RECT ci, wi; + int i; + + GetWindowRect( hWnd, &wi ); + GetClientRect( hWnd, &ci ); + + i = ( wi.right - wi.left - ( ci.right - ci.left ) ) / 2 ; + *iBorderLeft = i; + *iTitlebarHeight = ( ( wi.bottom - wi.top - ( ci.bottom - ci.top ) ) - i ); + + GetWindowRect( GetDesktopWindow(), &wi ); + *iDTWidth = wi.right - wi.left; + *iDTHeight = wi.bottom - wi.top; +} + static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT, BOOL bResizable ) { HWND hWnd, hWndParent; @@ -2426,8 +2443,32 @@ static HWND hb_gt_wvt_CreateWindow( PHB_GTWVT pWVT, BOOL bResizable ) ClientToScreen( hWndParent, &pt ); - pWVT->pPP->x = pt.x; - pWVT->pPP->y = pt.y; + { /* keep window within desktop but close to original position */ + int iBorderLeft, iTitlebarHeight, iDTWidth, iDTHeight, iWidth, iHeight; + + hb_gt_wvt_GetBorders( hWndParent, &iBorderLeft, &iTitlebarHeight, &iDTWidth, &iDTHeight ); + pWVT->pPP->x = pt.x; + pWVT->pPP->y = pt.y; + + if( pWVT->pPP->bRowCols ) + { + iWidth = ( iBorderLeft * 2 ) + ( pWVT->COLS * pWVT->PTEXTSIZE.x ) + ( iBorderLeft * 2 );; + iHeight = iTitlebarHeight + iBorderLeft + ( pWVT->ROWS * pWVT->PTEXTSIZE.y ) + iTitlebarHeight + iBorderLeft; + pWVT->pPP->width = iWidth; + pWVT->pPP->height = iHeight; + } + else + { + iWidth = pWVT->pPP->width; + iHeight = pWVT->pPP->height; + } + + if( ( pWVT->pPP->x + iWidth ) > iDTWidth ) + pWVT->pPP->x = HB_MAX( 0, iDTWidth - iWidth ); + + if( ( pWVT->pPP->y + iHeight ) > iDTHeight ) + pWVT->pPP->y = HB_MAX( 0, iDTHeight - iHeight ); + } bByConf = TRUE; } diff --git a/harbour/contrib/gtwvg/wvgdatar.prg b/harbour/contrib/gtwvg/wvgdatar.prg index 7145dbe54b..c7f3086fc4 100644 --- a/harbour/contrib/gtwvg/wvgdatar.prg +++ b/harbour/contrib/gtwvg/wvgdatar.prg @@ -165,7 +165,7 @@ METHOD setData( xValue, mp2 ) CLASS DataRef CASE ::className == "SCROLLBAR" IF ::sl_editBuffer <> NIL - WAPI_SetScrollPos( ::hWnd, SB_CTL, ::sl_editBuffer, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, ::sl_editBuffer, .t. ) ENDIF ENDCASE diff --git a/harbour/contrib/gtwvg/wvgscrlb.prg b/harbour/contrib/gtwvg/wvgscrlb.prg index 582d275fbe..ec32bcf660 100644 --- a/harbour/contrib/gtwvg/wvgscrlb.prg +++ b/harbour/contrib/gtwvg/wvgscrlb.prg @@ -188,7 +188,7 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgSc si IS SCROLLINFO si:cbSize := si:sizeof cSI := si:value - IF WAPI_GetScrollInfo( ::hWnd, SB_CTL, @cSI ) + IF WAPI_GetScrollInfo( ::pWnd, SB_CTL, @cSI ) si:buffer( cSI ) hb_ToOutDebug( "scrollinfo nMin=%i nMax=%i", si:nMin, si:nMax ) ENDIF @@ -219,57 +219,57 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgScrollBar IF nScrMsg == SB_THUMBPOSITION .or. nScrMsg == SB_THUMBTRACK nScrPos := aNM[ 2 ] ELSE - nScrPos := WAPI_GetScrollPos( ::hWnd, SB_CTL ) + nScrPos := WAPI_GetScrollPos( ::pWnd, SB_CTL ) ENDIF DO CASE CASE nScrMsg == SB_LEFT nCommand := WVGSB_PREVPOS IF nScrPos > ::range[ 1 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, --nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, --nScrPos, .t. ) ENDIF CASE nScrMsg == SB_RIGHT nCommand := WVGSB_NEXTPOS IF nScrPos < ::range[ 2 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, ++nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, ++nScrPos, .t. ) ENDIF CASE nScrMsg == SB_LINELEFT nCommand := WVGSB_PREVPAGE IF nScrPos > ::range[ 1 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, --nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, --nScrPos, .t. ) ENDIF CASE nScrMsg == SB_LINERIGHT nCommand := WVGSB_NEXTPAGE IF nScrPos < ::range[ 2 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, ++nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, ++nScrPos, .t. ) ENDIF CASE nScrMsg == SB_PAGELEFT nCommand := WVGSB_PREVPAGE IF nScrPos > ::range[ 1 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, --nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, --nScrPos, .t. ) ENDIF CASE nScrMsg == SB_PAGERIGHT nCommand := WVGSB_NEXTPAGE IF nScrPos < ::range[ 2 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, ++nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, ++nScrPos, .t. ) ENDIF CASE nScrMsg == SB_THUMBPOSITION nCommand := WVGSB_SLIDERTRACK - WAPI_SetScrollPos( ::hWnd, SB_CTL, nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, nScrPos, .t. ) CASE nScrMsg == SB_THUMBTRACK nCommand := WVGSB_ENDTRACK - WAPI_SetScrollPos( ::hWnd, SB_CTL, nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, nScrPos, .t. ) CASE nScrMsg == SB_ENDSCROLL nCommand := WVGSB_ENDSCROLL - WAPI_SetScrollPos( ::hWnd, SB_CTL, nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, nScrPos, .t. ) ENDCASE @@ -284,7 +284,7 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgScrollBar IF nScrMsg == SB_THUMBPOSITION .or. nScrMsg == SB_THUMBTRACK nScrPos := aNM[ 2 ] ELSE - nScrPos := WAPI_GetScrollPos( ::hWnd, SB_CTL ) + nScrPos := WAPI_GetScrollPos( ::pWnd, SB_CTL ) ENDIF IF !hb_isBlock( ::sl_xbeSB_Scroll ) @@ -295,50 +295,50 @@ METHOD handleEvent( nMessage, aNM ) CLASS WvgScrollBar CASE nScrMsg == SB_TOP nCommand := WVGSB_TOP IF nScrPos > ::range[ 1 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, --nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, --nScrPos, .t. ) ENDIF CASE nScrMsg == SB_BOTTOM nCommand := WVGSB_BOTTOM IF nScrPos < ::range[ 2 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, ++nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, ++nScrPos, .t. ) ENDIF CASE nScrMsg == SB_LINEUP nCommand := WVGSB_PREVPOS IF nScrPos > ::range[ 1 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, --nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, --nScrPos, .t. ) ENDIF CASE nScrMsg == SB_LINEDOWN nCommand := WVGSB_NEXTPOS IF nScrPos < ::range[ 2 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, ++nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, ++nScrPos, .t. ) ENDIF CASE nScrMsg == SB_PAGEUP nCommand := WVGSB_PREVPAGE IF nScrPos > ::range[ 1 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, --nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, --nScrPos, .t. ) ENDIF CASE nScrMsg == SB_PAGEDOWN nCommand := WVGSB_NEXTPAGE IF nScrPos < ::range[ 2 ] - WAPI_SetScrollPos( ::hWnd, SB_CTL, ++nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, ++nScrPos, .t. ) ENDIF CASE nScrMsg == SB_THUMBPOSITION nCommand := WVGSB_SLIDERTRACK - WAPI_SetScrollPos( ::hWnd, SB_CTL, nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, nScrPos, .t. ) CASE nScrMsg == SB_THUMBTRACK nCommand := WVGSB_ENDTRACK - WAPI_SetScrollPos( ::hWnd, SB_CTL, nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, nScrPos, .t. ) CASE nScrMsg == SB_ENDSCROLL nCommand := WVGSB_ENDSCROLL - WAPI_SetScrollPos( ::hWnd, SB_CTL, nScrPos, .t. ) + WAPI_SetScrollPos( ::pWnd, SB_CTL, nScrPos, .t. ) ENDCASE @@ -375,13 +375,13 @@ METHOD scroll( xParam ) CLASS WvgScrollBar METHOD setRange( aRange ) CLASS WvgScrollBar LOCAL aOldRange, nMin, nMax - IF WAPI_GetScrollRange( ::hWnd, SB_CTL, @nMin, @nMax ) + IF WAPI_GetScrollRange( ::pWnd, SB_CTL, @nMin, @nMax ) aOldRange := { nMin, nMax } ELSE aOldRange := ::range ENDIF - IF WAPI_SetScrollRange( ::hWnd, SB_CTL, aRange[ 1 ], aRange[ 2 ], .t. ) + IF WAPI_SetScrollRange( ::pWnd, SB_CTL, aRange[ 1 ], aRange[ 2 ], .t. ) ::range := aRange ENDIF diff --git a/harbour/contrib/gtwvg/wvgtabpg.prg b/harbour/contrib/gtwvg/wvgtabpg.prg index d8eba44bf8..c37b6587ba 100644 --- a/harbour/contrib/gtwvg/wvgtabpg.prg +++ b/harbour/contrib/gtwvg/wvgtabpg.prg @@ -142,7 +142,7 @@ METHOD create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) CLASS WvgTa DEFAULT ::caption TO " " - WAPI_TabCtrl_InsertItem( ::hWnd, 0, ::caption ) + WAPI_TabCtrl_InsertItem( ::pWnd, 0, ::caption ) IF ::visible ::show() diff --git a/harbour/contrib/gtwvg/wvgwnd.prg b/harbour/contrib/gtwvg/wvgwnd.prg index b72aecf76e..9d74e49d1f 100644 --- a/harbour/contrib/gtwvg/wvgwnd.prg +++ b/harbour/contrib/gtwvg/wvgwnd.prg @@ -350,7 +350,7 @@ METHOD destroy() CLASS WvgWindow ENDIF #ifdef __BYSETPROP__ - WVG_ReleaseWindowProcBlock( ::hWnd ) + WVG_ReleaseWindowProcBlock( ::pWnd ) #endif IF Win_IsWindow( ::hWnd ) @@ -1357,7 +1357,7 @@ METHOD ControlWndProc( hWnd, nMessage, nwParam, nlParam ) CLASS WvgWindow CASE WM_MOUSEHOVER IF ::objType == objTypeScrollBar IF ::oParent:objType == objTypeCrt - WAPI_SetFocus( ::oParent:hWnd ) + WAPI_SetFocus( ::oParent:pWnd ) ENDIF RETURN 0 ENDIF @@ -1367,7 +1367,7 @@ METHOD ControlWndProc( hWnd, nMessage, nwParam, nlParam ) CLASS WvgWindow IF ::objType == objTypeScrollBar ::lTracking := .f. IF ::oParent:objType == objTypeCrt - WAPI_SetFocus( ::oParent:hWnd ) + WAPI_SetFocus( ::oParent:pWnd ) ENDIF ENDIF EXIT