TGTextBuffer.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGTextBuffer.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   05/05/98
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGTextBuffer
00013 #define ROOT_TGTextBuffer
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGTextBuffer                                                         //
00019 //                                                                      //
00020 // A text buffer is used in several widgets, like TGTextEntry,          //
00021 // TGFileDialog, etc. It is a little wrapper around the powerful        //
00022 // TString class and used for sinlge line texts. For multi line texts   //
00023 // use TGText.                                                          //
00024 //                                                                      //
00025 //////////////////////////////////////////////////////////////////////////
00026 
00027 #ifndef ROOT_TString
00028 #include "TString.h"
00029 #endif
00030 
00031 
00032 class TGTextBuffer {
00033 
00034 private:
00035    TString    *fBuffer;
00036 
00037 protected:
00038    TGTextBuffer(const TGTextBuffer& tb): fBuffer(tb.fBuffer) { }
00039    TGTextBuffer& operator=(const TGTextBuffer& tb)
00040      {if(this!=&tb) fBuffer=tb.fBuffer; return *this;}
00041 
00042 public:
00043    TGTextBuffer(): fBuffer(new TString) { }
00044    TGTextBuffer(Int_t length): fBuffer(new TString(length)) { }
00045    virtual ~TGTextBuffer() { delete fBuffer; }
00046 
00047    UInt_t GetTextLength() const { return fBuffer->Length(); }
00048    UInt_t GetBufferLength() const { return fBuffer->Capacity(); }
00049    const char *GetString() const { return fBuffer->Data(); }
00050 
00051    void AddText(Int_t pos, const char *text) { fBuffer->Insert(pos, text); }
00052    void AddText(Int_t pos, const char *text, Int_t length) { fBuffer->Insert(pos, text, length); }
00053    void RemoveText(Int_t pos, Int_t length) { fBuffer->Remove(pos, length); }
00054    void Clear() { fBuffer->Remove(0, fBuffer->Length()); }
00055 
00056    ClassDef(TGTextBuffer,0)  // Text buffer used by widgets like TGTextEntry, etc.
00057 };
00058 
00059 #endif

Generated on Tue Jul 5 14:20:09 2011 for ROOT_528-00b_version by  doxygen 1.5.1