TEveWindow.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveWindow.cxx 32138 2010-01-28 15:16:30Z matevz $
00002 // Author: Matevz Tadel 2007
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEveWindow.h"
00013 #include "TEveWindowManager.h"
00014 #include "TEveManager.h"
00015 #include "TEveSelection.h"
00016 
00017 #include "THashList.h"
00018 #include "TContextMenu.h"
00019 
00020 #include "TGButton.h"
00021 #include "TContextMenu.h"
00022 #include "TGMenu.h"
00023 #include "TGPack.h"
00024 #include "TGTab.h"
00025 
00026 #include <cassert>
00027 
00028 //==============================================================================
00029 //==============================================================================
00030 // CompositeFrame classes - slots for TEveWindows
00031 //==============================================================================
00032 //==============================================================================
00033 
00034 
00035 //==============================================================================
00036 // TEveCompositeFrame
00037 //==============================================================================
00038 
00039 //______________________________________________________________________________
00040 //
00041 // Abstract base-class for frame-slots that encompass EVE-windows
00042 // (sub-classes of TEveWindow).
00043 //
00044 // The EVE-frame classes are managed by their embedded EVE-windows and
00045 // mostly serve as an interface to particular ROOT widgets
00046 // (sub-classes of TGCompositeFrame) they are embedded into.
00047 //
00048 // This base-class, a sub-class of a vertical composite-frame, creates
00049 // also the title-bar which can be used to interact with the embedded
00050 // window. Optionally, the title-bar can be replaced with a mini-bar
00051 // (a 4-pixel thin bar at the top). By clicking on the mini-bar, the
00052 // title-bar is restored.
00053 //
00054 // Sub-classes provide for specific behaviour and expectations of
00055 // individual ROOT GUI container frames.
00056 //
00057 //
00058 // POSSIBLE EXTENSIONS
00059 //
00060 // No frame is drawn around this composite-frame - frame style could be
00061 // available as a (static) member.
00062 //
00063 // Menus of embedded windows could also be managed - hidden or transposed
00064 // to a top-level menubar.
00065 
00066 ClassImp(TEveCompositeFrame);
00067 
00068 TContextMenu* TEveCompositeFrame::fgCtxMenu = 0;
00069 
00070 const TString TEveCompositeFrame::fgkEmptyFrameName("<relinquished>");
00071 TList*        TEveCompositeFrame::fgFrameList = new THashList;
00072 
00073 TEveCompositeFrame::IconBarCreator_foo TEveCompositeFrame::fgIconBarCreator = 0;
00074 
00075 UInt_t             TEveCompositeFrame::fgTopFrameHeight        = 14;
00076 UInt_t             TEveCompositeFrame::fgMiniBarHeight         = 4;
00077 Bool_t             TEveCompositeFrame::fgAllowTopFrameCollapse = kTRUE;
00078 
00079 //______________________________________________________________________________
00080 void TEveCompositeFrame::SetupFrameMarkup(IconBarCreator_foo creator,
00081                                           UInt_t top_frame_height,
00082                                           UInt_t mini_bar_height,
00083                                           Bool_t allow_top_collapse)
00084 {
00085    // Set properties of the EVE frame.
00086    // Should be called before the windows are created.
00087 
00088    fgIconBarCreator        = creator;
00089    fgTopFrameHeight        = top_frame_height;
00090    fgMiniBarHeight         = mini_bar_height;
00091    fgAllowTopFrameCollapse = allow_top_collapse;
00092 }
00093 
00094 //______________________________________________________________________________
00095 TEveCompositeFrame::TEveCompositeFrame(TGCompositeFrame* parent,
00096                                        TEveWindow*   eve_parent) :
00097    TGCompositeFrame (parent, 0, 0, kVerticalFrame),
00098 
00099    fTopFrame    (0),
00100    fToggleBar   (0),
00101    fTitleBar    (0),
00102    fIconBar     (0),
00103    fEveWindowLH (0),
00104 
00105    fMiniBar     (0),
00106 
00107    fEveParent   (eve_parent),
00108    fEveWindow   (0),
00109 
00110    fShowInSync  (kTRUE)
00111 {
00112    // Constructor.
00113 
00114    fTopFrame = new TGHorizontalFrame(this, 20, fgTopFrameHeight);
00115 
00116    if (fgAllowTopFrameCollapse)
00117    {
00118       fToggleBar = new TGTextButton(fTopFrame, "Hide");
00119       fToggleBar->ChangeOptions(kRaisedFrame);
00120       fToggleBar->Resize(40, fgTopFrameHeight);
00121       fToggleBar->Connect("Clicked()", "TEveCompositeFrame", this, "FlipTitleBarState()");
00122       fTopFrame->AddFrame(fToggleBar, new TGLayoutHints(kLHintsNormal));
00123    }
00124 
00125    fTitleBar = new TGTextButton(fTopFrame, "Title Bar");
00126    fTitleBar->ChangeOptions(kRaisedFrame);
00127    fTitleBar->Resize(40, fgTopFrameHeight);
00128    fTitleBar->Connect("Clicked()", "TEveCompositeFrame", this, "TitleBarClicked()");
00129    fTopFrame->AddFrame(fTitleBar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
00130 
00131    if (fgIconBarCreator)
00132    {
00133       fIconBar = (fgIconBarCreator)(this, fTopFrame, fgTopFrameHeight);
00134    }
00135    else
00136    {
00137       TGButton* b = new TGTextButton(fTopFrame, "Actions");
00138       b->ChangeOptions(kRaisedFrame);
00139       b->Resize(40, fgTopFrameHeight);
00140       b->Connect("Pressed()", "TEveCompositeFrame", this, "ActionPressed()");
00141       fIconBar = b;
00142    }
00143    fTopFrame->AddFrame(fIconBar, new TGLayoutHints(kLHintsNormal));
00144 
00145    AddFrame(fTopFrame, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
00146 
00147    // --- MiniBar
00148    if (fgAllowTopFrameCollapse)
00149    {
00150       fMiniBar = new TGButton(this);
00151       fMiniBar->ChangeOptions(kRaisedFrame | kFixedHeight);
00152       fMiniBar->Resize(20, fgMiniBarHeight);
00153       fMiniBar->SetBackgroundColor(TEveWindow::GetMiniBarBackgroundColor());
00154       fMiniBar->Connect("Clicked()", "TEveCompositeFrame", this, "FlipTitleBarState()");
00155       AddFrame(fMiniBar, new TGLayoutHints(kLHintsNormal | kLHintsExpandX));
00156    }
00157 
00158    // --- Common settings.
00159 
00160    fTopFrame->SetCleanup(kLocalCleanup);
00161    SetCleanup(kLocalCleanup);
00162 
00163    MapSubwindows();
00164    HideFrame(fMiniBar);
00165    SetMapSubwindows(kFALSE);
00166 
00167    // Layout for embedded windows.
00168    fEveWindowLH = new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY);
00169 
00170    // !!! The following should actually be done somewhere else, in
00171    // some not-yet-existing static method of TEveWindow. Right now the
00172    // eve-frame-creation code is still a little bit everywhere.
00173    if (fEveParent == 0)
00174       fEveParent = gEve->GetWindowManager();
00175 
00176    fgFrameList->Add(this);
00177 }
00178 
00179 //______________________________________________________________________________
00180 TEveCompositeFrame::~TEveCompositeFrame()
00181 {
00182    // If fEveWindow != 0 we are being deleted from the ROOT GUI side.
00183    // Relinquishe EveWindow and ref-counting should do the rest.
00184 
00185    fgFrameList->Remove(this);
00186 
00187    if (fEveWindow != 0)
00188    {
00189       if (gDebug > 0)
00190          Info("TEveCompositeFrame::~TEveCompositeFrame",
00191               "EveWindow not null '%s', relinquishing it now.",
00192               fEveWindow->GetElementName());
00193 
00194       fEveWindow->ClearEveFrame();
00195       RelinquishEveWindow();
00196    }
00197 
00198    delete fEveWindowLH;
00199 }
00200 
00201 //==============================================================================
00202 
00203 //______________________________________________________________________________
00204 void TEveCompositeFrame::WindowNameChanged(const TString& name)
00205 {
00206    // Update widgets using window's name or title.
00207 
00208    fTitleBar->SetText(name);
00209 }
00210 
00211 //==============================================================================
00212 
00213 //______________________________________________________________________________
00214 void TEveCompositeFrame::AcquireEveWindow(TEveWindow* ew)
00215 {
00216    // Accept window and increase its deny-destroy count.
00217    // Window's gui-frame is embedded and mapped.
00218    // Layout is not called.
00219    //
00220    // Throws an exception if a window is already embedded or if 0 is
00221    // passed as an argument.
00222 
00223    // Replace current eve-window with the given one.
00224    // Current GUI window is unmapped, removed and reparented to default-root.
00225    // New GUI window is reparented to this, added and mapped.
00226 
00227    static const TEveException eh("TEveCompositeFrame::AcquireEveWindow ");
00228 
00229    if (fEveWindow)
00230       throw eh + "Window already set.";
00231 
00232    if (ew == 0)
00233       throw eh + "Called with 0 argument.";
00234 
00235    fEveWindow = ew;
00236 
00237    fEveWindow->IncDenyDestroy();
00238    TGFrame* gui_frame = fEveWindow->GetGUIFrame();
00239    gui_frame->ReparentWindow(this);
00240    AddFrame(gui_frame, fEveWindowLH);
00241    fEveWindow->PostDock();
00242    gui_frame->MapWindow();
00243 
00244    SetCurrent(fEveWindow->IsCurrent());
00245    SetShowTitleBar(fEveWindow->GetShowTitleBar());
00246    WindowNameChanged(fEveWindow->GetElementName());
00247 }
00248 
00249 //______________________________________________________________________________
00250 TEveWindow* TEveCompositeFrame::RelinquishEveWindow(Bool_t reparent)
00251 {
00252    // Remove window and decrease its deny-destroy count.
00253    // Window's gui-frame is unmapped, removed and, if reparent flag is
00254    // true (default), reparented to default-root.
00255 
00256    TEveWindow* ex_ew = fEveWindow;
00257 
00258    if (fEveWindow)
00259    {
00260       TGFrame* gui_frame = fEveWindow->GetGUIFrame();
00261       gui_frame->UnmapWindow();
00262       fEveWindow->PreUndock();
00263       RemoveFrame(gui_frame);
00264       if (reparent)
00265          gui_frame->ReparentWindow(fClient->GetDefaultRoot());
00266       fEveWindow->DecDenyDestroy();
00267       fEveWindow = 0;
00268       SetCurrent(kFALSE);
00269       WindowNameChanged(fgkEmptyFrameName);
00270    }
00271 
00272    return ex_ew;
00273 }
00274 
00275 //______________________________________________________________________________
00276 TEveWindow* TEveCompositeFrame::GetEveParentAsWindow() const
00277 {
00278    // Returns eve-parent dynamic-casted to TEveWindow.
00279 
00280    return dynamic_cast<TEveWindow*>(fEveParent);
00281 }
00282 
00283 //______________________________________________________________________________
00284 void TEveCompositeFrame::SetCurrent(Bool_t curr)
00285 {
00286    // Set current state of this frame.
00287    // This is called by the management functions in TEveWindow.
00288 
00289    if (curr) {
00290       fTitleBar->SetBackgroundColor(TEveWindow::GetCurrentBackgroundColor());
00291    } else {
00292       fTitleBar->SetBackgroundColor(GetDefaultFrameBackground());
00293    }
00294    fClient->NeedRedraw(fTitleBar);
00295 }
00296 
00297 //______________________________________________________________________________
00298 void TEveCompositeFrame::SetShowTitleBar(Bool_t show)
00299 {
00300    // Set state of title-bar. This toggles between the display of the full
00301    // title-bar and 4-pixel-high mini-bar.
00302 
00303    if (show) {
00304       HideFrame(fMiniBar);
00305       ShowFrame(fTopFrame);
00306    } else {
00307       HideFrame(fTopFrame);
00308       ShowFrame(fMiniBar);
00309    }
00310 
00311    fShowInSync = show == fEveWindow->GetShowTitleBar();
00312 }
00313 
00314 //______________________________________________________________________________
00315 void TEveCompositeFrame::HideAllDecorations()
00316 {
00317    // Hide title-bar and mini-bar.
00318 
00319    HideFrame(fTopFrame);
00320    HideFrame(fMiniBar);
00321 
00322    fShowInSync = kFALSE;
00323 }
00324 
00325 //______________________________________________________________________________
00326 void TEveCompositeFrame::ShowNormalDecorations()
00327 {
00328    // Show title-bar or mini-bar, as dictated by the window.
00329 
00330    SetShowTitleBar(fEveWindow->GetShowTitleBar());
00331 }
00332 
00333 //______________________________________________________________________________
00334 void TEveCompositeFrame::ActionPressed()
00335 {
00336    // The action-button of the title-bar was pressed.
00337    // This opens context menu of the eve-window.
00338 
00339    if (fgCtxMenu == 0) {
00340       fgCtxMenu = new TContextMenu("", "");
00341    }
00342 
00343    Int_t    x, y;
00344    UInt_t   w, h;
00345    Window_t childdum;
00346    gVirtualX->GetWindowSize(fIconBar->GetId(), x, y, w, h);
00347    gVirtualX->TranslateCoordinates(fIconBar->GetId(),
00348                                    gClient->GetDefaultRoot()->GetId(),
00349                                    0, 0, x, y, childdum);
00350 
00351    fgCtxMenu->Popup(x - 2, y + h - 2, fEveWindow);
00352 }
00353 
00354 //______________________________________________________________________________
00355 void TEveCompositeFrame::FlipTitleBarState()
00356 {
00357    // Change display-state of the title-bar / mini-bar.
00358    // This function is used as a slot and passes the call to eve-window.
00359 
00360    if (fShowInSync)
00361       fEveWindow->FlipShowTitleBar();
00362    else
00363       SetShowTitleBar(fEveWindow->GetShowTitleBar());
00364 }
00365 
00366 //______________________________________________________________________________
00367 void TEveCompositeFrame::TitleBarClicked()
00368 {
00369    // Slot for mouse-click on the central part of the title-bar.
00370    // The call is passed to eve-window.
00371 
00372    fEveWindow->TitleBarClicked();
00373 }
00374 
00375 
00376 //==============================================================================
00377 // TEveCompositeFrameInMainFrame
00378 //==============================================================================
00379 
00380 //______________________________________________________________________________
00381 //
00382 // An EVE window-slot contained within a TGMainFrame.
00383 
00384 ClassImp(TEveCompositeFrameInMainFrame);
00385 
00386 //______________________________________________________________________________
00387 TEveCompositeFrameInMainFrame::TEveCompositeFrameInMainFrame(TGCompositeFrame* parent,
00388                                                              TEveWindow*  eve_parent,
00389                                                              TGMainFrame* mf) :
00390    TEveCompositeFrame(parent, eve_parent),
00391    fMainFrame         (mf),
00392    fOriginalSlot      (0),
00393    fOriginalContainer (0)
00394 {
00395    // Constructor.
00396 
00397    fMainFrame->Connect("CloseWindow()", "TEveCompositeFrameInMainFrame", this, "MainFrameClosed()");
00398    gEve->GetWindowManager()->Connect("WindowDeleted(TEveWindow*)", "TEveCompositeFrameInMainFrame", this, "SomeWindowClosed(TEveWindow*)");
00399 }
00400 
00401 //______________________________________________________________________________
00402 TEveCompositeFrameInMainFrame::~TEveCompositeFrameInMainFrame()
00403 {
00404    // Destructor.
00405 
00406    if (gDebug > 0)
00407       Info("~TEveCompositeFrameInMainFrame", "Destructor.");
00408 
00409    // MainFrames get deleted with a time-out. So, during EVE manager
00410    // shutdown, it might happen that this gets called when gEve is null.
00411    if (gEve && gEve->GetWindowManager())
00412    {
00413       gEve->GetWindowManager()->Disconnect("WindowDeleted(TEveWindow*)", this, "SomeWindowClosed(TEveWindow*)");
00414    }
00415    else
00416    {
00417       Info("~TEveCompositeFrameInMainFrame", "gEve null - OK if it was terminated.");
00418    }
00419 }
00420 
00421 //______________________________________________________________________________
00422 void TEveCompositeFrameInMainFrame::WindowNameChanged(const TString& name)
00423 {
00424    // Update widgets using window's name or title.
00425 
00426    fMainFrame->SetWindowName(name);
00427 
00428    TEveCompositeFrame::WindowNameChanged(name);
00429 }
00430 
00431 //______________________________________________________________________________
00432 void TEveCompositeFrameInMainFrame::Destroy()
00433 {
00434    // Virtual function called from eve side when the frame should be
00435    // destroyed. This means we expect that fEveWindow is null.
00436    //
00437    // We simply call CloseWindow() on the main-frame which will in
00438    // turn generate the "CloseWindow()" signal.
00439    // This is then handled in MainFrameClosed().
00440 
00441    if (gDebug > 0)
00442       Info("TEveCompositeFrameInMainFrame::Destroy()",
00443            "Propagating call to main-frame.");
00444 
00445    assert (fEveWindow == 0);
00446 
00447    fMainFrame->CloseWindow();
00448 }
00449 
00450 //______________________________________________________________________________
00451 void TEveCompositeFrameInMainFrame::SetOriginalSlotAndContainer(TEveWindow* slot,
00452                                                                 TEveWindow* container)
00453 {
00454    // Set the container where to return the contained window on destruction.
00455 
00456    static const TEveException kEH("TEveCompositeFrameInMainFrame::SetOriginalSlotAndContainer ");
00457 
00458    if (container && ! container->CanMakeNewSlots())
00459       throw kEH + "Given window can not make new slots.";
00460 
00461    fOriginalSlot      = slot;
00462    fOriginalContainer = container;
00463 }
00464 
00465 //______________________________________________________________________________
00466 void TEveCompositeFrameInMainFrame::SomeWindowClosed(TEveWindow* w)
00467 {
00468    // Slot called when a window is closed ... we check that this was
00469    // not our original container.
00470 
00471    if (w == fOriginalSlot)
00472       fOriginalSlot = 0;
00473 
00474    if (w == fOriginalContainer)
00475       fOriginalContainer = 0;
00476 }
00477 
00478 //______________________________________________________________________________
00479 void TEveCompositeFrameInMainFrame::MainFrameClosed()
00480 {
00481    // Slot for main-frame's "CloseWindow()" signal.
00482    // If an eve window is still present, it will be put into:
00483    //   - original-container, if it is set;
00484    ///  - into window-managers default-container.
00485 
00486    if (fEveWindow != 0)
00487    {
00488       TEveWindow* swapCandidate = 0;
00489       if (fOriginalSlot)
00490       {
00491          // if use pack, show hidden slot
00492          TEveCompositeFrameInPack* packFrame = dynamic_cast<TEveCompositeFrameInPack*>(fOriginalSlot->GetEveFrame());
00493          if (packFrame) {
00494             TGPack* pack = (TGPack*)(packFrame->GetParent());
00495             pack->ShowFrame(packFrame);
00496          }
00497          swapCandidate = fOriginalSlot;
00498       }
00499       else if (fOriginalContainer)
00500       {
00501          swapCandidate = fOriginalContainer->NewSlot();
00502       }
00503       else if (gEve->GetWindowManager()->HasDefaultContainer())
00504       {
00505          swapCandidate =  gEve->GetWindowManager()->GetDefaultContainer()->NewSlot();
00506       }
00507 
00508       if (swapCandidate)
00509       {
00510          TEveWindow::SwapWindows(fEveWindow, swapCandidate);
00511          gEve->GetWindowManager()->WindowDocked(fEveWindow );
00512       }
00513    }
00514 
00515    fMainFrame->DontCallClose();
00516 
00517    if (fEveWindow != 0)
00518       fEveWindow->DestroyWindowAndSlot();
00519 
00520    if (gDebug > 0)
00521       Info("TEveCompositeFrameInMainFrame::MainFrameClosed()",
00522            "Expecting destructor call soon.");
00523 }
00524 
00525 
00526 //==============================================================================
00527 // TEveCompositeFrameInPack
00528 //==============================================================================
00529 
00530 //______________________________________________________________________________
00531 //
00532 // An EVE window-slot contained within one frame of a TGPack.
00533 
00534 ClassImp(TEveCompositeFrameInPack);
00535 
00536 //______________________________________________________________________________
00537 TEveCompositeFrameInPack::TEveCompositeFrameInPack(TGCompositeFrame* parent,
00538                                                    TEveWindow* eve_parent,
00539                                                    TGPack*     pack) :
00540    TEveCompositeFrame(parent, eve_parent),
00541    fPack (pack)
00542 {
00543    // Constructor.
00544 }
00545 
00546 //______________________________________________________________________________
00547 TEveCompositeFrameInPack::~TEveCompositeFrameInPack()
00548 {
00549    // Destructor.
00550 }
00551 
00552 //______________________________________________________________________________
00553 void TEveCompositeFrameInPack::Destroy()
00554 {
00555    // Virtual function called from eve side when the frame should be
00556    // destroyed. This means we expect that fEveWindow is null.
00557    //
00558    // Remove the frame from pack and delete it.
00559 
00560    if (gDebug > 0)
00561       Info("TEveCompositeFrameInPack::Destroy()", "Removing from pack and deleting.");
00562 
00563    assert(fEveWindow == 0);
00564 
00565    fPack->RemoveFrame(this);
00566    delete this;
00567 }
00568 
00569 //==============================================================================
00570 // TEveCompositeFrameInTab
00571 //==============================================================================
00572 
00573 //______________________________________________________________________________
00574 //
00575 // An EVE window-slot contained within one tab of a TGTab.
00576 
00577 ClassImp(TEveCompositeFrameInTab);
00578 
00579 //______________________________________________________________________________
00580 TEveCompositeFrameInTab::TEveCompositeFrameInTab(TGCompositeFrame* parent,
00581                                                  TEveWindow* eve_parent,
00582                                                  TGTab*      tab) :
00583    TEveCompositeFrame(parent, eve_parent),
00584    fTab         (tab),
00585    fParentInTab (parent)
00586 {
00587    // Constructor.
00588 }
00589 
00590 //______________________________________________________________________________
00591 TEveCompositeFrameInTab::~TEveCompositeFrameInTab()
00592 {
00593    // Destructor.
00594 }
00595 
00596 //______________________________________________________________________________
00597 void TEveCompositeFrameInTab::WindowNameChanged(const TString& name)
00598 {
00599    // Update widgets using window's name or title.
00600 
00601    Int_t t = FindTabIndex();
00602    fTab->GetTabTab(t)->SetText(new TGString(name));
00603    fTab->Layout();
00604 
00605    TEveCompositeFrame::WindowNameChanged(name);
00606 }
00607 
00608 //______________________________________________________________________________
00609 Int_t TEveCompositeFrameInTab::FindTabIndex()
00610 {
00611    // Return index of this frame in the tab.
00612    // Throws an exception if it is not found.
00613 
00614    static const TEveException eh("TEveCompositeFrameInTab::FindTabIndex ");
00615 
00616    Int_t nt = fTab->GetNumberOfTabs();
00617    for (Int_t t = 0; t < nt; ++t)
00618    {
00619       if (fTab->GetTabContainer(t) == fParentInTab)
00620       {
00621          return t;
00622       }
00623    }
00624 
00625    throw eh + "parent frame not found in tab.";
00626 }
00627 
00628 //______________________________________________________________________________
00629 void TEveCompositeFrameInTab::Destroy()
00630 {
00631    // Virtual function called from eve side when the frame should be
00632    // destroyed. This means we expect that fEveWindow is null.
00633    //
00634    // Remove the frame from tab and delete it.
00635 
00636    if (gDebug > 0)
00637       Info("TEveCompositeFrameInTab::Destroy()", "Removing from tab and deleting.");
00638 
00639    assert (fEveWindow == 0);
00640 
00641    Int_t t = FindTabIndex();
00642 
00643    // disconnect form Removed() if / when connected
00644    fTab->RemoveTab(t, kFALSE);
00645    fParentInTab->DestroyWindow();
00646    fParentInTab->SetCleanup(kNoCleanup);
00647    delete fParentInTab;
00648    delete this;
00649 }
00650 
00651 //______________________________________________________________________________
00652 void TEveCompositeFrameInTab::SetCurrent(Bool_t curr)
00653 {
00654    // Set current state of this frame.
00655    // Virtual from TEveCompositeFrame.
00656 
00657    TEveCompositeFrame::SetCurrent(curr);
00658 
00659    Int_t t = FindTabIndex();
00660    TGTabElement* te = fTab->GetTabTab(t);
00661    if (curr) {
00662       te->SetBackgroundColor(TEveWindow::GetCurrentBackgroundColor());
00663    } else {
00664       te->SetBackgroundColor(GetDefaultFrameBackground());
00665    }
00666    fClient->NeedRedraw(te);
00667 }
00668 
00669 
00670 //==============================================================================
00671 //==============================================================================
00672 // TEveWindow classes
00673 //==============================================================================
00674 //==============================================================================
00675 
00676 
00677 //==============================================================================
00678 // TEveWindow
00679 //==============================================================================
00680 
00681 //______________________________________________________________________________
00682 //
00683 // Abstract base-class for representing eve-windows.
00684 // Sub-classes define a particular GUI frame that gets show
00685 // in the window.
00686 //
00687 
00688 ClassImp(TEveWindow);
00689 
00690 UInt_t      TEveWindow::fgMainFrameDefWidth  = 640;
00691 UInt_t      TEveWindow::fgMainFrameDefHeight = 480;
00692 Pixel_t     TEveWindow::fgCurrentBackgroundColor = 0x80A0C0;
00693 Pixel_t     TEveWindow::fgMiniBarBackgroundColor = 0x80C0A0;
00694 
00695 //______________________________________________________________________________
00696 TEveWindow::TEveWindow(const char* n, const char* t) :
00697    TEveElementList(n, t),
00698 
00699    fEveFrame     (0),
00700    fShowTitleBar (kTRUE)
00701 {
00702    // Constructor.
00703 
00704    // Override from TEveElementList.
00705    fChildClass = TEveWindow::Class();
00706 }
00707 
00708 //______________________________________________________________________________
00709 TEveWindow::~TEveWindow()
00710 {
00711    // Destructor.
00712 
00713    if (gDebug > 0)
00714       Info("~TEveWindow", "name='%s', deny-destroy=%d.",
00715            GetElementName(), fDenyDestroy);
00716 }
00717 
00718 //______________________________________________________________________________
00719 void TEveWindow::PreDeleteElement()
00720 {
00721    // Called before the element is deleted, thus offering the last chance
00722    // to detach from acquired resources and from the framework itself.
00723    // Here the request is just passed to TEveManager.
00724    // If you override it, make sure to call base-class version.
00725 
00726    gEve->GetWindowManager()->DeleteWindow(this);
00727    TEveElementList::PreDeleteElement();
00728 }
00729 
00730 //==============================================================================
00731 
00732 //______________________________________________________________________________
00733 void TEveWindow::PreUndock()
00734 {
00735    // Virtual function called before a window is undocked.
00736 
00737    for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
00738    {
00739       TEveWindow* w = dynamic_cast<TEveWindow*>(*i);
00740       if (w)
00741          w->PreUndock();
00742    }
00743 }
00744 
00745 //______________________________________________________________________________
00746 void TEveWindow::PostDock()
00747 {
00748    // Virtual function called after a window is docked.
00749 
00750    for (List_ci i=fChildren.begin(); i!=fChildren.end(); ++i)
00751    {
00752       TEveWindow* w = dynamic_cast<TEveWindow*>(*i);
00753       if (w)
00754          w->PostDock();
00755    }
00756 }
00757 
00758 //==============================================================================
00759 
00760 //______________________________________________________________________________
00761 void TEveWindow::NameTitleChanged()
00762 {
00763    // Name or title of the window changed - propagate to frames.
00764    // Virtual from TEveElement.
00765 
00766    fEveFrame->WindowNameChanged(GetElementName());
00767 }
00768 
00769 //______________________________________________________________________________
00770 void TEveWindow::PopulateEmptyFrame(TEveCompositeFrame* ef)
00771 {
00772    // Populate given frame-slot - intended for initial population
00773    // of a new slot or low-level window-swapping.
00774    // No layout or window-mapping is done.
00775 
00776    ef->fEveParent->AddElement(this);
00777    ef->AcquireEveWindow(this);
00778    fEveFrame = ef;
00779 }
00780 
00781 //______________________________________________________________________________
00782 void TEveWindow::SwapWindow(TEveWindow* w)
00783 {
00784    // Swap frames with the given window.
00785 
00786    static const TEveException eh("TEveWindow::SwapWindow ");
00787 
00788    if (w == 0)
00789       throw eh + "Called with null argument.";
00790 
00791    SwapWindows(this, w);
00792 }
00793 
00794 //______________________________________________________________________________
00795 void TEveWindow::SwapWindowWithCurrent()
00796 {
00797    // Swap frames with the current window.
00798 
00799    static const TEveException eh("TEveWindow::SwapWindowWithCurrent ");
00800 
00801    TEveWindow* current = gEve->GetWindowManager()->GetCurrentWindow();
00802 
00803    if (current == 0)
00804       throw eh + "Current eve-window is not set.";
00805 
00806    if (current == this)
00807       throw eh + "This is the current window ... nothing changed.";
00808 
00809    SwapWindows(this, current);
00810 }
00811 
00812 //______________________________________________________________________________
00813 void TEveWindow::UndockWindow()
00814 {
00815    // Undock the window - put it into a dedicated main-frame.
00816 
00817    TEveWindow* return_cont = fEveFrame->GetEveParentAsWindow();
00818    if (return_cont && ! return_cont->CanMakeNewSlots())
00819       return_cont = 0;
00820 
00821    // hide slot if in pack
00822    TEveCompositeFrameInPack* packFrame = dynamic_cast<TEveCompositeFrameInPack*>(fEveFrame);
00823    if (packFrame) {
00824       TGPack* pack = (TGPack*)(packFrame->GetParent());
00825       pack->HideFrame(fEveFrame);
00826    }
00827 
00828    TEveWindowSlot* ew_slot = TEveWindow::CreateWindowMainFrame(0);
00829 
00830    TEveWindow::SwapWindows(ew_slot, this);
00831 
00832    ((TEveCompositeFrameInMainFrame*) fEveFrame)->
00833       SetOriginalSlotAndContainer(ew_slot, return_cont);
00834 
00835    gEve->GetWindowManager()->WindowUndocked(this );
00836 }
00837 
00838 //______________________________________________________________________________
00839 void TEveWindow::UndockWindowDestroySlot()
00840 {
00841    // Undock the window - put it into a dedicated main-frame.
00842    // The old window slot is destroyed.
00843 
00844    TEveWindow* return_cont = fEveFrame->GetEveParentAsWindow();
00845    if (return_cont && ! return_cont->CanMakeNewSlots())
00846       return_cont = 0;
00847 
00848    TEveWindowSlot* ew_slot = TEveWindow::CreateWindowMainFrame(0);
00849 
00850    TEveWindow::SwapWindows(ew_slot, this);
00851 
00852    ((TEveCompositeFrameInMainFrame*) fEveFrame)->
00853       SetOriginalSlotAndContainer(0, return_cont);
00854 
00855    ew_slot->DestroyWindowAndSlot();
00856 
00857    gEve->GetWindowManager()->WindowUndocked(this);
00858 }
00859 
00860 //______________________________________________________________________________
00861 void TEveWindow::ReplaceWindow(TEveWindow* w)
00862 {
00863    // Replace this window with the passed one.
00864    // Eve parentship is properly handled.
00865    // This will most likely lead to the destruction of this window.
00866    // Layout is called on the frame.
00867 
00868    fEveFrame->RelinquishEveWindow();
00869 
00870    fEveFrame->fEveParent->AddElement(w);
00871    fEveFrame->AcquireEveWindow(w);
00872    w->fEveFrame = fEveFrame;
00873 
00874    fEveFrame->fEveParent->RemoveElement(this);
00875 
00876    w->fEveFrame->Layout();
00877 }
00878 
00879 //______________________________________________________________________________
00880 void TEveWindow::DestroyWindow()
00881 {
00882    // Destroy eve-window - replace it with an empty frame-slot.
00883 
00884    if (gDebug > 0)
00885       Info("TEveWindow::DestroyWindow()", "name='%s', class='%s', deny-destroy=%d.",
00886            GetElementName(), ClassName(), fDenyDestroy);
00887 
00888    if (fEveFrame != 0 && fDenyDestroy == 1)
00889    {
00890       TEveWindowSlot* ew_slot = TEveWindow::CreateDefaultWindowSlot();
00891 
00892       fEveFrame->UnmapWindow();
00893 
00894       Bool_t dozrc = fDestroyOnZeroRefCnt;
00895       fDestroyOnZeroRefCnt = kFALSE;
00896 
00897       fEveFrame->RelinquishEveWindow();
00898       ew_slot->PopulateEmptyFrame(fEveFrame);
00899       fEveFrame->fEveParent->RemoveElement(this);
00900 
00901       fDestroyOnZeroRefCnt = dozrc;
00902 
00903       fEveFrame->Layout();
00904       fEveFrame->MapWindow();
00905       fEveFrame = 0;
00906    }
00907 
00908    TEveElementList::Destroy();
00909 }
00910 
00911 //______________________________________________________________________________
00912 void TEveWindow::DestroyWindowAndSlot()
00913 {
00914    // Destroy eve-window and its frame-slot.
00915 
00916    if (gDebug > 0)
00917       Info("TEveWindow::DestroyWindowAndSlot()", "'name=%s', class= '%s', deny-destroy=%d.",
00918            GetElementName(), ClassName(), fDenyDestroy);
00919 
00920    if (fEveFrame != 0 && fDenyDestroy == 1)
00921    {
00922       fEveFrame->RelinquishEveWindow();
00923       fEveFrame->Destroy();
00924       fEveFrame = 0;
00925    }
00926 
00927    TEveElementList::Destroy();
00928 }
00929 
00930 //______________________________________________________________________________
00931 void TEveWindow::ClearEveFrame()
00932 {
00933    // Clears eve-frame associated with this window.
00934    // This is used in special case when the window is embedded in a foreign
00935    // GUI container and gets deleted from this side.
00936    // In particular, this happens when TRootBrowser closes a tab.
00937 
00938    fEveFrame = 0;
00939 }
00940 
00941 //______________________________________________________________________________
00942 void TEveWindow::SetShowTitleBar(Bool_t x)
00943 {
00944    // Set display state of the title-bar.
00945    // This is forwarded to eve-frame.
00946 
00947    if (fShowTitleBar == x)
00948       return;
00949 
00950    fShowTitleBar = x;
00951    fEveFrame->SetShowTitleBar(fShowTitleBar);
00952    fEveFrame->Layout();
00953 }
00954 
00955 //______________________________________________________________________________
00956 Bool_t TEveWindow::IsCurrent() const
00957 {
00958    // Returns true if this window is the current one.
00959 
00960    return gEve->GetWindowManager()->IsCurrentWindow(this);
00961 }
00962 
00963 //______________________________________________________________________________
00964 void TEveWindow::MakeCurrent()
00965 {
00966    // Make this window current.
00967 
00968    if ( ! gEve->GetWindowManager()->IsCurrentWindow(this))
00969       gEve->GetWindowManager()->SelectWindow(this);
00970 }
00971 
00972 //______________________________________________________________________________
00973 void TEveWindow::SetCurrent(Bool_t curr)
00974 {
00975    // Set current state of this eve-window.
00976    // Protected method - called by window-manager.
00977 
00978    fEveFrame->SetCurrent(curr);
00979 }
00980 
00981 //______________________________________________________________________________
00982 Bool_t TEveWindow::IsAncestorOf(TEveWindow* win)
00983 {
00984    // Returns true if this is an ancestor of win.
00985 
00986    TEveWindow* parent = dynamic_cast<TEveWindow*>(win->fEveFrame->fEveParent);
00987    if (parent)
00988    {
00989       if (parent == this)
00990          return kTRUE;
00991       else
00992          return IsAncestorOf(parent);
00993    }
00994    else
00995    {
00996       return kFALSE;
00997    }
00998 }
00999 
01000 //______________________________________________________________________________
01001 void TEveWindow::TitleBarClicked()
01002 {
01003    // Slot for clicking on the title-bar.
01004    // The wish that this window becomes the current one is sent to
01005    // the window-manager.
01006 
01007    gEve->GetWindowManager()->SelectWindow(this);
01008 }
01009 
01010 //------------------------------------------------------------------------------
01011 // Static helper functions.
01012 //------------------------------------------------------------------------------
01013 
01014 //______________________________________________________________________________
01015 TEveWindowSlot* TEveWindow::CreateDefaultWindowSlot()
01016 {
01017    // Create a default window slot.
01018    // Static helper.
01019 
01020    return new TEveWindowSlot("Free Window Slot", "A free window slot, can become a container or swallow a window.");
01021 }
01022 
01023 //______________________________________________________________________________
01024 TEveWindowSlot* TEveWindow::CreateWindowMainFrame(TEveWindow* eve_parent)
01025 {
01026    // Create a new main-frame and populate it with a default window-slot.
01027    // The main-frame is mapped.
01028    // Static helper.
01029 
01030    TGMainFrame* mf = new TGMainFrame(gClient->GetRoot(), fgMainFrameDefWidth, fgMainFrameDefHeight);
01031    mf->SetCleanup(kLocalCleanup);
01032 
01033    TEveCompositeFrameInMainFrame *slot = new TEveCompositeFrameInMainFrame
01034       (mf, eve_parent, mf);
01035 
01036    TEveWindowSlot* ew_slot = TEveWindow::CreateDefaultWindowSlot();
01037    ew_slot->PopulateEmptyFrame(slot);
01038 
01039    mf->AddFrame(slot, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
01040    slot->MapWindow();
01041 
01042    mf->Layout();
01043    mf->MapWindow();
01044 
01045    return ew_slot;
01046 }
01047 
01048 //______________________________________________________________________________
01049 TEveWindowSlot* TEveWindow::CreateWindowInTab(TGTab* tab, TEveWindow* eve_parent)
01050 {
01051    // Create a new tab in a given tab-widget and populate it with a
01052    // default window-slot.
01053    // Static helper.
01054 
01055    TGCompositeFrame *parent = tab->AddTab("<unused>");
01056    parent->SetCleanup(kLocalCleanup);
01057 
01058    TEveCompositeFrameInTab *slot = new TEveCompositeFrameInTab(parent, eve_parent, tab);
01059 
01060    TEveWindowSlot* ew_slot = TEveWindow::CreateDefaultWindowSlot();
01061 
01062    ew_slot->PopulateEmptyFrame(slot);
01063 
01064    parent->AddFrame(slot, new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY));
01065 
01066    tab->Layout();
01067 
01068    slot->MapWindow();
01069 
01070    return ew_slot;
01071 }
01072 
01073 //______________________________________________________________________________
01074 void TEveWindow::SwapWindows(TEveWindow* w1, TEveWindow* w2)
01075 {
01076    // Swap windows w1 and w2. They are properly reparented in the eve
01077    // hierarch as well.
01078    // Layout is called on both frames.
01079 
01080    static const TEveException eh("TEveWindow::SwapWindows ");
01081 
01082    if (w1 == 0 || w2 == 0)
01083       throw eh + "Called with null window.";
01084 
01085    if (w1 == w2)
01086       throw eh + "Windows are equal ... nothing to change.";
01087 
01088    if (w1->IsAncestorOf(w2) || w2->IsAncestorOf(w1))
01089       throw eh + "Windows are in direct ancestry.";
01090 
01091    TEveCompositeFrame *f1 = w1->fEveFrame,  *f2 = w2->fEveFrame;
01092    TEveElement        *p1 = f1->fEveParent, *p2 = f2->fEveParent;
01093 
01094    if (p1 != p2)
01095    {
01096       p1->AddElement(w2);
01097       p2->AddElement(w1);
01098    }
01099 
01100    f1->RelinquishEveWindow(kFALSE);
01101    f2->RelinquishEveWindow(kFALSE);
01102    f1->AcquireEveWindow(w2); w2->fEveFrame = f1;
01103    f2->AcquireEveWindow(w1); w1->fEveFrame = f2;
01104 
01105    if (p1 != p2)
01106    {
01107       p1->RemoveElement(w1);
01108       p2->RemoveElement(w2);
01109    }
01110 
01111    f1->Layout(); f2->Layout();
01112 }
01113 
01114 //==============================================================================
01115 
01116 //______________________________________________________________________________
01117 UInt_t TEveWindow::GetMainFrameDefWidth()
01118 {
01119    // Get default width for new main-frame windows. Static.
01120 
01121    return fgMainFrameDefWidth;
01122 }
01123 
01124 //______________________________________________________________________________
01125 UInt_t TEveWindow::GetMainFrameDefHeight()
01126 {
01127    // Get default heigth for new main-frame windows. Static.
01128 
01129    return fgMainFrameDefHeight;
01130 }
01131 
01132 //______________________________________________________________________________
01133 void TEveWindow::SetMainFrameDefWidth (UInt_t x)
01134 {
01135    // Set default width for new main-frame windows. Static.
01136 
01137    fgMainFrameDefWidth  = x;
01138 }
01139 
01140 //______________________________________________________________________________
01141 void TEveWindow::SetMainFrameDefHeight(UInt_t x)
01142 {
01143    // Set default height for new main-frame windows. Static.
01144 
01145    fgMainFrameDefHeight = x;
01146 }
01147 
01148 //______________________________________________________________________________
01149 Pixel_t TEveWindow::GetCurrentBackgroundColor()
01150 {
01151    // Get background-color for marking the title-bar of current window. Static.
01152 
01153    return fgCurrentBackgroundColor;
01154 }
01155 
01156 //______________________________________________________________________________
01157 Pixel_t TEveWindow::GetMiniBarBackgroundColor()
01158 {
01159    // Get background-color for mini-bar (collapsed title-bar). Static.
01160 
01161    return fgMiniBarBackgroundColor;
01162 }
01163 
01164 //______________________________________________________________________________
01165 void TEveWindow::SetCurrentBackgroundColor(Pixel_t p)
01166 {
01167    // Set background-color for marking the title-bar of current window. Static.
01168 
01169    fgCurrentBackgroundColor = p;
01170 }
01171 
01172 //______________________________________________________________________________
01173 void TEveWindow::SetMiniBarBackgroundColor(Pixel_t p)
01174 {
01175    // Set background-color for mini-bar (collapsed title-bar). Static.
01176 
01177    fgMiniBarBackgroundColor = p;
01178 }
01179 
01180 
01181 //==============================================================================
01182 // TEveWindowSlot
01183 //==============================================================================
01184 
01185 //______________________________________________________________________________
01186 // Description of TEveWindowSlot
01187 //
01188 
01189 ClassImp(TEveWindowSlot);
01190 
01191 //______________________________________________________________________________
01192 TEveWindowSlot::TEveWindowSlot(const char* n, const char* t) :
01193    TEveWindow (n, t),
01194    fEmptyButt   (0),
01195    fEmbedBuffer (0)
01196 {
01197    // Constructor.
01198 
01199    fEmptyButt = new TGTextButton(0, "    <empty>\nclick to select");
01200    fEmptyButt->ChangeOptions(kRaisedFrame);
01201    fEmptyButt->SetTextJustify(kTextCenterX | kTextCenterY);
01202 
01203    fEmptyButt->Connect("Clicked()", "TEveWindow", this, "TitleBarClicked()");
01204 }
01205 
01206 //______________________________________________________________________________
01207 TEveWindowSlot::~TEveWindowSlot()
01208 {
01209    // Destructor.
01210 
01211    fEmptyButt->DeleteWindow();
01212 }
01213 
01214 //______________________________________________________________________________
01215 TGFrame* TEveWindowSlot::GetGUIFrame()
01216 {
01217    // Return top-frame of this eve-window - the big button to make slot current.
01218 
01219    return fEmptyButt;
01220 }
01221 
01222 //______________________________________________________________________________
01223 void TEveWindowSlot::SetCurrent(Bool_t curr)
01224 {
01225    // Set current state of this window-slot.
01226    // Virtual from TEveWindow.
01227 
01228    TEveWindow::SetCurrent(curr);
01229 
01230    if (curr)
01231       fEmptyButt->SetBackgroundColor(fgCurrentBackgroundColor);
01232    else
01233       fEmptyButt->SetBackgroundColor(fEmptyButt->GetDefaultFrameBackground());
01234    gClient->NeedRedraw(fEmptyButt);
01235 }
01236 
01237 //______________________________________________________________________________
01238 TEveWindowPack* TEveWindowSlot::MakePack()
01239 {
01240    // A pack is created in place of this window-slot.
01241    // This window-slot will auto-destruct.
01242 
01243    TEveWindowPack* eve_pack = new TEveWindowPack
01244       (0, "Pack", "Window container for horizontal and vertical stacking.");
01245 
01246    ReplaceWindow(eve_pack);
01247 
01248    return eve_pack;
01249 }
01250 
01251 //______________________________________________________________________________
01252 TEveWindowTab* TEveWindowSlot::MakeTab()
01253 {
01254    // A tab is created in place of this window-slot.
01255    // This window-slot will auto-destruct.
01256 
01257    TEveWindowTab* eve_tab = new TEveWindowTab
01258       (0, "Tab", "Window container for horizontal and vertical stacking.");
01259 
01260    ReplaceWindow(eve_tab);
01261 
01262    return eve_tab;
01263 }
01264 
01265 //______________________________________________________________________________
01266 TEveWindowFrame* TEveWindowSlot::MakeFrame(TGFrame* frame)
01267 {
01268    // An eve-window-frame is created and frame is passed into it.
01269    // If frame is 0 (the default), a default composite-frame will be created
01270    // in TEveWindowFrame() constructor.
01271    // This window-slot will auto-destruct.
01272 
01273    TEveWindowFrame* eve_frame = new TEveWindowFrame
01274       (frame, "External frame", "");
01275 
01276    ReplaceWindow(eve_frame);
01277 
01278    return eve_frame;
01279 }
01280 
01281 //______________________________________________________________________________
01282 TGCompositeFrame* TEveWindowSlot::StartEmbedding()
01283 {
01284    // Start embedding a window that will replace the current slot.
01285    // It is expected that a main-frame will be created and then
01286    // StopEmbedding() will be called.
01287 
01288    static const TEveException eh("TEveWindowSlot::StartEmbedding ");
01289 
01290    if (fEmbedBuffer != 0)
01291       throw eh + "Already embedding.";
01292 
01293    fEmbedBuffer = new TGCompositeFrame(gClient->GetDefaultRoot());
01294    fEmbedBuffer->SetEditable(kTRUE);
01295 
01296    return fEmbedBuffer;
01297 }
01298 
01299 //______________________________________________________________________________
01300 TEveWindowFrame* TEveWindowSlot::StopEmbedding(const char* name)
01301 {
01302    // An embedded window is created in place of this window-slot.
01303    // This window-slot will auto-destruct.
01304 
01305    static const TEveException eh("TEveWindowSlot::StopEmbedding ");
01306 
01307    if (fEmbedBuffer == 0) {
01308       Warning(eh, "Embedding not in progress.");
01309       return 0;
01310    }
01311 
01312    fEmbedBuffer->SetEditable(kFALSE);
01313 
01314    Int_t size = fEmbedBuffer->GetList()->GetSize();
01315 
01316    if (size == 0) {
01317       Warning(eh, "Frame has not been registered.");
01318       delete fEmbedBuffer;
01319       fEmbedBuffer = 0;
01320       return 0;
01321    }
01322 
01323    if (size > 1) {
01324       Warning(eh, "Several frames have been registered (%d). Only the first one will be taken.", size);
01325    }
01326 
01327    TGFrame *f = ((TGFrameElement*)fEmbedBuffer->GetList()->First())->fFrame;
01328    fEmbedBuffer->RemoveFrame(f);
01329    f->UnmapWindow();
01330    f->ReparentWindow(gClient->GetDefaultRoot());
01331    delete fEmbedBuffer;
01332    fEmbedBuffer = 0;
01333 
01334    TGMainFrame *mf = dynamic_cast<TGMainFrame*>(f);
01335    assert(mf != 0);
01336 
01337    if (name) {
01338       mf->SetWindowName(name);
01339    }
01340 
01341    TEveWindowFrame* eve_frame = new TEveWindowFrame
01342       (f, mf->GetWindowName(), mf->ClassName());
01343 
01344    ReplaceWindow(eve_frame);
01345 
01346    return eve_frame;
01347 }
01348 
01349 
01350 //==============================================================================
01351 // TEveWindowFrame
01352 //==============================================================================
01353 
01354 //______________________________________________________________________________
01355 //
01356 // Encapsulates TGFrame into an eve-window.
01357 // The frame is owned by the eve-window.
01358 
01359 ClassImp(TEveWindowFrame);
01360 
01361 //______________________________________________________________________________
01362 TEveWindowFrame::TEveWindowFrame(TGFrame* frame, const char* n, const char* t) :
01363    TEveWindow (n, t),
01364    fGUIFrame  (frame)
01365 {
01366    // Constructor.
01367    // If the passed frame is 0, a default TGCompositeFrame frame is instantiated
01368    // and set to local-cleanup.
01369 
01370    if (fGUIFrame == 0)
01371    {
01372       fGUIFrame = new TGCompositeFrame();
01373       fGUIFrame->SetCleanup(kLocalCleanup);
01374    }
01375 }
01376 
01377 //______________________________________________________________________________
01378 TEveWindowFrame::~TEveWindowFrame()
01379 {
01380    // Destructor.
01381 
01382    fGUIFrame->DeleteWindow();
01383 }
01384 
01385 //______________________________________________________________________________
01386 TGCompositeFrame* TEveWindowFrame::GetGUICompositeFrame()
01387 {
01388    // Returns the registered top-frame of this eve-window dynamic-casted
01389    // to composite-frame.
01390    // Throws an execption if the cast fails.
01391 
01392    static const TEveException kEH("TEveWindowFrame::GetGUICompositeFrame ");
01393 
01394    TGCompositeFrame *cf = dynamic_cast<TGCompositeFrame*>(fGUIFrame);
01395    if (cf == 0)
01396       throw kEH + "The registered frame is not a composite-frame.";
01397 
01398    return cf;
01399 }
01400 
01401 //==============================================================================
01402 // TEveWindowPack
01403 //==============================================================================
01404 
01405 //______________________________________________________________________________
01406 //
01407 // Encapsulates TGPack into an eve-window.
01408 // The pack is owned by the eve-window.
01409 
01410 ClassImp(TEveWindowPack);
01411 
01412 //______________________________________________________________________________
01413 TEveWindowPack::TEveWindowPack(TGPack* p, const char* n, const char* t) :
01414    TEveWindow   (n, t),
01415    fPack        (p ? p : new TGPack())
01416 {
01417    // Constructor.
01418    // If passed pack is 0, a defualt one is instantiated.
01419 }
01420 
01421 //______________________________________________________________________________
01422 TEveWindowPack::~TEveWindowPack()
01423 {
01424    // Destructor.
01425 
01426    fPack->DeleteWindow();
01427 }
01428 
01429 //______________________________________________________________________________
01430 TGFrame* TEveWindowPack::GetGUIFrame()
01431 {
01432    // Return top-frame of this eve-window - the pack.
01433 
01434    return fPack;
01435 }
01436 
01437 //______________________________________________________________________________
01438 TEveWindowSlot* TEveWindowPack::NewSlot()
01439 {
01440    // Create a new frame-slot at the last position of the pack.
01441 
01442    return NewSlotWithWeight(1.f);
01443 }
01444 
01445 //______________________________________________________________________________
01446 TEveWindowSlot* TEveWindowPack::NewSlotWithWeight(Float_t w)
01447 {
01448    // Create a new weighted frame-slot at the last position of the pack.
01449 
01450    TEveCompositeFrame* slot = new TEveCompositeFrameInPack(fPack, this, fPack);
01451 
01452    TEveWindowSlot* ew_slot = TEveWindow::CreateDefaultWindowSlot();
01453    ew_slot->PopulateEmptyFrame(slot);
01454 
01455    fPack->AddFrameWithWeight(slot, 0, w);
01456    slot->MapWindow();
01457 
01458    fPack->Layout();
01459 
01460    return ew_slot;
01461 }
01462 
01463 //______________________________________________________________________________
01464 void TEveWindowPack::FlipOrientation()
01465 {
01466    // Flip orientation of the pack (vertical / horizontal).
01467 
01468    fPack->SetVertical( ! fPack->GetVertical());
01469 }
01470 
01471 //______________________________________________________________________________
01472 void TEveWindowPack::SetVertical(Bool_t x)
01473 {
01474    // Set orientation of the pack (vertical / horizontal).
01475 
01476    fPack->SetVertical(x);
01477 }
01478 
01479 //______________________________________________________________________________
01480 void TEveWindowPack::EqualizeFrames()
01481 {
01482    // Refit existing frames so that their lengths are equal.
01483 
01484    fPack->EqualizeFrames();
01485    fPack->Layout();
01486 }
01487 
01488 //==============================================================================
01489 // TEveWindowTab
01490 //==============================================================================
01491 
01492 //______________________________________________________________________________
01493 //
01494 // Encapsulates TGTab into an eve-window.
01495 // The tab is owned by the eve-window.
01496 
01497 ClassImp(TEveWindowTab);
01498 
01499 //______________________________________________________________________________
01500 TEveWindowTab::TEveWindowTab(TGTab* tab, const char* n, const char* t) :
01501    TEveWindow(n, t),
01502    fTab (tab ? tab : new TGTab())
01503 {
01504    // Constructor.
01505    // If passed tab is 0, a defualt one is instantiated.
01506 }
01507 
01508 //______________________________________________________________________________
01509 TEveWindowTab::~TEveWindowTab()
01510 {
01511    // Destructor.
01512 
01513    fTab->DeleteWindow();
01514 }
01515 
01516 //______________________________________________________________________________
01517 TGFrame* TEveWindowTab::GetGUIFrame()
01518 {
01519    // Return top-frame of this eve-window - the tab.
01520 
01521    return fTab;
01522 }
01523 
01524 //______________________________________________________________________________
01525 TEveWindowSlot* TEveWindowTab::NewSlot()
01526 {
01527    // Create new frame-slot - a new tab.
01528 
01529    return TEveWindow::CreateWindowInTab(fTab, this);
01530 }

Generated on Tue Jul 5 14:16:15 2011 for ROOT_528-00b_version by  doxygen 1.5.1