ROOT
Version v6.34
master
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
textviewostream.C
Go to the documentation of this file.
1
/// \file
2
/// \ingroup tutorial_gui
3
/// This macro gives an example of how to use the TGTextViewostream widget.
4
/// Simply type a command in the "Command" text entry, then the output is redirected to theTGTextViewostream.
5
/// To run it do either:
6
/// ~~~
7
/// .x textviewostream.C
8
/// .x textviewostream.C++
9
/// ~~~
10
///
11
/// \macro_code
12
///
13
/// \author Bertrand Bellenot 06/01/2015
14
15
#include "
TGButton.h
"
16
#include "
TGButtonGroup.h
"
17
#include "
TGLabel.h
"
18
#include "
TGNumberEntry.h
"
19
#include "
TGTextViewStream.h
"
20
#include "
TApplication.h
"
21
#include "
TGFrame.h
"
22
#include "
TSystem.h
"
23
24
////////////////////////////////////////////////////////////////////////////////
25
class
TextViewMainFrame
:
public
TGMainFrame
26
{
27
protected
:
28
TGTextButton
*fReset, *
fExit
;
29
TGTextViewostream
*fTextView;
30
TGVerticalFrame
*fContents;
31
TGHorizontalFrame
*fButtons, *
fCommandFrame
;
32
TGTextEntry
*fCommand;
33
34
public
:
35
TextViewMainFrame
();
36
~TextViewMainFrame
()
override
{}
37
void
Reset();
38
void
HandleReturn();
39
40
ClassDefOverride
(
TextViewMainFrame
, 0)
41
};
42
43
44
//______________________________________________________________________________
45
TextViewMainFrame::TextViewMainFrame() :
TGMainFrame
(
gClient
->GetRoot())
46
{
47
// Main test window.
48
49
SetCleanup(
kDeepCleanup
);
50
51
// Contents
52
fContents =
new
TGVerticalFrame
(
this
);
53
fButtons =
new
TGHorizontalFrame
(fContents);
54
55
// TextView
56
fTextView =
new
TGTextViewostream
(fContents, 500, 300);
57
fContents->AddFrame(fTextView,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsExpandY
, 5, 5, 5, 0));
58
59
fCommandFrame
=
new
TGHorizontalFrame
(fContents);
60
fCommand =
new
TGTextEntry
(
fCommandFrame
, (
const
char
*)
""
, 20);
61
fCommand->Connect(
"ReturnPressed()"
,
"TextViewMainFrame"
,
this
,
"HandleReturn()"
);
62
fCommandFrame
->AddFrame(
new
TGLabel
(
fCommandFrame
,
"Command: "
),
63
new
TGLayoutHints
(
kLHintsCenterY
|
kLHintsLeft
, 5, 5, 5, 5));
64
fCommandFrame
->AddFrame(fCommand,
new
TGLayoutHints
(
kLHintsExpandX
, 5, 5, 5, 5));
65
fContents->AddFrame(
fCommandFrame
,
new
TGLayoutHints
(
kLHintsExpandX
, 5, 5, 5, 5));
66
67
// The button for test
68
fReset =
new
TGTextButton
(fButtons,
"&Reset"
);
69
fReset->SetToolTipText(
"Press to clear the command entry\nand the TGTextView"
, 200);
70
fReset->Connect(
"Clicked()"
,
"TextViewMainFrame"
,
this
,
"Reset()"
);
71
fButtons->AddFrame(fReset,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsTop
, 5, 5, 5, 5));
72
73
fExit
=
new
TGTextButton
(fButtons,
"&Exit"
);
74
fExit
->SetToolTipText(
"Terminate the application"
, 200);
75
fButtons->AddFrame(
fExit
,
new
TGLayoutHints
(
kLHintsExpandX
|
kLHintsTop
, 5, 5, 5, 5));
76
fExit
->Connect(
"Pressed()"
,
"TApplication"
,
gApplication
,
"Terminate()"
);
77
78
fContents->AddFrame(fButtons,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
, 0, 0, 0, 0));
79
Connect(
"CloseWindow()"
,
"TApplication"
,
gApplication
,
"Terminate()"
);
80
DontCallClose();
81
82
AddFrame(fContents,
new
TGLayoutHints
(
kLHintsTop
|
kLHintsExpandX
|
kLHintsExpandY
));
83
MapSubwindows
();
84
Resize(GetDefaultSize());
85
86
SetWindowName(
"TGTextView Demo"
);
87
MapRaised();
88
}
89
90
//______________________________________________________________________________
91
void
TextViewMainFrame::Reset()
92
{
93
fCommand->Clear();
94
fTextView->Clear();
95
}
96
97
//______________________________________________________________________________
98
void
TextViewMainFrame::HandleReturn()
99
{
100
std::string
line
;
101
std::string
command
= fCommand->GetText();
102
*fTextView <<
gSystem
->
GetFromPipe
(
command
.c_str()).Data() << std::endl;
103
fTextView->ShowBottom();
104
fCommand->Clear();
105
}
106
107
//______________________________________________________________________________
108
void
textviewostream
()
109
{
110
// Main program.
111
112
new
TextViewMainFrame
();
113
}
114
115
ClassDefOverride
#define ClassDefOverride(name, id)
Definition
Rtypes.h:346
TApplication.h
gApplication
R__EXTERN TApplication * gApplication
Definition
TApplication.h:170
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
TGButtonGroup.h
TGButton.h
gClient
#define gClient
Definition
TGClient.h:156
TGFrame.h
kDeepCleanup
@ kDeepCleanup
Definition
TGFrame.h:42
TGLabel.h
kLHintsExpandY
@ kLHintsExpandY
Definition
TGLayout.h:31
kLHintsLeft
@ kLHintsLeft
Definition
TGLayout.h:24
kLHintsCenterY
@ kLHintsCenterY
Definition
TGLayout.h:28
kLHintsTop
@ kLHintsTop
Definition
TGLayout.h:27
kLHintsExpandX
@ kLHintsExpandX
Definition
TGLayout.h:30
TGNumberEntry.h
TGTextViewStream.h
MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Definition
TGWin32VirtualXProxy.cxx:94
TSystem.h
gSystem
R__EXTERN TSystem * gSystem
Definition
TSystem.h:572
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
TGHorizontalFrame
A composite frame that layout their children in horizontal way.
Definition
TGFrame.h:385
TGLabel
This class handles GUI labels.
Definition
TGLabel.h:24
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition
TGLayout.h:50
TGMainFrame
Defines top level windows that interact with the system Window Manager.
Definition
TGFrame.h:397
TGTextButton
Yield an action as soon as it is clicked.
Definition
TGButton.h:142
TGTextEntry
A TGTextEntry is a one line text input widget.
Definition
TGTextEntry.h:24
TGTextViewostream
Definition
TGTextViewStream.h:44
TGVerticalFrame
A composite frame that layout their children in vertical way.
Definition
TGFrame.h:374
TSystem::GetFromPipe
virtual TString GetFromPipe(const char *command)
Execute command and return output in TString.
Definition
TSystem.cxx:680
line
TLine * line
Definition
entrylistblock_figure1.C:235
tutorials
gui
textviewostream.C
ROOT v6-34 - Reference Guide Generated on Mon Mar 31 2025 06:04:14 (GVA Time) using Doxygen 1.10.0