source: trunk/MagicSoft/Mars/mmain/MMars.cc@ 745

Last change on this file since 745 was 714, checked in by tbretz, 24 years ago
*** empty log message ***
File size: 6.1 KB
Line 
1#include "MMars.h"
2
3#include <TApplication.h> // gROOT->GetApplication()->...
4
5#include <TGTab.h> // TGTab
6#include <TGMenu.h> // TGPopupMenu
7#include <TGMsgBox.h> // TGMsgBox
8#include <TGButton.h> // TGPictureButton
9#include <TGSplitter.h> // TGHorizontal3DLine
10
11#include "MEvtDisp.h"
12#include "MDataCheck.h"
13#include "MMonteCarlo.h"
14
15#include "MGPrototyp.h"
16
17ClassImp(MMars)
18
19enum {
20 M_FILE_EXIT ,
21 M_FILE_ABOUT ,
22
23 M_PICTURE_MAGIC ,
24 M_PICTURE_MARS ,
25
26 M_BUTTON_EVTDISP ,
27 M_BUTTON_DATACHECK ,
28 M_BUTTON_ANALYSE ,
29 M_BUTTON_MONTECARLO
30} ;
31
32
33MMars::MMars(/*const TGWindow *p,*/ UInt_t w, UInt_t h)
34 : TGMainFrame(gClient->GetRoot(), w, h)
35{
36 // First create the MenuBar.
37
38 // Layout objects for menue.
39
40 fLayMenuBar = new TGLayoutHints ( kLHintsTop | kLHintsLeft | kLHintsExpandX, 2, 2, 2, 2 ) ;
41 fLayMenuItem = new TGLayoutHints ( kLHintsTop | kLHintsLeft , 0, 4, 0, 0 ) ;
42
43 // crate the menu bar
44
45 fFileMenu = new TGPopupMenu ( fClient->GetRoot() ) ;
46 fFileMenu->AddEntry ("Exit", M_FILE_EXIT ) ;
47 fFileMenu->Associate(this) ;
48
49 // the button messages are handled by main frame (this)
50
51 fMenuBar = new TGMenuBar ( this, 1, 1, kHorizontalFrame ) ;
52 fMenuBar->AddPopup("File", fFileMenu, fLayMenuItem ) ;
53 AddFrame(fMenuBar, fLayMenuBar ) ;
54
55 fLineSep = new TGHorizontal3DLine(this) ;
56 AddFrame(fLineSep, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
57
58 // set up the top part of the main window with the logos
59
60 fTop = new TGHorizontalFrame (this, 300, 100 ) ;
61
62 fPicMagic = new TGPictureButton(fTop,
63 gClient->GetPicture("magiclogo.xpm"), M_PICTURE_MAGIC );
64 fPicMagic->Associate(this) ;
65 fTop->AddFrame ( fPicMagic, new TGLayoutHints(kLHintsLeft, 10., 10., 20., 10.) ) ;
66
67 fPicMars = new TGPictureButton(fTop,
68 gClient->GetPicture("marslogo.xpm"), M_PICTURE_MARS );
69 fPicMars->Associate(this) ;
70 fTop->AddFrame ( fPicMars, new TGLayoutHints(kLHintsLeft, 10., 10., 10., 10.) ) ;
71
72 AddFrame(fTop, new TGLayoutHints(kLHintsTop | kLHintsExpandX ) );
73
74 // a seperator
75
76 fLineSep2 = new TGHorizontal3DLine(this) ;
77 AddFrame(fLineSep2, new TGLayoutHints(kLHintsTop | kLHintsExpandX) );
78
79 // the low part of the frame
80
81 fLow = new TGHorizontalFrame (this, 300, 100 ) ;
82
83 // create the first tab
84
85 fTab = new TGTab ( fLow, 400, 400 ) ;
86
87 TGCompositeFrame *tf = fTab->AddTab("Control") ;
88
89 fTabF1 = new TGVerticalFrame (tf, 300, 100) ;
90
91 tf->AddFrame(fTabF1, new TGLayoutHints(kLHintsTop | kLHintsExpandX) ) ;
92
93 // the buttons to go in the new window
94
95 fTabF2 = new TGVerticalFrame (tf, 300, 100) ;
96
97 fButLayout = new TGLayoutHints(kLHintsTop | kLHintsCenterX , 10, 10, 10, 10) ;
98
99 fButEvtDisp = new TGTextButton(fTabF2, "EventDisplay", M_BUTTON_EVTDISP );
100 fButEvtDisp->Associate(this) ;
101 fTabF2->AddFrame(fButEvtDisp, fButLayout ) ;
102
103 fButDataCheck = new TGTextButton(fTabF2, "Data Check", M_BUTTON_DATACHECK );
104 fButDataCheck->Associate(this) ;
105 fTabF2->AddFrame(fButDataCheck, fButLayout ) ;
106
107 fButAnalys = new TGTextButton(fTabF2, "Analysis", M_BUTTON_ANALYSE );
108 fButAnalys->Associate(this) ;
109 fTabF2->AddFrame(fButAnalys, fButLayout ) ;
110
111 fButMonteCarlo = new TGTextButton(fTabF2, "MonteCarlo", M_BUTTON_MONTECARLO );
112 fButMonteCarlo->Associate(this) ;
113 fTabF2->AddFrame(fButMonteCarlo, fButLayout ) ;
114
115
116
117
118 tf->AddFrame(fTabF2, new TGLayoutHints(kLHintsTop | kLHintsExpandX) ) ;
119
120
121
122 fLow->AddFrame ( fTab, new TGLayoutHints(kLHintsBottom | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5) );
123 AddFrame(fLow, new TGLayoutHints(kLHintsTop | kLHintsExpandX ) );
124
125 // Map the window, set up the layout, etc.
126
127 SetWMSizeHints(400, 650, 1000, 1000, 10, 10 ) ; // set the smallest and biggest size of the Main frame
128
129 MapSubwindows();
130
131 Layout();
132
133 SetWindowName("MARS Main Window");
134 SetIconName("MARS");
135
136 MapWindow();
137
138}
139
140// ======================================================================
141
142MMars::~MMars()
143{
144
145 delete fButLayout;
146 delete fLayMenuBar;
147 delete fLayMenuItem;
148 delete fButEvtDisp;
149 delete fButDataCheck;
150 delete fButAnalys;
151 delete fButMonteCarlo;
152 delete fPicMagic;
153 delete fPicMars;
154 delete fTabF1;
155 delete fTabF2;
156 delete fTab;
157 delete fLow;
158 delete fTop;
159 delete fLineSep2;
160 delete fLineSep;
161 delete fFileMenu;
162 delete fMenuBar;
163}
164// ======================================================================
165
166void MMars::CloseWindow()
167{
168 // Got close message for this MainFrame. Calls parent CloseWindow()
169 // (which destroys the window) and terminate the application.
170 // The close message is generated by the window manager when its close
171 // window menu item is selected.
172
173 TGMainFrame::CloseWindow();
174 gROOT->GetApplication()->Terminate(0) ;
175}
176
177void MMars::DisplWarning(const char *txt)
178{
179 Int_t retval;
180 new TGMsgBox(fClient->GetRoot(), this,
181 "WARNING!", txt,
182 kMBIconExclamation, 4, &retval);
183}
184
185Bool_t MMars::ProcessMessage(Long_t msg, Long_t parm1, Long_t)
186{
187 // Process events generated by the buttons in the frame.
188
189 switch (GET_MSG(msg))
190 {
191 case kC_COMMAND:
192 switch (GET_SUBMSG(msg))
193 {
194 case kCM_BUTTON:
195
196 switch (parm1)
197 {
198
199 case M_BUTTON_EVTDISP:
200 new MEvtDisp(this);
201 return kTRUE;
202
203 case M_BUTTON_DATACHECK:
204 new MDataCheck(this);
205 return kTRUE;
206
207 case M_BUTTON_ANALYSE:
208 DisplWarning("Analysis not yet implemented!");
209 return kTRUE;
210
211 case M_BUTTON_MONTECARLO:
212 new MMonteCarlo(this);
213 return kTRUE;
214
215 case M_PICTURE_MAGIC:
216 DisplWarning("Please open a Netscape to the MAGIC homepage");
217 return kTRUE;
218
219 case M_PICTURE_MARS:
220 DisplWarning("Please open a Netscape to the MARS homepage");
221 return kTRUE;
222
223 }
224
225 case kCM_MENU:
226 if (parm1!=M_FILE_EXIT)
227 return kTRUE;
228
229 CloseWindow() ;
230 return kTRUE;
231 }
232 }
233
234 return kTRUE;
235}
Note: See TracBrowser for help on using the repository browser.