소스 검색

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

Daniel Blezek 15 년 전
부모
커밋
a6e87e5dc4

+ 1 - 1
Applications/ctkCLIPluginExplorer/CMakeLists.txt

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

+ 4 - 1
Applications/ctkCLIPluginExplorer/ctkCLIPluginExplorerMain.cpp

@@ -19,9 +19,12 @@
 
 =============================================================================*/
 
+// Qt includes
 #include <QCoreApplication>
+#include <QDebug>
 
-#include <PluginFramework/ctkPluginManager.h>
+// CTK includes
+#include <ctkPluginManager.h>
 
 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
   ${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
   "[Kk][Ww][Ss]tyle.*kws.*cxx"
@@ -80,4 +75,7 @@ SET(CTEST_CUSTOM_WARNING_EXCEPTION
   
   # Visual studio spurious warnings...
   "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
 SET(KIT_include_directories
   )
-  
+
 # Source files
 SET(KIT_SRCS
   ctkAddRemoveComboBox.cpp
@@ -20,6 +20,8 @@ SET(KIT_SRCS
   ctkCheckableHeaderView.h
   ctkCheckBoxPixmaps.cpp
   ctkCheckBoxPixmaps.h
+  ctkComboBox.cpp
+  ctkComboBox.h
   ctkCollapsibleButton.cpp
   ctkCollapsibleButton.h
   ctkCollapsibleGroupBox.cpp
@@ -54,8 +56,6 @@ SET(KIT_SRCS
   ctkSliderSpinBoxWidget.h
   ctkTestApplication.cpp
   ctkTestApplication.h
-  ctkTitleComboBox.cpp
-  ctkTitleComboBox.h
   ctkTransferFunctionControlPointsItem.cpp
   ctkTransferFunctionControlPointsItem.h
   ctkTransferFunctionGradientItem.cpp
@@ -78,6 +78,7 @@ SET(KIT_MOC_SRCS
   ctkButtonGroup.h
   ctkCheckableHeaderView.h
   ctkCheckBoxPixmaps.h
+  ctkComboBox.h
   ctkCollapsibleButton.h
   ctkCollapsibleGroupBox.h
   ctkColorPickerButton.h
@@ -95,7 +96,6 @@ SET(KIT_MOC_SRCS
   ctkSettings.h
   ctkSliderSpinBoxWidget.h
   ctkTestApplication.h
-  ctkTitleComboBox.h
   ctkTransferFunctionControlPointsItem.h
   ctkTransferFunctionGradientItem.h
   ctkTransferFunctionBarsItem.h

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

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

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

@@ -1,7 +1,7 @@
 /*=========================================================================
 
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
 
   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.
   See the License for the specific language governing permissions and
   limitations under the License.
- 
+
 =========================================================================*/
 
 // CTK includes
-#include "ctkTitleComboBoxPlugin.h"
-#include "ctkTitleComboBox.h"
+#include "ctkComboBoxPlugin.h"
+#include "ctkComboBox.h"
 
 //-----------------------------------------------------------------------------
-ctkTitleComboBoxPlugin::ctkTitleComboBoxPlugin(QObject *_parent)
+ctkComboBoxPlugin::ctkComboBoxPlugin(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;
 }
 
 //-----------------------------------------------------------------------------
-QString ctkTitleComboBoxPlugin::domXml() const
+QString ctkComboBoxPlugin::domXml() const
 {
-  return "<widget class=\"ctkTitleComboBox\" \
+  return "<widget class=\"ctkComboBox\" \
           name=\"CTKTitleComboBox\">\n"
           "</widget>\n";
 }
 
 // --------------------------------------------------------------------------
-QIcon ctkTitleComboBoxPlugin::icon() const
+QIcon ctkComboBoxPlugin::icon() const
 {
   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;
 }
 
 //-----------------------------------------------------------------------------
-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
- 
+
   Copyright (c) 2010  Kitware Inc.
 
   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.
   See the License for the specific language governing permissions and
   limitations under the License.
- 
+
 =========================================================================*/
 
-#ifndef __ctkTitleComboBoxPlugin_h
-#define __ctkTitleComboBoxPlugin_h
+#ifndef __ctkComboBoxPlugin_h
+#define __ctkComboBoxPlugin_h
 
 // CTK includes
 #include "ctkWidgetsAbstractPlugin.h"
 
-class CTK_WIDGETS_PLUGINS_EXPORT ctkTitleComboBoxPlugin :
+class CTK_WIDGETS_PLUGINS_EXPORT ctkComboBoxPlugin :
   public QObject,
   public ctkWidgetsAbstractPlugin
 {
   Q_OBJECT
 
 public:
-  ctkTitleComboBoxPlugin(QObject *_parent = 0);
-  
+  ctkComboBoxPlugin(QObject *_parent = 0);
+
   QWidget *createWidget(QWidget *_parent);
   QString  domXml() const;
   QIcon    icon() const;

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

@@ -1,7 +1,7 @@
 /*=========================================================================
 
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
 
   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.
   See the License for the specific language governing permissions and
   limitations under the License.
- 
+
 =========================================================================*/
 
 #ifndef __ctkWidgetsPlugins_h
@@ -26,6 +26,7 @@
 
 // CTK includes
 #include "CTKWidgetsPluginsExport.h"
+#include "ctkComboBoxPlugin.h"
 #include "ctkCollapsibleButtonPlugin.h"
 #include "ctkCollapsibleGroupBoxPlugin.h"
 #include "ctkColorPickerButtonPlugin.h"
@@ -39,7 +40,6 @@
 #include "ctkMenuButtonPlugin.h"
 #include "ctkRangeSliderPlugin.h"
 #include "ctkRangeWidgetPlugin.h"
-#include "ctkTitleComboBoxPlugin.h"
 #include "ctkTransferFunctionWidgetPlugin.h"
 #include "ctkTreeComboBoxPlugin.h"
 #include "ctkSliderSpinBoxWidgetPlugin.h"
@@ -55,7 +55,8 @@ public:
   QList<QDesignerCustomWidgetInterface*> customWidgets() const
     {
     QList<QDesignerCustomWidgetInterface *> plugins;
-    plugins << new ctkCollapsibleButtonPlugin
+    plugins << new ctkComboBoxPlugin
+            << new ctkCollapsibleButtonPlugin
             << new ctkCollapsibleGroupBoxPlugin
             << new ctkColorPickerButtonPlugin
             << new ctkCoordinatesWidgetPlugin
@@ -68,7 +69,6 @@ public:
             << new ctkMenuButtonPlugin
             << new ctkRangeSliderPlugin
             << new ctkRangeWidgetPlugin
-            << new ctkTitleComboBoxPlugin
             << new ctkTransferFunctionWidgetPlugin
             << new ctkTreeComboBoxPlugin
             << new ctkSliderSpinBoxWidgetPlugin;

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

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

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

@@ -1,7 +1,7 @@
 /*=========================================================================
 
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
 
   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.
   See the License for the specific language governing permissions and
   limitations under the License.
- 
+
 =========================================================================*/
 
 // Qt includes
 #include <QApplication>
 
 // CTK includes
-#include "ctkTitleComboBox.h"
+#include "ctkComboBox.h"
 
 // STD includes
 #include <stdlib.h>
 #include <iostream>
 
 //-----------------------------------------------------------------------------
-int ctkTitleComboBoxTest1(int argc, char * argv [] )
+int ctkComboBoxTest1(int argc, char * argv [] )
 {
   QApplication app(argc, argv);
 
-  ctkTitleComboBox ctkObject;
-
+  ctkComboBox ctkObject;
 
   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
- 
+
   Copyright (c) 2010  Kitware Inc.
 
   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.
   See the License for the specific language governing permissions and
   limitations under the License.
- 
+
 =========================================================================*/
 
-#ifndef __ctkTitleComboBox_h
-#define __ctkTitleComboBox_h
+#ifndef __ctkComboBox_h
+#define __ctkComboBox_h
 
 // Qt includes
 #include <QComboBox>
 
 // CTK includes
+#include "ctkPimpl.h"
 #include "CTKWidgetsExport.h"
+class ctkComboBoxPrivate;
 
-class CTK_WIDGETS_EXPORT ctkTitleComboBox : public QComboBox
+class CTK_WIDGETS_EXPORT ctkComboBox : public QComboBox
 {
   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:
-  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 sizeHint()const;
 
 protected:
   virtual void paintEvent(QPaintEvent*);
-  virtual QSize recomputeSizeHint(QSize &sh)const;
 
-  QString Title;
-  QIcon   Icon;
-  
 private:
-  mutable QSize MinimumSizeHint;
-  mutable QSize SizeHint;
+  CTK_DECLARE_PRIVATE(ctkComboBox);
 };
 
 #endif

+ 15 - 4
Libs/Widgets/ctkDirectoryButton.cpp

@@ -102,12 +102,23 @@ void ctkDirectoryButton::setDirectory(const QString& dir)
 {
   CTK_D(ctkDirectoryButton);
   QDir newDirectory(dir);
+
   if (d->Directory == newDirectory)
     {
+    emit directorySelected(d->DisplayAbsolutePath ?
+                           newDirectory.absolutePath() :
+                           newDirectory.path());
     return;
     }
+
   d->Directory = newDirectory;
+
   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());
 }
 
@@ -150,11 +161,11 @@ const ctkDirectoryButton::Options& ctkDirectoryButton::options()const
 void ctkDirectoryButton::browse()
 {
   CTK_D(ctkDirectoryButton);
-  QString dir = 
+  QString dir =
     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)));
   // An empty directory means that the user cancelled the dialog.
   if (dir.isEmpty())

+ 7 - 7
Libs/Widgets/ctkDirectoryButton.h

@@ -1,7 +1,7 @@
 /*=========================================================================
 
   Library:   CTK
- 
+
   Copyright (c) 2010  Kitware Inc.
 
   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.
   See the License for the specific language governing permissions and
   limitations under the License.
- 
+
 =========================================================================*/
 
 #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.
   Q_FLAGS(Option Options);
 
-public: 
+public:
   // QFileDialog::Options is not a meta-type, we need to create our own.
   enum Option
     {
@@ -52,20 +52,20 @@ public:
       HideNameFilterDetails = 0x00000040
     };
   Q_DECLARE_FLAGS(Options, Option)
-    
+
   ctkDirectoryButton(QWidget * parent = 0);
   ctkDirectoryButton(const QString& directory, QWidget * parent = 0);
   ctkDirectoryButton(const QIcon& icon, const QString& directory, QWidget * parent = 0);
 
   void setDirectory(const QString& directory);
   QString directory()const;
-  
+
   ///
   /// The title of the file dialog used to select a new directory
   /// If caption is not set, internally use QWidget::tooltip()
   void setCaption(const QString& caption);
   const QString& caption()const;
-  
+
   void setOptions(const Options& options);
   const Options& options()const;
 
@@ -77,7 +77,7 @@ signals:
   /// directoryChanged is emitted when the current directory changes
   ///if you want a directoryChanged signal as a utility. Feel free to add it
   void directoryChanged(const QString&);
-
+  void directorySelected(const QString&);
 private:
   CTK_DECLARE_PRIVATE(ctkDirectoryButton);
 };

+ 36 - 29
Libs/Widgets/ctkRangeWidget.h

@@ -31,6 +31,10 @@
 
 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
 {
   Q_OBJECT
@@ -52,23 +56,25 @@ public:
   /// Superclass typedef
   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);
 
-  /// 
+  ///
   /// This property holds the sliders and spinbox minimum value.
   /// 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.
   double minimum()const;
   void setMinimum(double minimum);
-  
-  /// 
+
+  ///
   /// This property holds the sliders and spinbox minimum value.
   /// 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.
   double maximum()const;
   void setMaximum(double maximum);
@@ -76,78 +82,79 @@ public:
   /// Utility function that set the min/max in once
   void setRange(double min, double max);
 
-  /// 
+  ///
   /// This property holds the slider and spinbox minimum value.
   /// ctkRangeWidget forces the value to be within the
   /// legal range: minimum <= minimumValue <= maximumValue <= maximum.
   double minimumValue()const;
 
-  /// 
+  ///
   /// This property holds the slider and spinbox maximum value.
   /// ctkRangeWidget forces the value to be within the
   /// legal range: minimum <= minimumValue <= maximumValue <= maximum.
   double maximumValue()const;
 
-  /// 
+  ///
   /// 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.
   double singleStep()const;
   void setSingleStep(double step);
 
-  /// 
+  ///
   /// 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;
   void setDecimals(int decimals);
 
   ///
   /// 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
   QString prefix()const;
   void setPrefix(const QString& prefix);
 
   ///
   /// 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
   QString suffix()const;
   void setSuffix(const QString& suffix);
 
-  /// 
+  ///
   /// 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().
   /// The default value is 0.
   double tickInterval()const;
   void setTickInterval(double ti);
 
-  /// 
+  ///
   /// This property holds the alignment of the spin boxes.
   /// Possible Values are Qt::AlignTop, Qt::AlignBottom, and Qt::AlignVCenter.
   /// By default, the alignment is Qt::AlignVCenter
   void setSpinBoxAlignment(Qt::Alignment alignment);
   Qt::Alignment spinBoxAlignment()const;
-  
-  /// 
+
+  ///
   /// This property holds the alignment of the text inside the spin boxes.
   /// Possible Values are Qt::AlignLeft, Qt::AlignRight, and Qt::AlignHCenter.
   /// By default, the alignment is Qt::AlignLeft
   void setSpinBoxTextAlignment(Qt::Alignment alignment);
   Qt::Alignment spinBoxTextAlignment()const;
 
-  /// 
+  ///
   /// 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.
   void setTracking(bool enable);
   bool hasTracking()const;
 
-  /// 
+  ///
   /// Set/Get the auto spinbox width
   /// When the autoSpinBoxWidth property is on, the width of the SpinBox is
   /// set to the same width of the largest QSpinBox of its
@@ -156,7 +163,7 @@ public:
   void setAutoSpinBoxWidth(bool autoWidth);
 
 public slots:
-  /// 
+  ///
   /// Reset the slider and spinbox to zero (value and position)
   void reset();
   void setMinimumValue(double value);
@@ -182,7 +189,7 @@ protected slots:
   void changeMaximumValue(double value);
   void setMinimumToMaximumSpinBox(double minimum);
   void setMaximumToMinimumSpinBox(double maximum);
-  
+
 protected:
   virtual bool eventFilter(QObject *obj, QEvent *event);
 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)
 
 # On linux, also find libutil
-IF(NOT WIN32)
+IF(UNIX AND NOT APPLE)
   FIND_LIBRARY(PYTHONQT_LIBUTIL util)
   MARK_AS_ADVANCED(PYTHONQT_LIBUTIL)
 ENDIF()