]> gitweb.factorcode.org Git - factor.git/commitdiff
Move core-graphics types from cocoa.types to core-graphics.types, clean up some code
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 19 Jan 2009 22:29:52 +0000 (16:29 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Mon, 19 Jan 2009 22:29:52 +0000 (16:29 -0600)
15 files changed:
basis/cocoa/cocoa-docs.factor
basis/cocoa/types/types.factor
basis/cocoa/views/views.factor
basis/core-foundation/strings/strings.factor
basis/core-graphics/core-graphics.factor
basis/core-graphics/types/authors.txt [new file with mode: 0644]
basis/core-graphics/types/types-docs.factor [new file with mode: 0644]
basis/core-graphics/types/types-tests.factor [new file with mode: 0644]
basis/core-graphics/types/types.factor [new file with mode: 0644]
basis/core-text/core-text.factor
basis/ui/cocoa/cocoa.factor
basis/ui/cocoa/views/views.factor
basis/ui/freetype/freetype-docs.factor
basis/ui/gadgets/worlds/worlds-docs.factor
basis/ui/tools/operations/operations.factor

index dd8d331b35f2f13a3c174f19549c7560e29cb030..17621dc6348ac760190152ebda376e7d7e7131fb 100644 (file)
@@ -44,7 +44,6 @@ $nl
 { $subsection "objc-calling" }
 { $subsection "objc-subclassing" }
 "A utility library is built to faciliate the development of Cocoa applications in Factor:"
-{ $subsection "cocoa-types" }
 { $subsection "cocoa-application-utils" }
 { $subsection "cocoa-dialogs" }
 { $subsection "cocoa-pasteboard-utils" }
index a76e74d9aabaeeaa02fbe024136261c89dd14404..6e03a21bbca5bc8da847e85cacbeabe50e585448 100644 (file)
@@ -1,73 +1,20 @@
-! Copyright (C) 2006, 2007 Slava Pestov
+! Copyright (C) 2006, 2009 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.c-types alien.syntax combinators kernel ;
+USING: alien.c-types alien.syntax combinators kernel layouts
+core-graphics.types ;
 IN: cocoa.types
 
 TYPEDEF: long NSInteger
 TYPEDEF: ulong NSUInteger
-<< "ptrdiff_t" heap-size {
-    { 4 [ "float" ] }
-    { 8 [ "double" ] }
-} case "CGFloat" typedef >>
-
-C-STRUCT: NSPoint
-    { "CGFloat" "x" }
-    { "CGFloat" "y" } ;
 
+TYPEDEF: CGPoint NSPoint
 TYPEDEF: NSPoint _NSPoint
-TYPEDEF: NSPoint CGPoint
-
-: <NSPoint> ( x y -- point )
-    "NSPoint" <c-object>
-    [ set-NSPoint-y ] keep
-    [ set-NSPoint-x ] keep ;
-
-C-STRUCT: NSSize
-    { "CGFloat" "w" }
-    { "CGFloat" "h" } ;
 
+TYPEDEF: CGSize NSSize
 TYPEDEF: NSSize _NSSize
-TYPEDEF: NSSize CGSize
-
-: <NSSize> ( w h -- size )
-    "NSSize" <c-object>
-    [ set-NSSize-h ] keep
-    [ set-NSSize-w ] keep ;
-
-C-STRUCT: NSRect
-    { "NSPoint" "origin" }
-    { "NSSize"  "size"   } ;
 
+TYPEDEF: CGRect NSRect
 TYPEDEF: NSRect _NSRect
-TYPEDEF: NSRect CGRect
-
-: NSRect-x ( NSRect -- x )
-    NSRect-origin NSPoint-x ; inline
-: NSRect-y ( NSRect -- y )
-    NSRect-origin NSPoint-y ; inline
-: NSRect-w ( NSRect -- w )
-    NSRect-size NSSize-w ; inline
-: NSRect-h ( NSRect -- h )
-    NSRect-size NSSize-h ; inline
-
-: set-NSRect-x ( x NSRect -- )
-    NSRect-origin set-NSPoint-x ; inline
-: set-NSRect-y ( y NSRect -- )
-    NSRect-origin set-NSPoint-y ; inline
-: set-NSRect-w ( w NSRect -- )
-    NSRect-size set-NSSize-w ; inline
-: set-NSRect-h ( h NSRect -- )
-    NSRect-size set-NSSize-h ; inline
-
-: <NSRect> ( x y w h -- rect )
-    "NSRect" <c-object>
-    [ set-NSRect-h ] keep
-    [ set-NSRect-w ] keep
-    [ set-NSRect-y ] keep
-    [ set-NSRect-x ] keep ;
-
-: NSRect-x-y ( alien -- origin-x origin-y )
-    [ NSRect-x ] keep NSRect-y ;
 
 C-STRUCT: NSRange
     { "NSUInteger" "location" }
@@ -85,14 +32,6 @@ TYPEDEF: void* unknown_type
     [ set-NSRange-length ] keep
     [ set-NSRange-location ] keep ;
 
-C-STRUCT: CGAffineTransform
-    { "CGFloat" "a" }
-    { "CGFloat" "b" }
-    { "CGFloat" "c" }
-    { "CGFloat" "d" }
-    { "CGFloat" "tx" }
-    { "CGFloat" "ty" } ;
-
 C-STRUCT: NSFastEnumerationState
     { "ulong" "state" }
     { "id*" "itemsPtr" }
index 03cafd0a0a895bd414a1ce9d57459d6946ca6440..4e3e55fdad37102c116a9dd229c0837bf46f4554 100644 (file)
@@ -1,68 +1,72 @@
-! Copyright (C) 2006, 2008 Slava Pestov
+! Copyright (C) 2006, 2009 Slava Pestov
 ! See http://factorcode.org/license.txt for BSD license.
 USING: specialized-arrays.int arrays kernel math namespaces make
-cocoa cocoa.messages cocoa.classes cocoa.types sequences
+cocoa cocoa.messages cocoa.classes core-graphics.types sequences
 continuations accessors ;
 IN: cocoa.views
 
-: NSOpenGLPFAAllRenderers 1 ;
-: NSOpenGLPFADoubleBuffer 5 ;
-: NSOpenGLPFAStereo 6 ;
-: NSOpenGLPFAAuxBuffers 7 ;
-: NSOpenGLPFAColorSize 8 ;
-: NSOpenGLPFAAlphaSize 11 ;
-: NSOpenGLPFADepthSize 12 ;
-: NSOpenGLPFAStencilSize 13 ;
-: NSOpenGLPFAAccumSize 14 ;
-: NSOpenGLPFAMinimumPolicy 51 ;
-: NSOpenGLPFAMaximumPolicy 52 ;
-: NSOpenGLPFAOffScreen 53 ;
-: NSOpenGLPFAFullScreen 54 ;
-: NSOpenGLPFASampleBuffers 55 ;
-: NSOpenGLPFASamples 56 ;
-: NSOpenGLPFAAuxDepthStencil 57 ;
-: NSOpenGLPFAColorFloat  58 ;
-: NSOpenGLPFAMultisample 59 ;
-: NSOpenGLPFASupersample 60 ;
-: NSOpenGLPFASampleAlpha 61 ;
-: NSOpenGLPFARendererID 70 ;
-: NSOpenGLPFASingleRenderer 71 ;
-: NSOpenGLPFANoRecovery 72 ;
-: NSOpenGLPFAAccelerated 73 ;
-: NSOpenGLPFAClosestPolicy 74 ;
-: NSOpenGLPFARobust 75 ;
-: NSOpenGLPFABackingStore 76 ;
-: NSOpenGLPFAMPSafe 78 ;
-: NSOpenGLPFAWindow 80 ;
-: NSOpenGLPFAMultiScreen 81 ;
-: NSOpenGLPFACompliant 83 ;
-: NSOpenGLPFAScreenMask 84 ;
-: NSOpenGLPFAPixelBuffer 90 ;
-: NSOpenGLPFAAllowOfflineRenderers 96 ;
-: NSOpenGLPFAVirtualScreenCount 128 ;
-
-: kCGLRendererGenericFloatID HEX: 00020400 ;
+CONSTANT: NSOpenGLPFAAllRenderers 1
+CONSTANT: NSOpenGLPFADoubleBuffer 5
+CONSTANT: NSOpenGLPFAStereo 6
+CONSTANT: NSOpenGLPFAAuxBuffers 7
+CONSTANT: NSOpenGLPFAColorSize 8
+CONSTANT: NSOpenGLPFAAlphaSize 11
+CONSTANT: NSOpenGLPFADepthSize 12
+CONSTANT: NSOpenGLPFAStencilSize 13
+CONSTANT: NSOpenGLPFAAccumSize 14
+CONSTANT: NSOpenGLPFAMinimumPolicy 51
+CONSTANT: NSOpenGLPFAMaximumPolicy 52
+CONSTANT: NSOpenGLPFAOffScreen 53
+CONSTANT: NSOpenGLPFAFullScreen 54
+CONSTANT: NSOpenGLPFASampleBuffers 55
+CONSTANT: NSOpenGLPFASamples 56
+CONSTANT: NSOpenGLPFAAuxDepthStencil 57
+CONSTANT: NSOpenGLPFAColorFloat  58
+CONSTANT: NSOpenGLPFAMultisample 59
+CONSTANT: NSOpenGLPFASupersample 60
+CONSTANT: NSOpenGLPFASampleAlpha 61
+CONSTANT: NSOpenGLPFARendererID 70
+CONSTANT: NSOpenGLPFASingleRenderer 71
+CONSTANT: NSOpenGLPFANoRecovery 72
+CONSTANT: NSOpenGLPFAAccelerated 73
+CONSTANT: NSOpenGLPFAClosestPolicy 74
+CONSTANT: NSOpenGLPFARobust 75
+CONSTANT: NSOpenGLPFABackingStore 76
+CONSTANT: NSOpenGLPFAMPSafe 78
+CONSTANT: NSOpenGLPFAWindow 80
+CONSTANT: NSOpenGLPFAMultiScreen 81
+CONSTANT: NSOpenGLPFACompliant 83
+CONSTANT: NSOpenGLPFAScreenMask 84
+CONSTANT: NSOpenGLPFAPixelBuffer 90
+CONSTANT: NSOpenGLPFAAllowOfflineRenderers 96
+CONSTANT: NSOpenGLPFAVirtualScreenCount 128
+
+CONSTANT: kCGLRendererGenericFloatID HEX: 00020400
+
+
+CONSTANT: NSOpenGLCPSwapInterval 222
 
 <PRIVATE
 
-SYMBOL: +software-renderer+
-SYMBOL: +multisample+
+SYMBOL: software-renderer?
+SYMBOL: multisample?
 
 PRIVATE>
 
 : with-software-renderer ( quot -- )
-    t +software-renderer+ pick with-variable ; inline
+    [ t software-renderer? ] dip with-variable ; inline
+
 : with-multisample ( quot -- )
-    t +multisample+ pick with-variable ; inline
+    [ t multisample? ] dip with-variable ; inline
 
 : <PixelFormat> ( attributes -- pixelfmt )
     NSOpenGLPixelFormat -> alloc swap [
         %
         NSOpenGLPFADepthSize , 16 ,
-        +software-renderer+ get [
+        software-renderer? get [
             NSOpenGLPFARendererID , kCGLRendererGenericFloatID ,
         ] when
-        +multisample+ get [
+        multisample? get [
             NSOpenGLPFASupersample ,
             NSOpenGLPFASampleBuffers , 1 ,
             NSOpenGLPFASamples , 8 ,
@@ -73,7 +77,7 @@ PRIVATE>
     -> autorelease ;
 
 : <GLView> ( class dim -- view )
-    [ -> alloc 0 0 ] dip first2 <NSRect>
+    [ -> alloc 0 0 ] dip first2 <CGRect>
     NSOpenGLPFAWindow NSOpenGLPFADoubleBuffer 2array <PixelFormat>
     -> initWithFrame:pixelFormat:
     dup 1 -> setPostsBoundsChangedNotifications:
@@ -81,26 +85,12 @@ PRIVATE>
 
 : view-dim ( view -- dim )
     -> bounds
-    dup NSRect-w >fixnum
-    swap NSRect-h >fixnum 2array ;
+    [ CGRect-w >fixnum ] [ CGRect-h >fixnum ] bi
+    2array ;
 
 : mouse-location ( view event -- loc )
     [
         -> locationInWindow f -> convertPoint:fromView:
-        [ NSPoint-x ] [ NSPoint-y ] bi
-    ] [ drop -> frame NSRect-h ] 2bi
+        [ CGPoint-x ] [ CGPoint-y ] bi
+    ] [ drop -> frame CGRect-h ] 2bi
     swap - 2array ;
-
-USE: opengl.gl
-USE: alien.syntax
-
-: NSOpenGLCPSwapInterval 222 ;
-
-LIBRARY: OpenGL
-
-TYPEDEF: int CGLError
-TYPEDEF: void* CGLContextObj
-TYPEDEF: int CGLContextParameter
-
-FUNCTION: CGLError CGLSetParameter ( CGLContextObj ctx, CGLContextParameter pname, GLint* params ) ;
-
index c3a969a32561d8a0a5a11fba39764a2133288604..a238616ff0786929bf65f167502763fa3379e59f 100644 (file)
@@ -1,26 +1,27 @@
-! Copyright (C) 2008 Slava Pestov.
+! Copyright (C) 2008, 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
 USING: alien.syntax alien.strings kernel sequences byte-arrays
-io.encodings.utf8 math core-foundation core-foundation.arrays ;
+io.encodings.utf8 math core-foundation core-foundation.arrays
+destructors ;
 IN: core-foundation.strings
 
 TYPEDEF: void* CFStringRef
 
 TYPEDEF: int CFStringEncoding
-: kCFStringEncodingMacRoman HEX: 0 ;
-: kCFStringEncodingWindowsLatin1 HEX: 0500 ;
-: kCFStringEncodingISOLatin1 HEX: 0201 ;
-: kCFStringEncodingNextStepLatin HEX: 0B01 ;
-: kCFStringEncodingASCII HEX: 0600 ;
-: kCFStringEncodingUnicode HEX: 0100 ;
-: kCFStringEncodingUTF8 HEX: 08000100 ;
-: kCFStringEncodingNonLossyASCII HEX: 0BFF ;
-: kCFStringEncodingUTF16 HEX: 0100 ;
-: kCFStringEncodingUTF16BE HEX: 10000100 ;
-: kCFStringEncodingUTF16LE HEX: 14000100 ;
-: kCFStringEncodingUTF32 HEX: 0c000100 ;
-: kCFStringEncodingUTF32BE HEX: 18000100 ;
-: kCFStringEncodingUTF32LE HEX: 1c000100 ;
+CONSTANT: kCFStringEncodingMacRoman HEX: 0
+CONSTANT: kCFStringEncodingWindowsLatin1 HEX: 0500
+CONSTANT: kCFStringEncodingISOLatin1 HEX: 0201
+CONSTANT: kCFStringEncodingNextStepLatin HEX: 0B01
+CONSTANT: kCFStringEncodingASCII HEX: 0600
+CONSTANT: kCFStringEncodingUnicode HEX: 0100
+CONSTANT: kCFStringEncodingUTF8 HEX: 08000100
+CONSTANT: kCFStringEncodingNonLossyASCII HEX: 0BFF
+CONSTANT: kCFStringEncodingUTF16 HEX: 0100
+CONSTANT: kCFStringEncodingUTF16BE HEX: 10000100
+CONSTANT: kCFStringEncodingUTF16LE HEX: 14000100
+CONSTANT: kCFStringEncodingUTF32 HEX: 0c000100
+CONSTANT: kCFStringEncodingUTF32BE HEX: 18000100
+CONSTANT: kCFStringEncodingUTF32LE HEX: 1c000100
 
 FUNCTION: CFStringRef CFStringCreateWithBytes (
     CFAllocatorRef alloc,
@@ -63,4 +64,4 @@ FUNCTION: CFStringRef CFStringCreateWithCString (
     CF>array [ CF>string ] map ;
 
 : <CFStringArray> ( seq -- alien )
-    [ <CFString> ] map [ <CFArray> ] [ [ CFRelease ] each ] bi ;
+    [ [ <CFString> &CFRelease ] map <CFArray> ] with-destructors ;
index ce3b0f967e09db66b3645600f4caa24ad43684aa..11b942357195b0a50638e06f8a57555d8f734a4f 100644 (file)
@@ -1,12 +1,10 @@
 ! Copyright (C) 2009 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: alien.syntax alien.c-types alien.destructors math
-locals fry sequences destructors kernel ;
+USING: alien.c-types alien.destructors alien.syntax
+destructors fry kernel locals math sequences
+core-graphics.types ;
 IN: core-graphics
 
-TYPEDEF: void* CGColorSpaceRef
-TYPEDEF: void* CGContextRef
-
 ! CGImageAlphaInfo
 C-ENUM:
 kCGImageAlphaNone
@@ -27,8 +25,6 @@ kCGImageAlphaNoneSkipFirst ;
 : kCGBitmapByteOrder16Big ( -- n ) 3 12 shift ; inline
 : kCGBitmapByteOrder32Big ( -- n ) 4 12 shift ; inline
 
-TYPEDEF: uint CGBitmapInfo
-    
 FUNCTION: CGColorSpaceRef CGColorSpaceCreateDeviceRGB ( ) ;
 
 FUNCTION: CGContextRef CGBitmapContextCreate (
@@ -71,6 +67,8 @@ FUNCTION: void CGContextSetTextPosition (
    CGFloat y
 ) ;
 
+FUNCTION: CGLError CGLSetParameter ( CGLContextObj ctx, CGLContextParameter pname, GLint* params ) ;
+
 :: <CGBitmapContext> ( data w h -- context )
     [
         data w h 8 w 4 *
@@ -82,4 +80,4 @@ FUNCTION: void CGContextSetTextPosition (
     '[
         [ * "uint" <c-array> ] 2keep
         [ <CGBitmapContext> &CGContextRelease @ ] [ 2drop ] 3bi
-    ] with-destructors ; inline
\ No newline at end of file
+    ] with-destructors ; inline
diff --git a/basis/core-graphics/types/authors.txt b/basis/core-graphics/types/authors.txt
new file mode 100644 (file)
index 0000000..d4f5d6b
--- /dev/null
@@ -0,0 +1 @@
+Slava Pestov
\ No newline at end of file
diff --git a/basis/core-graphics/types/types-docs.factor b/basis/core-graphics/types/types-docs.factor
new file mode 100644 (file)
index 0000000..e35c81d
--- /dev/null
@@ -0,0 +1,29 @@
+USING: math help.markup help.syntax ;
+IN: core-graphics.types
+
+HELP: <CGRect>
+{ $values { "x" real } { "y" real } { "w" real } { "h" real } { "rect" "an " { $snippet "CGRect" } } }
+{ $description "Allocates a new " { $snippet "CGRect" } " in the Factor heap." } ;
+
+HELP: <CGPoint>
+{ $values { "x" real } { "y" real } { "point" "an " { $snippet "CGPoint" } } }
+{ $description "Allocates a new " { $snippet "CGPoint" } " in the Factor heap." } ;
+
+HELP: <CGSize>
+{ $values { "w" real } { "h" real } { "size" "an " { $snippet "CGSize" } } }
+{ $description "Allocates a new " { $snippet "CGSize" } " in the Factor heap." } ;
+
+ARTICLE: "core-graphics.types" "Core Graphics types"
+"The Core Graphics binding defines some common C structs:"
+{ $code
+    "CGRect"
+    "CGPoint"
+    "CGSize"
+}
+"Some words for working with the above:"
+{ $subsection <CGRect> }
+{ $subsection <CGPoint> }
+{ $subsection <CGSize> } ;
+
+IN: core-graphics.types
+ABOUT: "core-graphics.types"
diff --git a/basis/core-graphics/types/types-tests.factor b/basis/core-graphics/types/types-tests.factor
new file mode 100644 (file)
index 0000000..d3b081f
--- /dev/null
@@ -0,0 +1,4 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test core-graphics.types ;
+IN: core-graphics.types.tests
diff --git a/basis/core-graphics/types/types.factor b/basis/core-graphics/types/types.factor
new file mode 100644 (file)
index 0000000..e2672ee
--- /dev/null
@@ -0,0 +1,75 @@
+! Copyright (C) 2009 Slava Pestov.
+! See http://factorcode.org/license.txt for BSD license.
+USING: alien.c-types alien.syntax kernel layouts ;
+IN: core-graphics.types
+
+<< cell 4 = "float" "double" ? "CGFloat" typedef >>
+
+: <CGFloat> ( x -- alien )
+    cell 4 = [ <float> ] [ <double> ] if ; inline
+
+C-STRUCT: CGPoint
+    { "CGFloat" "x" }
+    { "CGFloat" "y" } ;
+
+: <CGPoint> ( x y -- point )
+    "CGPoint" <c-object>
+    [ set-CGPoint-y ] keep
+    [ set-CGPoint-x ] keep ;
+
+C-STRUCT: CGSize
+    { "CGFloat" "w" }
+    { "CGFloat" "h" } ;
+
+: <CGSize> ( w h -- size )
+    "CGSize" <c-object>
+    [ set-CGSize-h ] keep
+    [ set-CGSize-w ] keep ;
+
+C-STRUCT: CGRect
+    { "CGPoint" "origin" }
+    { "CGSize"  "size"   } ;
+
+: CGRect-x ( CGRect -- x )
+    CGRect-origin CGPoint-x ; inline
+: CGRect-y ( CGRect -- y )
+    CGRect-origin CGPoint-y ; inline
+: CGRect-w ( CGRect -- w )
+    CGRect-size CGSize-w ; inline
+: CGRect-h ( CGRect -- h )
+    CGRect-size CGSize-h ; inline
+
+: set-CGRect-x ( x CGRect -- )
+    CGRect-origin set-CGPoint-x ; inline
+: set-CGRect-y ( y CGRect -- )
+    CGRect-origin set-CGPoint-y ; inline
+: set-CGRect-w ( w CGRect -- )
+    CGRect-size set-CGSize-w ; inline
+: set-CGRect-h ( h CGRect -- )
+    CGRect-size set-CGSize-h ; inline
+
+: <CGRect> ( x y w h -- rect )
+    "CGRect" <c-object>
+    [ set-CGRect-h ] keep
+    [ set-CGRect-w ] keep
+    [ set-CGRect-y ] keep
+    [ set-CGRect-x ] keep ;
+
+: CGRect-x-y ( alien -- origin-x origin-y )
+    [ CGRect-x ] keep CGRect-y ;
+
+C-STRUCT: CGAffineTransform
+    { "CGFloat" "a" }
+    { "CGFloat" "b" }
+    { "CGFloat" "c" }
+    { "CGFloat" "d" }
+    { "CGFloat" "tx" }
+    { "CGFloat" "ty" } ;
+
+TYPEDEF: void* CGColorSpaceRef
+TYPEDEF: void* CGContextRef
+TYPEDEF: uint CGBitmapInfo
+
+TYPEDEF: int CGLError
+TYPEDEF: void* CGLContextObj
+TYPEDEF: int CGLContextParameter
\ No newline at end of file
index f75e972fb58b1315a2496e91781c665789882821..e3ac79992eba92c556e734b5f77b45d21e16c778 100644 (file)
@@ -41,3 +41,11 @@ C-GLOBAL: kCTGlyphInfoAttributeName
 FUNCTION: CTLineRef CTLineCreateWithAttributedString ( CFAttributedStringRef string ) ;
 
 FUNCTION: void CTLineDraw ( CTLineRef line, CGContextRef context ) ;
+
+FUNCTION: CGFloat CTLineGetOffsetForStringIndex ( CTLineRef line, CFIndex charIndex, CGFloat* secondaryOffset ) ;
+
+FUNCTION: CFIndex CTLineGetStringIndexForPosition ( CTLineRef line, CGPoint position ) ;
+
+FUNCTION: double CTLineGetTypographicBounds ( CTLineRef line, CGFloat* ascent, CGFloat* descent, CGFloat* leading ) ;
+
+FUNCTION: CGRect CTLineGetImageBounds ( CTLineRef line, CGContextRef context ) ;
index 15a916716c7722f156252154a7712fcc0daaca2e..7f9a8d540930937a315427a4ada885ac654f7fb1 100755 (executable)
@@ -5,9 +5,10 @@ command-line kernel memory namespaces cocoa.messages
 cocoa.runtime cocoa.subclassing cocoa.pasteboard cocoa.types
 cocoa.windows cocoa.classes cocoa.nibs sequences system ui
 ui.backend ui.clipboards ui.gadgets ui.gadgets.worlds
-ui.cocoa.views core-foundation core-foundation.run-loop threads
-math.geometry.rect fry libc generalizations alien.c-types
-cocoa.views combinators io.thread ;
+ui.cocoa.views core-foundation core-foundation.run-loop
+core-graphics.types threads math.geometry.rect fry libc
+generalizations alien.c-types cocoa.views combinators
+io.thread ;
 IN: ui.cocoa
 
 TUPLE: handle ;
@@ -35,7 +36,7 @@ M: pasteboard set-clipboard-contents
     <clipboard> selection set-global ;
 
 : world>NSRect ( world -- NSRect )
-    [ window-loc>> ] [ dim>> ] bi [ first2 ] bi@ <NSRect> ;
+    [ window-loc>> ] [ dim>> ] bi [ first2 ] bi@ <CGRect> ;
 
 : gadget-window ( world -- )
     dup <FactorView>
index 3201779cc5026822e96a68f3a12a3d71654da0db..5d3243311a3f9f24f3dbf6a106fdf65da785e6f9 100644 (file)
@@ -4,7 +4,8 @@ USING: accessors alien alien.c-types arrays assocs cocoa kernel
 math cocoa.messages cocoa.subclassing cocoa.classes cocoa.views
 cocoa.application cocoa.pasteboard cocoa.types cocoa.windows
 sequences ui ui.gadgets ui.gadgets.worlds ui.gestures
-core-foundation.strings threads combinators math.geometry.rect ;
+core-foundation.strings core-graphics core-graphics.types
+threads combinators math.geometry.rect ;
 IN: ui.cocoa.views
 
 : send-mouse-moved ( view event -- )
@@ -14,15 +15,15 @@ IN: ui.cocoa.views
     #! Cocoa -> Factor UI button mapping
     -> buttonNumber H{ { 0 1 } { 2 2 } { 1 3 } } at ;
 
-: modifiers
+CONSTANT: modifiers
     {
         { S+ HEX: 20000 }
         { C+ HEX: 40000 }
         { A+ HEX: 100000 }
         { M+ HEX: 80000 }
-    } ;
+    }
 
-: key-codes
+CONSTANT: key-codes
     H{
         { 71 "CLEAR" }
         { 36 "RET" }
@@ -47,7 +48,7 @@ IN: ui.cocoa.views
         { 126 "UP" }
         { 116 "PAGE_UP" }
         { 121 "PAGE_DOWN" }
-    } ;
+    }
 
 : key-code ( event -- string ? )
     dup -> keyCode key-codes at
@@ -57,7 +58,7 @@ IN: ui.cocoa.views
     -> modifierFlags modifiers modifier ;
 
 : key-event>gesture ( event -- modifiers keycode action? )
-    dup event-modifiers swap key-code ;
+    [ event-modifiers ] [ key-code ] bi ;
 
 : send-key-event ( view gesture -- )
     swap window propagate-key-gesture ;
@@ -74,7 +75,7 @@ IN: ui.cocoa.views
     key-event>gesture <key-up> send-key-event ;
 
 : mouse-event>gesture ( event -- modifiers button )
-    dup event-modifiers swap button ;
+    [ event-modifiers ] [ button ] bi ;
 
 : send-button-down$ ( view event -- )
     [ nip mouse-event>gesture <button-down> ]
@@ -107,18 +108,18 @@ IN: ui.cocoa.views
     [ CF>string NSStringPboardType = ] [ t ] if* ;
 
 : valid-service? ( gadget send-type return-type -- ? )
-    over string-or-nil? over string-or-nil? and
+    2dup [ string-or-nil? ] [ string-or-nil? ] bi* and
     [ drop [ gadget-selection? ] [ drop t ] if ] [ 3drop f ] if ;
 
 : NSRect>rect ( NSRect world -- rect )
-    [ [ [ NSRect-x ] [ NSRect-y ] bi ] [ dim>> second ] bi* swap - 2array ]
-    [ drop [ NSRect-w ] [ NSRect-h ] bi 2array ]
+    [ [ [ CGRect-x ] [ CGRect-y ] bi ] [ dim>> second ] bi* swap - 2array ]
+    [ drop [ CGRect-w ] [ CGRect-h ] bi 2array ]
     2bi <rect> ;
 
 : rect>NSRect ( rect world -- NSRect )
     [ [ rect-loc first2 ] [ dim>> second ] bi* swap - ]
     [ drop rect-dim first2 ]
-    2bi <NSRect> ;
+    2bi <CGRect> ;
 
 CLASS: {
     { +superclass+ "NSOpenGLView" }
@@ -318,7 +319,7 @@ CLASS: {
 }
 
 { "firstRectForCharacterRange:" "NSRect" { "id" "SEL" "NSRange" }
-    [ 3drop 0 0 0 0 <NSRect> ]
+    [ 3drop 0 0 0 0 <CGRect> ]
 }
 
 { "conversationIdentifier" "NSInteger" { "id" "SEL" }
@@ -369,8 +370,9 @@ CLASS: {
 { "windowDidMove:" "void" { "id" "SEL" "id" }
     [
         2nip -> object
-        dup window-content-rect NSRect-x-y 2array
-        swap -> contentView window (>>window-loc)
+        [ -> contentView window ]
+        [ window-content-rect CGRect-x-y 2array ] bi
+        >>window-loc drop
     ]
 }
 
index ef01c6756c9febfed82b2749722bbf92d35a5f1c..437e4807faec9e86e2427e245d774d73ca1235f5 100644 (file)
@@ -1,5 +1,5 @@
 USING: help.syntax help.markup strings kernel alien opengl
-quotations ui.render io.styles freetype ;
+opengl.sprites quotations ui.render io.styles freetype ;
 IN: ui.freetype
 
 HELP: freetype
index 60e4e58ed5d7e9539e24019d887927ffb0f505b5..f4e63aa9e31ec02727fb34a27c370416c22fdc6e 100644 (file)
@@ -1,5 +1,5 @@
 USING: ui.gadgets ui.render ui.gestures ui.backend help.markup
-help.syntax models opengl strings ;
+help.syntax models opengl opengl.sprites strings ;
 IN: ui.gadgets.worlds
 
 HELP: user-input
index 4746ed904f8fcc70bfc5aa1e05f0b1780ec4c4e7..99758364981862cf788b49b9b4d139ac86272fce 100644 (file)
@@ -81,9 +81,9 @@ UNION: definition word method-spec link vocab vocab-link ;
 [ definition? ] \ com-forget H{ } define-operation
 
 ! Words
-[ word? ] \ insert-word H{
-    { +secondary+ t }
-} define-operation
+[ word? ] \ insert-word H{
+    { +secondary+ t }
+} define-operation
 
 [ topic? ] \ com-follow H{
     { +keyboard+ T{ key-down f { C+ } "h" } }