Re: [ROOT] Trouble with TGLabel and different fonts...

From: Fons Rademakers (Fons.Rademakers@cern.ch)
Date: Thu Mar 21 2002 - 20:36:05 MET


Hi Andreas,

  it is not very nice (mix of GC and fontstruct) but this is the way to
solve your problem:

change the *** new *** part to:
   FontStruct_t myfont =
gClient->GetFontByName("-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1");
  TGGC* myGC = new TGGC(TGLabel::GetDefaultGC());
  myGC->SetFont(gVirtualX->GetFontHandle(myfont));

and change the label creation to:

fLabel[i] = new TGLabel(fF[i], numlabel[i], myGC->GetGC(), myfont);

the problem is that the label size calculation is done using the myfont
FontStruct_t without looking into the GC if the font was specified
there, so they need to be specified both. Will be streamlined in the
future but the above recipe should always work.

Cheers, Fons.





On Wed, 2002-03-20 at 16:41, Andreas Zoglauer wrote:
> 
> Hello!
> 
> I tried to exchange the standard font of the TGLabel and realized, that it
> is no longer completely displayed on the screen (the last letters are
> truncated).
> 
> Is there any command which recalculates the size of the Label?
> - Layout() does not seem to work, nor MapSubwindows()...
> 
> 
> In order to illustrate the problem, I have modified the constructor of the
> class EntryTestDlg of the guitest.cxx example program provided with ROOT:
> 
> ____________________________________________________________________________
> 
> EntryTestDlg::EntryTestDlg(const TGWindow * p, const TGWindow * main)
>  : TGTransientFrame(p, main, 10, 10, kHorizontalFrame)
> {
>   // *** new ***
>   TGGC* myGC = new TGGC(TGLabel::GetDefaultGC());
>   myGC->SetFont(gVirtualX->GetFontHandle(gClient->GetFontByName(
>      "-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1")));
>   // *** end new ***
> 
>    fF1 = new TGVerticalFrame(this, 200, 300);
>    fL1 = new TGLayoutHints(kLHintsTop | kLHintsLeft, 2, 2, 2, 2);
>    AddFrame(fF1, fL1);
>    // *** modified ***
>    fL2 = new TGLayoutHints(kLHintsCenterY | kLHintsLeft, 2, 2, 2, 2);
>    // Orig: fL2 = new TGLayoutHints(kLHintsCenterY | kLHintsRight, 2, 2, 2, 2);
>    // *** end modified
>    for (int i = 0; i < 13; i++) {
>       fF[i] = new TGHorizontalFrame(fF1, 200, 30);
>       fF1->AddFrame(fF[i], fL2);
>       fNumericEntries[i] = new TGNumberEntry(fF[i], numinit[i], 12, i +
>          20, (TGNumberFormat::EStyle) i);
>       fNumericEntries[i]->Associate(this);
>       fF[i]->AddFrame(fNumericEntries[i], fL2);
>       // *** modified ***
>       fLabel[i] = new TGLabel(fF[i], numlabel[i], myGC->GetGC());
>       // Orig: fLabel[i] = new TGLabel(fF[i], numlabel[i]);
>       // *** end modified
>       fF[i]->AddFrame(fLabel[i], fL2);
>    }
> 
>   // no modifications ...
> 
> }
> ______________________________________________________________________
> 
> 
> When opening the Number entry test, all labels are bold, but the last
> letters are truncated.
> 
> Any ideas to prevent this?
> 
> Andreas
> 
> OS: SuSE Linux 7.3
> ROOT: 3.03/02
> 
> 
> ----------------------------------------------------------------------
> Andreas Zoglauer
> 
> MPI fuer extraterrestrische Physik         Phone:    +49/89-30000-3848
> Postfach 1312                              Fax:      +49/89-30000-3569
> 85741 Garching, Germany                    Email:    zog@mpe.mpg.de
> ----------------------------------------------------------------------
-- 
Org:    CERN, European Laboratory for Particle Physics.
Mail:   1211 Geneve 23, Switzerland
E-Mail: Fons.Rademakers@cern.ch              Phone: +41 22 7679248
WWW:    http://root.cern.ch/~rdm/            Fax:   +41 22 7679480



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:46 MET