#include "TGTextView.h"
#include "TGScrollBar.h"
#include "TGResourcePool.h"
#include "TSystem.h"
#include "Riostream.h"
const TGFont *TGTextView::fgDefaultFont = 0;
TGGC *TGTextView::fgDefaultGC = 0;
TGGC *TGTextView::fgDefaultSelectedGC = 0;
const TGGC *TGTextView::fgDefaultSelectedBackgroundGC = 0;
ClassImp(TGTextView)
void TGTextView::Init(ULong_t )
{
fFont = GetDefaultFontStruct();
fNormGC = GetDefaultGC();
fSelGC = GetDefaultSelectedGC();
fSelbackGC = GetDefaultSelectedBackgroundGC()();
fMarkedFromX = 0;
fMarkedFromY = 0;
fText = new TGText();
TGView::Clear();
fClipText = new TGText();
gVirtualX->GetFontProperties(fFont, fMaxAscent, fMaxDescent);
fScrollVal.fY = fMaxAscent + fMaxDescent;
fScrollVal.fX = fMaxWidth = gVirtualX->TextWidth(fFont, "W", 1);
gVirtualX->ClearWindow(fCanvas->GetId());
Layout();
}
TGTextView::TGTextView(const TGWindow *parent, UInt_t w, UInt_t h, Int_t id,
UInt_t sboptions, ULong_t back) :
TGView(parent, w, h, id, 3, 3, kSunkenFrame | kDoubleBorder, sboptions, back)
{
Init(back);
}
TGTextView::TGTextView(const TGWindow *parent, UInt_t w, UInt_t h, TGText *text,
Int_t id, UInt_t sboptions, ULong_t back) :
TGView(parent, w, h, id, 3, 3, kSunkenFrame | kDoubleBorder, sboptions, back)
{
Init(back);
TGLongPosition pos, srcStart, srcEnd;
pos.fX = pos.fY = 0;
srcStart.fX = srcStart.fY = 0;
srcEnd.fY = text->RowCount()-1;
srcEnd.fX = text->GetLineLength(srcEnd.fY)-1;
fText->InsText(pos, text, srcStart, srcEnd);
}
TGTextView::TGTextView(const TGWindow *parent, UInt_t w, UInt_t h,
const char *string, Int_t id, UInt_t sboptions,
ULong_t back) :
TGView(parent, w, h, id, 3, 3, kSunkenFrame | kDoubleBorder, sboptions, back)
{
Init(back);
TGLongPosition pos;
pos.fX = pos.fY = 0;
fText->InsText(pos, string);
}
TGTextView::~TGTextView()
{
delete fText;
delete fClipText;
}
void TGTextView::SetText(TGText *text)
{
Clear();
delete fText;
fText = text;
Layout();
DrawRegion(0, 0, fCanvas->GetWidth(), fCanvas->GetHeight());
}
void TGTextView::AddText(TGText *text)
{
fText->AddText(text);
Layout();
DrawRegion(0, 0, fCanvas->GetWidth(), fCanvas->GetHeight());
}
void TGTextView::AddLine(const char *string)
{
AddLineFast(string);
Update();
}
void TGTextView::AddLineFast(const char *string)
{
TGLongPosition pos;
pos.fX = 0;
pos.fY = fText->RowCount();
fText->InsText(pos, string);
}
void TGTextView::Update()
{
TGView::Layout();
DrawRegion(0, 0, fCanvas->GetWidth(), fCanvas->GetHeight());
}
Long_t TGTextView::ReturnLongestLineWidth()
{
Long_t count = 0, longest = 0, width;
Long_t rows = fText->RowCount();
while (count < rows) {
width = ToScrXCoord(fText->GetLineLength(count), count) + fVisible.fX;
if (width > longest)
longest = width;
count++;
}
return longest;
}
Bool_t TGTextView::Search(const char *string, Bool_t direction, Bool_t caseSensitive)
{
TGLongPosition pos, pos2;
pos2.fX = pos2.fY = 0;
if (fIsMarked) {
if (!direction) {
pos2.fX = fMarkedStart.fX;
pos2.fY = fMarkedStart.fY;
} else {
pos2.fX = fMarkedEnd.fX + 1;
pos2.fY = fMarkedEnd.fY;
}
}
if (!fText->Search(&pos, pos2, string, direction, caseSensitive))
return kFALSE;
UnMark();
fIsMarked = kTRUE;
fMarkedStart.fY = fMarkedEnd.fY = pos.fY;
fMarkedStart.fX = pos.fX;
fMarkedEnd.fX = fMarkedStart.fX + strlen(string) - 1;
pos.fY = ToObjYCoord(fVisible.fY);
if ((fMarkedStart.fY < pos.fY) ||
(ToScrYCoord(fMarkedStart.fY) >= (Int_t)fCanvas->GetHeight()))
pos.fY = fMarkedStart.fY;
pos.fX = ToObjXCoord(fVisible.fX, pos.fY);
if ((fMarkedStart.fX < pos.fX) ||
(ToScrXCoord(fMarkedStart.fX, pos.fY) >= (Int_t)fCanvas->GetWidth()))
pos.fX = fMarkedStart.fX;
SetVsbPosition((ToScrYCoord(pos.fY) + fVisible.fY)/fScrollVal.fY);
SetHsbPosition((ToScrXCoord(pos.fX, pos.fY) + fVisible.fX)/fScrollVal.fX);
DrawRegion(0, (Int_t)ToScrYCoord(fMarkedStart.fY), fCanvas->GetWidth(),
UInt_t(ToScrYCoord(fMarkedEnd.fY+1) - ToScrYCoord(fMarkedEnd.fY)));
return kTRUE;
}
void TGTextView::SetFont(FontStruct_t font)
{
if (font != fFont) {
fFont = font;
fNormGC.SetFont(gVirtualX->GetFontHandle(fFont));
fSelGC.SetFont(gVirtualX->GetFontHandle(fFont));
fClient->NeedRedraw(this);
}
}
Long_t TGTextView::ToScrYCoord(Long_t yCoord)
{
if (yCoord * (fMaxAscent + fMaxDescent) <= 0)
return 0;
if (yCoord > fText->RowCount())
return fText->RowCount() * (fMaxAscent + fMaxDescent);
return yCoord * (fMaxAscent + fMaxDescent) - fVisible.fY;
}
Long_t TGTextView::ToScrXCoord(Long_t xCoord, Long_t line)
{
TGLongPosition pos;
char *buffer;
pos.fX = 0;
pos.fY = line;
Long_t width = fText->GetLineLength(line);
if (xCoord <= 0 || pos.fY < 0 || width <= 0)
return 0;
if (xCoord > width)
xCoord = width;
buffer = fText->GetLine(pos, xCoord);
width = gVirtualX->TextWidth(fFont, buffer, (Int_t)xCoord) - fVisible.fX;
delete [] buffer;
return width;
}
Long_t TGTextView::ToObjYCoord(Long_t yCoord)
{
return yCoord / (fMaxAscent + fMaxDescent);
}
Long_t TGTextView::ToObjXCoord(Long_t xCoord, Long_t line)
{
TGLongPosition pos;
char *buffer, *travelBuffer;
char charBuffer;
if (line < 0 || line >= fText->RowCount())
return 0;
Long_t len = fText->GetLineLength(line);
pos.fX = 0;
pos.fY = line;
if (len <= 0 || xCoord < 0)
return 0;
Long_t viscoord = xCoord;
buffer = fText->GetLine(pos, len);
travelBuffer = buffer;
charBuffer = *travelBuffer++;
int cw = gVirtualX->TextWidth(fFont, &charBuffer, 1);
while (viscoord - cw >= 0 && pos.fX < len) {
viscoord -= cw;
pos.fX++;
charBuffer = *travelBuffer++;
cw = gVirtualX->TextWidth(fFont, &charBuffer, 1);
}
delete [] buffer;
return pos.fX;
}
void TGTextView::Clear(Option_t *)
{
TGView::Clear();
delete fText;
fText = new TGText();
fText->Clear();
SendMessage(fMsgWindow, MK_MSG(kC_TEXTVIEW, kTXT_ISMARKED), fWidgetId, kFALSE);
Marked(kFALSE);
gVirtualX->ClearWindow(fCanvas->GetId());
SendMessage(fMsgWindow, MK_MSG(kC_TEXTVIEW, kTXT_DATACHANGE), fWidgetId, 0);
DataChanged();
Layout();
}
Bool_t TGTextView::LoadFile(const char *filename, Long_t startpos, Long_t length)
{
FILE *fp;
if (!(fp = fopen(filename, "r")))
return kFALSE;
fclose(fp);
Clear();
fText->Load(filename, startpos, length);
Layout();
DrawRegion(0, 0, fCanvas->GetWidth(), fCanvas->GetHeight());
return kTRUE;
}
Bool_t TGTextView::LoadBuffer(const char *txtbuf)
{
if (!txtbuf || !strlen(txtbuf))
return kFALSE;
Clear();
fText->LoadBuffer(txtbuf);
Layout();
DrawRegion(0, 0, fCanvas->GetWidth(), fCanvas->GetHeight());
return kTRUE;
}
Bool_t TGTextView::Copy()
{
TGLongPosition insPos, startPos, endPos;
if (!fIsMarked)
return kFALSE;
delete fClipText;
fClipText = new TGText();
insPos.fY = insPos.fX = 0;
startPos.fX = fMarkedStart.fX;
startPos.fY = fMarkedStart.fY;
endPos.fX = fMarkedEnd.fX-1;
endPos.fY = fMarkedEnd.fY;
if (endPos.fX == -1) {
if (endPos.fY > 0)
endPos.fY--;
endPos.fX = fText->GetLineLength(endPos.fY);
if (endPos.fX < 0)
endPos.fX = 0;
}
fClipText->InsText(insPos, fText, startPos, endPos);
gVirtualX->SetPrimarySelectionOwner(fId);
return kTRUE;
}
Bool_t TGTextView::SelectAll()
{
if (fText->RowCount() == 1 && fText->GetLineLength(0) == 0)
return kFALSE;
fIsMarked = kTRUE;
fMarkedStart.fY = 0;
fMarkedStart.fX = 0;
fMarkedEnd.fY = fText->RowCount()-1;
fMarkedEnd.fX = fText->GetLineLength(fMarkedEnd.fY);
if (fMarkedEnd.fX < 0)
fMarkedEnd.fX = 0;
DrawRegion(0, 0, fCanvas->GetWidth(), fCanvas->GetHeight());
Copy();
return kTRUE;
}
void TGTextView::DrawRegion(Int_t x, Int_t y, UInt_t w, UInt_t h)
{
char *buffer;
TGLongPosition pos;
Long_t xoffset, len, len1, len2;
Long_t line_count = fText->RowCount();
Rectangle_t rect;
rect.fX = x;
rect.fY = y;
pos.fY = ToObjYCoord(fVisible.fY + h);
rect.fHeight = UShort_t(h + ToScrYCoord(pos.fY+1) - ToScrYCoord(pos.fY));
pos.fX = ToObjXCoord(fVisible.fX+w, pos.fY);
rect.fWidth = UShort_t(w + ToScrXCoord(pos.fX+1,pos.fY) - ToScrXCoord(pos.fX, pos.fY));
Int_t yloc = rect.fY + (Int_t)fScrollVal.fY;
pos.fY = ToObjYCoord(fVisible.fY + rect.fY);
while (pos.fY < line_count &&
yloc - fScrollVal.fY <= (Int_t)fCanvas->GetHeight() &&
yloc - fScrollVal.fY <= rect.fY + rect.fHeight) {
pos.fX = ToObjXCoord(fVisible.fX + rect.fX, pos.fY);
xoffset = ToScrXCoord(pos.fX, pos.fY);
len = fText->GetLineLength(pos.fY) - pos.fX;
gVirtualX->ClearArea(fCanvas->GetId(), x, Int_t(ToScrYCoord(pos.fY)),
rect.fWidth, UInt_t(ToScrYCoord(pos.fY+1)-ToScrYCoord(pos.fY)));
if (len > 0) {
if (len > ToObjXCoord(fVisible.fX + rect.fX + rect.fWidth, pos.fY) - pos.fX)
len = ToObjXCoord(fVisible.fX + rect.fX + rect.fWidth, pos.fY) - pos.fX + 1;
if (pos.fX == 0)
xoffset = -fVisible.fX;
if (pos.fY >= ToObjYCoord(fVisible.fY)) {
buffer = fText->GetLine(pos, len);
Int_t i = 0;
while (buffer[i] != '\0') {
if (buffer[i] == '\t') {
buffer[i] = ' ';
Int_t j = i+1;
while (buffer[j] == 16 && buffer[j] != '\0')
buffer[j++] = ' ';
}
i++;
}
if (!fIsMarked ||
pos.fY < fMarkedStart.fY || pos.fY > fMarkedEnd.fY ||
(pos.fY == fMarkedStart.fY &&
fMarkedStart.fX >= pos.fX+len &&
fMarkedStart.fY != fMarkedEnd.fY) ||
(pos.fY == fMarkedEnd.fY &&
fMarkedEnd.fX < pos.fX &&
fMarkedStart.fY != fMarkedEnd.fY) ||
(fMarkedStart.fY == fMarkedEnd.fY &&
(fMarkedEnd.fX < pos.fX ||
fMarkedStart.fX > pos.fX+len))) {
gVirtualX->DrawString(fCanvas->GetId(), fNormGC(), Int_t(xoffset),
Int_t(ToScrYCoord(pos.fY+1) - fMaxDescent),
buffer, Int_t(len));
} else {
if (pos.fY > fMarkedStart.fY && pos.fY < fMarkedEnd.fY) {
len1 = 0;
len2 = len;
} else {
if (fMarkedStart.fY == fMarkedEnd.fY) {
if (fMarkedStart.fX >= pos.fX &&
fMarkedStart.fX <= pos.fX + len)
len1 = fMarkedStart.fX - pos.fX;
else
len1 = 0;
if (fMarkedEnd.fX >= pos.fX &&
fMarkedEnd.fX <= pos.fX + len)
len2 = fMarkedEnd.fX - pos.fX - len1;
else
len2 = len - len1;
} else {
if (pos.fY == fMarkedStart.fY) {
if (fMarkedStart.fX < pos.fX) {
len1 = 0;
len2 = len;
} else {
len1 = fMarkedStart.fX - pos.fX;
len2 = len - len1;
}
} else {
if (fMarkedEnd.fX > pos.fX+len) {
len1 = 0;
len2 = len;
} else {
len1 = 0 ;
len2 = fMarkedEnd.fX - pos.fX;
}
}
}
}
gVirtualX->DrawString(fCanvas->GetId(), fNormGC(),
Int_t(ToScrXCoord(pos.fX, pos.fY)),
Int_t(ToScrYCoord(pos.fY+1) - fMaxDescent),
buffer, Int_t(len1));
gVirtualX->FillRectangle(fCanvas->GetId(), fSelbackGC,
Int_t(ToScrXCoord(pos.fX+len1, pos.fY)),
Int_t(ToScrYCoord(pos.fY)),
UInt_t(ToScrXCoord(pos.fX+len1+len2, pos.fY) -
ToScrXCoord(pos.fX+len1, pos.fY)),
UInt_t(ToScrYCoord(pos.fY+1)-ToScrYCoord(pos.fY)));
gVirtualX->DrawString(fCanvas->GetId(), fSelGC(),
Int_t(ToScrXCoord(pos.fX+len1, pos.fY)),
Int_t(ToScrYCoord(pos.fY+1) - fMaxDescent),
buffer+len1, Int_t(len2));
gVirtualX->DrawString(fCanvas->GetId(), fNormGC(),
Int_t(ToScrXCoord(pos.fX+len1+len2, pos.fY)),
Int_t(ToScrYCoord(pos.fY+1) - fMaxDescent),
buffer+len1+len2, Int_t(len-(len1+len2)));
}
delete [] buffer;
}
}
pos.fY++;
yloc += Int_t(ToScrYCoord(pos.fY) - ToScrYCoord(pos.fY-1));
}
}
Bool_t TGTextView::HandleButton(Event_t *event)
{
if (event->fWindow != fCanvas->GetId())
return kTRUE;
TGView::HandleButton(event);
if (event->fType == kButtonRelease) {
if (event->fCode == kButton1) {
if (fIsMarked)
Copy();
}
}
return kTRUE;
}
Bool_t TGTextView::HandleSelectionClear(Event_t * )
{
if (fIsMarked)
UnMark();
return kTRUE;
}
Bool_t TGTextView::HandleSelectionRequest(Event_t *event)
{
Event_t reply;
char *buffer, *temp_buffer;
Long_t len, prev_len, temp_len, count;
TGLongPosition pos;
Atom_t targets[2];
Atom_t type;
reply.fType = kSelectionNotify;
reply.fTime = event->fTime;
reply.fUser[0] = event->fUser[0];
reply.fUser[1] = event->fUser[1];
reply.fUser[2] = event->fUser[2];
reply.fUser[3] = event->fUser[3];
targets[0] = gVirtualX->InternAtom("TARGETS", kFALSE);
targets[1] = gVirtualX->InternAtom("XA_STRING", kFALSE);
if ((Atom_t)event->fUser[2] == targets[0]) {
type = gVirtualX->InternAtom("XA_ATOM", kFALSE);
gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
type, (UChar_t*) targets, (Int_t) 2);
gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
return kTRUE;
}
len = 0;
for (count = 0; count < fClipText->RowCount(); count++)
len += fClipText->GetLineLength(count)+1;
len--;
pos.fY = pos.fX = 0;
buffer = new char[len+1];
prev_len = temp_len = 0;
for (pos.fY = 0; pos.fY < fClipText->RowCount(); pos.fY++) {
temp_len = fClipText->GetLineLength(pos.fY);
temp_buffer = fClipText->GetLine(pos, temp_len);
strncpy(buffer+prev_len, temp_buffer, (UInt_t)temp_len);
if (pos.fY < fClipText->RowCount()-1) {
buffer[prev_len+temp_len] = 10;
prev_len += temp_len+1;
} else
prev_len += temp_len;
delete [] temp_buffer;
}
buffer[len] = '\0';
ULong_t i = 0;
while (buffer[i]) {
if (buffer[i] == '\t') {
ULong_t j = i + 1;
while (buffer[j] == 16 && buffer[j])
j++;
strcpy(buffer+i+1, buffer+j);
len -= j - i - 1;
}
i++;
}
gVirtualX->ChangeProperty((Window_t) event->fUser[0], (Atom_t) event->fUser[3],
(Atom_t) event->fUser[2], (UChar_t*) buffer,
(Int_t) len);
delete [] buffer;
gVirtualX->SendEvent((Window_t)event->fUser[0], &reply);
return kTRUE;
}
void TGTextView::Mark(Long_t xPos, Long_t yPos)
{
TGLongPosition posStart, posEnd, pos;
pos.fY = yPos;
pos.fX = xPos;
if (pos.fY > fText->RowCount()-1)
pos.fY = fText->RowCount()-1;
if (pos.fX > fText->GetLineLength(pos.fY))
pos.fX = fText->GetLineLength(pos.fY);
if (pos.fY < fMarkedStart.fY) {
posEnd.fY = fMarkedStart.fY;
if (fMarkedFromY == 1 || fMarkedFromX == 1) {
posEnd.fY = fMarkedEnd.fY;
fMarkedEnd.fX = fMarkedStart.fX;
fMarkedEnd.fY = fMarkedStart.fY;
}
posStart.fY = pos.fY;
fMarkedStart.fY = pos.fY;
fMarkedStart.fX = pos.fX;
fMarkedFromY = 0;
fMarkedFromX = 0;
} else if (pos.fY > fMarkedEnd.fY) {
posStart.fY = fMarkedEnd.fY;
if (fMarkedFromY == 0 || fMarkedFromX == 0) {
if (fMarkedStart.fY != fMarkedEnd.fY) {
posStart.fY = fMarkedStart.fY;
fMarkedStart.fX = fMarkedEnd.fX;
fMarkedStart.fY = fMarkedEnd.fY;
}
}
fMarkedEnd.fY = pos.fY;
fMarkedEnd.fX = pos.fX;
fMarkedFromY = 1;
fMarkedFromX = 1;
posEnd.fY = fMarkedEnd.fY;
} else {
if (pos.fX <= fMarkedStart.fX && pos.fY == fMarkedStart.fY) {
posEnd.fY = fMarkedStart.fY;
if (fMarkedFromY == 1 || fMarkedFromX == 1) {
posEnd.fY = fMarkedEnd.fY;
fMarkedEnd.fX = fMarkedStart.fX;
fMarkedEnd.fY = fMarkedStart.fY;
}
fMarkedStart.fX = pos.fX;
fMarkedFromY = 0;
fMarkedFromX = 0;
posStart.fY = fMarkedStart.fY;
} else {
if (pos.fX > fMarkedEnd.fX && pos.fY == fMarkedEnd.fY) {
posStart.fY = fMarkedEnd.fY;
if (fMarkedFromY == 0 || fMarkedFromX == 0) {
posStart.fY = fMarkedStart.fY;
fMarkedStart.fX = fMarkedEnd.fX;
fMarkedStart.fY = fMarkedEnd.fY;
}
fMarkedEnd.fX = pos.fX;
fMarkedFromY = 1;
fMarkedFromX = 1;
posEnd.fY = fMarkedEnd.fY;
} else {
if (fMarkedFromY == 0 || fMarkedFromX == 0) {
posStart.fY = fMarkedStart.fY;
fMarkedStart.fY = pos.fY;
fMarkedStart.fX = pos.fX;
posEnd.fY = fMarkedStart.fY;
fMarkedFromX = 0;
if (fMarkedStart.fY == fMarkedEnd.fY &&
fMarkedStart.fX > fMarkedEnd.fX) {
fMarkedStart.fX = fMarkedEnd.fX;
fMarkedEnd.fX = pos.fX;
fMarkedFromX = 1;
}
} else if (fMarkedFromX == 1 || fMarkedFromY == 1) {
posStart.fY = pos.fY;
posEnd.fY = fMarkedEnd.fY;
fMarkedEnd.fY = pos.fY;
fMarkedEnd.fX = pos.fX;
fMarkedFromY = 1;
fMarkedFromX = 1;
if (fMarkedEnd.fX == -1) {
fMarkedEnd.fY = pos.fY-1;
fMarkedEnd.fX = fText->GetLineLength(fMarkedEnd.fY);
if (fMarkedEnd.fX < 0)
fMarkedEnd.fX = 0;
}
fMarkedFromX = 1;
if (fMarkedStart.fY == fMarkedEnd.fY &&
fMarkedStart.fX > fMarkedEnd.fX) {
fMarkedEnd.fX = fMarkedStart.fX;
fMarkedStart.fX = pos.fX;
fMarkedFromX = 0;
}
}
}
}
}
if (fMarkedEnd.fX == -1) {
if (fMarkedEnd.fY > 0)
fMarkedEnd.fY--;
fMarkedEnd.fX = fText->GetLineLength(fMarkedEnd.fY);
if (fMarkedEnd.fX < 0)
fMarkedEnd.fX = 0;
}
DrawRegion(0, (Int_t)ToScrYCoord(posStart.fY), fCanvas->GetWidth(),
UInt_t(ToScrYCoord(posEnd.fY+1)-ToScrYCoord(posStart.fY)));
return;
}
void TGTextView::UnMark()
{
fIsMarked = kFALSE;
gVirtualX->ClearWindow(fCanvas->GetId());
DrawRegion(0, 0, fCanvas->GetWidth(), fCanvas->GetHeight());
}
void TGTextView::AdjustWidth()
{
Long_t line = fText->GetLongestLine();
if (line <= 0)
return;
Long_t size = ToScrXCoord(fText->GetLineLength(line), line) + fVisible.fX;
if (fVsb->IsMapped())
size += fVsb->GetDefaultWidth();
size += (fBorderWidth << 1) + fXMargin+1;
Resize((UInt_t)size, fHeight);
}
FontStruct_t TGTextView::GetDefaultFontStruct()
{
if (!fgDefaultFont)
fgDefaultFont = gClient->GetResourcePool()->GetDocumentFixedFont();
return fgDefaultFont->GetFontStruct();
}
const TGGC &TGTextView::GetDefaultGC()
{
if (!fgDefaultGC) {
fgDefaultGC = new TGGC(*gClient->GetResourcePool()->GetFrameGC());
fgDefaultGC->SetFont(fgDefaultFont->GetFontHandle());
}
return *fgDefaultGC;
}
const TGGC &TGTextView::GetDefaultSelectedGC()
{
if (!fgDefaultSelectedGC) {
fgDefaultSelectedGC = new TGGC(*gClient->GetResourcePool()->GetSelectedGC());
fgDefaultSelectedGC->SetFont(fgDefaultFont->GetFontHandle());
}
return *fgDefaultSelectedGC;
}
const TGGC &TGTextView::GetDefaultSelectedBackgroundGC()
{
if (!fgDefaultSelectedBackgroundGC)
fgDefaultSelectedBackgroundGC = gClient->GetResourcePool()->GetSelectedBckgndGC();
return *fgDefaultSelectedBackgroundGC;
}
void TGTextView::SavePrimitive(ostream &out, Option_t * )
{
char quote = '"';
out << " TGTextView *";
out << GetName() << " = new TGTextView(" << fParent->GetName()
<< "," << GetWidth() << "," << GetHeight()
<< ");"<< endl;
if (fCanvas->GetBackground() != TGFrame::fgWhitePixel) {
out << " " << GetName() << "->ChangeBackground(" << fCanvas->GetBackground() << ");" << endl;
}
TGText *txt = GetText();
Bool_t fromfile = strlen(txt->GetFileName()) ? kTRUE : kFALSE;
char fn[kMAXPATHLEN];
if (fromfile) {
const char *filename = txt->GetFileName();
sprintf(fn, gSystem->ExpandPathName(gSystem->UnixPathName(filename)));
} else {
sprintf(fn,"Txt%s",GetName()+5);
txt->Save(fn);
}
out << " " << GetName() << "->LoadFile(" << quote << fn << quote << ");" << endl;
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.