Salome HOME
quick optimization patch (bytearray for images)
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_InputPanel.cxx
index f89653dbe2039ba7eadd9bce4077d48502704648..0049fac767fe8fe0a6300fb991e0f88c1530e04b 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#include "HYDROGUI_InputPanel.h"
-#include "HYDROGUI_Module.h"
-
-#include <CAM_Application.h>
-#include <SUIT_Desktop.h>
-
+#include <HYDROGUI_InputPanel.h>
+#ifndef LIGHT_MODE
+  #include <HYDROGUI_Module.h>
+  #include <CAM_Application.h>
+  #include <SUIT_Desktop.h>
+#endif
+
+#include <QFrame>
 #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
 : QDockWidget( theModule->application()->desktop() ),
+#endif
   myModule( theModule )
 {
   setFloating( false );
@@ -43,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 );
 
@@ -118,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
@@ -145,3 +196,8 @@ QFrame* HYDROGUI_InputPanel::buttonFrame() const
 {
   return myBtnFrame;
 }
+
+QSplitter* HYDROGUI_InputPanel::splitter() const
+{
+  return mySplitter;
+}