diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 2861e411ff..546b6bc7f3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,41 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-25 14:49 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/rtl/gtwvt/gtwvt.h + + Added member to HB_GTWVT + + * harbour/include/hbgtinfo.ch + + Added HB_GTI_RESIZEMODE + + Added HB_GTI_RESIZEMODE_FONT + + Added HB_GTI_RESIZEMODE_ROWS + + * harbour/include/inkey.ch + + Added K_HB_RESIZE 1101 + + * harbour/rtl/gtwvt/gtwvt.c + ! Updated to accomodate HB_GTI_RESIZEMODE. + + * harbour/rtl/hbgtcore.c + ! static BOOL hb_gt_def_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) + { + case HB_GTI_RESIZEMODE: + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, HB_GTI_RESIZEMODE_FONT ); + break; + + * harbour/tests/wvtext.prg + ! Updated to demonstrate K_HB_RESIZE event in navigation loop. + ; Odd numbered windows will have HB_GTI_RESIZEMODE_ROWS mode + Even numbered windows will have HB_GTI_RESIZEMODE_FONT mode. + Open two or more browsers to see the effects. + + ; To activate HB_GTI_RESIZEMODE_ROWS mode call + hb_gtInfo( HB_GTI_RESIZEMODE, HB_GTI_RESIZEMODE_ROWS ) + and whenever window will be resized you can retrieve it via + if inkey() == K_HB_RESIZE + // Reconfigure browser/your screen accordingly + endif + 2008-10-25 09:35 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/gtwvg/gtwvg.c * harbour/contrib/gtwvg/gtwvg.h diff --git a/harbour/include/hbgtinfo.ch b/harbour/include/hbgtinfo.ch index 3b67c00425..56e1fb9121 100644 --- a/harbour/include/hbgtinfo.ch +++ b/harbour/include/hbgtinfo.ch @@ -129,6 +129,8 @@ #define HB_GTI_SCREENSIZE 52 /* Get/Set height/width of application window in pixels */ #define HB_GTI_PALETTE 53 /* Get/Set console colors 1 - 16 given an array of 16 elements containing RGB colors */ +#define HB_GTI_RESIZEMODE 54 /* Get/Set console resize mode : HB_GTI_RESIZEMODE_FONT | HB_GTI_RESIZEMODE_ROWS */ + /* Font weights */ #define HB_GTI_FONTW_THIN 1 #define HB_GTI_FONTW_NORMAL 2 @@ -163,6 +165,11 @@ #define HB_GTE_CLOSE 4 #define HB_GTE_RESIZED 5 +/* Harbour GT Reszing mode constants */ +#define HB_GTI_RESIZEMODE_FONT 0 /* Default */ +#define HB_GTI_RESIZEMODE_ROWS 1 + + /* Compatibility #defines. These codes are deprecated, _don't use them_. Please upgrade to the above versions. For developers: Don't add any more new codes to this section. */ diff --git a/harbour/include/inkey.ch b/harbour/include/inkey.ch index 331a939fdd..ffb214680a 100644 --- a/harbour/include/inkey.ch +++ b/harbour/include/inkey.ch @@ -95,6 +95,7 @@ #define K_MINMOUSE 1001 #define K_MAXMOUSE 1016 +#define K_HB_RESIZE 1101 /* Harbour extension - this marks that multi-characters keycode will be returned - call INKEY() until ZERO will be returned diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 72aa966eb5..fd9764340a 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -289,6 +289,8 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT ) pWVT->bResizable = TRUE; pWVT->bClosable = TRUE; + pWVT->ResizeMode = HB_GTI_RESIZEMODE_FONT; + return pWVT; } @@ -527,6 +529,43 @@ static void hb_gt_wvt_ResetWindowSize( PHB_GTWVT pWVT ) HB_GTSELF_EXPOSEAREA( pWVT->pGT, 0, 0, pWVT->ROWS, pWVT->COLS ); } +static void hb_gt_wvt_FitRows( PHB_GTWVT pWVT ) +{ + RECT wi; + RECT ci; + int maxWidth; + int maxHeight; + int borderWidth; + int borderHeight; + + GetClientRect( pWVT->hWnd, &ci ); + GetWindowRect( pWVT->hWnd, &wi ); + + borderWidth = ( wi.right - wi.left - ( ci.right - ci.left ) ); + borderHeight = ( wi.bottom - wi.top - ( ci.bottom - ci.top ) ); + + if( pWVT->bMaximized ) + { + SystemParametersInfo( SPI_GETWORKAREA, 0, &wi, 0 ); + + maxHeight = wi.bottom - wi.top - borderHeight; + maxWidth = wi.right - wi.left - borderWidth; + } + else + { + maxWidth = ci.right - ci.left; + maxHeight = ci.bottom - ci.top; + } + + if ( maxHeight > 0 ) + { + BOOL bOldCentre = pWVT->CentreWindow; + pWVT->CentreWindow = pWVT->bMaximized ? TRUE : FALSE; + HB_GTSELF_SETMODE( pWVT->pGT, (USHORT) ( maxHeight / pWVT->PTEXTSIZE.y ), (USHORT) ( maxWidth / pWVT->PTEXTSIZE.x ) ); + pWVT->CentreWindow = bOldCentre; + } +} + static void hb_gt_wvt_FitSize( PHB_GTWVT pWVT ) { RECT wi; @@ -1523,7 +1562,13 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara return 0; case WM_SIZE: - hb_gt_wvt_FitSize( pWVT ); + if ( pWVT->ResizeMode == HB_GTI_RESIZEMODE_FONT ) + hb_gt_wvt_FitSize( pWVT ); + else + { + hb_gt_wvt_FitRows( pWVT ); + hb_gt_wvt_AddCharToInputQueue( pWVT, K_HB_RESIZE ); + } return 0; case WM_SYSCOMMAND: @@ -1532,8 +1577,16 @@ static LRESULT CALLBACK hb_gt_wvt_WndProc( HWND hWnd, UINT message, WPARAM wPara case SC_MAXIMIZE: { pWVT->bMaximized = TRUE; - - hb_gt_wvt_FitSize( pWVT ); + + if ( pWVT->ResizeMode == HB_GTI_RESIZEMODE_FONT ) + { + hb_gt_wvt_FitSize( pWVT ); + } + else + { + hb_gt_wvt_FitRows( pWVT ); + hb_gt_wvt_AddCharToInputQueue( pWVT, K_HB_RESIZE ); + } /* Disable "maximize" button */ #if (defined(_MSC_VER) && (_MSC_VER <= 1200 || defined(HB_WINCE)) || defined(__DMC__)) && !defined(HB_ARCH_64BIT) @@ -2344,6 +2397,15 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) } } break; + } + case HB_GTI_RESIZEMODE: + { + pInfo->pResult = hb_itemPutNI( pInfo->pResult, pWVT->ResizeMode ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) + { + pWVT->ResizeMode = hb_itemGetNI( pInfo->pNewVal ); + } + break; } default: return HB_GTSUPER_INFO( pGT, iType, pInfo ); diff --git a/harbour/source/rtl/gtwvt/gtwvt.h b/harbour/source/rtl/gtwvt/gtwvt.h index a5afaebddb..ecd78040a4 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.h +++ b/harbour/source/rtl/gtwvt/gtwvt.h @@ -170,6 +170,8 @@ typedef struct char * pszSelectCopy; BOOL bClosable; + int ResizeMode; /* Sets the resizing mode either to FONT or ROWS */ + } HB_GTWVT, * PHB_GTWVT; /* xHarbour compatible definitions */ diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index c3f448d7dd..5d9ad9ce45 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -1584,6 +1584,10 @@ static BOOL hb_gt_def_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) } break; + case HB_GTI_RESIZEMODE: + pInfo->pResult = hb_itemPutNInt( pInfo->pResult, HB_GTI_RESIZEMODE_FONT ); + break; + default: return FALSE; } diff --git a/harbour/tests/wvtext.prg b/harbour/tests/wvtext.prg index 8d603be41c..ee13af5525 100644 --- a/harbour/tests/wvtext.prg +++ b/harbour/tests/wvtext.prg @@ -215,13 +215,23 @@ FUNCTION RunInSysTray() //----------------------------------------------------------------------// PROCEDURE thFunc() - Local cTitle + Local cTitle, oBrowse, lEnd, nKey, i, aStruct Local aColor := { 'W+/N', 'W+/B', 'W+/G', 'W+/BG', 'W+/N*', 'W+/RB', 'N/W*', 'N/GR*' } + static nBrowser := 0 + nBrowser++ + /* allocate own GT driver */ hb_gtReload( 'WVT' ) Hb_GtInfo( HB_GTI_PALETTE, 8, RGB( 120, 200, 240 ) ) + if ( nBrowser % 2 ) != 0 + Hb_GtInfo( HB_GTI_RESIZEMODE, HB_GTI_RESIZEMODE_ROWS ) + endif + Hb_GtInfo( HB_GTI_WINTITLE, 'Test.dbf ['+if( ( nBrowser % 2 ) != 0, 'RESIZABLE_BY_ROWS', 'RESIZABLE_BY_FONT' )+']' ) + + SetCursor( 0 ) + nColorIndex++ if nColorIndex > len( aColor ) nColorIndex := 1 @@ -229,17 +239,172 @@ PROCEDURE thFunc() nRows++ nCols += 2 - cTitle := 'New Window with '+ltrim( str( nRows ) )+; - ' Rows and '+ltrim( str( nCols ) )+' Columns' SetMode( nRows,nCols ) SetColor( aColor[ nColorIndex ] ) Hb_GtInfo( HB_GTI_WINTITLE, cTitle ) + + cTitle := 'New Window with '+ltrim( str( MaxRow() ) )+; + ' Rows and '+ltrim( str( MaxCol() ) )+' Columns' DispOutAt( 0, 0, padc( cTitle, maxcol()+1 ), 'N/GR*' ) use test shared - browse() + aStruct := DbStruct() - return + oBrowse := TBrowse():New( 1, 0, maxrow(), maxcol() ) + oBrowse:ColSep := " ³ " + oBrowse:HeadSep := "ÄÂÄ" + oBrowse:GoTopBlock := { || dbGoTop() } + oBrowse:GoBottomBlock := { || dbGoBottom() } + oBrowse:SkipBlock := { | nSkip | dbSkipBlock( nSkip,oBrowse ) } + + for i := 1 to len( aStruct ) + oBrowse:AddColumn( TBColumnNew( aStruct[ i,1 ], BlockField( i ) ) ) + next + + oBrowse:configure() + + lEnd := .f. + While !lEnd + oBrowse:ForceStable() + + nKey := InKey( 0 ) + + if BrwHandleKey( oBrowse, nKey, @lEnd ) + // + else + if nKey == K_HB_RESIZE + cTitle := 'New Window with '+ltrim( str( MaxRow() ) )+; + ' Rows and '+ltrim( str( MaxCol() ) )+' Columns' + DispOutAt( 0, 0, padc( cTitle, maxcol()+1 ), 'N/GR*' ) + + oBrowse:nBottom := MaxRow() + oBrowse:nRight := MaxCol() + oBrowse:Configure() + oBrowse:RefreshAll() + endif + endif + end + + DbCloseArea() + + RETURN //----------------------------------------------------------------------// +STATIC FUNCTION DbSkipBlock( n, oTbr ) + + LOCAL nSkipped := 0 + + if n == 0 + DBSkip( 0 ) + + elseif n > 0 + do while nSkipped != n .and. TBNext( oTbr ) + nSkipped++ + enddo + else + do while nSkipped != n .and. TBPrev( oTbr ) + nSkipped-- + enddo + endif + + RETURN nSkipped +//-------------------------------------------------------------------// +STATIC FUNCTION TBNext( oTbr ) + + LOCAL nSaveRecNum := recno() + LOCAL lMoved := .T. + + if Eof() + lMoved := .F. + else + DBSkip( 1 ) + if Eof() + lMoved := .F. + DBGoTo( nSaveRecNum ) + endif + endif + + RETURN lMoved +//-------------------------------------------------------------------// +STATIC FUNCTION TBPrev( oTbr ) + LOCAL nSaveRecNum := Recno() + LOCAL lMoved := .T. + + DBSkip( -1 ) + + if Bof() + DBGoTo( nSaveRecNum ) + lMoved := .F. + endif + + RETURN lMoved +//-------------------------------------------------------------------// +STATIC FUNCTION BlockField( i ) + RETURN {|| fieldget( i ) } +//-------------------------------------------------------------------// +STATIC FUNCTION BrwHandleKey( oBrowse, nKey, lEnd ) + LOCAL lRet := .t. + + do case + case nKey == K_ESC + lEnd := .t. + + case nKey == K_ENTER + lEnd := .t. + + case nKey == K_DOWN + oBrowse:Down() + + case nKey == K_UP + oBrowse:Up() + + case nKey == K_LEFT + oBrowse:Left() + + case nKey == K_RIGHT + oBrowse:Right() + + case nKey == K_PGDN + oBrowse:pageDown() + + case nKey == K_PGUP + oBrowse:pageUp() + + case nKey == K_CTRL_PGUP + oBrowse:goTop() + + case nKey == K_CTRL_PGDN + oBrowse:goBottom() + + case nKey == K_HOME + oBrowse:home() + + case nKey == K_END + oBrowse:end() + + case nKey == K_CTRL_LEFT + oBrowse:panLeft() + + case nKey == K_CTRL_RIGHT + oBrowse:panRight() + + case nKey == K_CTRL_HOME + oBrowse:panHome() + + case nKey == K_CTRL_END + oBrowse:panEnd() + + case nKey == K_MWBACKWARD + oBrowse:down() + + case nKey == K_MWFORWARD + oBrowse:up() + + otherwise + lRet := .f. + + endcase + + RETURN lRet +//-------------------------------------------------------------------//