FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) Ayuda browse con imagenes
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Ayuda browse con imagenes
Posted:
Manuel,

He modificado el c贸digo as铆:
Code (fw): Select all Collapse
- ( id ) tableView : ( NSTableView * ) aTableView objectValueForTableColumn : ( NSTableColumn * ) aTableColumn row : ( NSInteger ) rowIndex
{
   NSString * string;

   if( symFMH == NULL )
      symFMH = hb_dynsymSymbol( hb_dynsymFindName( "_FMH" ) );
   
   hb_vmPushSymbol( symFMH );
   hb_vmPushNil();
   hb_vmPushLong( ( LONG ) hWnd );
   hb_vmPushLong( WM_BRWVALUE );
   hb_vmPushLong( ( LONG ) aTableView );
   hb_vmPushLong( ( ( TableColumn * ) aTableColumn )->id );
   hb_vmPushLong( rowIndex );
   hb_vmDo( 5 );
   
   string = [ [ [ NSString alloc ] initWithCString: ISCHAR( -1 ) ? hb_parc( -1 ) : "" ] autorelease ];
    
   if( ( NSCellType ) [ [ aTableColumn dataCell ] type ] == NSImageCellType )
      return [ [ [ NSImage alloc ] initWithContentsOfFile : string ] autorelease ]; 
   else 
      return string;
}

Solo faltar铆a antes de intentar crear la imagen, ver si el nombre del fichero existe pues si no da error al no encontrarlo y no poder crear la imagen. Creo recordar que publicastes el c贸digo para detectar la existencia de un fichero, ando busc谩ndolo :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Ayuda browse con imagenes
Posted: Sat Jul 10, 2010 04:30 PM
He vuelto sobre el tema :
la idea es la siguiente , con una func
ion le digo que columna quiero que tenga imagenes .
Code (fw): Select all Collapse
HB_FUNC( BRWSETCOLBMP ) // hTableView, nIndex, lOnOff
{
    
    NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );
    
    NSTableColumn * column =  [ [ browse tableColumns ] objectAtIndex :(hb_parnl( 2 ) - 1 ) ] ;
    NSImageCell  *imageCell = [[[NSImageCell alloc] init] autorelease];
    [column setDataCell : imageCell ] ; 

}


luego en el tableview le digo que carge imagenes en vez string
Code (fw): Select all Collapse
- ( id ) tableView : ( NSTableView * ) aTableView objectValueForTableColumn : ( NSTableColumn * ) aTableColumn row : ( NSInteger ) rowIndex
{
    if( symFMH == NULL )
      symFMH = hb_dynsymSymbol( hb_dynsymFindName( "_FMH" ) );
   
   hb_vmPushSymbol( symFMH );
   hb_vmPushNil();
   hb_vmPushLong( ( LONG ) hWnd );
   hb_vmPushLong( WM_BRWVALUE );
   hb_vmPushLong( ( LONG ) aTableView );
   hb_vmPushLong( ( ( TableColumn * ) aTableColumn )->id );
   hb_vmPushLong( rowIndex );
   hb_vmDo( 5 );
   NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( -1 ) ? hb_parc( -1 ) : "" ] autorelease ];
    NSInteger * type =  [[aTableColumn dataCell ] type ] ;
    if( type  ==  NSImageCellType ) return [ [ NSImage alloc ] initWithContentsOfFile : string  ] ;     
    return [ [ NSImage alloc ] initWithContentsOfFile : string  ] ; 
    return string ;
}   
@end


el problema esta en las lineas :
Code (fw): Select all Collapse
NSInteger * type =  [[aTableColumn dataCell ] type ] ;
    if( type  ==  NSImageCellType ) return [ [ NSImage alloc ] initWithContentsOfFile : string  ] ;

no consiguo que me devuelva in integer para comparar .... que otras opciones tengo?
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Ayuda browse con imagenes
Posted: Sat Jul 10, 2010 09:50 PM
porfin me funciona :
Code (fw): Select all Collapse
- ( id ) tableView : ( NSTableView * ) aTableView objectValueForTableColumn : ( NSTableColumn * ) aTableColumn row : ( NSInteger ) rowIndex
{
聽 聽 if( symFMH == NULL )
聽 聽 聽 symFMH = hb_dynsymSymbol( hb_dynsymFindName( "_FMH" ) );
聽 聽
聽 聽hb_vmPushSymbol( symFMH );
聽 聽hb_vmPushNil();
聽 聽hb_vmPushLong( ( LONG ) hWnd );
聽 聽hb_vmPushLong( WM_BRWVALUE );
聽 聽hb_vmPushLong( ( LONG ) aTableView );
聽 聽hb_vmPushLong( ( ( TableColumn * ) aTableColumn )->id );
聽 聽hb_vmPushLong( rowIndex );
聽 聽hb_vmDo( 5 );
聽 聽NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( -1 ) ? hb_parc( -1 ) : "" ] autorelease ];
聽 聽NSCell * celda = [aTableColumn dataCell ] 聽;
聽 聽 if( [celda type ] == 聽0 )聽 聽return [ [ NSImage alloc ] initWithContentsOfFile : string 聽] ; 聽 聽 

聽 聽 聽 聽 return string ;
聽 聽 
聽 聽 }


Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Ayuda browse con imagenes
Posted: Sun Jul 11, 2010 08:40 AM
He mirado una cosa no funciona bien porque :
Code (fw): Select all Collapse
聽if( ( NSCellType ) [ [ aTableColumn dataCell ] type ] == NSImageCellType )
聽 聽 聽 return [ [ [ NSImage alloc ] initWithContentsOfFile : string ] autorelease ];

NSImageCellType tiene valor 3 y type devuelve valor 0 porque aun no tiene datos .

aun mejor pues sirve para mas tipos de NSCells y funciona :

Code (fw): Select all Collapse
聽 聽 if( [ [ [aTableColumn dataCell ] className ] isEqual : @"NSImageCell" ] )聽 聽
聽 聽 聽 聽 return [ [ [ NSImage alloc ] initWithContentsOfFile : string ] autorelease ];
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Ayuda browse con imagenes
Posted: Sun Jul 11, 2010 09:43 AM

Manuel,

Realmente buena tu soluci贸n ! :-)

Es una gran satisfacci贸n estar programando contigo en FiveMac :-)

gracias!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Ayuda browse con imagenes
Posted: Sun Jul 11, 2010 04:19 PM
Antonio Linares wrote:Manuel,

Realmente buena tu soluci贸n ! :-)

Es una gran satisfacci贸n estar programando contigo en FiveMac :-)

gracias!

La satisfaci贸n es m铆a al poder aportar algo a este gran proyecto .
faltaba el control de la existencia de imagen ....
Code (fw): Select all Collapse
 if( [ [ [aTableColumn dataCell ] className ] isEqual : @"NSImageCell" ] )  
      {
          if( [[NSFileManager defaultManager] fileExistsAtPath: string ]  == YES ){ 
               return [ [ NSImage alloc ] initWithContentsOfFile : string  ] ; 
          }
          else return (NULL) ; 
      }
            return string ;

Continue the discussion