Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGImageMap.h
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Valeriy Onuchin & Fons Rademakers 18/10/2000
3
4/*************************************************************************
5 * Copyright (C) 1995-2021, 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_TGImageMap
13#define ROOT_TGImageMap
14
15//////////////////////////////////////////////////////////////////////////
16// //
17// TGImageMap (with TGRegion and TGRegionWithId help classes) //
18// //
19// A TGImageMap provides the functionality like a clickable image in //
20// a web browser with sensitive regions (MAP HTML tag). //
21// //
22//////////////////////////////////////////////////////////////////////////
23
24#include "TGButton.h"
25#include "TPoint.h"
26#include "TGDimension.h"
27
28
29class TGRegionData;
30class TGPopupMenu;
31class TGToolTip;
32class TArrayS;
33
34
35class TGRegion : public TObject {
36
37protected:
38 TGRegionData *fData; // data describing region
39
41 TGRegion CopyRegion() const;
42
43public:
45
46 TGRegion();
49 TGRegion(Int_t n, Int_t *x, Int_t *y, Bool_t winding = kFALSE);
50 TGRegion(const TArrayS &x, const TArrayS &y, Bool_t winding = kFALSE);
51 TGRegion(const TGRegion &reg);
52 virtual ~TGRegion();
53
54 Bool_t Contains(const TPoint &p) const;
55 Bool_t Contains(Int_t x, Int_t y) const;
56 TGRegion Unite(const TGRegion &r) const;
57 TGRegion Intersect(const TGRegion &r) const;
58 TGRegion Subtract(const TGRegion &r) const;
59 TGRegion Eor(const TGRegion &r) const;
61 TGPosition GetPosition() const;
62 Bool_t IsNull() const;
63 Bool_t IsEmpty() const;
64
65 TGRegion operator|(const TGRegion &r) const { return Unite(r); }
66 TGRegion operator+(const TGRegion &r) const { return Unite(r); }
67 TGRegion operator&(const TGRegion &r) const { return Intersect(r); }
68 TGRegion operator-(const TGRegion &r) const { return Subtract(r); }
69 TGRegion operator^(const TGRegion &r) const { return Eor(r); }
70 TGRegion& operator|=(const TGRegion &r) { return *this = *this | r; }
71 TGRegion& operator+=(const TGRegion &r) { return *this = *this + r; }
72 TGRegion& operator&=(const TGRegion &r) { return *this = *this & r; }
73 TGRegion& operator-=(const TGRegion &r) { return *this = *this - r; }
74 TGRegion& operator^=(const TGRegion &r) { return *this = *this ^ r; }
75 Bool_t operator==(const TGRegion &r) const;
76 Bool_t operator!=(const TGRegion &r) const { return !(operator==(r)); }
78
79 ClassDef(TGRegion,0) // Describes a region
80};
81
82
83class TGRegionWithId : public TGRegion {
84
85private:
86
88
89protected:
90 Int_t fId; // region id
91 TGToolTip *fTip; // tooltip
92 TGPopupMenu *fPopup; // popup menu
93
94public:
100 TGRegionWithId(const TGRegion &reg, Int_t id);
101 virtual ~TGRegionWithId();
102
103 Int_t GetId() const { return fId; }
104 TGToolTip *GetToolTipText() const { return fTip; }
105 void SetToolTipText(const char *text, Long_t delayms,
106 const TGFrame *frame);
107 TGPopupMenu *GetPopup() const { return fPopup; }
108 void SetPopup(TGPopupMenu *popup) { fPopup = popup; }
109 void DisplayPopup();
110
111 ClassDef(TGRegionWithId,0) // Region with id, tooltip text and popup menu
112};
113
114
116
117private:
118
119 TGImageMap(const TGImageMap&) = delete;
120 TGImageMap& operator=(const TGImageMap&) = delete;
121
122public:
124
125protected:
126 TList *fListOfRegions; // list of regions
127 ENavMode fNavMode; // navigation mode
128 ECursor fCursorMouseOver; // cursor shape in regions
129 ECursor fCursorMouseOut; // cursor shape out of regions
130 Int_t fLastVisited; // id of the last visited region
131 TGToolTip *fMainTip; // tooltip text for main region
132 TList *fTrash; // collect all objects that need to be cleaned up
133
134public:
135 TGImageMap(const TGWindow *p = nullptr, const TGPicture *pic = nullptr);
136 TGImageMap(const TGWindow *p, const TString &pic);
137 virtual ~TGImageMap();
138
139 virtual Bool_t HandleButton(Event_t *event);
140 virtual Bool_t HandleDoubleClick(Event_t *event);
141 virtual Bool_t HandleMotion(Event_t *event);
142
144 void AddRegion(const TGRegion &region, Int_t id);
147
148 void SetToolTipText(const char *text, Long_t delayms = 300);
149 void SetToolTipText(Int_t id, const char *text, Long_t delayms = 300);
150 void SetCursor(ECursor cursor = kHand) { fCursorMouseOver = cursor; }
151 void SetPicture(const TGPicture * /*new_pic*/) { } // disabled
152
153 virtual void RegionClicked(Int_t id); // *SIGNAL*
154 virtual void DoubleClicked(Int_t id); // *SIGNAL*
155 virtual void DoubleClicked(); // *SIGNAL*
156 virtual void OnMouseOver(Int_t id); // *SIGNAL*
157 virtual void OnMouseOut(Int_t id); // *SIGNAL*
158
159 ClassDef(TGImageMap,0) // Clickable image (like MAP in HTML)
160};
161
163
164#endif
#define R__EXTERN
Definition DllImport.h:27
ECursor
Definition GuiTypes.h:372
@ kHand
Definition GuiTypes.h:374
ROOT::R::TRInterface & r
Definition Object.C:4
#define h(i)
Definition RSha256.hxx:106
int Int_t
Definition RtypesCore.h:45
unsigned int UInt_t
Definition RtypesCore.h:46
const Bool_t kFALSE
Definition RtypesCore.h:92
long Long_t
Definition RtypesCore.h:54
bool Bool_t
Definition RtypesCore.h:63
#define ClassDef(name, id)
Definition Rtypes.h:325
R__EXTERN TGRegionWithId * gCurrentRegion
Definition TGImageMap.h:162
point * points
Definition X3DBuffer.c:22
Array of shorts (16 bits per element).
Definition TArrayS.h:27
void SetToolTipText(const char *text, Long_t delayms=300)
Set tooltip text for main region.
virtual ~TGImageMap()
Cleanup image map widget.
ENavMode fNavMode
Definition TGImageMap.h:127
ENavMode GetNavMode()
Definition TGImageMap.h:143
TGPopupMenu * GetPopup(Int_t id)
Return popup for regions with specified id.
Int_t fLastVisited
Definition TGImageMap.h:130
virtual void OnMouseOut(Int_t id)
Handle when mouse moves from region id.
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion events.
virtual void OnMouseOver(Int_t id)
Handle when mouse moves over region id.
TGToolTip * fMainTip
Definition TGImageMap.h:131
TList * fTrash
Definition TGImageMap.h:132
virtual void DoubleClicked()
Handle when mouse is double clicked on main map.
virtual Bool_t HandleButton(Event_t *event)
Handle button events.
TGImageMap & operator=(const TGImageMap &)=delete
void SetPicture(const TGPicture *)
Change a picture in a picture button.
Definition TGImageMap.h:151
void AddRegion(const TGRegion &region, Int_t id)
Add a region to the image map.
TGPopupMenu * CreatePopup(Int_t id)
Create popoup menu or returns existing for regions with specified id.
TList * fListOfRegions
Definition TGImageMap.h:126
void SetCursor(ECursor cursor=kHand)
Definition TGImageMap.h:150
virtual Bool_t HandleDoubleClick(Event_t *event)
Handle double click events.
TGImageMap(const TGImageMap &)=delete
ECursor fCursorMouseOver
Definition TGImageMap.h:128
virtual void RegionClicked(Int_t id)
Handle when mouse was clicked on region id.
ECursor fCursorMouseOut
Definition TGImageMap.h:129
void SetPopup(TGPopupMenu *popup)
Definition TGImageMap.h:108
TGPopupMenu * fPopup
Definition TGImageMap.h:92
TGRegionWithId & operator=(const TGRegionWithId &)=delete
void SetToolTipText(const char *text, Long_t delayms, const TGFrame *frame)
Set tool tip text associated with this region.
Int_t GetId() const
Definition TGImageMap.h:103
TGToolTip * fTip
Definition TGImageMap.h:91
void DisplayPopup()
Display popup menu associated with this region.
TGPopupMenu * GetPopup() const
Definition TGImageMap.h:107
virtual ~TGRegionWithId()
Cleanup.
TGRegionWithId()
Create GUI region (with id and possible tooltip).
TGToolTip * GetToolTipText() const
Definition TGImageMap.h:104
TGRegion & operator+=(const TGRegion &r)
Definition TGImageMap.h:71
TGRegion CopyRegion() const
Copy a region.
Bool_t IsEmpty() const
Return true if region is empty.
TGRegion & operator&=(const TGRegion &r)
Definition TGImageMap.h:72
virtual ~TGRegion()
Delete a region.
TGDimension GetDimension() const
Return dimension of region (widht, height).
TGRegion Unite(const TGRegion &r) const
Return the union of this region with r.
TGRegion operator^(const TGRegion &r) const
Definition TGImageMap.h:69
TGRegion & operator^=(const TGRegion &r)
Definition TGImageMap.h:74
Bool_t Contains(const TPoint &p) const
Return true if point p is contained in the region.
Bool_t IsNull() const
Return true if region is not set.
TGRegion operator-(const TGRegion &r) const
Definition TGImageMap.h:68
TGRegion & operator|=(const TGRegion &r)
Definition TGImageMap.h:70
TGRegion operator&(const TGRegion &r) const
Definition TGImageMap.h:67
TGRegion operator|(const TGRegion &r) const
Definition TGImageMap.h:65
TGPosition GetPosition() const
Return position of region (x, y).
TGRegion Eor(const TGRegion &r) const
Returns a region which is the difference between the union and intersection this region and r.
TGRegionData * fData
Definition TGImageMap.h:38
Bool_t operator==(const TGRegion &r) const
Region == operator.
TGRegion operator+(const TGRegion &r) const
Definition TGImageMap.h:66
Bool_t operator!=(const TGRegion &r) const
Definition TGImageMap.h:76
TGRegion Subtract(const TGRegion &r) const
Returns a region which is r subtracted from this region.
TGRegion & operator-=(const TGRegion &r)
Definition TGImageMap.h:73
TGRegion Intersect(const TGRegion &r) const
Returns a region which is the intersection of this region and r.
TGRegion()
Create a region object.
TGRegion & operator=(const TGRegion &r)
Region assignment operator.
A doubly linked list.
Definition TList.h:44
Mother of all ROOT objects.
Definition TObject.h:37
Basic string class.
Definition TString.h:136
TText * text
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
const Int_t n
Definition legend1.C:16
Event structure.
Definition GuiTypes.h:174