forked from AllenDang/gform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrect.go
72 lines (55 loc) · 1.35 KB
/
rect.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
60
61
62
63
64
65
66
67
68
69
70
71
72
package gform
import (
"github.com/AllenDang/w32"
)
type Rect struct {
rect w32.RECT
}
func NewEmptyRect() *Rect {
var newRect Rect
w32.SetRectEmpty(&newRect.rect)
return &newRect
}
func NewRect(left, top, right, bottom int) *Rect {
var newRect Rect
w32.SetRectEmpty(&newRect.rect)
newRect.Set(left, top, right, bottom)
return &newRect
}
func (this *Rect) Data() (left, top, right, bottom int32) {
left = this.rect.Left
top = this.rect.Top
right = this.rect.Right
bottom = this.rect.Bottom
return
}
func (this *Rect) GetW32Rect() *w32.RECT {
return &this.rect
}
func (this *Rect) Set(left, top, right, bottom int) {
w32.SetRect(&this.rect, left, top, right, bottom)
}
func (this *Rect) IsEqual(rect *Rect) bool {
return w32.EqualRect(&this.rect, &rect.rect)
}
func (this *Rect) Inflate(x, y int) {
w32.InflateRect(&this.rect, x, y)
}
func (this *Rect) Intersect(src *Rect) {
w32.IntersectRect(&this.rect, &this.rect, &src.rect)
}
func (this *Rect) IsEmpty() bool {
return w32.IsRectEmpty(&this.rect)
}
func (this *Rect) Offset(x, y int) {
w32.OffsetRect(&this.rect, x, y)
}
func (this *Rect) IsPointIn(x, y int) bool {
return w32.PtInRect(&this.rect, x, y)
}
func (this *Rect) Substract(src *Rect) {
w32.SubtractRect(&this.rect, &this.rect, &src.rect)
}
func (this *Rect) Union(src *Rect) {
w32.UnionRect(&this.rect, &this.rect, &src.rect)
}