TEveWindowManager.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveWindowManager.cxx 29324 2009-07-03 11:27:35Z 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 "TEveWindowManager.h"
00013 #include "TEveWindow.h"
00014 
00015 //______________________________________________________________________________
00016 //
00017 // Manager for EVE windows.
00018 //
00019 // Provides the concept of the current window and takes care for proper
00020 // destruction of the windows.
00021 //
00022 // It is also the EVE-parent of windows that are not attaced into the
00023 // hierarchy of EVE-windows.
00024 //
00025 // Window-manager is created by the EVE-manager and can be retrieved via:
00026 //   gEve->GetWindowManager.
00027 
00028 ClassImp(TEveWindowManager);
00029 
00030 //______________________________________________________________________________
00031 TEveWindowManager::TEveWindowManager(const char* n, const char* t) :
00032    TEveElementList(n, t),
00033    TQObject       (),
00034    fCurrentWindow    (0),
00035    fDefaultContainer (0)
00036 {
00037    // Constructor.
00038 }
00039 
00040 //______________________________________________________________________________
00041 TEveWindowManager::~TEveWindowManager()
00042 {
00043    // Destructor.
00044 }
00045 
00046 //==============================================================================
00047 
00048 //______________________________________________________________________________
00049 void TEveWindowManager::SelectWindow(TEveWindow* window)
00050 {
00051    // Entry-point for communicating the fact that a window was acted
00052    // upon in such a way that it should become the current window.
00053    // If the passed window is already the current one, it is deselcted.
00054    //
00055    // For example, this is called from title-bar, when creating a new
00056    // window slot, etc.
00057    //
00058    // If the change is accepted (the manager can refuse to make a
00059    // window current), the state of window is changed accordingly and
00060    // WindowSelected() signal is emitted.
00061 
00062    if (window == fCurrentWindow)
00063       window = 0;
00064 
00065    if (fCurrentWindow)
00066       fCurrentWindow->SetCurrent(kFALSE);
00067 
00068    fCurrentWindow = window;
00069 
00070    if (fCurrentWindow)
00071       fCurrentWindow->SetCurrent(kTRUE);
00072 
00073    WindowSelected(fCurrentWindow);
00074 }
00075 
00076 //______________________________________________________________________________
00077 void TEveWindowManager::DeleteWindow(TEveWindow* window)
00078 {
00079    // Called by a window before it gets deleted.
00080 
00081    if (window == fCurrentWindow)
00082    {
00083       fCurrentWindow = 0;
00084       WindowSelected(fCurrentWindow);
00085    }
00086    WindowDeleted(window);
00087 }
00088 
00089 //______________________________________________________________________________
00090 void TEveWindowManager::WindowDocked(TEveWindow* window)
00091 {
00092    // Emit the "WindowDocked(TEveWindow*)" signal.
00093 
00094    Emit("WindowDocked(TEveWindow*)", (Long_t)window);
00095 }
00096 
00097 //______________________________________________________________________________
00098 void TEveWindowManager::WindowUndocked(TEveWindow* window)
00099 {
00100    // Emit the "WindowUndocked(TEveWindow*)" signal.
00101 
00102    Emit("WindowUndocked(TEveWindow*)", (Long_t)window);
00103 }
00104 
00105 //______________________________________________________________________________
00106 void TEveWindowManager::WindowSelected(TEveWindow* window)
00107 {
00108    // Emit the "WindowSelected(TEveWindow*)" signal.
00109 
00110    Emit("WindowSelected(TEveWindow*)", (Long_t)window);
00111 }
00112 
00113 //______________________________________________________________________________
00114 void TEveWindowManager::WindowDeleted(TEveWindow* window)
00115 {
00116    // Emit the "WindowDeleted(TEveWindow*)" signal.
00117 
00118    Emit("WindowDeleted(TEveWindow*)", (Long_t)window);
00119 }
00120 
00121 //==============================================================================
00122 
00123 //______________________________________________________________________________
00124 TEveWindowSlot* TEveWindowManager::GetCurrentWindowAsSlot() const
00125 {
00126    // Return current window dynamic-casted to TEveWindowSlot.
00127 
00128    return dynamic_cast<TEveWindowSlot*>(fCurrentWindow);
00129 }
00130 
00131 void TEveWindowManager::SetDefaultContainer(TEveWindow* w)
00132 {
00133    // Set default container window.
00134    // It has to be able to create new slots.
00135    // When main-frames are closed they will place the windows here.
00136 
00137    static const TEveException kEH("TEveWindowManager::SetDefaultContainer ");
00138 
00139    if ( ! w->CanMakeNewSlots())
00140       throw kEH + "Given window can not make new slots.";
00141 
00142    fDefaultContainer = w;
00143 }
00144 
00145 //______________________________________________________________________________
00146 void TEveWindowManager::DestroyWindowRecursively(TEveWindow* window)
00147 {
00148    // Destroy window's children and then the window itself.
00149    // Protected method used during shutdown.
00150 
00151    while (window->HasChildren())
00152    {
00153       TEveWindow* w = dynamic_cast<TEveWindow*>(window->FirstChild());
00154       if (w)
00155          DestroyWindowRecursively(w);
00156       else
00157          window->RemoveElement(window->FirstChild());
00158    }
00159    window->DestroyWindowAndSlot();
00160 }
00161 
00162 //______________________________________________________________________________
00163 void TEveWindowManager::DestroyWindows()
00164 {
00165    // Wait for all windows to shut-down.
00166 
00167    while (HasChildren())
00168    {
00169       TEveWindow* w = dynamic_cast<TEveWindow*>(FirstChild());
00170       if (w)
00171          DestroyWindowRecursively(w);
00172       else
00173          RemoveElement(FirstChild());
00174    }
00175 
00176 }
00177 
00178 //==============================================================================
00179 
00180 //______________________________________________________________________________
00181 void TEveWindowManager::HideAllEveDecorations()
00182 {
00183    // Hide all eve decorations (title-bar and mini-bar) on all frames.
00184 
00185    TEveCompositeFrame *ecf = 0;
00186    TIter wins(TEveCompositeFrame::fgFrameList);
00187    while ((ecf = (TEveCompositeFrame*) wins()))
00188    {
00189       ecf->HideAllDecorations();
00190       ecf->Layout();
00191    }
00192 }
00193 
00194 //______________________________________________________________________________
00195 void TEveWindowManager::ShowNormalEveDecorations()
00196 {
00197    // Show eve decorations (title-bar or mini-bar) as specified for
00198    // the contained window on all frames.
00199 
00200    TEveCompositeFrame *ecf = 0;
00201    TIter wins(TEveCompositeFrame::fgFrameList);
00202    while ((ecf = (TEveCompositeFrame*) wins()))
00203    {
00204       ecf->ShowNormalDecorations();
00205       ecf->Layout();
00206    }
00207 }
00208 
00209 //______________________________________________________________________________
00210 void TEveWindowManager::SetShowTitleBars(Bool_t state)
00211 {
00212    // Set show title-bar state on all frames.
00213    // This does not modify the per-window settings - call
00214    // ShowNormalEveDecorations() to restore them.
00215 
00216    TEveCompositeFrame *ecf = 0;
00217    TIter wins(TEveCompositeFrame::fgFrameList);
00218    while ((ecf = (TEveCompositeFrame*) wins()))
00219    {
00220       ecf->SetShowTitleBar(state);
00221       ecf->Layout();
00222    }
00223 }

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