]> Creatis software - cpPlugins.git/blobdiff - lib/cpExtensions/QT/QuadSplitter.cxx
Widget integration (step 5/6): Interactive plugins now supported, widgets updates...
[cpPlugins.git] / lib / cpExtensions / QT / QuadSplitter.cxx
diff --git a/lib/cpExtensions/QT/QuadSplitter.cxx b/lib/cpExtensions/QT/QuadSplitter.cxx
new file mode 100644 (file)
index 0000000..89fc717
--- /dev/null
@@ -0,0 +1,70 @@
+#include <cpExtensions/QT/QuadSplitter.h>
+
+#include <cpExtensions/Config.h>
+
+#ifdef cpExtensions_Interface_QT4
+
+/**
+ * Inspired by:
+ * https://forum.qt.io/topic/7144/quad-splitter-windows-an-implementation/2
+ */
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::QuadSplitter::
+QuadSplitter( QWidget* parent, Qt::WindowFlags f )
+  : QFrame( parent, f )
+{
+  this->m_Parent.setOrientation(Qt::Vertical);
+  this->m_Parent.addWidget(&this->m_Upper);
+  this->m_Parent.addWidget(&this->m_Bottom);
+
+  QObject::connect(
+    &this->m_Upper, SIGNAL( splitterMoved( int, int ) ),
+    this, SLOT( _SyncBottom( int, int ) )
+    );
+  QObject::connect(
+    &this->m_Bottom, SIGNAL( splitterMoved( int, int ) ),
+    this, SLOT( _SyncUpper( int, int ) )
+    );
+}
+
+// -------------------------------------------------------------------------
+cpExtensions::QT::QuadSplitter::
+~QuadSplitter( )
+{
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::QuadSplitter::
+show( )
+{
+  this->m_Parent.show( );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::QuadSplitter::
+addWidgets( QWidget* a, QWidget* b, QWidget* c, QWidget* d )
+{
+  this->m_Upper.addWidget( a );
+  this->m_Upper.addWidget( b );
+  this->m_Bottom.addWidget( c );
+  this->m_Bottom.addWidget( d );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::QuadSplitter::
+_SyncBottom( int a, int b )
+{
+  this->m_Bottom.setSizes( m_Upper.sizes( ) );
+}
+
+// -------------------------------------------------------------------------
+void cpExtensions::QT::QuadSplitter::
+_SyncUpper( int a, int b )
+{
+  this->m_Upper.setSizes( m_Bottom.sizes( ) );
+}
+
+#endif // cpExtensions_Interface_QT4
+
+// eof - $RCSfile$