added a feature which brings up a error message box, if there was any issue with the msr-file when starting musrview from musredit.

This commit is contained in:
2025-06-29 09:04:45 +02:00
parent 4da145d674
commit b692b78cac
9 changed files with 451 additions and 138 deletions

78
src/classes/PMsgBox.cpp Normal file
View File

@@ -0,0 +1,78 @@
/***************************************************************************
PMsgBox.cpp
Author: Andreas Suter
e-mail: andreas.suter@psi.ch
***************************************************************************/
/***************************************************************************
* Copyright (C) 2007-2025 by Andreas Suter *
* andreas.suter@psi.ch *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "PMsgBox.h"
PMsgBox::PMsgBox(const std::string errMsg, const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h)
{
fListBox = new TGListBox(this, 89);
// feed list box with errMsg
size_t start = 0;
size_t end = errMsg.find("\n");
unsigned int i=1;
std::string tok{""};
fListBox->AddEntry(tok.c_str(), i++);
while (end != std::string::npos) {
tok = errMsg.substr(start, end - start);
start = end + 1;
end = errMsg.find("\n", start);
fListBox->AddEntry(tok.c_str(), i++);
}
fListBox->Resize(600, 200);
AddFrame(fListBox, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
// Create a horizontal frame containing button(s)
TGHorizontalFrame *hframe = new TGHorizontalFrame(this, 150, 20, kFixedWidth);
TGTextButton *exit = new TGTextButton(hframe, "&Exit ");
exit->Connect("Pressed()", "PMsgBox", this, "DoExit()");
hframe->AddFrame(exit, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
AddFrame(hframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
// Set a name to the main frame
SetWindowName("Error Message");
MapSubwindows();
// Initialize the layout algorithm via Resize()
Resize(GetDefaultSize());
// Map main frame
MapWindow();
}
PMsgBox::~PMsgBox()
{
// nothing to be done here?
}
void PMsgBox::DoExit()
{
gApplication->Terminate(0);
}