KOffice – TDE office suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

183 lines
5.7KB

  1. /* -*- Mode: C++ -*-
  2. $Id$
  3. */
  4. /****************************************************************************
  5. ** Copyright (C) 2001-2004 Klar�lvdalens Datakonsult AB. All rights reserved.
  6. **
  7. ** This file is part of the KDGantt library.
  8. **
  9. ** This file may be distributed and/or modified under the terms of the
  10. ** GNU General Public License version 2 as published by the Free Software
  11. ** Foundation and appearing in the file LICENSE.GPL included in the
  12. ** packaging of this file.
  13. **
  14. ** Licensees holding valid commercial KDGantt licenses may use this file in
  15. ** accordance with the KDGantt Commercial License Agreement provided with
  16. ** the Software.
  17. **
  18. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  19. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  20. **
  21. ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
  22. ** information about KDGantt Commercial License Agreements.
  23. **
  24. ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
  25. ** licensing are not clear to you.
  26. **
  27. ** As a special exception, permission is given to link this program
  28. ** with any edition of TQt, and distribute the resulting executable,
  29. ** without including the source code for TQt in the source distribution.
  30. **
  31. **********************************************************************/
  32. #ifndef KDGANTTMINIMIZESPLITTER_H
  33. #define KDGANTTMINIMIZESPLITTER_H
  34. #ifndef TQT_H
  35. #include "tqframe.h"
  36. #include "tqvaluelist.h"
  37. #endif // TQT_H
  38. #ifndef TQT_NO_SPLITTER
  39. class TQSplitterData;
  40. class KDGanttSplitterLayoutStruct;
  41. class KDGanttMinimizeSplitter : public TQFrame
  42. {
  43. Q_OBJECT
  44. TQ_OBJECT
  45. Q_ENUMS( Direction )
  46. TQ_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation )
  47. TQ_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
  48. public:
  49. enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
  50. enum Direction { Left, Right, Up, Down };
  51. KDGanttMinimizeSplitter( TQWidget* parent=0, const char* name=0 );
  52. KDGanttMinimizeSplitter( Qt::Orientation, TQWidget* parent=0, const char* name=0 );
  53. ~KDGanttMinimizeSplitter();
  54. virtual void setOrientation( Qt::Orientation );
  55. Qt::Orientation orientation() const { return orient; }
  56. void setMinimizeDirection( Direction );
  57. Direction minimizeDirection() const;
  58. virtual void setResizeMode( TQWidget *w, ResizeMode );
  59. virtual void setOpaqueResize( bool = TRUE );
  60. bool opaqueResize() const;
  61. void moveToFirst( TQWidget * );
  62. void moveToLast( TQWidget * );
  63. void refresh() { recalc( TRUE ); }
  64. virtual TQSize tqsizeHint() const;
  65. virtual TQSize tqminimumSizeHint() const;
  66. TQValueList<int> sizes() const;
  67. void setSizes( TQValueList<int> );
  68. void expandPos( int id, int* min, int* max );
  69. protected:
  70. void childEvent( TQChildEvent * );
  71. bool event( TQEvent * );
  72. void resizeEvent( TQResizeEvent * );
  73. int idAfter( TQWidget* ) const;
  74. void moveSplitter( TQCOORD pos, int id );
  75. virtual void drawSplitter( TQPainter*, TQCOORD x, TQCOORD y,
  76. TQCOORD w, TQCOORD h );
  77. void styleChange( TQStyle& );
  78. int adjustPos( int , int );
  79. virtual void setRubberband( int );
  80. void getRange( int id, int*, int* );
  81. private:
  82. void init();
  83. void recalc( bool update = FALSE );
  84. void doResize();
  85. void storeSizes();
  86. void processChildEvents();
  87. KDGanttSplitterLayoutStruct *addWidget( TQWidget*, bool first = FALSE );
  88. void recalcId();
  89. void moveBefore( int pos, int id, bool upLeft );
  90. void moveAfter( int pos, int id, bool upLeft );
  91. void setG( TQWidget *w, int p, int s, bool isSplitter = FALSE );
  92. TQCOORD pick( const TQPoint &p ) const
  93. { return orient ==Qt::Horizontal ? p.x() : p.y(); }
  94. TQCOORD pick( const TQSize &s ) const
  95. { return orient ==Qt::Horizontal ? s.width() : s.height(); }
  96. TQCOORD trans( const TQPoint &p ) const
  97. { return orient ==Qt::Vertical ? p.x() : p.y(); }
  98. TQCOORD trans( const TQSize &s ) const
  99. { return orient ==Qt::Vertical ? s.width() : s.height(); }
  100. TQSplitterData *data;
  101. private:
  102. Qt::Orientation orient;
  103. Direction _direction;
  104. #ifndef DOXYGEN_SKIP_INTERNAL
  105. friend class KDGanttSplitterHandle;
  106. #endif
  107. private: // Disabled copy constructor and operator=
  108. #if defined(TQ_DISABLE_COPY)
  109. KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
  110. KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
  111. #endif
  112. };
  113. #ifndef DOXYGEN_SKIP_INTERNAL
  114. // This class was continued from a verbatim copy of the
  115. // TQSplitterHandle pertaining to the TQt Enterprise License and the
  116. // GPL. It has only been renamed to KDGanttSplitterHandler in order to
  117. // avoid a symbol clash on some platforms.
  118. class KDGanttSplitterHandle : public TQWidget
  119. {
  120. Q_OBJECT
  121. TQ_OBJECT
  122. public:
  123. KDGanttSplitterHandle( Qt::Orientation o,
  124. KDGanttMinimizeSplitter *parent, const char* name=0 );
  125. void setOrientation( Qt::Orientation o );
  126. Qt::Orientation orientation() const { return orient; }
  127. bool opaque() const { return s->opaqueResize(); }
  128. TQSize tqsizeHint() const;
  129. int id() const { return myId; } // data->list.at(id())->wid == this
  130. void setId( int i ) { myId = i; }
  131. protected:
  132. TQValueList<TQPointArray> buttonRegions();
  133. void paintEvent( TQPaintEvent * );
  134. void mouseMoveEvent( TQMouseEvent * );
  135. void mousePressEvent( TQMouseEvent * );
  136. void mouseReleaseEvent( TQMouseEvent * );
  137. int onButton( const TQPoint& p );
  138. void updateCursor( const TQPoint& p );
  139. private:
  140. Qt::Orientation orient;
  141. bool opaq;
  142. int myId;
  143. KDGanttMinimizeSplitter *s;
  144. int _activeButton;
  145. bool _collapsed;
  146. int _origPos;
  147. };
  148. #endif
  149. #endif // TQT_NO_SPLITTER
  150. #endif // KDGANTTMINIMIZESPLITTER_H