corrections to obey coding conventions
[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"
c4bd737c 26#include <TGFrame.h>
27#include <TGButton.h>
04fa961a 28
29
30ClassImp(AliMonitorDialog)
31
32
33//_____________________________________________________________________________
34AliMonitorDialog::AliMonitorDialog(TGFrame* main, Int_t width, Int_t height,
35 Bool_t cancelBtn)
36{
37// create a dialog with an ok and a cancel button
38
39 fMain = new TGTransientFrame(gClient->GetRoot(), main, width, height);
40
41 fFrameLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
42 2, 2, 2, 2);
43 fFrame = new TGHorizontalFrame(fMain, 0, 0);
44 fMain->AddFrame(fFrame, fFrameLayout);
45
46 fButtonFrameLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
47 2, 2, 2, 2);
48 fButtonFrame = new TGHorizontalFrame(fMain, 0, 0);
49 fMain->AddFrame(fButtonFrame, fButtonFrameLayout);
50
51 fButtonLayout = new TGLayoutHints(kLHintsCenterX | kLHintsCenterY,
52 15, 15, 2, 2);
53 fOkButton = new TGTextButton(fButtonFrame, " &Ok ", 1);
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()");
61 } else {
62 fCancelButton = NULL;
63 }
64
65 fMain->Connect("CloseWindow()", "AliMonitorDialog", this, "CloseWindow()");
66 Int_t x;
67 Int_t y;
68 Window_t child;
69 gVirtualX->TranslateCoordinates(main->GetId(), gClient->GetRoot()->GetId(),
70 (main->GetWidth() - width) >> 1,
71 (main->GetHeight() - height) >> 1,
72 x, y, child);
73 if (x < 0) x = 0;
74 if (y < 0) y = 0;
75 fMain->Move(x, y);
76 fMain->SetWMPosition(x, y);
77 fMain->SetWMSize(width, height);
78 fMain->SetWMSizeHints(width, height, width, height, 0, 0);
79 fMain->MapSubwindows();
80 fMain->Layout();
81 fMain->MapWindow();
82}
83
c4bd737c 84//_____________________________________________________________________________
85AliMonitorDialog::AliMonitorDialog(const AliMonitorDialog& dlg) :
86 TObject(dlg)
87{
88 Fatal("AliMonitorDialog", "copy constructor not implemented");
89}
90
91//_____________________________________________________________________________
92AliMonitorDialog& AliMonitorDialog::operator = (const AliMonitorDialog&
93 /*dlg*/)
94{
95 Fatal("operator =", "assignment operator not implemented");
96 return *this;
97}
98
04fa961a 99//_____________________________________________________________________________
100AliMonitorDialog::~AliMonitorDialog()
101{
102// clean up
103
104 delete fOkButton;
105 delete fCancelButton;
106 delete fButtonLayout;
107 delete fButtonFrame;
108 delete fButtonFrameLayout;
109 delete fFrame;
110 delete fFrameLayout;
111
112 delete fMain;
113}
114
115//_____________________________________________________________________________
c4bd737c 116void AliMonitorDialog::CloseWindow() const
04fa961a 117{
118// called when the window is closed
119
120 delete this;
121}
122
123//_____________________________________________________________________________
124void AliMonitorDialog::DoOk()
125{
126// called when the ok button is clicked
127
128 OnOkClicked();
129 fMain->SendCloseMessage();
130}
131
132//_____________________________________________________________________________
133void AliMonitorDialog::DoCancel()
134{
135// called when the cancel button is clicked
136
137 OnCancelClicked();
138 fMain->SendCloseMessage();
139}