// @(#)root/gui:$Id$

/*************************************************************************
 * Copyright (C) 1995-2015, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGTextViewStream
#define ROOT_TGTextViewStream

//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGTextViewStream                                                     //
//                                                                      //
// A TGTextViewStream is a text viewer widget. It is a specialization   //
// of TGTextView and std::ostream, and it uses a TGTextViewStreamBuf,   //
// who inherits from std::streambuf, allowing to stream text directly   //
// to the text view in a cout-like fashion                              //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TGTextView
#include "TGTextView.h"
#endif
#include <vector>
#include <streambuf>
#include <iostream>

#if defined (R__WIN32) && defined (__MAKECINT__)
typedef basic_streambuf<char, char_traits<char> > streambuf;
#endif

class TGTextViewStreamBuf : public std::streambuf
{
private:
   TGTextView *fTextView;
   std::vector<char> fLinebuffer;

protected:
   std::vector<char> fInputbuffer;
   typedef std::char_traits<char> traits;
   virtual int overflow(int = traits::eof());

public:
   TGTextViewStreamBuf(TGTextView *textview);
   virtual ~TGTextViewStreamBuf() { }

   ClassDef(TGTextViewStreamBuf, 0) // Specialization of std::streambuf
};


class TGTextViewostream : public TGTextView, public std::ostream
{
protected:
   TGTextViewStreamBuf fStreambuffer;

public:
   TGTextViewostream(const TGWindow* parent = 0, UInt_t w = 1, UInt_t h = 1,
                     Int_t id = -1, UInt_t sboptions = 0,
                     Pixel_t back = TGTextView::GetWhitePixel());
   TGTextViewostream(const TGWindow *parent, UInt_t w, UInt_t h,
                     TGText *text, Int_t id, UInt_t sboptions, ULong_t back);
   TGTextViewostream(const TGWindow *parent, UInt_t w, UInt_t h,
                     const char *string, Int_t id, UInt_t sboptions,
                     ULong_t back);
   virtual ~TGTextViewostream() { }

   ClassDef(TGTextViewostream, 0) // Specialization of TGTextView and std::ostream
};

#endif
 TGTextViewStream.h:1
 TGTextViewStream.h:2
 TGTextViewStream.h:3
 TGTextViewStream.h:4
 TGTextViewStream.h:5
 TGTextViewStream.h:6
 TGTextViewStream.h:7
 TGTextViewStream.h:8
 TGTextViewStream.h:9
 TGTextViewStream.h:10
 TGTextViewStream.h:11
 TGTextViewStream.h:12
 TGTextViewStream.h:13
 TGTextViewStream.h:14
 TGTextViewStream.h:15
 TGTextViewStream.h:16
 TGTextViewStream.h:17
 TGTextViewStream.h:18
 TGTextViewStream.h:19
 TGTextViewStream.h:20
 TGTextViewStream.h:21
 TGTextViewStream.h:22
 TGTextViewStream.h:23
 TGTextViewStream.h:24
 TGTextViewStream.h:25
 TGTextViewStream.h:26
 TGTextViewStream.h:27
 TGTextViewStream.h:28
 TGTextViewStream.h:29
 TGTextViewStream.h:30
 TGTextViewStream.h:31
 TGTextViewStream.h:32
 TGTextViewStream.h:33
 TGTextViewStream.h:34
 TGTextViewStream.h:35
 TGTextViewStream.h:36
 TGTextViewStream.h:37
 TGTextViewStream.h:38
 TGTextViewStream.h:39
 TGTextViewStream.h:40
 TGTextViewStream.h:41
 TGTextViewStream.h:42
 TGTextViewStream.h:43
 TGTextViewStream.h:44
 TGTextViewStream.h:45
 TGTextViewStream.h:46
 TGTextViewStream.h:47
 TGTextViewStream.h:48
 TGTextViewStream.h:49
 TGTextViewStream.h:50
 TGTextViewStream.h:51
 TGTextViewStream.h:52
 TGTextViewStream.h:53
 TGTextViewStream.h:54
 TGTextViewStream.h:55
 TGTextViewStream.h:56
 TGTextViewStream.h:57
 TGTextViewStream.h:58
 TGTextViewStream.h:59
 TGTextViewStream.h:60
 TGTextViewStream.h:61
 TGTextViewStream.h:62
 TGTextViewStream.h:63
 TGTextViewStream.h:64
 TGTextViewStream.h:65
 TGTextViewStream.h:66
 TGTextViewStream.h:67
 TGTextViewStream.h:68
 TGTextViewStream.h:69
 TGTextViewStream.h:70
 TGTextViewStream.h:71
 TGTextViewStream.h:72
 TGTextViewStream.h:73
 TGTextViewStream.h:74