BRect.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------------------+
2 |
3 | Supplied under applicable software license agreement.
4 |
5 | Copyright (c) 2018 Bentley Systems, Incorporated. All rights reserved.
6 |
7 +---------------------------------------------------------------------------------------*/
8 #pragma once
9 
10 #include <UI\UIFramework.h>
11 
12 #include <UI\Core\BSize.h>
13 #include <UI\Core\BPoint.h>
14 
16 
18 
19 //=======================================================================================
70 //=======================================================================================
71 class DLLEXPORT BRect : public BSIRect
72  {
73  public:
75  BRect ();
77  BRect (const BPoint &topleft, const BPoint &bottomright);
79  BRect (const BPoint &topleft, const BSize &size);
81  BRect (int left, int top, int width, int height);
82 
84  bool IsNull () const;
86  bool IsEmpty () const;
88  bool IsValid () const;
89 
93  BRect Normalized () const;
94 
96  int X () const;
98  int Y () const;
99 
101  void SetX (int x);
103  void SetY (int y);
105  void SetLeft (int pos);
107  void SetTop (int pos);
109  void SetRight (int pos);
111  void SetBottom (int pos);
112 
114  void SetTopLeft (const BPoint &p);
116  void SetBottomRight (const BPoint &p);
118  void SetTopRight (const BPoint &p);
120  void SetBottomLeft (const BPoint &p);
121 
123  BPoint TopLeft () const;
125  BPoint BottomRight () const;
127  BPoint TopRight () const;
129  BPoint BottomLeft () const;
131  BPoint Center () const;
132 
134  BSize Size () const;
136  void SetWidth (int w);
138  void SetHeight (int h);
140  void SetSize (const BSize &s);
141 
143  void MoveLeft (int pos);
145  void MoveTop (int pos);
147  void MoveRight (int pos);
149  void MoveBottom (int pos);
151  void MoveTopLeft (const BPoint &p);
153  void MoveBottomRight (const BPoint &p);
155  void MoveTopRight (const BPoint &p);
157  void MoveBottomLeft (const BPoint &p);
159  void MoveCenter (const BPoint &p);
160 
162  void MoveTo (int x, int y);
164  void MoveTo (const BPoint &p);
165 
170  void Translate (int dx, int dy);
171 
174  void Translate (const BPoint &p);
175 
179  BRect Translated (int dx, int dy) const;
180 
183  BRect Translated (const BPoint &p) const;
184 
186  void SetRect (int x, int y, int w, int h);
188  void GetRect (int *x, int *y, int *w, int *h) const;
189 
191  void SetCoords (int ox, int oy, int cx, int cy);
193  void GetCoords (int *ox, int *oy, int *cx, int *cy) const;
194 
196  void Adjust (int ox, int oy, int cx, int cy);
198  BRect Adjusted (int ox, int oy, int cx, int cy) const;
199 
204  bool Contains (const BPoint &p, bool proper = false) const;
209  bool Contains (int x, int y, bool proper = false) const;
214  bool Contains (const BRect &r, bool proper = false) const;
215 
217  BRect Unite (const BRect &r) const;
219  BRect United (const BRect &other) const;
220 
222  BRect Intersect (const BRect &r) const;
224  BRect Intersected (const BRect &other) const;
228  bool Intersects (const BRect &r) const;
229 
231  BRect operator | (const BRect &r) const;
234  BRect operator & (const BRect &r) const;
236  BRect& operator |= (const BRect &r);
239  BRect& operator &= (const BRect &r);
240 
242  friend bool operator == (const BRect &, const BRect &);
244  friend bool operator != (const BRect &, const BRect &);
245  };
246 
247 /*****************************************************************************
248  BRect inline friend operators
249  *****************************************************************************/
250 
252 inline bool operator == (const BRect &r1, const BRect &r2)
253  {
254  return r1.TopLeft () == r2.TopLeft () && r1.BottomRight () == r2.BottomRight ();
255  }
256 
258 inline bool operator != (const BRect &r1, const BRect &r2)
259  {
260  return r1.TopLeft () != r2.TopLeft () || r1.BottomRight () != r2.BottomRight ();
261  }
262 
bool operator==(const BRect &r1, const BRect &r2)
BRect - Operator overload for == (equality test).
Definition: BRect.h:252
BPoint TopLeft() const
Retrieves the origin X and Y.
The BRect class defines a rectangle using integer precision.
Definition: BRect.h:71
DgnECHostType operator|(DgnECHostType a, DgnECHostType b)
Definition: DgnECInstance.h:92
The BPoint class defines a point in the plane using integer precision.
Definition: BPoint.h:34
The BSize class defines the size of a two - dimensional object using integer point precision...
Definition: BSize.h:38
#define BEGIN_BENTLEY_UIFRAMEWORK_NAMESPACE
Definition: UIFramework.h:14
#define DLLEXPORT
Definition: basedefs.h:137
#define END_BENTLEY_UIFRAMEWORK_NAMESPACE
Definition: UIFramework.h:15
Curve's middle point or arc's center.
DgnECHostType operator&(DgnECHostType a, DgnECHostType b)
Definition: DgnECInstance.h:92
BPoint BottomRight() const
Retrieves the corner X and Y.
size_type size() const
Definition: stdcxx/bstdmap.h:214
bool operator!=(const BRect &r1, const BRect &r2)
BRect - Operator overload for != (not equal test).
Definition: BRect.h:258
Integer x,y rectangle coordinates for GUI: BSIRect.

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.