forked from leaanthony/winc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pen.go
59 lines (46 loc) · 1019 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
55
56
57
58
59
/*
* Copyright (C) 2019 The Winc Authors. All Rights Reserved.
* Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.
*/
package winc
import (
"github.com/leaanthony/winc/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 (pen *Pen) Style() uint {
return pen.style
}
func (pen *Pen) Brush() *Brush {
return pen.brush
}
func (pen *Pen) GetHPEN() w32.HPEN {
return pen.hPen
}
func (pen *Pen) Dispose() {
if pen.hPen != 0 {
w32.DeleteObject(w32.HGDIOBJ(pen.hPen))
pen.hPen = 0
}
}