cocoa-ui-backend - Factor Documentation (original) (raw)
Definition
Methods
USING: accessors alien.c-types cocoa.messages cocoa.runtime
kernel math ui.backend ui.backend.cocoa ;
M: cocoa-ui-backend (close-window)
[
view>> dup { char { id SEL } } "isInFullScreenMode" send
zero?
[ drop ] [
f
{ void { id SEL id } }
"exitFullScreenModeWithOptions:" send
] if
] [ window>> { void { id SEL } } "release" send ] bi ;
USING: accessors alien.c-types cocoa.messages cocoa.runtime
ui.backend.cocoa ui.pixel-formats ;
M: cocoa-ui-backend (free-pixel-format)
handle>> { void { id SEL } } "release" send ;
USING: accessors alien.c-types cocoa.messages cocoa.runtime
kernel math ui.backend ui.backend.cocoa ;
M: cocoa-ui-backend (fullscreen?)
handle>> [
view>> { char { id SEL } } "isInFullScreenMode" send
zero? not
] [ f ] if* ;
USING: accessors alien.c-types cocoa.classes cocoa.messages
cocoa.runtime cocoa.types core-graphics core-graphics.types
kernel math math.rectangles sequences threads ui.backend
ui.backend.cocoa ;
M: cocoa-ui-backend (grab-input)
0 CGAssociateMouseAndMouseCursorPosition drop
CGMainDisplayID CGDisplayHideCursor drop window>>
{ NSRect { id SEL } } "frame" send
CGRect>rect rect-center NSScreen
{ id { id SEL } } "screens" send 0
{ id { id SEL ulong } } "objectAtIndex:" send
{ NSRect { id SEL } } "frame" send CGRect-h
[ drop first ] [ swap second - ] 2bi
[ GetCurrentButtonState zero? not ] [ yield ] while
CGWarpMouseCursorPosition drop ;
USING: alien.c-types cocoa.classes cocoa.messages cocoa.runtime
kernel ui.backend.cocoa ui.pixel-formats ;
M: cocoa-ui-backend (make-pixel-format)
nip { } attrib-table pixel-format-attributes>int-array
NSOpenGLPixelFormat { id { id SEL } } "alloc" send swap
{ id { id SEL void* } } "initWithAttributes:" send ;
USING: accessors alien.c-types cocoa.messages cocoa.runtime
cocoa.windows kernel sequences ui.backend ui.backend.cocoa
ui.backend.cocoa.views ui.gadgets.worlds ui.private ;
M:: cocoa-ui-backend (open-window) ( world -- )
world [ [ dim>> ] dip ] with-world-pixel-format
:> view world window-controls>> textured-background swap
member-eq? [ view make-context-transparent ] when view world
[ world>NSRect ] [ world>styleMask ] bi
:> window view { void { id SEL } } "release" send
world view register-window
window world window-loc>> auto-position
world window save-position window install-window-delegate
view window world handle<< window f
{ void { id SEL id } } "makeKeyAndOrderFront:" send
t world active?<< ;
USING: kernel ui.backend ui.backend.cocoa ;
M: cocoa-ui-backend (set-fullscreen)
[ enter-fullscreen ] [ exit-fullscreen ] if ;
USING: core-graphics kernel ui.backend ui.backend.cocoa ;
M: cocoa-ui-backend (ungrab-input)
drop CGMainDisplayID CGDisplayShowCursor drop
1 CGAssociateMouseAndMouseCursorPosition drop ;
USING: alien.c-types cocoa.application cocoa.messages
cocoa.runtime combinators core-foundation.run-loop io.thread
namespaces ui.backend ui.backend.cocoa ui.private ;
M: cocoa-ui-backend (with-ui)
"UI" assert.app [
init-clipboard cocoa-startup-hook get ( -- ) call-effect
current-theme start-ui
stop-io-thread init-thread-timer reset-thread-timer
NSApp { void { id SEL } } "run" send
] with-cocoa ;
USING: cocoa.application ui ui.backend.cocoa ;
M: cocoa-ui-backend beep NSBeep ;
USING: accessors alien.c-types cocoa.messages cocoa.runtime
kernel ui ui.backend.cocoa ui.gadgets.worlds ;
M: cocoa-ui-backend close-window
find-world [
handle>>
[ window>> { void { id SEL } } "close" send ] when*
] when* ;
USING: accessors alien.c-types cocoa.application cocoa.messages
cocoa.runtime kernel ui.backend ui.backend.cocoa ;
M: cocoa-ui-backend raise-window*
handle>> [
window>> dup f { void { id SEL id } } "orderFront:" send
{ void { id SEL } } "makeKeyWindow" send NSApp 1
{ void { id SEL char } } "activateIgnoringOtherApps:"
send
] when* ;
USING: accessors alien.c-types cocoa.messages cocoa.runtime
cocoa.types core-graphics.types kernel sequences ui
ui.backend.cocoa ;
M: cocoa-ui-backend resize-window
[ handle>> window>> ] [ first2 ] bi*
{ void { id SEL NSSize } } "setContentSize:" send ;
USING: accessors alien.c-types cocoa.application cocoa.messages
cocoa.runtime kernel ui.backend ui.backend.cocoa ;
M: cocoa-ui-backend set-title
handle>> window>> swap
{ void { id SEL id } } "setTitle:" send ;
USING: alien.c-types cocoa.application cocoa.classes
cocoa.messages cocoa.runtime combinators kernel ui
ui.backend.cocoa ;
M: cocoa-ui-backend system-alert
NSAlert { id { id SEL } } "alloc" send
{ id { id SEL } } "init" send
{ id { id SEL } } "autorelease" send [
{
[
swap
{ void { id SEL id } } "setInformativeText:"
send
]
[
swap
{ void { id SEL id } } "setMessageText:" send
]
[
"OK"
{ id { id SEL id } } "addButtonWithTitle:" send
drop
]
[ { long { id SEL } } "runModal" send drop ]
} cleave
] [ 2drop ] if* ;