blob: 461528027ccc27d8da7bc268eac4f0cb2bba6ada (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// Copyright 2017 The Walk Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// +build windows
package declarative
import (
"github.com/lxn/walk"
"strconv"
)
type TransparentBrush struct {
}
func (TransparentBrush) Create() (walk.Brush, error) {
return walk.NullBrush(), nil
}
type SolidColorBrush struct {
Color walk.Color
}
func (scb SolidColorBrush) Create() (walk.Brush, error) {
return walk.NewSolidColorBrush(scb.Color)
}
type SystemColorBrush struct {
Color walk.SystemColor
}
func (scb SystemColorBrush) Create() (walk.Brush, error) {
return walk.NewSystemColorBrush(scb.Color)
}
type BitmapBrush struct {
Image interface{}
}
func (bb BitmapBrush) Create() (walk.Brush, error) {
var bmp *walk.Bitmap
var err error
switch img := bb.Image.(type) {
case *walk.Bitmap:
bmp = img
case string:
if bmp, err = walk.Resources.Bitmap(img); err != nil {
return nil, err
}
case int:
if bmp, err = walk.Resources.Bitmap(strconv.Itoa(img)); err != nil {
return nil, err
}
default:
return nil, walk.ErrInvalidType
}
return walk.NewBitmapBrush(bmp)
}
type GradientBrush struct {
Vertexes []walk.GradientVertex
Triangles []walk.GradientTriangle
}
func (gb GradientBrush) Create() (walk.Brush, error) {
return walk.NewGradientBrush(gb.Vertexes, gb.Triangles)
}
|