ctkCollapsibleButton.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Library:   CTK
00004  
00005   Copyright (c) 2010  Kitware Inc.
00006 
00007   Licensed under the Apache License, Version 2.0 (the "License");
00008   you may not use this file except in compliance with the License.
00009   You may obtain a copy of the License at
00010 
00011       http://www.commontk.org/LICENSE
00012 
00013   Unless required by applicable law or agreed to in writing, software
00014   distributed under the License is distributed on an "AS IS" BASIS,
00015   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016   See the License for the specific language governing permissions and
00017   limitations under the License.
00018  
00019 =========================================================================*/
00020 
00021 #ifndef __ctkCollapsibleButton_h
00022 #define __ctkCollapsibleButton_h
00023 
00024 // Qt includes
00025 #include <QAbstractButton>
00026 #include <QFrame>
00027 
00028 // CTK includes
00029 #include <ctkPimpl.h>
00030 #include "CTKWidgetsExport.h"
00031 
00032 class ctkCollapsibleButtonPrivate;
00033 class QStyleOptionButton;
00034 
00037 class CTK_WIDGETS_EXPORT ctkCollapsibleButton : public QAbstractButton
00038 {
00039   Q_OBJECT
00040   Q_PROPERTY(bool collapsed READ collapsed WRITE setCollapsed DESIGNABLE isCheckable NOTIFY contentsCollapsed)
00041   Q_PROPERTY(int collapsedHeight READ collapsedHeight WRITE setCollapsedHeight)
00042 
00043   Q_PROPERTY(QFrame::Shape contentsFrameShape READ contentsFrameShape WRITE setContentsFrameShape)
00044   Q_PROPERTY(QFrame::Shadow contentsFrameShadow READ contentsFrameShadow WRITE setContentsFrameShadow)
00045   Q_PROPERTY(int contentsLineWidth READ contentsLineWidth WRITE setContentsLineWidth)
00046   Q_PROPERTY(int contentsMidLineWidth READ contentsMidLineWidth WRITE setContentsMidLineWidth)
00047 
00048 public:
00049   ctkCollapsibleButton(QWidget *parent = 0);
00050   ctkCollapsibleButton(const QString& text, QWidget *parent = 0);
00051   virtual ~ctkCollapsibleButton();
00052 
00057   void setCollapsed(bool);
00058   bool collapsed()const;
00059 
00062   void setCollapsedHeight(int);
00063   int collapsedHeight()const;
00064 
00068   QFrame::Shape contentsFrameShape() const;
00069   void setContentsFrameShape(QFrame::Shape);
00070 
00074   QFrame::Shadow contentsFrameShadow() const;
00075   void setContentsFrameShadow(QFrame::Shadow);
00076 
00079   int contentsLineWidth() const;
00080   void setContentsLineWidth(int);
00081 
00084   int contentsMidLineWidth() const;
00085   void setContentsMidLineWidth(int);
00086 
00089   virtual QSize minimumSizeHint()const;
00090 
00093   virtual QSize sizeHint()const;
00094 
00095 signals:
00099   void contentsCollapsed(bool);
00100 
00101 protected slots:
00104   virtual void collapse(bool c);
00105   virtual void onToggled(bool clicked = false);
00106 
00107 protected:
00108   virtual void paintEvent(QPaintEvent*);
00109   //virtual void mousePressEvent(QMouseEvent* event);
00110   //virtual void mouseReleaseEvent(QMouseEvent* event);
00111   virtual void childEvent(QChildEvent* c);
00112 
00113   virtual bool hitButton(const QPoint & pos) const;
00115   virtual QSize buttonSizeHint() const;
00116 
00120   virtual void initStyleOption(QStyleOptionButton* option)const;
00121 
00122 private:
00123   CTK_DECLARE_PRIVATE(ctkCollapsibleButton);
00124 };
00125 
00126 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines