Re: [ROOT] auto-wrapping

From: Olivier Couet (Olivier.Couet@cern.ch)
Date: Mon Apr 19 2004 - 10:53:43 MEST


Hi,

TLatex support the text splitting. Try:

{
   gROOT->Reset();
   TCanvas *c1 = new TCanvas("c1","splittext",600,600);
   TLatex l(0.5,0.5,"#splitline{First line}{Second line}");            
   l.SetTextFont(42); l.SetTextSize(0.05);
   l.Draw();
}

I have tried the following example to simulate the seg fault you get with 
long text but for me it work (ROOT 4.00/03 on linux)

{
   gROOT->Reset();
   TCanvas *c1 = new TCanvas("c1","longtext",600,600);
   TText t(0.1,0.5,"ABCDEFGHIJKLMNOPQRSTUVWXYZ
abcdefghijklmnopqrstuvwxyz0123456789      
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
   t.SetTextFont(42); t.SetTextSize(0.015); 
   t.Draw();
}

Cheers,  Olivier


On Fri, 16 Apr 2004, Bernd REINHOLD wrote:

> Hi!
> 
> I'd like to display a TText within a TPad. But the TText is bigger than 
> TPad. Is there something like an option 'auto-wrap'? Does TText display 
> text only in one line? Is there a multiple-line version of TText? 
> I tried to use TPaveText, also, but didn't succeed. (see below for the 
> code I used, probably you can give me some hints for improvement)
> 
> And: Is there a limit for the length of the (C)string, that TText can 
> take (I got a segmentation violation) with a longer Cstring.
> 
> I use root 3.10.02 an CERN RedHat 7.3...
> 
> 
> the code: I tried different variations of that...
> SQL_Date is a subpad of a canvas (this works)
> 	TPad *SQL_Date = new TPad("SQL_Date", "SQL and date",.02,.3,.98,.49);
> 	SQL_Date->Draw();	
> 	SQL_Date->cd();
> 
> 	TPaveText *SQLLabel=new TPaveText(.02,.02,.98,.98, "NDC");
> 	TText *t1= SQLLabel->AddText(strSQLstring.c_str());
> 	t1->SetTextSize(0.07);
> 	SQLLabel->Draw();
> 	t1->Draw();
> 	SQL_Date->Update();
> 	SQL_Date->Modified();
> 	c1->Update();
> 
> found now, that this might be due to the textColor (white!!!). Now I can 
> see the t1, but still it is a TText, still it's only one line...
> 
> another try:
> 	TPad *SQL_Date = new TPad("SQL_Date", "SQL and date",.02,.3,.98,.49);
> 	SQL_Date->Draw();	
> 	SQL_Date->cd();
> 
> 	TText* Comment=new TText(0.04,0.2, strComment.c_str());
> 	Comment->SetTextSize(0.07);
> 	Comment->Draw();
> 	SQL_Date->Modified();
> 	c1->Update();
> 
> this drew both SQL_Date and inside the Comment, but it was too long (no 
> auto-wrap)
> 
> 

-- 
Org:    CERN - European Laboratory for Particle Physics.
Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910      
E-Mail: Olivier.Couet@cern.ch                            Phone:   +41 22 7676522
WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7677155



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET