Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "TGo4MdiArea.h"
00015
00016 #include "TPad.h"
00017 #include "TROOT.h"
00018
00019 #include <QMdiSubWindow>
00020
00021 #include "TGo4ViewPanel.h"
00022 #include "QGo4Widget.h"
00023
00024 TGo4MdiArea* TGo4MdiArea::fInstance = 0;
00025
00026 TGo4MdiArea* TGo4MdiArea::Instance()
00027 {
00028 return fInstance;
00029 }
00030
00031 TGo4MdiArea::TGo4MdiArea(QWidget* parent) :
00032 QMdiArea(parent),
00033 fxActivePanel(0),
00034 fxActivePad(0),
00035 fxSelectedPad(0)
00036 {
00037 setSizeIncrement( QSize( 100, 100 ) );
00038 setBaseSize( QSize( 100, 100 ) );
00039
00040 connect(this,SIGNAL(subWindowActivated (QMdiSubWindow*)), this, SLOT(subWindowActivatedSlot(QMdiSubWindow*)));
00041
00042 if (fInstance==0) fInstance = this;
00043 }
00044
00045 TGo4MdiArea::~TGo4MdiArea()
00046 {
00047 if (fInstance==this) fInstance = 0;
00048 }
00049
00050
00051 TPad* TGo4MdiArea::GetSelectedPad()
00052 {
00053 return fxSelectedPad;
00054 }
00055
00056 void TGo4MdiArea::SetSelectedPad(TPad* pad)
00057 {
00058 fxSelectedPad = pad;
00059 gROOT->SetSelectedPad(pad);
00060 gPad = pad;
00061 }
00062
00063 TGo4ViewPanel* TGo4MdiArea::GetActivePanel()
00064 {
00065 return fxActivePanel;
00066 }
00067
00068 void TGo4MdiArea::subWindowActivatedSlot(QMdiSubWindow* sub)
00069 {
00070 TGo4ViewPanel* panel = dynamic_cast<TGo4ViewPanel*> (sub ? sub->widget() : 0);
00071
00072 if ((panel!=0) && (fxActivePanel != panel))
00073 panel->SetActivePad(panel->GetActivePad());
00074 }
00075
00076 void TGo4MdiArea::ResponseOnPanelEvent(int funcid, TGo4ViewPanel* panel, TPad* pad)
00077 {
00078 if (panel==0) return;
00079
00080 switch (funcid) {
00081 case QGo4Widget::panel_Activated: {
00082 if ((fxActivePanel!=panel) && (fxActivePanel!=0))
00083 fxActivePanel->SetActivePad(0);
00084
00085 bool changed = (fxActivePanel != panel) || (fxActivePad != pad);
00086 fxActivePanel = panel;
00087 fxActivePad = pad;
00088
00089 if (changed)
00090 emit panelSignal(panel, pad, QGo4Widget::panel_Activated);
00091
00092 break;
00093 }
00094
00095 case QGo4Widget::panel_Modified: {
00096 emit panelSignal(panel, pad, QGo4Widget::panel_Modified);
00097 break;
00098 }
00099
00100 case QGo4Widget::panel_Updated: {
00101 emit panelSignal(panel, pad, QGo4Widget::panel_Updated);
00102 if ((panel==fxActivePanel) && (pad==fxActivePad))
00103 emit panelSignal(panel, pad, QGo4Widget::panel_ActiveUpdated);
00104 break;
00105 }
00106
00107 case QGo4Widget::panel_PadDeleted: {
00108 if (GetSelectedPad()==pad) SetSelectedPad(0);
00109 if (fxActivePad==pad) fxActivePad=0;
00110 emit panelSignal(panel, pad, QGo4Widget::panel_PadDeleted);
00111 break;
00112 }
00113
00114 case QGo4Widget::panel_Deleted: {
00115 if (GetSelectedPad()!=0)
00116 if (panel->IsPanelPad(GetSelectedPad()))
00117 SetSelectedPad(0);
00118 if (fxActivePanel==panel) {
00119 fxActivePanel = 0;
00120 fxActivePad = 0;
00121 }
00122 emit panelSignal(panel, pad, QGo4Widget::panel_Deleted);
00123 break;
00124 }
00125 }
00126 }
00127