Пример #1
0
func configureWidget(w *gtk.GtkWidget, b widgetBase) {
	width := -1
	if b.width != 0 {
		width = b.width
	}

	height := -1
	if b.height != 0 {
		height = b.height
	}

	if width != -1 || height != -1 {
		w.SetSizeRequest(width, height)
	}

	w.SetSensitive(!b.insensitive)

	if color := b.Foreground(); color != 0 {
		w.OverrideColor(gtk.GTK_STATE_FLAG_NORMAL, toColor(color))
	}
	if color := b.Background(); color != 0 {
		w.OverrideBackgroundColor(gtk.GTK_STATE_FLAG_NORMAL, toColor(color))
	}
	if len(b.font) != 0 {
		w.OverrideFont(b.font)
	}
	if b.hExpand {
		w.SetHExpand(true)
	}
	if b.vExpand {
		w.SetVExpand(true)
	}
	if b.margin > 0 {
		w.SetMargin(b.margin)
	}
	if b.marginTop > 0 {
		w.SetMarginTop(b.marginTop)
	}
	if b.marginBottom > 0 {
		w.SetMarginBottom(b.marginBottom)
	}
	if b.marginLeft > 0 {
		w.SetMarginLeft(b.marginLeft)
	}
	if b.vAlign != AlignNone {
		w.SetVAlign(alignToGTK(b.vAlign))
	}
	if b.hAlign != AlignNone {
		w.SetHAlign(alignToGTK(b.hAlign))
	}
}