Control box

Post Reply
User avatar
mastintin
Posts: 1502
Joined: Thu May 27, 2010 2:06 pm

Control box

Post by mastintin »

Sin probar aun :

Code: Select all

HB_FUNC( BOXCREATE ) 
{
   NSBox * box = [ [ NSBox alloc ] 
                       initWithFrame : NSMakeRect( hb_parnl( 2 ), hb_parnl( 1 ), hb_parnl( 3 ), hb_parnl( 4 ) ) ];
   NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 5 ) ? hb_parc( 5 ) : "" ] autorelease ];
   NSWindow * window = ( NSWindow * ) hb_parnl( 6 );

   [box setBoxType: NSBoxPrimary ];
   if ( string != NULL ) [box setTitle : string ];
   [ GetView( window ) addSubview : box ];
     
   hb_retnl( ( LONG ) box );
} 

HB_FUNC( SEPARATOR ) 
{
NSBox *Separator=[[NSBox alloc] 
        initWithFrame:NSMakeRect( hb_parnl( 2 ), hb_parnl( 1 ), hb_parnl( 3 ), hb_parnl( 4 ) ) ];
  NSWindow * window = ( NSWindow * ) hb_parnl( 6 );       
[Separator setBoxType:NSBoxSeparator];
  [ GetView( window ) addSubview :  Separator ];
     
   hb_retnl( ( LONG ) Separator );
} 

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

Re: Control box

Post by mastintin »

Las Funciones anteriores con las correciones oportunas , mas dos funciones para controlar el stylo . FUNCIONANDO .

Code: Select all

NSView * GetView( NSWindow * window );
HB_FUNC( BOXCREATE )
{
    NSBox * box = [ [ NSBox alloc ]
                   initWithFrame : NSMakeRect( hb_parnl( 2 ), hb_parnl( 1 ), hb_parnl( 3 ), hb_parnl( 4 ) ) ];
    NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 5 ) ? hb_parc( 5 ) : "" ] autorelease ];
    NSWindow * window = ( NSWindow * ) hb_parnl( 6 );
    
    [box setBoxType: NSBoxPrimary ];
    if ( string != NULL ) [box setTitle : string ] ;
    [ GetView( window ) addSubview : box ];
    
    hb_retnl( ( LONG ) box );
}

HB_FUNC( SEPARATOR )
{
    NSBox *Separator=[[NSBox alloc]
                      initWithFrame:NSMakeRect( hb_parnl( 2 ), hb_parnl( 1 ), hb_parnl( 3 ), hb_parnl( 4 ) ) ];
    NSWindow * window = ( NSWindow * ) hb_parnl( 5 );      
    [Separator setBoxType:NSBoxSeparator];
    [ GetView( window ) addSubview :  Separator ];
    
    hb_retnl( ( LONG ) Separator );
} 


HB_FUNC( BOXSETSTYLE )
{
    NSBox * box = ( NSBox * ) hb_parnl( 1 );
    [box setBoxType : hb_parnl( 2 ) ];
}

HB_FUNC( BOXGETSTYLE )
{
    NSBox * box = ( NSBox * ) hb_parnl( 1 );
    hb_retnl( [ box boxType ] );
}


 
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Control box

Post by Antonio Linares »

Manuel,

Has creado una Clase en PRG ? Podriamos llamarla TGroup por la equivalencia con Windows :-)

Que ejemplo has probado ? gracias
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
mastintin
Posts: 1502
Joined: Thu May 27, 2010 2:06 pm

Re: Control box

Post by mastintin »

No, no he creado la clase , lo he probado directamente sobre las funciones y sobre un dialogo que estoy creando para un "generador indices" perteneciente a un proyecto mayor ( cuando tenga mas o menos decente el generador intentaré compartirlo aquí ), pero se podría usar el tutor02.prg
He revisado para hacer la clase y se me ocurre que una de las funciones sobra si modifico un poco el codigo .
Lo pongo todo completo y SIN PROBAR ( Estoy en windows) :

La clase:

Code: Select all

#include "FiveMac.ch"

//----------------------------------------------------------------------------//


CLASS TGroup FROM TControl
   
   METHOD New( nRow, nCol, nWidth, nHeight,  cText ,oWnd , nStyle )
   METHOD SetStyle( nStyle ) INLINE boxSetStyle( ::hWnd, nStyle )
   METHOD GetStyle()         INLINE boxGetStyle( ::hWnd )
   METHOD separator (nRow, nCol, nWidth, nHeight, oWnd ) 

//----------------------------------------------------------------------------//

METHOD New( nRow, nCol, nWidth, nHeight, cText, oWnd , nStyle)  CLASS TGroup

   local hGroup := oRadMenu:hGroup

   DEFAULT oWnd := GetWndDefault(), nWidth := 100, nHeight := 23 , nStyle := 1

   ::hWnd = BoxCreate( nRow, nCol, nWidth, nHeight, cText,nStyle , oWnd:hWnd )
   
   oWnd:AddControl( Self )

return Self

//----------------------------------------------------------------------------//

METHOD Separator ( nRow, nCol, nWidth, nHeight,  oWnd )  CLASS TGroup

   local hGroup := oRadMenu:hGroup

   DEFAULT oWnd := GetWndDefault(), nWidth := 100, nHeight := 23

   ::hWnd = BoxCreate( nRow, nCol, nWidth, nHeight, , 3 , oWnd:hWnd )
   
   oWnd:AddControl( Self )

return Self
 
Las funciones :

Code: Select all


NSView * GetView( NSWindow * window );
HB_FUNC( BOXCREATE )
{
    NSBox * box = [ [ NSBox alloc ]
                   initWithFrame : NSMakeRect( hb_parnl( 2 ), hb_parnl( 1 ), hb_parnl( 3 ), hb_parnl( 4 ) ) ];
    NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 5 ) ? hb_parc( 5 ) : "" ] autorelease ];
    NSWindow * window = ( NSWindow * ) hb_parnl( 7 );
   
    [box setBoxType:hb_parnl( 6 ) ];
    if ( string != NULL ) [box setTitle : string ] ;
    [ GetView( window ) addSubview : box ];
   
    hb_retnl( ( LONG ) box );
}

HB_FUNC( BOXSETSTYLE )
{
    NSBox * box = ( NSBox * ) hb_parnl( 1 );
    [box setBoxType : hb_parnl( 2 ) ];
}

HB_FUNC( BOXGETSTYLE )
{
    NSBox * box = ( NSBox * ) hb_parnl( 1 );
    hb_retnl( [ box boxType ] );
}
 
el preprocesado :

Code: Select all

    
#xcommand @ <nTop>, <nLeft>  GROUP [ <oGroup> ] ;
             [ SIZE <nWidth>, <nHeight> ] ;
             [ <label:LABEL,PROMPT> <cLabel> ] ;
             [ OF <oWnd> ] ;
             [ STYLE <nStyle> ] ;
       => ;
          [ <oGroup> := ] TGroup():New( <nTop>, <nLeft>, <nWidth>, <nHeight>,;
             <cLabel>, <oWnd>, <nStyle> )
 
el ejemplo

Code: Select all

#include "FiveMac.ch"

function Main()

   local oDlg, cFirst := Space( 20 ), cLast := Space( 20 )
   local oGroup
   
   DEFINE DIALOG oDlg TITLE "Testing Gets" ;
      FROM 270, 350 TO 389, 206
   
    @ 70,30 GROUP oGroup SIZE 200, 200 ;
             PROMPT "Hola" OF oDlg ;
              STYLE 1 
      
   @ 139, 50 SAY "First:" OF oDlg SIZE 50, 17
      
   @ 137, 108 GET cFirst OF oDlg SIZE 208, 22 ;
      VALID If( Empty( cFirst ), ( MsgInfo( "Please type something" ), .f. ), .t. )
   
   @  98, 50 SAY "Last:" OF oDlg SIZE 50, 17
   
   @  96, 108 GET cLast OF oDlg SIZE 208, 22
   
   @ 34, 83 BUTTON "OK" OF oDlg ACTION oDlg:End()
   
   @ 34, 218 BUTTON "Cancel" OF oDlg ACTION oDlg:End()
   
   ACTIVATE DIALOG oDlg CENTERED
   
return nil   
 
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Control box

Post by Antonio Linares »

Manuel,

Implementado y funcionando bien, gracias! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply