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", gval.fBackground);
gClient->GetColorByName(
"yellow", ycolor);
gClient->GetColorByName(
"blue", bcolor);
fLbl2 =
new TGLabel(
this,
"Own Font & ForegroundColor", fTextGC->
GetGC(), labelfont);
fLbl2->SetTextColor(ycolor);
fLbl3 =
new TGLabel(
this,
"Normal Label");
bcolor);
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");
MapSubwindows();
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.
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
#define ClassDefOverride(name, id)
externTApplication * gApplication
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
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.
virtual void SetTextColor(Pixel_t color, Bool_t global=kFALSE)
Changes text color.
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.
Mask_t fMask
bit mask specifying which fields are valid