This macro gives an example of how to create different kind of labels and the possibility to enable/disable them.
To run it do either:
.x guilabels.C
.x guilabels.C++
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);
}
- Author
- Ilka Antcheva 1/12/2006
Definition in file guilabels.C.