Get StatusBar object

Hi ROOTers

I am trying to use a status bar to display some information. I have a small problem. I do not know how to get the status bar after I created. This is what I am trying to do:

[code]
APIanalyzer::APIanalyzer(const TGWindow *p,UInt_t w,UInt_t h,int argc, char **argv)
: TGMainFrame(p,w,h),defaultMacFileName(“RequestList.APImac”) {

// Creates widgets of the example
fEcanvas = new TRootEmbeddedCanvas (“Ecanvas”,this,1000,800);
this->AddFrame(fEcanvas, new TGLayoutHints(kLHintsExpandX |
kLHintsExpandY,10,10,10,1));

TGHorizontalFrame *hframe=new TGHorizontalFrame(this, 200,40);

TGTextButton *draw = new TGTextButton(hframe,"&Test");
draw->Connect(“Clicked()”,“APIanalyzer”,this,“Test()”);
hframe->AddFrame(draw, new TGLayoutHints(kLHintsCenterX,5,5,3,4));

//This next draws all the buttons
this->AddFrame(hframe,new TGLayoutHints(kLHintsCenterX,2,2,2,2));

int parts[]={60,20,20};
TGStatusBar *fStatusBar = new TGStatusBar(this,50,10,kHorizontalFrame);
fStatusBar->SetParts(parts,sizeof(parts)/sizeof(parts[0]));
this->AddFrame(fStatusBar,new TGLayoutHints(kLHintsBottom | kLHintsLeft | kLHintsExpandX,0,0,2,0));

fStatusBar->SetText(“API Analysis software”,0);

// Sets window name and shows the main frame
this->SetWindowName(“API Pre-Analysis Plots”);
this->MapSubwindows();
this->Resize(GetDefaultSize());
this->MapWindow();
this->Connect(“CloseWindow()”, “APIanalyzer”, this, “DoExit()”);
this->DontCallClose();

APIanalyzer::DoAnalysisVME(argc,argv);
}

int APIanalyzer::DoAnalysisVME(int argc, char **argv){

///QUESTION HERE
fStatusBar->SetText("I don’t know how to access my object here :slight_smile: ",1);
fStatusBar->SetText("How could I retrive my statusBar??? :slight_smile: ",2);

//Could I do something like this->GetStatusBar()… ???

}

int main(int argc, char **argv){

TApplication theApp(“APIanalyzer”, &argc, argv);
APIanalyzer mainWindow(gClient->GetRoot(),600,500,theApp.Argc(),
theApp.Argv());

theApp.Run();
return 0;
}[/code]

Any comments are always really appreciated,
Kris

Hi,

You have to declare fStatusBar being a member of your APIanalyzer class, and add a getter (e.g. GetStatusBar()) returning a pointer to the status bar, as any other class member, or access the status bar directly from inside your class via its fStatusBar pointer…
e.g.[code]
class APIanalyzer : public TGMainFrame {
protected:
TGStatusBar *fStatusBar;
[…]

public:
[…]
TGStatusBar *GetStatusBar() const { return fStatusBar; }
}
[/code]

Cheers,
Bertrand.