github.com/secoba/wails/v2@v2.6.4/internal/frontend/desktop/windows/winc/rect.go (about)

     1  //go:build windows
     2  
     3  /*
     4   * Copyright (C) 2019 The Winc Authors. All Rights Reserved.
     5   * Copyright (C) 2010-2013 Allen Dang. All Rights Reserved.
     6   */
     7  
     8  package winc
     9  
    10  import (
    11  	"github.com/secoba/wails/v2/internal/frontend/desktop/windows/winc/w32"
    12  )
    13  
    14  type Rect struct {
    15  	rect w32.RECT
    16  }
    17  
    18  func NewEmptyRect() *Rect {
    19  	var newRect Rect
    20  	w32.SetRectEmpty(&newRect.rect)
    21  
    22  	return &newRect
    23  }
    24  
    25  func NewRect(left, top, right, bottom int) *Rect {
    26  	var newRect Rect
    27  	w32.SetRectEmpty(&newRect.rect)
    28  	newRect.Set(left, top, right, bottom)
    29  
    30  	return &newRect
    31  }
    32  
    33  func (re *Rect) Data() (left, top, right, bottom int32) {
    34  	left = re.rect.Left
    35  	top = re.rect.Top
    36  	right = re.rect.Right
    37  	bottom = re.rect.Bottom
    38  	return
    39  }
    40  
    41  func (re *Rect) Width() int {
    42  	return int(re.rect.Right - re.rect.Left)
    43  }
    44  
    45  func (re *Rect) Height() int {
    46  	return int(re.rect.Bottom - re.rect.Top)
    47  }
    48  
    49  func (re *Rect) GetW32Rect() *w32.RECT {
    50  	return &re.rect
    51  }
    52  
    53  func (re *Rect) Set(left, top, right, bottom int) {
    54  	w32.SetRect(&re.rect, left, top, right, bottom)
    55  }
    56  
    57  func (re *Rect) IsEqual(rect *Rect) bool {
    58  	return w32.EqualRect(&re.rect, &rect.rect)
    59  }
    60  
    61  func (re *Rect) Inflate(x, y int) {
    62  	w32.InflateRect(&re.rect, x, y)
    63  }
    64  
    65  func (re *Rect) Intersect(src *Rect) {
    66  	w32.IntersectRect(&re.rect, &re.rect, &src.rect)
    67  }
    68  
    69  func (re *Rect) IsEmpty() bool {
    70  	return w32.IsRectEmpty(&re.rect)
    71  }
    72  
    73  func (re *Rect) Offset(x, y int) {
    74  	w32.OffsetRect(&re.rect, x, y)
    75  }
    76  
    77  func (re *Rect) IsPointIn(x, y int) bool {
    78  	return w32.PtInRect(&re.rect, x, y)
    79  }
    80  
    81  func (re *Rect) Substract(src *Rect) {
    82  	w32.SubtractRect(&re.rect, &re.rect, &src.rect)
    83  }
    84  
    85  func (re *Rect) Union(src *Rect) {
    86  	w32.UnionRect(&re.rect, &re.rect, &src.rect)
    87  }