Logo ROOT  
Reference Guide
No Matches
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Valeriy Onuchin & Fons Rademakers 18/10/2000
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 *************************************************************************/
12#ifndef ROOT_TGImageMap
13#define ROOT_TGImageMap
16#include "TGButton.h"
17#include "TPoint.h"
18#include "TGDimension.h"
21class TGRegionData;
22class TGPopupMenu;
23class TGToolTip;
24class TArrayS;
27class TGRegion : public TObject {
30 TGRegionData *fData; // data describing region
33 TGRegion CopyRegion() const;
38 TGRegion();
41 TGRegion(Int_t n, Int_t *x, Int_t *y, Bool_t winding = kFALSE);
42 TGRegion(const TArrayS &x, const TArrayS &y, Bool_t winding = kFALSE);
43 TGRegion(const TGRegion &reg);
44 ~TGRegion() override;
46 Bool_t Contains(const TPoint &p) const;
47 Bool_t Contains(Int_t x, Int_t y) const;
48 TGRegion Unite(const TGRegion &r) const;
49 TGRegion Intersect(const TGRegion &r) const;
50 TGRegion Subtract(const TGRegion &r) const;
51 TGRegion Eor(const TGRegion &r) const;
53 TGPosition GetPosition() const;
54 Bool_t IsNull() const;
55 Bool_t IsEmpty() const;
57 TGRegion operator|(const TGRegion &r) const { return Unite(r); }
58 TGRegion operator+(const TGRegion &r) const { return Unite(r); }
59 TGRegion operator&(const TGRegion &r) const { return Intersect(r); }
60 TGRegion operator-(const TGRegion &r) const { return Subtract(r); }
61 TGRegion operator^(const TGRegion &r) const { return Eor(r); }
62 TGRegion& operator|=(const TGRegion &r) { return *this = *this | r; }
63 TGRegion& operator+=(const TGRegion &r) { return *this = *this + r; }
64 TGRegion& operator&=(const TGRegion &r) { return *this = *this & r; }
65 TGRegion& operator-=(const TGRegion &r) { return *this = *this - r; }
66 TGRegion& operator^=(const TGRegion &r) { return *this = *this ^ r; }
67 Bool_t operator==(const TGRegion &r) const;
68 Bool_t operator!=(const TGRegion &r) const { return !(operator==(r)); }
71 ClassDefOverride(TGRegion,0) // Describes a region
75class TGRegionWithId : public TGRegion {
82 Int_t fId; ///< region id
83 TGToolTip *fTip; ///< tooltip
84 TGPopupMenu *fPopup; ///< popup menu
92 TGRegionWithId(const TGRegion &reg, Int_t id);
93 ~TGRegionWithId() override;
95 Int_t GetId() const { return fId; }
96 TGToolTip *GetToolTipText() const { return fTip; }
97 void SetToolTipText(const char *text, Long_t delayms,
98 const TGFrame *frame);
99 TGPopupMenu *GetPopup() const { return fPopup; }
100 void SetPopup(TGPopupMenu *popup) { fPopup = popup; }
101 void DisplayPopup();
103 ClassDefOverride(TGRegionWithId,0) // Region with id, tooltip text and popup menu
111 TGImageMap(const TGImageMap&) = delete;
112 TGImageMap& operator=(const TGImageMap&) = delete;
118 TList *fListOfRegions; ///< list of regions
119 ENavMode fNavMode; ///< navigation mode
120 ECursor fCursorMouseOver; ///< cursor shape in regions
121 ECursor fCursorMouseOut; ///< cursor shape out of regions
122 Int_t fLastVisited; ///< id of the last visited region
123 TGToolTip *fMainTip; ///< tooltip text for main region
124 TList *fTrash; ///< collect all objects that need to be cleaned up
127 TGImageMap(const TGWindow *p = nullptr, const TGPicture *pic = nullptr);
128 TGImageMap(const TGWindow *p, const TString &pic);
129 ~TGImageMap() override;
131 Bool_t HandleButton(Event_t *event) override;
133 Bool_t HandleMotion(Event_t *event) override;
136 void AddRegion(const TGRegion &region, Int_t id);
140 void SetToolTipText(const char *text, Long_t delayms = 300) override;
141 void SetToolTipText(Int_t id, const char *text, Long_t delayms = 300);
143 void SetPicture(const TGPicture * /*new_pic*/) override { } // disabled
145 virtual void RegionClicked(Int_t id); // *SIGNAL*
146 virtual void DoubleClicked(Int_t id); // *SIGNAL*
147 virtual void DoubleClicked(); // *SIGNAL*
148 virtual void OnMouseOver(Int_t id); // *SIGNAL*
149 virtual void OnMouseOut(Int_t id); // *SIGNAL*
151 ClassDefOverride(TGImageMap,0) // Clickable image (like MAP in HTML)
#define R__EXTERN
Definition DllImport.h:27
Definition GuiTypes.h:372
@ kHand
Definition GuiTypes.h:374
#define h(i)
Definition RSha256.hxx:106
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Long_t
Definition RtypesCore.h:54
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
R__EXTERN TGRegionWithId * gCurrentRegion
Definition TGImageMap.h:154
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t cursor
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t points
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void reg
Option_t Option_t TPoint TPoint const char text
Array of shorts (16 bits per element).
Definition TArrayS.h:27
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition TGFrame.h:80
(with TGRegion and TGRegionWithId help classes)
Definition TGImageMap.h:107
ENavMode fNavMode
navigation mode
Definition TGImageMap.h:119
ENavMode GetNavMode()
Definition TGImageMap.h:135
void SetPicture(const TGPicture *) override
Change a picture in a picture button.
Definition TGImageMap.h:143
TGPopupMenu * GetPopup(Int_t id)
Return popup for regions with specified id.
Int_t fLastVisited
id of the last visited region
Definition TGImageMap.h:122
Bool_t HandleButton(Event_t *event) override
Handle button events.
virtual void OnMouseOut(Int_t id)
Handle when mouse moves from region id.
virtual void OnMouseOver(Int_t id)
Handle when mouse moves over region id.
TGToolTip * fMainTip
tooltip text for main region
Definition TGImageMap.h:123
TList * fTrash
collect all objects that need to be cleaned up
Definition TGImageMap.h:124
Bool_t HandleMotion(Event_t *event) override
Handle mouse motion events.
virtual void DoubleClicked()
Handle when mouse is double clicked on main map.
TGImageMap & operator=(const TGImageMap &)=delete
void AddRegion(const TGRegion &region, Int_t id)
Add a region to the image map.
TGPopupMenu * CreatePopup(Int_t id)
Create popup menu or returns existing for regions with specified id.
TList * fListOfRegions
list of regions
Definition TGImageMap.h:118
void SetCursor(ECursor cursor=kHand)
Definition TGImageMap.h:142
Bool_t HandleDoubleClick(Event_t *event) override
Handle double click events.
TGImageMap(const TGImageMap &)=delete
void SetToolTipText(const char *text, Long_t delayms=300) override
Set tooltip text for main region.
ECursor fCursorMouseOver
cursor shape in regions
Definition TGImageMap.h:120
virtual void RegionClicked(Int_t id)
Handle when mouse was clicked on region id.
~TGImageMap() override
Cleanup image map widget.
ECursor fCursorMouseOut
cursor shape out of regions
Definition TGImageMap.h:121
Yield an action as soon as it is clicked.
Definition TGButton.h:228
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
This class creates a popup menu object.
Definition TGMenu.h:110
void SetPopup(TGPopupMenu *popup)
Definition TGImageMap.h:100
~TGRegionWithId() override
TGPopupMenu * fPopup
popup menu
Definition TGImageMap.h:84
Int_t fId
region id
Definition TGImageMap.h:82
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:95
TGToolTip * fTip
Definition TGImageMap.h:83
void DisplayPopup()
Display popup menu associated with this region.
TGPopupMenu * GetPopup() const
Definition TGImageMap.h:99
Create GUI region (with id and possible tooltip).
TGToolTip * GetToolTipText() const
Definition TGImageMap.h:96
TGRegion & operator+=(const TGRegion &r)
Definition TGImageMap.h:63
TGRegion CopyRegion() const
Copy a region.
Bool_t IsEmpty() const
Return true if region is empty.
TGRegion & operator&=(const TGRegion &r)
Definition TGImageMap.h:64
TGDimension GetDimension() const
Return dimension of region (width, height).
TGRegion Unite(const TGRegion &r) const
Return the union of this region with r.
TGRegion operator^(const TGRegion &r) const
Definition TGImageMap.h:61
TGRegion & operator^=(const TGRegion &r)
Definition TGImageMap.h:66
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:60
TGRegion & operator|=(const TGRegion &r)
Definition TGImageMap.h:62
TGRegion operator&(const TGRegion &r) const
Definition TGImageMap.h:59
TGRegion operator|(const TGRegion &r) const
Definition TGImageMap.h:57
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.
~TGRegion() override
Delete a region.
TGRegionData * fData
Definition TGImageMap.h:30
Bool_t operator==(const TGRegion &r) const
Region == operator.
TGRegion operator+(const TGRegion &r) const
Definition TGImageMap.h:58
Bool_t operator!=(const TGRegion &r) const
Definition TGImageMap.h:68
TGRegion Subtract(const TGRegion &r) const
Returns a region which is r subtracted from this region.
TGRegion & operator-=(const TGRegion &r)
Definition TGImageMap.h:65
TGRegion Intersect(const TGRegion &r) const
Returns a region which is the intersection of this region and r.
Create a region object.
TGRegion & operator=(const TGRegion &r)
Region assignment operator.
A tooltip can be a one or multiple lines help text that is displayed in a window when the mouse curso...
Definition TGToolTip.h:24
ROOT GUI Window base class.
Definition TGWindow.h:23
A doubly linked list.
Definition TList.h:38
Mother of all ROOT objects.
Definition TObject.h:41
Basic string class.
Definition TString.h:139
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