예제 #1
0
파일: tableview.go 프로젝트: kumakichi/walk
func NewFooModel() *FooModel {
	m := new(FooModel)
	m.evenBitmap, _ = walk.NewBitmapFromFile("../img/open.png")
	m.oddIcon, _ = walk.NewIconFromFile("../img/x.ico")
	m.ResetRows()
	return m
}
예제 #2
0
파일: drawing.go 프로젝트: kumakichi/walk
func createBitmap() (*walk.Bitmap, error) {
	bounds := walk.Rectangle{Width: 200, Height: 200}

	bmp, err := walk.NewBitmap(bounds.Size())
	if err != nil {
		return nil, err
	}

	succeeded := false
	defer func() {
		if !succeeded {
			bmp.Dispose()
		}
	}()

	canvas, err := walk.NewCanvasFromImage(bmp)
	if err != nil {
		return nil, err
	}
	defer canvas.Dispose()

	brushBmp, err := walk.NewBitmapFromFile("../img/plus.png")
	if err != nil {
		return nil, err
	}
	defer brushBmp.Dispose()

	brush, err := walk.NewBitmapBrush(brushBmp)
	if err != nil {
		return nil, err
	}
	defer brush.Dispose()

	if err := canvas.FillRectangle(brush, bounds); err != nil {
		return nil, err
	}

	font, err := walk.NewFont("Times New Roman", 40, walk.FontBold|walk.FontItalic)
	if err != nil {
		return nil, err
	}
	defer font.Dispose()

	if err := canvas.DrawText("Walk Drawing Example", font, walk.RGB(0, 0, 0), bounds, walk.TextWordbreak); err != nil {
		return nil, err
	}

	succeeded = true

	return bmp, nil
}
예제 #3
0
파일: action.go 프로젝트: kumakichi/walk
func setActionImage(action *walk.Action, image interface{}) (err error) {
	var img *walk.Bitmap

	switch image := image.(type) {
	case nil:
		return nil

	case *walk.Bitmap:
		img = image

	case string:
		if img, err = walk.NewBitmapFromFile(image); err != nil {
			return
		}

	default:
		return errors.New("invalid type for Image")
	}

	return action.SetImage(img)
}