]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TGeant4/TG4GUI.cxx
updated to renaming in global category
[u/mrichter/AliRoot.git] / TGeant4 / TG4GUI.cxx
CommitLineData
b8c9c0a3 1// $Id$
2// Category: interfaces
3//
4// Author: D. Adamova
5//
6//========================================================
7//
8//------------TG4GUI.cxx--------------------------------//
9//---------Main Window for the AG4 Geometry Browser---//
10//
11//=========================================================
12
13#include "TG4GUI.h"
14#include "TG4Editor.h"
15
16#include <TGListTree.h>
17#include <TGCanvas.h>
18#include <TGTab.h>
19#include <TGMenu.h>
20#include <TGCanvas.h>
21#include <TApplication.h>
22#include <TGMsgBox.h>
23#include <TGTextBuffer.h>
24
25
26ClassImp(TG4GUI)
27
28TG4GUI::TG4GUI(const TGWindow* p, UInt_t w, UInt_t h)
29 : TGMainFrame(p, w, h)
30{
31 // Create a main frame
32
33 fMenuBarLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1);
34 fMenuBarItemLayout = new TGLayoutHints(kLHintsTop | kLHintsLeft, 0, 4, 0, 0);
35 fMenuBarHelpLayout = new TGLayoutHints(kLHintsTop | kLHintsRight);
36
37 fMenuFile = new TGPopupMenu(gClient->GetRoot());
38 fMenuFile->AddLabel("CloseWindow/Exit");
39 fMenuFile->AddEntry("&Close", 1);
40 fMenuFile->AddEntry("&Exit", 2);
41
42 fMenuTest = new TGPopupMenu(this);
43 fMenuTest->AddEntry("&Message", 3);
44
45 fMenuHelp = new TGPopupMenu(gClient->GetRoot());
46 fMenuHelp->AddEntry("&About", 4);
47
48 fMenuFile->Associate(this);
49 fMenuTest->Associate(this);
50 fMenuHelp->Associate(this);
51
52 fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
53 fMenuBar->AddPopup("&Quit??", fMenuFile, fMenuBarItemLayout);
54 fMenuBar->AddPopup("&Draw Control", fMenuTest, fMenuBarItemLayout);
55 fMenuBar->AddPopup("&Report", fMenuHelp, fMenuBarHelpLayout);
56
57 AddFrame(fMenuBar, fMenuBarLayout);
58
59//------>Volumes
60
61 fTab = new TGTab(this, 400, 400);
62 TGCompositeFrame *tf = fTab->AddTab("Volumes");
63 TGLayoutHints *lTab = new TGLayoutHints(kLHintsBottom | kLHintsExpandX |
64 kLHintsExpandY, 2, 2, 5, 1);
65 AddFrame(fTab, lTab);
66
67//------>TGCanvas and a canvas container
68 fCanvasWindow = new TGCanvas(tf, 400, 240);
69
70//----->List
71 fLt = new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame,
72 fgWhitePixel);
73 fLt->Associate(this);
74 fCanvasWindow->SetContainer(fLt);
75
76
77 TGLayoutHints *lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
78 tf->AddFrame(fCanvasWindow, lo);
79
80//-----------------------------------------------------------------------------
81
82//----->Window name and final mapping
83
84 SetWindowName("AG4 Geometry Browser");
85 MapSubwindows();
86
87
88 Layout();
89 MapWindow();
90
91
92}
93
94TG4GUI::~TG4GUI()
95{
96
97 // Delete created widgets.
98
99 delete fCanvasWindow;
100
101 delete fMenuBarLayout;
102 delete fMenuBarItemLayout;
103 delete fMenuBarHelpLayout;
104
105 delete fMenuFile;
106 delete fMenuTest;
107 delete fMenuHelp;
108
109}
110
111TGListTreeItem* TG4GUI::
112AddItem(TObject* obj, TGListTreeItem* parent, const char* name,
113 const TGPicture* open, const TGPicture* closed)
114{
115//----->Add item to the list tree
116 return fLt->AddItem(parent, name, obj, open, closed);
117}
118
119void TG4GUI::CloseWindow()
120{
121 //----->Close the window & exit root
122
123 TGMainFrame::CloseWindow();
124 gApplication->Terminate(0);
125}
126
127Bool_t TG4GUI::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
128{
129
130/*************************************************************/
131//----->Message Box
132
133 int retval;
134 EMsgBoxIcon icontype = kMBIconExclamation;
135 int buttons = kMBOk;
136 TGTextBuffer* fTbtitle = new TGTextBuffer(100);
137 TGTextBuffer* fTbmsg = new TGTextBuffer(100);
138 fTbtitle->AddText(0, "MsgBox");
139 fTbmsg->AddText(0, "Volumes drawing & materials coming soon!");
140
141/*************************************************************/
142
143//----->Editor window text
144const char *editortxt =
145"This is a to-be AG4 Geometry Browser. \n"
146"The volumes drawing and materials coming soon.\n" ;
147
148
149/***********************************************************/
150
151//----->Process messages to widgets
152 switch (GET_MSG(msg)) {
153
154//---->case Handle Popup menus
155 case kC_COMMAND:
156 switch (GET_SUBMSG(msg)) {
157 case kCM_MENU:
158 switch (parm1) {
159
160 case 1:
161 printf("CLOSING MAIN WINDOW\n");
162 TGMainFrame::CloseWindow();
163 break;
164
165 case 2:
166 CloseWindow(); //-->and exit root
167 break;
168
169 case 3:
170 //-->popup Message
171 new TGMsgBox(fClient->GetRoot(), this,
172 fTbtitle->GetString(), fTbmsg->GetString(),
173 icontype, buttons, &retval);
174 break;
175
176 case 4:
177 //-->editor window
178 {
179 TG4Editor *ed = new TG4Editor(this, 400, 150);
180 ed->LoadBuffer(editortxt);
181 ed->Popup();
182 };
183
184 default:
185 break;
186 }
187 default:
188 break;
189 }
190 break;
191
192//----->case Handle volumes listing
193 case kC_LISTTREE:
194 switch (GET_SUBMSG(msg)) {
195
196//----->Cases to Handle mouse click
197 //-->case 1
198 case kCT_ITEMCLICK:
199 break;
200 //-->case 2
201 case kCT_ITEMDBLCLICK:
202 if (parm1 == kButton1) {
203 if (fLt->GetSelected() != 0) {
204 gClient->NeedRedraw(fLt);
205 }
206 }
207 break;
208 //-->default for GET_SUBMSG
209 default:
210 break;
211 }
212 break;
213//---->default for GET_MSG
214 default:
215 break;
216 }
217 return kTRUE;
218}