Logo ROOT   6.12/07
Reference Guide
TGTextViewStream.h
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 #ifndef ROOT_TGTextViewStream
12 #define ROOT_TGTextViewStream
13 
14 //////////////////////////////////////////////////////////////////////////
15 // //
16 // TGTextViewStream //
17 // //
18 // A TGTextViewStream is a text viewer widget. It is a specialization //
19 // of TGTextView and std::ostream, and it uses a TGTextViewStreamBuf, //
20 // who inherits from std::streambuf, allowing to stream text directly //
21 // to the text view in a cout-like fashion //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #include "TGTextView.h"
26 #include <vector>
27 #include <streambuf>
28 #include <iostream>
29 
30 #if defined (R__WIN32) && defined (__MAKECINT__)
31 typedef basic_streambuf<char, char_traits<char> > streambuf;
32 #endif
33 
34 class TGTextViewStreamBuf : public std::streambuf
35 {
36 private:
38  std::vector<char> fLinebuffer;
39 
40 protected:
41  std::vector<char> fInputbuffer;
42  typedef std::char_traits<char> traits;
43  virtual int overflow(int = traits::eof());
44 
45 public:
47  virtual ~TGTextViewStreamBuf() { }
48 
49  ClassDef(TGTextViewStreamBuf, 0) // Specialization of std::streambuf
50 };
51 
52 
53 class TGTextViewostream : public TGTextView, public std::ostream
54 {
55 protected:
57 
58 public:
59  TGTextViewostream(const TGWindow* parent = 0, UInt_t w = 1, UInt_t h = 1,
60  Int_t id = -1, UInt_t sboptions = 0,
62  TGTextViewostream(const TGWindow *parent, UInt_t w, UInt_t h,
63  TGText *text, Int_t id, UInt_t sboptions, ULong_t back);
64  TGTextViewostream(const TGWindow *parent, UInt_t w, UInt_t h,
65  const char *string, Int_t id, UInt_t sboptions,
66  ULong_t back);
67  virtual ~TGTextViewostream() { }
68 
69  ClassDef(TGTextViewostream, 0) // Specialization of TGTextView and std::ostream
70 };
71 
72 #endif
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
Definition: TGText.h:67
TH1 * h
Definition: legend2.C:5
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
TGTextViewStreamBuf fStreambuffer
std::vector< char > fInputbuffer
int Int_t
Definition: RtypesCore.h:41
std::char_traits< char > traits
virtual ~TGTextViewStreamBuf()
#define ClassDef(name, id)
Definition: Rtypes.h:320
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGTextView * fTextView
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual ~TGTextViewostream()
TText * text
unsigned long ULong_t
Definition: RtypesCore.h:51
TGTextViewStreamBuf(TGTextView *textview)
TGTextViewStreamBuf constructor.