summaryrefslogtreecommitdiff
path: root/objc_darwin.go
blob: 37b843088070a6c3726fb522a3389098866f6f51 (plain)
1
2
3
4
5
6
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
37
38
39
40
// 28 february 2014

package ui

import (
	"unsafe"
)

// #cgo LDFLAGS: -lobjc -framework Foundation
// #include <stdlib.h>
// #include "objc_darwin.h"
import "C"

func toNSString(str string) C.id {
	cstr := C.CString(str)
	defer C.free(unsafe.Pointer(cstr))

	return C.toNSString(cstr)
}

func fromNSString(str C.id) string {
	return C.GoString(C.fromNSString(str))
}

func toBOOL(what bool) C.BOOL {
	if what {
		return C.YES
	}
	return C.NO
}

// These consolidate the NSScrollView code (used by listbox_darwin.go and area_darwin.go) into a single place.

func makeScrollView(content C.id) C.id {
	return C.makeScrollView(content)
}

func getScrollViewContent(scrollview C.id) C.id {
	return C.scrollViewContent(scrollview)
}