kdgantt
KDGanttMinimizeSplitter.h00001
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
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:
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
00140
00141
00142
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; }
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
|