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 TQt, and distribute the resulting executable, 00030 ** without including the source code for TQt in the source distribution. 00031 ** 00032 **********************************************************************/ 00033 00034 #ifndef KDGANTTMINIMIZESPLITTER_H 00035 #define KDGANTTMINIMIZESPLITTER_H 00036 00037 #include "tqframe.h" 00038 #include "tqvaluelist.h" 00039 00040 class TQSplitterData; 00041 class TQSplitterLayoutStruct; 00042 00043 class KDGanttMinimizeSplitter : public TQFrame 00044 { 00045 Q_OBJECT 00046 TQ_OBJECT 00047 Q_ENUMS( Direction ) 00048 TQ_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) 00049 TQ_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) 00050 00051 public: 00052 enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; 00053 enum Direction { Left, Right, Up, Down }; 00054 00055 KDGanttMinimizeSplitter( TQWidget* parent=0, const char* name=0 ); 00056 KDGanttMinimizeSplitter( Qt::Orientation, TQWidget* parent=0, const char* name=0 ); 00057 ~KDGanttMinimizeSplitter(); 00058 00059 virtual void setOrientation( Qt::Orientation ); 00060 Qt::Orientation orientation() const { return orient; } 00061 00062 void setMinimizeDirection( Direction ); 00063 Direction minimizeDirection() const; 00064 00065 virtual void setResizeMode( TQWidget *w, ResizeMode ); 00066 virtual void setOpaqueResize( bool = TRUE ); 00067 bool opaqueResize() const; 00068 00069 void moveToFirst( TQWidget * ); 00070 void moveToLast( TQWidget * ); 00071 00072 void refresh() { recalc( TRUE ); } 00073 virtual TQSize sizeHint() const; 00074 virtual TQSize minimumSizeHint() const; 00075 00076 TQValueList<int> sizes() const; 00077 void setSizes( TQValueList<int> ); 00078 00079 void expandPos( int id, int* min, int* max ); 00080 protected: 00081 void childEvent( TQChildEvent * ); 00082 00083 bool event( TQEvent * ); 00084 void resizeEvent( TQResizeEvent * ); 00085 00086 int idAfter( TQWidget* ) const; 00087 00088 void moveSplitter( TQCOORD pos, int id ); 00089 virtual void drawSplitter( TQPainter*, TQCOORD x, TQCOORD y, 00090 TQCOORD w, TQCOORD h ); 00091 void styleChange( TQStyle& ); 00092 int adjustPos( int , int ); 00093 virtual void setRubberband( int ); 00094 void getRange( int id, int*, int* ); 00095 00096 private: 00097 void init(); 00098 void recalc( bool update = FALSE ); 00099 void doResize(); 00100 void storeSizes(); 00101 void processChildEvents(); 00102 TQSplitterLayoutStruct *addWidget( TQWidget*, bool first = FALSE ); 00103 void recalcId(); 00104 void moveBefore( int pos, int id, bool upLeft ); 00105 void moveAfter( int pos, int id, bool upLeft ); 00106 void setG( TQWidget *w, int p, int s, bool isSplitter = FALSE ); 00107 00108 TQCOORD pick( const TQPoint &p ) const 00109 { return orient == Qt::Horizontal ? p.x() : p.y(); } 00110 TQCOORD pick( const TQSize &s ) const 00111 { return orient == Qt::Horizontal ? s.width() : s.height(); } 00112 00113 TQCOORD trans( const TQPoint &p ) const 00114 { return orient == Qt::Vertical ? p.x() : p.y(); } 00115 TQCOORD trans( const TQSize &s ) const 00116 { return orient == Qt::Vertical ? s.width() : s.height(); } 00117 00118 TQSplitterData *data; 00119 00120 private: 00121 Qt::Orientation orient; 00122 Direction _direction; 00123 #ifndef DOXYGEN_SKIP_INTERNAL 00124 friend class KDGanttSplitterHandle; 00125 #endif 00126 private: // Disabled copy constructor and operator= 00127 #if defined(TQ_DISABLE_COPY) 00128 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); 00129 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); 00130 #endif 00131 }; 00132 00133 #ifndef DOXYGEN_SKIP_INTERNAL 00134 // This class was continued from a verbatim copy of the 00135 // TQSplitterHandle pertaining to the TQt Enterprise License and the 00136 // GPL. It has only been renamed to KDGanttSplitterHandler in order to 00137 // avoid a symbol clash on some platforms. 00138 class KDGanttSplitterHandle : public TQWidget 00139 { 00140 Q_OBJECT 00141 TQ_OBJECT 00142 public: 00143 KDGanttSplitterHandle( Qt::Orientation o, 00144 KDGanttMinimizeSplitter *parent, const char* name=0 ); 00145 void setOrientation( Qt::Orientation o ); 00146 Qt::Orientation orientation() const { return orient; } 00147 00148 bool opaque() const { return s->opaqueResize(); } 00149 00150 TQSize sizeHint() const; 00151 00152 int id() const { return myId; } // data->list.at(id())->wid == this 00153 void setId( int i ) { myId = i; } 00154 00155 protected: 00156 TQValueList<TQPointArray> buttonRegions(); 00157 void paintEvent( TQPaintEvent * ); 00158 void mouseMoveEvent( TQMouseEvent * ); 00159 void mousePressEvent( TQMouseEvent * ); 00160 void mouseReleaseEvent( TQMouseEvent * ); 00161 int onButton( const TQPoint& p ); 00162 void updateCursor( const TQPoint& p ); 00163 00164 private: 00165 Qt::Orientation orient; 00166 bool opaq; 00167 int myId; 00168 00169 KDGanttMinimizeSplitter *s; 00170 int _activeButton; 00171 bool _collapsed; 00172 int _origPos; 00173 }; 00174 #endif 00175 00176 #endif // KDGANTTMINIMIZESPLITTER_H