/* $Doc$ * $FuncName$ AddToArray( <pItem>, <pReturn>, <uiPos> ) * $Description$ Add <pItem> to array <pReturn> at pos <uiPos> * $End$ */ static void AddToArray( PHB_ITEM pItem, PHB_ITEM pReturn, ULONG ulPos ) { HB_ITEM_NEW( Temp ); HB_TRACE(HB_TR_DEBUG, ("AddToArray(%p, %p, %lu)", pItem, pReturn, ulPos)); if( pItem->type == HB_IT_SYMBOL ) { int iLen = strlen( pItem->item.asSymbol.value->szName ) + 2; char *sTemp = (char *) hb_xgrab( iLen + 1 ); hb_snprintf( sTemp, iLen + 1, "[%s]", pItem->item.asSymbol.value->szName ); hb_itemPutCPtr( &Temp, sTemp, iLen ); hb_arraySetForward( pReturn, ulPos, &Temp ); // hb_itemRelease( pTemp ); /* Get rid of temporary str.*/ } else /* Normal types */ { hb_arraySet( pReturn, ulPos, pItem ); } }
/* * Obtain the current value of a field. */ static HB_ERRCODE hb_delimGetValue( DELIMAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) { LPFIELD pField; HB_TRACE(HB_TR_DEBUG, ("hb_delimGetValue(%p, %hu, %p)", pArea, uiIndex, pItem)); --uiIndex; pField = pArea->lpFields + uiIndex; switch( pField->uiType ) { case HB_FT_STRING: #ifndef HB_CDP_SUPPORT_OFF if( pArea->cdPage != hb_cdppage() ) { char * pVal = ( char * ) hb_xgrab( pField->uiLen + 1 ); memcpy( pVal, pArea->pRecord + pArea->pFieldOffset[ uiIndex ], pField->uiLen ); pVal[ pField->uiLen ] = '\0'; hb_cdpnTranslate( pVal, pArea->cdPage, hb_cdppage(), pField->uiLen ); hb_itemPutCPtr( pItem, pVal, pField->uiLen ); } else #endif { hb_itemPutCL( pItem, ( char * ) pArea->pRecord + pArea->pFieldOffset[ uiIndex ], pField->uiLen ); } break; case HB_FT_LOGICAL: switch( pArea->pRecord[ pArea->pFieldOffset[ uiIndex ] ] ) { case 'T': case 't': case 'Y': case 'y': hb_itemPutL( pItem, TRUE ); break; default: hb_itemPutL( pItem, FALSE ); break; } break; case HB_FT_DATE: hb_itemPutDS( pItem, ( char * ) pArea->pRecord + pArea->pFieldOffset[ uiIndex ] ); break; case HB_FT_LONG: { HB_LONG lVal; double dVal; BOOL fDbl; fDbl = hb_strnToNum( (const char *) pArea->pRecord + pArea->pFieldOffset[ uiIndex ], pField->uiLen, &lVal, &dVal ); if( pField->uiDec ) { hb_itemPutNDLen( pItem, fDbl ? dVal : ( double ) lVal, ( int ) ( pField->uiLen - pField->uiDec - 1 ), ( int ) pField->uiDec ); } else if( fDbl ) { hb_itemPutNDLen( pItem, dVal, ( int ) pField->uiLen, 0 ); } else { hb_itemPutNIntLen( pItem, lVal, ( int ) pField->uiLen ); } } break; case HB_FT_MEMO: hb_itemPutC( pItem, "" ); break; case HB_FT_NONE: hb_itemClear( pItem ); break; default: { PHB_ITEM pError; pError = hb_errNew(); hb_errPutGenCode( pError, EG_DATATYPE ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_DATATYPE ) ); hb_errPutOperation( pError, hb_dynsymName( ( PHB_DYNS ) pField->sym ) ); hb_errPutSubCode( pError, EDBF_DATATYPE ); SELF_ERROR( ( AREAP ) pArea, pError ); hb_itemRelease( pError ); return HB_FAILURE; } } return HB_SUCCESS; }
BOOL xwt_gtk_base_getall( PXWT_WIDGET widget, PHB_ITEM pRet ) { HB_ITEM hbValue; XWT_GTK_BASE *wSelf = (PXWT_GTK_BASE) widget->widget_data; GtkWidget *wTop = wSelf->top_widget( widget ); hbValue.type = HB_IT_NIL; hb_hashAddChar( pRet, "x", hb_itemPutNI( &hbValue, wSelf->x ) ); hb_hashAddChar( pRet, "y", hb_itemPutNI( &hbValue, wSelf->y ) ); hb_hashAddChar( pRet, "width", hb_itemPutNI( &hbValue, wSelf->width ) ); hb_hashAddChar( pRet, "height", hb_itemPutNI( &hbValue, wSelf->height ) ); hb_hashAddChar( pRet, "id", hb_itemPutNI( &hbValue, wSelf->nId ) ); hb_hashAddChar( pRet, "broadcast", hb_itemPutL( &hbValue, wSelf->bBroadcast ) ); if (!wSelf->fgColor ) { hb_hashAddChar( pRet, "fgcolor", hb_itemPutC( &hbValue, "" ) ) ; } else { hb_hashAddChar( pRet, "fgcolor", hb_itemPutCPtr( &hbValue, wSelf->fgColor, 7 ) ); } if(wSelf->baseColor != NULL ) { hb_hashAddChar( pRet, "basecolor", hb_itemPutCPtr( &hbValue, wSelf->baseColor, 7) ); } else { hb_hashAddChar( pRet, "basecolor", hb_itemPutC( &hbValue, "" ) ); } if( wSelf->textColor != NULL ) { hb_hashAddChar( pRet, "textcolor", hb_itemPutCPtr( &hbValue, wSelf->textColor, 7 ) ); } else { hb_hashAddChar( pRet, "textcolor", hb_itemPutC( &hbValue, "" ) ); } if( wSelf->bgColor ) { hb_hashAddChar( pRet, "bgcolor", hb_itemPutCPtr( &hbValue, wSelf->bgColor, 7 ) ); } else { hb_hashAddChar( pRet, "bgcolor", hb_itemPutC( &hbValue, "" ) ); } if ( GTK_WIDGET_VISIBLE(wTop) ) { hb_itemPutCRawStatic( &hbValue, "visible", 7 ); } else { hb_itemPutCRawStatic( &hbValue, "hidden", 6 ); } hb_hashAddChar( pRet, "visibility", &hbValue ); hb_hashAddChar( pRet, "focus", hb_itemPutL( &hbValue, gtk_widget_is_focus( wTop )) ); hb_itemClear( &hbValue ); return TRUE; }
BOOL xwt_gtk_base_getprop( PXWT_WIDGET widget, char *prop, PHB_ITEM pValue ) { BOOL ret = TRUE; XWT_GTK_BASE *wSelf = (PXWT_GTK_BASE) widget->widget_data; GtkWidget *wTop = wSelf->top_widget( widget ); if ( strcmp( prop, "x" ) == 0 ) { hb_itemPutNI( pValue, wSelf->x ); } else if ( strcmp( prop, "x" ) == 0 ) { hb_itemPutNI( pValue, wSelf->y ); } else if ( strcmp( prop, "width" ) == 0 ) { hb_itemPutNI( pValue, wSelf->width ); } else if ( strcmp( prop, "height" ) == 0 ) { hb_itemPutNI( pValue, wSelf->height ); } else if ( strcmp( prop, "id" ) == 0 ) { hb_itemPutNI(pValue, wSelf->nId ); } else if ( strcmp( prop, "visibility" ) == 0 ) { if ( GTK_WIDGET_VISIBLE(wTop) ) { hb_itemPutCRawStatic( pValue, "visible", 7 ); } else { hb_itemPutCRawStatic( pValue, "hidden", 6 ); } } else if ( strcmp( prop, "focus" ) == 0 ) { hb_itemPutL( pValue, (BOOL) gtk_widget_is_focus( wTop ) ); } else if ( strcmp( prop, "broadcast" ) == 0 ) { hb_itemPutL( pValue, wSelf->bBroadcast ); } else if ( strcmp( prop, "fgcolor" ) == 0 ) { if ( !wSelf->fgColor ) hb_itemPutC( pValue, "" ) ; else hb_itemPutCPtr( pValue, wSelf->fgColor, 7); } else if ( strcmp( prop, "bgcolor" ) == 0 ) { if ( wSelf->bgColor) hb_itemPutCPtr( pValue, wSelf->bgColor, 7 ); else hb_itemPutC( pValue, "" ); } else if ( strcmp( prop, "textcolor" ) == 0 ) { if ( wSelf->textColor ) hb_itemPutCPtr( pValue, wSelf->textColor, 7 ); else hb_itemPutC( pValue, "" ); } else if ( strcmp( prop, "basecolor" ) == 0 ) { if ( wSelf->baseColor ) hb_itemPutCPtr( pValue, wSelf->baseColor, 7 ); else hb_itemPutC( pValue, "" ); } else { ret = FALSE; } return ret; }