00001
00002
00003
00004
00005
00006
00007
00008
00009
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
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
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
00086
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
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
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
00159
00160 fTopFrame->SetCleanup(kLocalCleanup);
00161 SetCleanup(kLocalCleanup);
00162
00163 MapSubwindows();
00164 HideFrame(fMiniBar);
00165 SetMapSubwindows(kFALSE);
00166
00167
00168 fEveWindowLH = new TGLayoutHints(kLHintsNormal | kLHintsExpandX | kLHintsExpandY);
00169
00170
00171
00172
00173 if (fEveParent == 0)
00174 fEveParent = gEve->GetWindowManager();
00175
00176 fgFrameList->Add(this);
00177 }
00178
00179
00180 TEveCompositeFrame::~TEveCompositeFrame()
00181 {
00182
00183
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
00207
00208 fTitleBar->SetText(name);
00209 }
00210
00211
00212
00213
00214 void TEveCompositeFrame::AcquireEveWindow(TEveWindow* ew)
00215 {
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
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
00253
00254
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
00279
00280 return dynamic_cast<TEveWindow*>(fEveParent);
00281 }
00282
00283
00284 void TEveCompositeFrame::SetCurrent(Bool_t curr)
00285 {
00286
00287
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
00301
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
00318
00319 HideFrame(fTopFrame);
00320 HideFrame(fMiniBar);
00321
00322 fShowInSync = kFALSE;
00323 }
00324
00325
00326 void TEveCompositeFrame::ShowNormalDecorations()
00327 {
00328
00329
00330 SetShowTitleBar(fEveWindow->GetShowTitleBar());
00331 }
00332
00333
00334 void TEveCompositeFrame::ActionPressed()
00335 {
00336
00337
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
00358
00359
00360 if (fShowInSync)
00361 fEveWindow->FlipShowTitleBar();
00362 else
00363 SetShowTitleBar(fEveWindow->GetShowTitleBar());
00364 }
00365
00366
00367 void TEveCompositeFrame::TitleBarClicked()
00368 {
00369
00370
00371
00372 fEveWindow->TitleBarClicked();
00373 }
00374
00375
00376
00377
00378
00379
00380
00381
00382
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
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
00405
00406 if (gDebug > 0)
00407 Info("~TEveCompositeFrameInMainFrame", "Destructor.");
00408
00409
00410
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
00425
00426 fMainFrame->SetWindowName(name);
00427
00428 TEveCompositeFrame::WindowNameChanged(name);
00429 }
00430
00431
00432 void TEveCompositeFrameInMainFrame::Destroy()
00433 {
00434
00435
00436
00437
00438
00439
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
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
00469
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
00482
00483
00484
00485
00486 if (fEveWindow != 0)
00487 {
00488 TEveWindow* swapCandidate = 0;
00489 if (fOriginalSlot)
00490 {
00491
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
00528
00529
00530
00531
00532
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
00544 }
00545
00546
00547 TEveCompositeFrameInPack::~TEveCompositeFrameInPack()
00548 {
00549
00550 }
00551
00552
00553 void TEveCompositeFrameInPack::Destroy()
00554 {
00555
00556
00557
00558
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
00571
00572
00573
00574
00575
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
00588 }
00589
00590
00591 TEveCompositeFrameInTab::~TEveCompositeFrameInTab()
00592 {
00593
00594 }
00595
00596
00597 void TEveCompositeFrameInTab::WindowNameChanged(const TString& name)
00598 {
00599
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
00612
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
00632
00633
00634
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
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
00655
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
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
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
00703
00704
00705 fChildClass = TEveWindow::Class();
00706 }
00707
00708
00709 TEveWindow::~TEveWindow()
00710 {
00711
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
00722
00723
00724
00725
00726 gEve->GetWindowManager()->DeleteWindow(this);
00727 TEveElementList::PreDeleteElement();
00728 }
00729
00730
00731
00732
00733 void TEveWindow::PreUndock()
00734 {
00735
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
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
00764
00765
00766 fEveFrame->WindowNameChanged(GetElementName());
00767 }
00768
00769
00770 void TEveWindow::PopulateEmptyFrame(TEveCompositeFrame* ef)
00771 {
00772
00773
00774
00775
00776 ef->fEveParent->AddElement(this);
00777 ef->AcquireEveWindow(this);
00778 fEveFrame = ef;
00779 }
00780
00781
00782 void TEveWindow::SwapWindow(TEveWindow* w)
00783 {
00784
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
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
00816
00817 TEveWindow* return_cont = fEveFrame->GetEveParentAsWindow();
00818 if (return_cont && ! return_cont->CanMakeNewSlots())
00819 return_cont = 0;
00820
00821
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
00842
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
00864
00865
00866
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
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
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
00934
00935
00936
00937
00938 fEveFrame = 0;
00939 }
00940
00941
00942 void TEveWindow::SetShowTitleBar(Bool_t x)
00943 {
00944
00945
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
00959
00960 return gEve->GetWindowManager()->IsCurrentWindow(this);
00961 }
00962
00963
00964 void TEveWindow::MakeCurrent()
00965 {
00966
00967
00968 if ( ! gEve->GetWindowManager()->IsCurrentWindow(this))
00969 gEve->GetWindowManager()->SelectWindow(this);
00970 }
00971
00972
00973 void TEveWindow::SetCurrent(Bool_t curr)
00974 {
00975
00976
00977
00978 fEveFrame->SetCurrent(curr);
00979 }
00980
00981
00982 Bool_t TEveWindow::IsAncestorOf(TEveWindow* win)
00983 {
00984
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
01004
01005
01006
01007 gEve->GetWindowManager()->SelectWindow(this);
01008 }
01009
01010
01011
01012
01013
01014
01015 TEveWindowSlot* TEveWindow::CreateDefaultWindowSlot()
01016 {
01017
01018
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
01027
01028
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
01052
01053
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
01077
01078
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
01120
01121 return fgMainFrameDefWidth;
01122 }
01123
01124
01125 UInt_t TEveWindow::GetMainFrameDefHeight()
01126 {
01127
01128
01129 return fgMainFrameDefHeight;
01130 }
01131
01132
01133 void TEveWindow::SetMainFrameDefWidth (UInt_t x)
01134 {
01135
01136
01137 fgMainFrameDefWidth = x;
01138 }
01139
01140
01141 void TEveWindow::SetMainFrameDefHeight(UInt_t x)
01142 {
01143
01144
01145 fgMainFrameDefHeight = x;
01146 }
01147
01148
01149 Pixel_t TEveWindow::GetCurrentBackgroundColor()
01150 {
01151
01152
01153 return fgCurrentBackgroundColor;
01154 }
01155
01156
01157 Pixel_t TEveWindow::GetMiniBarBackgroundColor()
01158 {
01159
01160
01161 return fgMiniBarBackgroundColor;
01162 }
01163
01164
01165 void TEveWindow::SetCurrentBackgroundColor(Pixel_t p)
01166 {
01167
01168
01169 fgCurrentBackgroundColor = p;
01170 }
01171
01172
01173 void TEveWindow::SetMiniBarBackgroundColor(Pixel_t p)
01174 {
01175
01176
01177 fgMiniBarBackgroundColor = p;
01178 }
01179
01180
01181
01182
01183
01184
01185
01186
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
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
01210
01211 fEmptyButt->DeleteWindow();
01212 }
01213
01214
01215 TGFrame* TEveWindowSlot::GetGUIFrame()
01216 {
01217
01218
01219 return fEmptyButt;
01220 }
01221
01222
01223 void TEveWindowSlot::SetCurrent(Bool_t curr)
01224 {
01225
01226
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
01241
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
01255
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
01269
01270
01271
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
01285
01286
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
01303
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
01352
01353
01354
01355
01356
01357
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
01367
01368
01369
01370 if (fGUIFrame == 0)
01371 {
01372 fGUIFrame = new TGCompositeFrame();
01373 fGUIFrame->SetCleanup(kLocalCleanup);
01374 }
01375 }
01376
01377
01378 TEveWindowFrame::~TEveWindowFrame()
01379 {
01380
01381
01382 fGUIFrame->DeleteWindow();
01383 }
01384
01385
01386 TGCompositeFrame* TEveWindowFrame::GetGUICompositeFrame()
01387 {
01388
01389
01390
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
01403
01404
01405
01406
01407
01408
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
01418
01419 }
01420
01421
01422 TEveWindowPack::~TEveWindowPack()
01423 {
01424
01425
01426 fPack->DeleteWindow();
01427 }
01428
01429
01430 TGFrame* TEveWindowPack::GetGUIFrame()
01431 {
01432
01433
01434 return fPack;
01435 }
01436
01437
01438 TEveWindowSlot* TEveWindowPack::NewSlot()
01439 {
01440
01441
01442 return NewSlotWithWeight(1.f);
01443 }
01444
01445
01446 TEveWindowSlot* TEveWindowPack::NewSlotWithWeight(Float_t w)
01447 {
01448
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
01467
01468 fPack->SetVertical( ! fPack->GetVertical());
01469 }
01470
01471
01472 void TEveWindowPack::SetVertical(Bool_t x)
01473 {
01474
01475
01476 fPack->SetVertical(x);
01477 }
01478
01479
01480 void TEveWindowPack::EqualizeFrames()
01481 {
01482
01483
01484 fPack->EqualizeFrames();
01485 fPack->Layout();
01486 }
01487
01488
01489
01490
01491
01492
01493
01494
01495
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
01505
01506 }
01507
01508
01509 TEveWindowTab::~TEveWindowTab()
01510 {
01511
01512
01513 fTab->DeleteWindow();
01514 }
01515
01516
01517 TGFrame* TEveWindowTab::GetGUIFrame()
01518 {
01519
01520
01521 return fTab;
01522 }
01523
01524
01525 TEveWindowSlot* TEveWindowTab::NewSlot()
01526 {
01527
01528
01529 return TEveWindow::CreateWindowInTab(fTab, this);
01530 }