diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ea64848ac2..61b0f569ed 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,35 @@ 2008-12-31 13:59 UTC+0100 Foo Bar */ +2008-04-18 01:41 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbapigt.h + * harbour/source/rtl/gtapi.c + ! changed USHORT hb_gtColorToN( char * szColorString ) to + int hb_gtColorToN( char * szColorString ) - it should be the same + type as indexes in hb_gtColorsToString() functions + + * harbour/source/rtl/hbgtcore.c + * return -1 from COLORNUM() method when passed color is not + valid color string + + * harbour/contrib/hbct/screen2.c + * harbour/contrib/hbct/color.c + * harbour/contrib/hbct/screen1.c + * harbour/contrib/hbct/ctwfunc.c + * harbour/contrib/hbnf/color2n.c + * harbour/contrib/gtwvg/wvtcore.c + * updated to respect -1 returned for wrong color strings + + * harbour/source/rtl/tget.prg + * updated to respect -1 returned for wrong color strings + Viktor please check me, now it's simpler and hbtest does not + reports any errors so I guess that this version will work like + in Clipper also for :colorSpec := "R,X,Y,0" or similar + + * harbour/source/rtl/tobject.prg + * harbour/source/debug/dbgbrwsr.prg + * formatting + 2008-04-18 01:04 UTC+0100 Viktor Szakats (harbour.01 syenar hu) * tests/rto_tb.prg + Added some assigment tests using numerics with decimals. diff --git a/harbour/contrib/gtwvg/wvtcore.c b/harbour/contrib/gtwvg/wvtcore.c index 80c2d27adb..333e46de38 100644 --- a/harbour/contrib/gtwvg/wvtcore.c +++ b/harbour/contrib/gtwvg/wvtcore.c @@ -907,6 +907,8 @@ static COLORREF hb_wvt_BgColorParam( int iParam ) { int iColor = ISCHAR( iParam ) ? hb_gtColorToN( hb_parc( iParam ) ) : hb_gtGetCurrColor(); + if( iColor == -1 ) + iColor = 0 color = hb_wvt_gtGetColorData( ( iColor >> 4 ) & 0x0f ); } @@ -923,6 +925,8 @@ static COLORREF hb_wvt_FgColorParam( int iParam ) { int iColor = ISCHAR( iParam ) ? hb_gtColorToN( hb_parc( iParam ) ) : hb_gtGetCurrColor(); + if( iColor == -1 ) + iColor = 0 color = hb_wvt_gtGetColorData( iColor & 0x0f ); } diff --git a/harbour/contrib/hbct/color.c b/harbour/contrib/hbct/color.c index 44683db5a2..9f6283f043 100644 --- a/harbour/contrib/hbct/color.c +++ b/harbour/contrib/hbct/color.c @@ -86,7 +86,15 @@ HB_FUNC( INVERTATTR ) { int iAttr; - iAttr = ISCHAR( 1 ) ? hb_gtColorToN( hb_parc( 1 ) ) : hb_parni( 1 ); + if( ISCHAR( 1 ) ) + { + iAttr = hb_gtColorToN( hb_parc( 1 ) ); + if( iAttr == -1 ) + iAttr = 0; + } + else + iAttr = hb_parni( 1 ); + hb_retni( ( iAttr & 0x88 ) | ( ( iAttr & 0x07 ) << 4 ) | ( ( iAttr >> 4 ) & 0x07 ) ); @@ -134,7 +142,10 @@ HB_FUNC( INVERTATTR ) HB_FUNC( COLORTON ) { if( ISCHAR( 1 ) ) - hb_retni( hb_gtColorToN( hb_parc( 1 ) ) ); + { + int iColor = hb_gtColorToN( hb_parc( 1 ) ); + hb_retni( iColor == -1 ? 0 : iColor ); + } else hb_retni( hb_parni( 1 ) ); } diff --git a/harbour/contrib/hbct/ctwfunc.c b/harbour/contrib/hbct/ctwfunc.c index dc64f3bc1d..24684e269e 100644 --- a/harbour/contrib/hbct/ctwfunc.c +++ b/harbour/contrib/hbct/ctwfunc.c @@ -61,7 +61,11 @@ static int hb_ctColorParam( int iParam, int iDefault ) if( ISNUM( iParam ) ) iColor = hb_parni( iParam ); else if( hb_parclen( iParam ) > 0 ) + { iColor = hb_gtColorToN( hb_parc( iParam ) ); + if( iColor == -1 ) + iColor = iDefault; + } else iColor = iDefault; diff --git a/harbour/contrib/hbct/screen1.c b/harbour/contrib/hbct/screen1.c index 73306be789..5a31a4a2df 100644 --- a/harbour/contrib/hbct/screen1.c +++ b/harbour/contrib/hbct/screen1.c @@ -318,7 +318,11 @@ static int hb_ctGetClearColor( int iParam ) if( ISNUM( iParam ) ) iColor = hb_parni( iParam ); else if( ISCHAR( iParam ) ) + { iColor = hb_gtColorToN( hb_parc( iParam ) ); + if( iColor == -1 ) + iColor = 0; + } else iColor = hb_gtGetClearColor(); diff --git a/harbour/contrib/hbct/screen2.c b/harbour/contrib/hbct/screen2.c index 147f867c45..a6569f7eec 100644 --- a/harbour/contrib/hbct/screen2.c +++ b/harbour/contrib/hbct/screen2.c @@ -411,7 +411,11 @@ HB_FUNC( _HB_CTDSPTIME ) if( ISNUM( 4 ) ) iColor = hb_parni( 4 ); else if( ISCHAR( 4 ) ) + { iColor = hb_gtColorToN( hb_parc( 4 ) ); + if( iColor == -1 ) + iColor = 0; + } else iColor = hb_gtGetClearColor(); diff --git a/harbour/contrib/hbnf/color2n.c b/harbour/contrib/hbnf/color2n.c index 879d98c3a9..7638e6d32d 100644 --- a/harbour/contrib/hbnf/color2n.c +++ b/harbour/contrib/hbnf/color2n.c @@ -59,7 +59,11 @@ HB_FUNC( FT_COLOR2N ) int iRet = 0; if( ISCHAR( 1 ) ) + { iRet = hb_gtColorToN( hb_parc( 1 ) ); + if( iRet == -1 ) + iRet = 0; + } hb_retni( iRet ); } diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index ef1d6b48a7..74966ddef1 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -140,7 +140,7 @@ extern HB_EXPORT ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SH extern HB_EXPORT ERRCODE hb_gtBoxD( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight ); extern HB_EXPORT ERRCODE hb_gtBoxS( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight ); extern HB_EXPORT ERRCODE hb_gtColorSelect( USHORT uiColorIndex ); -extern HB_EXPORT USHORT hb_gtColorToN( char * szColorString ); +extern HB_EXPORT int hb_gtColorToN( char * szColorString ); extern HB_EXPORT ERRCODE hb_gtColorsToString( int * pColors, int iColorCount, char * pszColorString, int iBufSize ); extern HB_EXPORT ERRCODE hb_gtDispBegin( void ); extern HB_EXPORT USHORT hb_gtDispCount( void ); diff --git a/harbour/source/debug/dbgbrwsr.prg b/harbour/source/debug/dbgbrwsr.prg index bc6ec75a00..180446b3c9 100644 --- a/harbour/source/debug/dbgbrwsr.prg +++ b/harbour/source/debug/dbgbrwsr.prg @@ -172,7 +172,7 @@ METHOD ForceStable() @ ::nTop + nRow - 1, nColX SAY PadR( xData, nWid ) + IIf( nCol < Len( ::aColumns ), " ", "" ) nColX += nWid + 1 ENDIF - NEXT + NEXT ENDIF ::aRowState[ nRow ] := .T. ENDIF diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index 6d136c3af0..2cc7a3c8c0 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -308,7 +308,7 @@ HB_EXPORT ERRCODE hb_gtGetColorStr( char * pszColorString ) return FAILURE; } -HB_EXPORT USHORT hb_gtColorToN( char * szColorString ) +HB_EXPORT int hb_gtColorToN( char * szColorString ) { PHB_GT pGT; diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index 243c699619..eb86aacfc2 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -308,7 +308,7 @@ static void hb_gt_def_SetClearChar( PHB_GT pGT, int iChar ) static const char * hb_gt_def_ColorDecode( const char * szColorString, int * piColor ) { char c; - int nColor = 0; + int nColor = 0, iCount = 0; BOOL bFore = TRUE; HB_TRACE(HB_TR_DEBUG, ("hb_gt_def_ColorDecode(%s,%p)", szColorString, piColor)); @@ -378,7 +378,7 @@ static const char * hb_gt_def_ColorDecode( const char * szColorString, int * piC break; case ',': - * piColor = nColor; + * piColor = iCount == 0 ? -1 : nColor; return szColorString; default: @@ -393,10 +393,13 @@ static const char * hb_gt_def_ColorDecode( const char * szColorString, int * piC else nColor = ( nColor & 0x0F8F ) | ( iColor << 4 ); } + else + --iCount; } + ++iCount; } - * piColor = nColor; + * piColor = iCount == 0 ? -1 : nColor; return NULL; } @@ -445,9 +448,11 @@ static void hb_gt_def_StringToColors( PHB_GT pGT, const char * szColorString, in { ++*piColorCount; pColors = *pColorsPtr = ( int * ) hb_xrealloc( pColors, *piColorCount * sizeof( int ) ); + pColors[ nPos ] = 0; } - pColors[ nPos++ ] = nColor; - + if( nColor != -1 ) + pColors[ nPos ] = nColor; + ++nPos; } while( szColorString ); diff --git a/harbour/source/rtl/tget.prg b/harbour/source/rtl/tget.prg index bb8fa2a4c1..23f8d3edb0 100644 --- a/harbour/source/rtl/tget.prg +++ b/harbour/source/rtl/tget.prg @@ -1172,13 +1172,13 @@ METHOD colorSpec( cColorSpec ) CLASS Get IF ISCHARACTER( cColorSpec ) #ifdef HB_COMPAT_C53 - ::cColorSpec := hb_NToColor( nClrUns := hb_ColorToN( hb_ColorIndex( cColorSpec, GET_CLR_UNSELECTED ) ) ) +; - "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ENHANCED ) ) ) != 0 .OR. Upper( StrTran( cClrOth, " ", "" ) ) == "N/N", nClrOth, nClrUns ) ) +; - "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_CAPTION ) ) ) != 0 .OR. Upper( StrTran( cClrOth, " ", "" ) ) == "N/N", nClrOth, nClrUns ) ) +; - "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ACCEL ) ) ) != 0 .OR. Upper( StrTran( cClrOth, " ", "" ) ) == "N/N", nClrOth, nClrUns ) ) + ::cColorSpec := hb_NToColor( nClrUns := Max( hb_ColorToN( hb_ColorIndex( cColorSpec, GET_CLR_UNSELECTED ) ), 0 ) ) +; + "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ENHANCED ) ) ) != -1, nClrOth, nClrUns ) ) +; + "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_CAPTION ) ) ) != -1, nClrOth, nClrUns ) ) +; + "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ACCEL ) ) ) != -1, nClrOth, nClrUns ) ) #else - ::cColorSpec := hb_NToColor( nClrUns := hb_ColorToN( hb_ColorIndex( cColorSpec, GET_CLR_UNSELECTED ) ) ) +; - "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ENHANCED ) ) ) != 0 .OR. Upper( StrTran( cClrOth, " ", "" ) ) == "N/N", nClrOth, nClrUns ) ) + ::cColorSpec := hb_NToColor( nClrUns := Max( hb_ColorToN( hb_ColorIndex( cColorSpec, GET_CLR_UNSELECTED ) ), 0 ) ) +; + "," + hb_NToColor( iif( ( nClrOth := hb_ColorToN( cClrOth := hb_ColorIndex( cColorSpec, GET_CLR_ENHANCED ) ) ) != -1, nClrOth, nClrUns ) ) #endif RETURN cColorSpec diff --git a/harbour/source/rtl/tobject.prg b/harbour/source/rtl/tobject.prg index 314bccf2c3..120b713c35 100644 --- a/harbour/source/rtl/tobject.prg +++ b/harbour/source/rtl/tobject.prg @@ -100,7 +100,7 @@ FUNCTION HBObject() s_oClass:SetOnError( @HBObject_DftonError() ) - s_oClass:AddInline( "MSGNOTFOUND" , {| Self, cMsg | ::Error( "Message not found", __OBJGETCLSNAME( Self ), cMsg, iif(substr(cMsg,1,1)=="_",1005,1004) ) }, HB_OO_CLSTP_EXPORTED ) + s_oClass:AddInline( "MSGNOTFOUND" , {| Self, cMsg | ::Error( "Message not found", __OBJGETCLSNAME( Self ), cMsg, IIF( cMsg="_", 1005, 1004 ) ) }, HB_OO_CLSTP_EXPORTED ) /*s_oClass:AddMultiData(,,HB_OO_CLSTP_EXPORTED,{"CLASS"}, .F. )*/