FSUDAQ/DAQ/startStopDialog.cpp

68 lines
2.3 KiB
C++
Raw Normal View History

#include "startStopDialog.h"
TString StartStopDialog::startComment = "";
TString StartStopDialog::stopComment = "";
bool StartStopDialog::isOK = false;
StartStopDialog::StartStopDialog(const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h, bool isStart){
this->isStart = isStart;
startComment = "";
stopComment = "";
fMain = new TGTransientFrame(p, main, w, h, kVerticalFrame);
fMain->DontCallClose(); /// to avoid double deletions.
//fMain->SetCleanup(kDeepCleanup); /// use hierarchical cleaning
fMain->Connect("CloseWindow()", "StartStopDialog", this, "CloseWindow()");
TGHorizontalFrame * fFrame1 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame1, new TGLayoutHints(kLHintsCenterX | kLHintsExpandX ));
txtComment = new TGTextEntry(fFrame1, ""); fFrame1->AddFrame(txtComment);
txtComment->Resize(300, 20);
txtComment->Connect("ReturnPressed()", "StartStopDialog", this, "DoOK()");
TGHorizontalFrame * fFrame2 = new TGHorizontalFrame(fMain); fMain->AddFrame(fFrame2,new TGLayoutHints(kLHintsCenterX | kLHintsExpandX));
TGTextButton * bOK = new TGTextButton(fFrame2, "OK"); fFrame2->AddFrame(bOK, new TGLayoutHints(kLHintsCenterX));
bOK->Connect("Clicked()", "StartStopDialog", this, "DoOK()");
TGTextButton * bCancel = new TGTextButton(fFrame2, "Cancel"); fFrame2->AddFrame(bCancel, new TGLayoutHints(kLHintsCenterX));
bCancel->Connect("Clicked()", "StartStopDialog", this, "DoClose()");
fMain->MapSubwindows();
fMain->Resize();
fMain->CenterOnParent(); /// position relative to the parent's window
if( isStart) {
fMain->SetWindowName("Start Comment");
}else{
fMain->SetWindowName("Stop Comment");
}
fMain->MapWindow();
gClient->WaitFor(fMain); /// make everything wait for it
}
StartStopDialog::~StartStopDialog(){
printf("-------- %s \n", __func__);
isOK = false;
delete txtComment;
fMain->DeleteWindow(); /// deletes fMain
}
void StartStopDialog::DoClose(){
isOK = false;
///Wait for 500 msec
TTimer::SingleShot(500, "StartStopDialog", this, "CloseWindow()");
}
void StartStopDialog::DoOK(){
if( isStart ) startComment = txtComment->GetText();
if( !isStart ) stopComment = txtComment->GetText();
isOK = true;
TTimer::SingleShot(500, "StartStopDialog", this, "CloseWindow()");
}