Sophie

Sophie

distrib > CentOS > 5 > i386 > by-pkgid > d5f6a048a2b223e97fccd86095a60071 > files > 1986

qt4-doc-4.2.1-1.el5_7.1.i386.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Qt 4.2: colorswatch.cpp Example File (demos/mainwindow/colorswatch.cpp)</title>
  <link href="classic.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td>
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="modules.html"><font color="#004faf">Modules</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
<td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">colorswatch.cpp Example File<br /><sup><sup>demos/mainwindow/colorswatch.cpp</sup></sup></h1>
<pre> /****************************************************************************
 **
 ** Copyright (C) 2004-2006 Trolltech ASA. All rights reserved.
 **
 ** This file is part of the demonstration applications of the Qt Toolkit.
 **
 ** This file may be used under the terms of the GNU General Public
 ** License version 2.0 as published by the Free Software Foundation
 ** and appearing in the file LICENSE.GPL included in the packaging of
 ** this file.  Please review the following information to ensure GNU
 ** General Public Licensing requirements will be met:
 ** http:<span class="comment">//www.trolltech.com/products/qt/opensource.html</span>
 **
 ** If you are unsure which license is appropriate for your use, please
 ** review the following information:
 ** http:<span class="comment">//www.trolltech.com/products/qt/licensing.html or contact the</span>
 ** sales department at sales@trolltech.com.
 **
 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 **
 ****************************************************************************/

 #include &quot;colorswatch.h&quot;

 #include &lt;QAction&gt;
 #include &lt;QtEvents&gt;
 #include &lt;QFrame&gt;
 #include &lt;QMainWindow&gt;
 #include &lt;QMenu&gt;
 #include &lt;QPainter&gt;
 #include &lt;QImage&gt;
 #include &lt;QColor&gt;
 #include &lt;QDialog&gt;
 #include &lt;QGridLayout&gt;
 #include &lt;QSpinBox&gt;
 #include &lt;QLabel&gt;
 #include &lt;QPainterPath&gt;
 #include &lt;QPushButton&gt;
 #include &lt;QHBoxLayout&gt;
 #include &lt;QtDebug&gt;

 #undef DEBUG_SIZEHINTS

 QColor bgColorForName(const QString &amp;name)
 {
     if (name == &quot;Black&quot;)
         return QColor(&quot;#D8D8D8&quot;);
     else if (name == &quot;White&quot;)
         return QColor(&quot;#F1F1F1&quot;);
     else if (name == &quot;Red&quot;)
         return QColor(&quot;#F1D8D8&quot;);
     else if (name == &quot;Green&quot;)
         return QColor(&quot;#D8E4D8&quot;);
     else if (name == &quot;Blue&quot;)
         return QColor(&quot;#D8D8F1&quot;);
     else if (name == &quot;Yellow&quot;)
         return QColor(&quot;#F1F0D8&quot;);
     return QColor(name).light(110);
 }

 QColor fgColorForName(const QString &amp;name)
 {
     if (name == &quot;Black&quot;)
         return QColor(&quot;#6C6C6C&quot;);
     else if (name == &quot;White&quot;)
         return QColor(&quot;#F8F8F8&quot;);
     else if (name == &quot;Red&quot;)
         return QColor(&quot;#F86C6C&quot;);
     else if (name == &quot;Green&quot;)
         return QColor(&quot;#6CB26C&quot;);
     else if (name == &quot;Blue&quot;)
         return QColor(&quot;#6C6CF8&quot;);
     else if (name == &quot;Yellow&quot;)
         return QColor(&quot;#F8F76C&quot;);
     return QColor(name);
 }

 class ColorDock : public QFrame
 {
     Q_OBJECT
 public:
     ColorDock(const QString &amp;c, QWidget *parent);

     virtual QSize sizeHint() const;
     virtual QSize minimumSizeHint() const;

 public slots:
     void changeSizeHints();

 protected:
     void paintEvent(QPaintEvent *);
     QString color;
     QSize szHint, minSzHint;
 };

 ColorDock::ColorDock(const QString &amp;c, QWidget *parent)
     : QFrame(parent) , color(c)
 {
     QFont font = this-&gt;font();
     font.setPointSize(8);
     setFont(font);
     szHint = QSize(-1, -1);
     minSzHint = QSize(125, 75);
 }

 QSize ColorDock::sizeHint() const
 {
     return szHint;
 }

 QSize ColorDock::minimumSizeHint() const
 {
     return minSzHint;
 }

 void ColorDock::paintEvent(QPaintEvent *)
 {
     QPainter p(this);
     p.setRenderHint(QPainter::Antialiasing);
     p.fillRect(rect(), bgColorForName(color));

     p.save();

     extern void render_qt_text(QPainter *, int, int, const QColor &amp;);
     render_qt_text(&amp;p, width(), height(), fgColorForName(color));

     p.restore();

 #ifdef DEBUG_SIZEHINTS
     p.setRenderHint(QPainter::Antialiasing, false);

     QSize sz = size();
     QSize szHint = sizeHint();
     QSize minSzHint = minimumSizeHint();
     QSize maxSz = maximumSize();
     QString text = QString::fromLatin1(&quot;sz: %1x%2\nszHint: %3x%4\nminSzHint: %5x%6\n&quot;
                                         &quot;maxSz: %8x%9&quot;)
                     .arg(sz.width()).arg(sz.height())
                     .arg(szHint.width()).arg(szHint.height())
                     .arg(minSzHint.width()).arg(minSzHint.height())
                     .arg(maxSz.width()).arg(maxSz.height());

     QRect r = fontMetrics().boundingRect(rect(), Qt::AlignLeft|Qt::AlignTop, text);
     r.adjust(-2, -2, 1, 1);
     p.translate(4, 4);
     QColor bg = Qt::yellow;
     bg.setAlpha(120);
     p.setBrush(bg);
     p.setPen(Qt::black);
     p.drawRect(r);
     p.drawText(rect(), Qt::AlignLeft|Qt::AlignTop, text);
 #endif <span class="comment">// DEBUG_SIZEHINTS</span>
 }

 static QSpinBox *createSpinBox(int value, QWidget *parent, int max = 1000)
 {
     QSpinBox *result = new QSpinBox(parent);
     result-&gt;setMinimum(-1);
     result-&gt;setMaximum(max);
     result-&gt;setValue(value);
     return result;
 }

 void ColorDock::changeSizeHints()
 {
     QDialog dialog(this);
     dialog.setWindowTitle(color);

     QVBoxLayout *topLayout = new QVBoxLayout(&amp;dialog);

     QGridLayout *inputLayout = new QGridLayout();
     topLayout-&gt;addLayout(inputLayout);

     inputLayout-&gt;addWidget(new QLabel(tr(&quot;Size Hint:&quot;), &amp;dialog), 0, 0);
     inputLayout-&gt;addWidget(new QLabel(tr(&quot;Min Size Hint:&quot;), &amp;dialog), 1, 0);
     inputLayout-&gt;addWidget(new QLabel(tr(&quot;Max Size:&quot;), &amp;dialog), 2, 0);
     inputLayout-&gt;addWidget(new QLabel(tr(&quot;Dockwgt Max Size:&quot;), &amp;dialog), 3, 0);

     QSpinBox *szHintW = createSpinBox(szHint.width(), &amp;dialog);
     inputLayout-&gt;addWidget(szHintW, 0, 1);
     QSpinBox *szHintH = createSpinBox(szHint.height(), &amp;dialog);
     inputLayout-&gt;addWidget(szHintH, 0, 2);

     QSpinBox *minSzHintW = createSpinBox(minSzHint.width(), &amp;dialog);
     inputLayout-&gt;addWidget(minSzHintW, 1, 1);
     QSpinBox *minSzHintH = createSpinBox(minSzHint.height(), &amp;dialog);
     inputLayout-&gt;addWidget(minSzHintH, 1, 2);

     QSize maxSz = maximumSize();
     QSpinBox *maxSzW = createSpinBox(maxSz.width(), &amp;dialog, QWIDGETSIZE_MAX);
     inputLayout-&gt;addWidget(maxSzW, 2, 1);
     QSpinBox *maxSzH = createSpinBox(maxSz.height(), &amp;dialog, QWIDGETSIZE_MAX);
     inputLayout-&gt;addWidget(maxSzH, 2, 2);

     QSize dwMaxSz = parentWidget()-&gt;maximumSize();
     QSpinBox *dwMaxSzW = createSpinBox(dwMaxSz.width(), &amp;dialog, QWIDGETSIZE_MAX);
     inputLayout-&gt;addWidget(dwMaxSzW, 3, 1);
     QSpinBox *dwMaxSzH = createSpinBox(dwMaxSz.height(), &amp;dialog, QWIDGETSIZE_MAX);
     inputLayout-&gt;addWidget(dwMaxSzH, 3, 2);

     inputLayout-&gt;setColumnStretch(1, 1);
     inputLayout-&gt;setColumnStretch(2, 1);

     topLayout-&gt;addStretch();

     QHBoxLayout *buttonBox = new QHBoxLayout();
     topLayout-&gt;addLayout(buttonBox);

     QPushButton *okButton = new QPushButton(tr(&quot;Ok&quot;), &amp;dialog);
     QPushButton *cancelButton = new QPushButton(tr(&quot;Cancel&quot;), &amp;dialog);
     connect(okButton, SIGNAL(clicked()), &amp;dialog, SLOT(accept()));
     connect(cancelButton, SIGNAL(clicked()), &amp;dialog, SLOT(reject()));
     buttonBox-&gt;addStretch();
     buttonBox-&gt;addWidget(cancelButton);
     buttonBox-&gt;addWidget(okButton);

     if (!dialog.exec())
         return;

     szHint = QSize(szHintW-&gt;value(), szHintH-&gt;value());
     minSzHint = QSize(minSzHintW-&gt;value(), minSzHintH-&gt;value());
     maxSz = QSize(maxSzW-&gt;value(), maxSzH-&gt;value());
     setMaximumSize(maxSz);
     dwMaxSz = QSize(dwMaxSzW-&gt;value(), dwMaxSzH-&gt;value());
     parentWidget()-&gt;setMaximumSize(dwMaxSz);
     updateGeometry();
     update();
 }

 ColorSwatch::ColorSwatch(const QString &amp;colorName, QWidget *parent, Qt::WindowFlags flags)
     : QDockWidget(parent, flags)
 {
     setObjectName(colorName + QLatin1String(&quot; Dock Widget&quot;));
     setWindowTitle(objectName());

     QFrame *swatch = new ColorDock(colorName, this);
     swatch-&gt;setFrameStyle(QFrame::Box | QFrame::Sunken);

     setWidget(swatch);

     changeSizeHintsAction = new QAction(tr(&quot;Change Size Hints&quot;), this);
     connect(changeSizeHintsAction, SIGNAL(triggered()), swatch, SLOT(changeSizeHints()));

     closableAction = new QAction(tr(&quot;Closable&quot;), this);
     closableAction-&gt;setCheckable(true);
     connect(closableAction, SIGNAL(triggered(bool)), SLOT(changeClosable(bool)));

     movableAction = new QAction(tr(&quot;Movable&quot;), this);
     movableAction-&gt;setCheckable(true);
     connect(movableAction, SIGNAL(triggered(bool)), SLOT(changeMovable(bool)));

     floatableAction = new QAction(tr(&quot;Floatable&quot;), this);
     floatableAction-&gt;setCheckable(true);
     connect(floatableAction, SIGNAL(triggered(bool)), SLOT(changeFloatable(bool)));

     floatingAction = new QAction(tr(&quot;Floating&quot;), this);
     floatingAction-&gt;setCheckable(true);
     connect(floatingAction, SIGNAL(triggered(bool)), SLOT(changeFloating(bool)));

     allowedAreasActions = new QActionGroup(this);
     allowedAreasActions-&gt;setExclusive(false);

     allowLeftAction = new QAction(tr(&quot;Allow on Left&quot;), this);
     allowLeftAction-&gt;setCheckable(true);
     connect(allowLeftAction, SIGNAL(triggered(bool)), SLOT(allowLeft(bool)));

     allowRightAction = new QAction(tr(&quot;Allow on Right&quot;), this);
     allowRightAction-&gt;setCheckable(true);
     connect(allowRightAction, SIGNAL(triggered(bool)), SLOT(allowRight(bool)));

     allowTopAction = new QAction(tr(&quot;Allow on Top&quot;), this);
     allowTopAction-&gt;setCheckable(true);
     connect(allowTopAction, SIGNAL(triggered(bool)), SLOT(allowTop(bool)));

     allowBottomAction = new QAction(tr(&quot;Allow on Bottom&quot;), this);
     allowBottomAction-&gt;setCheckable(true);
     connect(allowBottomAction, SIGNAL(triggered(bool)), SLOT(allowBottom(bool)));

     allowedAreasActions-&gt;addAction(allowLeftAction);
     allowedAreasActions-&gt;addAction(allowRightAction);
     allowedAreasActions-&gt;addAction(allowTopAction);
     allowedAreasActions-&gt;addAction(allowBottomAction);

     areaActions = new QActionGroup(this);
     areaActions-&gt;setExclusive(true);

     leftAction = new QAction(tr(&quot;Place on Left&quot;) , this);
     leftAction-&gt;setCheckable(true);
     connect(leftAction, SIGNAL(triggered(bool)), SLOT(placeLeft(bool)));

     rightAction = new QAction(tr(&quot;Place on Right&quot;) , this);
     rightAction-&gt;setCheckable(true);
     connect(rightAction, SIGNAL(triggered(bool)), SLOT(placeRight(bool)));

     topAction = new QAction(tr(&quot;Place on Top&quot;) , this);
     topAction-&gt;setCheckable(true);
     connect(topAction, SIGNAL(triggered(bool)), SLOT(placeTop(bool)));

     bottomAction = new QAction(tr(&quot;Place on Bottom&quot;) , this);
     bottomAction-&gt;setCheckable(true);
     connect(bottomAction, SIGNAL(triggered(bool)), SLOT(placeBottom(bool)));

     areaActions-&gt;addAction(leftAction);
     areaActions-&gt;addAction(rightAction);
     areaActions-&gt;addAction(topAction);
     areaActions-&gt;addAction(bottomAction);

     connect(movableAction, SIGNAL(triggered(bool)), areaActions, SLOT(setEnabled(bool)));

     connect(movableAction, SIGNAL(triggered(bool)), allowedAreasActions, SLOT(setEnabled(bool)));

     connect(floatableAction, SIGNAL(triggered(bool)), floatingAction, SLOT(setEnabled(bool)));

     connect(floatingAction, SIGNAL(triggered(bool)), floatableAction, SLOT(setDisabled(bool)));
     connect(movableAction, SIGNAL(triggered(bool)), floatableAction, SLOT(setEnabled(bool)));

     tabMenu = new QMenu(this);
     tabMenu-&gt;setTitle(tr(&quot;Tab into&quot;));
     connect(tabMenu, SIGNAL(triggered(QAction*)), this, SLOT(tabInto(QAction*)));

     splitHMenu = new QMenu(this);
     splitHMenu-&gt;setTitle(tr(&quot;Split horizontally into&quot;));
     connect(splitHMenu, SIGNAL(triggered(QAction*)), this, SLOT(splitInto(QAction*)));

     splitVMenu = new QMenu(this);
     splitVMenu-&gt;setTitle(tr(&quot;Split vertically into&quot;));
     connect(splitVMenu, SIGNAL(triggered(QAction*)), this, SLOT(splitInto(QAction*)));

     menu = new QMenu(colorName, this);
     menu-&gt;addAction(toggleViewAction());
     QAction *action = menu-&gt;addAction(tr(&quot;Raise&quot;));
     connect(action, SIGNAL(triggered()), this, SLOT(raise()));
     menu-&gt;addAction(changeSizeHintsAction);
     menu-&gt;addSeparator();
     menu-&gt;addAction(closableAction);
     menu-&gt;addAction(movableAction);
     menu-&gt;addAction(floatableAction);
     menu-&gt;addAction(floatingAction);
     menu-&gt;addSeparator();
     menu-&gt;addActions(allowedAreasActions-&gt;actions());
     menu-&gt;addSeparator();
     menu-&gt;addActions(areaActions-&gt;actions());
     menu-&gt;addSeparator();
     menu-&gt;addMenu(splitHMenu);
     menu-&gt;addMenu(splitVMenu);
     menu-&gt;addMenu(tabMenu);

     connect(menu, SIGNAL(aboutToShow()), this, SLOT(updateContextMenu()));

     if(colorName == &quot;Black&quot;) {
         leftAction-&gt;setShortcut(Qt::CTRL|Qt::Key_W);
         rightAction-&gt;setShortcut(Qt::CTRL|Qt::Key_E);
         toggleViewAction()-&gt;setShortcut(Qt::CTRL|Qt::Key_R);
     }
 }

 void ColorSwatch::updateContextMenu()
 {
     QMainWindow *mainWindow = qobject_cast&lt;QMainWindow *&gt;(parentWidget());
     const Qt::DockWidgetArea area = mainWindow-&gt;dockWidgetArea(this);
     const Qt::DockWidgetAreas areas = allowedAreas();

     closableAction-&gt;setChecked(features() &amp; QDockWidget::DockWidgetClosable);
     if (windowType() == Qt::Drawer) {
         floatableAction-&gt;setEnabled(false);
         floatingAction-&gt;setEnabled(false);
         movableAction-&gt;setEnabled(false);
     } else {
         floatableAction-&gt;setChecked(features() &amp; QDockWidget::DockWidgetFloatable);
         floatingAction-&gt;setChecked(isWindow());
         <span class="comment">// done after floating, to get 'floatable' correctly initialized</span>
         movableAction-&gt;setChecked(features() &amp; QDockWidget::DockWidgetMovable);
     }

     allowLeftAction-&gt;setChecked(isAreaAllowed(Qt::LeftDockWidgetArea));
     allowRightAction-&gt;setChecked(isAreaAllowed(Qt::RightDockWidgetArea));
     allowTopAction-&gt;setChecked(isAreaAllowed(Qt::TopDockWidgetArea));
     allowBottomAction-&gt;setChecked(isAreaAllowed(Qt::BottomDockWidgetArea));

     if (allowedAreasActions-&gt;isEnabled()) {
         allowLeftAction-&gt;setEnabled(area != Qt::LeftDockWidgetArea);
         allowRightAction-&gt;setEnabled(area != Qt::RightDockWidgetArea);
         allowTopAction-&gt;setEnabled(area != Qt::TopDockWidgetArea);
         allowBottomAction-&gt;setEnabled(area != Qt::BottomDockWidgetArea);
     }

     leftAction-&gt;blockSignals(true);
     rightAction-&gt;blockSignals(true);
     topAction-&gt;blockSignals(true);
     bottomAction-&gt;blockSignals(true);

     leftAction-&gt;setChecked(area == Qt::LeftDockWidgetArea);
     rightAction-&gt;setChecked(area == Qt::RightDockWidgetArea);
     topAction-&gt;setChecked(area == Qt::TopDockWidgetArea);
     bottomAction-&gt;setChecked(area == Qt::BottomDockWidgetArea);

     leftAction-&gt;blockSignals(false);
     rightAction-&gt;blockSignals(false);
     topAction-&gt;blockSignals(false);
     bottomAction-&gt;blockSignals(false);

     if (areaActions-&gt;isEnabled()) {
         leftAction-&gt;setEnabled(areas &amp; Qt::LeftDockWidgetArea);
         rightAction-&gt;setEnabled(areas &amp; Qt::RightDockWidgetArea);
         topAction-&gt;setEnabled(areas &amp; Qt::TopDockWidgetArea);
         bottomAction-&gt;setEnabled(areas &amp; Qt::BottomDockWidgetArea);
     }

     tabMenu-&gt;clear();
     splitHMenu-&gt;clear();
     splitVMenu-&gt;clear();
     QList&lt;ColorSwatch*&gt; dock_list = qFindChildren&lt;ColorSwatch*&gt;(mainWindow);
     foreach (ColorSwatch *dock, dock_list) {
<span class="comment"> //        if (!dock-&gt;isVisible() || dock-&gt;isFloating())</span>
<span class="comment"> //            continue;</span>
         tabMenu-&gt;addAction(dock-&gt;windowTitle());
         splitHMenu-&gt;addAction(dock-&gt;windowTitle());
         splitVMenu-&gt;addAction(dock-&gt;windowTitle());
     }
 }

 void ColorSwatch::splitInto(QAction *action)
 {
     QMainWindow *mainWindow = qobject_cast&lt;QMainWindow *&gt;(parentWidget());
     QList&lt;ColorSwatch*&gt; dock_list = qFindChildren&lt;ColorSwatch*&gt;(mainWindow);
     ColorSwatch *target = 0;
     foreach (ColorSwatch *dock, dock_list) {
         if (action-&gt;text() == dock-&gt;windowTitle()) {
             target = dock;
             break;
         }
     }
     if (target == 0)
         return;

     Qt::Orientation o = action-&gt;parent() == splitHMenu
                         ? Qt::Horizontal : Qt::Vertical;
     mainWindow-&gt;splitDockWidget(target, this, o);
 }

 void ColorSwatch::tabInto(QAction *action)
 {
     QMainWindow *mainWindow = qobject_cast&lt;QMainWindow *&gt;(parentWidget());
     QList&lt;ColorSwatch*&gt; dock_list = qFindChildren&lt;ColorSwatch*&gt;(mainWindow);
     ColorSwatch *target = 0;
     foreach (ColorSwatch *dock, dock_list) {
         if (action-&gt;text() == dock-&gt;windowTitle()) {
             target = dock;
             break;
         }
     }
     if (target == 0)
         return;

     mainWindow-&gt;tabifyDockWidget(target, this);
 }

 void ColorSwatch::contextMenuEvent(QContextMenuEvent *event)
 {
     event-&gt;accept();
     menu-&gt;exec(event-&gt;globalPos());
 }

 void ColorSwatch::allow(Qt::DockWidgetArea area, bool a)
 {
     Qt::DockWidgetAreas areas = allowedAreas();
     areas = a ? areas | area : areas &amp; ~area;
     setAllowedAreas(areas);

     if (areaActions-&gt;isEnabled()) {
         leftAction-&gt;setEnabled(areas &amp; Qt::LeftDockWidgetArea);
         rightAction-&gt;setEnabled(areas &amp; Qt::RightDockWidgetArea);
         topAction-&gt;setEnabled(areas &amp; Qt::TopDockWidgetArea);
         bottomAction-&gt;setEnabled(areas &amp; Qt::BottomDockWidgetArea);
     }
 }

 void ColorSwatch::place(Qt::DockWidgetArea area, bool p)
 {
     if (!p) return;

     QMainWindow *mainWindow = qobject_cast&lt;QMainWindow *&gt;(parentWidget());
     mainWindow-&gt;addDockWidget(area, this);

     if (allowedAreasActions-&gt;isEnabled()) {
         allowLeftAction-&gt;setEnabled(area != Qt::LeftDockWidgetArea);
         allowRightAction-&gt;setEnabled(area != Qt::RightDockWidgetArea);
         allowTopAction-&gt;setEnabled(area != Qt::TopDockWidgetArea);
         allowBottomAction-&gt;setEnabled(area != Qt::BottomDockWidgetArea);
     }
 }

 void ColorSwatch::changeClosable(bool on)
 { setFeatures(on ? features() | DockWidgetClosable : features() &amp; ~DockWidgetClosable); }

 void ColorSwatch::changeMovable(bool on)
 { setFeatures(on ? features() | DockWidgetMovable : features() &amp; ~DockWidgetMovable); }

 void ColorSwatch::changeFloatable(bool on)
 { setFeatures(on ? features() | DockWidgetFloatable : features() &amp; ~DockWidgetFloatable); }

 void ColorSwatch::changeFloating(bool floating)
 { setFloating(floating); }

 void ColorSwatch::allowLeft(bool a)
 { allow(Qt::LeftDockWidgetArea, a); }

 void ColorSwatch::allowRight(bool a)
 { allow(Qt::RightDockWidgetArea, a); }

 void ColorSwatch::allowTop(bool a)
 { allow(Qt::TopDockWidgetArea, a); }

 void ColorSwatch::allowBottom(bool a)
 { allow(Qt::BottomDockWidgetArea, a); }

 void ColorSwatch::placeLeft(bool p)
 { place(Qt::LeftDockWidgetArea, p); }

 void ColorSwatch::placeRight(bool p)
 { place(Qt::RightDockWidgetArea, p); }

 void ColorSwatch::placeTop(bool p)
 { place(Qt::TopDockWidgetArea, p); }

 void ColorSwatch::placeBottom(bool p)
 { place(Qt::BottomDockWidgetArea, p); }

 #include &quot;colorswatch.moc&quot;</pre>
<p /><address><hr /><div align="center">
<table width="100%" cellspacing="0" border="0"><tr class="address">
<td width="30%">Copyright &copy; 2006 <a href="trolltech.html">Trolltech</a></td>
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
<td width="30%" align="right"><div align="right">Qt 4.2.1</div></td>
</tr></table></div></address></body>
</html>