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.

181 lines
5.6KB

  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. #include "tqframe.h"
  35. #include "tqvaluelist.h"
  36. #ifndef TQT_NO_SPLITTER
  37. class TQSplitterData;
  38. class KDGanttSplitterLayoutStruct;
  39. class KDGanttMinimizeSplitter : public TQFrame
  40. {
  41. Q_OBJECT
  42. TQ_ENUMS( Direction )
  43. TQ_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
  44. TQ_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
  45. public:
  46. enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
  47. enum Direction { Left, Right, Up, Down };
  48. KDGanttMinimizeSplitter( TQWidget* parent=0, const char* name=0 );
  49. KDGanttMinimizeSplitter( Orientation, TQWidget* parent=0, const char* name=0 );
  50. ~KDGanttMinimizeSplitter();
  51. virtual void setOrientation( Orientation );
  52. Orientation orientation() const { return orient; }
  53. void setMinimizeDirection( Direction );
  54. Direction minimizeDirection() const;
  55. virtual void setResizeMode( TQWidget *w, ResizeMode );
  56. virtual void setOpaqueResize( bool = TRUE );
  57. bool opaqueResize() const;
  58. void moveToFirst( TQWidget * );
  59. void moveToLast( TQWidget * );
  60. void refresh() { recalc( TRUE ); }
  61. virtual TQSize sizeHint() const;
  62. virtual TQSize minimumSizeHint() const;
  63. TQValueList<int> sizes() const;
  64. void setSizes( TQValueList<int> );
  65. void expandPos( int id, int* min, int* max );
  66. protected:
  67. void childEvent( TQChildEvent * );
  68. bool event( TQEvent * );
  69. void resizeEvent( TQResizeEvent * );
  70. int idAfter( TQWidget* ) const;
  71. void moveSplitter( TQCOORD pos, int id );
  72. virtual void drawSplitter( TQPainter*, TQCOORD x, TQCOORD y,
  73. TQCOORD w, TQCOORD h );
  74. void styleChange( TQStyle& );
  75. int adjustPos( int , int );
  76. virtual void setRubberband( int );
  77. void getRange( int id, int*, int* );
  78. private:
  79. void init();
  80. void recalc( bool update = FALSE );
  81. void doResize();
  82. void storeSizes();
  83. void processChildEvents();
  84. KDGanttSplitterLayoutStruct *addWidget( TQWidget*, bool first = FALSE );
  85. void recalcId();
  86. void moveBefore( int pos, int id, bool upLeft );
  87. void moveAfter( int pos, int id, bool upLeft );
  88. void setG( TQWidget *w, int p, int s, bool isSplitter = FALSE );
  89. TQCOORD pick( const TQPoint &p ) const
  90. { return orient ==Qt::Horizontal ? p.x() : p.y(); }
  91. TQCOORD pick( const TQSize &s ) const
  92. { return orient ==Qt::Horizontal ? s.width() : s.height(); }
  93. TQCOORD trans( const TQPoint &p ) const
  94. { return orient ==Qt::Vertical ? p.x() : p.y(); }
  95. TQCOORD trans( const TQSize &s ) const
  96. { return orient ==Qt::Vertical ? s.width() : s.height(); }
  97. TQSplitterData *data;
  98. private:
  99. Orientation orient;
  100. Direction _direction;
  101. #ifndef DOXYGEN_SKIP_INTERNAL
  102. friend class KDGanttSplitterHandle;
  103. #endif
  104. private: // Disabled copy constructor and operator=
  105. #if defined(TQ_DISABLE_COPY)
  106. KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
  107. KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
  108. #endif
  109. };
  110. #ifndef DOXYGEN_SKIP_INTERNAL
  111. // This class was continued from a verbatim copy of the
  112. // TQSplitterHandle pertaining to the TQt Enterprise License and the
  113. // GPL. It has only been renamed to KDGanttSplitterHandler in order to
  114. // avoid a symbol clash on some platforms.
  115. class KDGanttSplitterHandle : public TQWidget
  116. {
  117. Q_OBJECT
  118. public:
  119. KDGanttSplitterHandle( Orientation o,
  120. KDGanttMinimizeSplitter *parent, const char* name=0 );
  121. void setOrientation( Orientation o );
  122. Orientation orientation() const { return orient; }
  123. bool opaque() const { return s->opaqueResize(); }
  124. TQSize sizeHint() const;
  125. int id() const { return myId; } // data->list.at(id())->wid == this
  126. void setId( int i ) { myId = i; }
  127. protected:
  128. TQValueList<TQPointArray> buttonRegions();
  129. void paintEvent( TQPaintEvent * );
  130. void mouseMoveEvent( TQMouseEvent * );
  131. void mousePressEvent( TQMouseEvent * );
  132. void mouseReleaseEvent( TQMouseEvent * );
  133. int onButton( const TQPoint& p );
  134. void updateCursor( const TQPoint& p );
  135. private:
  136. Orientation orient;
  137. bool opaq;
  138. int myId;
  139. KDGanttMinimizeSplitter *s;
  140. int _activeButton;
  141. bool _collapsed;
  142. int _origPos;
  143. };
  144. #endif
  145. #endif // TQT_NO_SPLITTER
  146. #endif // KDGANTTMINIMIZESPLITTER_H