Files
musrfit/src/include/PMsgBox.h

108 lines
4.1 KiB
C++

/***************************************************************************
PMsgBox.h
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. *
***************************************************************************/
#ifndef _PMSGBOX_H_
#define _PMSGBOX_H_
#include <string>
#include <TApplication.h>
#include <TGClient.h>
#include <TGButton.h>
#include <TGListBox.h>
#include <TList.h>
//--------------------------------------------------------------------------
/**
* \brief GUI message box for displaying error messages and warnings.
*
* PMsgBox is a ROOT-based GUI window that displays multi-line error messages
* in a scrollable list box. It provides a simple, modal-like interface for
* showing diagnostic information to the user.
*
* The message box:
* - Parses multi-line error messages (separated by newline characters)
* - Displays each line in a scrollable list box
* - Provides an Exit button that terminates the application
* - Uses ROOT's TGMainFrame for window management
*
* Typical use case:
* \code
* std::string errorMsg = "Error parsing file:\nLine 42: Invalid syntax\nAborting...";
* PMsgBox msgBox(errorMsg, gClient->GetRoot(), 640, 240);
* \endcode
*
* \see TGMainFrame for the base class
*/
class PMsgBox : public TGMainFrame {
private:
TGListBox *fListBox; ///< List box widget displaying error message lines
public:
//-----------------------------------------------------------------------
/**
* \brief Constructor that creates and displays the message box window.
*
* Creates a GUI window containing:
* - A scrollable list box with the parsed error message
* - An Exit button that terminates the application
*
* The error message is split at newline characters, and each line is
* displayed as a separate entry in the list box.
*
* \param errMsg Multi-line error message string (lines separated by '\n')
* \param p Parent window (typically gClient->GetRoot())
* \param w Window width in pixels
* \param h Window height in pixels
*/
PMsgBox(const std::string errMsg, const TGWindow *p, UInt_t w, UInt_t h);
//-----------------------------------------------------------------------
/**
* \brief Destructor that cleans up the message box resources.
*/
~PMsgBox() override;
//-----------------------------------------------------------------------
/**
* \brief Exit button callback that terminates the application.
*
* This method is called when the user clicks the Exit button.
* It terminates the entire application with exit code 0.
*
* \note This will exit the entire application, not just close the window
*/
void DoExit();
ClassDefOverride(PMsgBox, 0)
};
#endif // _PMSGBOX_H_