diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 739cdc33b0..638f94580c 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,12 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-10-07 09:11 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/gtwvt/gtwvt.h + * harbour/source/rtl/gtwvt/gtwvt.c + * use dynamic line buffers - now WVT_MAX_{ROW,COL} macros can be + simply removed + 2009-10-07 08:09 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * config/global.mk * config/detect.mk diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 7d5fa190c1..40c6b4c696 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -236,6 +236,12 @@ static void hb_gt_wvt_Free( PHB_GTWVT pWVT ) if( pWVT->hIcon && pWVT->bIconToFree ) DestroyIcon( pWVT->hIcon ); + if( pWVT->TextLine ) + hb_xfree( pWVT->TextLine ); + + if( pWVT->FixedSize ) + hb_xfree( pWVT->FixedSize ); + hb_xfree( pWVT ); } @@ -263,6 +269,9 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->ROWS = WVT_DEFAULT_ROWS; pWVT->COLS = WVT_DEFAULT_COLS; + pWVT->TextLine = ( TCHAR * ) hb_xgrab( pWVT->COLS * sizeof( TCHAR ) ); + pWVT->FixedSize = ( int * ) hb_xgrab( pWVT->COLS * sizeof( int ) ); + pWVT->COLORS[ 0] = BLACK; pWVT->COLORS[ 1] = BLUE; pWVT->COLORS[ 2] = GREEN; @@ -897,12 +906,19 @@ static BOOL hb_gt_wvt_GetWindowTitle( HWND hWnd, char ** title ) return FALSE; } -static BOOL hb_gt_wvt_SetWindowSize( PHB_GTWVT pWVT, int iRow, int iCol ) +static BOOL hb_gt_wvt_SetWindowSize( PHB_GTWVT pWVT, int iRows, int iCols ) { - if( HB_GTSELF_RESIZE( pWVT->pGT, iRow, iCol ) ) + if( HB_GTSELF_RESIZE( pWVT->pGT, iRows, iCols ) ) { - pWVT->ROWS = iRow; - pWVT->COLS = iCol; + if( pWVT->COLS != iCols ) + { + pWVT->TextLine = ( TCHAR * ) hb_xrealloc( pWVT->TextLine, + iCols * sizeof( TCHAR ) ); + pWVT->FixedSize = ( int * ) hb_xrealloc( pWVT->FixedSize, + iCols * sizeof( int ) ); + } + pWVT->ROWS = iRows; + pWVT->COLS = iCols; return TRUE; } @@ -1539,7 +1555,6 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect ) HFONT hFont, hOldFont = NULL; #endif USHORT usChar; - TCHAR text[ WVT_MAX_COLS ]; hdc = BeginPaint( pWVT->hWnd, &ps ); #if defined( UNICODE ) @@ -1570,7 +1585,7 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect ) } else if( iColor != iOldColor ) { - hb_gt_wvt_TextOut( pWVT, hdc, startCol, iRow, iOldColor, text, ( UINT ) len ); + hb_gt_wvt_TextOut( pWVT, hdc, startCol, iRow, iOldColor, pWVT->TextLine, ( UINT ) len ); iOldColor = iColor; startCol = iCol; len = 0; @@ -1589,7 +1604,7 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect ) } else if( iColor != iOldColor || hFont != hOldFont ) { - hb_gt_wvt_TextOut( pWVT, hdc, startCol, iRow, iOldColor, text, ( UINT ) len ); + hb_gt_wvt_TextOut( pWVT, hdc, startCol, iRow, iOldColor, pWVT->TextLine, ( UINT ) len ); if( hFont != hOldFont ) { SelectObject( hdc, hFont ); @@ -1600,11 +1615,11 @@ static void hb_gt_wvt_PaintText( PHB_GTWVT pWVT, RECT updateRect ) len = 0; } #endif - text[ len++ ] = ( TCHAR ) usChar; + pWVT->TextLine[ len++ ] = ( TCHAR ) usChar; iCol++; } if( len > 0 ) - hb_gt_wvt_TextOut( pWVT, hdc, startCol, iRow, iOldColor, text, ( UINT ) len ); + hb_gt_wvt_TextOut( pWVT, hdc, startCol, iRow, iOldColor, pWVT->TextLine, ( UINT ) len ); } EndPaint( pWVT->hWnd, &ps ); diff --git a/harbour/source/rtl/gtwvt/gtwvt.h b/harbour/source/rtl/gtwvt/gtwvt.h index aa264b9e42..14b63376fe 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.h +++ b/harbour/source/rtl/gtwvt/gtwvt.h @@ -118,6 +118,8 @@ typedef struct int ROWS; /* number of displayable rows in window */ int COLS; /* number of displayable columns in window */ + TCHAR * TextLine; /* buffer for text line */ + COLORREF COLORS[ 16 ]; /* colors */ BOOL CaretExist; /* TRUE if a caret has been created */ @@ -135,7 +137,7 @@ typedef struct 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 * FixedSize; /* 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 */