1 ! Copyright (C) 2006, 2007 Slava Pestov
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: arrays kernel math cocoa cocoa.messages cocoa.classes
4 sequences math.bitwise ;
8 CONSTANT: NSBorderlessWindowMask 0
9 CONSTANT: NSTitledWindowMask 1
10 CONSTANT: NSClosableWindowMask 2
11 CONSTANT: NSMiniaturizableWindowMask 4
12 CONSTANT: NSResizableWindowMask 8
13 CONSTANT: NSTexturedBackgroundWindowMask 256
15 ! Additional panel-only styles
16 CONSTANT: NSUtilityWindowMask 16
17 CONSTANT: NSDocModalWindowMask 64
18 CONSTANT: NSNonactivatingPanelMask 128
19 CONSTANT: NSHUDWindowMask 0x1000
21 CONSTANT: NSBackingStoreRetained 0
22 CONSTANT: NSBackingStoreNonretained 1
23 CONSTANT: NSBackingStoreBuffered 2
25 : <NSWindow> ( rect style class -- window )
26 [ -> alloc ] curry 2dip NSBackingStoreBuffered 1
27 -> initWithContentRect:styleMask:backing:defer: ;
29 : class-for-style ( style -- NSWindow/NSPanel )
30 0x1ef0 bitand zero? NSWindow NSPanel ? ;
32 : <ViewWindow> ( view rect style -- window )
33 dup class-for-style <NSWindow> [ swap -> setContentView: ] keep
34 dup dup -> contentView -> setInitialFirstResponder:
35 dup 1 -> setAcceptsMouseMovedEvents:
36 dup 0 -> setReleasedWhenClosed: ;
38 : window-content-rect ( window -- rect )
40 [ -> frame ] [ -> styleMask ] bi
41 -> contentRectForFrameRect:styleMask: ;