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 ;
34 dup world-loc first2 rot rect-dim first2 <NSRect> ;
36 : gadget-window ( world -- )
39 dup rot rect>NSRect <ViewWindow>
40 dup install-window-delegate
43 ] keep set-world-handle ;
47 : set-title ( string world -- )
48 world-handle second swap <NSString> -> setTitle: ;
50 : open-window* ( world -- )
53 world-handle second f -> makeKeyAndOrderFront: ;
55 : raise-window ( world -- )
56 world-handle second dup f -> orderFront: -> makeKeyWindow ;
58 : select-gl-context ( handle -- )
59 first -> openGLContext -> makeCurrentContext ;
61 : flush-gl-context ( handle -- )
62 first -> openGLContext -> flushBuffer ;
64 : running.app? ( -- ? )
65 #! Test if we're running Factor.app.
67 NSBundle -> mainBundle -> bundlePath CF>string
74 "The Factor UI requires you to run the supplied Factor.app." throw
94 : default-shell running.app? "ui" "tty" ? ;