factor/library/cocoa/ui.factor

71 lines
1.6 KiB
Factor
Raw Normal View History

2006-03-12 23:21:01 -05:00
! Copyright (C) 2006 Slava Pestov.
2006-03-17 02:50:16 -05:00
! See http://factorcode.org/license.txt for BSD license.
IN: objc-FactorApplicationDelegate
2006-03-21 01:43:03 -05:00
DEFER: FactorApplicationDelegate
2006-03-14 21:09:25 -05:00
IN: cocoa
2006-05-24 19:34:30 -04:00
USING: gadgets gadgets-listener kernel objc objc-NSApplication
objc-NSObject ;
2006-03-17 02:50:16 -05:00
: finder-run-files ( alien -- )
CF>string-array listener-run-files
NSApp NSApplicationDelegateReplySuccess
[replyToOpenOrPrint:] ;
2006-03-12 23:21:01 -05:00
! Handle Open events from the Finder
"NSObject" "FactorApplicationDelegate" {
{ "application:openFiles:" "void" { "id" "SEL" "id" "id" }
[ >r 3drop r> finder-run-files ]
}
} { } define-objc-class
: install-app-delegate ( -- )
NSApp
FactorApplicationDelegate [alloc] [init] [setDelegate:] ;
2006-05-24 19:34:30 -04:00
: init-cocoa-ui ( -- )
reset-views
reset-callbacks
init-ui
install-app-delegate
register-services
default-main-menu ;
2006-03-18 02:23:57 -05:00
IN: gadgets
2006-05-24 19:34:30 -04:00
USING: errors freetype objc-NSOpenGLContext
objc-NSOpenGLView objc-NSView objc-NSWindow ;
2006-03-18 02:23:57 -05:00
: redraw-world ( handle -- )
world-handle 1 [setNeedsDisplay:] ;
2006-03-18 02:23:57 -05:00
2006-03-24 22:58:03 -05:00
: open-window* ( world title -- )
>r <FactorView> r> <ViewWindow>
dup install-window-delegate
[contentView] [release] ;
2006-03-18 02:23:57 -05:00
: select-gl-context ( handle -- )
[openGLContext] [makeCurrentContext] ;
: flush-gl-context ( handle -- )
[openGLContext] [flushBuffer] ;
IN: shells
2006-03-15 00:57:02 -05:00
2006-03-14 21:09:25 -05:00
: ui
2006-03-19 15:43:40 -05:00
running.app? [
"The Factor UI requires you to run the supplied Factor.app." throw
] unless
2006-03-13 00:41:59 -05:00
[
2006-03-14 21:09:25 -05:00
[
2006-05-24 19:34:30 -04:00
init-cocoa-ui
2006-03-18 02:23:57 -05:00
listener-window
2006-03-17 02:50:16 -05:00
finish-launching
2006-03-14 21:09:25 -05:00
event-loop
] with-cocoa
] with-freetype ;
2006-03-19 18:00:07 -05:00
IN: kernel
: default-shell running.app? "ui" "tty" ? ;