'
13 |
14 | hr_faded: '
'
15 | hr_shaded: '
'
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # scalanative-cocoa
2 | Experimental [scala-native](https://github.com/scala-native/scala-native) bridge for Objective-C / Cocoa.
3 |
4 | **WARNING**: This project is in an early experimental stage. Most of the bindings to Cocoa are still missing. The API and especially the semantics for creating Objective-C classes in Scala may change any time!
5 |
6 | **[Documentation](https://jokade.github.io/scalanative-cocoa/)**
7 |
8 | ### sbt Settings
9 | Add this to your `build.sbt`:
10 | ```scala
11 | libraryDependencies += "de.surfice" %%% "scalanative-cocoa-foundation" % "0.0.1-SNAPSHOT"
12 |
13 | addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full)
14 |
15 | resolvers += Resolver.sonatypeRepo("snapshots")
16 | ```
17 | Replace `scalanative-cocoa-foundation` with `scalanative-cocoa-appkit` if you want to use AppKit. However, it's probably best to start with the template in that case (see below).
18 |
19 | scalanative-cocoa requires scala-native 0.3.2.
20 |
21 |
22 |
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSController.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import scala.language.experimental.macros
5 | import scalanative.native._
6 | import objc._
7 | import cocoa.foundation._
8 |
9 |
10 | @ObjC
11 | class NSController extends NSObject with NSCoding {
12 | @inline def objectDidBeginEditing_(editor: id): Unit = extern
13 | @inline def objectDidEndEditing_(editor: id): Unit = extern
14 | @inline def discardEditing(): Unit = extern
15 | @inline def commitEditing(): BOOL = extern
16 | @inline def commitEditingWithDelegate_didCommitSelector_contextInfo_(delegate: id, didCommitSelector: SEL, contextInfo: Ptr[Byte]): Unit = extern
17 | @inline def isEditing(): BOOL = extern
18 | }
19 |
20 | @ObjCClass
21 | abstract class NSControllerClass extends NSObjectClass {
22 | }
23 |
24 | object NSController extends NSControllerClass {
25 | override type InstanceType = NSController
26 | }
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSControlTextEditingDelegate.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import scalanative.native._
5 | import cocoa.foundation.{BOOL, NSArray, NSInteger, NSObject, NSRange, NSString, SEL, id}
6 |
7 | import objc._
8 |
9 | @ObjC
10 | trait NSControlTextEditingDelegate extends NSObject {
11 | @inline def control_fieldEditor_(control: NSControl, fieldEditor: NSText): BOOL = extern
12 | @inline def control_string_error_(control: NSControl, string: NSString, error: NSString): BOOL = extern
13 | @inline def control_obj_(control: NSControl, obj: id): BOOL = extern
14 | // @inline def control_textView_commandSelector_(control: NSControl, textView: NSTextView, commandSelector: SEL): BOOL = extern
15 | // @inline def control_textView_words_charRange_index_(control: NSControl, textView: NSTextView, words: NSString, charRange: NSRange, index: NSInteger): NSArray[NSString] = extern
16 | }
17 |
18 |
--------------------------------------------------------------------------------
/docs/pages/sncocoa/overview/snc_get_started.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Get Started
3 | keywords:
4 | summary:
5 | sidebar: sncocoa_sidebar
6 | permalink: snc_get_started.html
7 | folder: sncocoa
8 | ---
9 |
10 | ## Template for Cocoa UI projects
11 | If you want to create a Cocoa UI application you can start with this [giter8 template](https://github.com/jokade/scalanative-cocoa-seed.g8):
12 | ```
13 | # g8 jokade/scalanative-cocoa-seed.g8
14 | ```
15 | or, with a recent version of sbt:
16 | ```
17 | # sbt new jokade/scalanative-cocoa-seed.g8
18 | ```
19 |
20 | This template requires Xcode to be installed.
21 |
22 | After you've created the project from the template, open the Xcode project located in `$PROJECT/xcode/`
23 | (you might want to rename the Xcode project folder first), and build the project (*Product* -> *Build*).
24 |
25 | After the Xcode build is finished, execute `sbt run` to run the application, or use `sbt prepareBundle` to create
26 | the application bundle under `target/scala-2.11/`.
27 |
28 | {% include links.html %}
29 |
--------------------------------------------------------------------------------
/foundation/src/test/scala/cocoa/foundation/test/NSDictionaryTest.scala:
--------------------------------------------------------------------------------
1 | package cocoa.foundation.test
2 |
3 | import cocoa.foundation.{@@, NSDictionary, NSQuote}
4 | import utest._
5 |
6 | object NSDictionaryTest extends TestSuite {
7 | val tests = Tests {
8 | /*
9 | 'class - {
10 | assert(NSDictionary.className == "NSDictionary")
11 | 'dictionary-{
12 | val dict = NSDictionary.dictionary()
13 | assert( dict.count().toInt == 0 )
14 | }
15 | 'dictionaryWithObject-{
16 | val dict = NSDictionary.dictionaryWithObject(@@(42),ns"int")
17 | assert(
18 | dict.count().toInt == 1,
19 | dict.objectForKey(ns"int").intValue() == 42 )
20 | }
21 | }
22 | 'classExtensions-{
23 | val dict = NSDictionary.dictionaryWithObjects(Seq(
24 | ns"int" -> @@(42),
25 | ns"bool" -> @@(true)
26 | ))
27 | assert(
28 | dict.count().toInt == 2,
29 | dict.objectForKey(ns"int").intValue() == 42,
30 | dict.objectForKey(ns"bool").boolValue() == true )
31 | }
32 | */
33 | }
34 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSProxy.scala_:
--------------------------------------------------------------------------------
1 | package cocoa.foundation
2 |
3 | import scalanative.native._
4 |
5 | import scala.language.experimental.macros
6 |
7 |
8 | @ObjC
9 | class NSProxy extends NSObject {
10 | @inline def forwardInvocation(invocation: NSInvocation): Unit = extern
11 | @inline def methodSignatureForSelector(sel: SEL): NSMethodSignature = extern
12 | // @inline def dealloc(): Unit = extern
13 | // @inline def `finalize`(): Unit = extern
14 | // @inline def allowsWeakReference(): BOOL = extern
15 | // @inline def retainWeakReference(): BOOL = extern
16 | // @inline def description(): NSString = extern
17 | // @inline def debugDescription(): NSString = extern
18 | }
19 |
20 | @ObjCClass
21 | abstract class NSProxyClass extends NSObjectClass {
22 | def __cls: id
23 | // @inline def alloc(): id = extern
24 | @inline def allocWithZone(zone: NSZone): id = extern
25 | // @inline def `class`(): id = extern
26 | @inline def respondsToSelector(aSelector: SEL): BOOL = extern
27 | }
28 |
29 | object NSProxy extends NSProxyClass {
30 | override type InstanceType = NSProxy
31 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSMutableIndexSet.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scala.language.experimental.macros
5 | import scalanative.native._
6 | import objc._
7 |
8 | @ObjC
9 | class NSMutableIndexSet extends NSIndexSet {
10 | @inline def addIndexes_(indexSet: NSIndexSet): Unit = extern
11 | @inline def removeIndexes_(indexSet: NSIndexSet): Unit = extern
12 | @inline def removeAllIndexes(): Unit = extern
13 | @inline def addIndex_(value: NSUInteger): Unit = extern
14 | @inline def removeIndex_(value: NSUInteger): Unit = extern
15 | @inline def addIndexesInRange_(range: NSRange): Unit = extern
16 | @inline def removeIndexesInRange_(range: NSRange): Unit = extern
17 | @inline def shiftIndexesStartingAtIndex_delta_(index: NSUInteger, delta: NSInteger): Unit = extern
18 | }
19 |
20 | @ObjCClass
21 | abstract class NSMutableIndexSetClass extends NSIndexSetClass {
22 | }
23 |
24 | object NSMutableIndexSet extends NSMutableIndexSetClass {
25 | override type InstanceType = NSMutableIndexSet
26 | }
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/AppKit.scala:
--------------------------------------------------------------------------------
1 | package cocoa.appkit
2 |
3 | import cocoa.foundation.{BOOL, NSInteger, NSString}
4 | import scalanative.native._
5 | import objc.runtime.id
6 |
7 |
8 | @extern
9 | object AppKit {
10 |
11 |
12 | // from NSApplication.h
13 | type _NSModalSession = Ptr[Byte]
14 | type NSThreadPrivate = Ptr[Byte]
15 | type __appFlags = Ptr[Byte]
16 | def NSApplicationMain(argc: CInt, argv: Ptr[Ptr[CSignedChar]]): CInt = extern
17 | def NSApplicationLoad(): BOOL = extern
18 | def NSShowsServicesMenuItem(itemName: NSString): BOOL = extern
19 | def NSSetShowsServicesMenuItem(itemName: NSString, enabled: BOOL): NSInteger = extern
20 | def NSUpdateDynamicServices(): Unit = extern
21 | // def NSPerformService_pboard_(itemName: NSString, pboard: NSPasteboard): BOOL = extern
22 | // def NSRegisterServicesProvider_name_(provider: id, name: NSServiceProviderName): Unit = extern
23 | // def NSUnregisterServicesProvider_(name: NSServiceProviderName): Unit = extern
24 |
25 |
26 | // from NSEvent.h
27 | def NSEventMaskFromType_(`type`: NSEventType): NSEventMask = extern
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSNotification.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scalanative.native._
5 | import objc._
6 |
7 | @ObjC
8 | class NSNotification extends NSObject with NSCopying with NSCoding {
9 | @inline def initWithName_object_userInfo_(name: NSNotificationName, `object`: id, userInfo: NSDictionary[NSObject,NSObject]): NSNotification = extern
10 | @inline def name(): NSNotificationName = extern
11 | @inline def `object`(): id = extern
12 | @inline def userInfo(): NSDictionary[NSObject,NSObject] = extern
13 | }
14 |
15 |
16 | @ObjCClass
17 | abstract class NSNotificationClass extends NSObjectClass {
18 | @inline def notificationWithName_anObject_(aName: NSNotificationName, anObject: id): NSNotification = extern
19 | @inline def notificationWithName_anObject_aUserInfo_(aName: NSNotificationName, anObject: id, aUserInfo: NSDictionary[NSObject,NSObject]): NSNotification = extern
20 | }
21 |
22 | object NSNotification extends NSNotificationClass {
23 | override type InstanceType = NSNotification
24 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2017,2018 Johannes Kastner
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/coredata/src/main/scala/cocoa/coredata/package.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa
3 |
4 | import scalanative.native._
5 | import cocoa.foundation.NSUInteger
6 |
7 | package object coredata {
8 |
9 | type NSManagedObjectContextConcurrencyType = NSUInteger
10 | object NSManagedObjectContextConcurrencyType {
11 | val NSPrivateQueueConcurrencyType :NSManagedObjectContextConcurrencyType = 1.toULong
12 | val NSMainQueueConcurrencyType :NSManagedObjectContextConcurrencyType = 2.toULong
13 | }
14 |
15 | type NSSnapshotEventType = NSUInteger
16 | object NSSnapshotEventType {
17 | val NSSnapshotEventUndoInsertion :NSSnapshotEventType = 1.toULong << 1
18 | val NSSnapshotEventUndoDeletion :NSSnapshotEventType = 1.toULong << 2
19 | val NSSnapshotEventUndoUpdate :NSSnapshotEventType = 1.toULong << 3
20 | val NSSnapshotEventRollback :NSSnapshotEventType = 1.toULong << 4
21 | val NSSnapshotEventRefresh :NSSnapshotEventType = 1.toULong << 5
22 | val NSSnapshotEventMergePolicy :NSSnapshotEventType = 1.toULong << 6
23 | }
24 |
25 | type NSPersistentStoreDescription = foundation.NSObject
26 | }
27 |
--------------------------------------------------------------------------------
/docs/_data/topnav.yml:
--------------------------------------------------------------------------------
1 | ## Topnav single links
2 | ## if you want to list an external url, use external_url instead of url. the theme will apply a different link base.
3 | topnav:
4 | - title: Topnav
5 | items:
6 | - title: GitHub
7 | external_url: https://github.com/jokade/scalanative-cocoa
8 | # - title: News
9 | # url: /news
10 |
11 | #Topnav dropdowns
12 | topnav_dropdowns:
13 | - title: Topnav dropdowns
14 | folders:
15 | # - title: Jekyll Help
16 | # folderitems:
17 | # - title: Jekyll Talk
18 | # external_url: https://talk.jekyllrb.com
19 | # - title: Jekyll documentation
20 | # external_url: http://jekyllrb.com/docs/home/
21 | # - title: Jekyll on Stack Overflow
22 | # external_url: http://stackoverflow.com/questions/tagged/jekyll
23 | # - title: Jekyll on my blog
24 | # external_url: http://idratherbewriting.com/category-jekyll/
25 | # - title: Products
26 | # folderitems:
27 | # - title: Jekyll Documentation Theme
28 | # url: /mydoc_introduction.html
29 | # - title: Product 1
30 | # url: /p1_landing_page.html
31 | # - title: Product 2
32 | # url: /p2_landing_page.html
33 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSValue.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scala.scalanative.native._
5 | import objc._
6 |
7 | @ObjC
8 | class NSValue extends NSObject with NSCopying with NSSecureCoding {
9 | @inline def getValue_(value: Ptr[Byte]): Unit = extern
10 | @inline def initWithBytes_type_(value: Ptr[Byte], `type`: Ptr[CSignedChar]): NSValue = extern
11 | @inline def objCType(): Ptr[CSignedChar] = extern
12 | @inline def isEqualToValue_(value: NSValue): BOOL = extern
13 | @inline def nonretainedObjectValue(): id = extern
14 | @inline def pointerValue(): Ptr[Byte] = extern
15 | }
16 |
17 |
18 | @ObjCClass
19 | abstract class NSValueClass extends NSObjectClass {
20 | @inline def valueWithBytes_type_(value: Ptr[Byte], `type`: Ptr[CSignedChar]): NSValue = extern
21 | @inline def value_type_(value: Ptr[Byte], `type`: Ptr[CSignedChar]): NSValue = extern
22 | @inline def valueWithNonretainedObject_(anObject: id): NSValue = extern
23 | @inline def valueWithPointer_(pointer: Ptr[Byte]): NSValue = extern
24 | }
25 |
26 |
27 |
28 | object NSValue extends NSValueClass {
29 | override type InstanceType = NSValue
30 | }
31 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSInvocation.scala_:
--------------------------------------------------------------------------------
1 | package cocoa.foundation
2 |
3 | import scala.scalanative.native._
4 |
5 | import scala.language.experimental.macros
6 |
7 | @ObjC
8 | class NSInvocation extends NSObject {
9 | @inline def retainArguments(): Unit = extern
10 | @inline def getReturnValue(retLoc: Ptr[Byte]): Unit = extern
11 | @inline def setReturnValue(retLoc: Ptr[Byte]): Unit = extern
12 | @inline def getArgument(argumentLocation: Ptr[Byte], idx: NSInteger): Unit = extern
13 | @inline def setArgument(argumentLocation: Ptr[Byte], idx: NSInteger): Unit = extern
14 | @inline def invoke(): Unit = extern
15 | @inline def invokeWithTarget(target: id): Unit = extern
16 | @inline def methodSignature(): NSMethodSignature = extern
17 | @inline def argumentsRetained(): BOOL = extern
18 | @inline def target(): id = extern
19 | @inline def setTarget(target: id): Unit = extern
20 | @inline def selector(): SEL = extern
21 | @inline def setSelector(selector: SEL): Unit = extern
22 | }
23 |
24 | @ObjCClass
25 | abstract class NSInvocationClass {
26 | def __cls: id
27 | @inline def invocationWithMethodSignature(sig: NSMethodSignature): NSInvocation = extern
28 | }
29 |
30 | object NSInvocation extends NSInvocationClass {
31 | }
--------------------------------------------------------------------------------
/docs/_includes/disqus.html:
--------------------------------------------------------------------------------
1 | {% if site.disqus_shortname %}
2 |
3 |
4 |
24 | Please enable JavaScript to view the comments powered by Disqus.
25 | {% endif %}
26 |
--------------------------------------------------------------------------------
/test/src/main/scala/Main.scala:
--------------------------------------------------------------------------------
1 | // Project: scalanative-cocoa
2 | // Module:
3 | // Description:
4 |
5 | import scala.scalanative.native._
6 | import objc._
7 | import cocoa.foundation._
8 | import cocoa.foundation.Foundation._
9 | import de.surfice.smacrotools.debug
10 |
11 | import scala.scalanative.native.objc.runtime.ObjCObject
12 |
13 | object Main {
14 |
15 | def main(args: Array[String]): Unit = {
16 | val str = NSString.stringWithUTF8String(c"Hello, world!")
17 | NSLog(str)
18 | val x = XClass.alloc()
19 | x.asInstanceOf[NSObject].init()
20 | }
21 | /*
22 | def f(): Unit = {
23 | val dict = NSDictionary(ns"greeting" -> ns"Hello")
24 | NSLog(ns"%@",dict)
25 | // val parent = ObjCParent(x.cast[id])
26 | // val desc = objc_msgSend(parent,sel_registerName(c"hello"))
27 | // NSLog(ns"%@",parent)
28 | }
29 | */
30 |
31 | }
32 |
33 | @extern
34 | object util {
35 | def util_callInit(obj: ObjCProxy[XClass]): Unit = extern
36 | }
37 |
38 | @ScalaObjC
39 | @debug
40 | class XClass(self: NSObject) {
41 | // override type InstanceType = XClass
42 | var i = 42
43 |
44 | @selector("init")
45 | def myInit(): NSObject = {
46 | println("FOO!")
47 | $super(self)(_.init())
48 |
49 | self
50 | }
51 |
52 | }
53 | object XClass extends NSObjectClass {
54 | override type InstanceType = ObjCProxy[XClass]
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/docs/_layouts/post.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | ---
4 |
5 |
6 |
21 |
22 |
23 |
24 | {% if page.summary %}
25 |
{{page.summary}}
26 | {% endif %}
27 |
28 | {{ content }}
29 |
30 |
31 |
32 |
33 |
34 |
35 | {% include disqus.html %}
36 |
37 | {{site.data.alerts.hr_shaded}}
38 |
39 | {% include footer.html %}
40 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSNotificationCenter.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scalanative.native._
5 | import objc._
6 |
7 |
8 | @ObjC
9 | class NSNotificationCenter extends NSObject {
10 | @inline def addObserver_aSelector_aName_anObject_(observer: id, aSelector: SEL, aName: NSNotificationName, anObject: id): Unit = extern
11 | @inline def postNotification_(notification: NSNotification): Unit = extern
12 | @inline def postNotificationName_anObject_(aName: NSNotificationName, anObject: id): Unit = extern
13 | @inline def postNotificationName_anObject_aUserInfo_(aName: NSNotificationName, anObject: id, aUserInfo: NSDictionary[NSObject,NSObject]): Unit = extern
14 | @inline def removeObserver_(observer: id): Unit = extern
15 | @inline def removeObserver_aName_anObject_(observer: id, aName: NSNotificationName, anObject: id): Unit = extern
16 | // @inline def addObserverForName_obj_queue_block_(name: NSNotificationName, obj: id, queue: NSOperationQueue, block: Ptr[Byte]): id[NSObject] = extern
17 | }
18 |
19 | @ObjCClass
20 | abstract class NSNotificationCenterClass extends NSObjectClass {
21 | @inline def defaultCenter(): NSNotificationCenter = extern
22 | }
23 |
24 | object NSNotificationCenter extends NSNotificationCenterClass {
25 | override type InstanceType = NSNotificationCenter
26 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/Macros.scala:
--------------------------------------------------------------------------------
1 | // Project: scalanative-cocoa
2 | // Module:
3 | // Description:
4 | package cocoa.foundation
5 |
6 | import de.surfice.smacrotools.BlackboxMacroTools
7 | import scalanative.native.objc.ObjCMacroTools
8 |
9 | import scala.reflect.macros.blackbox
10 |
11 | /**
12 | * Provides implementations for macros used in package cocoa.foundation.
13 | *
14 | * @param c
15 | */
16 | private[this] class Macros(val c: blackbox.Context) extends BlackboxMacroTools with ObjCMacroTools {
17 | import c.universe._
18 |
19 | def nsquoteImpl() = {
20 | val expr = c.prefix match {
21 | case Expr(Apply(x,args)) => q"scalanative.native.CQuote(..$args).c()"
22 | }
23 | c.Expr(q"cocoa.foundation.NSString($expr)")
24 | }
25 |
26 | def superImpl(self: Tree)(f: Tree) = {
27 | val t = f match {
28 | case Function(_,Apply(f,args)) =>
29 | val method = f.symbol.asMethod
30 | val params = method.paramLists.head
31 | val callSuper = args.size match {
32 | case 0 => q"msgSendSuper0($self,sel)"
33 | case 1 => q"msgSendSuper1($self,sel,${args(0)})"
34 | }
35 | q"""import objc.runtime._
36 | import objc.helper._
37 | val sel = sel_registerName(${cstring(genSelectorString(method))})
38 | $callSuper.cast[${method.returnType}]
39 | """
40 | }
41 | t
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSMutableString.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scalanative.native._
5 | import objc._
6 |
7 |
8 | @ObjC
9 | class NSMutableString extends NSString {
10 | @inline def replaceCharactersInRange_aString_(range: NSRange, aString: NSString): Unit = extern
11 | @inline def insertString_loc_(aString: NSString, loc: NSUInteger): Unit = extern
12 | @inline def deleteCharactersInRange_(range: NSRange): Unit = extern
13 | @inline def appendString_(aString: NSString): Unit = extern
14 | @inline def appendFormat_(format: NSString): Unit = extern
15 | @inline def setString_(aString: NSString): Unit = extern
16 | @inline def replaceOccurrencesOfString_replacement_options_searchRange_(target: NSString, replacement: NSString, options: NSStringCompareOptions, searchRange: NSRange): NSUInteger = extern
17 | @inline def applyTransform_reverse_range_resultingRange_(transform: NSString, reverse: BOOL, range: NSRange, resultingRange: NSRangePointer): BOOL = extern
18 | @inline def initWithCapacity_(capacity: NSUInteger): NSMutableString = extern
19 | }
20 |
21 | @ObjCClass
22 | abstract class NSMutableStringClass extends NSStringClass {
23 | @inline def stringWithCapacity_(capacity: NSUInteger): NSMutableString = extern
24 | }
25 |
26 | object NSMutableString extends NSMutableStringClass {
27 | override type InstanceType = NSMutableString
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/docs/_includes/taglogic.html:
--------------------------------------------------------------------------------
1 | The following pages and posts are tagged with {{page.tagName}}
2 | Title Type Excerpt
3 |
4 | {% assign thisTag = page.tagName %}
5 | {% for page in site.pages %}
6 | {% for tag in page.tags %}
7 | {% if tag == thisTag %}
8 |
9 | {{page.title}}
10 | Page
11 | {% if page.summary %} {{ page.summary | strip_html | strip_newlines | truncate: 160 }} {% else %} {{ page.content | truncatewords: 50 | strip_html }} {% endif %}
12 |
13 | {% endif %}
14 | {% endfor %}
15 | {% endfor %}
16 |
17 | {% assign thisTag = page.tagName %}
18 | {% for post in site.posts %}
19 | {% for tag in post.tags %}
20 | {% if tag == thisTag %}
21 |
22 | {{post.title}}
23 | Post
24 | {% if post.summary %} {{ post.summary | strip_html | strip_newlines | truncate: 160 }} {% else %} {{ post.content | truncatewords: 50 | strip_html }} {% endif %}
25 |
26 | {% endif %}
27 | {% endfor %}
28 | {% endfor %}
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSMutableData.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scala.language.experimental.macros
5 | import scalanative.native._
6 | import objc._
7 |
8 | @ObjC
9 | class NSMutableData extends NSData {
10 | @inline def mutableBytes(): Ptr[Byte] = extern
11 | @inline def setLength_(length: NSUInteger): Unit = extern
12 | @inline def appendBytes_length_(bytes: Ptr[Byte], length: NSUInteger): Unit = extern
13 | @inline def appendData_(other: NSData): Unit = extern
14 | @inline def increaseLengthBy_(extraLength: NSUInteger): Unit = extern
15 | @inline def replaceBytesInRange_bytes_(range: NSRange, bytes: Ptr[Byte]): Unit = extern
16 | @inline def resetBytesInRange_(range: NSRange): Unit = extern
17 | @inline def setData_(data: NSData): Unit = extern
18 | @inline def replaceBytesInRange_replacementBytes_replacementLength_(range: NSRange, replacementBytes: Ptr[Byte], replacementLength: NSUInteger): Unit = extern
19 | @inline def initWithCapacity_(capacity: NSUInteger): NSMutableData = extern
20 | @inline def initWithLength_(length: NSUInteger): NSMutableData = extern
21 | }
22 |
23 | @ObjCClass
24 | abstract class NSMutableDataClass extends NSDataClass {
25 | @inline def dataWithCapacity_(aNumItems: NSUInteger): NSMutableData = extern
26 | @inline def dataWithLength_(length: NSUInteger): NSMutableData = extern
27 | }
28 |
29 | object NSMutableData extends NSMutableDataClass {
30 | override type InstanceType = NSMutableData
31 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSError.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scalanative.native._
5 | import objc._
6 |
7 | @ObjC
8 | class NSError extends NSObject with NSCopying with NSSecureCoding {
9 | @inline def initWithDomain_code_dict_(domain: NSString, code: NSInteger, dict: NSDictionary[NSErrorUserInfoKey,NSObject]): NSError = extern
10 | @inline def domain(): NSString = extern
11 | @inline def code(): NSInteger = extern
12 | @inline def userInfo(): NSDictionary[NSErrorUserInfoKey,NSObject] = extern
13 | @inline def localizedDescription(): NSString = extern
14 | @inline def localizedFailureReason(): NSString = extern
15 | @inline def localizedRecoverySuggestion(): NSString = extern
16 | @inline def localizedRecoveryOptions(): NSArray[NSString] = extern
17 | @inline def recoveryAttempter(): id = extern
18 | @inline def helpAnchor(): NSString = extern
19 | }
20 |
21 |
22 | @ObjCClass
23 | abstract class NSErrorClass extends NSObjectClass {
24 | @inline def errorWithDomain_code_dict_(domain: NSString, code: NSInteger, dict: NSDictionary[NSErrorUserInfoKey,NSObject]): NSError = extern
25 | @inline def setUserInfoValueProviderForDomain_provider_(errorDomain: NSString, provider: id): Unit = extern
26 | @inline def userInfoValueProviderForDomain_userInfoKey_errorDomain_(err: NSError, userInfoKey: NSErrorUserInfoKey, errorDomain: NSString): Ptr[Byte] = extern
27 | }
28 |
29 | object NSError extends NSErrorClass {
30 | override type InstanceType = NSError
31 | }
--------------------------------------------------------------------------------
/docs/_includes/links.html:
--------------------------------------------------------------------------------
1 | {% comment %}Get links from each sidebar, as listed in the _config.yml file under sidebars{% endcomment %}
2 |
3 | {% for sidebar in site.sidebars %}
4 | {% for entry in site.data.sidebars[sidebar].entries %}
5 | {% for folder in entry.folders %}
6 | {% for folderitem in folder.folderitems %}
7 | {% if folderitem.url contains "html#" %}
8 | [{{folderitem.url | remove: "/" }}]: {{folderitem.url | remove: "/"}}
9 | {% else %}
10 | [{{folderitem.url | remove: "/" | remove: ".html"}}]: {{folderitem.url | remove: "/"}}
11 | {% endif %}
12 | {% for subfolders in folderitem.subfolders %}
13 | {% for subfolderitem in subfolders.subfolderitems %}
14 | [{{subfolderitem.url | remove: "/" | remove: ".html"}}]: {{subfolderitem.url | remove: "/"}}
15 | {% endfor %}
16 | {% endfor %}
17 | {% endfor %}
18 | {% endfor %}
19 | {% endfor %}
20 | {% endfor %}
21 |
22 |
23 | {% comment %} Get links from topnav {% endcomment %}
24 |
25 | {% for entry in site.data.topnav.topnav %}
26 | {% for item in entry.items %}
27 | {% if item.external_url == null %}
28 | [{{item.url | remove: "/" | remove: ".html"}}]: {{item.url | remove: "/"}}
29 | {% endif %}
30 | {% endfor %}
31 | {% endfor %}
32 |
33 | {% comment %}Get links from topnav dropdowns {% endcomment %}
34 |
35 | {% for entry in site.data.topnav.topnav_dropdowns %}
36 | {% for folder in entry.folders %}
37 | {% for folderitem in folder.folderitems %}
38 | {% if folderitem.external_url == null %}
39 | [{{folderitem.url | remove: "/" | remove: ".html"}}]: {{folderitem.url | remove: "/"}}
40 | {% endif %}
41 | {% endfor %}
42 | {% endfor %}
43 | {% endfor %}
44 |
45 |
--------------------------------------------------------------------------------
/foundation/src/test/scala/cocoa/foundation/test/NSArrayTest.scala:
--------------------------------------------------------------------------------
1 | package cocoa.foundation.test
2 |
3 | import utest._
4 | import cocoa.foundation.{NSArray, NSNumber, NSQuote}
5 | import scalanative.native._
6 |
7 | object NSArrayTest extends TestSuite {
8 | val tests = Tests {
9 | /*
10 | 'class- {
11 | assert(NSArray.className == "NSArray")
12 | 'array - {
13 | val array = NSArray.array[NSNumber]()
14 | assert(
15 | array.className == "__NSArray0",
16 | array.count().toInt == 0)
17 | }
18 | 'arrayWithObject - {
19 | val array = NSArray.arrayWithObject(NSNumber(42))
20 | assert(array.count().toInt == 1,
21 | array.objectAtIndex(0.toUInt).intValue() == 42)
22 | }
23 | }
24 | 'classExtensions- {
25 | 'arrayWithObjects - {
26 | val array: NSArray[NSNumber] = NSArray.arrayWithObjects(Seq(NSNumber(0), NSNumber(1), NSNumber(2)))
27 | assert(
28 | array.count().toInt == 3,
29 | array.objectAtIndex(0.toUInt).intValue() == 0,
30 | array.objectAtIndex(1.toUInt).intValue() == 1,
31 | array.objectAtIndex(2.toUInt).intValue() == 2)
32 | }
33 | }
34 | // 'RichNSArray-{
35 | // val array = NSArray(NSNumber(42),NSNumber(Int.MinValue),NSNumber(Int.MaxValue))
36 | // 'size-{
37 | // assert( array.count().toInt == 3 )
38 | // }
39 | // 'apply-{
40 | // assert(
41 | // array(0).intValue() == 42,
42 | // array(1).intValue() == Int.MinValue,
43 | // array(2).intValue() == Int.MaxValue )
44 | // }
45 | // }
46 | */
47 | }
48 | }
--------------------------------------------------------------------------------
/docs/css/modern-business.css:
--------------------------------------------------------------------------------
1 | /*!
2 | * Start Bootstrap - Modern Business HTML Template (http://startbootstrap.com)
3 | * Code licensed under the Apache License v2.0.
4 | * For details, see http://www.apache.org/licenses/LICENSE-2.0.
5 | */
6 |
7 | /* Global Styles */
8 |
9 | html,
10 | body {
11 | height: 100%;
12 | }
13 |
14 | .img-portfolio {
15 | margin-bottom: 30px;
16 | }
17 |
18 | .img-hover:hover {
19 | opacity: 0.8;
20 | }
21 |
22 | /* Home Page Carousel */
23 |
24 | header.carousel {
25 | height: 50%;
26 | }
27 |
28 | header.carousel .item,
29 | header.carousel .item.active,
30 | header.carousel .carousel-inner {
31 | height: 100%;
32 | }
33 |
34 | header.carousel .fill {
35 | width: 100%;
36 | height: 100%;
37 | background-position: center;
38 | background-size: cover;
39 | }
40 |
41 | /* 404 Page Styles */
42 |
43 | .error-404 {
44 | font-size: 100px;
45 | }
46 |
47 | /* Pricing Page Styles */
48 |
49 | .price {
50 | display: block;
51 | font-size: 50px;
52 | line-height: 50px;
53 | }
54 |
55 | .price sup {
56 | top: -20px;
57 | left: 2px;
58 | font-size: 20px;
59 | }
60 |
61 | .period {
62 | display: block;
63 | font-style: italic;
64 | }
65 |
66 | /* Footer Styles */
67 |
68 | footer {
69 | margin: 50px 0;
70 | }
71 |
72 | /* Responsive Styles */
73 |
74 | @media(max-width:991px) {
75 | .client-img,
76 | .img-related {
77 | margin-bottom: 30px;
78 | }
79 | }
80 |
81 | @media(max-width:767px) {
82 | .img-portfolio {
83 | margin-bottom: 15px;
84 | }
85 |
86 | header.carousel .carousel {
87 | height: 70%;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/Foundation.scala:
--------------------------------------------------------------------------------
1 | // Project: scalanative-cocoa
2 | // Module: Foundation
3 | // Description: Contains all functions defined in the Foundation global scope.
4 | package cocoa.foundation
5 |
6 | import scala.scalanative.native._
7 | import objc.runtime._
8 | import cocoa.foundation._
9 |
10 | @extern
11 | object Foundation {
12 | // type objc_class = Ptr[Byte]
13 | // type objc_object = Ptr[Byte]
14 | // type objc_selector = Ptr[Byte]
15 | // type _NSZone = Ptr[Byte]
16 | // def sel_getName_(sel: SEL): Ptr[CSignedChar] = extern
17 | // def sel_registerName_(str: Ptr[CSignedChar]): SEL = extern
18 | // def object_getClassName_(obj: id): Ptr[CSignedChar] = extern
19 | // def object_getIndexedIvars_(obj: id): Ptr[Byte] = extern
20 | // def sel_isMapped_(sel: SEL): BOOL = extern
21 | // def sel_getUid_(str: Ptr[CSignedChar]): SEL = extern
22 | def NSAllocateObject_extraBytes_zone(aClass: id, extraBytes: NSUInteger, zone: NSZone): id = extern
23 | def NSDeallocateObject_(`object`: id): Unit = extern
24 | def NSCopyObject_extraBytes_zone(`object`: id, extraBytes: NSUInteger, zone: NSZone): id = extern
25 | def NSShouldRetainWithZone_requestedZone(anObject: id, requestedZone: NSZone): BOOL = extern
26 | def NSIncrementExtraRefCount(`object`: id): Unit = extern
27 | def NSDecrementExtraRefCountWasZero(`object`: id): BOOL = extern
28 | def NSExtraRefCount(`object`: id): NSUInteger = extern
29 | // def CFBridgingRetain_(X: id): CFTypeRef = extern
30 | // def CFBridgingRelease_(X: CFTypeRef): id = extern
31 |
32 | def NSLog(format: NSString, args: CVararg*): Unit = extern
33 | def NXReadNSObjectFromCoder(decoder: NSCoder): NSObject = extern
34 | }
35 |
--------------------------------------------------------------------------------
/docs/_includes/head_print.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {% if page.homepage == true %} {{site.homepage_title}} {% elsif page.title %}{{ page.title }}{% endif %} | {{ site.site_title }}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
23 |
24 |
29 |
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSLevelIndicator.scala_:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import cocoa.foundation.{NSInteger, NSObjectClass, NSRect}
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 |
9 |
10 | @ObjC
11 | class NSLevelIndicator extends NSControl {
12 | @inline def tickMarkValueAtIndex(index: NSInteger): Double = extern
13 | @inline def rectOfTickMarkAtIndex(index: NSInteger): NSRect = extern
14 | // @inline def levelIndicatorStyle(): NSLevelIndicatorStyle = extern
15 | // @inline def setLevelIndicatorStyle(levelIndicatorStyle: NSLevelIndicatorStyle): Unit = extern
16 | @inline def minValue(): Double = extern
17 | @inline def setMinValue(minValue: Double): Unit = extern
18 | @inline def maxValue(): Double = extern
19 | @inline def setMaxValue(maxValue: Double): Unit = extern
20 | @inline def warningValue(): Double = extern
21 | @inline def setWarningValue(warningValue: Double): Unit = extern
22 | @inline def criticalValue(): Double = extern
23 | @inline def setCriticalValue(criticalValue: Double): Unit = extern
24 | // @inline def tickMarkPosition(): NSTickMarkPosition = extern
25 | // @inline def setTickMarkPosition(tickMarkPosition: NSTickMarkPosition): Unit = extern
26 | @inline def numberOfTickMarks(): NSInteger = extern
27 | @inline def setNumberOfTickMarks(numberOfTickMarks: NSInteger): Unit = extern
28 | @inline def numberOfMajorTickMarks(): NSInteger = extern
29 | @inline def setNumberOfMajorTickMarks(numberOfMajorTickMarks: NSInteger): Unit = extern
30 | }
31 |
32 |
33 | @ObjCClass
34 | abstract class NSLevelIndicatorClass extends NSObjectClass {
35 | }
36 |
37 | object NSLevelIndicator extends NSLevelIndicatorClass {
38 | override type InstanceType = NSLevelIndicator
39 | }
--------------------------------------------------------------------------------
/docs/_layouts/page.html:
--------------------------------------------------------------------------------
1 | ---
2 | layout: default
3 | ---
4 |
5 |
8 |
9 | {% if page.simple_map == true %}
10 |
11 |
16 |
17 | {% include custom/{{page.map_name}}.html %}
18 |
19 | {% elsif page.complex_map == true %}
20 |
21 |
26 |
27 | {% include custom/{{page.map_name}}.html %}
28 |
29 | {% endif %}
30 |
31 |
32 |
33 | {% if page.summary %}
34 |
{{page.summary}}
35 | {% endif %}
36 |
37 | {% unless page.toc == false %}
38 | {% include toc.html %}
39 | {% endunless %}
40 |
41 |
42 | {% if site.github_editme_path %}
43 |
44 |
Edit me
45 |
46 | {% endif %}
47 |
48 | {{content}}
49 |
50 |
61 |
62 | {% include disqus.html %}
63 |
64 |
65 |
66 | {{site.data.alerts.hr_shaded}}
67 |
68 | {% include footer.html %}
69 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/decorators.scala_:
--------------------------------------------------------------------------------
1 | // Project: scalanative-cocoa
2 | // Module:
3 | // Description:
4 | // Copyright (c) $today.year. Distributed under the MIT License (see included LICENSE file). package cocoa.foundation
5 | package cocoa.foundation
6 |
7 | import scala.reflect.macros.blackbox
8 | import scala.language.experimental.macros
9 | import scalanative.native._
10 |
11 | //TODO: these decorators don't work - segmentation fault during execution
12 | //object NSDecorators {
13 | //
14 | // trait NSIterable[T] extends NSObject {
15 | // def count(): NSUInteger
16 | // }
17 | // object NSIterable {
18 | // implicit final class RichNSIterable[T](val ns: NSIterable[T]) extends AnyVal {
19 | // /**
20 | // * Return the number of elements in this collection.
21 | // */
22 | // def size: Int = ns.count().toInt
23 | // }
24 | //
25 | // def sizeImpl(c: blackbox.Context) = {
26 | // import c.universe._
27 | // q"${c.prefix}.ns.count().toInt"
28 | // }
29 | // }
30 | //
31 | // trait NSSeqLike[T] extends NSIterable[T] {
32 | // def objectAtIndex(idx: NSUInteger): T
33 | // }
34 | //
35 | // object NSSeqLike {
36 | // implicit final class RichNSSeqLike[T](val ns: NSSeqLike[T]) extends AnyVal {
37 | // /**
38 | // * Returns the element at the specified index.
39 | // *
40 | // * @param idx
41 | // */
42 | // @inline def apply(idx: Int): T = ns.objectAtIndex(idx.toUInt)
43 | // }
44 | // }
45 | //
46 | // trait NSMapLike[K,V] extends NSIterable[(K,V)] {
47 | // def objectForKey(key: K): V
48 | // }
49 | // object NSMapLike {
50 | // implicit final class RichNSMapLike[K,V](val ns: NSMapLike[K,V]) extends AnyVal {
51 | // /**
52 | // * Returns the object with the specified key.
53 | // * @param key
54 | // */
55 | // @inline def apply(key: K): V = ns.objectForKey(key)
56 | // }
57 | // }
58 | //}
59 |
60 |
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSTableViewDataSource.scala_:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import cocoa.foundation.{BOOL, NSArray, NSInteger, NSObject, NSPoint, NSString, NSURL, id}
5 | import de.surfice.smacrotools.debug
6 |
7 | import scalanative.native._
8 |
9 | @ObjC
10 | trait NSTableViewDataSource extends NSObject {
11 | def numberOfRowsInTableView(tableView: NSTableView): NSInteger
12 | def tableView_objectValueForTableColumn_row_(tableView: NSTableView, objectValueForTableColumn: NSTableColumn, row: NSInteger): NSObject = extern
13 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn, row: NSInteger): id = extern
14 | // @inline def tableView(tableView: NSTableView, `object`: id, tableColumn: NSTableColumn, row: NSInteger): Unit = extern
15 | // @inline def tableView(tableView: NSTableView, oldDescriptors: NSSortDescriptor): Unit = extern
16 | // @inline def tableView(tableView: NSTableView, row: NSInteger): id[NSPasteboardWriting] = extern
17 | // @inline def tableView(tableView: NSTableView, session: NSDraggingSession, screenPoint: NSPoint, rowIndexes: NSIndexSet): Unit = extern
18 | // @inline def tableView(tableView: NSTableView, session: NSDraggingSession, screenPoint: NSPoint, operation: NSDragOperation): Unit = extern
19 | // @inline def tableView(tableView: NSTableView, draggingInfo: id): Unit = extern
20 | // @inline def tableView(tableView: NSTableView, rowIndexes: NSIndexSet, pboard: NSPasteboard): BOOL = extern
21 | // @inline def tableView(tableView: NSTableView, info: id, row: NSInteger, dropOperation: NSTableViewDropOperation): NSDragOperation = extern
22 | // @inline def tableView(tableView: NSTableView, info: id, row: NSInteger, dropOperation: NSTableViewDropOperation): BOOL = extern
23 | // @inline def tableView(tableView: NSTableView, dropDestination: NSURL, indexSet: NSIndexSet): NSArray[NSString] = extern
24 | }
25 |
26 |
27 |
--------------------------------------------------------------------------------
/docs/js/customscripts.js:
--------------------------------------------------------------------------------
1 | $('#mysidebar').height($(".nav").height());
2 |
3 |
4 | $( document ).ready(function() {
5 |
6 | //this script says, if the height of the viewport is greater than 800px, then insert affix class, which makes the nav bar float in a fixed
7 | // position as your scroll. if you have a lot of nav items, this height may not work for you.
8 | var h = $(window).height();
9 | //console.log (h);
10 | if (h > 800) {
11 | $( "#mysidebar" ).attr("class", "nav affix");
12 | }
13 | // activate tooltips. although this is a bootstrap js function, it must be activated this way in your theme.
14 | $('[data-toggle="tooltip"]').tooltip({
15 | placement : 'top'
16 | });
17 |
18 | /**
19 | * AnchorJS
20 | */
21 | anchors.add('h2,h3,h4,h5');
22 |
23 | });
24 |
25 | // needed for nav tabs on pages. See Formatting > Nav tabs for more details.
26 | // script from http://stackoverflow.com/questions/10523433/how-do-i-keep-the-current-tab-active-with-twitter-bootstrap-after-a-page-reload
27 | $(function() {
28 | var json, tabsState;
29 | $('a[data-toggle="pill"], a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
30 | var href, json, parentId, tabsState;
31 |
32 | tabsState = localStorage.getItem("tabs-state");
33 | json = JSON.parse(tabsState || "{}");
34 | parentId = $(e.target).parents("ul.nav.nav-pills, ul.nav.nav-tabs").attr("id");
35 | href = $(e.target).attr('href');
36 | json[parentId] = href;
37 |
38 | return localStorage.setItem("tabs-state", JSON.stringify(json));
39 | });
40 |
41 | tabsState = localStorage.getItem("tabs-state");
42 | json = JSON.parse(tabsState || "{}");
43 |
44 | $.each(json, function(containerId, href) {
45 | return $("#" + containerId + " a[href=" + href + "]").tab('show');
46 | });
47 |
48 | $("ul.nav.nav-pills, ul.nav.nav-tabs").each(function() {
49 | var $this = $(this);
50 | if (!json[$this.attr("id")]) {
51 | return $this.find("a[data-toggle=tab]:first, a[data-toggle=pill]:first").tab("show");
52 | }
53 | });
54 | });
55 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSDate.scala_:
--------------------------------------------------------------------------------
1 | package cocoa.foundation
2 |
3 | import scalanative.native._
4 |
5 | import scala.language.experimental.macros
6 |
7 |
8 | @ObjC
9 | class NSDate extends NSObject with NSCopying with NSSecureCoding {
10 | @inline def initWithTimeIntervalSinceReferenceDate(ti: NSTimeInterval): NSDate = extern
11 | @inline def initWithCoder(aDecoder: NSCoder): NSDate = extern
12 | @inline def timeIntervalSinceReferenceDate(): NSTimeInterval = extern
13 | @inline def timeIntervalSinceDate(anotherDate: NSDate): NSTimeInterval = extern
14 | @inline def addTimeInterval(seconds: NSTimeInterval): id = extern
15 | @inline def dateByAddingTimeInterval(ti: NSTimeInterval): NSDate = extern
16 | @inline def earlierDate(anotherDate: NSDate): NSDate = extern
17 | @inline def laterDate(anotherDate: NSDate): NSDate = extern
18 | @inline def compare(other: NSDate): NSComparisonResult = extern
19 | @inline def isEqualToDate(otherDate: NSDate): BOOL = extern
20 | @inline def descriptionWithLocale(locale: id): NSString = extern
21 | @inline def timeIntervalSinceNow(): NSTimeInterval = extern
22 | @inline def timeIntervalSince1970(): NSTimeInterval = extern
23 | @inline def initWithTimeIntervalSinceNow(secs: NSTimeInterval): NSDate = extern
24 | @inline def initWithTimeIntervalSince1970(secs: NSTimeInterval): NSDate = extern
25 | @inline def initWithTimeInterval(secsToBeAdded: NSTimeInterval, date: NSDate): NSDate = extern
26 | }
27 |
28 |
29 | @ObjCClass
30 | abstract class NSDateClass extends NSObjectClass {
31 | @inline def timeIntervalSinceReferenceDate(): NSTimeInterval = extern
32 | @inline def date(): NSDate = extern
33 | @inline def dateWithTimeIntervalSinceNow(secs: NSTimeInterval): NSDate = extern
34 | @inline def dateWithTimeIntervalSinceReferenceDate(ti: NSTimeInterval): NSDate = extern
35 | @inline def dateWithTimeIntervalSince1970(secs: NSTimeInterval): NSDate = extern
36 | @inline def dateWithTimeInterval(secsToBeAdded: NSTimeInterval, date: NSDate): NSDate = extern
37 | @inline def distantFuture(): NSDate = extern
38 | @inline def distantPast(): NSDate = extern
39 | }
40 |
41 | object NSDate extends NSDateClass {
42 | override type InstanceType = NSDate
43 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSLocale.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2017. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scalanative.native._
5 | import objc._
6 |
7 | import scala.language.experimental.macros
8 |
9 | import scala.scalanative.posix.inttypes.uint32_t
10 |
11 | @ObjC
12 | class NSLocale extends NSObject with NSCopying with NSSecureCoding {
13 | @inline def objectForKey_(key: id): id = extern
14 | @inline def displayNameForKey_value_(key: id, value: id): NSString = extern
15 | @inline def initWithLocaleIdentifier_(string: NSString): NSLocale = extern
16 | @inline def localeIdentifier(): NSString = extern
17 | }
18 |
19 |
20 | @ObjCClass
21 | abstract class NSLocaleClass extends NSObjectClass {
22 | @inline def autoupdatingCurrentLocale(): NSLocale = extern
23 | @inline def currentLocale(): NSLocale = extern
24 | @inline def systemLocale(): NSLocale = extern
25 | @inline def localeWithLocaleIdentifier_(ident: NSString): NSLocale = extern
26 | @inline def availableLocaleIdentifiers(): NSArray[NSString] = extern
27 | @inline def ISOLanguageCodes(): NSArray[NSString] = extern
28 | @inline def ISOCountryCodes(): NSArray[NSString] = extern
29 | @inline def ISOCurrencyCodes(): NSArray[NSString] = extern
30 | @inline def commonISOCurrencyCodes(): NSArray[NSString] = extern
31 | @inline def preferredLanguages(): NSArray[NSString] = extern
32 | @inline def componentsFromLocaleIdentifier_(string: NSString): NSDictionary[NSString, NSString] = extern
33 | @inline def localeIdentifierFromComponents_(dict: NSString): NSString = extern
34 | @inline def canonicalLocaleIdentifierFromString_(string: NSString): NSString = extern
35 | @inline def canonicalLanguageIdentifierFromString_(string: NSString): NSString = extern
36 | @inline def localeIdentifierFromWindowsLocaleCode_(lcid: uint32_t): NSString = extern
37 | @inline def windowsLocaleCodeFromLocaleIdentifier_(localeIdentifier: NSString): uint32_t = extern
38 | @inline def characterDirectionForLanguage_(isoLangCode: NSString): NSLocaleLanguageDirection = extern
39 | @inline def lineDirectionForLanguage_(isoLangCode: NSString): NSLocaleLanguageDirection = extern
40 | }
41 |
42 | object NSLocale extends NSLocaleClass {
43 | override type InstanceType = NSLocale
44 | }
--------------------------------------------------------------------------------
/docs/_data/samplelist.yml:
--------------------------------------------------------------------------------
1 | entries:
2 | - title: Sidebar
3 | folders:
4 | - title: Food
5 |
6 | folderitems:
7 | - title: Bananas
8 | url: bananas.html
9 |
10 | subfolder:
11 | - title: Apples
12 |
13 | subfolderitems:
14 | - title: Fuji apples
15 | url: fuji_apples.html
16 |
17 |
18 | - title: Gala apples
19 | url: gala_apples.html
20 |
21 | name:
22 | husband: Tom
23 | wife: Shannon
24 |
25 | bikes:
26 | - title: mountain bikes
27 | - title: road bikes
28 | - title: hybrid bikes
29 |
30 |
31 | salesteams:
32 | - title: Regions
33 | subfolderitems:
34 | - location: US
35 | - location: Spain
36 | - location: France
37 |
38 | toc:
39 | - title: Group 1
40 | subfolderitems:
41 | - page: Thing 1
42 | - page: Thing 2
43 | - page: Thing 3
44 | - title: Group 2
45 | subfolderitems:
46 | - page: Piece 1
47 | - page: Piece 2
48 | - page: Piece 3
49 | - title: Group 3
50 | subfolderitems:
51 | - page: Widget 1
52 | - page: Widget 2
53 | - page: Widget 3
54 |
55 | something: &hello Greetings earthling!
56 | myref: *hello
57 |
58 | about:
59 | - zero
60 | - one
61 | - two
62 | - three
63 |
64 | numbercolors:
65 | - zero:
66 | properties: red
67 | - one:
68 | properties: yellow
69 | - two:
70 | properties: green
71 | - three:
72 | properties: blue
73 |
74 | mypages:
75 | - section1: Section 1
76 | audience: developers
77 | product: acme
78 | url: facebook.com
79 | - section2: Section 2
80 | audience: writers
81 | product: acme
82 | url: google.com
83 | - section3: Section 3
84 | audience: developers
85 | product: acme
86 | url: amazon.com
87 | - section4: Section 4
88 | audience: writers
89 | product: gizmo
90 | url: apple.com
91 | - section5: Section 5
92 | audience: writers
93 | product: acme
94 | url: microsoft.com
95 |
96 | feedback: >
97 | This is my feedback to you.
98 | Even if I include linebreaks here,
99 | all of the linebreaks will be removed when the value is inserted.
100 |
101 | block: |
102 | This pipe does something a little different.
103 | It preserves the breaks.
104 | This is really helpful for code samples,
105 | since you can format the code samples with
106 | the appropriate
107 | white spacing.
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSTimeZone.scala_:
--------------------------------------------------------------------------------
1 | package cocoa.foundation
2 |
3 | import scala.language.experimental.macros
4 | import scalanative.native._
5 |
6 |
7 | @ObjC
8 | class NSTimeZone extends NSObject with NSCopying with NSSecureCoding {
9 | @inline def secondsFromGMTForDate(aDate: NSDate): NSInteger = extern
10 | @inline def abbreviationForDate(aDate: NSDate): NSString = extern
11 | @inline def isDaylightSavingTimeForDate(aDate: NSDate): BOOL = extern
12 | @inline def daylightSavingTimeOffsetForDate(aDate: NSDate): NSTimeInterval = extern
13 | @inline def nextDaylightSavingTimeTransitionAfterDate(aDate: NSDate): NSDate = extern
14 | @inline def name(): NSString = extern
15 | @inline def data(): NSData = extern
16 | @inline def isEqualToTimeZone(aTimeZone: NSTimeZone): BOOL = extern
17 | @inline def localizedName(style: NSTimeZoneNameStyle, locale: NSLocale): NSString = extern
18 | @inline def secondsFromGMT(): NSInteger = extern
19 | @inline def abbreviation(): NSString = extern
20 | @inline def isDaylightSavingTime(): BOOL = extern
21 | @inline def daylightSavingTimeOffset(): NSTimeInterval = extern
22 | @inline def nextDaylightSavingTimeTransition(): NSDate = extern
23 | @inline def initWithName(tzName: NSString): NSTimeZone = extern
24 | @inline def initWithName(tzName: NSString, aData: NSData): NSTimeZone = extern
25 | }
26 |
27 |
28 | @ObjCClass
29 | abstract class NSTimeZoneClass extends NSObjectClass {
30 | @inline def systemTimeZone(): NSTimeZone = extern
31 | @inline def resetSystemTimeZone(): Unit = extern
32 | @inline def defaultTimeZone(): NSTimeZone = extern
33 | @inline def setDefaultTimeZone(aTimeZone: NSTimeZone): Unit = extern
34 | @inline def localTimeZone(): NSTimeZone = extern
35 | @inline def knownTimeZoneNames(): NSArray[NSString] = extern
36 | @inline def abbreviationDictionary(): NSDictionary[NSString, NSString] = extern
37 | @inline def setAbbreviationDictionary(dict: NSString): Unit = extern
38 | @inline def timeZoneDataVersion(): NSString = extern
39 | @inline def timeZoneWithName(tzName: NSString): NSTimeZone = extern
40 | @inline def timeZoneWithName(tzName: NSString, aData: NSData): NSTimeZone = extern
41 | @inline def timeZoneForSecondsFromGMT(seconds: NSInteger): NSTimeZone = extern
42 | @inline def timeZoneWithAbbreviation(abbreviation: NSString): NSTimeZone = extern
43 | }
44 |
45 | object NSTimeZone extends NSTimeZoneClass {
46 | override type InstanceType = NSTimeZone
47 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/convert/Wrappers.scala:
--------------------------------------------------------------------------------
1 | // Project: scalanative-cocoa
2 | // Module:
3 | // Description:
4 | // Copyright (c) 2017. Distributed under the MIT License (see included LICENSE file).
5 | package cocoa.foundation.convert
6 |
7 | import scala.scalanative.native._
8 | import cocoa.foundation.{NSArray, NSDictionary, NSEnumerator, NSObject, Foundation, NSQuote}
9 | import Foundation.NSLog
10 | import objc.runtime._
11 |
12 | import scala.collection.immutable.AbstractMap
13 | import scala.collection.{AbstractIterator, AbstractSeq}
14 |
15 | object Wrappers {
16 |
17 | case class NSArrayWrapper[T<:NSObject](ns: NSArray[T]) extends AbstractSeq[T] with IndexedSeq[T] {
18 | override def length: Int = ns.count().toInt
19 | override def apply(idx: Int): T = ns.objectAtIndex_(idx.toUInt)
20 | }
21 |
22 | case class NSDictionaryWrapper[K<:NSObject, V<:NSObject](ns: NSDictionary[K,V]) extends AbstractMap[K,V] {
23 | private def keyIterator = NSEnumeratorWrapper(ns.keyEnumerator())
24 |
25 | override def +[B1 >: V](kv: (K, B1)): Map[K, B1] = ???
26 |
27 | override def get(key: K): Option[V] = ns.objectForKey_(key) match {
28 | case null => None
29 | case x => Some(x)
30 | }
31 |
32 | // TODO: more efficient implementation
33 | override def iterator: Iterator[(K, V)] = KeyValueIterator(keyIterator,ns)
34 |
35 | override def -(key: K): Map[K, V] = ???
36 |
37 | override def size: CInt = ns.count().toInt
38 | }
39 |
40 | private case class KeyValueIterator[K<:NSObject, V<:NSObject](keyIterator: Iterator[K], dict: NSDictionary[K,V])
41 | extends AbstractIterator[(K,V)] {
42 | override def hasNext: CBool = {
43 | keyIterator.hasNext
44 | }
45 | override def next(): (K, V) = {
46 | val key = keyIterator.next()
47 | (key,dict.objectForKey_(key))
48 | }
49 | }
50 |
51 | case class NSEnumeratorWrapper[T<:NSObject](ns: NSEnumerator[T]) extends AbstractIterator[T] {
52 | private var _next: id = _
53 | private var _consumed = true
54 |
55 | private def loadNext(): Unit =
56 | if(_consumed) {
57 | _next = ns.nextObject().toPtr
58 | _consumed = false
59 | }
60 |
61 | override def hasNext: CBool = {
62 | loadNext()
63 | _next != null
64 | }
65 |
66 | override def next(): T = {
67 | loadNext()
68 | _consumed = true
69 | _next.cast[NSObject].asInstanceOf[T]
70 | }
71 | }
72 | }
73 |
74 |
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSDatePicker.scala_:
--------------------------------------------------------------------------------
1 | package cocoa.appkit
2 |
3 | import scalanative.native._
4 | import cocoa.foundation.{BOOL, NSDate, NSLocale, NSTimeInterval, NSTimeZone}
5 | import objc.runtime.id
6 |
7 | import scala.language.experimental.macros
8 |
9 |
10 | @ObjC
11 | class NSDatePicker extends NSControl {
12 | @inline def datePickerStyle(): NSDatePickerStyle = extern
13 | @inline def setDatePickerStyle(datePickerStyle: NSDatePickerStyle): Unit = extern
14 | @inline def isBezeled(): BOOL = extern
15 | @inline def setBezeled(bezeled: BOOL): Unit = extern
16 | @inline def isBordered(): BOOL = extern
17 | @inline def setBordered(bordered: BOOL): Unit = extern
18 | @inline def drawsBackground(): BOOL = extern
19 | @inline def setDrawsBackground(drawsBackground: BOOL): Unit = extern
20 | // @inline def backgroundColor(): NSColor = extern
21 | // @inline def setBackgroundColor(backgroundColor: NSColor): Unit = extern
22 | // @inline def textColor(): NSColor = extern
23 | // @inline def setTextColor(textColor: NSColor): Unit = extern
24 | @inline def datePickerMode(): NSDatePickerMode = extern
25 | @inline def setDatePickerMode(datePickerMode: NSDatePickerMode): Unit = extern
26 | @inline def datePickerElements(): NSDatePickerElementFlags = extern
27 | @inline def setDatePickerElements(datePickerElements: NSDatePickerElementFlags): Unit = extern
28 | // @inline def calendar(): NSCalendar = extern
29 | // @inline def setCalendar(calendar: NSCalendar): Unit = extern
30 | @inline def locale(): NSLocale = extern
31 | @inline def setLocale(locale: NSLocale): Unit = extern
32 | @inline def timeZone(): NSTimeZone = extern
33 | @inline def setTimeZone(timeZone: NSTimeZone): Unit = extern
34 | @inline def dateValue(): NSDate = extern
35 | @inline def setDateValue(dateValue: NSDate): Unit = extern
36 | @inline def timeInterval(): NSTimeInterval = extern
37 | @inline def setTimeInterval(timeInterval: NSTimeInterval): Unit = extern
38 | @inline def minDate(): NSDate = extern
39 | @inline def setMinDate(minDate: NSDate): Unit = extern
40 | @inline def maxDate(): NSDate = extern
41 | @inline def setMaxDate(maxDate: NSDate): Unit = extern
42 | @inline def delegate(): id = extern
43 | @inline def setDelegate(delegate: id): Unit = extern
44 | }
45 |
46 |
47 | @ObjCClass
48 | abstract class NSDatePickerClass extends NSControlClass {
49 | }
50 |
51 | object NSDatePicker extends NSDatePickerClass {
52 | override type InstanceType = NSDatePicker
53 | }
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSObjectController.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import scala.language.experimental.macros
5 | import scalanative.native._
6 | import objc._
7 | import cocoa.foundation._
8 |
9 | @ObjC
10 | class NSObjectController[T<:NSObject] extends NSController {
11 | @inline def initWithContent_(content: id): NSObjectController[T] = extern
12 | @inline def prepareContent(): Unit = extern
13 | @inline def newObject(): id = extern
14 | @inline def addObject_(`object`: id): Unit = extern
15 | @inline def removeObject_(`object`: id): Unit = extern
16 | @inline def add_(sender: id): Unit = extern
17 | @inline def remove_(sender: id): Unit = extern
18 | @inline def validateUserInterfaceItem_(item: id): BOOL = extern
19 | @inline def content(): id = extern
20 | @inline def setContent_(content: id): Unit = extern
21 | @inline def selection(): id = extern
22 | @inline def selectedObjects(): NSArray[T] = extern
23 | @inline def automaticallyPreparesContent(): BOOL = extern
24 | @inline def setAutomaticallyPreparesContent_(automaticallyPreparesContent: BOOL): Unit = extern
25 | @inline def objectClass(): id = extern
26 | @inline def setObjectClass_(objectClass: id): Unit = extern
27 | @inline def isEditable(): BOOL = extern
28 | @inline def setEditable_(editable: BOOL): Unit = extern
29 | @inline def canAdd(): BOOL = extern
30 | @inline def canRemove(): BOOL = extern
31 | // @inline def fetchWithRequest_merge_error_(fetchRequest: NSFetchRequest, merge: BOOL, error: NSError): BOOL = extern
32 | @inline def fetch_(sender: id): Unit = extern
33 | // @inline def defaultFetchRequest(): NSFetchRequest = extern
34 | // @inline def managedObjectContext(): NSManagedObjectContext = extern
35 | // @inline def setManagedObjectContext_(managedObjectContext: NSManagedObjectContext): Unit = extern
36 | @inline def entityName(): NSString = extern
37 | @inline def setEntityName_(entityName: NSString): Unit = extern
38 | // @inline def fetchPredicate(): NSPredicate = extern
39 | // @inline def setFetchPredicate_(fetchPredicate: NSPredicate): Unit = extern
40 | @inline def usesLazyFetching(): BOOL = extern
41 | @inline def setUsesLazyFetching_(usesLazyFetching: BOOL): Unit = extern
42 | }
43 |
44 | @ObjCClass
45 | abstract class NSObjectControllerClass extends NSControllerClass {
46 | }
47 |
48 | object NSObjectController extends NSObjectControllerClass {
49 | override type InstanceType = NSObjectController[_]
50 | }
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSTableColumn.scala_:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import cocoa.foundation.{BOOL, NSCoding, NSInteger, NSObject, NSObjectClass, NSString, id}
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 |
9 |
10 | @ObjC
11 | class NSTableColumn extends NSObject with NSCoding { //with NSUserInterfaceItemIdentification {
12 | @inline def initWithIdentifier(identifier: NSString): NSTableColumn = extern
13 | @inline def sizeToFit(): Unit = extern
14 | @inline def identifier(): NSString = extern
15 | @inline def setIdentifier(identifier: NSString): Unit = extern
16 | @inline def tableView(): NSTableView = extern
17 | @inline def setTableView(tableView: NSTableView): Unit = extern
18 | // @inline def width(): CGFloat = extern
19 | // @inline def setWidth(width: CGFloat): Unit = extern
20 | // @inline def minWidth(): CGFloat = extern
21 | // @inline def setMinWidth(minWidth: CGFloat): Unit = extern
22 | // @inline def maxWidth(): CGFloat = extern
23 | // @inline def setMaxWidth(maxWidth: CGFloat): Unit = extern
24 | @inline def title(): NSString = extern
25 | @inline def setTitle(title: NSString): Unit = extern
26 | // @inline def headerCell(): NSTableHeaderCell = extern
27 | // @inline def setHeaderCell(headerCell: NSTableHeaderCell): Unit = extern
28 | @inline def isEditable(): BOOL = extern
29 | @inline def setEditable(editable: BOOL): Unit = extern
30 | // @inline def sortDescriptorPrototype(): NSSortDescriptor = extern
31 | // @inline def setSortDescriptorPrototype(sortDescriptorPrototype: NSSortDescriptor): Unit = extern
32 | // @inline def resizingMask(): NSTableColumnResizingOptions = extern
33 | // @inline def setResizingMask(resizingMask: NSTableColumnResizingOptions): Unit = extern
34 | @inline def headerToolTip(): NSString = extern
35 | @inline def setHeaderToolTip(headerToolTip: NSString): Unit = extern
36 | @inline def isHidden(): BOOL = extern
37 | @inline def setHidden(hidden: BOOL): Unit = extern
38 | @inline def setResizable(flag: BOOL): Unit = extern
39 | @inline def isResizable(): BOOL = extern
40 | @inline def dataCellForRow(row: NSInteger): id = extern
41 | @inline def dataCell(): id = extern
42 | @inline def setDataCell(dataCell: id): Unit = extern
43 | }
44 |
45 | @ObjCClass
46 | abstract class NSTableColumnClass extends NSObjectClass {
47 | }
48 |
49 | object NSTableColumn extends NSTableColumnClass {
50 | override type InstanceType = NSTableColumn
51 | }
--------------------------------------------------------------------------------
/docs/_includes/head.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | {{ page.title }} | {{ site.site_title }}
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSTableRowView.scala_:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import cocoa.foundation.{BOOL, NSInteger, NSObjectClass, NSRect, id}
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 |
9 |
10 | @ObjC
11 | class NSTableRowView extends NSView { //with NSAccessibilityRow {
12 | @inline def drawBackgroundInRect(dirtyRect: NSRect): Unit = extern
13 | @inline def drawSelectionInRect(dirtyRect: NSRect): Unit = extern
14 | @inline def drawSeparatorInRect(dirtyRect: NSRect): Unit = extern
15 | @inline def drawDraggingDestinationFeedbackInRect(dirtyRect: NSRect): Unit = extern
16 | @inline def viewAtColumn(column: NSInteger): id = extern
17 | @inline def selectionHighlightStyle(): NSTableViewSelectionHighlightStyle = extern
18 | @inline def setSelectionHighlightStyle(selectionHighlightStyle: NSTableViewSelectionHighlightStyle): Unit = extern
19 | @inline def isEmphasized(): BOOL = extern
20 | @inline def setEmphasized(emphasized: BOOL): Unit = extern
21 | @inline def isGroupRowStyle(): BOOL = extern
22 | @inline def setGroupRowStyle(groupRowStyle: BOOL): Unit = extern
23 | @inline def isSelected(): BOOL = extern
24 | @inline def setSelected(selected: BOOL): Unit = extern
25 | @inline def isPreviousRowSelected(): BOOL = extern
26 | @inline def setPreviousRowSelected(previousRowSelected: BOOL): Unit = extern
27 | @inline def isNextRowSelected(): BOOL = extern
28 | @inline def setNextRowSelected(nextRowSelected: BOOL): Unit = extern
29 | @inline def isFloating(): BOOL = extern
30 | @inline def setFloating(floating: BOOL): Unit = extern
31 | @inline def isTargetForDropOperation(): BOOL = extern
32 | @inline def setTargetForDropOperation(targetForDropOperation: BOOL): Unit = extern
33 | @inline def draggingDestinationFeedbackStyle(): NSTableViewDraggingDestinationFeedbackStyle = extern
34 | @inline def setDraggingDestinationFeedbackStyle(draggingDestinationFeedbackStyle: NSTableViewDraggingDestinationFeedbackStyle): Unit = extern
35 | // @inline def indentationForDropOperation(): CGFloat = extern
36 | // @inline def setIndentationForDropOperation(indentationForDropOperation: CGFloat): Unit = extern
37 | // @inline def interiorBackgroundStyle(): NSBackgroundStyle = extern
38 | // @inline def backgroundColor(): NSColor = extern
39 | // @inline def setBackgroundColor(backgroundColor: NSColor): Unit = extern
40 | @inline def numberOfColumns(): NSInteger = extern
41 | }
42 |
43 |
44 | @ObjCClass
45 | abstract class NSTableRowViewClass extends NSObjectClass {
46 | }
47 |
48 | object NSTableRowView extends NSTableRowViewClass {
49 | override type InstanceType = NSTableRowView
50 | }
--------------------------------------------------------------------------------
/coredata/src/main/scala/cocoa/coredata/NSManagedObjectModel.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.coredata
3 |
4 | import cocoa.foundation.{BOOL, NSArray, NSCoding, NSCopying, NSDictionary, NSFastEnumeration, NSObject, NSObjectClass, NSString, NSURL, id}
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 | import objc._
9 |
10 |
11 | @ObjC
12 | class NSManagedObjectModel extends NSObject with NSCoding with NSCopying with NSFastEnumeration {
13 | @inline def initWithContentsOfURL_(url: NSURL): NSManagedObjectModel = extern
14 | // @inline def entitiesForConfiguration_(configuration: NSString): NSArray[NSEntityDescription] = extern
15 | // @inline def setEntities_configuration_(entities: NSEntityDescription, configuration: NSString): Unit = extern
16 | // @inline def setFetchRequestTemplate_name_(fetchRequestTemplate: NSFetchRequest, name: NSString): Unit = extern
17 | // @inline def fetchRequestTemplateForName_(name: NSString): NSFetchRequest = extern
18 | // @inline def fetchRequestFromTemplateWithName_variables_(name: NSString, variables: id): NSFetchRequest = extern
19 | @inline def isConfiguration_metadata_(configuration: NSString, metadata: id): BOOL = extern
20 | // @inline def entitiesByName(): NSDictionary[NSString, NSEntityDescription] = extern
21 | // @inline def entities(): NSArray[NSEntityDescription] = extern
22 | // @inline def setEntities_(entities: NSArray[NSEntityDescription]): Unit = extern
23 | @inline def configurations(): NSArray[NSString] = extern
24 | @inline def localizationDictionary(): NSDictionary[NSString, NSString] = extern
25 | @inline def setLocalizationDictionary_(localizationDictionary: NSDictionary[NSString, NSString]): Unit = extern
26 | // @inline def fetchRequestTemplatesByName(): NSDictionary[NSString, NSFetchRequest] = extern
27 | // @inline def versionIdentifiers(): NSSet = extern
28 | // @inline def setVersionIdentifiers_(versionIdentifiers: NSSet): Unit = extern
29 | // @inline def entityVersionHashesByName(): NSDictionary[NSString, NSData] = extern
30 | }
31 |
32 | @ObjCClass
33 | abstract class NSManagedObjectModelClass extends NSObjectClass {
34 | // @inline def mergedModelFromBundles_(bundles: NSBundle): NSManagedObjectModel = extern
35 | @inline def modelByMergingModels_(models: NSManagedObjectModel): NSManagedObjectModel = extern
36 | // @inline def mergedModelFromBundles_metadata_(bundles: NSBundle, metadata: id): NSManagedObjectModel = extern
37 | @inline def modelByMergingModels_metadata_(models: NSManagedObjectModel, metadata: id): NSManagedObjectModel = extern
38 | }
39 |
40 | object NSManagedObjectModel extends NSManagedObjectModelClass {
41 | override type InstanceType = NSManagedObjectModel
42 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSMutableCharacterSet.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scala.language.experimental.macros
5 | import scalanative.native._
6 | import objc._
7 |
8 |
9 | @ObjC
10 | class NSMutableCharacterSet extends NSCharacterSet with NSCopying with NSMutableCopying {
11 | @inline def addCharactersInRange_(aRange: NSRange): Unit = extern
12 | @inline def removeCharactersInRange_(aRange: NSRange): Unit = extern
13 | @inline def addCharactersInString_(aString: NSString): Unit = extern
14 | @inline def removeCharactersInString_(aString: NSString): Unit = extern
15 | @inline def formUnionWithCharacterSet_(otherSet: NSCharacterSet): Unit = extern
16 | @inline def formIntersectionWithCharacterSet_(otherSet: NSCharacterSet): Unit = extern
17 | @inline def invert(): Unit = extern
18 | }
19 |
20 | @ObjCClass
21 | abstract class NSMutableCharacterSetClass extends NSCharacterSetClass {
22 | @inline override def controlCharacterSet(): NSMutableCharacterSet = extern
23 | @inline override def whitespaceCharacterSet(): NSMutableCharacterSet = extern
24 | @inline override def whitespaceAndNewlineCharacterSet(): NSMutableCharacterSet = extern
25 | @inline override def decimalDigitCharacterSet(): NSMutableCharacterSet = extern
26 | @inline override def letterCharacterSet(): NSMutableCharacterSet = extern
27 | @inline override def lowercaseLetterCharacterSet(): NSMutableCharacterSet = extern
28 | @inline override def uppercaseLetterCharacterSet(): NSMutableCharacterSet = extern
29 | @inline override def nonBaseCharacterSet(): NSMutableCharacterSet = extern
30 | @inline override def alphanumericCharacterSet(): NSMutableCharacterSet = extern
31 | @inline override def decomposableCharacterSet(): NSMutableCharacterSet = extern
32 | @inline override def illegalCharacterSet(): NSMutableCharacterSet = extern
33 | @inline override def punctuationCharacterSet(): NSMutableCharacterSet = extern
34 | @inline override def capitalizedLetterCharacterSet(): NSMutableCharacterSet = extern
35 | @inline override def symbolCharacterSet(): NSMutableCharacterSet = extern
36 | @inline override def newlineCharacterSet(): NSMutableCharacterSet = extern
37 | @inline override def characterSetWithRange_(aRange: NSRange): NSMutableCharacterSet = extern
38 | @inline override def characterSetWithCharactersInString_(aString: NSString): NSMutableCharacterSet = extern
39 | @inline override def characterSetWithBitmapRepresentation_(data: NSData): NSMutableCharacterSet = extern
40 | @inline override def characterSetWithContentsOfFile_(fName: NSString): NSMutableCharacterSet = extern
41 | }
42 |
43 | object NSMutableCharacterSet extends NSMutableCharacterSetClass {
44 | override type InstanceType = NSMutableCharacterSet
45 | }
--------------------------------------------------------------------------------
/coredata/src/main/scala/cocoa/coredata/NSPersistentContainer.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.coredata
3 |
4 | import cocoa.foundation.{NSArray, NSError, NSObject, NSObjectClass, NSString, NSURL}
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 | import objc._
9 |
10 |
11 | @ObjC
12 | class NSPersistentContainer extends NSObject {
13 | @inline def initWithName_(name: NSString): NSPersistentContainer = extern
14 | @inline def initWithName_model_(name: NSString, model: NSManagedObjectModel): NSPersistentContainer = extern
15 | @inline def loadPersistentStoresWithCompletionHandler_(block: Block2[NSPersistentStoreDescription,NSError,_]): Unit = extern
16 | @inline def newBackgroundContext(): NSManagedObjectContext = extern
17 | @inline def performBackgroundTask_(block: Ptr[Byte]): Unit = extern
18 | @inline def name(): NSString = extern
19 | @inline def viewContext(): NSManagedObjectContext = extern
20 | @inline def managedObjectModel(): NSManagedObjectModel = extern
21 | // @inline def persistentStoreCoordinator(): NSPersistentStoreCoordinator = extern
22 | // @inline def persistentStoreDescriptions(): NSArray[NSPersistentStoreDescription] = extern
23 | // @inline def setPersistentStoreDescriptions_(persistentStoreDescriptions: NSArray[NSPersistentStoreDescription]): Unit = extern
24 | }
25 |
26 | @ObjCClass
27 | abstract class NSPersistentContainerClass extends NSObjectClass {
28 | @inline def persistentContainerWithName_(name: NSString): NSPersistentContainer = extern
29 | @inline def persistentContainerWithName_model_(name: NSString, model: NSManagedObjectModel): NSPersistentContainer = extern
30 | @inline def defaultDirectoryURL(): NSURL = extern
31 | }
32 |
33 | object NSPersistentContainer extends NSPersistentContainerClass {
34 | override type InstanceType = NSPersistentContainer
35 |
36 | /**
37 | * Creates a persistent container with the given name.
38 | *
39 | * @param name The name of the container.
40 | */
41 | def apply(name: String): NSPersistentContainer =
42 | NSPersistentContainer.alloc().initWithName_(NSString(name))
43 |
44 | /**
45 | * Creates a persistent container with the given name and model.
46 | *
47 | * @param name The name used by the persistent container
48 | * @param model The managed object model used by the persistent container.
49 | */
50 | def apply(name: String, model: NSManagedObjectModel): NSPersistentContainer =
51 | NSPersistentContainer.alloc().initWithName_model_(NSString(name),model)
52 |
53 | // implicit final class Wrapper(val c: NSPersistentContainer) extends AnyVal {
54 | // @inline def loadStores(onComplete: CFunctionPtr2[Unit]): Unit = {
55 | // c.loadPersistentStoresWithCompletionHandler_(onComplete)
56 | // }
57 | // }
58 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSCharacterSet.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scala.language.experimental.macros
5 | import scalanative.native._
6 | import objc._
7 |
8 | import scala.scalanative.posix.inttypes.uint8_t
9 |
10 | @ObjC
11 | class NSCharacterSet extends NSObject with NSCopying with NSMutableCopying with NSCoding {
12 | @inline def characterIsMember_(aCharacter: unichar): BOOL = extern
13 | @inline def longCharacterIsMember_(theLongChar: CChar32): BOOL = extern
14 | @inline def isSupersetOfSet_(theOtherSet: NSCharacterSet): BOOL = extern
15 | @inline def hasMemberInPlane_(thePlane: uint8_t): BOOL = extern
16 | @inline def bitmapRepresentation(): NSData = extern
17 | @inline def invertedSet(): NSCharacterSet = extern
18 | }
19 |
20 | @ObjCClass
21 | abstract class NSCharacterSetClass extends NSObjectClass {
22 | @inline def controlCharacterSet(): NSCharacterSet = extern
23 | @inline def whitespaceCharacterSet(): NSCharacterSet = extern
24 | @inline def whitespaceAndNewlineCharacterSet(): NSCharacterSet = extern
25 | @inline def decimalDigitCharacterSet(): NSCharacterSet = extern
26 | @inline def letterCharacterSet(): NSCharacterSet = extern
27 | @inline def lowercaseLetterCharacterSet(): NSCharacterSet = extern
28 | @inline def uppercaseLetterCharacterSet(): NSCharacterSet = extern
29 | @inline def nonBaseCharacterSet(): NSCharacterSet = extern
30 | @inline def alphanumericCharacterSet(): NSCharacterSet = extern
31 | @inline def decomposableCharacterSet(): NSCharacterSet = extern
32 | @inline def illegalCharacterSet(): NSCharacterSet = extern
33 | @inline def punctuationCharacterSet(): NSCharacterSet = extern
34 | @inline def capitalizedLetterCharacterSet(): NSCharacterSet = extern
35 | @inline def symbolCharacterSet(): NSCharacterSet = extern
36 | @inline def newlineCharacterSet(): NSCharacterSet = extern
37 | @inline def characterSetWithRange_(aRange: NSRange): NSCharacterSet = extern
38 | @inline def characterSetWithCharactersInString_(aString: NSString): NSCharacterSet = extern
39 | @inline def characterSetWithBitmapRepresentation_(data: NSData): NSCharacterSet = extern
40 | @inline def characterSetWithContentsOfFile_(fName: NSString): NSCharacterSet = extern
41 |
42 | // from NSURL.h
43 | @inline def URLUserAllowedCharacterSet(): NSCharacterSet = extern
44 | @inline def URLPasswordAllowedCharacterSet(): NSCharacterSet = extern
45 | @inline def URLHostAllowedCharacterSet(): NSCharacterSet = extern
46 | @inline def URLPathAllowedCharacterSet(): NSCharacterSet = extern
47 | @inline def URLQueryAllowedCharacterSet(): NSCharacterSet = extern
48 | @inline def URLFragmentAllowedCharacterSet(): NSCharacterSet = extern
49 | }
50 |
51 | object NSCharacterSet extends NSCharacterSetClass {
52 | override type InstanceType = NSCharacterSet
53 | }
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSComboBox.scala_:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import cocoa.foundation.{BOOL, NSArray, NSInteger, NSObject, NSObjectClass, NSSize, id}
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 |
9 | @ObjC
10 | class NSComboBox extends NSTextField {
11 | @inline def reloadData(): Unit = extern
12 | @inline def noteNumberOfItemsChanged(): Unit = extern
13 | @inline def scrollItemAtIndexToTop(index: NSInteger): Unit = extern
14 | @inline def scrollItemAtIndexToVisible(index: NSInteger): Unit = extern
15 | @inline def selectItemAtIndex(index: NSInteger): Unit = extern
16 | @inline def deselectItemAtIndex(index: NSInteger): Unit = extern
17 | @inline def addItemWithObjectValue(`object`: id): Unit = extern
18 | @inline def addItemsWithObjectValues[T<:NSObject](objects: NSArray[T]): Unit = extern
19 | @inline def insertItemWithObjectValue(`object`: id, index: NSInteger): Unit = extern
20 | @inline def removeItemWithObjectValue(`object`: id): Unit = extern
21 | @inline def removeItemAtIndex(index: NSInteger): Unit = extern
22 | @inline def removeAllItems(): Unit = extern
23 | @inline def selectItemWithObjectValue(`object`: id): Unit = extern
24 | @inline def itemObjectValueAtIndex(index: NSInteger): id = extern
25 | @inline def indexOfItemWithObjectValue(`object`: id): NSInteger = extern
26 | @inline def hasVerticalScroller(): BOOL = extern
27 | @inline def setHasVerticalScroller(hasVerticalScroller: BOOL): Unit = extern
28 | @inline def intercellSpacing(): NSSize = extern
29 | @inline def setIntercellSpacing(intercellSpacing: NSSize): Unit = extern
30 | // @inline def itemHeight(): CGFloat = extern
31 | // @inline def setItemHeight(itemHeight: CGFloat): Unit = extern
32 | @inline def numberOfVisibleItems(): NSInteger = extern
33 | @inline def setNumberOfVisibleItems(numberOfVisibleItems: NSInteger): Unit = extern
34 | @inline def isButtonBordered(): BOOL = extern
35 | @inline def setButtonBordered(buttonBordered: BOOL): Unit = extern
36 | @inline def usesDataSource(): BOOL = extern
37 | @inline def setUsesDataSource(usesDataSource: BOOL): Unit = extern
38 | @inline def indexOfSelectedItem(): NSInteger = extern
39 | @inline def numberOfItems(): NSInteger = extern
40 | @inline def completes(): BOOL = extern
41 | @inline def setCompletes(completes: BOOL): Unit = extern
42 | @inline def dataSource(): NSComboBoxDataSource = extern
43 | @inline def setDataSource(dataSource: NSComboBoxDataSource): Unit = extern
44 | @inline def objectValueOfSelectedItem(): id = extern
45 | @inline def objectValues[T<:NSObject](): NSArray[T] = extern
46 | }
47 |
48 | @ObjCClass
49 | abstract class NSComboBoxClass extends NSObjectClass {
50 | }
51 |
52 | object NSComboBox extends NSComboBoxClass {
53 | override type InstanceType = NSComboBox
54 | }
--------------------------------------------------------------------------------
/docs/_includes/sidebar.html:
--------------------------------------------------------------------------------
1 | {% assign sidebar = site.data.sidebars[page.sidebar].entries %}
2 |
3 |
56 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/docs/css/theme-green.css:
--------------------------------------------------------------------------------
1 | .summary {
2 | color: #808080;
3 | border-left: 5px solid #E50E51;
4 | font-size:16px;
5 | }
6 |
7 |
8 | h3 {color: #E50E51; }
9 | h4 {color: #808080; }
10 |
11 | .nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
12 | background-color: #248ec2;
13 | color: white;
14 | }
15 |
16 | .nav > li.active > a {
17 | background-color: #72ac4a;
18 | }
19 |
20 | .nav > li > a:hover {
21 | background-color: #72ac4a;
22 | }
23 |
24 | div.navbar-collapse .dropdown-menu > li > a:hover {
25 | background-color: #72ac4a;
26 | }
27 |
28 | .navbar-inverse .navbar-nav>li>a, .navbar-inverse .navbar-brand {
29 | color: white;
30 | }
31 |
32 | .navbar-inverse .navbar-nav>li>a:hover, a.fa.fa-home.fa-lg.navbar-brand:hover {
33 | color: #f0f0f0;
34 | }
35 |
36 | .nav li.thirdlevel > a {
37 | background-color: #FAFAFA !important;
38 | color: #72ac4a;
39 | font-weight: bold;
40 | }
41 |
42 | a[data-toggle="tooltip"] {
43 | color: #649345;
44 | font-style: italic;
45 | cursor: default;
46 | }
47 |
48 | .navbar-inverse {
49 | background-color: #72ac4a;
50 | border-color: #5b893c;
51 | }
52 |
53 | .navbar-inverse .navbar-nav > .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus {
54 | color: #5b893c;
55 | }
56 |
57 | .navbar-inverse .navbar-nav > .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus {
58 | background-color: #5b893c;
59 | color: #ffffff;
60 | }
61 |
62 | /* not sure if using this ...*/
63 | .navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
64 | border-color: #72ac4a !important;
65 | }
66 |
67 | .btn-primary {
68 | color: #ffffff;
69 | background-color: #5b893c;
70 | border-color: #5b893c;
71 | }
72 |
73 | .btn-primary:hover,
74 | .btn-primary:focus,
75 | .btn-primary:active,
76 | .btn-primary.active,
77 | .open .dropdown-toggle.btn-primary {
78 | background-color: #72ac4a;
79 | border-color: #5b893c;
80 | }
81 |
82 | .printTitle {
83 | color: #5b893c !important;
84 | }
85 |
86 | body.print h1 {color: #5b893c !important; font-size:28px;}
87 | body.print h2 {color: #595959 !important; font-size:24px;}
88 | body.print h3 {color: #E50E51 !important; font-size:14px;}
89 | body.print h4 {color: #679DCE !important; font-size:14px; font-style: italic;}
90 |
91 | .anchorjs-link:hover {
92 | color: #4f7233;
93 | }
94 |
95 | div.sidebarTitle {
96 | color: #E50E51;
97 | }
98 |
99 | li.sidebarTitle {
100 | margin-top:20px;
101 | font-weight:normal;
102 | font-size:130%;
103 | color: #ED1951;
104 | margin-bottom:10px;
105 | margin-left: 5px;
106 | }
107 |
108 | .navbar-inverse .navbar-toggle:focus, .navbar-inverse .navbar-toggle:hover {
109 | background-color: #E50E51;
110 | }
111 |
--------------------------------------------------------------------------------
/test/src/test/scala/objc/test/ScalaObjCTest.scala:
--------------------------------------------------------------------------------
1 | // Project: scalanative-cocoa
2 | // Module: test
3 | // Description: Tests for Scala-defined ObjC classes
4 | // Copyright (c) 2017. Distributed under the MIT License (see included LICENSE file).
5 | package objc.test
6 | /*
7 | import cocoa.foundation.NSObjectClass
8 | import objc.{ObjCProxy, ScalaObjC}
9 | import objc.runtime._
10 | import objc.helper._
11 |
12 | import scalanative.native._
13 | import cocoa.foundation._
14 | import cocoa.foundation.Foundation.NSLog
15 | import de.surfice.smacrotools.debug
16 | import utest._
17 |
18 | object ScalaObjCTest extends TestSuite {
19 | val tests = TestSuite {
20 | 'alloc-{
21 | val foo = Foo.alloc()
22 | // check behaviour of ObjC proxy
23 | 'proxy-{
24 | val eut = foo.asInstanceOf[NSObject]
25 | val inst = foo.get
26 | assert( eut.className == "Foo" )
27 |
28 | assert( objc_msgSend(eut,sel_registerName(c"intProp")).cast[Int] == 42 )
29 |
30 | objc_msgSend(eut,sel_registerName(c"incr"))
31 | assert( objc_msgSend(eut,sel_registerName(c"intProp")).cast[Int] == 43 )
32 |
33 | objc_msgSend(eut,sel_registerName(c"setIntProp:"),-1)
34 | assert( objc_msgSend(eut,sel_registerName(c"intProp")).cast[Int] == -1 )
35 |
36 | assert( objc_msgSend(eut,sel_registerName(c"booleanProp")).cast[Boolean] == true )
37 |
38 | // TODO: check the result of objc_msgSend instead of the value on the Scala instance
39 | // (currently the result value seems to be 0 => why?)
40 | assert( inst.doubleProp == 1.234 )
41 | objc_msgSend(eut,sel_registerName(c"setDoubleProp:"),-2.345)
42 | assert( inst.doubleProp == -2.345 )
43 |
44 | assert( objc_msgSend(eut,sel_registerName(c"stringProp")) == null )
45 | objc_msgSend(eut,sel_registerName(c"setStringProp:"),"foo")
46 | assert( objc_msgSend(eut,sel_registerName(c"stringProp")).cast[String] == "foo" )
47 |
48 | assert( objc_msgSend(eut,sel_registerName(c"incr:"),42).cast[Int] == 43 )
49 |
50 | assert( objc_msgSend(eut,sel_registerName(c"add:b:"),2,3).cast[Int] == 5 )
51 | }
52 | // check behaviour of Scala instance
53 | 'scala-{
54 | val eut = foo.get
55 | assert( eut.intProp == 42 )
56 |
57 | eut.incr()
58 | assert( eut.intProp == 43 )
59 |
60 | eut.intProp = -1
61 | assert( eut.intProp == -1 )
62 | }
63 | }
64 | }
65 |
66 | @ScalaObjC
67 | // @debug
68 | class Foo(self: ObjCProxy[Foo]) extends NSObject {
69 | private var _intProp = 42
70 | def intProp = _intProp
71 | def intProp_=(i: Int) = _intProp = i
72 |
73 | val booleanProp = true
74 | var doubleProp = 1.234
75 |
76 | var stringProp: String = _
77 |
78 | def incr(): Unit = _intProp += 1
79 |
80 | def incr(i: Int): Int = i+1
81 |
82 | def add(a: Int, b: Int): Int = a + b
83 | }
84 | object Foo extends NSObjectClass {
85 | override type InstanceType = ObjCProxy[Foo]
86 | }
87 | }
88 | */
--------------------------------------------------------------------------------
/docs/css/theme-blue.css:
--------------------------------------------------------------------------------
1 | .summary {
2 | color: #808080;
3 | border-left: 5px solid #ED1951;
4 | font-size:16px;
5 | }
6 |
7 |
8 | h3 {color: #ED1951; }
9 | h4 {color: #808080; }
10 |
11 | .nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
12 | background-color: #248ec2;
13 | color: white;
14 | }
15 |
16 | .nav > li.active > a {
17 | background-color: #347DBE;
18 | }
19 |
20 | .nav > li > a:hover {
21 | background-color: #248ec2;
22 | }
23 |
24 | div.navbar-collapse .dropdown-menu > li > a:hover {
25 | background-color: #347DBE;
26 | }
27 |
28 | .nav li.thirdlevel > a {
29 | background-color: #FAFAFA !important;
30 | color: #248EC2;
31 | font-weight: bold;
32 | }
33 |
34 | a[data-toggle="tooltip"] {
35 | color: #649345;
36 | font-style: italic;
37 | cursor: default;
38 | }
39 |
40 | .navbar-inverse {
41 | background-color: #347DBE;
42 | border-color: #015CAE;
43 | }
44 | .navbar-inverse .navbar-nav>li>a, .navbar-inverse .navbar-brand {
45 | color: white;
46 | }
47 |
48 | .navbar-inverse .navbar-nav>li>a:hover, a.fa.fa-home.fa-lg.navbar-brand:hover {
49 | color: #f0f0f0;
50 | }
51 |
52 | a.navbar-brand:hover {
53 | color: #f0f0f0;
54 | }
55 |
56 | .navbar-inverse .navbar-nav > .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus {
57 | color: #015CAE;
58 | }
59 |
60 | .navbar-inverse .navbar-nav > .open > a, .navbar-inverse .navbar-nav > .open > a:hover, .navbar-inverse .navbar-nav > .open > a:focus {
61 | background-color: #015CAE;
62 | color: #ffffff;
63 | }
64 |
65 | .navbar-inverse .navbar-collapse, .navbar-inverse .navbar-form {
66 | border-color: #248ec2 !important;
67 | }
68 |
69 | .btn-primary {
70 | color: #ffffff;
71 | background-color: #347DBE;
72 | border-color: #347DBE;
73 | }
74 |
75 | .navbar-inverse .navbar-nav > .active > a, .navbar-inverse .navbar-nav > .active > a:hover, .navbar-inverse .navbar-nav > .active > a:focus {
76 | background-color: #347DBE;
77 | }
78 |
79 | .btn-primary:hover,
80 | .btn-primary:focus,
81 | .btn-primary:active,
82 | .btn-primary.active,
83 | .open .dropdown-toggle.btn-primary {
84 | background-color: #248ec2;
85 | border-color: #347DBE;
86 | }
87 |
88 | .printTitle {
89 | color: #015CAE !important;
90 | }
91 |
92 | body.print h1 {color: #015CAE !important; font-size:28px !important;}
93 | body.print h2 {color: #595959 !important; font-size:20px !important;}
94 | body.print h3 {color: #E50E51 !important; font-size:14px !important;}
95 | body.print h4 {color: #679DCE !important; font-size:14px; font-style: italic !important;}
96 |
97 | .anchorjs-link:hover {
98 | color: #216f9b;
99 | }
100 |
101 | div.sidebarTitle {
102 | color: #015CAE;
103 | }
104 |
105 | li.sidebarTitle {
106 | margin-top:20px;
107 | font-weight:normal;
108 | font-size:130%;
109 | color: #ED1951;
110 | margin-bottom:10px;
111 | margin-left: 5px;
112 |
113 | }
114 |
115 | .navbar-inverse .navbar-toggle:focus, .navbar-inverse .navbar-toggle:hover {
116 | background-color: #015CAE;
117 | }
118 |
119 | .navbar-inverse .navbar-toggle {
120 | border-color: #015CAE;
121 | }
122 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSIndexSet.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scala.language.experimental.macros
5 | import scalanative.native._
6 | import objc._
7 |
8 | @ObjC
9 | class NSIndexSet extends NSObject with NSCopying with NSMutableCopying with NSSecureCoding {
10 | @inline def initWithIndexesInRange_(range: NSRange): NSIndexSet = extern
11 | @inline def initWithIndexSet_(indexSet: NSIndexSet): NSIndexSet = extern
12 | @inline def initWithIndex_(value: NSUInteger): NSIndexSet = extern
13 | @inline def isEqualToIndexSet_(indexSet: NSIndexSet): BOOL = extern
14 | @inline def indexGreaterThanIndex_(value: NSUInteger): NSUInteger = extern
15 | @inline def indexLessThanIndex_(value: NSUInteger): NSUInteger = extern
16 | @inline def indexGreaterThanOrEqualToIndex_(value: NSUInteger): NSUInteger = extern
17 | @inline def indexLessThanOrEqualToIndex_(value: NSUInteger): NSUInteger = extern
18 | @inline def getIndexes_bufferSize_range_(indexBuffer: NSUInteger, bufferSize: NSUInteger, range: NSRangePointer): NSUInteger = extern
19 | @inline def countOfIndexesInRange_(range: NSRange): NSUInteger = extern
20 | @inline def containsIndex_(value: NSUInteger): BOOL = extern
21 | @inline def containsIndexesInRange_(range: NSRange): BOOL = extern
22 | @inline def containsIndexes_(indexSet: NSIndexSet): BOOL = extern
23 | @inline def intersectsIndexesInRange_(range: NSRange): BOOL = extern
24 | @inline def enumerateIndexesUsingBlock_(block: Ptr[Byte]): Unit = extern
25 | @inline def enumerateIndexesWithOptions_block_(opts: NSEnumerationOptions, block: Ptr[Byte]): Unit = extern
26 | @inline def enumerateIndexesInRange_opts_block_(range: NSRange, opts: NSEnumerationOptions, block: Ptr[Byte]): Unit = extern
27 | @inline def indexPassingTest_(predicate: BOOL): NSUInteger = extern
28 | @inline def indexWithOptions_predicate_(opts: NSEnumerationOptions, predicate: BOOL): NSUInteger = extern
29 | @inline def indexInRange_opts_predicate_(range: NSRange, opts: NSEnumerationOptions, predicate: BOOL): NSUInteger = extern
30 | @inline def indexesPassingTest_(predicate: BOOL): NSIndexSet = extern
31 | @inline def indexesWithOptions_predicate_(opts: NSEnumerationOptions, predicate: BOOL): NSIndexSet = extern
32 | @inline def indexesInRange_opts_predicate_(range: NSRange, opts: NSEnumerationOptions, predicate: BOOL): NSIndexSet = extern
33 | @inline def enumerateRangesUsingBlock_(block: Ptr[Byte]): Unit = extern
34 | @inline def enumerateRangesWithOptions_block_(opts: NSEnumerationOptions, block: Ptr[Byte]): Unit = extern
35 | @inline def enumerateRangesInRange_opts_block_(range: NSRange, opts: NSEnumerationOptions, block: Ptr[Byte]): Unit = extern
36 | @inline def count(): NSUInteger = extern
37 | @inline def firstIndex(): NSUInteger = extern
38 | @inline def lastIndex(): NSUInteger = extern
39 | }
40 |
41 | @ObjCClass
42 | abstract class NSIndexSetClass extends NSObjectClass {
43 | @inline def indexSet(): NSIndexSet = extern
44 | @inline def indexSetWithIndex_(value: NSUInteger): NSIndexSet = extern
45 | @inline def indexSetWithIndexesInRange_(range: NSRange): NSIndexSet = extern
46 | }
47 |
48 | object NSIndexSet extends NSIndexSetClass {
49 | override type InstanceType = NSIndexSet
50 | }
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSURLComponents.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scala.language.experimental.macros
5 | import scalanative.native._
6 | import objc._
7 |
8 | @ObjC
9 | class NSURLComponents extends NSObject with NSCopying {
10 | @inline def initWithURL_resolve_(url: NSURL, resolve: BOOL): NSURLComponents = extern
11 | @inline def initWithString_(URLString: NSString): NSURLComponents = extern
12 | @inline def URLRelativeToURL_(baseURL: NSURL): NSURL = extern
13 | @inline def URL(): NSURL = extern
14 | @inline def string(): NSString = extern
15 | @inline def scheme(): NSString = extern
16 | @inline def setScheme_(scheme: NSString): Unit = extern
17 | @inline def user(): NSString = extern
18 | @inline def setUser_(user: NSString): Unit = extern
19 | @inline def password(): NSString = extern
20 | @inline def setPassword_(password: NSString): Unit = extern
21 | @inline def host(): NSString = extern
22 | @inline def setHost_(host: NSString): Unit = extern
23 | @inline def port(): NSNumber = extern
24 | @inline def setPort_(port: NSNumber): Unit = extern
25 | @inline def path(): NSString = extern
26 | @inline def setPath_(path: NSString): Unit = extern
27 | @inline def query(): NSString = extern
28 | @inline def setQuery_(query: NSString): Unit = extern
29 | @inline def fragment(): NSString = extern
30 | @inline def setFragment_(fragment: NSString): Unit = extern
31 | @inline def percentEncodedUser(): NSString = extern
32 | @inline def setPercentEncodedUser_(percentEncodedUser: NSString): Unit = extern
33 | @inline def percentEncodedPassword(): NSString = extern
34 | @inline def setPercentEncodedPassword_(percentEncodedPassword: NSString): Unit = extern
35 | @inline def percentEncodedHost(): NSString = extern
36 | @inline def setPercentEncodedHost_(percentEncodedHost: NSString): Unit = extern
37 | @inline def percentEncodedPath(): NSString = extern
38 | @inline def setPercentEncodedPath_(percentEncodedPath: NSString): Unit = extern
39 | @inline def percentEncodedQuery(): NSString = extern
40 | @inline def setPercentEncodedQuery_(percentEncodedQuery: NSString): Unit = extern
41 | @inline def percentEncodedFragment(): NSString = extern
42 | @inline def setPercentEncodedFragment_(percentEncodedFragment: NSString): Unit = extern
43 | @inline def rangeOfScheme(): NSRange = extern
44 | @inline def rangeOfUser(): NSRange = extern
45 | @inline def rangeOfPassword(): NSRange = extern
46 | @inline def rangeOfHost(): NSRange = extern
47 | @inline def rangeOfPort(): NSRange = extern
48 | @inline def rangeOfPath(): NSRange = extern
49 | @inline def rangeOfQuery(): NSRange = extern
50 | @inline def rangeOfFragment(): NSRange = extern
51 | @inline def queryItems(): NSArray[NSURLQueryItem] = extern
52 | @inline def setQueryItems_(queryItems: NSArray[NSURLQueryItem]): Unit = extern
53 | }
54 |
55 | @ObjCClass
56 | abstract class NSURLComponentsClass extends NSObjectClass {
57 | @inline def componentsWithURL_resolve_(url: NSURL, resolve: BOOL): NSURLComponents = extern
58 | @inline def componentsWithString_(URLString: NSString): NSURLComponents = extern
59 | }
60 |
61 | object NSURLComponents extends NSURLComponentsClass {
62 | override type InstanceType = NSURLComponents
63 | }
--------------------------------------------------------------------------------
/docs/js/toc.js:
--------------------------------------------------------------------------------
1 | // https://github.com/ghiculescu/jekyll-table-of-contents
2 | (function($){
3 | $.fn.toc = function(options) {
4 | var defaults = {
5 | noBackToTopLinks: false,
6 | title: '',
7 | minimumHeaders: 3,
8 | headers: 'h1, h2, h3, h4',
9 | listType: 'ol', // values: [ol|ul]
10 | showEffect: 'show', // values: [show|slideDown|fadeIn|none]
11 | showSpeed: 'slow' // set to 0 to deactivate effect
12 | },
13 | settings = $.extend(defaults, options);
14 |
15 | var headers = $(settings.headers).filter(function() {
16 | // get all headers with an ID
17 | var previousSiblingName = $(this).prev().attr( "name" );
18 | if (!this.id && previousSiblingName) {
19 | this.id = $(this).attr( "id", previousSiblingName.replace(/\./g, "-") );
20 | }
21 | return this.id;
22 | }), output = $(this);
23 | if (!headers.length || headers.length < settings.minimumHeaders || !output.length) {
24 | return;
25 | }
26 |
27 | if (0 === settings.showSpeed) {
28 | settings.showEffect = 'none';
29 | }
30 |
31 | var render = {
32 | show: function() { output.hide().html(html).show(settings.showSpeed); },
33 | slideDown: function() { output.hide().html(html).slideDown(settings.showSpeed); },
34 | fadeIn: function() { output.hide().html(html).fadeIn(settings.showSpeed); },
35 | none: function() { output.html(html); }
36 | };
37 |
38 | var get_level = function(ele) { return parseInt(ele.nodeName.replace("H", ""), 10); }
39 | var highest_level = headers.map(function(_, ele) { return get_level(ele); }).get().sort()[0];
40 | var return_to_top = ' ';
41 |
42 | var level = get_level(headers[0]),
43 | this_level,
44 | html = settings.title + " <"+settings.listType+">";
45 | headers.on('click', function() {
46 | if (!settings.noBackToTopLinks) {
47 | window.location.hash = this.id;
48 | }
49 | })
50 | .addClass('clickable-header')
51 | .each(function(_, header) {
52 | this_level = get_level(header);
53 | if (!settings.noBackToTopLinks && this_level === highest_level) {
54 | $(header).addClass('top-level-header').after(return_to_top);
55 | }
56 | if (this_level === level) // same level as before; same indenting
57 | html += "" + header.innerHTML + " ";
58 | else if (this_level <= level){ // higher level than before; end parent ol
59 | for(i = this_level; i < level; i++) {
60 | html += " "+settings.listType+">"
61 | }
62 | html += "" + header.innerHTML + " ";
63 | }
64 | else if (this_level > level) { // lower level than before; expand the previous to contain a ol
65 | for(i = this_level; i > level; i--) {
66 | html += "<"+settings.listType+">"
67 | }
68 | html += "" + header.innerHTML + " ";
69 | }
70 | level = this_level; // update for the next one
71 | });
72 | html += ""+settings.listType+">";
73 | if (!settings.noBackToTopLinks) {
74 | $(document).on('click', '.back-to-top', function() {
75 | $(window).scrollTop(0);
76 | window.location.hash = '';
77 | });
78 | }
79 |
80 | render[settings.showEffect]();
81 | };
82 | })(jQuery);
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSTextViewDelegate.scala_:
--------------------------------------------------------------------------------
1 | package cocoa.appkit
2 |
3 | import scalanative.native._
4 | import cocoa.foundation.{BOOL, NSArray, NSDictionary, NSInteger, NSNotification, NSObject, NSRange, NSRect, NSString, NSUInteger, NSURL, NSValue}
5 | import objc.runtime.{SEL, id}
6 |
7 | import scala.language.experimental.macros
8 |
9 |
10 | @ObjC
11 | trait NSTextViewDelegate { //extends NSTextDelegate {
12 | @inline def textView(textView: NSTextView, link: id, charIndex: NSUInteger): BOOL = extern
13 | // @inline def textView(textView: NSTextView, cell: id, cellFrame: NSRect, charIndex: NSUInteger): Unit = extern
14 | // @inline def textView(textView: NSTextView, cell: id, cellFrame: NSRect, charIndex: NSUInteger): Unit = extern
15 | // @inline def textView(view: NSTextView, cell: id, rect: NSRect, event: NSEvent, charIndex: NSUInteger): Unit = extern
16 | // @inline def textView(view: NSTextView, cell: id, charIndex: NSUInteger): NSArray[NSString] = extern
17 | // @inline def textView(view: NSTextView, cell: id, charIndex: NSUInteger, pboard: NSPasteboard, `type`: NSString): BOOL = extern
18 | @inline def textView(textView: NSTextView, oldSelectedCharRange: NSRange, newSelectedCharRange: NSRange): NSRange = extern
19 | @inline def textView(textView: NSTextView, oldSelectedCharRanges: NSValue, newSelectedCharRanges: NSValue): NSArray[NSValue] = extern
20 | @inline def textView(textView: NSTextView, affectedRanges: NSValue, replacementStrings: NSString): BOOL = extern
21 | @inline def textView(textView: NSTextView, oldTypingAttributes: id, newTypingAttributes: id): NSDictionary[NSString, NSObject] = extern
22 | @inline def textViewDidChangeSelection(notification: NSNotification): Unit = extern
23 | @inline def textViewDidChangeTypingAttributes(notification: NSNotification): Unit = extern
24 | @inline def textView(textView: NSTextView, tooltip: NSString, characterIndex: NSUInteger): NSString = extern
25 | @inline def textView(textView: NSTextView, words: NSString, charRange: NSRange, index: NSInteger): NSArray[NSString] = extern
26 | @inline def textView(textView: NSTextView, affectedCharRange: NSRange, replacementString: NSString): BOOL = extern
27 | @inline def textView(textView: NSTextView, commandSelector: SEL): BOOL = extern
28 | @inline def textView(textView: NSTextView, value: NSInteger, affectedCharRange: NSRange): NSInteger = extern
29 | // @inline def textView(view: NSTextView, menu: NSMenu, event: NSEvent, charIndex: NSUInteger): NSMenu = extern
30 | // @inline def textView(view: NSTextView, range: NSRange, options: id, checkingTypes: NSTextCheckingTypes): NSDictionary[NSString, id] = extern
31 | // @inline def textView(view: NSTextView, range: NSRange, checkingTypes: NSTextCheckingTypes, options: id, results: NSTextCheckingResult, orthography: NSOrthography, wordCount: NSInteger): NSArray[NSTextCheckingResult] = extern
32 | // @inline def textView(textView: NSTextView, textAttachment: NSTextAttachment, charIndex: NSUInteger): NSURL = extern
33 | // @inline def textView(textView: NSTextView, servicePicker: NSSharingServicePicker, items: NSArray): NSSharingServicePicker = extern
34 | // @inline def undoManagerForTextView(view: NSTextView): NSUndoManager = extern
35 | // @inline def textView(textView: NSTextView, link: id): BOOL = extern
36 | @inline def textView(textView: NSTextView, cell: id, cellFrame: NSRect): Unit = extern
37 | @inline def textView(view: NSTextView, cell: id, rect: NSRect, event: NSEvent): Unit = extern
38 | }
39 |
--------------------------------------------------------------------------------
/docs/js/jquery.navgoco.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery Navgoco Menus Plugin v0.2.1 (2014-04-11)
3 | * https://github.com/tefra/navgoco
4 | *
5 | * Copyright (c) 2014 Chris T (@tefra)
6 | * BSD - https://github.com/tefra/navgoco/blob/master/LICENSE-BSD
7 | */
8 | !function(a){"use strict";var b=function(b,c,d){return this.el=b,this.$el=a(b),this.options=c,this.uuid=this.$el.attr("id")?this.$el.attr("id"):d,this.state={},this.init(),this};b.prototype={init:function(){var b=this;b._load(),b.$el.find("ul").each(function(c){var d=a(this);d.attr("data-index",c),b.options.save&&b.state.hasOwnProperty(c)?(d.parent().addClass(b.options.openClass),d.show()):d.parent().hasClass(b.options.openClass)?(d.show(),b.state[c]=1):d.hide()});var c=a(" ").prepend(b.options.caretHtml),d=b.$el.find("li > a");b._trigger(c,!1),b._trigger(d,!0),b.$el.find("li:has(ul) > a").prepend(c)},_trigger:function(b,c){var d=this;b.on("click",function(b){b.stopPropagation();var e=c?a(this).next():a(this).parent().next(),f=!1;if(c){var g=a(this).attr("href");f=void 0===g||""===g||"#"===g}if(e=e.length>0?e:!1,d.options.onClickBefore.call(this,b,e),!c||e&&f)b.preventDefault(),d._toggle(e,e.is(":hidden")),d._save();else if(d.options.accordion){var h=d.state=d._parents(a(this));d.$el.find("ul").filter(":visible").each(function(){var b=a(this),c=b.attr("data-index");h.hasOwnProperty(c)||d._toggle(b,!1)}),d._save()}d.options.onClickAfter.call(this,b,e)})},_toggle:function(b,c){var d=this,e=b.attr("data-index"),f=b.parent();if(d.options.onToggleBefore.call(this,b,c),c){if(f.addClass(d.options.openClass),b.slideDown(d.options.slide),d.state[e]=1,d.options.accordion){var g=d.state=d._parents(b);g[e]=d.state[e]=1,d.$el.find("ul").filter(":visible").each(function(){var b=a(this),c=b.attr("data-index");g.hasOwnProperty(c)||d._toggle(b,!1)})}}else f.removeClass(d.options.openClass),b.slideUp(d.options.slide),d.state[e]=0;d.options.onToggleAfter.call(this,b,c)},_parents:function(b,c){var d={},e=b.parent(),f=e.parents("ul");return f.each(function(){var b=a(this),e=b.attr("data-index");return e?void(d[e]=c?b:1):!1}),d},_save:function(){if(this.options.save){var b={};for(var d in this.state)1===this.state[d]&&(b[d]=1);c[this.uuid]=this.state=b,a.cookie(this.options.cookie.name,JSON.stringify(c),this.options.cookie)}},_load:function(){if(this.options.save){if(null===c){var b=a.cookie(this.options.cookie.name);c=b?JSON.parse(b):{}}this.state=c.hasOwnProperty(this.uuid)?c[this.uuid]:{}}},toggle:function(b){var c=this,d=arguments.length;if(1>=d)c.$el.find("ul").each(function(){var d=a(this);c._toggle(d,b)});else{var e,f={},g=Array.prototype.slice.call(arguments,1);d--;for(var h=0;d>h;h++){e=g[h];var i=c.$el.find('ul[data-index="'+e+'"]').first();if(i&&(f[e]=i,b)){var j=c._parents(i,!0);for(var k in j)f.hasOwnProperty(k)||(f[k]=j[k])}}for(e in f)c._toggle(f[e],b)}c._save()},destroy:function(){a.removeData(this.$el),this.$el.find("li:has(ul) > a").unbind("click"),this.$el.find("li:has(ul) > a > span").unbind("click")}},a.fn.navgoco=function(c){if("string"==typeof c&&"_"!==c.charAt(0)&&"init"!==c)var d=!0,e=Array.prototype.slice.call(arguments,1);else c=a.extend({},a.fn.navgoco.defaults,c||{}),a.cookie||(c.save=!1);return this.each(function(f){var g=a(this),h=g.data("navgoco");h||(h=new b(this,d?a.fn.navgoco.defaults:c,f),g.data("navgoco",h)),d&&h[c].apply(h,e)})};var c=null;a.fn.navgoco.defaults={caretHtml:"",accordion:!1,openClass:"open",save:!0,cookie:{name:"navgoco",expires:!1,path:"/"},slide:{duration:400,easing:"swing"},onClickBefore:a.noop,onClickAfter:a.noop,onToggleBefore:a.noop,onToggleAfter:a.noop}}(jQuery);
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSMutableArray.scala_:
--------------------------------------------------------------------------------
1 | // Project: scalanative-cocoa
2 | // Module: Foundation
3 | // Description: Generated with scala-obj-bindgen (with manual postprocessing) from:
4 | // Foundation/NSArray.h
5 | // Copyright (c) 2017. Distributed under the MIT License (see included LICENSE file).
6 | package cocoa.foundation
7 |
8 | import scalanative.native._
9 |
10 | import scala.language.experimental.macros
11 |
12 |
13 | @ObjC
14 | class NSMutableArray[T<:NSObject] extends NSArray[T] {
15 | @inline def addObject(anObject: T): Unit = extern
16 | @inline def insertObject(anObject: T, index: NSUInteger): Unit = extern
17 | @inline def removeLastObject(): Unit = extern
18 | @inline def removeObjectAtIndex(index: NSUInteger): Unit = extern
19 | @inline def replaceObjectAtIndex(index: NSUInteger, anObject: T): Unit = extern
20 | // @inline def init(): NSMutableArray[T] = extern
21 | @inline def initWithCapacity(numItems: NSUInteger): NSMutableArray[T] = extern
22 | // @inline def initWithCoder(aDecoder: NSCoder): NSMutableArray[T] = extern
23 | @inline def addObjectsFromArray(otherArray: T): Unit = extern
24 | @inline def exchangeObjectAtIndex(idx1: NSUInteger, idx2: NSUInteger): Unit = extern
25 | @inline def removeAllObjects(): Unit = extern
26 | @inline def removeObject(anObject: T, range: NSRange): Unit = extern
27 | @inline def removeObject(anObject: T): Unit = extern
28 | @inline def removeObjectIdenticalTo(anObject: T, range: NSRange): Unit = extern
29 | @inline def removeObjectIdenticalTo(anObject: T): Unit = extern
30 | @inline def removeObjectsFromIndices(indices: NSUInteger, cnt: NSUInteger): Unit = extern
31 | @inline def removeObjectsInArray(otherArray: T): Unit = extern
32 | @inline def removeObjectsInRange(range: NSRange): Unit = extern
33 | @inline def replaceObjectsInRange(range: NSRange, otherArray: T, otherRange: NSRange): Unit = extern
34 | @inline def replaceObjectsInRange(range: NSRange, otherArray: T): Unit = extern
35 | @inline def setArray(otherArray: T): Unit = extern
36 | @inline def sortUsingFunction(compare: NSInteger, context: Ptr[Byte]): Unit = extern
37 | @inline def sortUsingSelector(comparator: SEL): Unit = extern
38 | // @inline def insertObjects(objects: T, indexes: NSIndexSet): Unit = extern
39 | // @inline def removeObjectsAtIndexes(indexes: NSIndexSet): Unit = extern
40 | // @inline def replaceObjectsAtIndexes(indexes: NSIndexSet, objects: T): Unit = extern
41 | @inline def setObject(obj: T, idx: NSUInteger): Unit = extern
42 | // @inline def sortUsingComparator(cmptr: NSComparator): Unit = extern
43 | // @inline def sortWithOptions(opts: NSSortOptions, cmptr: NSComparator): Unit = extern
44 | @inline def initWithContentsOfFile(path: NSString): NSMutableArray[T] = extern
45 | @inline def initWithContentsOfURL(url: NSURL): NSMutableArray[T] = extern
46 | }
47 |
48 | @ObjCClass
49 | abstract class NSMutableArrayClass extends NSArrayClass {
50 | @inline override def array[T<:NSObject](): NSMutableArray[T] = extern
51 | @inline override def arrayWithObject[T<:NSObject](anObject: T): NSMutableArray[T] = extern
52 | @inline def arrayWithCapacity[T<:NSObject](numItems: NSUInteger): NSMutableArray[T] = extern
53 | @inline def arrayWithContentsOfFile[T<:NSObject](path: NSString): NSMutableArray[T] = extern
54 | @inline def arrayWithContentsOfURL[T<:NSObject](url: NSURL): NSMutableArray[T] = extern
55 | }
56 |
57 | object NSMutableArray extends NSMutableArrayClass {
58 | override type InstanceType = NSMutableArray[_]
59 | }
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSArrayController.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import scalanative.native._
5 | import objc._
6 | import cocoa.foundation._
7 |
8 |
9 | @ObjC
10 | class NSArrayController[T<:NSObject] extends NSObjectController[T] {
11 | @inline def rearrangeObjects(): Unit = extern
12 | @inline def didChangeArrangementCriteria(): Unit = extern
13 | @inline def arrangeObjects_(objects: NSArray[T]): NSArray[T] = extern
14 | @inline def setSelectionIndexes_(indexes: NSIndexSet): BOOL = extern
15 | @inline def setSelectionIndex_(index: NSUInteger): BOOL = extern
16 | @inline def addSelectionIndexes_(indexes: NSIndexSet): BOOL = extern
17 | @inline def removeSelectionIndexes_(indexes: NSIndexSet): BOOL = extern
18 | @inline def setSelectedObjects_(objects: NSArray[T]): BOOL = extern
19 | @inline def addSelectedObjects_(objects: NSArray[T]): BOOL = extern
20 | @inline def removeSelectedObjects_(objects: NSArray[T]): BOOL = extern
21 | @inline def insert_(sender: id): Unit = extern
22 | @inline def selectNext_(sender: id): Unit = extern
23 | @inline def selectPrevious_(sender: id): Unit = extern
24 | @inline def addObjects_(objects: NSArray[T]): Unit = extern
25 | @inline def insertObject_index_(`object`: id, index: NSUInteger): Unit = extern
26 | @inline def insertObjects_indexes_(objects: NSArray[T], indexes: NSIndexSet): Unit = extern
27 | @inline def removeObjectAtArrangedObjectIndex_(index: NSUInteger): Unit = extern
28 | @inline def removeObjectsAtArrangedObjectIndexes_(indexes: NSIndexSet): Unit = extern
29 | @inline def removeObjects_(objects: NSArray[T]): Unit = extern
30 | @inline def automaticallyRearrangesObjects(): BOOL = extern
31 | @inline def setAutomaticallyRearrangesObjects_(automaticallyRearrangesObjects: BOOL): Unit = extern
32 | @inline def automaticRearrangementKeyPaths(): NSArray[T] = extern
33 | // @inline def sortDescriptors(): NSArray[T][NSSortDescriptor] = extern
34 | // @inline def setSortDescriptors_(sortDescriptors: NSArray[T][NSSortDescriptor]): Unit = extern
35 | // @inline def filterPredicate(): NSPredicate = extern
36 | // @inline def setFilterPredicate_(filterPredicate: NSPredicate): Unit = extern
37 | @inline def clearsFilterPredicateOnInsertion(): BOOL = extern
38 | @inline def setClearsFilterPredicateOnInsertion_(clearsFilterPredicateOnInsertion: BOOL): Unit = extern
39 | @inline def arrangedObjects(): id = extern
40 | @inline def avoidsEmptySelection(): BOOL = extern
41 | @inline def setAvoidsEmptySelection_(avoidsEmptySelection: BOOL): Unit = extern
42 | @inline def preservesSelection(): BOOL = extern
43 | @inline def setPreservesSelection_(preservesSelection: BOOL): Unit = extern
44 | @inline def selectsInsertedObjects(): BOOL = extern
45 | @inline def setSelectsInsertedObjects_(selectsInsertedObjects: BOOL): Unit = extern
46 | @inline def alwaysUsesMultipleValuesMarker(): BOOL = extern
47 | @inline def setAlwaysUsesMultipleValuesMarker_(alwaysUsesMultipleValuesMarker: BOOL): Unit = extern
48 | @inline def selectionIndexes(): NSIndexSet = extern
49 | @inline def selectionIndex(): NSUInteger = extern
50 | @inline def canInsert(): BOOL = extern
51 | @inline def canSelectNext(): BOOL = extern
52 | @inline def canSelectPrevious(): BOOL = extern
53 | }
54 |
55 | @ObjCClass
56 | abstract class NSArrayControllerClass extends NSObjectControllerClass {
57 | }
58 |
59 | object NSArrayController extends NSArrayControllerClass {
60 | override type InstanceType = NSArrayController[_]
61 | }
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSTableViewDelegate.scala_:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import cocoa.foundation.{BOOL, NSArray, NSInteger, NSNotification, NSString, id}
5 |
6 | import scalanative.native._
7 |
8 | @ObjC
9 | trait NSTableViewDelegate extends NSControlTextEditingDelegate {
10 | @inline def tableView_viewForTableColumn_row_(tableView: NSTableView, column: NSTableColumn, row: NSInteger): NSView = extern
11 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn, row: NSInteger): NSView = extern
12 | // @inline def tableView(tableView: NSTableView, row: NSInteger): NSTableRowView = extern
13 | // @inline def tableView(tableView: NSTableView, rowView: NSTableRowView, row: NSInteger): Unit = extern
14 | // @inline def tableView(tableView: NSTableView, rowView: NSTableRowView, row: NSInteger): Unit = extern
15 | // @inline def tableView(tableView: NSTableView, cell: id, tableColumn: NSTableColumn, row: NSInteger): Unit = extern
16 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn, row: NSInteger): BOOL = extern
17 | // @inline def tableView(tableView: NSTableView, cell: NSCell, rect: NSRectPointer, tableColumn: NSTableColumn, row: NSInteger, mouseLocation: NSPoint): NSString = extern
18 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn, row: NSInteger): BOOL = extern
19 | // @inline def tableView(tableView: NSTableView, cell: NSCell, tableColumn: NSTableColumn, row: NSInteger): BOOL = extern
20 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn, row: NSInteger): NSCell = extern
21 | // @inline def selectionShouldChangeInTableView(tableView: NSTableView): BOOL = extern
22 | // @inline def tableView(tableView: NSTableView, row: NSInteger): BOOL = extern
23 | // @inline def tableView(tableView: NSTableView, proposedSelectionIndexes: NSIndexSet): NSIndexSet = extern
24 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn): BOOL = extern
25 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn): Unit = extern
26 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn): Unit = extern
27 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn): Unit = extern
28 | // @inline def tableView(tableView: NSTableView, row: NSInteger): CGFloat = extern
29 | // @inline def tableView(tableView: NSTableView, tableColumn: NSTableColumn, row: NSInteger): NSString = extern
30 | // @inline def tableView(tableView: NSTableView, startRow: NSInteger, endRow: NSInteger, searchString: NSString): NSInteger = extern
31 | // @inline def tableView(tableView: NSTableView, event: NSEvent, searchString: NSString): BOOL = extern
32 | // @inline def tableView(tableView: NSTableView, row: NSInteger): BOOL = extern
33 | // @inline def tableView(tableView: NSTableView, column: NSInteger): CGFloat = extern
34 | // @inline def tableView(tableView: NSTableView, columnIndex: NSInteger, newColumnIndex: NSInteger): BOOL = extern
35 | // @inline def tableView(tableView: NSTableView, row: NSInteger, edge: NSTableRowActionEdge): NSArray[NSTableViewRowAction] = extern
36 | @inline def tableViewSelectionDidChange(notification: NSNotification): Unit = extern
37 | // @inline def tableViewColumnDidMove(notification: NSNotification): Unit = extern
38 | // @inline def tableViewColumnDidResize(notification: NSNotification): Unit = extern
39 | // @inline def tableViewSelectionIsChanging(notification: NSNotification): Unit = extern
40 | }
41 |
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSMutableDictionary.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scalanative.native._
5 | import objc._
6 |
7 | @ObjC
8 | class NSMutableDictionary[K<:NSObject,V<:NSObject] extends NSDictionary[K,V] {
9 | @inline def removeObjectForKey_(aKey: K): Unit = extern
10 | @inline def setObject_aKey_(anObject: V, aKey: K): Unit = extern
11 | @inline def initWithCapacity_(numItems: NSUInteger): NSMutableDictionary[K, V] = extern
12 | @inline def addEntriesFromDictionary_(otherDictionary: V): Unit = extern
13 | @inline def removeAllObjects(): Unit = extern
14 | @inline def removeObjectsForKeys_(keyArray: K): Unit = extern
15 | @inline def setDictionary_(otherDictionary: V): Unit = extern
16 | @inline def setObject_forKey_(obj: V, key: K): Unit = extern
17 | @inline override def initWithContentsOfFile_(path: NSString): NSMutableDictionary[K, V] = extern
18 | @inline override def initWithContentsOfURL_(url: NSURL): NSMutableDictionary[K, V] = extern
19 | }
20 |
21 | @ObjCClass
22 | abstract class NSMutableDictionaryClass extends NSDictionaryClass {
23 | @inline def dictionaryWithCapacity_[K<:NSObject,V<:NSObject](numItems: NSUInteger): NSMutableDictionary[K, V] = extern
24 | @inline override def dictionaryWithContentsOfFile_[K<:NSObject,V<:NSObject](path: NSString): NSMutableDictionary[K, V] = extern
25 | @inline override def dictionaryWithContentsOfURL_[K<:NSObject,V<:NSObject](url: NSURL): NSMutableDictionary[K, V] = extern
26 | @inline def dictionaryWithSharedKeySet_[K<:NSObject,V<:NSObject](keyset: id): NSMutableDictionary[K, V] = extern
27 |
28 | @inline override def dictionary[K<:NSObject,V<:NSObject](): NSMutableDictionary[K, V] = extern
29 | @inline override def dictionaryWithObject_key_[K<:NSObject,V<:NSObject](`object`: V, key: K): NSMutableDictionary[K, V] = extern
30 | @inline override def dictionaryWithObjects_forKeys_count_[K<:NSObject,V<:NSObject](objects: Ptr[id], keys: Ptr[id], cnt: NSUInteger): NSMutableDictionary[K, V] = extern
31 | @inline override def dictionaryWithObjectsAndKeys_[K<:NSObject,V<:NSObject](firstObject: id): NSMutableDictionary[K, V] = extern
32 | @inline override def dictionaryWithDictionary_[K<:NSObject,V<:NSObject](dict: V): NSMutableDictionary[K, V] = extern
33 | @inline override def dictionaryWithObjects_forKeys_[K<:NSObject,V<:NSObject](objects: Ptr[id], keys: Ptr[id]): NSMutableDictionary[K, V] = extern
34 | @inline override def sharedKeySetForKeys_[K<:NSObject](keys: K): id = extern
35 | }
36 |
37 | object NSMutableDictionary extends NSMutableDictionaryClass {
38 | override type InstanceType = NSMutableDictionary[_,_]
39 | def apply[K<:NSObject, V<:NSObject](kv: (K,V)*): NSDictionary[K,V] = dictionaryWithObjects(kv)
40 |
41 | // TODO: use Iterable instead of Seq?
42 | def dictionaryWithObjects[K<:NSObject, V<:NSObject](objects: Seq[(K,V)]): NSMutableDictionary[K,V] = Zone { implicit z =>
43 | val count = objects.size
44 | val objArray = stackalloc[id]( sizeof[id] * count)
45 | val keyArray = stackalloc[id]( sizeof[id] * count )
46 | for(i<-0 until count) {
47 | !(keyArray + i) = objects(i)._1.toPtr
48 | !(objArray + i) = objects(i)._2.toPtr
49 | }
50 | dictionaryWithObjects_forKeys_count_(objArray,keyArray,count.toULong)
51 | //objc_msgSend(__cls,__sel_dictionaryWithObjects_forKeys_count,objArray,keyArray,count).cast[NSDictionary[K,V]]
52 | }
53 |
54 | def empty[K<:NSObject,V<:NSObject]: NSMutableDictionary[K,V] = alloc().init().asInstanceOf[NSMutableDictionary[K,V]]
55 | }
--------------------------------------------------------------------------------
/coredata/src/main/scala/cocoa/coredata/NSEntityDescription.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.coredata
3 |
4 | import cocoa.foundation.{BOOL, NSArray, NSCoding, NSCopying, NSData, NSDictionary, NSFastEnumeration, NSObject, NSObjectClass, NSString}
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 | import objc._
9 |
10 |
11 | @ObjC
12 | class NSEntityDescription extends NSObject with NSCoding with NSCopying with NSFastEnumeration {
13 | // @inline def relationshipsWithDestinationEntity_(entity: NSEntityDescription): NSArray[NSRelationshipDescription] = extern
14 | @inline def isKindOfEntity_(entity: NSEntityDescription): BOOL = extern
15 | @inline def managedObjectModel(): NSManagedObjectModel = extern
16 | @inline def managedObjectClassName(): NSString = extern
17 | @inline def setManagedObjectClassName_(managedObjectClassName: NSString): Unit = extern
18 | @inline def name(): NSString = extern
19 | @inline def setName_(name: NSString): Unit = extern
20 | @inline def isAbstract(): BOOL = extern
21 | @inline def setAbstract_(flag: BOOL): Unit = extern
22 | @inline def subentitiesByName(): NSDictionary[NSString, NSEntityDescription] = extern
23 | @inline def subentities(): NSArray[NSEntityDescription] = extern
24 | @inline def setSubentities_(subentities: NSArray[NSEntityDescription]): Unit = extern
25 | @inline def superentity(): NSEntityDescription = extern
26 | // @inline def propertiesByName(): NSDictionary[NSString, NSPropertyDescription] = extern
27 | // @inline def properties(): NSArray[NSPropertyDescription] = extern
28 | // @inline def setProperties_(properties: NSArray[NSPropertyDescription]): Unit = extern
29 | @inline def userInfo(): NSDictionary[NSObject,NSObject] = extern
30 | @inline def setUserInfo_(userInfo: NSDictionary[NSObject,NSObject]): Unit = extern
31 | // @inline def attributesByName(): NSDictionary[NSString, NSAttributeDescription] = extern
32 | // @inline def relationshipsByName(): NSDictionary[NSString, NSRelationshipDescription] = extern
33 | @inline def versionHash(): NSData = extern
34 | @inline def versionHashModifier(): NSString = extern
35 | @inline def setVersionHashModifier_(versionHashModifier: NSString): Unit = extern
36 | @inline def renamingIdentifier(): NSString = extern
37 | @inline def setRenamingIdentifier_(renamingIdentifier: NSString): Unit = extern
38 | // @inline def indexes(): NSArray[NSFetchIndexDescription] = extern
39 | // @inline def setIndexes_(indexes: NSArray[NSFetchIndexDescription]): Unit = extern
40 | // @inline def uniquenessConstraints(): NSArray[NSArray] = extern
41 | // @inline def setUniquenessConstraints_(uniquenessConstraints: NSArray[NSArray]): Unit = extern
42 | // @inline def compoundIndexes(): NSArray[NSArray] = extern
43 | // @inline def setCompoundIndexes_(compoundIndexes: NSArray[NSArray]): Unit = extern
44 | // @inline def coreSpotlightDisplayNameExpression(): NSExpression = extern
45 | // @inline def setCoreSpotlightDisplayNameExpression_(coreSpotlightDisplayNameExpression: NSExpression): Unit = extern
46 | }
47 |
48 | @ObjCClass
49 | abstract class NSEntityDescriptionClass extends NSObjectClass {
50 | @inline def entityForName_inManagedObjectContext_(entityName: NSString, context: NSManagedObjectContext): NSEntityDescription = extern
51 | @inline def insertNewObjectForEntityForName_inManagedObjectContext_(entityName: NSString, context: NSManagedObjectContext): NSManagedObject = extern
52 | }
53 |
54 | object NSEntityDescription extends NSEntityDescriptionClass {
55 | override type InstanceType = NSEntityDescription
56 | }
--------------------------------------------------------------------------------
/coredata/src/main/scala/cocoa/coredata/NSManagedObject.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.coredata
3 |
4 | import cocoa.foundation._
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 | import objc._
9 |
10 | @ObjC
11 | class NSManagedObject extends NSObject {
12 | // @inline def initWithEntity_context_(entity: NSEntityDescription, context: NSManagedObjectContext): NSManagedObject = extern
13 | @inline def initWithContext_(moc: NSManagedObjectContext): NSManagedObject = extern
14 | @inline def hasFaultForRelationshipNamed_(key: NSString): BOOL = extern
15 | @inline def objectIDsForRelationshipNamed_(key: NSString): NSArray[NSManagedObjectID] = extern
16 | @inline def willAccessValueForKey_(key: NSString): Unit = extern
17 | @inline def didAccessValueForKey_(key: NSString): Unit = extern
18 | @inline def willChangeValueForKey_(key: NSString): Unit = extern
19 | @inline def didChangeValueForKey_(key: NSString): Unit = extern
20 | // @inline def willChangeValueForKey_inMutationKind_inObjects_(inKey: NSString, inMutationKind: NSKeyValueSetMutationKind, inObjects: NSSet): Unit = extern
21 | // @inline def didChangeValueForKey_inMutationKind_inObjects_(inKey: NSString, inMutationKind: NSKeyValueSetMutationKind, inObjects: NSSet): Unit = extern
22 | @inline def awakeFromFetch(): Unit = extern
23 | @inline def awakeFromInsert(): Unit = extern
24 | @inline def awakeFromSnapshotEvents_(flags: NSSnapshotEventType): Unit = extern
25 | @inline def prepareForDeletion(): Unit = extern
26 | @inline def willSave(): Unit = extern
27 | @inline def didSave(): Unit = extern
28 | @inline def willTurnIntoFault(): Unit = extern
29 | @inline def didTurnIntoFault(): Unit = extern
30 | @inline def valueForKey_(key: NSString): id = extern
31 | @inline def setValue_key_(value: id, key: NSString): Unit = extern
32 | @inline def primitiveValueForKey_(key: NSString): id = extern
33 | @inline def setPrimitiveValue_key_(value: id, key: NSString): Unit = extern
34 | @inline def committedValuesForKeys_(keys: NSString): NSDictionary[NSString, NSObject] = extern
35 | @inline def changedValues(): NSDictionary[NSString, NSObject] = extern
36 | @inline def changedValuesForCurrentEvent(): NSDictionary[NSString, NSObject] = extern
37 | @inline def validateValue_key_error_(value: id, key: NSString, error: NSError): BOOL = extern
38 | @inline def validateForDelete_(error: NSError): BOOL = extern
39 | @inline def validateForInsert_(error: NSError): BOOL = extern
40 | @inline def validateForUpdate_(error: NSError): BOOL = extern
41 | @inline def setObservationInfo_(inObservationInfo: Ptr[Byte]): Unit = extern
42 | @inline def observationInfo(): Ptr[Byte] = extern
43 | @inline def managedObjectContext(): NSManagedObjectContext = extern
44 | // @inline def entity(): NSEntityDescription = extern
45 | @inline def objectID(): NSManagedObjectID = extern
46 | @inline def isInserted(): BOOL = extern
47 | @inline def isUpdated(): BOOL = extern
48 | @inline def isDeleted(): BOOL = extern
49 | @inline def hasChanges(): BOOL = extern
50 | @inline def hasPersistentChangedValues(): BOOL = extern
51 | @inline def isFault(): BOOL = extern
52 | @inline def faultingState(): NSUInteger = extern
53 | }
54 |
55 |
56 | @ObjCClass
57 | abstract class NSManagedObjectClass extends NSObjectClass {
58 | // @inline def entity(): NSEntityDescription = extern
59 | // @inline def fetchRequest(): NSFetchRequest = extern
60 | @inline def contextShouldIgnoreUnmodeledPropertyChanges(): BOOL = extern
61 | }
62 |
63 | object NSManagedObject extends NSManagedObjectClass {
64 | override type InstanceType = NSManagedObject
65 | }
--------------------------------------------------------------------------------
/docs/_includes/initialize_shuffle.html:
--------------------------------------------------------------------------------
1 |
7 |
8 |
100 |
101 |
102 |
103 |
114 |
115 |
129 |
130 |
131 |
--------------------------------------------------------------------------------
/docs/css/printstyles.css:
--------------------------------------------------------------------------------
1 |
2 | /*body.print .container {max-width: 650px;}*/
3 |
4 | body {
5 | font-size:14px;
6 | }
7 | .nav ul li a {border-top:0px; background-color:transparent; color: #808080; }
8 | #navig a[href] {color: #595959 !important;}
9 | table .table {max-width:650px;}
10 |
11 | #navig li.sectionHead {font-weight: bold; font-size: 18px; color: #595959 !important; }
12 | #navig li {font-weight: normal; }
13 |
14 | #navig a[href]::after { content: leader(".") target-counter(attr(href), page); }
15 |
16 | a[href]::after {
17 | content: " (page " target-counter(attr(href), page) ")"
18 | }
19 |
20 | a[href^="http:"]::after, a[href^="https:"]::after {
21 | content: "";
22 | }
23 |
24 | a[href] {
25 | color: blue !important;
26 | }
27 | a[href*="mailto"]::after, a[data-toggle="tooltip"]::after, a[href].noCrossRef::after {
28 | content: "";
29 | }
30 |
31 |
32 | @page {
33 | margin: 60pt 90pt 60pt 90pt;
34 | font-family: sans-serif;
35 | font-style:none;
36 | color: gray;
37 |
38 | }
39 |
40 | .printTitle {
41 | line-height:30pt;
42 | font-size:27pt;
43 | font-weight: bold;
44 | letter-spacing: -.5px;
45 | margin-bottom:25px;
46 | }
47 |
48 | .printSubtitle {
49 | font-size: 19pt;
50 | color: #cccccc !important;
51 | font-family: "Grotesque MT Light";
52 | line-height: 22pt;
53 | letter-spacing: -.5px;
54 | margin-bottom:20px;
55 | }
56 | .printTitleArea hr {
57 | color: #999999 !important;
58 | height: 2px;
59 | width: 100%;
60 | }
61 |
62 | .printTitleImage {
63 | max-width:300px;
64 | margin-bottom:200px;
65 | }
66 |
67 |
68 | .printTitleImage {
69 | max-width: 250px;
70 | }
71 |
72 | #navig {
73 | /*page-break-before: always;*/
74 | }
75 |
76 | .copyrightBoilerplate {
77 | page-break-before:always;
78 | font-size:14px;
79 | }
80 |
81 | .lastGeneratedDate {
82 | font-style: italic;
83 | font-size:14px;
84 | color: gray;
85 | }
86 |
87 | .alert a {
88 | text-decoration: none !important;
89 | }
90 |
91 |
92 | body.title { page: title }
93 |
94 | @page title {
95 | @top-left {
96 | content: " ";
97 | }
98 | @top-right {
99 | content: " "
100 | }
101 | @bottom-right {
102 | content: " ";
103 | }
104 | @bottom-left {
105 | content: " ";
106 | }
107 | }
108 |
109 | body.frontmatter { page: frontmatter }
110 | body.frontmatter {counter-reset: page 1}
111 |
112 |
113 | @page frontmatter {
114 | @top-left {
115 | content: prince-script(guideName);
116 | }
117 | @top-right {
118 | content: prince-script(datestamp);
119 | }
120 | @bottom-right {
121 | content: counter(page, lower-roman);
122 | }
123 | @bottom-left {
124 | content: "youremail@domain.com"; }
125 | }
126 |
127 | body.first_page {counter-reset: page 1}
128 |
129 | h1 { string-set: doctitle content() }
130 |
131 | @page {
132 | @top-left {
133 | content: string(doctitle);
134 | font-size: 11px;
135 | font-style: italic;
136 | }
137 | @top-right {
138 | content: prince-script(datestamp);
139 | font-size: 11px;
140 | }
141 |
142 | @bottom-right {
143 | content: "Page " counter(page);
144 | font-size: 11px;
145 | }
146 | @bottom-left {
147 | content: prince-script(guideName);
148 | font-size: 11px;
149 | }
150 | }
151 | .alert {
152 | background-color: #fafafa !important;
153 | border-color: #dedede !important;
154 | color: black;
155 | }
156 |
157 | pre {
158 | background-color: #fafafa;
159 | }
160 |
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSImageRep.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import cocoa.foundation._
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 | import objc._
9 |
10 |
11 | @ObjC
12 | class NSImageRep extends NSObject with NSCopying with NSCoding {
13 | @inline def draw(): BOOL = extern
14 | @inline def drawAtPoint_(point: NSPoint): BOOL = extern
15 | @inline def drawInRect_(rect: NSRect): BOOL = extern
16 | // @inline def drawInRect_srcSpacePortionRect_op_requestedAlpha_respectContextIsFlipped_hints_(dstSpacePortionRect: NSRect, srcSpacePortionRect: NSRect, op: NSCompositingOperation, requestedAlpha: CGFloat, respectContextIsFlipped: BOOL, hints: id): BOOL = extern
17 | // @inline def CGImageForProposedRect_context_hints_(proposedDestRect: NSRect, context: NSGraphicsContext, hints: id): CGImageRef = extern
18 | @inline def size(): NSSize = extern
19 | @inline def setSize_(size: NSSize): Unit = extern
20 | @inline def hasAlpha(): BOOL = extern
21 | @inline def setAlpha_(alpha: BOOL): Unit = extern
22 | @inline def isOpaque(): BOOL = extern
23 | @inline def setOpaque_(opaque: BOOL): Unit = extern
24 | // @inline def colorSpaceName(): NSColorSpaceName = extern
25 | // @inline def setColorSpaceName_(colorSpaceName: NSColorSpaceName): Unit = extern
26 | @inline def bitsPerSample(): NSInteger = extern
27 | @inline def setBitsPerSample_(bitsPerSample: NSInteger): Unit = extern
28 | @inline def pixelsWide(): NSInteger = extern
29 | @inline def setPixelsWide_(pixelsWide: NSInteger): Unit = extern
30 | @inline def pixelsHigh(): NSInteger = extern
31 | @inline def setPixelsHigh_(pixelsHigh: NSInteger): Unit = extern
32 | @inline def layoutDirection(): NSImageLayoutDirection = extern
33 | @inline def setLayoutDirection_(layoutDirection: NSImageLayoutDirection): Unit = extern
34 | }
35 |
36 | @ObjCClass
37 | abstract class NSImageRepClass extends NSObjectClass {
38 | @inline def registerImageRepClass_(imageRepClass: id): Unit = extern
39 | @inline def unregisterImageRepClass_(imageRepClass: id): Unit = extern
40 | @inline def imageRepClassForFileType_(`type`: NSString): id = extern
41 | // @inline def imageRepClassForPasteboardType_(`type`: NSPasteboardType): id = extern
42 | @inline def imageRepClassForType_(`type`: NSString): id = extern
43 | @inline def imageRepClassForData_(data: NSData): id = extern
44 | @inline def canInitWithData_(data: NSData): BOOL = extern
45 | @inline def imageUnfilteredFileTypes(): NSArray[NSString] = extern
46 | // @inline def imageUnfilteredPasteboardTypes(): NSArray[NSPasteboardType] = extern
47 | @inline def imageFileTypes(): NSArray[NSString] = extern
48 | // @inline def imagePasteboardTypes(): NSArray[NSPasteboardType] = extern
49 | // @inline def canInitWithPasteboard_(pasteboard: NSPasteboard): BOOL = extern
50 | @inline def imageRepsWithContentsOfFile_(filename: NSString): NSArray[NSImageRep] = extern
51 | @inline def imageRepWithContentsOfFile_(filename: NSString): NSImageRep = extern
52 | @inline def imageRepsWithContentsOfURL_(url: NSURL): NSArray[NSImageRep] = extern
53 | @inline def imageRepWithContentsOfURL_(url: NSURL): NSImageRep = extern
54 | // @inline def imageRepsWithPasteboard_(pasteboard: NSPasteboard): NSArray[NSImageRep] = extern
55 | // @inline def imageRepWithPasteboard_(pasteboard: NSPasteboard): NSImageRep = extern
56 | @inline def registeredImageRepClasses(): NSArray[NSObject] = extern
57 | @inline def imageUnfilteredTypes(): NSArray[NSString] = extern
58 | @inline def imageTypes(): NSArray[NSString] = extern
59 | }
60 |
61 | object NSImageRep extends NSImageRepClass {
62 | override type InstanceType = NSImageRep
63 | }
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSAlert.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import cocoa.foundation.{BOOL, NSArray, NSError, NSObject, NSObjectClass, NSString, SEL, id}
5 |
6 | import scala.language.experimental.macros
7 | import scalanative.native._
8 | import objc._
9 |
10 | @ObjC
11 | trait NSAlertDelegate extends NSObject {
12 | @inline def alertShowHelp_(alert: NSAlert): BOOL = extern
13 | }
14 |
15 | @ObjC
16 | class NSAlert extends NSObject {
17 | @inline def addButtonWithTitle_(title: NSString): NSButton = extern
18 | @inline def layout(): Unit = extern
19 | @inline def runModal(): NSModalResponse = extern
20 | @inline def beginSheetModalForWindow_handler_(sheetWindow: NSWindow, handler: Ptr[Byte]): Unit = extern
21 | @inline def messageText(): NSString = extern
22 | @inline def setMessageText_(messageText: NSString): Unit = extern
23 | @inline def informativeText(): NSString = extern
24 | @inline def setInformativeText_(informativeText: NSString): Unit = extern
25 | @inline def icon(): NSImage = extern
26 | @inline def setIcon_(icon: NSImage): Unit = extern
27 | @inline def buttons(): NSArray[NSButton] = extern
28 | @inline def showsHelp(): BOOL = extern
29 | @inline def setShowsHelp_(showsHelp: BOOL): Unit = extern
30 | @inline def helpAnchor(): NSHelpAnchorName = extern
31 | @inline def setHelpAnchor_(helpAnchor: NSHelpAnchorName): Unit = extern
32 | @inline def alertStyle(): NSAlertStyle = extern
33 | @inline def setAlertStyle_(alertStyle: NSAlertStyle): Unit = extern
34 | @inline def delegate(): NSAlertDelegate = extern
35 | @inline def setDelegate_(delegate: NSAlertDelegate): Unit = extern
36 | @inline def showsSuppressionButton(): BOOL = extern
37 | @inline def setShowsSuppressionButton_(showsSuppressionButton: BOOL): Unit = extern
38 | @inline def suppressionButton(): NSButton = extern
39 | @inline def accessoryView(): NSView = extern
40 | @inline def setAccessoryView_(accessoryView: NSView): Unit = extern
41 | @inline def window(): NSWindow = extern
42 | @inline def beginSheetModalForWindow_delegate_didEndSelector_contextInfo_(window: NSWindow, delegate: id, didEndSelector: SEL, contextInfo: Ptr[Byte]): Unit = extern
43 | }
44 |
45 | @ObjCClass
46 | abstract class NSAlertClass extends NSObjectClass {
47 | @inline def alertWithError_(error: NSError): NSAlert = extern
48 | }
49 |
50 | object NSAlert extends NSAlertClass {
51 | override type InstanceType = NSAlert
52 |
53 | def apply(messageText: String,
54 | defaultButton: String,
55 | alternateButton: String = "",
56 | informativeText: String = "",
57 | otherButton: String = "",
58 | alertStyle: NSAlertStyle = NSAlertStyle.Informational): NSAlert = apply(
59 | NSString(messageText),
60 | NSString(defaultButton),
61 | if( alternateButton != "") NSString(alternateButton) else null,
62 | if( informativeText != "") NSString(informativeText) else null,
63 | if( otherButton != "") NSString(otherButton) else null,
64 | alertStyle)
65 |
66 | def apply(messageText: NSString,
67 | defaultButton: NSString,
68 | alternateButton: NSString,
69 | informativeText: NSString,
70 | otherButton: NSString,
71 | alertStyle: NSAlertStyle): NSAlert = {
72 | val alert = NSAlert.alloc().init()
73 | alert.setMessageText_(messageText)
74 | alert.addButtonWithTitle_(defaultButton)
75 | if( alternateButton != null )
76 | alert.addButtonWithTitle_(alternateButton)
77 | if( otherButton != null )
78 | alert.addButtonWithTitle_(otherButton)
79 | if( informativeText != null )
80 | alert.setInformativeText_(informativeText)
81 | alert.setAlertStyle_(alertStyle)
82 | alert
83 | }
84 | }
--------------------------------------------------------------------------------
/docs/_layouts/default.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {% include head.html %}
5 |
37 |
42 |
53 | {% if page.datatable == true %}
54 |
55 |
56 |
57 |
62 |
72 | {% endif %}
73 |
74 |
75 |
76 | {% include topnav.html %}
77 |
78 |
79 |
80 |
81 |
82 | {% assign content_col_size = "col-md-12" %}
83 | {% unless page.hide_sidebar %}
84 |
85 |
88 | {% assign content_col_size = "col-md-9" %}
89 | {% endunless %}
90 |
91 |
92 |
93 | {{content}}
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 | {% if site.google_analytics %}
104 | {% include google_analytics.html %}
105 | {% endif %}
106 |
107 |
--------------------------------------------------------------------------------
/docs/_config.yml:
--------------------------------------------------------------------------------
1 | repository: jokade/scalanative-cocoa
2 |
3 | output: web
4 | # this property is useful for conditional filtering of content that is separate from the PDF.
5 |
6 | topnav_title: SNCocoa
7 | # this appears on the top navigation bar next to the home button
8 |
9 | site_title: scalanative-cocoa documantetion
10 | # this appears in the html browser tab for the site title (seen mostly by search engines, not users)
11 |
12 | company_name:
13 | # this appears in the footer
14 |
15 | #github_editme_path: jokade/scalanative-cocoa/blob/master/docs/
16 | # if you're using Github, provide the basepath to the branch you've created for reviews, following the sample here. if not, leave this value blank.
17 |
18 | disqus_shortname:
19 | # if you're using disqus for comments, add the shortname here. if not, leave this value blank.
20 |
21 | google_analytics:
22 | # if you have google-analytics ID, put it in. if not, edit this value to blank.
23 |
24 | host: 127.0.0.1
25 | # the preview server used. Leave as is.
26 |
27 | port: 4000
28 | # the port where the preview is rendered. You can leave this as is unless you have other Jekyll builds using this same port that might cause conflicts. in that case, use another port such as 4006.
29 |
30 | exclude:
31 | - .idea/
32 | - .gitignore
33 | # these are the files and directories that jekyll will exclude from the build
34 |
35 | feedback_subject_line: SNCocoa documentation
36 |
37 | feedback_email: jokade@karchedon.de
38 | # used as a contact email for the Feedback link in the top navigation bar
39 |
40 | feedback_disable: true
41 | # if you uncomment the previous line, the Feedback link gets removed
42 |
43 | # feedback_text: "Need help?"
44 | # if you uncomment the previous line, it changes the Feedback text
45 |
46 | # feedback_link: "http://helpy.io/"
47 | # if you uncomment the previous line, it changes where the feedback link points to
48 |
49 | highlighter: rouge
50 | # library used for syntax highlighting
51 |
52 | markdown: kramdown
53 | kramdown:
54 | input: GFM
55 | auto_ids: true
56 | hard_wrap: false
57 | syntax_highlighter: rouge
58 |
59 | # filter used to process markdown. note that kramdown differs from github-flavored markdown in some subtle ways
60 |
61 | collections:
62 | tooltips:
63 | output: false
64 | # collections are declared here. this renders the content in _tooltips and processes it, but doesn't output it as actual files in the output unless you change output to true
65 |
66 | defaults:
67 | -
68 | scope:
69 | path: ""
70 | type: "pages"
71 | values:
72 | layout: "page"
73 | comments: true
74 | search: true
75 | sidebar: home_sidebar
76 | topnav: topnav
77 | -
78 | scope:
79 | path: ""
80 | type: "tooltips"
81 | values:
82 | layout: "page"
83 | comments: true
84 | search: true
85 | tooltip: true
86 |
87 | -
88 | scope:
89 | path: ""
90 | type: "posts"
91 | values:
92 | layout: "post"
93 | comments: true
94 | search: true
95 | sidebar: home_sidebar
96 | topnav: topnav
97 |
98 | # these are defaults used for the frontmatter for these file types
99 |
100 | sidebars:
101 | - home_sidebar
102 |
103 | #- mydoc_sidebar
104 | #- product1_sidebar
105 | #- product2_sidebar
106 | #- other
107 |
108 | description: "Intended as a documentation theme based on Jekyll for technical writers documenting software and other technical products, this theme has all the elements you would need to handle multiple products with both multi-level sidebar navigation, tags, and other documentation features."
109 | # the description is used in the feed.xml file
110 |
111 | # needed for sitemap.xml file only
112 | url: jokade.github.io
113 | baseurl: /scalanative-cocoa
114 |
--------------------------------------------------------------------------------
/docs/pages/sncocoa/guide/snc_basic_interop.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Basic Interop
3 | keywords:
4 | summary:
5 | sidebar: sncocoa_sidebar
6 | permalink: snc_basic_interop.html
7 | folder: sncocoa
8 | ---
9 |
10 | ## Calling Objective-C Methods from Scala
11 | You can call Objective-C class and instance methods using the normal Scala method call syntax,
12 | if there is a [binding](snc_create_binding.html) defined for that class, e.g.:
13 |
14 |
15 |
16 |
17 |
Objective-C
18 |
19 |
20 |
Scala
21 |
22 |
23 |
24 |
25 |
26 | {% highlight objc %}
27 | [[NSNumber alloc] initWithInt:42]; {% endhighlight %}
28 |
29 |
30 |
31 | {% highlight scala %}
32 | NSNumber.alloc().initWithInt(42){% endhighlight %}
33 |
34 |
35 |
36 |
37 | SNCocoa provides bindings for the *Foundation* and *AppKit* frameworks, located in the packages `cocoa.foundation`
38 | and `cocoa.appkit`, respectively.
39 |
40 | {% include callout.html content='Methods with varargs are currently not supported' type="warning" %}
41 |
42 | ## Objective-C Functions
43 | Bindings to global Objective-C functions are provided as functions in an object named after the framework to which they belong.
44 | `NSLog()` for example is provided by `cocoa.foundation.Foundation`
45 | ```scala
46 | import cocoa.foundation._
47 |
48 | Foundation.NSLog(ns"Hello world!")
49 | ```
50 |
51 | ## Strings and Numbers
52 | ### Literals
53 | Similar to Objective-C, SNCocoa provides short-forms to create strings and numbers from Scala literals:
54 |
55 |
56 |
57 |
Objective-C
58 |
59 |
60 |
Scala
61 |
62 |
63 |
64 |
65 |
66 | {% highlight objc %}
67 | #import
68 |
69 | NSString *thString = @"A string";
70 | NSNumber *intNumber = @42;
71 | NSNumber *doubleNumber = @1e42;{% endhighlight %}
72 |
73 |
74 |
75 | {% highlight scala %}
76 | import cocoa.foundation._
77 |
78 | val theString = ns"A string"
79 | val intNumber = @@(42)
80 | val doubleNumber = @@(1e42) {% endhighlight %}
81 |
82 |
83 |
84 |
85 | {% include callout.html content='In contrast to Objective-C, NSString literals created with the `ns""` syntax are
86 | not constants, but a short-hand for writing `NSString.stringWithCString(c"...", NSStringEncoding.NSUTF8StringEncoding)`' type="info" %}
87 |
88 | ### Scala Extensions
89 | SNCocoa provides extension methods for `NSString`:
90 | ```scala
91 | import cocoa.foundation._
92 |
93 | val nsString = ns"The String"
94 | nsString.string // returns the NSString value as Scala string
95 | nsString.cstring // returns the NSString value as CString
96 | ```
97 |
98 | ## Enums
99 | Enums defined by cocoa frameworks are represented in Scala as type aliases for `NSInteger` and `NSUInteger`,
100 | plus a companion object that holds the enum values. For example, the values for `NSStringEncoding` are defined
101 | in `cocoa.foundation.NSStringEncoding`:
102 | ```scala
103 | import scalanative.native._
104 | import cocoa.foundation._
105 |
106 | val string = NSString.stringWithCString(c"The string", NSStringEncoding.NSUTF8StringEncoding)
107 | ```
108 | {% include links.html %}
109 |
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSApplicationDelegate.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import scalanative.native._
5 | import cocoa.foundation.{BOOL, NSCoder, NSData, NSError, NSNotification, NSObject, NSString, NSURL, id}
6 |
7 | import objc._
8 |
9 |
10 | @ObjC
11 | trait NSApplicationDelegate extends NSObject {
12 | @inline def applicationShouldTerminate_(sender: NSApplication): NSApplicationTerminateReply = extern
13 | @inline def application_urls_(application: NSApplication, urls: NSURL): Unit = extern
14 | @inline def application_filename_(sender: NSApplication, filename: NSString): BOOL = extern
15 | @inline def application_filenames_(sender: NSApplication, filenames: NSString): Unit = extern
16 | @inline def applicationShouldOpenUntitledFile_(sender: NSApplication): BOOL = extern
17 | @inline def applicationOpenUntitledFile_(sender: NSApplication): BOOL = extern
18 | @inline def application_filename_(sender: id, filename: NSString): BOOL = extern
19 | // @inline def application_fileNames_printSettings_showPrintPanels_(application: NSApplication, fileNames: NSString, printSettings: id, showPrintPanels: BOOL): NSApplicationPrintReply = extern
20 | @inline def applicationShouldTerminateAfterLastWindowClosed_(sender: NSApplication): BOOL = extern
21 | @inline def applicationShouldHandleReopen_flag_(sender: NSApplication, flag: BOOL): BOOL = extern
22 | // @inline def applicationDockMenu_(sender: NSApplication): NSMenu = extern
23 | @inline def application_error_(application: NSApplication, error: NSError): NSError = extern
24 | @inline def application_deviceToken_(application: NSApplication, deviceToken: NSData): Unit = extern
25 | @inline def application_userInfo_(application: NSApplication, userInfo: id): Unit = extern
26 | @inline def application_coder_(app: NSApplication, coder: NSCoder): Unit = extern
27 | @inline def application_userActivityType_(application: NSApplication, userActivityType: NSString): BOOL = extern
28 | // @inline def application_userActivity_restorationHandler_(application: NSApplication, userActivity: NSUserActivity, restorationHandler: Ptr[Byte]): BOOL = extern
29 | @inline def application_userActivityType_error_(application: NSApplication, userActivityType: NSString, error: NSError): Unit = extern
30 | // @inline def application_userActivity_(application: NSApplication, userActivity: NSUserActivity): Unit = extern
31 | // @inline def application_metadata_(application: NSApplication, metadata: CKShareMetadata): Unit = extern
32 | @inline def applicationWillFinishLaunching_(notification: NSNotification): Unit = extern
33 | @inline def applicationDidFinishLaunching_(notification: NSNotification): Unit = extern
34 | @inline def applicationWillHide_(notification: NSNotification): Unit = extern
35 | @inline def applicationDidHide_(notification: NSNotification): Unit = extern
36 | @inline def applicationWillUnhide_(notification: NSNotification): Unit = extern
37 | @inline def applicationDidUnhide_(notification: NSNotification): Unit = extern
38 | @inline def applicationWillBecomeActive_(notification: NSNotification): Unit = extern
39 | @inline def applicationDidBecomeActive_(notification: NSNotification): Unit = extern
40 | @inline def applicationWillResignActive_(notification: NSNotification): Unit = extern
41 | @inline def applicationDidResignActive_(notification: NSNotification): Unit = extern
42 | @inline def applicationWillUpdate_(notification: NSNotification): Unit = extern
43 | @inline def applicationDidUpdate_(notification: NSNotification): Unit = extern
44 | @inline def applicationWillTerminate_(notification: NSNotification): Unit = extern
45 | @inline def applicationDidChangeScreenParameters_(notification: NSNotification): Unit = extern
46 | @inline def applicationDidChangeOcclusionState_(notification: NSNotification): Unit = extern
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/docs/css/syntax.css:
--------------------------------------------------------------------------------
1 | .highlight { background: #ffffff; }
2 | .highlight .c { color: #999988; font-style: italic } /* Comment */
3 | .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
4 | .highlight .k { font-weight: bold } /* Keyword */
5 | .highlight .o { font-weight: bold } /* Operator */
6 | .highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
7 | .highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
8 | .highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
9 | .highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
10 | .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
11 | .highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
12 | .highlight .ge { font-style: italic } /* Generic.Emph */
13 | .highlight .gr { color: #aa0000 } /* Generic.Error */
14 | .highlight .gh { color: #999999 } /* Generic.Heading */
15 | .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
16 | .highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
17 | .highlight .go { color: #888888 } /* Generic.Output */
18 | .highlight .gp { color: #555555 } /* Generic.Prompt */
19 | .highlight .gs { font-weight: bold } /* Generic.Strong */
20 | .highlight .gu { color: #aaaaaa } /* Generic.Subheading */
21 | .highlight .gt { color: #aa0000 } /* Generic.Traceback */
22 | .highlight .kc { font-weight: bold } /* Keyword.Constant */
23 | .highlight .kd { font-weight: bold } /* Keyword.Declaration */
24 | .highlight .kp { font-weight: bold } /* Keyword.Pseudo */
25 | .highlight .kr { font-weight: bold } /* Keyword.Reserved */
26 | .highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
27 | .highlight .m { color: #009999 } /* Literal.Number */
28 | .highlight .s { color: #d14 } /* Literal.String */
29 | .highlight .na { color: #008080 } /* Name.Attribute */
30 | .highlight .nb { color: #0086B3 } /* Name.Builtin */
31 | .highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
32 | .highlight .no { color: #008080 } /* Name.Constant */
33 | .highlight .ni { color: #800080 } /* Name.Entity */
34 | .highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
35 | .highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
36 | .highlight .nn { color: #555555 } /* Name.Namespace */
37 | .highlight .nt { color: #000080 } /* Name.Tag */
38 | .highlight .nv { color: #008080 } /* Name.Variable */
39 | .highlight .ow { font-weight: bold } /* Operator.Word */
40 | .highlight .w { color: #bbbbbb } /* Text.Whitespace */
41 | .highlight .mf { color: #009999 } /* Literal.Number.Float */
42 | .highlight .mh { color: #009999 } /* Literal.Number.Hex */
43 | .highlight .mi { color: #009999 } /* Literal.Number.Integer */
44 | .highlight .mo { color: #009999 } /* Literal.Number.Oct */
45 | .highlight .sb { color: #d14 } /* Literal.String.Backtick */
46 | .highlight .sc { color: #d14 } /* Literal.String.Char */
47 | .highlight .sd { color: #d14 } /* Literal.String.Doc */
48 | .highlight .s2 { color: #d14 } /* Literal.String.Double */
49 | .highlight .se { color: #d14 } /* Literal.String.Escape */
50 | .highlight .sh { color: #d14 } /* Literal.String.Heredoc */
51 | .highlight .si { color: #d14 } /* Literal.String.Interpol */
52 | .highlight .sx { color: #d14 } /* Literal.String.Other */
53 | .highlight .sr { color: #009926 } /* Literal.String.Regex */
54 | .highlight .s1 { color: #d14 } /* Literal.String.Single */
55 | .highlight .ss { color: #990073 } /* Literal.String.Symbol */
56 | .highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
57 | .highlight .vc { color: #008080 } /* Name.Variable.Class */
58 | .highlight .vg { color: #008080 } /* Name.Variable.Global */
59 | .highlight .vi { color: #008080 } /* Name.Variable.Instance */
60 | .highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
--------------------------------------------------------------------------------
/foundation/src/main/scala/cocoa/foundation/NSNumber.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.foundation
3 |
4 | import scala.scalanative.native._
5 | import objc._
6 |
7 |
8 | @ObjC
9 | class NSNumber extends NSValue {
10 | @inline def initWithChar_(value: CSignedChar): NSNumber = extern
11 | @inline def initWithUnsignedChar_(value: CUnsignedChar): NSNumber = extern
12 | @inline def initWithShort_(value: CShort): NSNumber = extern
13 | @inline def initWithUnsignedShort_(value: CUnsignedShort): NSNumber = extern
14 | @inline def initWithInt_(value: CInt): NSNumber = extern
15 | @inline def initWithUnsignedInt_(value: CUnsignedInt): NSNumber = extern
16 | @inline def initWithLong_(value: CLong): NSNumber = extern
17 | @inline def initWithUnsignedLong_(value: CUnsignedLong): NSNumber = extern
18 | @inline def initWithLongLong_(value: CLongLong): NSNumber = extern
19 | @inline def initWithUnsignedLongLong_(value: CUnsignedLongLong): NSNumber = extern
20 | @inline def initWithFloat_(value: Float): NSNumber = extern
21 | @inline def initWithDouble_(value: Double): NSNumber = extern
22 | @inline def initWithBool_(value: BOOL): NSNumber = extern
23 | @inline def initWithInteger_(value: NSInteger): NSNumber = extern
24 | @inline def initWithUnsignedInteger_(value: NSUInteger): NSNumber = extern
25 | @inline def compare_(otherNumber: NSNumber): NSComparisonResult = extern
26 | @inline def isEqualToNumber_(number: NSNumber): BOOL = extern
27 | @inline def descriptionWithLocale_(locale: id): NSString = extern
28 | @inline def charValue(): CSignedChar = extern
29 | @inline def unsignedCharValue(): CUnsignedChar = extern
30 | @inline def shortValue(): CShort = extern
31 | @inline def unsignedShortValue(): CUnsignedShort = extern
32 | @inline def intValue(): CInt = extern
33 | @inline def unsignedIntValue(): CUnsignedInt = extern
34 | @inline def longValue(): CLong = extern
35 | @inline def unsignedLongValue(): CUnsignedLong = extern
36 | @inline def longLongValue(): CLongLong = extern
37 | @inline def unsignedLongLongValue(): CUnsignedLongLong = extern
38 | @inline def floatValue(): Float = extern
39 | @inline def doubleValue(): Double = extern
40 | @inline def boolValue(): BOOL = extern
41 | @inline def integerValue(): NSInteger = extern
42 | @inline def unsignedIntegerValue(): NSUInteger = extern
43 | @inline def stringValue(): NSString = extern
44 | }
45 |
46 |
47 | @ObjCClass
48 | abstract class NSNumberClass extends NSValueClass {
49 | @inline def numberWithChar_(value: CSignedChar): NSNumber = extern
50 | @inline def numberWithUnsignedChar_(value: CUnsignedChar): NSNumber = extern
51 | @inline def numberWithShort_(value: CShort): NSNumber = extern
52 | @inline def numberWithUnsignedShort_(value: CUnsignedShort): NSNumber = extern
53 | @inline def numberWithInt_(value: CInt): NSNumber = extern
54 | @inline def numberWithUnsignedInt_(value: CUnsignedInt): NSNumber = extern
55 | @inline def numberWithLong_(value: CLong): NSNumber = extern
56 | @inline def numberWithUnsignedLong_(value: CUnsignedLong): NSNumber = extern
57 | @inline def numberWithLongLong_(value: CLongLong): NSNumber = extern
58 | @inline def numberWithUnsignedLongLong_(value: CUnsignedLongLong): NSNumber = extern
59 | @inline def numberWithFloat_(value: Float): NSNumber = extern
60 | @inline def numberWithDouble_(value: Double): NSNumber = extern
61 | @inline def numberWithBool_(value: BOOL): NSNumber = extern
62 | @inline def numberWithInteger_(value: NSInteger): NSNumber = extern
63 | @inline def numberWithUnsignedInteger_(value: NSUInteger): NSNumber = extern
64 | }
65 |
66 |
67 | object NSNumber extends NSNumberClass {
68 | override type InstanceType = NSNumber
69 |
70 | def apply(b: Boolean): NSNumber = NSNumber.numberWithBool_(b)
71 | def apply(i: Int): NSNumber = NSNumber.numberWithInt_(i)
72 | def apply(d: Double): NSNumber = NSNumber.numberWithDouble_(d)
73 | }
74 |
--------------------------------------------------------------------------------
/appkit/src/main/scala/cocoa/appkit/NSTextField.scala:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2018. Distributed under the MIT License (see included LICENSE file).
2 | package cocoa.appkit
3 |
4 | import scalanative.native._
5 | import cocoa.foundation.{BOOL, NSInteger, NSNotification, NSObjectClass, NSString, id}
6 |
7 | import objc._
8 |
9 | @ObjC
10 | class NSTextField extends NSControl { //with NSUserInterfaceValidations with NSAccessibilityNavigableStaticText {
11 | @inline def selectText_(sender: id): Unit = extern
12 | @inline def textShouldBeginEditing_(textObject: NSText): BOOL = extern
13 | @inline def textShouldEndEditing_(textObject: NSText): BOOL = extern
14 | @inline def textDidBeginEditing_(notification: NSNotification): Unit = extern
15 | @inline def textDidEndEditing_(notification: NSNotification): Unit = extern
16 | @inline def textDidChange_(notification: NSNotification): Unit = extern
17 | @inline def placeholderString(): NSString = extern
18 | @inline def setPlaceholderString_(placeholderString: NSString): Unit = extern
19 | // @inline def placeholderAttributedString(): NSAttributedString = extern
20 | // @inline def setPlaceholderAttributedString_(placeholderAttributedString: NSAttributedString): Unit = extern
21 | // @inline def backgroundColor(): NSColor = extern
22 | // @inline def setBackgroundColor_(backgroundColor: NSColor): Unit = extern
23 | @inline def drawsBackground(): BOOL = extern
24 | @inline def setDrawsBackground_(drawsBackground: BOOL): Unit = extern
25 | // @inline def textColor(): NSColor = extern
26 | // @inline def setTextColor_(textColor: NSColor): Unit = extern
27 | @inline def isBordered(): BOOL = extern
28 | @inline def setBordered_(bordered: BOOL): Unit = extern
29 | @inline def isBezeled(): BOOL = extern
30 | @inline def setBezeled_(bezeled: BOOL): Unit = extern
31 | @inline def isEditable(): BOOL = extern
32 | @inline def setEditable_(editable: BOOL): Unit = extern
33 | @inline def isSelectable(): BOOL = extern
34 | @inline def setSelectable_(selectable: BOOL): Unit = extern
35 | @inline def delegate(): NSTextFieldDelegate = extern
36 | @inline def setDelegate_(delegate: NSTextFieldDelegate): Unit = extern
37 | // @inline def bezelStyle(): NSTextFieldBezelStyle = extern
38 | // @inline def setBezelStyle_(bezelStyle: NSTextFieldBezelStyle): Unit = extern
39 | @inline def preferredMaxLayoutWidth(): CGFloat = extern
40 | @inline def setPreferredMaxLayoutWidth_(preferredMaxLayoutWidth: CGFloat): Unit = extern
41 | @inline def maximumNumberOfLines(): NSInteger = extern
42 | @inline def setMaximumNumberOfLines_(maximumNumberOfLines: NSInteger): Unit = extern
43 | @inline def allowsDefaultTighteningForTruncation(): BOOL = extern
44 | @inline def setAllowsDefaultTighteningForTruncation_(allowsDefaultTighteningForTruncation: BOOL): Unit = extern
45 | @inline def isAutomaticTextCompletionEnabled(): BOOL = extern
46 | @inline def setAutomaticTextCompletionEnabled_(automaticTextCompletionEnabled: BOOL): Unit = extern
47 | @inline def allowsCharacterPickerTouchBarItem(): BOOL = extern
48 | @inline def setAllowsCharacterPickerTouchBarItem_(allowsCharacterPickerTouchBarItem: BOOL): Unit = extern
49 | @inline def allowsEditingTextAttributes(): BOOL = extern
50 | @inline def setAllowsEditingTextAttributes_(allowsEditingTextAttributes: BOOL): Unit = extern
51 | @inline def importsGraphics(): BOOL = extern
52 | @inline def setImportsGraphics_(importsGraphics: BOOL): Unit = extern
53 | @inline def setTitleWithMnemonic_(stringWithAmpersand: NSString): Unit = extern
54 | }
55 | @ObjCClass
56 | abstract class NSTextFieldClass extends NSObjectClass {
57 | @inline def labelWithString_(stringValue: NSString): NSTextField = extern
58 | @inline def wrappingLabelWithString_(stringValue: NSString): NSTextField = extern
59 | // @inline def labelWithAttributedString_(attributedStringValue: NSAttributedString): NSTextField = extern
60 | @inline def textFieldWithString_(stringValue: NSString): NSTextField = extern
61 | }
62 |
63 | object NSTextField extends NSTextFieldClass {
64 | override type InstanceType = NSTextField
65 | }
--------------------------------------------------------------------------------
/docs/pages/sncocoa/guide/snc_memory_management.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Memory Management
3 | keywords:
4 | summary:
5 | sidebar: sncocoa_sidebar
6 | permalink: snc_memory_management.html
7 | folder: sncocoa
8 | ---
9 |
10 | {% include callout.html content='SNCocoa does not supported [Automatic Reference Counting (ARC)](https://developer.apple.com/library/content/releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html#//apple_ref/doc/uid/TP40011226),
11 | so you have to manage memory of Objective-C objects allocated in Scala manually. Make sure you are familiar with the Objective-C
12 | [Memory Management Policy](https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/MemoryMgmt/Articles/mmRules.html#//apple_ref/doc/uid/20000994-BAJHFBGH).'
13 | type="info" %}
14 |
15 |
16 | ## Memory Management in UI delegates
17 | ### Transient Objects
18 | Callbacks from AppKit, e.g. to your `NSApplicationDelegate` are contained within autorelease pools.
19 | For transient objects, that are only referenced during the callback, there are two simple rules:
20 | - for objects you own, call `autorelease()` before you loose the reference to the object
21 | - objects you don't own need no special consideration.
22 |
23 | The same applies to objects created during initialization of the delegate.
24 |
25 | **Example:**
26 | ```scala
27 | @ScalaObjC
28 | class AppDelegate(self: NSObject) extends NSApplicationDelegate {
29 |
30 | // IBAction callback
31 | def action(sender: id): Unit = {
32 | // objects without ownership interest -> automatically released
33 | val int = @@(42)
34 | val string = ns"The String"
35 | val date = NSDate.date()
36 | val array = NSArray(@@(1),@@(2),@@(3))
37 |
38 | // call autorelease() on objects you own
39 | val ownedDate = NSDate.alloc().init().autorelease()
40 | }
41 | }
42 | ```
43 |
44 | ### Objects stored in instance vars
45 | Objective-C objects created in callbacks and stored in instance vars must be released explicitly when they are no longer
46 | referenced by the class by calling `release()`. Furthermore, if you don't own the object, you also must call `retain()`
47 | on it, to avoid its autorelease after the callback has completed.
48 |
49 | Furthermore, if your delegate has a property that is an Objective-C object, you must ensure that an object assigned to it
50 | is not deallocated while you're using it. You must also make sure you relinquish ownership of any currently-held value
51 | when a new value is assigned. To accomplish this, you must call `release()` on the currently-held, and `retain()`
52 | on the new value within the setter of the property.
53 |
54 | An exception to this rule are usually IBOutlet properties, since those are auto-released when appropriate.
55 |
56 | **Example:**
57 | ```scala
58 | @ScalaObjC
59 | class AppDelegate(self: NSObject) extends NSApplicationDelegate {
60 | private var _int: NSNumber = @@(0).retain() // we need to retain since we call release() in action()_
61 | private var _date: NSDate = NSDate.alloc().init()
62 | private var _count: NSNumber = _
63 |
64 | // retain/ release usually not required for IBOutlets
65 | var window: NSWindow = _
66 |
67 | def count: NSNumber = _count
68 | // release currently-held and retain new value in setters for Objective-C objects
69 | def count_=(n: NSNumber): Unit = {
70 | n.retain()
71 | _count.release()
72 | _count = n
73 | }
74 |
75 | // IBAction callback
76 | def action(sender: id): Unit = {
77 | // release old objects
78 | _int.release()
79 | _date.release()
80 |
81 | // objects without ownership interest must be retained when they are stored
82 | _int = @@(42).retain()
83 |
84 | // owned object
85 | _date = NSDate.alloc().init()
86 | }
87 | }
88 | ```
89 | #### Simplify memory management using setters
90 | Manually retaining/ releasing objects whenever the old value of a variable is replaced is cumbersome and error-prone.
91 | Hence, you should use also setters for private vars that hold Objective-C objects instead of directly accessing the var.
92 |
93 | {% include links.html %}
94 |
--------------------------------------------------------------------------------