blob: 27031c32b1bf2d42908b88d97e85c30d58fa3cb9 (
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
41
42
43
44
45
46
47
48
|
// 27 february 2014
package ui
/*
This creates a class goAppDelegate that will be used as the delegate for /everything/. Specifically, it:
- runs uitask requests (uitask:)
- handles window close events (windowShouldClose:)
- handles window resize events (windowDidResize:)
- handles button click events (buttonClicked:)
- handles the application-global Quit event (such as from the Dock) (applicationShouldTerminate)
*/
// #include <stdlib.h>
// #include "objc_darwin.h"
import "C"
var (
appDelegate C.id
)
func makeAppDelegate() {
appDelegate = C.makeAppDelegate()
}
//export appDelegate_windowShouldClose
func appDelegate_windowShouldClose(win C.id) C.BOOL {
sysData := getSysData(win)
b := false // TODO
sysData.close(&b)
return toBOOL(b)
}
//export appDelegate_windowDidResize
func appDelegate_windowDidResize(win C.id) {
s := getSysData(win)
wincv := C.windowGetContentView(win) // we want the content view's size, not the window's
r := C.frame(wincv)
// (0,0) is the bottom left corner but this is handled in sysData.translateAllocationCoords()
s.resizeWindow(int(r.width), int(r.height))
C.display(win) // redraw everything
}
//export appDelegate_buttonClicked
func appDelegate_buttonClicked(button C.id) {
sysData := getSysData(button)
sysData.event()
}
|