00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef ROOT_TGDimension
00013 #define ROOT_TGDimension
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef ROOT_TObject
00026 #include "TObject.h"
00027 #endif
00028
00029 class TGDimension {
00030 public:
00031 UInt_t fWidth;
00032 UInt_t fHeight;
00033
00034 TGDimension(): fWidth(0), fHeight(0) { }
00035 TGDimension(UInt_t width, UInt_t height): fWidth(width), fHeight(height) { }
00036 TGDimension(const TGDimension &d): fWidth(d.fWidth), fHeight(d.fHeight) { }
00037 virtual ~TGDimension() { }
00038
00039 Bool_t operator==(const TGDimension &b) const
00040 { return ((fWidth == b.fWidth) && (fHeight == b.fHeight)); }
00041 TGDimension operator-(const TGDimension &b) const
00042 { return TGDimension(fWidth - b.fWidth, fHeight - b.fHeight); }
00043 TGDimension operator+(const TGDimension &b) const
00044 { return TGDimension(fWidth + b.fWidth, fHeight + b.fHeight); }
00045
00046 ClassDef(TGDimension,0)
00047 };
00048
00049
00050 class TGPosition {
00051 public:
00052 Int_t fX;
00053 Int_t fY;
00054
00055 TGPosition(): fX(0), fY(0) { }
00056 TGPosition(Int_t xc, Int_t yc): fX(xc), fY(yc) { }
00057 TGPosition(const TGPosition &p): fX(p.fX), fY(p.fY) { }
00058 virtual ~TGPosition() { }
00059
00060 Bool_t operator==(const TGPosition &b) const
00061 { return ((fX == b.fX) && (fY == b.fY)); }
00062 TGPosition operator-(const TGPosition &b) const
00063 { return TGPosition(fX - b.fX, fY - b.fY); }
00064 TGPosition operator+(const TGPosition &b) const
00065 { return TGPosition(fX + b.fX, fY + b.fY); }
00066
00067 ClassDef(TGPosition,0)
00068 };
00069
00070
00071 class TGLongPosition {
00072 public:
00073 Long_t fX;
00074 Long_t fY;
00075
00076 TGLongPosition(): fX(0), fY(0) { }
00077 TGLongPosition(Long_t xc, Long_t yc): fX(xc), fY(yc) { }
00078 TGLongPosition(const TGLongPosition &p): fX(p.fX), fY(p.fY) { }
00079 virtual ~TGLongPosition() { }
00080
00081 Bool_t operator==(const TGLongPosition &b) const
00082 { return ((fX == b.fX) && (fY == b.fY)); }
00083 TGLongPosition operator-(const TGLongPosition &b) const
00084 { return TGLongPosition(fX - b.fX, fY - b.fY); }
00085 TGLongPosition operator+(const TGLongPosition &b) const
00086 { return TGLongPosition(fX + b.fX, fY + b.fY); }
00087
00088 ClassDef(TGLongPosition,0)
00089 };
00090
00091
00092 class TGInsets {
00093 public:
00094 Int_t fL;
00095 Int_t fR;
00096 Int_t fT;
00097 Int_t fB;
00098
00099 TGInsets(): fL(0), fR(0), fT(0), fB(0) { }
00100 TGInsets(Int_t lf, Int_t rg, Int_t tp, Int_t bt):
00101 fL(lf), fR(rg), fT(tp), fB(bt) { }
00102 TGInsets(const TGInsets &in):
00103 fL(in.fL), fR(in.fR), fT(in.fT), fB(in.fB) { }
00104 virtual ~TGInsets() { }
00105
00106 Bool_t operator==(const TGInsets &in) const
00107 { return ((fL == in.fL) && (fR == in.fR) && (fT == in.fT) && (fB == in.fB)); }
00108
00109 ClassDef(TGInsets,0)
00110 };
00111
00112
00113 class TGRectangle {
00114 public:
00115 Int_t fX;
00116 Int_t fY;
00117 UInt_t fW;
00118 UInt_t fH;
00119
00120
00121 TGRectangle(): fX(0), fY(0), fW(0), fH(0) { Empty(); }
00122 TGRectangle(Int_t rx, Int_t ry, UInt_t rw, UInt_t rh):
00123 fX(rx), fY(ry), fW(rw), fH(rh) { }
00124 TGRectangle(const TGPosition &p, const TGDimension &d):
00125 fX(p.fX), fY(p.fY), fW(d.fWidth), fH(d.fHeight) { }
00126 TGRectangle(const TGRectangle &r):
00127 fX(r.fX), fY(r.fY), fW(r.fW), fH(r.fH) { }
00128 virtual ~TGRectangle() { }
00129
00130
00131 Bool_t Contains(Int_t px, Int_t py) const
00132 { return ((px >= fX) && (px < fX + (Int_t) fW) &&
00133 (py >= fY) && (py < fY + (Int_t) fH)); }
00134 Bool_t Contains(const TGPosition &p) const
00135 { return ((p.fX >= fX) && (p.fX < fX + (Int_t) fW) &&
00136 (p.fY >= fY) && (p.fY < fY + (Int_t) fH)); }
00137 Bool_t Intersects(const TGRectangle &r) const
00138 { return ((fX <= r.fX + (Int_t) r.fW - 1) && (fX + (Int_t) fW - 1 >= r.fX) &&
00139 (fY <= r.fY + (Int_t) r.fH - 1) && (fY + (Int_t) fH - 1 >= r.fY)); }
00140 Int_t Area() const
00141 { return (fW * fH); }
00142 TGDimension Size() const
00143 { return TGDimension(fW, fH); }
00144 TGPosition LeftTop() const
00145 { return TGPosition(fX, fY); }
00146 TGPosition RightBottom() const
00147 { return TGPosition(fX + (Int_t) fW - 1, fY + (Int_t) fH - 1); }
00148 void Merge(const TGRectangle &r);
00149 void Empty() { fX = fY = 0; fW = fH = 0; }
00150 Bool_t IsEmpty() const { return ((fW == 0) && (fH == 0)); }
00151
00152 ClassDef(TGRectangle, 0)
00153 };
00154
00155 #endif