2015-08-06 21:38:39 -05:00
|
|
|
// 31 july 2015
|
|
|
|
import Cocoa
|
|
|
|
|
|
|
|
var spaced = false
|
2015-08-07 15:24:15 -05:00
|
|
|
var firstvert = true
|
2015-08-06 21:38:39 -05:00
|
|
|
|
2015-08-07 18:29:01 -05:00
|
|
|
// keep alive
|
|
|
|
// apparently I'm not allowed to declare a variable and then assign to it first thing in a function
|
|
|
|
// it'd be great if people weren't so afraid of nil pointers
|
|
|
|
var keepAliveMainwin: Window? = nil
|
|
|
|
|
2015-08-06 21:38:39 -05:00
|
|
|
func appLaunched() {
|
2015-08-07 17:17:29 -05:00
|
|
|
var mainwin = Window()
|
|
|
|
mainwin.SetMargined(spaced)
|
2015-08-06 21:38:39 -05:00
|
|
|
|
2015-08-08 10:12:55 -05:00
|
|
|
var box = Box(vertical: firstvert, padded: spaced)
|
|
|
|
mainwin.SetControl(box)
|
|
|
|
|
2015-08-08 22:03:05 -05:00
|
|
|
/*
|
2015-08-08 21:04:03 -05:00
|
|
|
var hbox = {(entrys: Bool, buttons: Bool) -> Box in
|
|
|
|
var hbox = Box(vertical: !firstvert, padded: spaced)
|
|
|
|
hbox.Add(Entry(), entrys)
|
|
|
|
hbox.Add(Button("Button"), buttons)
|
|
|
|
return hbox
|
|
|
|
}
|
|
|
|
|
|
|
|
box.Add(hbox(true, true), false)
|
|
|
|
box.Add(hbox(true, false), false)
|
|
|
|
box.Add(hbox(false, true), false)
|
|
|
|
box.Add(hbox(false, false), false)
|
2015-08-08 22:03:05 -05:00
|
|
|
*/
|
|
|
|
|
2015-08-08 22:46:29 -05:00
|
|
|
box.Add(Spinbox(), false)
|
2015-08-08 22:03:05 -05:00
|
|
|
|
|
|
|
var mkhbox = {() -> Box in
|
|
|
|
Box(vertical: !firstvert, padded: spaced)
|
|
|
|
}
|
|
|
|
|
|
|
|
var hbox = mkhbox()
|
|
|
|
hbox.Add(Button("Button"), true)
|
|
|
|
hbox.Add(Button("Button"), true)
|
|
|
|
box.Add(hbox, false)
|
|
|
|
|
|
|
|
hbox = mkhbox()
|
|
|
|
hbox.Add(Button("Button"), true)
|
|
|
|
hbox.Add(Button("Button"), true)
|
|
|
|
box.Add(hbox, false)
|
|
|
|
|
|
|
|
hbox = mkhbox()
|
|
|
|
hbox.Add(Button("Button"), true)
|
|
|
|
hbox.Add(Button("A"), false)
|
|
|
|
hbox.Add(Button("BB"), false)
|
|
|
|
hbox.Add(Button("CCC"), false)
|
|
|
|
box.Add(hbox, false)
|
2015-08-07 18:44:08 -05:00
|
|
|
|
2015-08-08 22:46:29 -05:00
|
|
|
hbox = mkhbox()
|
|
|
|
hbox.Add(Spinbox(), false)
|
|
|
|
hbox.Add(Spinbox(), true)
|
|
|
|
box.Add(hbox, false)
|
|
|
|
|
|
|
|
hbox = mkhbox()
|
|
|
|
hbox.Add(Entry(), true)
|
|
|
|
hbox.Add(Entry(), false)
|
|
|
|
box.Add(hbox, false)
|
|
|
|
|
|
|
|
hbox = mkhbox()
|
|
|
|
hbox.Add(Label(), false)
|
|
|
|
box.Add(hbox, false)
|
|
|
|
|
2015-08-07 17:17:29 -05:00
|
|
|
mainwin.Show()
|
2015-08-07 18:29:01 -05:00
|
|
|
|
|
|
|
keepAliveMainwin = mainwin
|
2015-08-06 21:38:39 -05:00
|
|
|
}
|
|
|
|
|
2015-08-07 13:45:01 -05:00
|
|
|
class appDelegate : NSObject, NSApplicationDelegate {
|
2015-08-06 21:38:39 -05:00
|
|
|
func applicationDidFinishLaunching(note: NSNotification) {
|
|
|
|
appLaunched()
|
|
|
|
}
|
|
|
|
|
|
|
|
func applicationShouldTerminateAfterLastWindowClosed(app: NSApplication) -> Bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2015-08-08 18:47:53 -05:00
|
|
|
for arg in dropFirst(Process.arguments) {
|
|
|
|
if arg == "spaced" {
|
|
|
|
spaced = true
|
|
|
|
} else if arg == "horizontal" {
|
|
|
|
firstvert = false
|
|
|
|
} else {
|
|
|
|
fatalError("unrecognized option \(arg)")
|
|
|
|
}
|
|
|
|
}
|
2015-08-06 21:38:39 -05:00
|
|
|
|
|
|
|
var app = NSApplication.sharedApplication()
|
2015-08-07 13:45:01 -05:00
|
|
|
app.setActivationPolicy(NSApplicationActivationPolicy.Regular)
|
2015-08-07 14:07:53 -05:00
|
|
|
// NSApplication.delegate is weak; if we don't use the temporary variable, the delegate will die before it's used
|
|
|
|
var delegate = appDelegate()
|
|
|
|
app.delegate = delegate
|
2015-08-06 21:38:39 -05:00
|
|
|
app.run()
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|