Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGTextViewStream.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2
3/*************************************************************************
4 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11
12/** \class TGTextViewStream
13 \ingroup guiwidgets
14
15A TGTextViewStream is a text viewer widget. It is a specialization
16of TGTextView and std::ostream, and it uses a TGTextViewStreamBuf,
17who inherits from std::streambuf, allowing to stream text directly
18to the text view in a cout-like fashion
19
20*/
21
22
23#include "TGTextViewStream.h"
24#include "TSystem.h"
25
27
28////////////////////////////////////////////////////////////////////////////////
29/// TGTextViewStreamBuf constructor.
30
32 fTextView(textview)
33{
34 fInputbuffer.reserve(32);
35 setg(&fInputbuffer[0], &fInputbuffer[0], &fInputbuffer[0]);
36 setp(&fInputbuffer[0], &fInputbuffer[0]);
37}
38
39////////////////////////////////////////////////////////////////////////////////
40/// Method called to put a character into the controlled output sequence
41/// without changing the current position.
42
44{
45 typedef std::char_traits<char> Tr;
46 if (c == Tr::eof())
47 return Tr::not_eof(c);
48 if (c=='\n') {
49 fLinebuffer.push_back('\0');
51 fLinebuffer.clear();
55 } else {
56 fLinebuffer.push_back(c);
57 }
58 return c;
59}
60
61////////////////////////////////////////////////////////////////////////////////
62/// TGTextViewostream constructor.
63
65 UInt_t h,Int_t id, UInt_t sboptions,
66 Pixel_t back) :
67 TGTextView(parent, w, h, id, sboptions, back), std::ostream(&fStreambuffer),
68 fStreambuffer(this)
69{
70}
71
72////////////////////////////////////////////////////////////////////////////////
73/// TGTextViewostream constructor.
74
76 UInt_t h, TGText *text, Int_t id,
77 UInt_t sboptions, ULong_t back):
78 TGTextView(parent, w, h, text, id, sboptions, back),
79 std::ostream(&fStreambuffer), fStreambuffer(this)
80{
81}
82
83////////////////////////////////////////////////////////////////////////////////
84/// TGTextViewostream constructor.
85
87 UInt_t h,const char *string, Int_t id,
88 UInt_t sboptions, ULong_t back):
89 TGTextView(parent, w, h, string, id, sboptions, back),
90 std::ostream(&fStreambuffer), fStreambuffer(this)
91{
92}
93
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define c(i)
Definition RSha256.hxx:101
#define h(i)
Definition RSha256.hxx:106
unsigned long ULong_t
Definition RtypesCore.h:55
#define ClassImp(name)
Definition Rtypes.h:364
XFontStruct * id
Definition TGX11.cxx:109
R__EXTERN TSystem * gSystem
Definition TSystem.h:559
virtual int overflow(int=traits::eof())
Method called to put a character into the controlled output sequence without changing the current pos...
std::vector< char > fLinebuffer
TGTextViewStreamBuf(TGTextView *textview)
TGTextViewStreamBuf constructor.
std::vector< char > fInputbuffer
A TGTextView is a text viewer widget.
Definition TGTextView.h:22
virtual void Update()
update the whole window of text view
virtual void AddLineFast(const char *string)
Add a line of text to the view widget.
virtual void ShowBottom()
Show bottom of the page.
TGTextViewostream(const TGWindow *parent=nullptr, UInt_t w=1, UInt_t h=1, Int_t id=-1, UInt_t sboptions=0, Pixel_t back=TGTextView::GetWhitePixel())
TGTextViewostream constructor.
A TGText is a multi line text buffer.
Definition TGText.h:57
ROOT GUI Window base class.
Definition TGWindow.h:23
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).
Definition TSystem.cxx:419
TText * text