예제 #1
0
func (v *ScrolledView) scrolledViewInit(width, height int) (err error) {
	v.hadj, err = gtk.AdjustmentNew(0, 0, float64(width), 1, 10, float64(width))
	if err != nil {
		log.Println("Unable to create hadj:", err)
		return
	}
	v.vadj, err = gtk.AdjustmentNew(0, 0, float64(height), 1, 10, float64(height))
	if err != nil {
		log.Println("Unable to create vadj:", err)
		return
	}
	v.scrolled, err = gtk.ScrolledWindowNew(v.hadj, v.vadj)
	if err != nil {
		log.Println("Unable to create scrolled:", err)
		return
	}
	v.scrolled.SetHExpand(true)
	v.scrolled.SetVExpand(true)
	return
}
예제 #2
0
func (v *ScaledView) init() (err error) {
	v.layoutBox, err = gtk.BoxNew(gtk.ORIENTATION_VERTICAL, 0)
	if err != nil {
		return
	}
	const (
		initialWidth  = 800
		initialHeight = 600
	)
	v.scene, err = ScrolledViewNew(initialWidth, initialHeight)
	if err != nil {
		return
	}
	var adj *gtk.Adjustment
	adj, err = gtk.AdjustmentNew(0.0, scaleMin, scaleMax, scaleStep, scalePStep, scalePage)
	v.scaler, err = gtk.ScaleNew(gtk.ORIENTATION_HORIZONTAL, adj)
	if err != nil {
		return
	}
	v.scaler.Connect("value-changed", scalerValueCallback, v)
	v.layoutBox.Add(v.scene.Widget())
	v.layoutBox.Add(v.scaler)
	return
}
예제 #3
0
파일: newgtk.go 프로젝트: sqp/godock
// Adjustment recast a pointer to *gtk.Adjustment.
func Adjustment(value, lower, upper, stepIncrement, pageIncrement, pageSize float64) *gtk.Adjustment {
	w, _ := gtk.AdjustmentNew(value, lower, upper, stepIncrement, pageIncrement, pageSize)
	return w
}