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-ppc
macosx
macosx-sdl
solaris
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:
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
alien/ - C library interface
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,
vectors, hashtables, and operations on them
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
math/ - integers, ratios, floats, complex numbers, vectors, matrices
opengl/ - OpenGL graphics library binding
sdl/ - SDL binding
syntax/ - parser and object prettyprinter
test/ - unit test framework and test suite
tools/ - interactive development tools

View File

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

View File

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

View File

@ -3,7 +3,7 @@
USING: alien arrays cocoa freetype gadgets gadgets-layouts
gadgets-listener kernel namespaces objc objc-NSApplication
objc-NSObject objc-NSOpenGLContext objc-NSOpenGLView objc-NSView
objc-NSWindow opengl threads ;
objc-NSWindow opengl sequences threads walker ;
IN: gadgets-cocoa
! Cocoa backend for Factor UI
@ -56,15 +56,20 @@ USE: objc-FactorView
FactorView [alloc]
0 0 100 100 <NSRect> NSOpenGLView [defaultPixelFormat]
[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
listener-application
ui-title 10 10 600 600 <NSRect> <NSWindow>
dup <FactorView> [setContentView:]
f [makeKeyAndOrderFront:]
event-loop
[
init-world
listener-application
world get ui-title <FactorWindow> drop
event-loop
] with-cocoa
] with-freetype

View File

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