GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4MdiArea.cpp
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4MdiArea.h"
15 
16 #include "TPad.h"
17 #include "TROOT.h"
18 
19 #include <QMdiSubWindow>
20 
21 #include "TGo4ViewPanel.h"
22 #include "QGo4Widget.h"
23 #include "TGo4QSettings.h"
24 
26 
28 {
29  return fInstance;
30 }
31 
32 TGo4MdiArea::TGo4MdiArea(QWidget* parent) :
33  QMdiArea(parent),
34  fxActivePanel(0),
35  fxActivePad(0),
36  fxSelectedPad(0)
37 {
38  setSizeIncrement( QSize( 100, 100 ) );
39  setBaseSize( QSize( 100, 100 ) );
40 
41  connect(this,SIGNAL(subWindowActivated (QMdiSubWindow*)), this, SLOT(subWindowActivatedSlot(QMdiSubWindow*)));
42 
43  if (fInstance==0) fInstance = this;
44 }
45 
47 {
48  if (fInstance==this) fInstance = 0;
49 }
50 
51 
53 {
54  return fxSelectedPad;
55 }
56 
58 {
59  fxSelectedPad = pad;
60  gROOT->SetSelectedPad(pad);
61  gPad = pad;
62 }
63 
65 {
66  return fxActivePanel;
67 }
68 
69 QMdiSubWindow* TGo4MdiArea::AddGo4SubWindow(QWidget * widget, Qt::WindowFlags flags)
70 {
71  QMdiSubWindow*sub=addSubWindow(widget, flags);
72 // JAM make window behaviour configurable in Go4 for all Qt versions.
74  {
75  sub->setOption(QMdiSubWindow::RubberBandResize);
76  sub->setOption(QMdiSubWindow::RubberBandMove); // JAM required for qt5 performance
77  }
78  return sub;
79 }
80 
81 
82 void TGo4MdiArea::subWindowActivatedSlot(QMdiSubWindow* sub)
83 {
84  TGo4ViewPanel* panel = dynamic_cast<TGo4ViewPanel*> (sub ? sub->widget() : 0);
85 
86  if ((panel!=0) && (fxActivePanel != panel))
87  panel->SetActivePad(panel->GetActivePad());
88 }
89 
90 void TGo4MdiArea::ResponseOnPanelEvent(int funcid, TGo4ViewPanel* panel, TPad* pad)
91 {
92  if (panel==0) return;
93 
94  switch (funcid) {
96  if ((fxActivePanel!=panel) && (fxActivePanel!=0))
98 
99  bool changed = (fxActivePanel != panel) || (fxActivePad != pad);
100  fxActivePanel = panel;
101  fxActivePad = pad;
102 
103  if (changed)
104  emit panelSignal(panel, pad, QGo4Widget::panel_Activated);
105 
106  break;
107  }
108 
110  emit panelSignal(panel, pad, QGo4Widget::panel_Modified);
111  break;
112  }
113 
115  emit panelSignal(panel, pad, QGo4Widget::panel_Updated);
116  if ((panel==fxActivePanel) && (pad==fxActivePad))
118  break;
119  }
120 
122  if (GetSelectedPad()==pad) SetSelectedPad(0);
123  if (fxActivePad==pad) fxActivePad=0;
124  emit panelSignal(panel, pad, QGo4Widget::panel_PadDeleted);
125  break;
126  }
127 
129  if (GetSelectedPad()!=0)
130  if (panel->IsPanelPad(GetSelectedPad()))
131  SetSelectedPad(0);
132  if (fxActivePanel==panel) {
133  fxActivePanel = 0;
134  fxActivePad = 0;
135  }
136  emit panelSignal(panel, pad, QGo4Widget::panel_Deleted);
137  break;
138  }
139  }
140 }
141 
TPad * fxSelectedPad
Definition: TGo4MdiArea.h:57
virtual void SetActivePad(TPad *pad)
TPad * GetSelectedPad()
Definition: TGo4MdiArea.cpp:52
static TGo4MdiArea * Instance()
Definition: TGo4MdiArea.cpp:27
TPad * fxActivePad
Definition: TGo4MdiArea.h:56
void ResponseOnPanelEvent(int funcid, TGo4ViewPanel *panel, TPad *pad)
Definition: TGo4MdiArea.cpp:90
static TGo4MdiArea * fInstance
Definition: TGo4MdiArea.h:59
TGo4QSettings * go4sett
TGo4ViewPanel * GetActivePanel()
Definition: TGo4MdiArea.cpp:64
void subWindowActivatedSlot(QMdiSubWindow *window)
Definition: TGo4MdiArea.cpp:82
virtual ~TGo4MdiArea()
Definition: TGo4MdiArea.cpp:46
virtual bool IsPanelPad(TPad *pad)
bool getMoveSubwindowRubberBand()
TGo4ViewPanel * fxActivePanel
Definition: TGo4MdiArea.h:55
virtual TPad * GetActivePad()
void SetSelectedPad(TPad *pad)
Definition: TGo4MdiArea.cpp:57
QMdiSubWindow * AddGo4SubWindow(QWidget *widget, Qt::WindowFlags flags=0)
Definition: TGo4MdiArea.cpp:69
TGo4MdiArea(QWidget *parent=0)
Definition: TGo4MdiArea.cpp:32
void panelSignal(TGo4ViewPanel *, TPad *, int)