2 // Category: interfaces
6 //========================================================
8 //------------TG4GUI.cxx--------------------------------//
9 //---------Main Window for the AG4 Geometry Browser---//
11 //=========================================================
14 #include "TG4Editor.h"
16 #include <TGListTree.h>
21 #include <TApplication.h>
23 #include <TGTextBuffer.h>
28 TG4GUI::TG4GUI(const TGWindow* p, UInt_t w, UInt_t h)
29 : TGMainFrame(p, w, h)
31 // Create a main frame
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);
37 fMenuFile = new TGPopupMenu(gClient->GetRoot());
38 fMenuFile->AddLabel("CloseWindow/Exit");
39 fMenuFile->AddEntry("&Close", 1);
40 fMenuFile->AddEntry("&Exit", 2);
42 fMenuTest = new TGPopupMenu(this);
43 fMenuTest->AddEntry("&Message", 3);
45 fMenuHelp = new TGPopupMenu(gClient->GetRoot());
46 fMenuHelp->AddEntry("&About", 4);
48 fMenuFile->Associate(this);
49 fMenuTest->Associate(this);
50 fMenuHelp->Associate(this);
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);
57 AddFrame(fMenuBar, fMenuBarLayout);
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);
67 //------>TGCanvas and a canvas container
68 fCanvasWindow = new TGCanvas(tf, 400, 240);
71 fLt = new TGListTree(fCanvasWindow->GetViewPort(), 10, 10, kHorizontalFrame,
74 fCanvasWindow->SetContainer(fLt);
77 TGLayoutHints *lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
78 tf->AddFrame(fCanvasWindow, lo);
80 //-----------------------------------------------------------------------------
82 //----->Window name and final mapping
84 SetWindowName("AG4 Geometry Browser");
97 // Delete created widgets.
101 delete fMenuBarLayout;
102 delete fMenuBarItemLayout;
103 delete fMenuBarHelpLayout;
111 TGListTreeItem* TG4GUI::
112 AddItem(TObject* obj, TGListTreeItem* parent, const char* name,
113 const TGPicture* open, const TGPicture* closed)
115 //----->Add item to the list tree
116 return fLt->AddItem(parent, name, obj, open, closed);
119 void TG4GUI::CloseWindow()
121 //----->Close the window & exit root
123 TGMainFrame::CloseWindow();
124 gApplication->Terminate(0);
127 Bool_t TG4GUI::ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
130 /*************************************************************/
134 EMsgBoxIcon icontype = kMBIconExclamation;
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!");
141 /*************************************************************/
143 //----->Editor window text
144 const char *editortxt =
145 "This is a to-be AG4 Geometry Browser. \n"
146 "The volumes drawing and materials coming soon.\n" ;
149 /***********************************************************/
151 //----->Process messages to widgets
152 switch (GET_MSG(msg)) {
154 //---->case Handle Popup menus
156 switch (GET_SUBMSG(msg)) {
161 printf("CLOSING MAIN WINDOW\n");
162 TGMainFrame::CloseWindow();
166 CloseWindow(); //-->and exit root
171 new TGMsgBox(fClient->GetRoot(), this,
172 fTbtitle->GetString(), fTbmsg->GetString(),
173 icontype, buttons, &retval);
179 TG4Editor *ed = new TG4Editor(this, 400, 150);
180 ed->LoadBuffer(editortxt);
192 //----->case Handle volumes listing
194 switch (GET_SUBMSG(msg)) {
196 //----->Cases to Handle mouse click
201 case kCT_ITEMDBLCLICK:
202 if (parm1 == kButton1) {
203 if (fLt->GetSelected() != 0) {
204 gClient->NeedRedraw(fLt);
208 //-->default for GET_SUBMSG
213 //---->default for GET_MSG