#ifndef ROOT_TGImageMap
#define ROOT_TGImageMap
#include "TGButton.h"
#include "TPoint.h"
#include "TGDimension.h"
class TGRegionData;
class TGPopupMenu;
class TGToolTip;
class TArrayS;
class TGRegion : public TObject {
protected:
TGRegionData *fData;
TGRegion(Bool_t);
TGRegion CopyRegion() const;
public:
enum ERegionType { kRectangle, kEllipse };
TGRegion();
TGRegion(Int_t x, Int_t y, UInt_t w, UInt_t h, ERegionType = kRectangle);
TGRegion(Int_t n, TPoint *points, Bool_t winding = kFALSE);
TGRegion(Int_t n, Int_t *x, Int_t *y, Bool_t winding = kFALSE);
TGRegion(const TArrayS &x, const TArrayS &y, Bool_t winding = kFALSE);
TGRegion(const TGRegion ®);
virtual ~TGRegion();
Bool_t Contains(const TPoint &p) const;
Bool_t Contains(Int_t x, Int_t y) const;
TGRegion Unite(const TGRegion &r) const;
TGRegion Intersect(const TGRegion &r) const;
TGRegion Subtract(const TGRegion &r) const;
TGRegion Eor(const TGRegion &r) const;
TGDimension GetDimension() const;
TGPosition GetPosition() const;
Bool_t IsNull() const;
Bool_t IsEmpty() const;
TGRegion operator|(const TGRegion &r) const { return Unite(r); }
TGRegion operator+(const TGRegion &r) const { return Unite(r); }
TGRegion operator&(const TGRegion &r) const { return Intersect(r); }
TGRegion operator-(const TGRegion &r) const { return Subtract(r); }
TGRegion operator^(const TGRegion &r) const { return Eor(r); }
TGRegion& operator|=(const TGRegion &r) { return *this = *this | r; }
TGRegion& operator+=(const TGRegion &r) { return *this = *this + r; }
TGRegion& operator&=(const TGRegion &r) { return *this = *this & r; }
TGRegion& operator-=(const TGRegion &r) { return *this = *this - r; }
TGRegion& operator^=(const TGRegion &r) { return *this = *this ^ r; }
Bool_t operator==(const TGRegion &r) const;
Bool_t operator!=(const TGRegion &r) const { return !(operator==(r)); }
TGRegion &operator=(const TGRegion &r);
ClassDef(TGRegion,0)
};
class TGRegionWithId : public TGRegion {
private:
TGRegionWithId& operator=(const TGRegionWithId&);
protected:
Int_t fId;
TGToolTip *fTip;
TGPopupMenu *fPopup;
public:
TGRegionWithId();
TGRegionWithId(Int_t id, Int_t x, Int_t y, UInt_t w, UInt_t h,
ERegionType = kRectangle);
TGRegionWithId(Int_t id, Int_t n, TPoint *points, Bool_t winding = kFALSE);
TGRegionWithId(const TGRegionWithId ®);
TGRegionWithId(const TGRegion ®, Int_t id);
virtual ~TGRegionWithId();
Int_t GetId() const { return fId; }
TGToolTip *GetToolTipText() const { return fTip; }
void SetToolTipText(const char *text, Long_t delayms,
const TGFrame *frame);
TGPopupMenu *GetPopup() const { return fPopup; }
void SetPopup(TGPopupMenu *popup) { fPopup = popup; }
void DisplayPopup();
ClassDef(TGRegionWithId,0)
};
class TGImageMap : public TGPictureButton {
private:
TGImageMap(const TGImageMap&);
TGImageMap& operator=(const TGImageMap&);
public:
enum ENavMode { kNavRegions, kNavGrid };
protected:
TList *fListOfRegions;
ENavMode fNavMode;
ECursor fCursorMouseOver;
ECursor fCursorMouseOut;
Int_t fLastVisited;
TGToolTip *fMainTip;
TList *fTrash;
public:
TGImageMap(const TGWindow *p = 0, const TGPicture *pic = 0);
TGImageMap(const TGWindow *p, const TString &pic);
virtual ~TGImageMap();
virtual Bool_t HandleButton(Event_t *event);
virtual Bool_t HandleDoubleClick(Event_t *event);
virtual Bool_t HandleMotion(Event_t *event);
ENavMode GetNavMode() { return fNavMode; }
void AddRegion(const TGRegion ®ion, Int_t id);
TGPopupMenu *CreatePopup(Int_t id);
TGPopupMenu *GetPopup(Int_t id);
void SetToolTipText(const char *text, Long_t delayms = 300);
void SetToolTipText(Int_t id, const char *text, Long_t delayms = 300);
void SetCursor(ECursor cursor = kHand) { fCursorMouseOver = cursor; }
void SetPicture(const TGPicture * ) { }
virtual void RegionClicked(Int_t id);
virtual void DoubleClicked(Int_t id);
virtual void DoubleClicked();
virtual void OnMouseOver(Int_t id);
virtual void OnMouseOut(Int_t id);
ClassDef(TGImageMap,0)
};
R__EXTERN TGRegionWithId *gCurrentRegion;
#endif