Logo ROOT   6.08/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 #ifndef ROOT_TGTextView
26 #include "TGTextView.h"
27 #endif
28 #include <vector>
29 #include <streambuf>
30 #include <iostream>
31 
32 #if defined (R__WIN32) && defined (__MAKECINT__)
33 typedef basic_streambuf<char, char_traits<char> > streambuf;
34 #endif
35 
36 class TGTextViewStreamBuf : public std::streambuf
37 {
38 private:
40  std::vector<char> fLinebuffer;
41 
42 protected:
43  std::vector<char> fInputbuffer;
44  typedef std::char_traits<char> traits;
45  virtual int overflow(int = traits::eof());
46 
47 public:
49  virtual ~TGTextViewStreamBuf() { }
50 
51  ClassDef(TGTextViewStreamBuf, 0) // Specialization of std::streambuf
52 };
53 
54 
55 class TGTextViewostream : public TGTextView, public std::ostream
56 {
57 protected:
59 
60 public:
61  TGTextViewostream(const TGWindow* parent = 0, UInt_t w = 1, UInt_t h = 1,
62  Int_t id = -1, UInt_t sboptions = 0,
64  TGTextViewostream(const TGWindow *parent, UInt_t w, UInt_t h,
65  TGText *text, Int_t id, UInt_t sboptions, ULong_t back);
66  TGTextViewostream(const TGWindow *parent, UInt_t w, UInt_t h,
67  const char *string, Int_t id, UInt_t sboptions,
68  ULong_t back);
69  virtual ~TGTextViewostream() { }
70 
71  ClassDef(TGTextViewostream, 0) // Specialization of TGTextView and std::ostream
72 };
73 
74 #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:71
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:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
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.