! Copyright (C) 2006, 2009 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors alien.c-types arrays assocs classes cocoa
-cocoa.application cocoa.classes cocoa.messages cocoa.nibs
+USING: accessors alien.c-types alien.data arrays assocs classes
+cocoa cocoa.application cocoa.classes cocoa.messages cocoa.nibs
cocoa.pasteboard cocoa.runtime cocoa.subclassing cocoa.types
cocoa.views cocoa.windows combinators command-line
core-foundation core-foundation.run-loop core-graphics
core-graphics.types destructors fry generalizations io.thread
-kernel libc literals locals math math.bitwise math.rectangles memory
-namespaces sequences threads ui
-ui.backend ui.backend.cocoa.views ui.clipboards ui.gadgets
+kernel libc literals locals math math.bitwise math.rectangles
+memory namespaces sequences threads ui colors ui.backend
+ui.backend.cocoa.views ui.clipboards ui.gadgets
ui.gadgets.worlds ui.pixel-formats ui.pixel-formats.private
ui.private words.symbol ;
IN: ui.backend.cocoa
M: cocoa-ui-backend (pixel-format-attribute)
[ handle>> ] [ >NSOpenGLPFA ] bi*
[ drop f ]
- [ first 0 <int> [ swap 0 -> getValues:forAttribute:forVirtualScreen: ] keep *int ]
- if-empty ;
-
-M: cocoa-ui-backend system-background-color
- T{ rgba f 0.0 0.0 0.0 0.0 } ; inline
+ [
+ first
+ { int } [ swap 0 -> getValues:forAttribute:forVirtualScreen: ] [ ]
+ with-out-parameters
+ ] if-empty ;
TUPLE: pasteboard handle ;
M:: cocoa-ui-backend (open-window) ( world -- )
world [ [ dim>> ] dip <FactorView> ]
with-world-pixel-format :> view
- world transparent?>> [ view make-context-transparent ] when
+ world window-controls>> textured-background swap member-eq?
+ [ view make-context-transparent ] when
view world [ world>NSRect ] [ world>styleMask ] bi <ViewWindow> :> window
view -> release
world view register-window
window world window-loc>> auto-position
world window save-position
window install-window-delegate
- view window <window-handle> world (>>handle)
+ view window <window-handle> world handle<<
window f -> makeKeyAndOrderFront: ;
M: cocoa-ui-backend (close-window) ( handle -- )
M: cocoa-ui-backend beep ( -- )
NSBeep ;
+M: cocoa-ui-backend system-alert
+ invalidate-run-loop-timers
+ NSAlert -> alloc -> init -> autorelease [
+ {
+ [ swap <NSString> -> setInformativeText: ]
+ [ swap <NSString> -> setMessageText: ]
+ [ "OK" <NSString> -> addButtonWithTitle: drop ]
+ [ -> runModal drop ]
+ } cleave
+ ] [ 2drop ] if*
+ init-thread-timer ;
+
CLASS: {
{ +superclass+ "NSObject" }
{ +name+ "FactorApplicationDelegate" }
}
-{ "applicationDidUpdate:" "void" { "id" "SEL" "id" }
+{ "applicationDidUpdate:" void { id SEL id }
[ 3drop reset-run-loop ]
} ;
: install-app-delegate ( -- )
NSApp FactorApplicationDelegate install-delegate ;
-SYMBOL: cocoa-init-hook
+SYMBOL: cocoa-startup-hook
-cocoa-init-hook [
+cocoa-startup-hook [
[ "MiniFactor.nib" load-nib install-app-delegate ]
] initialize
"UI" assert.app [
[
init-clipboard
- cocoa-init-hook get call( -- )
+ cocoa-startup-hook get call( -- )
start-ui
f io-thread-running? set-global
init-thread-timer