ROOT  6.06/09
Reference Guide
TGTextBuffer.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 05/05/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGTextBuffer
13 #define ROOT_TGTextBuffer
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGTextBuffer //
19 // //
20 // A text buffer is used in several widgets, like TGTextEntry, //
21 // TGFileDialog, etc. It is a little wrapper around the powerful //
22 // TString class and used for sinlge line texts. For multi line texts //
23 // use TGText. //
24 // //
25 //////////////////////////////////////////////////////////////////////////
26 
27 #ifndef ROOT_TString
28 #include "TString.h"
29 #endif
30 
31 
32 class TGTextBuffer {
33 
34 private:
36 
37 protected:
38  TGTextBuffer(const TGTextBuffer& tb): fBuffer(tb.fBuffer) { }
40  {if(this!=&tb) fBuffer=tb.fBuffer; return *this;}
41 
42 public:
43  TGTextBuffer(): fBuffer(new TString) { }
44  TGTextBuffer(Int_t length): fBuffer(new TString(length)) { }
45  virtual ~TGTextBuffer() { delete fBuffer; }
46 
47  UInt_t GetTextLength() const { return fBuffer->Length(); }
48  UInt_t GetBufferLength() const { return fBuffer->Capacity(); }
49  const char *GetString() const { return fBuffer->Data(); }
50 
51  void AddText(Int_t pos, const char *text) { fBuffer->Insert(pos, text); }
52  void AddText(Int_t pos, const char *text, Int_t length) { fBuffer->Insert(pos, text, length); }
53  void RemoveText(Int_t pos, Int_t length) { fBuffer->Remove(pos, length); }
54  void Clear() { fBuffer->Remove(0, fBuffer->Length()); }
55 
56  ClassDef(TGTextBuffer,0) // Text buffer used by widgets like TGTextEntry, etc.
57 };
58 
59 #endif
virtual ~TGTextBuffer()
Definition: TGTextBuffer.h:45
Ssiz_t Length() const
Definition: TString.h:390
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:592
const char * Data() const
Definition: TString.h:349
#define ClassDef(name, id)
Definition: Rtypes.h:254
UInt_t GetBufferLength() const
Definition: TGTextBuffer.h:48
TString * fBuffer
Definition: TGTextBuffer.h:35
const char * GetString() const
Definition: TGTextBuffer.h:49
void AddText(Int_t pos, const char *text)
Definition: TGTextBuffer.h:51
Ssiz_t Capacity() const
Definition: TString.h:337
TGTextBuffer & operator=(const TGTextBuffer &tb)
Definition: TGTextBuffer.h:39
void RemoveText(Int_t pos, Int_t length)
Definition: TGTextBuffer.h:53
Double_t length(const TVector2 &v)
Definition: CsgOps.cxx:347
unsigned int UInt_t
Definition: RtypesCore.h:42
void AddText(Int_t pos, const char *text, Int_t length)
Definition: TGTextBuffer.h:52
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
UInt_t GetTextLength() const
Definition: TGTextBuffer.h:47
TText * text
void Clear()
Definition: TGTextBuffer.h:54
TGTextBuffer(const TGTextBuffer &tb)
Definition: TGTextBuffer.h:38
TGTextBuffer(Int_t length)
Definition: TGTextBuffer.h:44