Salome HOME
quick optimization patch (bytearray for images)
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_InputPanel.cxx
index 3ece51e833d035ddf097191de5307063ea39eb46..0049fac767fe8fe0a6300fb991e0f88c1530e04b 100644 (file)
 #include <QLayout>
 #include <QPushButton>
 #include <QDir>
+#include <QSplitter>
 
-HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle, bool doInitLayout )
+HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QString& theTitle,
+                                          bool doInitLayout, bool isSplitter )
 #ifdef LIGHT_MODE
 : QDockWidget( 0 ),
 #else
@@ -49,6 +51,14 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr
   QBoxLayout* aMainLayout = new QVBoxLayout( myMainFrame );
   aMainLayout->setMargin( 0 );
   aMainLayout->setSpacing( 5 );
+  if( isSplitter )
+  {
+    mySplitter = new QSplitter( myMainFrame );
+    mySplitter->setOrientation( Qt::Vertical );
+    aMainLayout->addWidget( mySplitter, 1 );
+  }
+  else
+    mySplitter = 0;
     
   aLayout->addWidget( myMainFrame, 1 );
 
@@ -124,22 +134,57 @@ void HYDROGUI_InputPanel::closeEvent ( QCloseEvent * event )
   emit panelCancel();
 }
 
+void HYDROGUI_InputPanel::insertWidget( QWidget* theWidget, int theIndex, int theStretch )
+{
+  if( mySplitter )
+  {
+    mySplitter->insertWidget( theIndex, theWidget );
+    mySplitter->setStretchFactor( theIndex, theStretch );
+  }
+  else
+  {
+    QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
+    aMainLayout->insertWidget( theIndex, theWidget, theStretch );
+  }
+}
+
 void HYDROGUI_InputPanel::addWidget( QWidget* theWidget, int theStretch )
 {
-  QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
-  aMainLayout->addWidget( theWidget, theStretch );
+  if( mySplitter )
+  {
+    int s = mySplitter->count();
+    mySplitter->addWidget( theWidget );
+    mySplitter->setStretchFactor( s, theStretch );
+  }
+  else
+  {
+    QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
+    aMainLayout->addWidget( theWidget, theStretch );
+  }
 }
 
-void HYDROGUI_InputPanel::addLayout( QLayout* theLayout )
+void HYDROGUI_InputPanel::addLayout( QLayout* theLayout, int theStretch )
 {
-  QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
-  aMainLayout->addLayout( theLayout );
+  if( mySplitter )
+  {
+  }
+  else
+  {
+    QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
+    aMainLayout->addLayout( theLayout, theStretch );
+  }
 }
 
 void HYDROGUI_InputPanel::addStretch()
 {
-  QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
-  aMainLayout->addStretch();
+  if( mySplitter )
+  {
+  }
+  else
+  {
+    QBoxLayout* aMainLayout = dynamic_cast<QBoxLayout*>( myMainFrame->layout() );
+    aMainLayout->addStretch();
+  }
 }
 
 QFrame* HYDROGUI_InputPanel::mainFrame() const
@@ -151,3 +196,8 @@ QFrame* HYDROGUI_InputPanel::buttonFrame() const
 {
   return myBtnFrame;
 }
+
+QSplitter* HYDROGUI_InputPanel::splitter() const
+{
+  return mySplitter;
+}