12 #ifndef ROOT_TGDimension
13 #define ROOT_TGDimension
32 TGDimension(): fWidth(0), fHeight(0) { }
33 TGDimension(UInt_t width, UInt_t height): fWidth(width), fHeight(height) { }
34 ~TGDimension() =
default;
36 Bool_t operator==(
const TGDimension &b)
const
37 {
return ((fWidth == b.fWidth) && (fHeight == b.fHeight)); }
38 TGDimension operator-(
const TGDimension &b)
const
39 {
return TGDimension(fWidth - b.fWidth, fHeight - b.fHeight); }
40 TGDimension operator+(
const TGDimension &b)
const
41 {
return TGDimension(fWidth + b.fWidth, fHeight + b.fHeight); }
50 TGPosition(): fX(0), fY(0) { }
51 TGPosition(Int_t xc, Int_t yc): fX(xc), fY(yc) { }
52 ~TGPosition() =
default;
54 Bool_t operator==(
const TGPosition &b)
const
55 {
return ((fX == b.fX) && (fY == b.fY)); }
56 TGPosition operator-(
const TGPosition &b)
const
57 {
return TGPosition(fX - b.fX, fY - b.fY); }
58 TGPosition operator+(
const TGPosition &b)
const
59 {
return TGPosition(fX + b.fX, fY + b.fY); }
63 class TGLongPosition {
68 TGLongPosition(): fX(0), fY(0) { }
69 TGLongPosition(Long_t xc, Long_t yc): fX(xc), fY(yc) { }
70 ~TGLongPosition() =
default;
72 Bool_t operator==(
const TGLongPosition &b)
const
73 {
return ((fX == b.fX) && (fY == b.fY)); }
74 TGLongPosition operator-(
const TGLongPosition &b)
const
75 {
return TGLongPosition(fX - b.fX, fY - b.fY); }
76 TGLongPosition operator+(
const TGLongPosition &b)
const
77 {
return TGLongPosition(fX + b.fX, fY + b.fY); }
88 TGInsets(): fL(0), fR(0), fT(0), fB(0) { }
89 TGInsets(Int_t lf, Int_t rg, Int_t tp, Int_t bt):
90 fL(lf), fR(rg), fT(tp), fB(bt) { }
91 ~TGInsets() =
default;
93 Bool_t operator==(
const TGInsets &in)
const
94 {
return ((fL == in.fL) && (fR == in.fR) && (fT == in.fT) && (fB == in.fB)); }
106 TGRectangle(): fX(0), fY(0), fW(0), fH(0) { Empty(); }
107 TGRectangle(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh):
108 fX(rx), fY(ry), fW(rw), fH(rh) { }
109 TGRectangle(
const TGPosition &p,
const TGDimension &d):
110 fX(p.fX), fY(p.fY), fW(d.fWidth), fH(d.fHeight) { }
111 ~TGRectangle() =
default;
114 Bool_t Contains(Int_t px, Int_t py)
const
115 {
return ((px >= fX) && (px < fX + (Int_t) fW) &&
116 (py >= fY) && (py < fY + (Int_t) fH)); }
117 Bool_t Contains(
const TGPosition &p)
const
118 {
return ((p.fX >= fX) && (p.fX < fX + (Int_t) fW) &&
119 (p.fY >= fY) && (p.fY < fY + (Int_t) fH)); }
120 Bool_t Intersects(
const TGRectangle &r)
const
121 {
return ((fX <= r.fX + (Int_t) r.fW - 1) && (fX + (Int_t) fW - 1 >= r.fX) &&
122 (fY <= r.fY + (Int_t) r.fH - 1) && (fY + (Int_t) fH - 1 >= r.fY)); }
124 {
return (fW * fH); }
125 TGDimension Size()
const
126 {
return TGDimension(fW, fH); }
127 TGPosition LeftTop()
const
128 {
return TGPosition(fX, fY); }
129 TGPosition RightBottom()
const
130 {
return TGPosition(fX + (Int_t) fW - 1, fY + (Int_t) fH - 1); }
131 void Merge(
const TGRectangle &r);
132 void Empty() { fX = fY = 0; fW = fH = 0; }
133 Bool_t IsEmpty()
const {
return ((fW == 0) && (fH == 0)); }