]> gitweb.factorcode.org Git - factor.git/blob - basis/cocoa/windows/windows.factor
use radix literals
[factor.git] / basis / cocoa / windows / windows.factor
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 ;
5 IN: cocoa.windows
6
7 ! Window styles
8 CONSTANT: NSBorderlessWindowMask           0
9 CONSTANT: NSTitledWindowMask               1
10 CONSTANT: NSClosableWindowMask             2
11 CONSTANT: NSMiniaturizableWindowMask       4
12 CONSTANT: NSResizableWindowMask            8
13 CONSTANT: NSTexturedBackgroundWindowMask 256
14
15 ! Additional panel-only styles 
16 CONSTANT: NSUtilityWindowMask       16
17 CONSTANT: NSDocModalWindowMask      64
18 CONSTANT: NSNonactivatingPanelMask 128
19 CONSTANT: NSHUDWindowMask    0x1000
20
21 CONSTANT: NSBackingStoreRetained    0
22 CONSTANT: NSBackingStoreNonretained 1
23 CONSTANT: NSBackingStoreBuffered    2
24
25 : <NSWindow> ( rect style class -- window )
26     [ -> alloc ] curry 2dip NSBackingStoreBuffered 1
27     -> initWithContentRect:styleMask:backing:defer: ;
28
29 : class-for-style ( style -- NSWindow/NSPanel )
30     0x1ef0 bitand zero? NSWindow NSPanel ? ;
31
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: ;
37
38 : window-content-rect ( window -- rect )
39     dup -> class swap
40     [ -> frame ] [ -> styleMask ] bi
41     -> contentRectForFrameRect:styleMask: ;