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:
virtual ~MyMainFrame();
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");
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
Cleanup();
}
void guilabels()
{
new MyMainFrame(
gClient->GetRoot(), 200, 200);
}
const Mask_t kGCBackground
const Mask_t kGCForeground
#define ClassDef(name, id)
R__EXTERN TApplication * gApplication
void Printf(const char *fmt,...)
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
FontStruct_t GetFontStruct() const
FontH_t GetFontHandle() const
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.