QGpGuiTools/ExpandTabTitle.h
Go to the documentation of this file.
00001 /***************************************************************************
00002 **
00003 **  This file is part of QGpGuiTools.
00004 **
00005 **  This library is free software; you can redistribute it and/or
00006 **  modify it under the terms of the GNU Lesser General Public
00007 **  License as published by the Free Software Foundation; either
00008 **  version 2.1 of the License, or (at your option) any later version.
00009 **
00010 **  This file is distributed in the hope that it will be useful, but WITHOUT
00011 **  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 **  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
00013 **  License for more details.
00014 **
00015 **  You should have received a copy of the GNU Lesser General Public
00016 **  License along with this library; if not, write to the Free Software
00017 **  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 **
00019 **  See http://www.geopsy.org for more information.
00020 **
00021 **  Created : 2008-03-30
00022 **  Authors :
00023 **    Marc Wathelet
00024 **    Marc Wathelet (LGIT, Grenoble, France)
00025 **
00026 ***************************************************************************/
00027 
00028 #ifndef EXPANDTABTITLE_H
00029 #define EXPANDTABTITLE_H
00030 
00031 #include <QtGui>
00032 #include <QGpCoreTools.h>
00033 
00034 #include "QGpGuiToolsDLLExport.h"
00035 
00036 namespace QGpGuiTools {
00037 
00038 class QGPGUITOOLS_EXPORT ExpandTabTitle : public QWidget
00039 {
00040   Q_OBJECT
00041   Q_PROPERTY(QString title READ title WRITE setTitle)
00042   Q_PROPERTY(bool expanded READ expanded WRITE setExpanded)
00043 public:
00044   ExpandTabTitle(QWidget * parent=0);
00045   ~ExpandTabTitle();
00046 
00047   void setTitle(QString t) {_title=t;}
00048   QString title() const {return _title;}
00049 
00050   void setContent(QWidget * w) {_content=w;}
00051   QWidget * content() const {return _content;}
00052 
00053   bool expanded() const {return _expanded;}
00054   void setExpanded(bool e);
00055 
00056   bool docked() const {return _docked;}
00057   void setDocked(bool d) {_docked=d;}
00058 signals:
00059   void moveUp();
00060   void moveDown();
00061   void dock();
00062   void addActions(QMenu * );
00063   void resize(int dy);
00064 protected:
00065   virtual void contextMenuEvent(QContextMenuEvent * e);
00066   virtual void paintEvent(QPaintEvent * e);
00067   virtual void mousePressEvent(QMouseEvent * e);
00068   virtual void mouseReleaseEvent(QMouseEvent * e);
00069   virtual void mouseMoveEvent(QMouseEvent * e);
00070   virtual QSize minimumSizeHint() const;
00071 private:
00072   QString _title;
00073   QWidget * _content;
00074   int _resizeStart;
00075   uint _expanded:1;
00076   uint _docked:1;
00077   uint _expandPress:1;
00078   uint _moveUpPress:1;
00079   uint _moveDownPress:1;
00080   uint _dockPress:1;
00081   uint _expandHover:1;
00082   uint _moveUpHover:1;
00083   uint _moveDownHover:1;
00084   uint _dockHover:1;
00085 
00086   inline QRect expandRect() const;
00087   inline QRect moveUpRect() const;
00088   inline QRect moveDownRect() const;
00089   inline QRect dockRect() const;
00090   static const int _spacing;
00091   static const int _expandSize;
00092   static const int _upDownSize;
00093 };
00094 
00095 } // namespace QGpGuiTools
00096 
00097 #endif // EXPANDTABTITLE_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines