Logo ROOT  
Reference Guide
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-2000, 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
87 TGRegionWithId& operator=(const TGRegionWithId&); // Not implemented
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&); // Not implemented
120 TGImageMap& operator=(const TGImageMap&); // Not implemented
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 = 0, const TGPicture *pic = 0);
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:371
@ kHand
Definition: GuiTypes.h:373
ROOT::R::TRInterface & r
Definition: Object.C:4
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:43
unsigned int UInt_t
Definition: RtypesCore.h:44
const Bool_t kFALSE
Definition: RtypesCore.h:90
long Long_t
Definition: RtypesCore.h:52
bool Bool_t
Definition: RtypesCore.h:61
#define ClassDef(name, id)
Definition: Rtypes.h:322
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.
Definition: TGImageMap.cxx:613
virtual ~TGImageMap()
Cleanup image map widget.
Definition: TGImageMap.cxx:464
ENavMode fNavMode
Definition: TGImageMap.h:127
ENavMode GetNavMode()
Definition: TGImageMap.h:143
TGPopupMenu * GetPopup(Int_t id)
Return popup for regions with specified id.
Definition: TGImageMap.cxx:507
Int_t fLastVisited
Definition: TGImageMap.h:130
virtual void OnMouseOut(Int_t id)
Handle when mouse moves from region id.
Definition: TGImageMap.cxx:652
virtual Bool_t HandleMotion(Event_t *event)
Handle mouse motion events.
Definition: TGImageMap.cxx:521
virtual void OnMouseOver(Int_t id)
Handle when mouse moves over region id.
Definition: TGImageMap.cxx:640
TGToolTip * fMainTip
Definition: TGImageMap.h:131
TList * fTrash
Definition: TGImageMap.h:132
virtual void DoubleClicked()
Handle when mouse is double clicked on main map.
Definition: TGImageMap.cxx:673
virtual Bool_t HandleButton(Event_t *event)
Handle button events.
Definition: TGImageMap.cxx:579
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.
Definition: TGImageMap.cxx:476
TGImageMap(const TGImageMap &)
TGPopupMenu * CreatePopup(Int_t id)
Create popoup menu or returns existing for regions with specified id.
Definition: TGImageMap.cxx:484
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.
Definition: TGImageMap.cxx:553
ECursor fCursorMouseOver
Definition: TGImageMap.h:128
virtual void RegionClicked(Int_t id)
Handle when mouse was clicked on region id.
Definition: TGImageMap.cxx:664
ECursor fCursorMouseOut
Definition: TGImageMap.h:129
TGImageMap & operator=(const TGImageMap &)
TGRegionWithId & operator=(const TGRegionWithId &)
void SetPopup(TGPopupMenu *popup)
Definition: TGImageMap.h:108
TGPopupMenu * fPopup
Definition: TGImageMap.h:92
void SetToolTipText(const char *text, Long_t delayms, const TGFrame *frame)
Set tool tip text associated with this region.
Definition: TGImageMap.cxx:396
Int_t GetId() const
Definition: TGImageMap.h:103
TGToolTip * fTip
Definition: TGImageMap.h:91
void DisplayPopup()
Display popup menu associated with this region.
Definition: TGImageMap.cxx:386
TGPopupMenu * GetPopup() const
Definition: TGImageMap.h:107
virtual ~TGRegionWithId()
Cleanup.
Definition: TGImageMap.cxx:378
TGRegionWithId()
Create GUI region (with id and possible tooltip).
Definition: TGImageMap.cxx:323
TGToolTip * GetToolTipText() const
Definition: TGImageMap.h:104
TGRegion & operator+=(const TGRegion &r)
Definition: TGImageMap.h:71
TGRegion CopyRegion() const
Copy a region.
Definition: TGImageMap.cxx:209
Bool_t IsEmpty() const
Return true if region is empty.
Definition: TGImageMap.cxx:227
TGRegion & operator&=(const TGRegion &r)
Definition: TGImageMap.h:72
@ kRectangle
Definition: TGImageMap.h:44
@ kEllipse
Definition: TGImageMap.h:44
virtual ~TGRegion()
Delete a region.
Definition: TGImageMap.cxx:180
TGDimension GetDimension() const
Return dimension of region (widht, height).
Definition: TGImageMap.cxx:292
TGRegion Unite(const TGRegion &r) const
Return the union of this region with r.
Definition: TGImageMap.cxx:251
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.
Definition: TGImageMap.cxx:235
Bool_t IsNull() const
Return true if region is not set.
Definition: TGImageMap.cxx:219
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).
Definition: TGImageMap.cxx:302
TGRegion Eor(const TGRegion &r) const
Returns a region which is the difference between the union and intersection this region and r.
Definition: TGImageMap.cxx:282
TGRegionData * fData
Definition: TGImageMap.h:38
Bool_t operator==(const TGRegion &r) const
Region == operator.
Definition: TGImageMap.cxx:312
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.
Definition: TGImageMap.cxx:271
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.
Definition: TGImageMap.cxx:261
TGRegion()
Create a region object.
Definition: TGImageMap.cxx:75
TGRegion & operator=(const TGRegion &r)
Region assignment operator.
Definition: TGImageMap.cxx:191
A doubly linked list.
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
Definition: TPoint.h:31
Basic string class.
Definition: TString.h:131
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