Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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:
37  TGTextView *fTextView;
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:
46  TGTextViewStreamBuf(TGTextView *textview);
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:
56  TGTextViewStreamBuf fStreambuffer;
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,
61  Pixel_t back = TGTextView::GetWhitePixel());
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