Procházet zdrojové kódy

Merge branch 'master' of github.com:pieper/CTK

Daniel Blezek před 15 roky
rodič
revize
a6e87e5dc4

+ 1 - 1
Applications/ctkCLIPluginExplorer/CMakeLists.txt

@@ -5,7 +5,7 @@ PROJECT(ctkCLIPluginExplorer)
 #
 #
 
 
 SET(KIT_SRCS
 SET(KIT_SRCS
-  ctkCLIPluginExplorerMain.cxx
+  ctkCLIPluginExplorerMain.cpp
 )
 )
 
 
 # Headers that should run through moc
 # Headers that should run through moc

+ 4 - 1
Applications/ctkCLIPluginExplorer/ctkCLIPluginExplorerMain.cpp

@@ -19,9 +19,12 @@
 
 
 =============================================================================*/
 =============================================================================*/
 
 
+// Qt includes
 #include <QCoreApplication>
 #include <QCoreApplication>
+#include <QDebug>
 
 
-#include <PluginFramework/ctkPluginManager.h>
+// CTK includes
+#include <ctkPluginManager.h>
 
 
 int main(int argc, char** argv)
 int main(int argc, char** argv)
 {
 {

+ 3 - 5
CMake/CTestCustom.cmake.in

@@ -33,11 +33,6 @@ SET(CTEST_CUSTOM_WARNING_MATCH
 
 
 SET(CTEST_CUSTOM_WARNING_EXCEPTION
 SET(CTEST_CUSTOM_WARNING_EXCEPTION
   ${CTEST_CUSTOM_WARNING_EXCEPTION}
   ${CTEST_CUSTOM_WARNING_EXCEPTION}
-  # cmake suppressions
-  "CMake.*Utilities.cmcurl"
-  "CMake.*Source.kwsys.*warn_unused_result"
-  "CMake.*Source.*cm.*cxx"
-  "CMake.*Source.*cm.*h"
 
 
   # kwstyle suppressions
   # kwstyle suppressions
   "[Kk][Ww][Ss]tyle.*kws.*cxx"
   "[Kk][Ww][Ss]tyle.*kws.*cxx"
@@ -80,4 +75,7 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION
   
   
   # Visual studio spurious warnings...
   # Visual studio spurious warnings...
   "The following environment variables were not found"
   "The following environment variables were not found"
+  
+  # QtMobility 
+  "warning: jobserver unavailable: using -j1.  Add `+' to parent make rule."
   )
   )

+ 4 - 4
Libs/Widgets/CMakeLists.txt

@@ -9,7 +9,7 @@ SET(KIT_export_directive "CTK_WIDGETS_EXPORT")
 # Additional directories to include
 # Additional directories to include
 SET(KIT_include_directories
 SET(KIT_include_directories
   )
   )
-  
+
 # Source files
 # Source files
 SET(KIT_SRCS
 SET(KIT_SRCS
   ctkAddRemoveComboBox.cpp
   ctkAddRemoveComboBox.cpp
@@ -20,6 +20,8 @@ SET(KIT_SRCS
   ctkCheckableHeaderView.h
   ctkCheckableHeaderView.h
   ctkCheckBoxPixmaps.cpp
   ctkCheckBoxPixmaps.cpp
   ctkCheckBoxPixmaps.h
   ctkCheckBoxPixmaps.h
+  ctkComboBox.cpp
+  ctkComboBox.h
   ctkCollapsibleButton.cpp
   ctkCollapsibleButton.cpp
   ctkCollapsibleButton.h
   ctkCollapsibleButton.h
   ctkCollapsibleGroupBox.cpp
   ctkCollapsibleGroupBox.cpp
@@ -54,8 +56,6 @@ SET(KIT_SRCS
   ctkSliderSpinBoxWidget.h
   ctkSliderSpinBoxWidget.h
   ctkTestApplication.cpp
   ctkTestApplication.cpp
   ctkTestApplication.h
   ctkTestApplication.h
-  ctkTitleComboBox.cpp
-  ctkTitleComboBox.h
   ctkTransferFunctionControlPointsItem.cpp
   ctkTransferFunctionControlPointsItem.cpp
   ctkTransferFunctionControlPointsItem.h
   ctkTransferFunctionControlPointsItem.h
   ctkTransferFunctionGradientItem.cpp
   ctkTransferFunctionGradientItem.cpp
@@ -78,6 +78,7 @@ SET(KIT_MOC_SRCS
   ctkButtonGroup.h
   ctkButtonGroup.h
   ctkCheckableHeaderView.h
   ctkCheckableHeaderView.h
   ctkCheckBoxPixmaps.h
   ctkCheckBoxPixmaps.h
+  ctkComboBox.h
   ctkCollapsibleButton.h
   ctkCollapsibleButton.h
   ctkCollapsibleGroupBox.h
   ctkCollapsibleGroupBox.h
   ctkColorPickerButton.h
   ctkColorPickerButton.h
@@ -95,7 +96,6 @@ SET(KIT_MOC_SRCS
   ctkSettings.h
   ctkSettings.h
   ctkSliderSpinBoxWidget.h
   ctkSliderSpinBoxWidget.h
   ctkTestApplication.h
   ctkTestApplication.h
-  ctkTitleComboBox.h
   ctkTransferFunctionControlPointsItem.h
   ctkTransferFunctionControlPointsItem.h
   ctkTransferFunctionGradientItem.h
   ctkTransferFunctionGradientItem.h
   ctkTransferFunctionBarsItem.h
   ctkTransferFunctionBarsItem.h

+ 3 - 3
Libs/Widgets/Plugins/CMakeLists.txt

@@ -13,6 +13,8 @@ SET(PLUGIN_SRCS
   ctkWidgetsAbstractPlugin.cpp
   ctkWidgetsAbstractPlugin.cpp
   ctkWidgetsAbstractPlugin.h
   ctkWidgetsAbstractPlugin.h
 
 
+  ctkComboBoxPlugin.cpp
+  ctkComboBoxPlugin.h
   ctkCollapsibleButtonPlugin.cpp
   ctkCollapsibleButtonPlugin.cpp
   ctkCollapsibleButtonPlugin.h
   ctkCollapsibleButtonPlugin.h
   ctkCollapsibleGroupBoxPlugin.cpp
   ctkCollapsibleGroupBoxPlugin.cpp
@@ -41,8 +43,6 @@ SET(PLUGIN_SRCS
   ctkRangeSliderPlugin.h
   ctkRangeSliderPlugin.h
   ctkRangeWidgetPlugin.cpp
   ctkRangeWidgetPlugin.cpp
   ctkRangeWidgetPlugin.h
   ctkRangeWidgetPlugin.h
-  ctkTitleComboBoxPlugin.cpp
-  ctkTitleComboBoxPlugin.h
   ctkTransferFunctionWidgetPlugin.cpp
   ctkTransferFunctionWidgetPlugin.cpp
   ctkTransferFunctionWidgetPlugin.h
   ctkTransferFunctionWidgetPlugin.h
   ctkTreeComboBoxPlugin.cpp
   ctkTreeComboBoxPlugin.cpp
@@ -55,6 +55,7 @@ SET(PLUGIN_SRCS
 SET(PLUGIN_MOC_SRCS
 SET(PLUGIN_MOC_SRCS
   ctkWidgetsPlugins.h
   ctkWidgetsPlugins.h
 
 
+  ctkComboBoxPlugin.h
   ctkCollapsibleButtonPlugin.h
   ctkCollapsibleButtonPlugin.h
   ctkCollapsibleGroupBoxPlugin.h
   ctkCollapsibleGroupBoxPlugin.h
   ctkColorPickerButtonPlugin.h
   ctkColorPickerButtonPlugin.h
@@ -69,7 +70,6 @@ SET(PLUGIN_MOC_SRCS
   ctkMenuButtonPlugin.h
   ctkMenuButtonPlugin.h
   ctkRangeSliderPlugin.h
   ctkRangeSliderPlugin.h
   ctkRangeWidgetPlugin.h
   ctkRangeWidgetPlugin.h
-  ctkTitleComboBoxPlugin.h
   ctkTransferFunctionWidgetPlugin.h
   ctkTransferFunctionWidgetPlugin.h
   ctkTreeComboBoxPlugin.h
   ctkTreeComboBoxPlugin.h
   ctkSliderSpinBoxWidgetPlugin.h
   ctkSliderSpinBoxWidgetPlugin.h

+ 15 - 15
Libs/Widgets/Plugins/ctkTitleComboBoxPlugin.cpp

@@ -1,7 +1,7 @@
 /*=========================================================================
 /*=========================================================================
 
 
   Library:   CTK
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
   Copyright (c) 2010  Kitware Inc.
 
 
   Licensed under the Apache License, Version 2.0 (the "License");
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,55 +15,55 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   See the License for the specific language governing permissions and
   limitations under the License.
   limitations under the License.
- 
+
 =========================================================================*/
 =========================================================================*/
 
 
 // CTK includes
 // CTK includes
-#include "ctkTitleComboBoxPlugin.h"
-#include "ctkTitleComboBox.h"
+#include "ctkComboBoxPlugin.h"
+#include "ctkComboBox.h"
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-ctkTitleComboBoxPlugin::ctkTitleComboBoxPlugin(QObject *_parent)
+ctkComboBoxPlugin::ctkComboBoxPlugin(QObject *_parent)
         : QObject(_parent)
         : QObject(_parent)
 {
 {
 
 
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-QWidget *ctkTitleComboBoxPlugin::createWidget(QWidget *_parent)
+QWidget *ctkComboBoxPlugin::createWidget(QWidget *_parent)
 {
 {
-  ctkTitleComboBox* _widget = new ctkTitleComboBox(_parent);
+  ctkComboBox* _widget = new ctkComboBox(_parent);
   return _widget;
   return _widget;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-QString ctkTitleComboBoxPlugin::domXml() const
+QString ctkComboBoxPlugin::domXml() const
 {
 {
-  return "<widget class=\"ctkTitleComboBox\" \
+  return "<widget class=\"ctkComboBox\" \
           name=\"CTKTitleComboBox\">\n"
           name=\"CTKTitleComboBox\">\n"
           "</widget>\n";
           "</widget>\n";
 }
 }
 
 
 // --------------------------------------------------------------------------
 // --------------------------------------------------------------------------
-QIcon ctkTitleComboBoxPlugin::icon() const
+QIcon ctkComboBoxPlugin::icon() const
 {
 {
   return QIcon(":/Icons/combobox.png");
   return QIcon(":/Icons/combobox.png");
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-QString ctkTitleComboBoxPlugin::includeFile() const
+QString ctkComboBoxPlugin::includeFile() const
 {
 {
-  return "ctkTitleComboBox.h";
+  return "ctkComboBox.h";
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-bool ctkTitleComboBoxPlugin::isContainer() const
+bool ctkComboBoxPlugin::isContainer() const
 {
 {
   return false;
   return false;
 }
 }
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-QString ctkTitleComboBoxPlugin::name() const
+QString ctkComboBoxPlugin::name() const
 {
 {
-  return "ctkTitleComboBox";
+  return "ctkComboBox";
 }
 }

+ 7 - 7
Libs/Widgets/Plugins/ctkTitleComboBoxPlugin.h

@@ -1,7 +1,7 @@
 /*=========================================================================
 /*=========================================================================
 
 
   Library:   CTK
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
   Copyright (c) 2010  Kitware Inc.
 
 
   Licensed under the Apache License, Version 2.0 (the "License");
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,24 +15,24 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   See the License for the specific language governing permissions and
   limitations under the License.
   limitations under the License.
- 
+
 =========================================================================*/
 =========================================================================*/
 
 
-#ifndef __ctkTitleComboBoxPlugin_h
-#define __ctkTitleComboBoxPlugin_h
+#ifndef __ctkComboBoxPlugin_h
+#define __ctkComboBoxPlugin_h
 
 
 // CTK includes
 // CTK includes
 #include "ctkWidgetsAbstractPlugin.h"
 #include "ctkWidgetsAbstractPlugin.h"
 
 
-class CTK_WIDGETS_PLUGINS_EXPORT ctkTitleComboBoxPlugin :
+class CTK_WIDGETS_PLUGINS_EXPORT ctkComboBoxPlugin :
   public QObject,
   public QObject,
   public ctkWidgetsAbstractPlugin
   public ctkWidgetsAbstractPlugin
 {
 {
   Q_OBJECT
   Q_OBJECT
 
 
 public:
 public:
-  ctkTitleComboBoxPlugin(QObject *_parent = 0);
-  
+  ctkComboBoxPlugin(QObject *_parent = 0);
+
   QWidget *createWidget(QWidget *_parent);
   QWidget *createWidget(QWidget *_parent);
   QString  domXml() const;
   QString  domXml() const;
   QIcon    icon() const;
   QIcon    icon() const;

+ 5 - 5
Libs/Widgets/Plugins/ctkWidgetsPlugins.h

@@ -1,7 +1,7 @@
 /*=========================================================================
 /*=========================================================================
 
 
   Library:   CTK
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
   Copyright (c) 2010  Kitware Inc.
 
 
   Licensed under the Apache License, Version 2.0 (the "License");
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,7 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   See the License for the specific language governing permissions and
   limitations under the License.
   limitations under the License.
- 
+
 =========================================================================*/
 =========================================================================*/
 
 
 #ifndef __ctkWidgetsPlugins_h
 #ifndef __ctkWidgetsPlugins_h
@@ -26,6 +26,7 @@
 
 
 // CTK includes
 // CTK includes
 #include "CTKWidgetsPluginsExport.h"
 #include "CTKWidgetsPluginsExport.h"
+#include "ctkComboBoxPlugin.h"
 #include "ctkCollapsibleButtonPlugin.h"
 #include "ctkCollapsibleButtonPlugin.h"
 #include "ctkCollapsibleGroupBoxPlugin.h"
 #include "ctkCollapsibleGroupBoxPlugin.h"
 #include "ctkColorPickerButtonPlugin.h"
 #include "ctkColorPickerButtonPlugin.h"
@@ -39,7 +40,6 @@
 #include "ctkMenuButtonPlugin.h"
 #include "ctkMenuButtonPlugin.h"
 #include "ctkRangeSliderPlugin.h"
 #include "ctkRangeSliderPlugin.h"
 #include "ctkRangeWidgetPlugin.h"
 #include "ctkRangeWidgetPlugin.h"
-#include "ctkTitleComboBoxPlugin.h"
 #include "ctkTransferFunctionWidgetPlugin.h"
 #include "ctkTransferFunctionWidgetPlugin.h"
 #include "ctkTreeComboBoxPlugin.h"
 #include "ctkTreeComboBoxPlugin.h"
 #include "ctkSliderSpinBoxWidgetPlugin.h"
 #include "ctkSliderSpinBoxWidgetPlugin.h"
@@ -55,7 +55,8 @@ public:
   QList<QDesignerCustomWidgetInterface*> customWidgets() const
   QList<QDesignerCustomWidgetInterface*> customWidgets() const
     {
     {
     QList<QDesignerCustomWidgetInterface *> plugins;
     QList<QDesignerCustomWidgetInterface *> plugins;
-    plugins << new ctkCollapsibleButtonPlugin
+    plugins << new ctkComboBoxPlugin
+            << new ctkCollapsibleButtonPlugin
             << new ctkCollapsibleGroupBoxPlugin
             << new ctkCollapsibleGroupBoxPlugin
             << new ctkColorPickerButtonPlugin
             << new ctkColorPickerButtonPlugin
             << new ctkCoordinatesWidgetPlugin
             << new ctkCoordinatesWidgetPlugin
@@ -68,7 +69,6 @@ public:
             << new ctkMenuButtonPlugin
             << new ctkMenuButtonPlugin
             << new ctkRangeSliderPlugin
             << new ctkRangeSliderPlugin
             << new ctkRangeWidgetPlugin
             << new ctkRangeWidgetPlugin
-            << new ctkTitleComboBoxPlugin
             << new ctkTransferFunctionWidgetPlugin
             << new ctkTransferFunctionWidgetPlugin
             << new ctkTreeComboBoxPlugin
             << new ctkTreeComboBoxPlugin
             << new ctkSliderSpinBoxWidgetPlugin;
             << new ctkSliderSpinBoxWidgetPlugin;

+ 2 - 2
Libs/Widgets/Testing/Cpp/CMakeLists.txt

@@ -8,6 +8,7 @@ CREATE_TEST_SOURCELIST(Tests ${KIT}CppTests.cxx
   ctkCollapsibleButtonTest1.cpp
   ctkCollapsibleButtonTest1.cpp
   ctkCollapsibleGroupBoxTest1.cpp
   ctkCollapsibleGroupBoxTest1.cpp
   ctkColorPickerButtonTest1.cpp
   ctkColorPickerButtonTest1.cpp
+  ctkComboBoxTest1.cpp
   ctkCoordinatesWidgetTest1.cpp
   ctkCoordinatesWidgetTest1.cpp
   ctkDoubleRangeSliderTest1.cpp
   ctkDoubleRangeSliderTest1.cpp
   ctkDoubleSliderTest1.cpp
   ctkDoubleSliderTest1.cpp
@@ -16,7 +17,6 @@ CREATE_TEST_SOURCELIST(Tests ${KIT}CppTests.cxx
   ctkRangeSliderTest1.cpp
   ctkRangeSliderTest1.cpp
   ctkRangeWidgetTest1.cpp
   ctkRangeWidgetTest1.cpp
   ctkSliderSpinBoxWidgetTest1.cpp
   ctkSliderSpinBoxWidgetTest1.cpp
-  ctkTitleComboBoxTest1.cpp
   ctkTreeComboBoxTest1.cpp
   ctkTreeComboBoxTest1.cpp
   )
   )
 
 
@@ -49,6 +49,7 @@ SIMPLE_TEST( ctkCheckableHeaderViewTest1 )
 SIMPLE_TEST( ctkCollapsibleButtonTest1 )
 SIMPLE_TEST( ctkCollapsibleButtonTest1 )
 SIMPLE_TEST( ctkCollapsibleGroupBoxTest1 )
 SIMPLE_TEST( ctkCollapsibleGroupBoxTest1 )
 SIMPLE_TEST( ctkColorPickerButtonTest1 )
 SIMPLE_TEST( ctkColorPickerButtonTest1 )
+SIMPLE_TEST( ctkComboBoxTest1 )
 SIMPLE_TEST( ctkCoordinatesWidgetTest1 )
 SIMPLE_TEST( ctkCoordinatesWidgetTest1 )
 SIMPLE_TEST( ctkDoubleRangeSliderTest1 )
 SIMPLE_TEST( ctkDoubleRangeSliderTest1 )
 SIMPLE_TEST( ctkDoubleSliderTest1 )
 SIMPLE_TEST( ctkDoubleSliderTest1 )
@@ -57,5 +58,4 @@ SIMPLE_TEST( ctkMatrixWidgetTest1 )
 SIMPLE_TEST( ctkRangeSliderTest1 )
 SIMPLE_TEST( ctkRangeSliderTest1 )
 SIMPLE_TEST( ctkRangeWidgetTest1 )
 SIMPLE_TEST( ctkRangeWidgetTest1 )
 SIMPLE_TEST( ctkSliderSpinBoxWidgetTest1 )
 SIMPLE_TEST( ctkSliderSpinBoxWidgetTest1 )
-SIMPLE_TEST( ctkTitleComboBoxTest1 )
 SIMPLE_TEST( ctkTreeComboBoxTest1 )
 SIMPLE_TEST( ctkTreeComboBoxTest1 )

+ 5 - 6
Libs/Widgets/Testing/Cpp/ctkTitleComboBoxTest1.cpp

@@ -1,7 +1,7 @@
 /*=========================================================================
 /*=========================================================================
 
 
   Library:   CTK
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
   Copyright (c) 2010  Kitware Inc.
 
 
   Licensed under the Apache License, Version 2.0 (the "License");
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,26 +15,25 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   See the License for the specific language governing permissions and
   limitations under the License.
   limitations under the License.
- 
+
 =========================================================================*/
 =========================================================================*/
 
 
 // Qt includes
 // Qt includes
 #include <QApplication>
 #include <QApplication>
 
 
 // CTK includes
 // CTK includes
-#include "ctkTitleComboBox.h"
+#include "ctkComboBox.h"
 
 
 // STD includes
 // STD includes
 #include <stdlib.h>
 #include <stdlib.h>
 #include <iostream>
 #include <iostream>
 
 
 //-----------------------------------------------------------------------------
 //-----------------------------------------------------------------------------
-int ctkTitleComboBoxTest1(int argc, char * argv [] )
+int ctkComboBoxTest1(int argc, char * argv [] )
 {
 {
   QApplication app(argc, argv);
   QApplication app(argc, argv);
 
 
-  ctkTitleComboBox ctkObject;
-
+  ctkComboBox ctkObject;
 
 
   return EXIT_SUCCESS;
   return EXIT_SUCCESS;
 }
 }

+ 258 - 0
Libs/Widgets/ctkComboBox.cpp

@@ -0,0 +1,258 @@
+/*=========================================================================
+
+  Library:   CTK
+
+  Copyright (c) 2010  Kitware Inc.
+
+  Licensed under the Apache License, Version 2.0 (the "License");
+  you may not use this file except in compliance with the License.
+  You may obtain a copy of the License at
+
+      http://www.commontk.org/LICENSE
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+
+=========================================================================*/
+
+// Qt includes
+#include <QStylePainter>
+#include <QApplication>
+#include <QDebug>
+
+// CTK includes
+#include "ctkComboBox.h"
+
+// -------------------------------------------------------------------------
+class ctkComboBoxPrivate: public ctkPrivate<ctkComboBox>
+{
+public:
+  ctkComboBoxPrivate();
+  void initStyleOption(QStyleOptionComboBox* opt)const;
+  QSize recomputeSizeHint(QSize &sh) const;
+  QString DefaultText;
+  QIcon   DefaultIcon;
+  bool    ForceDefault;
+
+  mutable QSize MinimumSizeHint;
+  mutable QSize SizeHint;
+};
+
+// -------------------------------------------------------------------------
+ctkComboBoxPrivate::ctkComboBoxPrivate()
+{
+  this->DefaultText = "Select an item...";
+  this->ForceDefault = false;
+}
+
+// -------------------------------------------------------------------------
+ctkComboBox::ctkComboBox(QWidget* _parent)
+  : QComboBox(_parent)
+{
+  CTK_INIT_PRIVATE(ctkComboBox);
+}
+
+// -------------------------------------------------------------------------
+ctkComboBox::~ctkComboBox()
+{
+}
+
+// -------------------------------------------------------------------------
+void ctkComboBox::setDefaultText(const QString& newDefaultText)
+{
+  CTK_D(ctkComboBox);
+  d->DefaultText = newDefaultText;
+  d->SizeHint = QSize();
+  this->updateGeometry();
+}
+
+// -------------------------------------------------------------------------
+QString ctkComboBox::defaultText()const
+{
+  CTK_D(const ctkComboBox);
+  return d->DefaultText;
+}
+
+// -------------------------------------------------------------------------
+void ctkComboBox::setDefaultIcon(const QIcon& newIcon)
+{
+  CTK_D(ctkComboBox);
+  d->DefaultIcon = newIcon;
+  d->SizeHint = QSize();
+  this->updateGeometry();
+}
+
+// -------------------------------------------------------------------------
+QIcon ctkComboBox::defaultIcon()const
+{
+  CTK_D(const ctkComboBox);
+  return d->DefaultIcon;
+}
+
+// -------------------------------------------------------------------------
+void ctkComboBox::forceDefault(bool newForceDefault)
+{
+  CTK_D(ctkComboBox);
+  if (newForceDefault == d->ForceDefault)
+    {
+    return;
+    }
+  d->ForceDefault = newForceDefault;
+  d->SizeHint = QSize();
+  this->updateGeometry();
+}
+
+// -------------------------------------------------------------------------
+bool ctkComboBox::isDefaultForced()const
+{
+  CTK_D(const ctkComboBox);
+  return d->ForceDefault;
+}
+
+// -------------------------------------------------------------------------
+void ctkComboBox::paintEvent(QPaintEvent*)
+{
+  CTK_D(ctkComboBox);
+  QStylePainter painter(this);
+  painter.setPen(palette().color(QPalette::Text));
+
+  QStyleOptionComboBox opt;
+  d->initStyleOption(&opt);
+
+  // draw the combobox frame, focusrect and selected etc.
+  painter.drawComplexControl(QStyle::CC_ComboBox, opt);
+  // draw the icon and text
+  painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
+}
+
+// -------------------------------------------------------------------------
+QSize ctkComboBox::minimumSizeHint() const
+{
+  CTK_D(const ctkComboBox);
+  return d->recomputeSizeHint(d->MinimumSizeHint);
+}
+
+// -------------------------------------------------------------------------
+/*!
+    \reimp
+
+    This implementation caches the size hint to avoid resizing when
+    the contents change dynamically. To invalidate the cached value
+    change the \l sizeAdjustPolicy.
+*/
+QSize ctkComboBox::sizeHint() const
+{
+  CTK_D(const ctkComboBox);
+  return d->recomputeSizeHint(d->SizeHint);
+}
+
+// -------------------------------------------------------------------------
+QSize ctkComboBoxPrivate::recomputeSizeHint(QSize &sh) const
+{
+  CTK_P(const ctkComboBox);
+  if (sh.isValid())
+    {
+    return sh.expandedTo(QApplication::globalStrut());
+    }
+
+  bool hasIcon = false;
+  int count = p->count();
+  QSize iconSize = p->iconSize();
+  const QFontMetrics &fm = p->fontMetrics();
+
+  // text width
+  if (&sh == &this->SizeHint || p->minimumContentsLength() == 0)
+    {
+    switch (p->sizeAdjustPolicy())
+      {
+      case QComboBox::AdjustToContents:
+      case QComboBox::AdjustToContentsOnFirstShow:
+        if (count == 0 || this->ForceDefault)
+          {
+          sh.rwidth() = this->DefaultText.isEmpty() ?
+            7 * fm.width(QLatin1Char('x')) :
+            fm.boundingRect(this->DefaultText).width();
+          if (!this->DefaultIcon.isNull())
+            {
+            hasIcon = true;
+            sh.rwidth() += iconSize.width() + 4;
+            }
+          }
+        for (int i = 0; i < count; ++i)
+          {
+          if (!p->itemIcon(i).isNull())
+            {
+            hasIcon = true;
+            sh.setWidth(qMax(sh.width(), fm.boundingRect(p->itemText(i)).width() + iconSize.width() + 4));
+            }
+          else
+            {
+            sh.setWidth(qMax(sh.width(), fm.boundingRect(p->itemText(i)).width()));
+            }
+          }
+        break;
+      case QComboBox::AdjustToMinimumContentsLength:
+        if ((count == 0 || this->ForceDefault) && !this->DefaultIcon.isNull())
+          {
+          hasIcon = true;
+          }
+        for (int i = 0; i < count && !hasIcon; ++i)
+          {
+          hasIcon = !p->itemIcon(i).isNull();
+          }
+        break;
+      case QComboBox::AdjustToMinimumContentsLengthWithIcon:
+        hasIcon = true;
+        break;
+      default:
+        break;
+      }
+    }
+  else // minimumsizehint is computing and minimumcontentslenght is > 0
+    {
+    if ((count == 0 || this->ForceDefault) && !this->DefaultIcon.isNull())
+      {
+      hasIcon = true;
+      }
+
+    for (int i = 0; i < count && !hasIcon; ++i)
+      {
+      hasIcon = !p->itemIcon(i).isNull();
+      }
+    }
+  if (p->minimumContentsLength() > 0)
+    {
+    sh.setWidth(qMax(sh.width(),
+                     p->minimumContentsLength() * fm.width(QLatin1Char('X'))
+                     + (hasIcon ? iconSize.width() + 4 : 0)));
+    }
+
+  // height
+  sh.setHeight(qMax(fm.height(), 14) + 2);
+  if (hasIcon)
+    {
+    sh.setHeight(qMax(sh.height(), iconSize.height() + 2));
+    }
+
+  // add style and strut values
+  QStyleOptionComboBox opt;
+  this->initStyleOption(&opt);
+  sh = p->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, sh, p);
+  return sh.expandedTo(QApplication::globalStrut());
+}
+
+// -------------------------------------------------------------------------
+void ctkComboBoxPrivate::initStyleOption(QStyleOptionComboBox* opt)const
+{
+  CTK_P(const ctkComboBox);
+  p->initStyleOption(opt);
+  if (p->currentIndex() == -1 ||
+      this->ForceDefault)
+    {
+    opt->currentText = this->DefaultText;
+    opt->currentIcon = this->DefaultIcon;
+    }
+}

+ 21 - 20
Libs/Widgets/ctkTitleComboBox.h

@@ -1,7 +1,7 @@
 /*=========================================================================
 /*=========================================================================
 
 
   Library:   CTK
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
   Copyright (c) 2010  Kitware Inc.
 
 
   Licensed under the Apache License, Version 2.0 (the "License");
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,47 +15,48 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   See the License for the specific language governing permissions and
   limitations under the License.
   limitations under the License.
- 
+
 =========================================================================*/
 =========================================================================*/
 
 
-#ifndef __ctkTitleComboBox_h
-#define __ctkTitleComboBox_h
+#ifndef __ctkComboBox_h
+#define __ctkComboBox_h
 
 
 // Qt includes
 // Qt includes
 #include <QComboBox>
 #include <QComboBox>
 
 
 // CTK includes
 // CTK includes
+#include "ctkPimpl.h"
 #include "CTKWidgetsExport.h"
 #include "CTKWidgetsExport.h"
+class ctkComboBoxPrivate;
 
 
-class CTK_WIDGETS_EXPORT ctkTitleComboBox : public QComboBox
+class CTK_WIDGETS_EXPORT ctkComboBox : public QComboBox
 {
 {
   Q_OBJECT
   Q_OBJECT
-  Q_PROPERTY(QString title READ title WRITE setTitle)
-  Q_PROPERTY(QIcon icon READ icon WRITE setIcon)
+  Q_PROPERTY(QString defaultText READ defaultText WRITE setDefaultText)
+  Q_PROPERTY(QIcon defaultIcon READ defaultIcon WRITE setDefaultIcon)
+  Q_PROPERTY(bool forceDefault READ isDefaultForced WRITE forceDefault)
 
 
 public:
 public:
-  explicit ctkTitleComboBox(QWidget* parent = 0);
-  virtual ~ctkTitleComboBox();
+  explicit ctkComboBox(QWidget* parent = 0);
+  virtual ~ctkComboBox();
+
+  void setDefaultText(const QString&);
+  QString defaultText()const;
+
+  void setDefaultIcon(const QIcon&);
+  QIcon defaultIcon()const;
 
 
-  void setTitle(const QString&);
-  QString title()const;
-  
-  void setIcon(const QIcon&);
-  QIcon icon()const;
+  void forceDefault(bool forceDefault);
+  bool isDefaultForced()const;
 
 
   virtual QSize minimumSizeHint()const;
   virtual QSize minimumSizeHint()const;
   virtual QSize sizeHint()const;
   virtual QSize sizeHint()const;
 
 
 protected:
 protected:
   virtual void paintEvent(QPaintEvent*);
   virtual void paintEvent(QPaintEvent*);
-  virtual QSize recomputeSizeHint(QSize &sh)const;
 
 
-  QString Title;
-  QIcon   Icon;
-  
 private:
 private:
-  mutable QSize MinimumSizeHint;
-  mutable QSize SizeHint;
+  CTK_DECLARE_PRIVATE(ctkComboBox);
 };
 };
 
 
 #endif
 #endif

+ 15 - 4
Libs/Widgets/ctkDirectoryButton.cpp

@@ -102,12 +102,23 @@ void ctkDirectoryButton::setDirectory(const QString& dir)
 {
 {
   CTK_D(ctkDirectoryButton);
   CTK_D(ctkDirectoryButton);
   QDir newDirectory(dir);
   QDir newDirectory(dir);
+
   if (d->Directory == newDirectory)
   if (d->Directory == newDirectory)
     {
     {
+    emit directorySelected(d->DisplayAbsolutePath ?
+                           newDirectory.absolutePath() :
+                           newDirectory.path());
     return;
     return;
     }
     }
+
   d->Directory = newDirectory;
   d->Directory = newDirectory;
+
   d->PushButton->setText(d->DisplayAbsolutePath ? d->Directory.absolutePath() : d->Directory.path());
   d->PushButton->setText(d->DisplayAbsolutePath ? d->Directory.absolutePath() : d->Directory.path());
+
+  emit directorySelected(d->DisplayAbsolutePath ?
+                         newDirectory.absolutePath() :
+                         newDirectory.path());
+
   emit directoryChanged(d->DisplayAbsolutePath ? d->Directory.absolutePath() : d->Directory.path());
   emit directoryChanged(d->DisplayAbsolutePath ? d->Directory.absolutePath() : d->Directory.path());
 }
 }
 
 
@@ -150,11 +161,11 @@ const ctkDirectoryButton::Options& ctkDirectoryButton::options()const
 void ctkDirectoryButton::browse()
 void ctkDirectoryButton::browse()
 {
 {
   CTK_D(ctkDirectoryButton);
   CTK_D(ctkDirectoryButton);
-  QString dir = 
+  QString dir =
     QFileDialog::getExistingDirectory(
     QFileDialog::getExistingDirectory(
-      this, 
-      d->DialogCaption.isEmpty() ? this->toolTip() : d->DialogCaption, 
-      d->Directory.path(), 
+      this,
+      d->DialogCaption.isEmpty() ? this->toolTip() : d->DialogCaption,
+      d->Directory.path(),
       QFlags<QFileDialog::Option>(int(d->DialogOptions)));
       QFlags<QFileDialog::Option>(int(d->DialogOptions)));
   // An empty directory means that the user cancelled the dialog.
   // An empty directory means that the user cancelled the dialog.
   if (dir.isEmpty())
   if (dir.isEmpty())

+ 7 - 7
Libs/Widgets/ctkDirectoryButton.h

@@ -1,7 +1,7 @@
 /*=========================================================================
 /*=========================================================================
 
 
   Library:   CTK
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
   Copyright (c) 2010  Kitware Inc.
 
 
   Licensed under the Apache License, Version 2.0 (the "License");
   Licensed under the Apache License, Version 2.0 (the "License");
@@ -15,7 +15,7 @@
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   See the License for the specific language governing permissions and
   limitations under the License.
   limitations under the License.
- 
+
 =========================================================================*/
 =========================================================================*/
 
 
 #ifndef __ctkDirectoryButton_h
 #ifndef __ctkDirectoryButton_h
@@ -39,7 +39,7 @@ class CTK_WIDGETS_EXPORT ctkDirectoryButton: public QWidget
   // QFileDialog::Options is not a meta-type, we need to create our own.
   // QFileDialog::Options is not a meta-type, we need to create our own.
   Q_FLAGS(Option Options);
   Q_FLAGS(Option Options);
 
 
-public: 
+public:
   // QFileDialog::Options is not a meta-type, we need to create our own.
   // QFileDialog::Options is not a meta-type, we need to create our own.
   enum Option
   enum Option
     {
     {
@@ -52,20 +52,20 @@ public:
       HideNameFilterDetails = 0x00000040
       HideNameFilterDetails = 0x00000040
     };
     };
   Q_DECLARE_FLAGS(Options, Option)
   Q_DECLARE_FLAGS(Options, Option)
-    
+
   ctkDirectoryButton(QWidget * parent = 0);
   ctkDirectoryButton(QWidget * parent = 0);
   ctkDirectoryButton(const QString& directory, QWidget * parent = 0);
   ctkDirectoryButton(const QString& directory, QWidget * parent = 0);
   ctkDirectoryButton(const QIcon& icon, const QString& directory, QWidget * parent = 0);
   ctkDirectoryButton(const QIcon& icon, const QString& directory, QWidget * parent = 0);
 
 
   void setDirectory(const QString& directory);
   void setDirectory(const QString& directory);
   QString directory()const;
   QString directory()const;
-  
+
   ///
   ///
   /// The title of the file dialog used to select a new directory
   /// The title of the file dialog used to select a new directory
   /// If caption is not set, internally use QWidget::tooltip()
   /// If caption is not set, internally use QWidget::tooltip()
   void setCaption(const QString& caption);
   void setCaption(const QString& caption);
   const QString& caption()const;
   const QString& caption()const;
-  
+
   void setOptions(const Options& options);
   void setOptions(const Options& options);
   const Options& options()const;
   const Options& options()const;
 
 
@@ -77,7 +77,7 @@ signals:
   /// directoryChanged is emitted when the current directory changes
   /// directoryChanged is emitted when the current directory changes
   ///if you want a directoryChanged signal as a utility. Feel free to add it
   ///if you want a directoryChanged signal as a utility. Feel free to add it
   void directoryChanged(const QString&);
   void directoryChanged(const QString&);
-
+  void directorySelected(const QString&);
 private:
 private:
   CTK_DECLARE_PRIVATE(ctkDirectoryButton);
   CTK_DECLARE_PRIVATE(ctkDirectoryButton);
 };
 };

+ 36 - 29
Libs/Widgets/ctkRangeWidget.h

@@ -31,6 +31,10 @@
 
 
 class ctkRangeWidgetPrivate;
 class ctkRangeWidgetPrivate;
 
 
+///
+/// ctkRangeWidget is a wrapper around a ctkDoubleRangeSlider and 2 QSpinBoxes
+/// \image html http:\\www.commontk.org/images/1/14/CtkRangeWidget.png
+/// \sa ctkSliderSpinBoxWidget, ctkDoubleRangeSlider, QSpinBox
 class CTK_WIDGETS_EXPORT ctkRangeWidget : public QWidget
 class CTK_WIDGETS_EXPORT ctkRangeWidget : public QWidget
 {
 {
   Q_OBJECT
   Q_OBJECT
@@ -52,23 +56,25 @@ public:
   /// Superclass typedef
   /// Superclass typedef
   typedef QWidget Superclass;
   typedef QWidget Superclass;
 
 
-  /// Constructors
+  /// Constructor
+  /// If \li parent is null, ctkRangeWidget will be a top-leve widget
+  /// \note The \li parent can be set later using QWidget::setParent()
   explicit ctkRangeWidget(QWidget* parent = 0);
   explicit ctkRangeWidget(QWidget* parent = 0);
 
 
-  /// 
+  ///
   /// This property holds the sliders and spinbox minimum value.
   /// This property holds the sliders and spinbox minimum value.
   /// FIXME: Test following specs.
   /// FIXME: Test following specs.
-  /// When setting this property, the maximum is adjusted if necessary 
-  /// to ensure that the range remains valid. 
+  /// When setting this property, the maximum is adjusted if necessary
+  /// to ensure that the range remains valid.
   /// Also the slider's current value is adjusted to be within the new range.
   /// Also the slider's current value is adjusted to be within the new range.
   double minimum()const;
   double minimum()const;
   void setMinimum(double minimum);
   void setMinimum(double minimum);
-  
-  /// 
+
+  ///
   /// This property holds the sliders and spinbox minimum value.
   /// This property holds the sliders and spinbox minimum value.
   /// FIXME: Test following specs.
   /// FIXME: Test following specs.
-  /// When setting this property, the maximum is adjusted if necessary 
-  /// to ensure that the range remains valid. 
+  /// When setting this property, the maximum is adjusted if necessary
+  /// to ensure that the range remains valid.
   /// Also the slider's current value is adjusted to be within the new range.
   /// Also the slider's current value is adjusted to be within the new range.
   double maximum()const;
   double maximum()const;
   void setMaximum(double maximum);
   void setMaximum(double maximum);
@@ -76,78 +82,79 @@ public:
   /// Utility function that set the min/max in once
   /// Utility function that set the min/max in once
   void setRange(double min, double max);
   void setRange(double min, double max);
 
 
-  /// 
+  ///
   /// This property holds the slider and spinbox minimum value.
   /// This property holds the slider and spinbox minimum value.
   /// ctkRangeWidget forces the value to be within the
   /// ctkRangeWidget forces the value to be within the
   /// legal range: minimum <= minimumValue <= maximumValue <= maximum.
   /// legal range: minimum <= minimumValue <= maximumValue <= maximum.
   double minimumValue()const;
   double minimumValue()const;
 
 
-  /// 
+  ///
   /// This property holds the slider and spinbox maximum value.
   /// This property holds the slider and spinbox maximum value.
   /// ctkRangeWidget forces the value to be within the
   /// ctkRangeWidget forces the value to be within the
   /// legal range: minimum <= minimumValue <= maximumValue <= maximum.
   /// legal range: minimum <= minimumValue <= maximumValue <= maximum.
   double maximumValue()const;
   double maximumValue()const;
 
 
-  /// 
+  ///
   /// This property holds the single step.
   /// This property holds the single step.
-  /// The smaller of two natural steps that the 
-  /// slider provides and typically corresponds to the 
+  /// The smaller of two natural steps that the
+  /// slider provides and typically corresponds to the
   /// user pressing an arrow key.
   /// user pressing an arrow key.
   double singleStep()const;
   double singleStep()const;
   void setSingleStep(double step);
   void setSingleStep(double step);
 
 
-  /// 
+  ///
   /// This property holds the precision of the spin box, in decimals.
   /// This property holds the precision of the spin box, in decimals.
-  /// Sets how many decimals the spinbox will use for displaying and interpreting doubles.
+  /// Sets how many decimals the spinbox will use for displaying and
+  /// interpreting doubles.
   int decimals()const;
   int decimals()const;
   void setDecimals(int decimals);
   void setDecimals(int decimals);
 
 
   ///
   ///
   /// This property holds the spin box's prefix.
   /// This property holds the spin box's prefix.
-  /// The prefix is prepended to the start of the displayed value. 
+  /// The prefix is prepended to the start of the displayed value.
   /// Typical use is to display a unit of measurement or a currency symbol
   /// Typical use is to display a unit of measurement or a currency symbol
   QString prefix()const;
   QString prefix()const;
   void setPrefix(const QString& prefix);
   void setPrefix(const QString& prefix);
 
 
   ///
   ///
   /// This property holds the spin box's suffix.
   /// This property holds the spin box's suffix.
-  /// The suffix is appended to the end of the displayed value. 
+  /// The suffix is appended to the end of the displayed value.
   /// Typical use is to display a unit of measurement or a currency symbol
   /// Typical use is to display a unit of measurement or a currency symbol
   QString suffix()const;
   QString suffix()const;
   void setSuffix(const QString& suffix);
   void setSuffix(const QString& suffix);
 
 
-  /// 
+  ///
   /// This property holds the interval between tickmarks.
   /// This property holds the interval between tickmarks.
-  /// This is a value interval, not a pixel interval. 
+  /// This is a value interval, not a pixel interval.
   /// If it is 0, the slider will choose between lineStep() and pageStep().
   /// If it is 0, the slider will choose between lineStep() and pageStep().
   /// The default value is 0.
   /// The default value is 0.
   double tickInterval()const;
   double tickInterval()const;
   void setTickInterval(double ti);
   void setTickInterval(double ti);
 
 
-  /// 
+  ///
   /// This property holds the alignment of the spin boxes.
   /// This property holds the alignment of the spin boxes.
   /// Possible Values are Qt::AlignTop, Qt::AlignBottom, and Qt::AlignVCenter.
   /// Possible Values are Qt::AlignTop, Qt::AlignBottom, and Qt::AlignVCenter.
   /// By default, the alignment is Qt::AlignVCenter
   /// By default, the alignment is Qt::AlignVCenter
   void setSpinBoxAlignment(Qt::Alignment alignment);
   void setSpinBoxAlignment(Qt::Alignment alignment);
   Qt::Alignment spinBoxAlignment()const;
   Qt::Alignment spinBoxAlignment()const;
-  
-  /// 
+
+  ///
   /// This property holds the alignment of the text inside the spin boxes.
   /// This property holds the alignment of the text inside the spin boxes.
   /// Possible Values are Qt::AlignLeft, Qt::AlignRight, and Qt::AlignHCenter.
   /// Possible Values are Qt::AlignLeft, Qt::AlignRight, and Qt::AlignHCenter.
   /// By default, the alignment is Qt::AlignLeft
   /// By default, the alignment is Qt::AlignLeft
   void setSpinBoxTextAlignment(Qt::Alignment alignment);
   void setSpinBoxTextAlignment(Qt::Alignment alignment);
   Qt::Alignment spinBoxTextAlignment()const;
   Qt::Alignment spinBoxTextAlignment()const;
 
 
-  /// 
+  ///
   /// This property holds whether slider tracking is enabled.
   /// This property holds whether slider tracking is enabled.
-  /// If tracking is enabled (the default), the widget emits the valueChanged() 
-  /// signal while the slider or spinbox is being dragged. If tracking is 
-  /// disabled, the widget emits the valueChanged() signal only when the user 
+  /// If tracking is enabled (the default), the widget emits the valueChanged()
+  /// signal while the slider or spinbox is being dragged. If tracking is
+  /// disabled, the widget emits the valueChanged() signal only when the user
   /// releases the slider or spinbox.
   /// releases the slider or spinbox.
   void setTracking(bool enable);
   void setTracking(bool enable);
   bool hasTracking()const;
   bool hasTracking()const;
 
 
-  /// 
+  ///
   /// Set/Get the auto spinbox width
   /// Set/Get the auto spinbox width
   /// When the autoSpinBoxWidth property is on, the width of the SpinBox is
   /// When the autoSpinBoxWidth property is on, the width of the SpinBox is
   /// set to the same width of the largest QSpinBox of its
   /// set to the same width of the largest QSpinBox of its
@@ -156,7 +163,7 @@ public:
   void setAutoSpinBoxWidth(bool autoWidth);
   void setAutoSpinBoxWidth(bool autoWidth);
 
 
 public slots:
 public slots:
-  /// 
+  ///
   /// Reset the slider and spinbox to zero (value and position)
   /// Reset the slider and spinbox to zero (value and position)
   void reset();
   void reset();
   void setMinimumValue(double value);
   void setMinimumValue(double value);
@@ -182,7 +189,7 @@ protected slots:
   void changeMaximumValue(double value);
   void changeMaximumValue(double value);
   void setMinimumToMaximumSpinBox(double minimum);
   void setMinimumToMaximumSpinBox(double minimum);
   void setMaximumToMinimumSpinBox(double maximum);
   void setMaximumToMinimumSpinBox(double maximum);
-  
+
 protected:
 protected:
   virtual bool eventFilter(QObject *obj, QEvent *event);
   virtual bool eventFilter(QObject *obj, QEvent *event);
 private:
 private:

+ 0 - 149
Libs/Widgets/ctkTitleComboBox.cpp

@@ -1,149 +0,0 @@
-/*=========================================================================
-
-  Library:   CTK
- 
-  Copyright (c) 2010  Kitware Inc.
-
-  Licensed under the Apache License, Version 2.0 (the "License");
-  you may not use this file except in compliance with the License.
-  You may obtain a copy of the License at
-
-      http://www.commontk.org/LICENSE
-
-  Unless required by applicable law or agreed to in writing, software
-  distributed under the License is distributed on an "AS IS" BASIS,
-  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-  See the License for the specific language governing permissions and
-  limitations under the License.
- 
-=========================================================================*/
-
-// Qt includes
-#include <QStylePainter>
-#include <QApplication>
-#include <QDebug>
-
-// CTK includes
-#include "ctkTitleComboBox.h"
-
-// -------------------------------------------------------------------------
-ctkTitleComboBox::ctkTitleComboBox(QWidget* _parent)
-  : QComboBox(_parent)
-{
-  this->Title = "Select an item...";
-}
-
-// -------------------------------------------------------------------------
-ctkTitleComboBox::~ctkTitleComboBox()
-{
-  
-}
-
-// -------------------------------------------------------------------------
-void ctkTitleComboBox::setTitle(const QString& _title)
-{
-  this->Title = _title;
-  this->SizeHint = QSize();
-  this->updateGeometry();
-}
-
-// -------------------------------------------------------------------------
-QString ctkTitleComboBox::title()const
-{
-  return this->Title;
-}
-
-// -------------------------------------------------------------------------
-void ctkTitleComboBox::setIcon(const QIcon& _icon)
-{
-  this->Icon = _icon;
-  this->SizeHint = QSize();
-  this->updateGeometry();
-}
-
-// -------------------------------------------------------------------------
-QIcon ctkTitleComboBox::icon()const
-{
-  return this->Icon;
-}
-
-// -------------------------------------------------------------------------
-void ctkTitleComboBox::paintEvent(QPaintEvent*)
-{
-  QStylePainter painter(this);
-  painter.setPen(palette().color(QPalette::Text));
-
-  QStyleOptionComboBox opt;
-  initStyleOption(&opt);
-
-  opt.currentText = this->Title;
-  opt.currentIcon = this->Icon;
-  if (!this->Icon.isNull() && !this->Icon.availableSizes().empty())
-    {
-    QList<QSize> sizes = this->Icon.availableSizes();
-    // TODO: pick the best size (based on the pixelMetric maybe)
-    //int iconSize = style()->pixelMetric(QStyle::PM_SmallIconSize);
-    opt.iconSize = sizes[0];
-    }
-
-  // draw the combobox frame, focusrect and selected etc.
-  painter.drawComplexControl(QStyle::CC_ComboBox, opt);
-  // draw the icon and text
-  painter.drawControl(QStyle::CE_ComboBoxLabel, opt);
-}
-
-// -------------------------------------------------------------------------
-QSize ctkTitleComboBox::minimumSizeHint() const
-{
-  return this->recomputeSizeHint(this->SizeHint);
-}
-
-// -------------------------------------------------------------------------
-/*!
-    \reimp
-
-    This implementation caches the size hint to avoid resizing when
-    the contents change dynamically. To invalidate the cached value
-    change the \l sizeAdjustPolicy.
-*/
-QSize ctkTitleComboBox::sizeHint() const
-{
-  return this->recomputeSizeHint(this->SizeHint);
-}
-
-// -------------------------------------------------------------------------
-QSize ctkTitleComboBox::recomputeSizeHint(QSize &sh) const
-{
-  if (sh.isValid()) 
-    {
-    return sh.expandedTo(QApplication::globalStrut());
-    }
-  const QFontMetrics &fm = this->fontMetrics();
-  QList<QSize> iconSizes = this->Icon.availableSizes();
-  if (!this->Icon.isNull() && !iconSizes.empty()) 
-    {
-    // TODO: pick the best size (based on the pixelMetric maybe)
-    QSize _iconSize = iconSizes[0];
-    sh.setWidth(qMax(sh.width(), fm.boundingRect(this->Title).width() + _iconSize.width() + 4));
-    }
-  else
-    {
-    sh.setWidth(qMax(sh.width(), fm.boundingRect(this->Title).width()));
-    }
-
-  // height
-  sh.setHeight(qMax(fm.lineSpacing(), 14) + 2);
-  if (!this->Icon.isNull() && !iconSizes.empty()) 
-    {
-    // TODO: pick the best size (based on the pixelMetric maybe)
-    QSize _iconSize = iconSizes[0];
-    sh.setHeight(qMax(sh.height(), _iconSize.height() + 2));
-    }
-
-  // add style and strut values
-  QStyleOptionComboBox opt;
-  this->initStyleOption(&opt);
-  sh = this->style()->sizeFromContents(QStyle::CT_ComboBox, &opt, sh, this);
-
-  return sh.expandedTo(QApplication::globalStrut());
-}

+ 1 - 1
Utilities/CMake/FindPythonQt.cmake

@@ -18,7 +18,7 @@ MARK_AS_ADVANCED(PYTHONQT_INCLUDE_DIR)
 MARK_AS_ADVANCED(PYTHONQT_LIBRARY)
 MARK_AS_ADVANCED(PYTHONQT_LIBRARY)
 
 
 # On linux, also find libutil
 # On linux, also find libutil
-IF(NOT WIN32)
+IF(UNIX AND NOT APPLE)
   FIND_LIBRARY(PYTHONQT_LIBUTIL util)
   FIND_LIBRARY(PYTHONQT_LIBUTIL util)
   MARK_AS_ADVANCED(PYTHONQT_LIBUTIL)
   MARK_AS_ADVANCED(PYTHONQT_LIBUTIL)
 ENDIF()
 ENDIF()