Esempio n. 1
0
func NewFill(parent ui.Drawer) *Fill {
	f := &Fill{
		parent,
		nil,
		false,
		false,
		ui.NewRectangle(0, 0, 0, 0),
		ui.Margin{0, 0, 0, 0},
		ui.NewMask(true),
		ui.NewKeyDispatch(),
		ui.NewCharDispatch(),
		ui.NewMouseDispatch(),
	}

	f.attachCB(parent)
	return f
}
Esempio n. 2
0
// NewTable builds a default Table.
func NewTable(parent ui.Drawer) *Table {
	table := &Table{
		ui.NewRectangle(0, 0, 0, 0),
		parent,
		nil,
		make([]*cell, 0),
		make([]float64, 0),
		make([]float64, 0),
		DEFAULT_TABLE_CELL_HEIGHT,
		DEFAULT_TABLE_CELL_WIDTH,
		ui.Margin{0, 0, 0, 0},
		ui.Padding{0, 0, 0, 0},
		ui.NewKeyDispatch(),
		ui.NewCharDispatch(),
		ui.NewMouseDispatch(),
		ui.NewScrollDispatch(),
	}

	table.route(parent)
	return table
}
Esempio n. 3
0
func (self *Table) bounds(child *cell) ui.Rectangle {
	x, y, w, h := self.X, self.Y, 0.0, 0.0
	for i := 0; i < child.col+child.w && i < len(self.cellWidths); i++ {
		if i < child.col {
			x += self.cellPadding.Left
			x += self.cellMargin.Left
			x += self.cellWidths[i]
		} else {
			w += self.cellPadding.Right

			if i == child.col+child.w-1 {
				w -= self.cellMargin.Right
			} else {
				w += self.cellMargin.Left
			}
			w += self.cellWidths[i]
		}
	}

	for i := 0; i < child.row+child.h && i < len(self.cellHeights); i++ {
		if i < child.row {
			y += self.cellPadding.Top
			y += self.cellMargin.Top
			y += self.cellHeights[i]
		} else {
			h += self.cellPadding.Bottom
			if i == child.row+child.h-1 {
				h -= self.cellMargin.Bottom
			} else {
				h += self.cellMargin.Top
			}
			h += self.cellHeights[i]
		}
	}
	return ui.NewRectangle(x, y, w, h)
}