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