Logo ROOT  
Reference Guide
TGDimension.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 02/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGDimension
13 #define ROOT_TGDimension
14 
15 
16 #include "RtypesCore.h"
17 
18 class TGDimension {
19 public:
20  UInt_t fWidth; // width
21  UInt_t fHeight; // height
22 
23  TGDimension(): fWidth(0), fHeight(0) { }
24  TGDimension(UInt_t width, UInt_t height): fWidth(width), fHeight(height) { }
25  ~TGDimension() = default;
26 
28  { return ((fWidth == b.fWidth) && (fHeight == b.fHeight)); }
30  { return TGDimension(fWidth - b.fWidth, fHeight - b.fHeight); }
32  { return TGDimension(fWidth + b.fWidth, fHeight + b.fHeight); }
33 };
34 
35 
36 class TGPosition {
37 public:
38  Int_t fX; ///< x position
39  Int_t fY; ///< y position
40 
41  TGPosition(): fX(0), fY(0) { }
42  TGPosition(Int_t xc, Int_t yc): fX(xc), fY(yc) { }
43  ~TGPosition() = default;
44 
45  Bool_t operator==(const TGPosition &b) const
46  { return ((fX == b.fX) && (fY == b.fY)); }
48  { return TGPosition(fX - b.fX, fY - b.fY); }
50  { return TGPosition(fX + b.fX, fY + b.fY); }
51 };
52 
53 
55 public:
56  Long_t fX; ///< x position
57  Long_t fY; ///< y position
58 
59  TGLongPosition(): fX(0), fY(0) { }
60  TGLongPosition(Long_t xc, Long_t yc): fX(xc), fY(yc) { }
61  ~TGLongPosition() = default;
62 
64  { return ((fX == b.fX) && (fY == b.fY)); }
66  { return TGLongPosition(fX - b.fX, fY - b.fY); }
68  { return TGLongPosition(fX + b.fX, fY + b.fY); }
69 };
70 
71 
72 class TGInsets {
73 public:
74  Int_t fL; ///< left
75  Int_t fR; ///< right
76  Int_t fT; ///< top
77  Int_t fB; ///< bottom
78 
79  TGInsets(): fL(0), fR(0), fT(0), fB(0) { }
80  TGInsets(Int_t lf, Int_t rg, Int_t tp, Int_t bt):
81  fL(lf), fR(rg), fT(tp), fB(bt) { }
82  ~TGInsets() = default;
83 
84  Bool_t operator==(const TGInsets &in) const
85  { return ((fL == in.fL) && (fR == in.fR) && (fT == in.fT) && (fB == in.fB)); }
86 };
87 
88 
89 class TGRectangle {
90 public:
91  Int_t fX; ///< x position
92  Int_t fY; ///< y position
93  UInt_t fW; ///< width
94  UInt_t fH; ///< height
95 
96  // constructors
97  TGRectangle(): fX(0), fY(0), fW(0), fH(0) { Empty(); }
98  TGRectangle(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh):
99  fX(rx), fY(ry), fW(rw), fH(rh) { }
100  TGRectangle(const TGPosition &p, const TGDimension &d):
101  fX(p.fX), fY(p.fY), fW(d.fWidth), fH(d.fHeight) { }
102  ~TGRectangle() = default;
103 
104  // methods
105  Bool_t Contains(Int_t px, Int_t py) const
106  { return ((px >= fX) && (px < fX + (Int_t) fW) &&
107  (py >= fY) && (py < fY + (Int_t) fH)); }
108  Bool_t Contains(const TGPosition &p) const
109  { return ((p.fX >= fX) && (p.fX < fX + (Int_t) fW) &&
110  (p.fY >= fY) && (p.fY < fY + (Int_t) fH)); }
112  { return ((fX <= r.fX + (Int_t) r.fW - 1) && (fX + (Int_t) fW - 1 >= r.fX) &&
113  (fY <= r.fY + (Int_t) r.fH - 1) && (fY + (Int_t) fH - 1 >= r.fY)); }
114  Int_t Area() const
115  { return (fW * fH); }
117  { return TGDimension(fW, fH); }
119  { return TGPosition(fX, fY); }
121  { return TGPosition(fX + (Int_t) fW - 1, fY + (Int_t) fH - 1); }
122  void Merge(const TGRectangle &r);
123  void Empty() { fX = fY = 0; fW = fH = 0; }
124  Bool_t IsEmpty() const { return ((fW == 0) && (fH == 0)); }
125 };
126 
127 #endif
TGPosition::operator-
TGPosition operator-(const TGPosition &b) const
Definition: TGDimension.h:47
TGDimension::TGDimension
TGDimension(UInt_t width, UInt_t height)
Definition: TGDimension.h:24
TGPosition::fY
Int_t fY
y position
Definition: TGDimension.h:39
TGLongPosition::operator==
Bool_t operator==(const TGLongPosition &b) const
Definition: TGDimension.h:63
TGDimension
Definition: TGDimension.h:18
TGRectangle::Size
TGDimension Size() const
Definition: TGDimension.h:116
TGInsets
Definition: TGDimension.h:72
TGRectangle::LeftTop
TGPosition LeftTop() const
Definition: TGDimension.h:118
TGRectangle::IsEmpty
Bool_t IsEmpty() const
Definition: TGDimension.h:124
TGPosition::TGPosition
TGPosition(Int_t xc, Int_t yc)
Definition: TGDimension.h:42
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TGPosition::TGPosition
TGPosition()
Definition: TGDimension.h:41
TGInsets::operator==
Bool_t operator==(const TGInsets &in) const
Definition: TGDimension.h:84
TGRectangle::TGRectangle
TGRectangle(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh)
Definition: TGDimension.h:98
TGRectangle::Contains
Bool_t Contains(Int_t px, Int_t py) const
Definition: TGDimension.h:105
TGInsets::fT
Int_t fT
top
Definition: TGDimension.h:76
TGInsets::TGInsets
TGInsets(Int_t lf, Int_t rg, Int_t tp, Int_t bt)
Definition: TGDimension.h:80
TGLongPosition::fY
Long_t fY
y position
Definition: TGDimension.h:57
width
include TDocParser_001 C image html pict1_TDocParser_001 png width
Definition: TDocParser.cxx:121
TGDimension::operator==
Bool_t operator==(const TGDimension &b) const
Definition: TGDimension.h:27
TGRectangle::fY
Int_t fY
y position
Definition: TGDimension.h:92
TGInsets::fB
Int_t fB
bottom
Definition: TGDimension.h:77
TGLongPosition::TGLongPosition
TGLongPosition()
Definition: TGDimension.h:59
TGInsets::fR
Int_t fR
right
Definition: TGDimension.h:75
TGPosition::operator==
Bool_t operator==(const TGPosition &b) const
Definition: TGDimension.h:45
b
#define b(i)
Definition: RSha256.hxx:100
bool
TGPosition::operator+
TGPosition operator+(const TGPosition &b) const
Definition: TGDimension.h:49
TGRectangle::Contains
Bool_t Contains(const TGPosition &p) const
Definition: TGDimension.h:108
TGDimension::~TGDimension
~TGDimension()=default
TGDimension::operator+
TGDimension operator+(const TGDimension &b) const
Definition: TGDimension.h:31
TGRectangle
Definition: TGDimension.h:89
TGLongPosition::TGLongPosition
TGLongPosition(Long_t xc, Long_t yc)
Definition: TGDimension.h:60
TGInsets::~TGInsets
~TGInsets()=default
TGInsets::TGInsets
TGInsets()
Definition: TGDimension.h:79
TGLongPosition::operator+
TGLongPosition operator+(const TGLongPosition &b) const
Definition: TGDimension.h:67
TGPosition::fX
Int_t fX
x position
Definition: TGDimension.h:38
TGDimension::fHeight
UInt_t fHeight
Definition: TGDimension.h:21
TGLongPosition::~TGLongPosition
~TGLongPosition()=default
TGRectangle::Intersects
Bool_t Intersects(const TGRectangle &r) const
Definition: TGDimension.h:111
TGInsets::fL
Int_t fL
left
Definition: TGDimension.h:74
TGLongPosition::fX
Long_t fX
x position
Definition: TGDimension.h:56
TGLongPosition::operator-
TGLongPosition operator-(const TGLongPosition &b) const
Definition: TGDimension.h:65
Long_t
long Long_t
Definition: RtypesCore.h:54
TGDimension::fWidth
UInt_t fWidth
Definition: TGDimension.h:20
TGRectangle::fX
Int_t fX
x position
Definition: TGDimension.h:91
TGDimension::TGDimension
TGDimension()
Definition: TGDimension.h:23
TGRectangle::Area
Int_t Area() const
Definition: TGDimension.h:114
TGRectangle::RightBottom
TGPosition RightBottom() const
Definition: TGDimension.h:120
unsigned int
TGLongPosition
Definition: TGDimension.h:54
TGRectangle::fW
UInt_t fW
width
Definition: TGDimension.h:93
TGRectangle::~TGRectangle
~TGRectangle()=default
TGPosition::~TGPosition
~TGPosition()=default
TGDimension::operator-
TGDimension operator-(const TGDimension &b) const
Definition: TGDimension.h:29
RtypesCore.h
TGRectangle::TGRectangle
TGRectangle(const TGPosition &p, const TGDimension &d)
Definition: TGDimension.h:100
d
#define d(i)
Definition: RSha256.hxx:102
TGRectangle::TGRectangle
TGRectangle()
Definition: TGDimension.h:97
TGRectangle::Empty
void Empty()
Definition: TGDimension.h:123
TGPosition
Definition: TGDimension.h:36
TGRectangle::fH
UInt_t fH
height
Definition: TGDimension.h:94
TGRectangle::Merge
void Merge(const TGRectangle &r)
Definition: TGDimension.cxx:49
int