FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) Dos cosas mas
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Dos cosas mas
Posted: Mon Jul 05, 2010 12:47 PM
Sería util poder controlar las anchuras de las columnas del browse . Lo he estado intentando ,pero no consiguo hacer que funcione .
La idea era esta, pero no va :
Code (fw): Select all Collapse
HB_FUNC( BRWCOLSETWIDTH )
{
    NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );
    TableColumn * column = [ [ TableColumn alloc ] init ];  
    column->id = hb_prnl(2) ; 
    [column setWidth : hb_parnl( 3 ) ]; 
    [ browse reloadData ];
}


por otro lado he realizado esta funcion primaria para el uso de los mensajes en sheet y pare que funciona .
Code (fw): Select all Collapse
HB_FUNC( MSGALERTSHEET )
{
    NSString * msg;
    NSWindow * window = ( NSWindow * ) hb_parnl( 2 );
    CocoaInit();
    
    ValToChar( hb_param( 1, HB_IT_ANY ) );
    msg = [ [ [ NSString alloc ] initWithCString: ISCHAR( -1 ) ? hb_parc( -1 ) : "" ] autorelease ];
    
    NSBeginAlertSheet(nil, nil, nil, nil, window, nil , NULL, NULL,NULL, msg);
    
    hb_ret();
}


Saludos.
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dos cosas mas
Posted: Mon Jul 05, 2010 03:45 PM
Manuel,

Probemos asi: (no lo he probado aun)
Code (fw): Select all Collapse
 
HB_FUNC( BRWCOLSETWIDTH )
{
    NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );
    
    [ [ [ browse tableColumns ] objectAtIndex : hb_parnl( 2 ) ] setWidth : hb_parnl( 3 ) ];    
    [ browse reloadData ];
}
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dos cosas mas
Posted: Mon Jul 05, 2010 04:15 PM

Funciona bien :-)

Le he cambiado el nombre asi: function BrwSetColWidth() y este es el nuevo método en la Clase TWBrowse:

METHOD SetColWidth( nIndex, nWidth ) INLINE BrwSetColWidth( ::hWnd, nIndex, nWidth )

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dos cosas mas
Posted: Mon Jul 05, 2010 04:18 PM

Como el índice del array ( NSArray ) comienza en cero, hay que modificar esta línea asi:

[ [ [ browse tableColumns ] objectAtIndex : hb_parnl( 2 ) - 1 ] setWidth : hb_parnl( 3 ) ];

Para los que esteis leyendo estas líneas que escribimos en Objective-C daros cuenta que la línea anterior en Harbour se escribiría de esta forma:

browse:tableColumns:objectAtIndex( hb_parnl( 2 ) - 1 ):setWidth( hb_parnl( 3 ) )

realmente el usar el operador [ ] como envio de mensajes ( : en Harbour ) es más ineficaz y obliga a escribir mas.
Veremos algún dia a Apple evolucionar a Objective-C para soportar una sintaxis parecida a la de Harbour ? :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dos cosas mas
Posted: Mon Jul 05, 2010 04:37 PM
De forma similar podemos obtener el ancho de cualquier columna del browse:
Code (fw): Select all Collapse
HB_FUNC( BRWGETCOLWIDTH ) // hTableView, nIndex --> nWidth
{
   NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );
    
   hb_retnl( [ [ [ browse tableColumns ] objectAtIndex : hb_parnl( 2 ) - 1 ] width ] );    
}

y el método en la Clase TWBrowse:
Code (fw): Select all Collapse
   METHOD GetColWidth( nIndex ) INLINE BrwGetColWidth( ::hWnd, nIndex )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Dos cosas mas
Posted: Mon Jul 05, 2010 05:13 PM
· metodos mas para tWbrowse FUNCIONANDO :

Code (fw): Select all Collapse
HB_FUNC( BRWSETROWHEIGHT )
{
   NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );   
   [ browse setRowHeight : hb_parnl( 2 ) ];    
}  

HB_FUNC( BRWGETROWHEIGHT )
{
   NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );   
   hb_retnl ( [ browse rowHeight ] )  ;    
} 

HB_FUNC( BRWSETALTCOLOR )
{
    NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );  
    [ browse setUsesAlternatingRowBackgroundColors : hb_parl( 2 ) ];    

}


Y sus metodos :

Code (fw): Select all Collapse
 METHOD GetrowHeight( ) INLINE BrwGetRowHeight( ::hWnd )
 METHOD SetRowHeight( ) INLINE BrwSetRowHeight( ::hWnd,nHeight )
METHOD SetArternateColor(lonoff) INLINE BrwSetAltColor(::hWnd,lonoff )
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Dos cosas mas
Posted: Mon Jul 05, 2010 06:34 PM

Las funciones anteriores para la altura de las filas funcionan perfectamente :-)
Saludos.

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dos cosas mas
Posted: Tue Jul 06, 2010 02:52 AM

Manuel,

Implementados para el próximo build :-)

Muchas gracias! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Dos cosas mas
Posted: Tue Jul 06, 2010 08:30 AM
SIn probar :
Nueva funcion para el manejo de las "lineas separadoras" del browse . Se puede implementar mejor con el uso del operador OR en los estilos ,pero eso se tendrá que hacer al implementar el Metodo de la clase en Twbrowse para que sea lo mas compatible posible con el FWH , de momenot para probar vale asi .
Saludos.

Code (fw): Select all Collapse
HB_FUNC( BRWSETGRIDLINES )
{
   NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );  
   NSInteger * nStyle hb_parnl( 2 )
   if (nStyle == 1 ){
      [ browse setGridStyleMask :  NSTableViewGridNone ];
      }
   else
    { if (nStyle == 2) {
         [ browse setGridStyleMask : NSTableViewSolidHorizontalGridLineMask ];
         }
      else
        {  if (nStyle == 3 ) {
            [ browse setGridStyleMask : NSTableViewSolidHorizontalGridLineMask ];            
           }
        else
          {
           [ browse setGridStyleMask : NSTableViewSolidVerticalGridLineMask | NSTableViewSolidHorizontalGridLineMask ];
          }
     }        
     }
    
    }   
}
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM
Re: Dos cosas mas
Posted: Tue Jul 06, 2010 11:56 AM
He cambiado el codigo para que sea mas facil de modificar a posteriori ,en una mejor implementacion .FUNCIONANDO correcto :
Code (fw): Select all Collapse
HB_FUNC( BRWSETGRIDLINES )
{
    NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );  
    NSInteger  nStyle =  hb_parnl( 2 ) ;
        if (nStyle == 1 )[ browse setGridStyleMask :  NSTableViewGridNone ];
    if (nStyle == 2) [ browse setGridStyleMask : NSTableViewSolidHorizontalGridLineMask ];
    if (nStyle == 3 )[  browse setGridStyleMask : NSTableViewSolidVerticalGridLineMask ];   
    if (nStyle == 4 )[  browse setGridStyleMask : NSTableViewSolidVerticalGridLineMask | NSTableViewSolidHorizontalGridLineMask ];
        
}
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Dos cosas mas
Posted: Tue Jul 06, 2010 06:25 PM
Manuel,

Lo he modificado para que use un switch (parecido al do case de Harbour). No lo he probado aún, voy ahora a probarlo:
Code (fw): Select all Collapse
HB_FUNC( BRWSETGRIDLINES )
{
   NSTableView * browse = ( NSTableView * ) hb_parnl( 1 );  
   int iType = hb_parnl( 2 );
   
   switch( iType )
   {
      case 1:
         [ browse setGridStyleMask : NSTableViewGridNone ];
         break;
         
      case 2:       
         [ browse setGridStyleMask : NSTableViewSolidHorizontalGridLineMask ];
         break;
         
      case 3:       
         [ browse setGridStyleMask : NSTableViewSolidVerticalGridLineMask ];
         break;
         
      default:         
         [ browse setGridStyleMask : NSTableViewSolidVerticalGridLineMask | NSTableViewSolidHorizontalGridLineMask ];
         break;
   }      
}
regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion