Started reimplementing Box.

This commit is contained in:
Pietro Gagliardi 2015-08-07 22:01:19 -04:00
parent 43e3d538e0
commit 34684cf2aa
1 changed files with 46 additions and 0 deletions

46
redo/osxaltest/box.swift Normal file
View File

@ -0,0 +1,46 @@
// 7 august 2015
import Cocoa
struct BoxControl {
var c: Control
var stretchy: Bool
}
class Box : NSView, Control {
private var controls: [BoxControl]
private var parent: Control?
private var padded: Bool
init(_ padded: Bool) {
self.controls = []
self.parent = nil
self.padded = padded
super.init(frame: NSZeroRect)
self.translatesAutoresizingMaskIntoConstraints = false
}
func Add(control: Control, stretchy: Stretchy) {
var c BoxControl
c.c = control
c.stretchy = stretchy
self.addSubview(c.c.View())
self.controls.append(c)
// TODO relayout
}
func View() -> NSView {
return self
}
func SetParent(p: Control) {
self.parent = p
}
func Relayout() {
if self.parent != nil {
self.parent?.Relayout()
}
}
}