From 3ee9c2ff1c4833718f376ab3e7ba56dca809930d Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 9 Jun 2008 07:50:08 +0000 Subject: [PATCH] 2008-06-09 09:47 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * source/rtl/gtwvt/gtwvt.c ! Fixed most cases of trashing whilst marking. Maybe there is a simpler way of doing this... ! Readded "HB_NOSTARTUPWINDOW" feature deleted by mistake. ; TOFIX: Some trashing is still visible if switching directions relative to the starting corner. ; TOFIX: It doesn't seem to be possible to select the last row and the last column. Pritpal, could you take a look at it? --- harbour/ChangeLog | 11 +++ harbour/source/rtl/gtwvt/gtwvt.c | 119 +++++++++++++++++++++++-------- 2 files changed, 101 insertions(+), 29 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9cb03d2551..86b68b7212 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,17 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-09 09:47 UTC+0100 Viktor Szakats (harbour.01 syenar hu) + * source/rtl/gtwvt/gtwvt.c + ! Fixed most cases of trashing whilst marking. + Maybe there is a simpler way of doing this... + ! Readded "HB_NOSTARTUPWINDOW" feature deleted by mistake. + ; TOFIX: Some trashing is still visible if switching + directions relative to the starting corner. + ; TOFIX: It doesn't seem to be possible to select + the last row and the last column. Pritpal, + could you take a look at it? + 2008-06-09 07:36 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * tests/wvtext.prg * include/hbgtinfo.ch diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 5d60b4c22b..28b06a2779 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -870,9 +870,10 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L HDC hdc = GetDC( pWVT->hWnd ); RECT rectUpd; - int nOldSize = ( abs( s_rectOld.left - s_rectOld.right ) * abs( s_rectOld.top - s_rectOld.bottom ) ); - - if( nOldSize == 0 ) + if( s_rectOld.left == 0 && + s_rectOld.right == 0 && + s_rectOld.top == 0 && + s_rectOld.bottom == 0 ) { /* New selection */ @@ -883,41 +884,90 @@ static void hb_gt_wvt_MouseEvent( PHB_GTWVT pWVT, UINT message, WPARAM wParam, L InvertRect( hdc, &rect ); } - else if( ( abs( rect.left - rect.right ) * abs( rect.top - rect.bottom ) ) > nOldSize ) + else { - /* Selection grown */ + int nS = 0; + int nG = 0; - rectUpd.left = s_rectOld.right; - rectUpd.top = s_rectOld.top; - rectUpd.right = rect.right; - rectUpd.bottom = s_rectOld.bottom; + if( abs( rect.left - rect.right ) < abs( s_rectOld.left - s_rectOld.right ) ) + { + /* Selection shrunk horizontally */ + + rectUpd.left = rect.right; + rectUpd.top = rect.top; + rectUpd.right = s_rectOld.right; + rectUpd.bottom = s_rectOld.bottom; + + RedrawWindow( pWVT->hWnd, &rectUpd, NULL, RDW_INVALIDATE | RDW_UPDATENOW ); - InvertRect( hdc, &rectUpd ); + ++nS; + } - rectUpd.left = s_rectOld.left; - rectUpd.top = s_rectOld.bottom; - rectUpd.right = rect.right; - rectUpd.bottom = rect.bottom; + if( abs( rect.top - rect.bottom ) < abs( s_rectOld.top - s_rectOld.bottom ) ) + { + /* Selection shrunk vertically */ + + rectUpd.left = rect.left; + rectUpd.top = rect.bottom; + rectUpd.right = s_rectOld.right; + rectUpd.bottom = s_rectOld.bottom; + + RedrawWindow( pWVT->hWnd, &rectUpd, NULL, RDW_INVALIDATE | RDW_UPDATENOW ); - InvertRect( hdc, &rectUpd ); - } - else - { - /* Selection shrunk */ + ++nS; + } - rectUpd.left = rect.right; - rectUpd.top = rect.top; - rectUpd.right = s_rectOld.right; - rectUpd.bottom = rect.bottom; + if( nS == 2 ) + { + /* Selection shrunk horizontally + vertically */ + + rectUpd.left = rect.right; + rectUpd.top = rect.bottom; + rectUpd.right = s_rectOld.right; + rectUpd.bottom = s_rectOld.bottom; + + RedrawWindow( pWVT->hWnd, &rectUpd, NULL, RDW_INVALIDATE | RDW_UPDATENOW ); + } - RedrawWindow( pWVT->hWnd, &rectUpd, NULL, RDW_INVALIDATE | RDW_UPDATENOW ); + if( abs( rect.left - rect.right ) > abs( s_rectOld.left - s_rectOld.right ) ) + { + /* Selection grown horizontally */ + + rectUpd.left = s_rectOld.right; + rectUpd.top = s_rectOld.top; + rectUpd.right = rect.right; + rectUpd.bottom = nS ? rect.bottom : s_rectOld.bottom; + + InvertRect( hdc, &rectUpd ); - rectUpd.left = rect.left; - rectUpd.top = rect.bottom; - rectUpd.right = s_rectOld.right; - rectUpd.bottom = s_rectOld.bottom; + ++nG; + } - RedrawWindow( pWVT->hWnd, &rectUpd, NULL, RDW_INVALIDATE | RDW_UPDATENOW ); + if( abs( rect.top - rect.bottom ) > abs( s_rectOld.top - s_rectOld.bottom ) ) + { + /* Selection grown vertically */ + + rectUpd.left = s_rectOld.left; + rectUpd.top = s_rectOld.bottom; + rectUpd.right = nS ? rect.right : s_rectOld.right; + rectUpd.bottom = rect.bottom; + + InvertRect( hdc, &rectUpd ); + + ++nG; + } + + if( nG == 2 ) + { + /* Selection grown horizontally + vertically */ + + rectUpd.left = s_rectOld.right; + rectUpd.top = s_rectOld.bottom; + rectUpd.right = rect.right; + rectUpd.bottom = rect.bottom; + + InvertRect( hdc, &rectUpd ); + } } s_rectOld.left = rect.left; @@ -1593,6 +1643,17 @@ static HWND hb_gt_wvt_CreateWindow( HINSTANCE hInstance, HINSTANCE hPrevInstance return NULL; } + /* + * If you wish to show window the way you want, put somewhere in your application + * ANNOUNCE HB_NOSTARTUPWINDOW + * If so compiled, then you need to issue Wvt_ShowWindow( SW_RESTORE ) + * at the point you desire in your code. + */ + if( hb_dynsymFind( "HB_NOSTARTUPWINDOW" ) != NULL ) + { + iCmdShow = SW_HIDE; + } + ShowWindow( hWnd, iCmdShow ); UpdateWindow( hWnd );