-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathpen.go
54 lines (42 loc) · 982 Bytes
/
pen.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
46
47
48
49
50
51
52
53
54
package gform
import (
"github.com/AllenDang/w32"
)
type Pen struct {
hPen w32.HPEN
style uint
brush *Brush
}
func NewPen(style uint, width uint, brush *Brush) *Pen {
if brush == nil {
panic("Brush cannot be nil")
}
hPen := w32.ExtCreatePen(style, width, brush.GetLOGBRUSH(), 0, nil)
if hPen == 0 {
panic("Failed to create pen")
}
return &Pen{hPen, style, brush}
}
func NewNullPen() *Pen {
lb := w32.LOGBRUSH{LbStyle: w32.BS_NULL}
hPen := w32.ExtCreatePen(w32.PS_COSMETIC|w32.PS_NULL, 1, &lb, 0, nil)
if hPen == 0 {
panic("failed to create null brush")
}
return &Pen{hPen: hPen}
}
func (this *Pen) Style() uint {
return this.style
}
func (this *Pen) Brush() *Brush {
return this.brush
}
func (this *Pen) GetHPEN() w32.HPEN {
return this.hPen
}
func (this *Pen) Dispose() {
if this.hPen != 0 {
w32.DeleteObject(w32.HGDIOBJ(this.hPen))
this.hPen = 0
}
}