-
Notifications
You must be signed in to change notification settings - Fork 45
/
brush.go
45 lines (36 loc) · 919 Bytes
/
brush.go
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
package gform
import (
"github.com/AllenDang/w32"
)
type Brush struct {
hBrush w32.HBRUSH
logBrush w32.LOGBRUSH
}
func NewSolidColorBrush(color Color) *Brush {
lb := w32.LOGBRUSH{LbStyle: w32.BS_SOLID, LbColor: w32.COLORREF(color)}
hBrush := w32.CreateBrushIndirect(&lb)
if hBrush == 0 {
panic("Faild to create solid color brush")
}
return &Brush{hBrush, lb}
}
func NewNullBrush() *Brush {
lb := w32.LOGBRUSH{LbStyle: w32.BS_NULL}
hBrush := w32.CreateBrushIndirect(&lb)
if hBrush == 0 {
panic("Failed to create null brush")
}
return &Brush{hBrush, lb}
}
func (this *Brush) GetHBRUSH() w32.HBRUSH {
return this.hBrush
}
func (this *Brush) GetLOGBRUSH() *w32.LOGBRUSH {
return &this.logBrush
}
func (this *Brush) Dispose() {
if this.hBrush != 0 {
w32.DeleteObject(w32.HGDIOBJ(this.hBrush))
this.hBrush = 0
}
}