kdgantt1
KDGanttMinimizeSplitter.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef KDGANTTMINIMIZESPLITTER_H
00033 #define KDGANTTMINIMIZESPLITTER_H
00034
00035
00036 #ifndef QT_H
00037 #include "qframe.h"
00038 #endif // QT_H
00039
00040 #include "kdgantt_qt3_compat.h"
00041
00042 #ifndef QT_NO_SPLITTER
00043
00044 #if QT_VERSION < 0x040000
00045
00046 #include "qvaluelist.h"
00047
00048 class QSplitterData;
00049 class QSplitterLayoutStruct;
00050
00051 class KDGanttMinimizeSplitter : public QFrame
00052 {
00053 Q_OBJECT
00054 Q_ENUMS( Direction )
00055 Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
00056 Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
00057
00058 public:
00059 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
00060 enum Direction { Left, Right, Up, Down };
00061
00062 KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 );
00063 KDGanttMinimizeSplitter( Qt::Orientation, QWidget* parent=0, const char* name=0 );
00064 ~KDGanttMinimizeSplitter();
00065
00066 virtual void setOrientation( Orientation );
00067 Orientation orientation() const { return orient; }
00068
00069 void setMinimizeDirection( Direction );
00070 Direction minimizeDirection() const;
00071
00072 #if QT_VERSION >= 300
00073 virtual void setResizeMode( QWidget *w, ResizeMode );
00074 virtual void setOpaqueResize( bool = true );
00075 bool opaqueResize() const;
00076
00077 void moveToFirst( QWidget * );
00078 void moveToLast( QWidget * );
00079
00080 void refresh() { recalc( true ); }
00081 virtual QSize sizeHint() const;
00082 virtual QSize minimumSizeHint() const;
00083
00084 QValueList<int> sizes() const;
00085 void setSizes( QValueList<int> );
00086
00087 void expandPos( int id, int* min, int* max );
00088 protected:
00089 void childEvent( QChildEvent * );
00090
00091 bool event( QEvent * );
00092 void resizeEvent( QResizeEvent * );
00093
00094 int idAfter( QWidget* ) const;
00095
00096 void moveSplitter( QCOORD pos, int id );
00097 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
00098 QCOORD w, QCOORD h );
00099 void styleChange( QStyle& );
00100 int adjustPos( int , int );
00101 virtual void setRubberband( int );
00102 void getRange( int id, int*, int* );
00103
00104 private:
00105 void init();
00106 void recalc( bool update = false );
00107 void doResize();
00108 void storeSizes();
00109 void processChildEvents();
00110 QSplitterLayoutStruct *addWidget( QWidget*, bool first = false );
00111 void recalcId();
00112 void moveBefore( int pos, int id, bool upLeft );
00113 void moveAfter( int pos, int id, bool upLeft );
00114 void setG( QWidget *w, int p, int s, bool isSplitter = false );
00115
00116 QCOORD pick( const QPoint &p ) const
00117 { return orient == Qt::Horizontal ? p.x() : p.y(); }
00118 QCOORD pick( const QSize &s ) const
00119 { return orient == Qt::Horizontal ? s.width() : s.height(); }
00120
00121 QCOORD trans( const QPoint &p ) const
00122 { return orient == Qt::Vertical ? p.x() : p.y(); }
00123 QCOORD trans( const QSize &s ) const
00124 { return orient == Qt::Vertical ? s.width() : s.height(); }
00125
00126 QSplitterData *data;
00127 #endif
00128
00129 private:
00130 Qt::Orientation orient;
00131 Direction _direction;
00132 #ifndef DOXYGEN_SKIP_INTERNAL
00133 friend class KDGanttSplitterHandle;
00134 #endif
00135 private:
00136 #if defined(Q_DISABLE_COPY)
00137 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
00138 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
00139 #endif
00140 };
00141
00142 #ifndef DOXYGEN_SKIP_INTERNAL
00143
00144
00145
00146
00147 class KDGanttSplitterHandle : public QWidget
00148 {
00149 Q_OBJECT
00150 #if QT_VERSION >= 300
00151 public:
00152 KDGanttSplitterHandle( Qt::Orientation o,
00153 KDGanttMinimizeSplitter *parent, const char* name=0 );
00154 void setOrientation( Qt::Orientation o );
00155 Qt::Orientation orientation() const { return orient; }
00156
00157 bool opaque() const { return s->opaqueResize(); }
00158
00159 QSize sizeHint() const;
00160
00161 int id() const { return myId; }
00162 void setId( int i ) { myId = i; }
00163
00164 protected:
00165 QValueList<QPointArray> buttonRegions();
00166 void paintEvent( QPaintEvent * );
00167 void mouseMoveEvent( QMouseEvent * );
00168 void mousePressEvent( QMouseEvent * );
00169 void mouseReleaseEvent( QMouseEvent * );
00170 int onButton( const QPoint& p );
00171 void updateCursor( const QPoint& p );
00172
00173 private:
00174 Qt::Orientation orient;
00175 bool opaq;
00176 int myId;
00177
00178 KDGanttMinimizeSplitter *s;
00179 int _activeButton;
00180 bool _collapsed;
00181 int _origPos;
00182 #endif
00183 };
00184 #endif
00185
00186 #else //QT_VERSION < 0x040000
00187
00188 #include <QSplitter>
00189
00190 #define KDGanttMinimizeSplitter QSplitter
00191
00192
00193 #endif // QT_VERSION < 0x040000
00194
00195 #endif // QT_NO_SPLITTER
00196
00197 #endif // KDGANTTMINIMIZESPLITTER_H