What is the correct sequence of calls to change the color of a TGLabel font?
Chris
Hi Chris,
If the label was already created, you can use:
ULong_t color;
gClient->GetColorByName("blue", color);
lbl3->SetTextColor(color);
If you want to create a label with different color, font, background, the code is: TGGC *fTextGC;
const TGFont *font = gClient->GetFont("-*-times-bold-r-*-*-18-*-*-*-*-*-*-*");
if (!font)
font = gClient->GetResourcePool()->GetDefaultFont();
FontStruct_t labelfont = font->GetFontStruct();
GCValues_t gval;
gval.fMask = kGCBackground | kGCFont | kGCForeground; //define what will be changed
gval.fFont = font->GetFontHandle();
gClient->GetColorByName("red", gval.fBackground);
fTextGC = gClient->GetGC(&gval, kTRUE);
lbl = new TGLabel(fMain, "HasBackground", fTextGC->GetGC(),
labelfont, kChildFrame, color);
lbl->SetTextColor(color);
Cheers, Ilka
Thanks for the code snippet!
Regards
Chris