示例#1
0
文件: fill.go 项目: xormplus/ui-1
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
}
示例#2
0
文件: table.go 项目: xormplus/ui-1
// 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
}
示例#3
0
文件: table.go 项目: xormplus/ui-1
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)
}