musrfit 1.10.0
PMsgBox Class Reference

GUI message box for displaying error messages and warnings. More...

#include <PMsgBox.h>

Inheritance diagram for PMsgBox:
Collaboration diagram for PMsgBox:

Public Member Functions

 PMsgBox (const std::string errMsg, const TGWindow *p, UInt_t w, UInt_t h)
 Constructor that creates and displays the message box window.
 
 ~PMsgBox () override
 Destructor that cleans up the message box resources.
 
void DoExit ()
 Exit button callback that terminates the application.
 

Private Attributes

TGListBox * fListBox
 List box widget displaying error message lines.
 

Detailed Description

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:

std::string errorMsg = "Error parsing file:\nLine 42: Invalid syntax\nAborting...";
PMsgBox msgBox(errorMsg, gClient->GetRoot(), 640, 240);
PMsgBox(const std::string errMsg, const TGWindow *p, UInt_t w, UInt_t h)
Constructor that creates and displays the message box window.
Definition PMsgBox.cpp:64
See also
TGMainFrame for the base class

Definition at line 63 of file PMsgBox.h.

Constructor & Destructor Documentation

◆ PMsgBox()

PMsgBox::PMsgBox ( const std::string errMsg,
const TGWindow * p,
UInt_t w,
UInt_t h )

Constructor that creates and displays the message box window.

Constructor that creates and displays the message box GUI.

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.

Parameters
errMsgMulti-line error message string (lines separated by '
')
pParent window (typically gClient->GetRoot())
wWindow width in pixels
hWindow height in pixels

This constructor performs the following steps:

  1. Creates a scrollable list box widget
  2. Parses the error message string by splitting at newline characters
  3. Populates the list box with individual message lines
  4. Creates an Exit button with callback to DoExit()
  5. Configures layout and displays the window

The message parsing algorithm:

  • Adds an initial empty line
  • Splits the input string at each '
    ' character
  • Each substring becomes a separate list box entry
  • Handles multi-line messages gracefully

GUI Layout:

  • List box: 600x200 pixels, expandable, with 5-pixel margins
  • Button frame: Fixed width (150px), contains Exit button
  • Window title: "Error Message"
Parameters
errMsgMulti-line error message string with '
' separators
pParent window pointer (typically gClient->GetRoot())
wInitial window width in pixels
hInitial window height in pixels
Note
The window is automatically mapped (displayed) after construction
The list box ID is set to 89 (ROOT widget identifier)

Definition at line 64 of file PMsgBox.cpp.

References fListBox.

◆ ~PMsgBox()

PMsgBox::~PMsgBox ( )
override

Destructor that cleans up the message box resources.

The ROOT framework automatically handles cleanup of GUI components (list box, buttons, frames) through the TGMainFrame destructor chain, so no explicit cleanup is required here.

Note
GUI widgets are managed by ROOT and are automatically deleted when the main frame is destroyed

Definition at line 115 of file PMsgBox.cpp.

Member Function Documentation

◆ DoExit()

void PMsgBox::DoExit ( )

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

This method is invoked when the user clicks the Exit button. It terminates the entire ROOT application with exit code 0, which causes a clean shutdown of the program.

The method is connected to the Exit button's "Pressed()" signal in the constructor via ROOT's signal/slot mechanism:

exit->Connect("Pressed()", "PMsgBox", this, "DoExit()");
Note
This terminates the entire application, not just the message box window
Exit code 0 indicates successful termination
See also
gApplication for ROOT's global application object

Definition at line 141 of file PMsgBox.cpp.

Member Data Documentation

◆ fListBox

TGListBox* PMsgBox::fListBox
private

List box widget displaying error message lines.

Definition at line 66 of file PMsgBox.h.

Referenced by PMsgBox().


The documentation for this class was generated from the following files: