Small fix (Mikolaj)
[u/mrichter/AliRoot.git] / MONITOR / AliMonitorDialog.cxx
CommitLineData
04fa961a 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"
7ba8900c 26#include "AliLog.h"
c4bd737c 27#include <TGFrame.h>
28#include <TGButton.h>
04fa961a 29
30
31ClassImp(AliMonitorDialog)
32
33
34//_____________________________________________________________________________
35AliMonitorDialog::AliMonitorDialog(TGFrame* main, Int_t width, Int_t height,
17c3cc9e 36 Bool_t cancelBtn) :
37 TObject(),
38 fQObject(),
39 fMain(new TGTransientFrame(gClient->GetRoot(), main, width, height)),
40 fFrameLayout(new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 2, 2, 2)),
41 fFrame(new TGHorizontalFrame(fMain, 0, 0)),
42 fButtonFrameLayout(new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 2, 2, 2, 2)),
43 fButtonFrame(new TGHorizontalFrame(fMain, 0, 0)),
44 fButtonLayout(new TGLayoutHints(kLHintsCenterX | kLHintsCenterY, 15, 15, 2, 2)),
45 fOkButton(new TGTextButton(fButtonFrame, " &Ok ", 1)),
46 fCancelButton(NULL)
04fa961a 47{
48// create a dialog with an ok and a cancel button
49
04fa961a 50 fMain->AddFrame(fFrame, fFrameLayout);
51
04fa961a 52 fMain->AddFrame(fButtonFrame, fButtonFrameLayout);
53
04fa961a 54 fButtonFrame->AddFrame(fOkButton, fButtonLayout);
55 fOkButton->Connect("Clicked()", "AliMonitorDialog", this, "DoOk()");
56 if (cancelBtn) {
57 fCancelButton = new TGTextButton(fButtonFrame, " &Cancel ", 2);
58 fButtonFrame->AddFrame(fCancelButton, fButtonLayout);
59 fCancelButton->Connect("Clicked()", "AliMonitorDialog", this,
60 "DoCancel()");
04fa961a 61 }
62
63 fMain->Connect("CloseWindow()", "AliMonitorDialog", this, "CloseWindow()");
64 Int_t x;
65 Int_t y;
66 Window_t child;
67 gVirtualX->TranslateCoordinates(main->GetId(), gClient->GetRoot()->GetId(),
68 (main->GetWidth() - width) >> 1,
69 (main->GetHeight() - height) >> 1,
70 x, y, child);
71 if (x < 0) x = 0;
72 if (y < 0) y = 0;
73 fMain->Move(x, y);
74 fMain->SetWMPosition(x, y);
75 fMain->SetWMSize(width, height);
76 fMain->SetWMSizeHints(width, height, width, height, 0, 0);
77 fMain->MapSubwindows();
78 fMain->Layout();
79 fMain->MapWindow();
80}
81
82//_____________________________________________________________________________
83AliMonitorDialog::~AliMonitorDialog()
84{
85// clean up
86
87 delete fOkButton;
88 delete fCancelButton;
89 delete fButtonLayout;
90 delete fButtonFrame;
91 delete fButtonFrameLayout;
92 delete fFrame;
93 delete fFrameLayout;
94
95 delete fMain;
96}
97
98//_____________________________________________________________________________
c4bd737c 99void AliMonitorDialog::CloseWindow() const
04fa961a 100{
101// called when the window is closed
102
103 delete this;
104}
105
106//_____________________________________________________________________________
107void AliMonitorDialog::DoOk()
108{
109// called when the ok button is clicked
110
111 OnOkClicked();
112 fMain->SendCloseMessage();
113}
114
115//_____________________________________________________________________________
116void AliMonitorDialog::DoCancel()
117{
118// called when the cancel button is clicked
119
120 OnCancelClicked();
121 fMain->SendCloseMessage();
122}