1 ! Copyright (C) 2006 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
4 DEFER: FactorApplicationDelegate
7 USING: arrays gadgets gadgets-listener gadgets-workspace
8 hashtables kernel memory namespaces objc sequences errors freetype ;
10 : finder-run-files ( alien -- )
11 #! We filter out the image name since that might be there on
13 CF>string-array [ image = not ] subset listener-run-files
14 NSApp NSApplicationDelegateReplySuccess
15 -> replyToOpenOrPrint: ;
17 ! Handle Open events from the Finder
18 "NSObject" "FactorApplicationDelegate" {
19 { "application:openFiles:" "void" { "id" "SEL" "id" "id" }
20 [ >r 3drop r> finder-run-files ]
24 : install-app-delegate ( -- )
25 NSApp FactorApplicationDelegate install-delegate ;
35 dup world-loc first2 rot rect-dim first2 <NSRect> ;
37 : gadget-window ( world -- )
40 dup rot rect>NSRect <ViewWindow>
41 dup install-window-delegate
44 ] keep set-world-handle ;
48 : set-title ( string world -- )
49 world-handle second swap <NSString> -> setTitle: ;
51 : open-window* ( world -- )
54 world-handle second f -> makeKeyAndOrderFront: ;
56 : raise-window ( world -- )
57 world-handle second dup f -> orderFront: -> makeKeyWindow ;
59 : select-gl-context ( handle -- )
60 first -> openGLContext -> makeCurrentContext ;
62 : flush-gl-context ( handle -- )
63 first -> openGLContext -> flushBuffer ;
65 : running.app? ( -- ? )
66 #! Test if we're running Factor.app.
68 NSBundle -> mainBundle -> bundlePath CF>string
75 "The Factor UI requires you to run the supplied Factor.app." throw
95 : default-shell running.app? "ui" "tty" ? ;