Cocoa fixes

release
slava 2006-03-13 05:41:59 +00:00
parent e3baeed782
commit 60945fa05e
5 changed files with 27 additions and 19 deletions

View File

@ -39,13 +39,9 @@ parameters to build the Factor runtime:
linux linux
linux-ppc linux-ppc
macosx macosx
macosx-sdl
solaris solaris
windows windows
Note: If you wish to use the Factor UI on Mac OS X, you must build with
the macosx-sdl target.
The following options can be given to make: The following options can be given to make:
SITE_CFLAGS="..." SITE_CFLAGS="..."
@ -127,6 +123,7 @@ as, and issue a command similar to the following to bootstrap Factor:
library/ - sources for the library, written in Factor library/ - sources for the library, written in Factor
alien/ - C library interface alien/ - C library interface
bootstrap/ - code for generating boot images bootstrap/ - code for generating boot images
cocoa/ - Mac OS X Cocoa API and Objective-C runtime binding
collections/ - data types including but not limited to lists, collections/ - data types including but not limited to lists,
vectors, hashtables, and operations on them vectors, hashtables, and operations on them
compiler/ - optimizing native compiler compiler/ - optimizing native compiler
@ -138,7 +135,6 @@ as, and issue a command similar to the following to bootstrap Factor:
io/ - input and output streams io/ - input and output streams
math/ - integers, ratios, floats, complex numbers, vectors, matrices math/ - integers, ratios, floats, complex numbers, vectors, matrices
opengl/ - OpenGL graphics library binding opengl/ - OpenGL graphics library binding
sdl/ - SDL binding
syntax/ - parser and object prettyprinter syntax/ - parser and object prettyprinter
test/ - unit test framework and test suite test/ - unit test framework and test suite
tools/ - interactive development tools tools/ - interactive development tools

View File

@ -8,6 +8,12 @@ objc-NSObject objc-NSView threads ;
: with-autorelease-pool ( quot -- ) : with-autorelease-pool ( quot -- )
NSAutoreleasePool [new] slip [release] ; inline NSAutoreleasePool [new] slip [release] ; inline
: with-cocoa ( quot -- )
[
NSApplication [sharedApplication] drop
call
] with-autorelease-pool ; inline
: <NSString> <CFString> [autorelease] ; : <NSString> <CFString> [autorelease] ;
: CFRunLoopDefaultMode "kCFRunLoopDefaultMode" <NSString> ; : CFRunLoopDefaultMode "kCFRunLoopDefaultMode" <NSString> ;

View File

@ -69,6 +69,7 @@ libc math namespaces sequences strings ;
objc_addClass ; objc_addClass ;
: define-objc-class ( superclass name imeth cmeth -- ) : define-objc-class ( superclass name imeth cmeth -- )
2swap dup class-exists? 2swap [
[ [ 2drop 2drop ] [ (define-objc-class) ] if ] keep dup class-exists?
import-objc-class ; [ 2drop 2drop ] [ (define-objc-class) ] if
] keep import-objc-class ;

View File

@ -3,7 +3,7 @@
USING: alien arrays cocoa freetype gadgets gadgets-layouts USING: alien arrays cocoa freetype gadgets gadgets-layouts
gadgets-listener kernel namespaces objc objc-NSApplication gadgets-listener kernel namespaces objc objc-NSApplication
objc-NSObject objc-NSOpenGLContext objc-NSOpenGLView objc-NSView objc-NSObject objc-NSOpenGLContext objc-NSOpenGLView objc-NSView
objc-NSWindow opengl threads ; objc-NSWindow opengl sequences threads walker ;
IN: gadgets-cocoa IN: gadgets-cocoa
! Cocoa backend for Factor UI ! Cocoa backend for Factor UI
@ -56,15 +56,20 @@ USE: objc-FactorView
FactorView [alloc] FactorView [alloc]
0 0 100 100 <NSRect> NSOpenGLView [defaultPixelFormat] 0 0 100 100 <NSRect> NSOpenGLView [defaultPixelFormat]
[initWithFrame:pixelFormat:] [initWithFrame:pixelFormat:]
over set-world-handle ; [ swap set-world-handle ] keep ;
: <FactorWindow> ( gadget title -- window )
over rect-dim first2 0 0 2swap <NSRect> <NSWindow>
[ swap <FactorView> [setContentView:] ] keep
dup f [makeKeyAndOrderFront:] ;
[
[ [
init-world init-world
listener-application listener-application
ui-title 10 10 600 600 <NSRect> <NSWindow> world get ui-title <FactorWindow> drop
dup <FactorView> [setContentView:]
f [makeKeyAndOrderFront:]
event-loop event-loop
] with-cocoa
] with-freetype ] with-freetype

View File

@ -90,7 +90,7 @@ M: f set-message 2drop ;
: world-step ( -- ) : world-step ( -- )
do-timers do-timers
world get world-invalid >r layout-world r> world get world-invalid >r layout-world r>
[ update-hand redraw-world ] when ; [ update-hand world get redraw-world ] when ;
SYMBOL: first-time SYMBOL: first-time