Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CanvasViewer.cxx

Go to the documentation of this file.
00001 #include "CanvasViewer.h"
00002 
00003 #include <TGFrame.h>
00004 #include <TRootEmbeddedCanvas.h>
00005 #include <TGTab.h>
00006 #include <TApplication.h>
00007 
00008 
00009 CanvasTab::CanvasTab() {}
00010 CanvasTab::~CanvasTab() {}
00011 
00012 void CanvasTab::Init(TCanvas* /*canvas*/)
00013 {
00014     //cerr << "CanvasTab::Init()\n";
00015 }
00016 void CanvasTab::Expose()
00017 {
00018     //cerr << "CanvasTab::Expose()\n";
00019 }
00020 
00021 
00022 CanvasTabs::CanvasTabs(TGCompositeFrame* parent)
00023 {
00024     fParent = parent;
00025     fTab = new TGTab(parent,800,800);
00026     TGLayoutHints *lh = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |
00027                                           kLHintsExpandY, 2, 2, 5, 1);
00028     parent->AddFrame(fTab, lh);
00029     
00030     fTab->Connect("Selected(Int_t)", "CanvasTabs", this, "DoTab(Int_t)");
00031 
00032 }
00033 
00034 void CanvasTabs::AdoptTab(const char* label, CanvasTab* ctab)
00035 {
00036     TGCompositeFrame *tf = fTab->AddTab(label);
00037     
00038     TGCompositeFrame *cf = new TGCompositeFrame(tf, 800, 800, kVerticalFrame);
00039     
00040     TGLayoutHints* lh = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX |
00041                                           kLHintsExpandY, 5, 5, 5, 5);
00042     
00043     TRootEmbeddedCanvas *rec = new TRootEmbeddedCanvas(label, cf, 800,800);
00044     cf->AddFrame(rec,lh);
00045     tf->AddFrame(cf,lh);
00046     
00047     fTab->Layout();
00048     
00049     TCanvas* can = rec->GetCanvas();
00050     can->cd();
00051     ctab->Init(can);
00052     fCTabs.push_back(ctab);
00053     
00054     //fTab->MapSubwindows();
00055     //fTab->Layout();
00056     
00057     fParent->Resize(800,800);
00058     //fParent->Layout();
00059     fParent->MapSubwindows();
00060 }
00061 
00062 void CanvasTabs::DoTab(Int_t tab) 
00063 {
00064     fCTabs[tab]->Expose();
00065 }
00066 
00067 CanvasViewer::CanvasViewer()
00068 {
00069     fMain   = new TGMainFrame(0, 800,800);
00070     fMain->SetCleanup(kDeepCleanup);
00071     fMain->Connect("CloseWindow()", "CanvasViewer", this, "CloseWindow()");
00072     
00073     fMain->SetWindowName("MINOS Canvas Viewer");
00074     
00075     fCTabs = new CanvasTabs(fMain);
00076 
00077     fMain->Resize(800,800);
00078     fMain->Layout();
00079     fMain->MapSubwindows();
00080     fMain->MapWindow();
00081     
00082     //fMain->Print();
00083 }
00084 
00085 void CanvasViewer::CloseWindow() 
00086 {
00087     gApplication->Terminate();
00088 }
00089 

Generated on Mon Feb 15 11:06:30 2010 for loon by  doxygen 1.3.9.1