From 8520cab552bdcda94312ffd569c1e823fde0ceef Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 12 Jun 2008 18:01:04 +0000 Subject: [PATCH] 2008-06-13 10:56 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/source/rtl/gtwvt/gtwvt.c * harbour/source/rtl/gtfunc.c * harbour/include/hbapigt.h + Added Palette implementation by color index. Hb_GtInfo( HB_GTI_PALETTE, nIndex[, nNewRGB ] ) -> nOldRGB * harbour/tests/wvtext.prg * Updated to demonstrate above functionality. --- harbour/ChangeLog | 10 ++++++++ harbour/include/hbapigt.h | 5 ++-- harbour/source/rtl/gtfunc.c | 9 +++---- harbour/source/rtl/gtwvt/gtwvt.c | 41 +++++++++++++++++++++----------- harbour/tests/wvtext.prg | 21 ++++++++++++---- 5 files changed, 62 insertions(+), 24 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 526252f632..9460fc3c65 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,16 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-06-13 10:56 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/source/rtl/gtwvt/gtwvt.c + * harbour/source/rtl/gtfunc.c + * harbour/include/hbapigt.h + + Added Palette implementation by color index. + Hb_GtInfo( HB_GTI_PALETTE, nIndex[, nNewRGB ] ) -> nOldRGB + + * harbour/tests/wvtext.prg + * Updated to demonstrate above functionality. + 2008-06-13 09:12 UTC+0800 Pritpal Bedi (pritpal@vouchcac.com * harbour/source/rtl/gtwvt/gtwvt.c * harbour/include/hbgtinfo.ch diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index 74966ddef1..300efca69e 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -130,6 +130,7 @@ typedef struct { PHB_ITEM pNewVal; PHB_ITEM pResult; + PHB_ITEM pNewVal2; } HB_GT_INFO, * PHB_GT_INFO; /* Public interface. These should never change, only be added to. */ @@ -201,7 +202,7 @@ extern HB_EXPORT ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iR extern HB_EXPORT ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, BYTE bColor ); extern HB_EXPORT int hb_gtGfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor ); extern HB_EXPORT ERRCODE hb_gtGfxText( int iTop, int iLeft, char * szText, int iColor, int iSize, int iWidth ); - + extern HB_EXPORT BOOL hb_mouseIsPresent( void ); extern HB_EXPORT BOOL hb_mouseGetCursor( void ); extern HB_EXPORT void hb_mouseSetCursor( BOOL bVisible ); @@ -251,7 +252,7 @@ extern HB_EXPORT void hb_gtWApp( HB_GT_WND ** wnd ); extern HB_EXPORT void hb_gtWCurrent( HB_GT_WND * wnd ); extern HB_EXPORT void hb_gtWPos( HB_GT_WND * wnd, HB_GT_RECT * rect ); extern HB_EXPORT BOOL hb_gtWVis( HB_GT_WND * wnd, USHORT uiStatus ); - + extern HB_EXPORT ERRCODE hb_gtSLR( HB_GT_SLR * pSLR ); /* System Level Request */ extern HB_EXPORT ERRCODE hb_gtModalRead( void * ); extern HB_EXPORT ERRCODE hb_gtFlushCursor( void ); diff --git a/harbour/source/rtl/gtfunc.c b/harbour/source/rtl/gtfunc.c index 49897797dd..78cc14a50f 100644 --- a/harbour/source/rtl/gtfunc.c +++ b/harbour/source/rtl/gtfunc.c @@ -100,8 +100,9 @@ HB_FUNC( HB_GTINFO ) { HB_GT_INFO gtInfo; - gtInfo.pNewVal = hb_param( 2, HB_IT_ANY ); - gtInfo.pResult = NULL; + gtInfo.pNewVal = hb_param( 2, HB_IT_ANY ); + gtInfo.pNewVal2 = hb_param( 3, HB_IT_ANY ); + gtInfo.pResult = NULL; hb_gtInfo( hb_parni( 1 ), >Info ); if( gtInfo.pResult ) @@ -118,7 +119,7 @@ HB_FUNC( HB_GTVERSION ) HB_FUNC( HB_GTALERT ) { - hb_retni( hb_gtAlert( hb_param( 1, HB_IT_ANY ), + hb_retni( hb_gtAlert( hb_param( 1, HB_IT_ANY ), hb_param( 2, HB_IT_ANY ), ISCHAR( 3 ) ? hb_gtColorToN( hb_parc( 3 ) ) : hb_parni( 3 ) /* iClrNorm */, ISCHAR( 4 ) ? hb_gtColorToN( hb_parc( 4 ) ) : hb_parni( 4 ) /* iClrHigh */, @@ -141,6 +142,6 @@ HB_FUNC( HB_GFXTEXT ) hb_parni( 2 ) /* nLeft */, hb_parc( 3 ) /* cText */, hb_parni( 4 ) /* nColor */, - hb_parni( 5 ) /* nSize */, + hb_parni( 5 ) /* nSize */, hb_parni( 6 ) /* nWidth */ ); } diff --git a/harbour/source/rtl/gtwvt/gtwvt.c b/harbour/source/rtl/gtwvt/gtwvt.c index 7f6901b735..855d8c6641 100644 --- a/harbour/source/rtl/gtwvt/gtwvt.c +++ b/harbour/source/rtl/gtwvt/gtwvt.c @@ -2219,22 +2219,35 @@ static BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) } case HB_GTI_PALETTE: { - int i; - - if( !pInfo->pResult ) + if( hb_itemType( pInfo->pNewVal ) & HB_IT_NUMERIC ) { - pInfo->pResult = hb_itemNew( NULL ); - } - hb_arrayNew( pInfo->pResult, 16 ); - for( i = 0; i < 16; i++ ) - hb_itemPutNL( hb_arrayGetItemPtr( pInfo->pResult,i ), pWVT->COLORS[ i ] ); - - if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY ) - { - if( hb_arrayLen( pInfo->pNewVal ) == 16 ) + int iIndex = hb_itemGetNI( pInfo->pNewVal ); + if( iIndex > 0 && iIndex <= 16 ) { - for( i = 0; i < 16; i++ ) - pWVT->COLORS[ i ] = hb_arrayGetNL( pInfo->pNewVal, i ); + pInfo->pResult = hb_itemPutNL( pInfo->pResult, pWVT->COLORS[ iIndex - 1 ] ); + + if( hb_itemType( pInfo->pNewVal2 ) & HB_IT_NUMERIC ) + pWVT->COLORS[ iIndex - 1 ] = hb_itemGetNL( pInfo->pNewVal2 ); + } + } + else + { + int i; + if( !pInfo->pResult ) + { + pInfo->pResult = hb_itemNew( NULL ); + } + hb_arrayNew( pInfo->pResult, 16 ); + for( i = 1; i <= 16; i++ ) + hb_itemPutNL( hb_arrayGetItemPtr( pInfo->pResult, i ), pWVT->COLORS[ i - 1 ] ); + + if( hb_itemType( pInfo->pNewVal ) & HB_IT_ARRAY ) + { + if( hb_arrayLen( pInfo->pNewVal ) == 16 ) + { + for( i = 0; i < 16; i++ ) + pWVT->COLORS[ i ] = hb_arrayGetNL( pInfo->pNewVal, i + 1 ); + } } } break; diff --git a/harbour/tests/wvtext.prg b/harbour/tests/wvtext.prg index 85275705f6..7f5405ac05 100644 --- a/harbour/tests/wvtext.prg +++ b/harbour/tests/wvtext.prg @@ -65,10 +65,13 @@ FUNCTION Main() hb_GtInfo( HB_GTI_CLOSABLE, !lClose ) CASE nKey == K_F5 - SetPallete( 1 ) + SetPalette( 1 ) CASE nKey == K_F6 - SetPallete( 0 ) + SetPalette( 0 ) + + CASE nKey == K_F7 + SetPaletteIndex() ENDCASE ENDDO @@ -118,6 +121,7 @@ STATIC FUNCTION DispScreen() DispOutAt( ++nRow, nCol, '< F4 Closable Toggle >', cColor ) DispOutAt( ++nRow, nCol, '< F5 Palette L Repeat >', cColor ) DispOutAt( ++nRow, nCol, '< F6 Palette D Repeat >', cColor ) + DispOutAt( ++nRow, nCol, '< F7 Palette By Index R >', cColor ) DispOutAt( ++nRow, nCol, '< Click Other Window >', cColor ) DispOutAt( ++nRow, nCol, '< Click X Button >', cColor ) @@ -145,7 +149,7 @@ PROCEDURE HB_GT_WVT_DEFAULT() //----------------------------------------------------------------------// -Function SetPallete( nMode ) +FUNCTION SetPalette( nMode ) Local aPalette := Hb_GtInfo( HB_GTI_PALETTE ) static nR := 198 @@ -158,10 +162,19 @@ Function SetPallete( nMode ) // Change 'W' to slightly gray everytime you press F5 // - aPalette[ 7 ] := RGB( nR, nG, nB ) + aPalette[ 8 ] := RGB( nR, nG, nB ) Hb_GtInfo( HB_GTI_PALETTE, aPalette ) DispScreen() RETURN NIL //----------------------------------------------------------------------// + +FUNCTION SetPaletteIndex() + + Hb_GtInfo( HB_GTI_PALETTE, 8, RGB( 120, 200, 240 ) ) + DispScreen() + + RETURN NIL + +//----------------------------------------------------------------------//