File indexing completed on 2026-09-19 09:37:50
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGImageMap
0013 #define ROOT_TGImageMap
0014
0015
0016 #include "TGButton.h"
0017 #include "TPoint.h"
0018 #include "TGDimension.h"
0019
0020
0021 class TGRegionData;
0022 class TGPopupMenu;
0023 class TGToolTip;
0024 class TArrayS;
0025
0026
0027 class TGRegion : public TObject {
0028
0029 protected:
0030 TGRegionData *fData;
0031
0032 TGRegion(Bool_t);
0033 TGRegion CopyRegion() const;
0034
0035 public:
0036 enum ERegionType { kRectangle,
0037
0038 #if defined(__clang__) && __clang_major__ < 20
0039 #pragma clang diagnostic push
0040 #pragma clang diagnostic ignored "-Wshadow"
0041 #endif
0042 kEllipse };
0043 #if defined(__clang__) && __clang_major__ < 20
0044 #pragma clang diagnostic pop
0045 #endif
0046
0047 TGRegion();
0048 TGRegion(Int_t x, Int_t y, UInt_t w, UInt_t h, ERegionType = kRectangle);
0049 TGRegion(Int_t n, TPoint *points, Bool_t winding = kFALSE);
0050 TGRegion(Int_t n, Int_t *x, Int_t *y, Bool_t winding = kFALSE);
0051 TGRegion(const TArrayS &x, const TArrayS &y, Bool_t winding = kFALSE);
0052 TGRegion(const TGRegion ®);
0053 ~TGRegion() override;
0054
0055 Bool_t Contains(const TPoint &p) const;
0056 Bool_t Contains(Int_t x, Int_t y) const;
0057 TGRegion Unite(const TGRegion &r) const;
0058 TGRegion Intersect(const TGRegion &r) const;
0059 TGRegion Subtract(const TGRegion &r) const;
0060 TGRegion Eor(const TGRegion &r) const;
0061 TGDimension GetDimension() const;
0062 TGPosition GetPosition() const;
0063 Bool_t IsNull() const;
0064 Bool_t IsEmpty() const;
0065
0066 TGRegion operator|(const TGRegion &r) const { return Unite(r); }
0067 TGRegion operator+(const TGRegion &r) const { return Unite(r); }
0068 TGRegion operator&(const TGRegion &r) const { return Intersect(r); }
0069 TGRegion operator-(const TGRegion &r) const { return Subtract(r); }
0070 TGRegion operator^(const TGRegion &r) const { return Eor(r); }
0071 TGRegion& operator|=(const TGRegion &r) { return *this = *this | r; }
0072 TGRegion& operator+=(const TGRegion &r) { return *this = *this + r; }
0073 TGRegion& operator&=(const TGRegion &r) { return *this = *this & r; }
0074 TGRegion& operator-=(const TGRegion &r) { return *this = *this - r; }
0075 TGRegion& operator^=(const TGRegion &r) { return *this = *this ^ r; }
0076 Bool_t operator==(const TGRegion &r) const;
0077 Bool_t operator!=(const TGRegion &r) const { return !(operator==(r)); }
0078 TGRegion &operator=(const TGRegion &r);
0079
0080 ClassDefOverride(TGRegion,0)
0081 };
0082
0083
0084 class TGRegionWithId : public TGRegion {
0085
0086 private:
0087
0088 TGRegionWithId& operator=(const TGRegionWithId&) = delete;
0089
0090 protected:
0091 Int_t fId;
0092 TGToolTip *fTip;
0093 TGPopupMenu *fPopup;
0094
0095 public:
0096 TGRegionWithId();
0097 TGRegionWithId(Int_t id, Int_t x, Int_t y, UInt_t w, UInt_t h,
0098 ERegionType = kRectangle);
0099 TGRegionWithId(Int_t id, Int_t n, TPoint *points, Bool_t winding = kFALSE);
0100 TGRegionWithId(const TGRegionWithId ®);
0101 TGRegionWithId(const TGRegion ®, Int_t id);
0102 ~TGRegionWithId() override;
0103
0104 Int_t GetId() const { return fId; }
0105 TGToolTip *GetToolTipText() const { return fTip; }
0106 void SetToolTipText(const char *text, Long_t delayms,
0107 const TGFrame *frame);
0108 TGPopupMenu *GetPopup() const { return fPopup; }
0109 void SetPopup(TGPopupMenu *popup) { fPopup = popup; }
0110 void DisplayPopup();
0111
0112 ClassDefOverride(TGRegionWithId,0)
0113 };
0114
0115
0116 class TGImageMap : public TGPictureButton {
0117
0118 private:
0119
0120 TGImageMap(const TGImageMap&) = delete;
0121 TGImageMap& operator=(const TGImageMap&) = delete;
0122
0123 public:
0124 enum ENavMode { kNavRegions, kNavGrid };
0125
0126 protected:
0127 TList *fListOfRegions;
0128 ENavMode fNavMode;
0129 ECursor fCursorMouseOver;
0130 ECursor fCursorMouseOut;
0131 Int_t fLastVisited;
0132 TGToolTip *fMainTip;
0133 TList *fTrash;
0134
0135 public:
0136 TGImageMap(const TGWindow *p = nullptr, const TGPicture *pic = nullptr);
0137 TGImageMap(const TGWindow *p, const TString &pic);
0138 ~TGImageMap() override;
0139
0140 Bool_t HandleButton(Event_t *event) override;
0141 Bool_t HandleDoubleClick(Event_t *event) override;
0142 Bool_t HandleMotion(Event_t *event) override;
0143
0144 ENavMode GetNavMode() { return fNavMode; }
0145 void AddRegion(const TGRegion ®ion, Int_t id);
0146 TGPopupMenu *CreatePopup(Int_t id);
0147 TGPopupMenu *GetPopup(Int_t id);
0148
0149 void SetToolTipText(const char *text, Long_t delayms = 300) override;
0150 void SetToolTipText(Int_t id, const char *text, Long_t delayms = 300);
0151 void SetCursor(ECursor cursor = kHand) { fCursorMouseOver = cursor; }
0152 void SetPicture(const TGPicture * ) override { }
0153
0154 virtual void RegionClicked(Int_t id);
0155 virtual void DoubleClicked(Int_t id);
0156 virtual void DoubleClicked();
0157 virtual void OnMouseOver(Int_t id);
0158 virtual void OnMouseOut(Int_t id);
0159
0160 ClassDefOverride(TGImageMap,0)
0161 };
0162
0163 R__EXTERN TGRegionWithId *gCurrentRegion;
0164
0165 #endif