1 Star 0 Fork 0

mentallxm/walk

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
rectangle.go 1.35 KB
一键复制 编辑 原始数据 按行查看 历史
// Copyright 2010 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 walk
import (
"github.com/lxn/win"
)
// Rectangle defines upper left corner with width and height region in 1/96" units, or native
// pixels, or grid rows and columns.
type Rectangle struct {
X, Y, Width, Height int
}
func (r Rectangle) IsZero() bool {
return r.X == 0 && r.Y == 0 && r.Width == 0 && r.Height == 0
}
func rectangleFromRECT(r win.RECT) Rectangle {
return Rectangle{
X: int(r.Left),
Y: int(r.Top),
Width: int(r.Right - r.Left),
Height: int(r.Bottom - r.Top),
}
}
func (r Rectangle) Left() int {
return r.X
}
func (r Rectangle) Top() int {
return r.Y
}
func (r Rectangle) Right() int {
return r.X + r.Width - 1
}
func (r Rectangle) Bottom() int {
return r.Y + r.Height - 1
}
func (r Rectangle) Location() Point {
return Point{r.X, r.Y}
}
func (r *Rectangle) SetLocation(p Point) Rectangle {
r.X = p.X
r.Y = p.Y
return *r
}
func (r Rectangle) Size() Size {
return Size{r.Width, r.Height}
}
func (r *Rectangle) SetSize(s Size) Rectangle {
r.Width = s.Width
r.Height = s.Height
return *r
}
func (r Rectangle) toRECT() win.RECT {
return win.RECT{
int32(r.X),
int32(r.Y),
int32(r.X + r.Width),
int32(r.Y + r.Height),
}
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/strawer/walk.git
git@gitee.com:strawer/walk.git
strawer
walk
walk
master

搜索帮助