This macro gives an example for changing text button labels anytime the Start or Pause buttons are clicked.
private:
public:
virtual ~MyMainFrame();
void ChangeStartLabel();
void ChangePauseLabel();
};
void MyMainFrame::ChangeStartLabel()
{
if (!start) {
fStart->SetText("&Stop");
} else {
fStart->SetText("&Start");
}
}
void MyMainFrame::ChangePauseLabel()
{
if (!pause) {
fPause->SetText("&Resume");
} else {
fPause->SetText("&Pause");
}
}
{
fStart->Connect("Clicked()", "MyMainFrame", this, "ChangeStartLabel()");
3, 2, 2, 2));
fStart->SetToolTipText("Click to toggle the button label (Start/Stop)");
fPause->Connect("Clicked()", "MyMainFrame", this, "ChangePauseLabel()");
fPause->SetToolTipText("Click to toggle the button label (Pause/Resume)");
3, 2, 2, 2));
fExit =
new TGTextButton(
this,
"&Exit ",
"gApplication->Terminate(0)");
SetWindowName("Change Labels");
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
fCframe->Cleanup();
Cleanup();
}
void buttonChangelabel()
{
new MyMainFrame(
gClient->GetRoot(), 350, 80);
}
#define ClassDef(name, id)
The base class for composite widgets (menu bars, list boxes, etc.).
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.