desde archivo de recursos
Posted: Thu Jul 15, 2010 8:56 pm
Es un primer acercamiento que no tiene utilidad alguna pero seguro que podemos ir avanzando entre todos ...
Saludos.
Saludos.
www.FiveTechSoft.com
http://forums.fivetechsoft.com/
Code: Select all
#import <Cocoa/Cocoa.h>
#define HB_DONT_DEFINE_BOOL
#include <hbapi.h>
@interface WindowController : NSWindowController
{
}
- ( void ) windowDidLoad;
@end
@implementation WindowController
- ( void ) windowDidLoad
{
NSArray * controls = [ [ [ self window ] contentView ] subviews ];
int i;
NSRunAlertPanel( @"windowDidLoad", @"", @"OK", NULL, NULL );
if( [ controls count ] == 0 )
NSRunAlertPanel( @"no hay controles", @"", @"OK", NULL, NULL );
for( i = 0; i < [ controls count ]; i++ )
NSRunAlertPanel( @"control", @"", @"OK", NULL, NULL );
}
@end
HB_FUNC( WINDOWCONTROLLERCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
WindowController * wndController = [ [ WindowController alloc ] initWithWindowNibName : string ];
[ wndController showWindow : nil ];
hb_retnl( ( LONG ) wndController );
}
Explico aqui los pasos a hacer desde el Interface Builder:Did you remember to hook up the window in the nib to File's Owner's
window outlet? Did you remember to change the class identity of File's
Owner to your NSWindowController subclass?
Code: Select all
HB_FUNC( WINDOWCONTROLLERCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
NSWindowController * wndController = [ [ NSWindowController alloc ] initWithWindowNibName : string ];
if( [ wndController window ] != nil )
NSRunAlertPanel( @"ventana accesible", @"", @"OK", NULL, NULL );
hb_retnl( ( LONG ) wndController );
}
Code: Select all
HB_FUNC( WINDOWCONTROLLERCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
NSWindowController * wndController = [ [ NSWindowController alloc ] initWithWindowNibName : string ];
NSArray * controls = [ [ [ wndController window ] contentView ] subviews ];
int i;
for( i = 0; i < [ controls count ]; i++ )
NSRunAlertPanel( [ [ controls objectAtIndex : i ] className ], @"", @"OK", NULL, NULL );
hb_retnl( ( LONG ) wndController );
}
Code: Select all
NSWindowController * mynibWindow = [[NSWindowController alloc] initWithWindowNibName:@"MainMenu"];
[mynibWindow showWindow: nil];
NSWindow * ventana = [mynibWindow window] ;
[ ventana setTitle: @"Hola" ] ;
Code: Select all
#import <Cocoa/Cocoa.h>
#define HB_DONT_DEFINE_BOOL
#include <hbapi.h>
// NSView * GetView( NSWindow * window );
@interface WindowController : NSWindowController
{
}
- ( void ) BtnClick : ( id ) sender;
@end
@implementation WindowController
- ( void ) BtnClick : ( id ) sender;
{
NSRunAlertPanel( @"click", @"", @"OK", NULL, NULL );
}
@end
HB_FUNC( WINDOWCONTROLLERCREATE )
{
NSString * string = [ [ [ NSString alloc ] initWithCString: ISCHAR( 1 ) ? hb_parc( 1 ) : "" ] autorelease ];
WindowController * wndController = [ [ WindowController alloc ] initWithWindowNibName : string ];
NSArray * controls = [ [ [ wndController window ] contentView ] subviews ];
int i;
for( i = 0; i < [ controls count ]; i++ )
{
NSControl * control = [ controls objectAtIndex : i ];
NSString * className = [ control className ];
if( [ className isEqual : @"NSButton" ] )
{
NSButton * button = ( NSButton * ) control;
[ button setAction : @selector( BtnClick: ) ];
}
}
hb_retnl( ( LONG ) wndController );
}
Code: Select all
NSView * myview = [ventana contentView ] ;
[[myview viewWithTag :255 ] setTitle: @"Hola" ] ;
Code: Select all
NSView * myview = [ventana contentView ] ;
[[myview viewWithTag :255 ] setTitle: @"Hola" ] ;
NSButton * boton = ( NSButton * ) [myview viewWithTag :255 ];
[ boton setAction : @selector( BtnClick: ) ];