Creating a status bar

From: <matthew.a.barker_at_nexiasolutions.com>
Date: Tue, 23 Jan 2007 11:28:28 +0000


Folks,

I have two TRootEmbeddedCanvas objects inside a TGMainFrame. I am trying to create a status bar on the TGMainFrame that mimics the behaviour of the status bar provided in TCanvas. So I want the status bar to display the information relating to (for example) histograms which are drawn on separate pads -- the pads are drawn on the TCanvas that is owned by the TRootEmbeddedCanvas. At the moment I have the code below. However, the problem is that the x and y positions passed to ExecEvent refer to the underlying canvas -- rather than the pad on which the selected object exists. This means that the line
fStatusBar->SetText(selected->GetObjectInfo(x,y),3); yields meaningless information because the x and y do not refer to the correct coordinate system.

How do I obtain the position in the pad that the selected object is in?

Matthew Barker

ResalGUI::ResalGUI(){
...

   ECan1 = new TRootEmbeddedCanvas(0,MainFrame,340,180); // MainFrame is the TGMainFrame

   Can1 = ECan1->GetCanvas();
   MainFrame->AddFrame(ECan1, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY,5,5,5,5));

   ECan2 = new TRootEmbeddedCanvas(0,MainFrame,340,180);    MainFrame->AddFrame(ECan2, new TGLayoutHints(kLHintsLeft | kLHintsTop | kLHintsExpandX | kLHintsExpandY,5,5,5,5));

   Can2 = ECan2->GetCanvas();  

   Can1->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "ResalGUI", 
this, "ExecEvent(Int_t,Int_t,Int_t,TObject*)");
   Can2->Connect("ProcessedEvent(Int_t,Int_t,Int_t,TObject*)", "ResalGUI", 
this, "ExecEvent(Int_t,Int_t,Int_t,TObject*)");
...
}

void ResalGUI::ExecEvent(Int_t event, Int_t x, Int_t y, TObject *selected) {

   TCanvas *c = (TCanvas *) gTQSender;
   const Int_t kTMAX=256;
   static char atext[kTMAX];

   fStatusBar->SetText(selected->GetTitle(),0); //fStatusbar is my status bar, embedded into the TMainFrame

   fStatusBar->SetText(selected->GetName(),1);    if (event == kKeyPress)

      sprintf(atext, "%c", (char) x);
   else

      sprintf(atext, "%d,%d", x, y);
   fStatusBar->SetText(atext,2);
   fStatusBar->SetText(selected->GetObjectInfo(x,y),3);
}

The information contained in this email may be commercially sensitive and/or legally privileged. It is intended solely for the person(s) to whom it is addressed. If you are not a named recipient, you are on notice of its status. Please notify the sender immediately by reply e-mail and then delete this message from your system. You must not disclose it to any other person, copy or distribute it or use it for any purpose. Received on Tue Jan 23 2007 - 12:29:05 CET

This archive was generated by hypermail 2.2.0 : Tue Jan 23 2007 - 17:50:00 CET