Dos cosas mas

Dos cosas mas

Postby mastintin » 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: Select all  Expand view

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: Select all  Expand view

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.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Dos cosas mas

Postby Antonio Linares » Mon Jul 05, 2010 3:45 pm

Manuel,

Probemos asi: (no lo he probado aun)
Code: Select all  Expand view

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
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Dos cosas mas

Postby Antonio Linares » Mon Jul 05, 2010 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Dos cosas mas

Postby Antonio Linares » Mon Jul 05, 2010 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Dos cosas mas

Postby Antonio Linares » Mon Jul 05, 2010 4:37 pm

De forma similar podemos obtener el ancho de cualquier columna del browse:
Code: Select all  Expand view

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: Select all  Expand view

   METHOD GetColWidth( nIndex ) INLINE BrwGetColWidth( ::hWnd, nIndex )
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Dos cosas mas

Postby mastintin » Mon Jul 05, 2010 5:13 pm

· metodos mas para tWbrowse FUNCIONANDO :

Code: Select all  Expand view

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: Select all  Expand view

 METHOD GetrowHeight( ) INLINE BrwGetRowHeight( ::hWnd )
 METHOD SetRowHeight( ) INLINE BrwSetRowHeight( ::hWnd,nHeight )
METHOD SetArternateColor(lonoff) INLINE BrwSetAltColor(::hWnd,lonoff )

 
Last edited by mastintin on Mon Jul 05, 2010 7:51 pm, edited 2 times in total.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Dos cosas mas

Postby mastintin » Mon Jul 05, 2010 6:34 pm

Las funciones anteriores para la altura de las filas funcionan perfectamente :-)
Saludos.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Dos cosas mas

Postby Antonio Linares » Tue Jul 06, 2010 2:52 am

Manuel,

Implementados para el próximo build :-)

Muchas gracias! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Dos cosas mas

Postby mastintin » Tue Jul 06, 2010 8: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: Select all  Expand view

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 ];
          }
     }        
     }
   
    }  
}
 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Dos cosas mas

Postby mastintin » 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: Select all  Expand view

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 ];
       
}  

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: Dos cosas mas

Postby Antonio Linares » Tue Jul 06, 2010 6: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: Select all  Expand view

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
User avatar
Antonio Linares
Site Admin
 
Posts: 41208
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 4 guests