Ejemplo n.º 1
0
func (cw CustomWidget) Create(builder *Builder) error {
	w, err := walk.NewCustomWidget(builder.Parent(), uint(cw.Style), cw.Paint)
	if err != nil {
		return err
	}

	return builder.InitWidget(cw, w, func() error {
		w.SetClearsBackground(cw.ClearsBackground)
		w.SetInvalidatesOnResize(cw.InvalidatesOnResize)

		if cw.AssignTo != nil {
			*cw.AssignTo = w
		}

		return nil
	})
}
Ejemplo n.º 2
0
func (cw CustomWidget) Create(builder *Builder) error {
	w, err := walk.NewCustomWidget(builder.Parent(), uint(cw.Style), cw.Paint)
	if err != nil {
		return err
	}

	return builder.InitWidget(cw, w, func() error {
		if cw.PaintMode != PaintNormal && cw.ClearsBackground {
			panic("PaintMode and ClearsBackground are incompatible")
		}
		w.SetClearsBackground(cw.ClearsBackground)
		w.SetInvalidatesOnResize(cw.InvalidatesOnResize)
		w.SetPaintMode(walk.PaintMode(cw.PaintMode))

		if cw.AssignTo != nil {
			*cw.AssignTo = w
		}

		return nil
	})
}
Ejemplo n.º 3
0
func main() {
	walk.SetPanicOnError(true)

	mainWnd, _ := walk.NewMainWindow()

	mw := &MainWindow{MainWindow: mainWnd}
	mw.SetTitle("Walk Drawing Example")

	mw.SetLayout(walk.NewVBoxLayout())

	mw.paintWidget, _ = walk.NewCustomWidget(mw, 0, func(canvas *walk.Canvas, updateBounds walk.Rectangle) error {
		return mw.drawStuff(canvas, updateBounds)
	})
	mw.paintWidget.SetClearsBackground(true)
	mw.paintWidget.SetInvalidatesOnResize(true)

	mw.SetMinMaxSize(walk.Size{320, 240}, walk.Size{})
	mw.SetSize(walk.Size{800, 600})
	mw.Show()

	mw.Run()
}