This macro gives an example of how to create different kind of labels and the possibility to enable/disable them.
private:
TGLabel *fLbl1, *fLbl2, *fLbl3, *fLbl4;
public:
~MyMainFrame() override;
void DoExit();
void DoSwitch();
};
void MyMainFrame::DoSwitch()
{
if (fLbl1->IsDisabled()) {
printf("Enabled labels\n");
fLbl1->Enable();
fLbl2->Enable();
fLbl3->Enable();
fLbl4->Enable();
} else {
printf("Disabled labels\n");
fLbl1->Disable();
fLbl2->Disable();
fLbl3->Disable();
fLbl4->Disable();
}
}
void MyMainFrame::DoExit()
{
}
{
const TGFont *font =
gClient->GetFont(
"-*-times-bold-r-*-*-18-*-*-*-*-*-*-*");
if (!font)
font =
gClient->GetResourcePool()->GetDefaultFont();
gClient->GetColorByName(
"yellow", ycolor);
gClient->GetColorByName(
"blue", bcolor);
fLbl1 =
new TGLabel(
this,
"OwnFont & Bck/ForgrColor", fTextGC->
GetGC(),
fLbl1->SetTextColor(ycolor);
fLbl2 =
new TGLabel(
this,
"Own Font & ForegroundColor", fTextGC->
GetGC(),
labelfont);
fLbl2->SetTextColor(ycolor);
fLbl3 =
new TGLabel(
this,
"Normal Label");
fLbl4 =
new TGLabel(
this,
"Multi-line label, resized\nto 300x80 pixels",
fLbl4->SetTextColor(ycolor);
fLbl4->ChangeOptions(fLbl4->GetOptions() |
kFixedSize);
fLbl4->Resize(350, 80);
toggle->
Connect(
"Clicked()",
"MyMainFrame",
this,
"DoSwitch()");
toggle->
SetToolTipText(
"Click on the button to toggle label's state (enable/disable)");
exit->
Connect(
"Pressed()",
"MyMainFrame",
this,
"DoExit()");
SetWindowName("Labels");
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
Cleanup();
}
void guilabels()
{
new MyMainFrame(
gClient->GetRoot(), 200, 200);
}
const Mask_t kGCBackground
const Mask_t kGCForeground
Handle_t FontStruct_t
Pointer to font structure.
#define ClassDefOverride(name, id)
R__EXTERN TApplication * gApplication
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize MapSubwindows
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t gval
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
Encapsulate fonts used in the GUI system.
FontStruct_t GetFontStruct() const
FontH_t GetFontHandle() const
Encapsulate a graphics context used in the low level graphics.
This class handles GUI labels.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
Yield an action as soon as it is clicked.
ROOT GUI Window base class.
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Graphics context structure.