]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MONITOR/AliMonitorDialog.cxx
(martin) pt vs eta correction matrix calculation macro using CorrectionMatrix2D class.
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorDialog.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 //  This is a base class for dialogs with ok and cancel button               //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24
25 #include "AliMonitorDialog.h"
26 #include "AliLog.h"
27 #include <TGFrame.h>
28 #include <TGButton.h>
29
30
31 ClassImp(AliMonitorDialog) 
32
33
34 //_____________________________________________________________________________
35 AliMonitorDialog::AliMonitorDialog(TGFrame* main, Int_t width, Int_t height,
36                                    Bool_t cancelBtn)
37 {
38 // create a dialog with an ok and a cancel button
39
40   fMain = new TGTransientFrame(gClient->GetRoot(), main, width, height);
41
42   fFrameLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
43                                    2, 2, 2, 2);
44   fFrame = new TGHorizontalFrame(fMain, 0, 0);
45   fMain->AddFrame(fFrame, fFrameLayout);
46
47   fButtonFrameLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 
48                                          2, 2, 2, 2);
49   fButtonFrame = new TGHorizontalFrame(fMain, 0, 0);
50   fMain->AddFrame(fButtonFrame, fButtonFrameLayout);
51
52   fButtonLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 
53                                     15, 15, 2, 2);
54   fOkButton = new TGTextButton(fButtonFrame, "    &Ok    ", 1);
55   fButtonFrame->AddFrame(fOkButton, fButtonLayout);
56   fOkButton->Connect("Clicked()", "AliMonitorDialog", this, "DoOk()");
57   if (cancelBtn) {
58     fCancelButton = new TGTextButton(fButtonFrame, " &Cancel ", 2);
59     fButtonFrame->AddFrame(fCancelButton, fButtonLayout);
60     fCancelButton->Connect("Clicked()", "AliMonitorDialog", this, 
61                            "DoCancel()");
62   } else {
63     fCancelButton = NULL;
64   }
65
66   fMain->Connect("CloseWindow()", "AliMonitorDialog", this, "CloseWindow()");
67   Int_t x;
68   Int_t y;
69   Window_t child;
70   gVirtualX->TranslateCoordinates(main->GetId(), gClient->GetRoot()->GetId(),
71                                   (main->GetWidth() - width) >> 1,
72                                   (main->GetHeight() - height) >> 1, 
73                                   x, y, child);
74   if (x < 0) x = 0;
75   if (y < 0) y = 0;
76   fMain->Move(x, y);
77   fMain->SetWMPosition(x, y);
78   fMain->SetWMSize(width, height);
79   fMain->SetWMSizeHints(width, height, width, height, 0, 0);
80   fMain->MapSubwindows();
81   fMain->Layout();
82   fMain->MapWindow();
83 }
84
85 //_____________________________________________________________________________
86 AliMonitorDialog::AliMonitorDialog(const AliMonitorDialog& dlg) :
87   TObject(dlg)
88 {
89   AliFatal("copy constructor not implemented");
90 }
91
92 //_____________________________________________________________________________
93 AliMonitorDialog& AliMonitorDialog::operator = (const AliMonitorDialog& 
94                                                 /*dlg*/)
95 {
96   AliFatal("assignment operator not implemented");
97   return *this;
98 }
99
100 //_____________________________________________________________________________
101 AliMonitorDialog::~AliMonitorDialog()
102 {
103 // clean up
104
105   delete fOkButton;
106   delete fCancelButton;
107   delete fButtonLayout;
108   delete fButtonFrame;
109   delete fButtonFrameLayout;
110   delete fFrame;
111   delete fFrameLayout;
112
113   delete fMain;
114 }
115
116 //_____________________________________________________________________________
117 void AliMonitorDialog::CloseWindow() const
118 {
119 // called when the window is closed
120
121   delete this;
122 }
123
124 //_____________________________________________________________________________
125 void AliMonitorDialog::DoOk()
126 {
127 // called when the ok button is clicked
128
129   OnOkClicked();
130   fMain->SendCloseMessage();
131 }
132
133 //_____________________________________________________________________________
134 void AliMonitorDialog::DoCancel()
135 {
136 // called when the cancel button is clicked
137
138   OnCancelClicked();
139   fMain->SendCloseMessage();
140 }