00001 /**************************************************************************** 00002 ** 00003 ** Copyright (C) Qxt Foundation. Some rights reserved. 00004 ** 00005 ** This file is part of the QxtGui module of the Qxt library. 00006 ** 00007 ** This library is free software; you can redistribute it and/or modify it 00008 ** under the terms of the Common Public License, version 1.0, as published 00009 ** by IBM, and/or under the terms of the GNU Lesser General Public License, 00010 ** version 2.1, as published by the Free Software Foundation. 00011 ** 00012 ** This file is provided "AS IS", without WARRANTIES OR CONDITIONS OF ANY 00013 ** KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY 00014 ** WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR 00015 ** FITNESS FOR A PARTICULAR PURPOSE. 00016 ** 00017 ** You should have received a copy of the CPL and the LGPL along with this 00018 ** file. See the LICENSE file and the cpl1.0.txt/lgpl-2.1.txt files 00019 ** included with the source distribution for more information. 00020 ** If you did not receive a copy of the licenses, contact the Qxt Foundation. 00021 ** 00022 ** <http://libqxt.org> <foundation@libqxt.org> 00023 ** 00024 ****************************************************************************/ 00025 #include "qxtdockwidget.h" 00026 #include <QStyle> 00027 00028 class QxtDockWidgetPrivate : public QxtPrivate<QxtDockWidget> 00029 { 00030 public: 00031 QXT_DECLARE_PUBLIC(QxtDockWidget); 00032 00033 QSize contentsSize() const; 00034 QSize prev; 00035 }; 00036 00037 QSize QxtDockWidgetPrivate::contentsSize() const 00038 { 00039 QSize contents = qxt_p().size(); 00040 int fw = qxt_p().style()->pixelMetric(QStyle::PM_DockWidgetFrameWidth); 00041 QSize frame(2 * fw, fw); 00042 #ifdef Q_WS_WIN 00043 frame -= QSize(0, 3); 00044 #endif 00045 contents -= frame; 00046 return contents; 00047 } 00048 00064 QxtDockWidget::QxtDockWidget(const QString& title, QWidget* parent, Qt::WindowFlags flags) 00065 : QDockWidget(title, parent, flags) 00066 { 00067 QXT_INIT_PRIVATE(QxtDockWidget); 00068 } 00069 00073 QxtDockWidget::QxtDockWidget(QWidget* parent, Qt::WindowFlags flags) 00074 : QDockWidget(parent, flags) 00075 { 00076 QXT_INIT_PRIVATE(QxtDockWidget); 00077 } 00078 00082 QxtDockWidget::~QxtDockWidget() 00083 {} 00084 00088 QSize QxtDockWidget::sizeHint() const 00089 { 00090 QSize size; 00091 if (qxt_d().prev.isValid() && !isFloating()) 00092 size = qxt_d().prev; 00093 else 00094 size = QDockWidget::sizeHint(); 00095 return size; 00096 } 00097 00101 void QxtDockWidget::setVisible(bool visible) 00102 { 00103 if (!visible && !isFloating()) 00104 qxt_d().prev = qxt_d().contentsSize(); 00105 QDockWidget::setVisible(visible); 00106 }