Salome HOME
NRI : Temporary modification for reading catalog of modules.
[modules/kernel.git] / src / SALOMEGUI / QAD_StudyFrame.cxx
1 using namespace std;
2 //  File      : QAD_StudyFrame.cxx
3 //  Created   : Sun Jul 22 15:31:59 2001
4 //  Author    : Nicolas REJNERI
5 //  Project   : SALOME
6 //  Module    : SALOMEGUI
7 //  Copyright : Open CASCADE
8 //  $Header$
9
10 /*!
11   \class QAD_StudyFrame QAD_StudyFrame.h
12   \brief Frame window which contains QAD_LeftFrame and QAD_RightFrame.
13 */
14
15 #include "QAD_StudyFrame.h"
16 #include "QAD_RightFrame.h"
17 #include "QAD_LeftFrame.h"
18 #include "QAD_Application.h"
19 #include "QAD_Desktop.h"
20 #include "QAD_Study.h"
21 #include "QAD_ObjectBrowser.h"
22 #include <qvaluelist.h>
23
24 /*!
25     Constructor
26 */
27 QAD_StudyFrame::QAD_StudyFrame(QAD_Study* study, QWidget* parent, const QString& title, 
28                                QAD_PyInterp* interp, ViewType typeView) :
29   QMainWindow( parent , title,  WStyle_NormalBorder | 
30                WStyle_MinMax | WStyle_SysMenu | WDestructiveClose),
31   myStudy(study)
32 {
33   myTypeView = typeView;
34   myTitle = title;
35   setCaption( myTitle );
36   setPalette(QAD_Application::getPalette());
37
38   myEntry = "";
39   _interp = interp;
40
41   s1 = new QAD_Splitter( Qt::Horizontal, this);
42   s1->setCompressEnabled( true );
43
44   setCentralWidget( s1 );
45   myLeftFrm = new QAD_LeftFrame(study->getStudyDocument(), s1 , title );
46   myRightFrm = new QAD_RightFrame( s1, title, _interp, myTypeView);
47
48   QValueList<int> sizes;
49   sizes.append( 0.30*QAD_Application::getDesktop()->getMainFrame()->width() );
50   sizes.append( 0.50*QAD_Application::getDesktop()->getMainFrame()->width() );
51   s1->setSizes( sizes );
52
53   QAD_ASSERT_DEBUG_ONLY ( parent->inherits("QWorkspaceP") );
54   QAD_ASSERT ( QObject::connect( (QWorkspaceP*)parent, SIGNAL(windowActivated(QWidget*)), 
55                                  this, SLOT(onStudyFrameActivated(QWidget*))) );
56 }
57
58 /*!
59     Constructor
60 */
61 QAD_StudyFrame::QAD_StudyFrame(QAD_Study* study, QWidget* parent  ) :
62   QMainWindow ( parent ),
63   myStudy(study)
64 {
65 }
66
67 /*!
68     Destructor
69 */
70 QAD_StudyFrame::~QAD_StudyFrame()
71
72 }
73
74 /*!
75     Returns the rightframe of this frame        
76 */
77 QAD_RightFrame* QAD_StudyFrame::getRightFrame() const
78 {
79   return myRightFrm;
80 }
81
82 /*!
83     Returns the leftframe of this frame 
84 */
85 QAD_LeftFrame* QAD_StudyFrame::getLeftFrame() const
86 {
87   return myLeftFrm;
88 }
89
90 /*!
91     Returns 'true' if studyframe is visible
92 */
93 void QAD_StudyFrame::setVisible( bool visible )
94 {
95   if ( visible == isVisible() )
96     return;
97   
98   if ( visible ) show();
99   else hide();
100 }
101
102 /*!
103    Called when StudyFrame is about to close
104 */
105 void QAD_StudyFrame::closeEvent(QCloseEvent* e)
106 {
107   emit sfBeforeStudyFrameClosing(this); 
108   emit sfStudyFrameClosing(this); 
109 }
110
111 /*!
112   Call when  
113  */
114 void QAD_StudyFrame::compressLeft()
115 {
116   s1->compress(myLeftFrm);
117 }
118
119 void QAD_StudyFrame::compressRight()
120 {
121   s1->compress(myRightFrm);  
122 }
123
124 void QAD_StudyFrame::unCompressLeft()
125 {
126   s1->unCompress(myLeftFrm);
127 }
128
129 void QAD_StudyFrame::unCompressRight()
130 {
131   s1->unCompress(myRightFrm);  
132 }
133
134 /*!
135     Returns the title of studyframe
136 */
137 const QString& QAD_StudyFrame::title() const
138 {
139     return myTitle;
140 }
141
142 /*!
143     Sets the new title of studyframe
144 */
145 void QAD_StudyFrame::setTitle( const QString& title )
146 {
147   myTitle = title;      
148   setCaption( myTitle );
149 }
150
151 /*!
152     Returns the entry of studyframe
153 */
154 const QString& QAD_StudyFrame::entry() const
155 {
156   return myEntry;
157 }
158
159 /*!
160     Sets the new entru of studyframe
161 */
162 void QAD_StudyFrame::setEntry( const QString& entry )
163 {
164   myEntry = entry;      
165 }
166
167 ViewType QAD_StudyFrame::getTypeView() const
168 {
169   return myTypeView;    
170 }
171
172 /*!
173     The slot is called when a studyframe is activated
174 */
175 void QAD_StudyFrame::onStudyFrameActivated ( QWidget* activeWindow )
176 {
177   emit sfStudyFrameActivated( (QAD_StudyFrame*) activeWindow );
178 }
179
180 /*!
181   Returns the Python interpreter that belongs to this study
182 */
183 QAD_PyInterp* QAD_StudyFrame::get_PyInterp(void)
184 {
185   return _interp;
186 }