18 namespace GUITutorials {
24 TGImageMap* fImageMap;
26 virtual void InitMap();
27 virtual void InitRU();
28 virtual void InitUS();
30 virtual void InitAU();
31 virtual void InitFR();
32 virtual void InitUK();
40 kRU = 7, kUS = 1, kFR = 33, kDE = 49, kCH = 41, kCN = 86, kAU = 61,
41 kUK = 44, kUA = 380, kBR = 55
44 WorldMap(
const char *picName =
"worldmap.jpg");
45 virtual ~WorldMap() {}
47 virtual void Show() { fMain->MapRaised(); }
48 TGImageMap* GetImageMap()
const {
return fImageMap; }
49 virtual TString GetTitle()
const;
52 void PrintCode(Int_t code);
57 WorldMap::WorldMap(
const char* picName)
61 fMain =
new TGMainFrame(gClient->GetRoot(), 750, 420);
63 fImageMap =
new TGImageMap(fMain, picName);
64 fMain->AddFrame(fImageMap);
65 fMain->SetWindowName(GetTitle().Data());
66 fMain->SetIconName(
"World Map");
68 TGDimension size = fMain->GetDefaultSize();
70 fMain->MapSubwindows();
73 fImageMap->Connect(
"RegionClicked(Int_t)",
"ROOT::GUITutorials::WorldMap",
74 this,
"PrintCode(Int_t)");
78 TString WorldMap::GetTitle()
const
82 return "Country Code (left button). City/Area Codes (right button)";
86 void WorldMap::InitRU()
90 int x[12] = { 403, 406, 427, 444, 438, 470, 508, 568, 599, 632, 645, 493 };
91 int y[12] = { 68, 90, 120, 125, 109, 94, 109, 101, 122, 107, 74, 46 };
92 TGRegion reg(12, x, y);
93 fImageMap->AddRegion(reg, kRU);
94 fImageMap->SetToolTipText(kRU,
"Russia");
95 TGPopupMenu* pm = fImageMap->CreatePopup(kRU);
96 pm->AddLabel(
"City Codes");
98 pm->AddEntry(
"Moscow = 095", 95);
99 pm->AddEntry(
"Protvino = 0967", 967);
100 pm->AddEntry(
"St.Petersburg = 812", 812);
104 void WorldMap::InitUS()
108 int x[5] = { 136, 122, 165, 194, 232 };
109 int y[5] = { 110, 141, 158, 160, 118 };
110 TGRegion reg(5, x, y);
111 fImageMap->AddRegion(reg, kUS);
113 int alaskaX[4] = { 86, 131, 154, 117 };
114 int alaskaY[4] = { 90, 82, 64, 63 };
115 TGRegion alaska(4, alaskaX, alaskaY);
116 fImageMap->AddRegion(alaska, kUS);
117 fImageMap->SetToolTipText(kUS,
"USA");
119 TGPopupMenu* pm = fImageMap->CreatePopup(kUS);
120 pm->AddLabel(
"Area Codes");
122 pm->AddEntry(
"Illinois = 217", 217);
123 pm->AddEntry(
"New York = 212", 212);
127 void WorldMap::InitFR()
131 int x[5] = { 349, 353, 368, 368, 358 };
132 int y[5] = { 112, 123, 119, 108, 107 };
133 TGRegion reg(5, x, y);
134 fImageMap->AddRegion(reg, kFR);
135 fImageMap->SetToolTipText(kFR,
"France");
139 void WorldMap::InitUK()
143 int x[4] = { 346, 348, 359, 352 };
144 int y[4] = { 93, 104, 103, 87 };
145 TGRegion reg(4, x, y);
146 fImageMap->AddRegion(reg, kUK);
147 fImageMap->SetToolTipText(kUK,
"United Kingdom");
151 void WorldMap::InitAU()
155 int x[6] = { 582, 576, 634, 658, 641, 607 };
156 int y[6] = { 271, 300, 310, 283, 251, 253 };
157 TGRegion reg(6, x, y);
158 fImageMap->AddRegion(reg, kAU);
159 fImageMap->SetToolTipText(kAU,
"Australia");
163 void WorldMap::InitMap()
172 fImageMap->SetToolTipText(GetTitle().Data(), 300);
176 void WorldMap::PrintCode(Int_t code)
180 EMsgBoxIcon icontype = kMBIconAsterisk;
184 new TGMsgBox(gClient->GetRoot(), fMain,
185 "Country Code", Form(
"Country Code=%d",code),
186 icontype, buttons, &retval);
194 namespace GUI = ROOT::GUITutorials;
195 GUI::WorldMap *map =
new GUI::WorldMap;