From $ROOTSYS/tutorials/eve/window_manager.C

// @(#)root/eve:$Id$
// Author: Matevz Tadel

// Demonstrates usage of EVE window-manager.

#include "TEveWindow.h"
#include "TEveViewer.h"
#include "TEveManager.h"
#include "TEveBrowser.h"
#include "TEveGedEditor.h"
#include "TGLEmbeddedViewer.h"
#include "TCanvas.h"
#include "TGTab.h"

void window_manager()
{
   TEveManager::Create();

   TEveUtil::Macro("pointset.C");

   PackTest();
   DetailTest();
   TabsTest();

   gEve->GetBrowser()->GetTabRight()->SetTab(1);
   gDebug = 1;
}

void PackTest()
{
   TEveWindowSlot  *slot  = 0;
   TEveWindowFrame *frame = 0;
   TEveViewer *v = 0;

   slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
   TEveWindowPack* pack1 = slot->MakePack();
   pack1->SetShowTitleBar(kFALSE);
   pack1->SetHorizontal();

   // Embedded viewer.
   slot = pack1->NewSlot();
   v = new TEveViewer("BarViewer");
   v->SpawnGLEmbeddedViewer(gEve->GetEditor());
   slot->ReplaceWindow(v);
   v->SetElementName("Bar Embedded Viewer");

   gEve->GetViewers()->AddElement(v);
   v->AddScene(gEve->GetEventScene());

   slot = pack1->NewSlot();
   TEveWindowPack* pack2 = slot->MakePack();
   pack2->SetShowTitleBar(kFALSE);

   slot = pack2->NewSlot();
   slot->StartEmbedding();
   TCanvas* can = new TCanvas("Root Canvas");
   can->ToggleEditor();
   slot->StopEmbedding();

   // SA viewer.
   slot = pack2->NewSlot();
   v = new TEveViewer("FooViewer");
   v->SpawnGLViewer(gEve->GetEditor());
   slot->ReplaceWindow(v);
   gEve->GetViewers()->AddElement(v);
   v->AddScene(gEve->GetEventScene());
}


void DetailTest()
{
   TEveWindowSlot* slot =
      TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
   pack1 = slot->MakePack();
   pack1->SetShowTitleBar(kFALSE);
   pack1->SetElementName("Detail");
   pack1->SetHorizontal();

   // left slot
   slot = pack1->NewSlot();
   frame = slot->MakeFrame();
   frame->SetElementName("Latex Frame");
   frame->SetShowTitleBar(kFALSE);
   TGCompositeFrame* cf = frame->GetGUICompositeFrame();
   TGCompositeFrame* hf = new TGVerticalFrame(cf);
   hf->SetCleanup(kLocalCleanup);
   cf->AddFrame(hf, new TGLayoutHints(kLHintsExpandX | kLHintsExpandY));
   {
      TGVerticalFrame* guiFrame = new TGVerticalFrame(hf);
      hf->AddFrame(guiFrame, new TGLayoutHints(kLHintsExpandX));
      guiFrame->SetCleanup(kDeepCleanup);

      guiFrame->AddFrame(new TGLabel(guiFrame, "Press Button:"),
                         new TGLayoutHints(kLHintsLeft, 2, 2, 0, 0));
      TGTextButton *b = new TGTextButton(guiFrame, "TestButton");
      guiFrame->AddFrame(b, new TGLayoutHints(kLHintsExpandX));
      TRootEmbeddedCanvas* ec =
         new TRootEmbeddedCanvas("Embeddedcanvas", hf, 220);
      hf->AddFrame(ec, new TGLayoutHints(kLHintsExpandY|kLHintsExpandX));
      double fontsize = 0.07;
      double x = 0.02;
      double y = 1 -1*fontsize;
      TLatex* latex = new TLatex(x, y, "Legend:");
      latex->SetTextSize(fontsize);
      latex->Draw();
      y -= 2*fontsize;
      // legend
      latex->DrawLatex(x, y, "greek letter #Delta#eta_{out}");
      y -= fontsize;
      latex->DrawLatex(x, y, "#color[5]{+} marker");
      y -= fontsize;
      latex->DrawLatex(x, y, "#color[5]{+} marker");
      y -= fontsize;
      latex->DrawLatex(x, y, "#color[4]{+} marker");
      y -= fontsize;
      latex->DrawLatex(x, y, "#color[5]{#bullet} marker");
      y -= fontsize;
      latex->DrawLatex(x, y, "#color[4]{#bullet} marker some text");
      y -= fontsize;
      latex->DrawLatex(x, y, "#color[2]{#Box} square");
      y -= fontsize;
      latex->DrawLatex(x, y, "#color[5]{#Box} color");
   }

   cf->MapSubwindows();
   cf->Layout();
   cf->MapWindow();

   // viewer slot
   TEveWindowSlot* slot2 = pack1->NewSlotWithWeight(3);
   TEveViewer*  viewer = new TEveViewer("DetailView", "DetailView");
   TGLEmbeddedViewer*  embeddedViewer =  viewer->SpawnGLEmbeddedViewer();
   slot2->ReplaceWindow(viewer);
   gEve->GetViewers()->AddElement(viewer);
   viewer->AddScene(gEve->GetEventScene());
}

void TabsTest()
{
   TRandom r(0);
   TEveWindowSlot  *slot  = 0;
   TEveWindowFrame *frame = 0;
   TEveViewer *v = 0;

   slot = TEveWindow::CreateWindowInTab(gEve->GetBrowser()->GetTabRight());
   TEveWindowTab* tab1 = slot->MakeTab();
   tab1->SetElementName("Tabs");
   tab1->SetShowTitleBar(kFALSE);

   // horizontal text views
   slot = tab1->NewSlot();
   TEveWindowPack* pack1 = slot->MakePack();
   for(int i = 0; i<4;++i)
   {
      Int_t weight = r.Uniform(3, 7);
      slot = pack1->NewSlotWithWeight(weight);
      frame = slot->MakeFrame();
      frame->SetElementName(Form("FrameInPack %d", i));
      TGCompositeFrame* cf = frame->GetGUICompositeFrame();
      TGTextView* text_view = new TGTextView(cf, 200, 400);
      cf->AddFrame(text_view, new TGLayoutHints(kLHintsLeft    |
                                                kLHintsExpandX |
                                                kLHintsExpandY));

      for(Int_t l =0; l<weight; l++)
      {
         text_view->AddLine(Form("slot[%d] add line %d here ", i, l));
      }
      text_view->Update();
      text_view->SetWidth(text_view->ReturnLongestLineWidth()+20);
      text_view->Layout();

      cf->MapSubwindows();
      cf->Layout();
      cf->MapWindow();
   }

   // canvas tab
   slot = tab1->NewSlot();
   frame = slot->MakeFrame(new TRootEmbeddedCanvas());
   frame->SetElementName("Embedded Canvas");

   // neseted 2nd leveltabs
   slot = tab1->NewSlot();
   slot->SetShowTitleBar(kFALSE);
   TEveWindowTab* tab2 = slot->MakeTab();
   tab2->SetElementName("Nested");
   tab2->SetShowTitleBar(kFALSE);
   slot =  tab2->NewSlot();
   slot->SetShowTitleBar(kFALSE);
   slot =    tab2->NewSlot();
   slot->SetShowTitleBar(kFALSE);
}
 window_manager.C:1
 window_manager.C:2
 window_manager.C:3
 window_manager.C:4
 window_manager.C:5
 window_manager.C:6
 window_manager.C:7
 window_manager.C:8
 window_manager.C:9
 window_manager.C:10
 window_manager.C:11
 window_manager.C:12
 window_manager.C:13
 window_manager.C:14
 window_manager.C:15
 window_manager.C:16
 window_manager.C:17
 window_manager.C:18
 window_manager.C:19
 window_manager.C:20
 window_manager.C:21
 window_manager.C:22
 window_manager.C:23
 window_manager.C:24
 window_manager.C:25
 window_manager.C:26
 window_manager.C:27
 window_manager.C:28
 window_manager.C:29
 window_manager.C:30
 window_manager.C:31
 window_manager.C:32
 window_manager.C:33
 window_manager.C:34
 window_manager.C:35
 window_manager.C:36
 window_manager.C:37
 window_manager.C:38
 window_manager.C:39
 window_manager.C:40
 window_manager.C:41
 window_manager.C:42
 window_manager.C:43
 window_manager.C:44
 window_manager.C:45
 window_manager.C:46
 window_manager.C:47
 window_manager.C:48
 window_manager.C:49
 window_manager.C:50
 window_manager.C:51
 window_manager.C:52
 window_manager.C:53
 window_manager.C:54
 window_manager.C:55
 window_manager.C:56
 window_manager.C:57
 window_manager.C:58
 window_manager.C:59
 window_manager.C:60
 window_manager.C:61
 window_manager.C:62
 window_manager.C:63
 window_manager.C:64
 window_manager.C:65
 window_manager.C:66
 window_manager.C:67
 window_manager.C:68
 window_manager.C:69
 window_manager.C:70
 window_manager.C:71
 window_manager.C:72
 window_manager.C:73
 window_manager.C:74
 window_manager.C:75
 window_manager.C:76
 window_manager.C:77
 window_manager.C:78
 window_manager.C:79
 window_manager.C:80
 window_manager.C:81
 window_manager.C:82
 window_manager.C:83
 window_manager.C:84
 window_manager.C:85
 window_manager.C:86
 window_manager.C:87
 window_manager.C:88
 window_manager.C:89
 window_manager.C:90
 window_manager.C:91
 window_manager.C:92
 window_manager.C:93
 window_manager.C:94
 window_manager.C:95
 window_manager.C:96
 window_manager.C:97
 window_manager.C:98
 window_manager.C:99
 window_manager.C:100
 window_manager.C:101
 window_manager.C:102
 window_manager.C:103
 window_manager.C:104
 window_manager.C:105
 window_manager.C:106
 window_manager.C:107
 window_manager.C:108
 window_manager.C:109
 window_manager.C:110
 window_manager.C:111
 window_manager.C:112
 window_manager.C:113
 window_manager.C:114
 window_manager.C:115
 window_manager.C:116
 window_manager.C:117
 window_manager.C:118
 window_manager.C:119
 window_manager.C:120
 window_manager.C:121
 window_manager.C:122
 window_manager.C:123
 window_manager.C:124
 window_manager.C:125
 window_manager.C:126
 window_manager.C:127
 window_manager.C:128
 window_manager.C:129
 window_manager.C:130
 window_manager.C:131
 window_manager.C:132
 window_manager.C:133
 window_manager.C:134
 window_manager.C:135
 window_manager.C:136
 window_manager.C:137
 window_manager.C:138
 window_manager.C:139
 window_manager.C:140
 window_manager.C:141
 window_manager.C:142
 window_manager.C:143
 window_manager.C:144
 window_manager.C:145
 window_manager.C:146
 window_manager.C:147
 window_manager.C:148
 window_manager.C:149
 window_manager.C:150
 window_manager.C:151
 window_manager.C:152
 window_manager.C:153
 window_manager.C:154
 window_manager.C:155
 window_manager.C:156
 window_manager.C:157
 window_manager.C:158
 window_manager.C:159
 window_manager.C:160
 window_manager.C:161
 window_manager.C:162
 window_manager.C:163
 window_manager.C:164
 window_manager.C:165
 window_manager.C:166
 window_manager.C:167
 window_manager.C:168
 window_manager.C:169
 window_manager.C:170
 window_manager.C:171
 window_manager.C:172
 window_manager.C:173
 window_manager.C:174
 window_manager.C:175
 window_manager.C:176
 window_manager.C:177
 window_manager.C:178
 window_manager.C:179
 window_manager.C:180
 window_manager.C:181
 window_manager.C:182
 window_manager.C:183
 window_manager.C:184
 window_manager.C:185
 window_manager.C:186
 window_manager.C:187
 window_manager.C:188
 window_manager.C:189
 window_manager.C:190
 window_manager.C:191
 window_manager.C:192
 window_manager.C:193
 window_manager.C:194