This macro gives an example of how to create a status bar related to an embedded canvas that shows the info of the selected object, exactly as the status bar of any canvas window.
private:
public:
~MyMainFrame() override;
void DoExit();
void DoDraw();
void SetStatusText(
const char *txt,
Int_t pi);
};
void MyMainFrame::DoDraw()
{
for (
Int_t i = 0; i <
n; i++) {
y[i] = 10 * sin(
x[i] + 0.2);
printf(
" i %i %f %f \n", i,
x[i],
y[i]);
}
gr->SetTitle(
"a simple graph");
gr->GetXaxis()->SetTitle(
"X title");
gr->GetYaxis()->SetTitle(
"Y title");
c1->GetFrame()->SetFillColor(21);
c1->GetFrame()->SetBorderSize(12);
}
void MyMainFrame::DoExit()
{
printf("Exit application...");
}
void MyMainFrame::SetStatusText(
const char *txt,
Int_t pi)
{
fStatusBar->SetText(txt, pi);
}
{
const char *text0, *text1, *text3;
char text2[50];
text0 = selected->GetTitle();
SetStatusText(text0, 0);
text1 = selected->GetName();
SetStatusText(text1, 1);
sprintf(text2, "%c", (char)px);
else
sprintf(text2, "%d,%d", px, py);
SetStatusText(text2, 2);
text3 = selected->GetObjectInfo(px, py);
SetStatusText(text3, 3);
}
{
Int_t wid = fEcan->GetCanvasWindowId();
fEcan->AdoptCanvas(myc);
myc->
Connect(
"ProcessedEvent(Int_t,Int_t,Int_t,TObject*)",
"MyMainFrame",
this,
"EventInfo(Int_t,Int_t,Int_t,TObject*)");
Int_t parts[] = {45, 15, 10, 30};
fStatusBar->SetParts(parts, 4);
fStatusBar->Draw3DCorner(
kFALSE);
draw->
Connect(
"Clicked()",
"MyMainFrame",
this,
"DoDraw()");
exit->
Connect(
"Pressed()",
"MyMainFrame",
this,
"DoExit()");
SetWindowName("Embedded Canvas Status Info");
MapSubwindows();
Resize(GetDefaultSize());
MapWindow();
}
MyMainFrame::~MyMainFrame()
{
Cleanup();
delete fEcan;
}
void statusBar()
{
new MyMainFrame(
gClient->GetRoot(), 200, 200);
}
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
double Double_t
Double 8 bytes.
#define ClassDefOverride(name, id)
externTApplication * gApplication
void Printf(const char *fmt,...)
Formats a string in a circular formatting buffer and prints the string.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
A composite frame that layout their children in horizontal way.
This class describes layout hints used by the layout classes.
Defines top level windows that interact with the system Window Manager.
Provides a StatusBar widget.
Yield an action as soon as it is clicked.
ROOT GUI Window base class.
Mother of all ROOT objects.
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.
This class creates a TGCanvas in which a TCanvas is created.