Logo ROOT  
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 #include "TString.h"
28 
29 
30 class TGTextBuffer {
31 
32 private:
34 
35 protected:
36  TGTextBuffer(const TGTextBuffer& tb): fBuffer(tb.fBuffer) { }
38  {if(this!=&tb) fBuffer=tb.fBuffer; return *this;}
39 
40 public:
41  TGTextBuffer(): fBuffer(new TString) { }
42  TGTextBuffer(Int_t length): fBuffer(new TString(length)) { }
43  virtual ~TGTextBuffer() { delete fBuffer; }
44 
45  UInt_t GetTextLength() const { return fBuffer->Length(); }
46  UInt_t GetBufferLength() const { return fBuffer->Capacity(); }
47  const char *GetString() const { return fBuffer->Data(); }
48 
49  void AddText(Int_t pos, const char *text) { fBuffer->Insert(pos, text); }
50  void AddText(Int_t pos, const char *text, Int_t length) { fBuffer->Insert(pos, text, length); }
51  void RemoveText(Int_t pos, Int_t length) { fBuffer->Remove(pos, length); }
52  void Clear() { fBuffer->Remove(0, fBuffer->Length()); }
53 
54  ClassDef(TGTextBuffer,0) // Text buffer used by widgets like TGTextEntry, etc.
55 };
56 
57 #endif
TString::Data
const char * Data() const
Definition: TString.h:369
TGTextBuffer::GetTextLength
UInt_t GetTextLength() const
Definition: TGTextBuffer.h:51
TGTextBuffer::~TGTextBuffer
virtual ~TGTextBuffer()
Definition: TGTextBuffer.h:49
Int_t
int Int_t
Definition: RtypesCore.h:45
TString::Length
Ssiz_t Length() const
Definition: TString.h:410
TGTextBuffer::TGTextBuffer
TGTextBuffer(const TGTextBuffer &tb)
Definition: TGTextBuffer.h:42
TString
Definition: TString.h:136
text
TText * text
Definition: entrylist_figure1.C:10
TString.h
TGTextBuffer
Definition: TGTextBuffer.h:30
TGTextBuffer::fBuffer
TString * fBuffer
Definition: TGTextBuffer.h:39
TString::Remove
TString & Remove(Ssiz_t pos)
Definition: TString.h:673
TGTextBuffer::operator=
TGTextBuffer & operator=(const TGTextBuffer &tb)
Definition: TGTextBuffer.h:43
TString::Insert
TString & Insert(Ssiz_t pos, const char *s)
Definition: TString.h:649
UInt_t
unsigned int UInt_t
Definition: RtypesCore.h:46
TGTextBuffer::Clear
void Clear()
Definition: TGTextBuffer.h:58
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TString::Capacity
Ssiz_t Capacity() const
Definition: TString.h:357
TGTextBuffer::TGTextBuffer
TGTextBuffer()
Definition: TGTextBuffer.h:47
TGTextBuffer::RemoveText
void RemoveText(Int_t pos, Int_t length)
Definition: TGTextBuffer.h:57
TGTextBuffer::GetBufferLength
UInt_t GetBufferLength() const
Definition: TGTextBuffer.h:52
TGTextBuffer::AddText
void AddText(Int_t pos, const char *text)
Definition: TGTextBuffer.h:55
TGTextBuffer::GetString
const char * GetString() const
Definition: TGTextBuffer.h:53
int