musrfit 1.10.0
PMsgBox.cpp
Go to the documentation of this file.
1/***************************************************************************
2
3 PMsgBox.cpp
4
5 Author: Andreas Suter
6 e-mail: andreas.suter@psi.ch
7
8***************************************************************************/
9
10/***************************************************************************
11 * Copyright (C) 2007-2026 by Andreas Suter *
12 * andreas.suter@psi.ch *
13 * *
14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. *
18 * *
19 * This program is distributed in the hope that it will be useful, *
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
22 * GNU General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU General Public License *
25 * along with this program; if not, write to the *
26 * Free Software Foundation, Inc., *
27 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
28 ***************************************************************************/
29
30#include "PMsgBox.h"
31
32//--------------------------------------------------------------------------
33// Constructor
34//--------------------------------------------------------------------------
64PMsgBox::PMsgBox(const std::string errMsg, const TGWindow *p, UInt_t w, UInt_t h) : TGMainFrame(p, w, h)
65{
66 fListBox = new TGListBox(this, 89);
67
68 // feed list box with errMsg
69 size_t start = 0;
70 size_t end = errMsg.find("\n");
71 unsigned int i=1;
72 std::string tok{""};
73 fListBox->AddEntry(tok.c_str(), i++);
74 while (end != std::string::npos) {
75 tok = errMsg.substr(start, end - start);
76 start = end + 1;
77 end = errMsg.find("\n", start);
78 fListBox->AddEntry(tok.c_str(), i++);
79 }
80
81 fListBox->Resize(600, 200);
82 AddFrame(fListBox, new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY, 5, 5, 5, 5));
83
84 // Create a horizontal frame containing button(s)
85 TGHorizontalFrame *hframe = new TGHorizontalFrame(this, 150, 20, kFixedWidth);
86 TGTextButton *exit = new TGTextButton(hframe, "&Exit ");
87 exit->Connect("Pressed()", "PMsgBox", this, "DoExit()");
88 hframe->AddFrame(exit, new TGLayoutHints(kLHintsExpandX, 5, 5, 3, 4));
89 AddFrame(hframe, new TGLayoutHints(kLHintsExpandX, 2, 2, 5, 1));
90
91 // Set a name to the main frame
92 SetWindowName("Error Message");
93 MapSubwindows();
94
95 // Initialize the layout algorithm via Resize()
96 Resize(GetDefaultSize());
97
98 // Map main frame
99 MapWindow();
100}
101
102//--------------------------------------------------------------------------
103// Destructor
104//--------------------------------------------------------------------------
116{
117 // nothing to be done here - ROOT handles GUI cleanup automatically
118}
119
120//--------------------------------------------------------------------------
121// DoExit
122//--------------------------------------------------------------------------
142{
143 gApplication->Terminate(0);
144}
TGListBox * fListBox
List box widget displaying error message lines.
Definition PMsgBox.h:66
~PMsgBox() override
Destructor that cleans up the message box resources.
Definition PMsgBox.cpp:115
void DoExit()
Exit button callback that terminates the application.
Definition PMsgBox.cpp:141
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