kdgantt

KDGanttMinimizeSplitter.h

00001 /* -*- Mode: C++ -*-
00002    $Id$
00003 */
00004 
00005 /****************************************************************************
00006  ** Copyright (C)  2001-2004 Klarälvdalens Datakonsult AB.  All rights reserved.
00007  **
00008  ** This file is part of the KDGantt library.
00009  **
00010  ** This file may be distributed and/or modified under the terms of the
00011  ** GNU General Public License version 2 as published by the Free Software
00012  ** Foundation and appearing in the file LICENSE.GPL included in the
00013  ** packaging of this file.
00014  **
00015  ** Licensees holding valid commercial KDGantt licenses may use this file in
00016  ** accordance with the KDGantt Commercial License Agreement provided with
00017  ** the Software.
00018  **
00019  ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00020  ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021  **
00022  ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
00023  **   information about KDGantt Commercial License Agreements.
00024  **
00025  ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
00026  ** licensing are not clear to you.
00027  **
00028  ** As a special exception, permission is given to link this program
00029  ** with any edition of Qt, and distribute the resulting executable,
00030  ** without including the source code for Qt in the source distribution.
00031  **
00032  **********************************************************************/
00033 
00034 #ifndef KDGANTTMINIMIZESPLITTER_H
00035 #define KDGANTTMINIMIZESPLITTER_H
00036 
00037 #ifndef QT_H
00038 #include "qframe.h"
00039 #include "qvaluelist.h"
00040 #endif // QT_H
00041 
00042 #ifndef QT_NO_SPLITTER
00043 
00044 class QSplitterData;
00045 class QSplitterLayoutStruct;
00046 
00047 class KDGanttMinimizeSplitter : public QFrame
00048 {
00049     Q_OBJECT
00050     Q_ENUMS( Direction )
00051     Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
00052     Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
00053 
00054 public:
00055     enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
00056     enum Direction { Left, Right, Up, Down };
00057 
00058     KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 );
00059     KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 );
00060     ~KDGanttMinimizeSplitter();
00061 
00062     virtual void setOrientation( Orientation );
00063     Orientation orientation() const { return orient; }
00064 
00065     void setMinimizeDirection( Direction );
00066     Direction minimizeDirection() const;
00067 
00068 #if QT_VERSION >= 300
00069     virtual void setResizeMode( QWidget *w, ResizeMode );
00070     virtual void setOpaqueResize( bool = TRUE );
00071     bool opaqueResize() const;
00072 
00073     void moveToFirst( QWidget * );
00074     void moveToLast( QWidget * );
00075 
00076     void refresh() { recalc( TRUE ); }
00077     virtual QSize sizeHint() const;
00078     virtual QSize minimumSizeHint() const;
00079 
00080     QValueList<int> sizes() const;
00081     void setSizes( QValueList<int> );
00082 
00083     void expandPos( int id, int* min, int* max );
00084 protected:
00085     void childEvent( QChildEvent * );
00086 
00087     bool event( QEvent * );
00088     void resizeEvent( QResizeEvent * );
00089 
00090     int idAfter( QWidget* ) const;
00091 
00092     void moveSplitter( QCOORD pos, int id );
00093     virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
00094                    QCOORD w, QCOORD h );
00095     void styleChange( QStyle& );
00096     int adjustPos( int , int );
00097     virtual void setRubberband( int );
00098     void getRange( int id, int*, int* );
00099 
00100 private:
00101     void init();
00102     void recalc( bool update = FALSE );
00103     void doResize();
00104     void storeSizes();
00105     void processChildEvents();
00106     QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE );
00107     void recalcId();
00108     void moveBefore( int pos, int id, bool upLeft );
00109     void moveAfter( int pos, int id, bool upLeft );
00110     void setG( QWidget *w, int p, int s, bool isSplitter = FALSE );
00111 
00112     QCOORD pick( const QPoint &p ) const
00113     { return orient == Horizontal ? p.x() : p.y(); }
00114     QCOORD pick( const QSize &s ) const
00115     { return orient == Horizontal ? s.width() : s.height(); }
00116 
00117     QCOORD trans( const QPoint &p ) const
00118     { return orient == Vertical ? p.x() : p.y(); }
00119     QCOORD trans( const QSize &s ) const
00120     { return orient == Vertical ? s.width() : s.height(); }
00121 
00122     QSplitterData *data;
00123 #endif
00124 
00125 private:
00126     Orientation orient;
00127     Direction _direction;
00128 #ifndef DOXYGEN_SKIP_INTERNAL
00129     friend class KDGanttSplitterHandle;
00130 #endif
00131 private:    // Disabled copy constructor and operator=
00132 #if defined(Q_DISABLE_COPY)
00133     KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
00134     KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
00135 #endif
00136 };
00137 
00138 #ifndef DOXYGEN_SKIP_INTERNAL
00139 // This class was continued from a verbatim copy of the
00140 // QSplitterHandle pertaining to the Qt Enterprise License and the
00141 // GPL. It has only been renamed to KDGanttSplitterHandler in order to
00142 // avoid a symbol clash on some platforms.
00143 class KDGanttSplitterHandle : public QWidget
00144 {
00145     Q_OBJECT
00146 #if QT_VERSION >= 300
00147 public:
00148     KDGanttSplitterHandle( Qt::Orientation o,
00149                KDGanttMinimizeSplitter *parent, const char* name=0 );
00150     void setOrientation( Qt::Orientation o );
00151     Qt::Orientation orientation() const { return orient; }
00152 
00153     bool opaque() const { return s->opaqueResize(); }
00154 
00155     QSize sizeHint() const;
00156 
00157     int id() const { return myId; } // data->list.at(id())->wid == this
00158     void setId( int i ) { myId = i; }
00159 
00160 protected:
00161     QValueList<QPointArray> buttonRegions();
00162     void paintEvent( QPaintEvent * );
00163     void mouseMoveEvent( QMouseEvent * );
00164     void mousePressEvent( QMouseEvent * );
00165     void mouseReleaseEvent( QMouseEvent * );
00166     int onButton( const QPoint& p );
00167     void updateCursor( const QPoint& p );
00168 
00169 private:
00170     Qt::Orientation orient;
00171     bool opaq;
00172     int myId;
00173 
00174     KDGanttMinimizeSplitter *s;
00175     int _activeButton;
00176     bool _collapsed;
00177     int _origPos;
00178 #endif
00179 };
00180 #endif
00181 
00182 #endif // QT_NO_SPLITTER
00183 
00184 #endif // KDGANTTMINIMIZESPLITTER_H
KDE Home | KDE Accessibility Home | Description of Access Keys