SimpleWindow
载入中...
搜索中...
未找到
Rect.h
1#pragma once
2
3#include "IComparable.h"
4#include "IToString.h"
5#include "Point.h"
6#include "Size.h"
7#include <Windows.h>
8#include <string>
9#include <type_traits>
10
11namespace sw
12{
16 struct Rect : public IToString<Rect>,
17 public IEqualityComparable<Rect> {
21 double left;
22
26 double top;
27
31 double width;
32
36 double height;
37
41 Rect() = default;
42
46 Rect(double left, double top, double width, double height);
47
51 Rect(const RECT &rect);
52
56 operator RECT() const;
57
61 Point GetPos() const;
62
66 Size GetSize() const;
67
71 bool Equals(const Rect &other) const;
72
76 std::wstring ToString() const;
77 };
78
79 // Rect应为POD类型
80 static_assert(
81 std::is_trivial<Rect>::value && std::is_standard_layout<Rect>::value,
82 "Rect should be a POD type.");
83}
相等性比较接口
Definition IComparable.h:14
为支持ToString方法的类提供统一接口
Definition IToString.h:13
表示相对于左上角的点坐标
Definition Point.h:15
表示一个矩形区域
Definition Rect.h:17
Rect()=default
默认构造函数
std::wstring ToString() const
获取描述当前对象的字符串
Point GetPos() const
获取Rect左上角的位置
Rect(const RECT &rect)
从RECT构造Rect
Size GetSize() const
获取Rect的尺寸
Rect(double left, double top, double width, double height)
构造Rect
bool Equals(const Rect &other) const
判断两个Rect是否相等
double width
宽度
Definition Rect.h:31
double top
顶边
Definition Rect.h:26
double left
左边
Definition Rect.h:21
double height
高度
Definition Rect.h:36
尺寸
Definition Size.h:15