summaryrefslogtreecommitdiffabout
path: root/microkde/KDGanttMinimizeSplitter.h
Unidiff
Diffstat (limited to 'microkde/KDGanttMinimizeSplitter.h') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/KDGanttMinimizeSplitter.h186
1 files changed, 186 insertions, 0 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h
new file mode 100644
index 0000000..75e0443
--- a/dev/null
+++ b/microkde/KDGanttMinimizeSplitter.h
@@ -0,0 +1,186 @@
1/* -*- Mode: C++ -*-
2 $Id$
3*/
4
5/****************************************************************************
6 ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved.
7 **
8 ** This file is part of the KDGantt library.
9 **
10 ** This file may be distributed and/or modified under the terms of the
11 ** GNU General Public License version 2 as published by the Free Software
12 ** Foundation and appearing in the file LICENSE.GPL included in the
13 ** packaging of this file.
14 **
15 ** Licensees holding valid commercial KDGantt licenses may use this file in
16 ** accordance with the KDGantt Commercial License Agreement provided with
17 ** the Software.
18 **
19 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
20 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
21 **
22 ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for
23 ** information about KDGantt Commercial License Agreements.
24 **
25 ** Contact info@klaralvdalens-datakonsult.se if any conditions of this
26 ** licensing are not clear to you.
27 **
28 ** As a special exception, permission is given to link this program
29 ** with any edition of Qt, and distribute the resulting executable,
30 ** without including the source code for Qt in the source distribution.
31 **
32 **********************************************************************/
33
34#ifndef KDGANTTMINIMIZESPLITTER_H
35#define KDGANTTMINIMIZESPLITTER_H
36
37#ifndef QT_H
38#include "qframe.h"
39#include "qvaluelist.h"
40#endif // QT_H
41
42#ifndef QT_NO_SPLITTER___
43class QSplitterData;
44class QSplitterLayoutStruct;
45class KDGanttSplitterHandle;
46class KDGanttMinimizeSplitter : public QFrame
47{
48 Q_OBJECT
49 // Q_ENUMS( Direction )
50 // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation )
51 // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection )
52
53public:
54 enum ResizeMode { Stretch, KeepSize, FollowSizeHint };
55 enum Direction { Left, Right, Up, Down };
56
57 KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 );
58 KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 );
59 ~KDGanttMinimizeSplitter();
60
61 virtual void setOrientation( Orientation );
62 Orientation orientation() const { return orient; }
63
64 void setMinimizeDirection( Direction );
65 Direction minimizeDirection() const;
66
67#if QT_VERSION >= 232
68 virtual void setResizeMode( QWidget *w, ResizeMode );
69 virtual void setOpaqueResize( bool = TRUE );
70 bool opaqueResize() const;
71
72 void moveToFirst( QWidget * );
73 void moveToLast( QWidget * );
74
75 void refresh() { recalc( TRUE ); }
76 QSize sizeHint() const;
77 QSize minimumSizeHint() const;
78
79 QValueList<int> sizes() const;
80 void setSizes( QValueList<int> );
81 KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;}
82 void expandPos( int id, int* min, int* max );
83protected:
84 void childEvent( QChildEvent * );
85
86 bool event( QEvent * );
87 void resizeEvent( QResizeEvent * );
88
89 int idAfter( QWidget* ) const;
90
91 void moveSplitter( QCOORD pos, int id );
92 virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y,
93 QCOORD w, QCOORD h );
94 void styleChange( QStyle& );
95 int adjustPos( int , int );
96 virtual void setRubberband( int );
97 void getRange( int id, int*, int* );
98
99private:
100 void init();
101 void recalc( bool update = FALSE );
102 void doResize();
103 void storeSizes();
104 void processChildEvents();
105 QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE );
106 void recalcId();
107 void moveBefore( int pos, int id, bool upLeft );
108 void moveAfter( int pos, int id, bool upLeft );
109 void setG( QWidget *w, int p, int s, bool isSplitter = FALSE );
110
111 QCOORD pick( const QPoint &p ) const
112 { return orient == Horizontal ? p.x() : p.y(); }
113 QCOORD pick( const QSize &s ) const
114 { return orient == Horizontal ? s.width() : s.height(); }
115
116 QCOORD trans( const QPoint &p ) const
117 { return orient == Vertical ? p.x() : p.y(); }
118 QCOORD trans( const QSize &s ) const
119 { return orient == Vertical ? s.width() : s.height(); }
120 KDGanttSplitterHandle* mFirstHandle;
121 QSplitterData *data;
122#endif
123
124private:
125 Orientation orient;
126 Direction _direction;
127#ifndef DOXYGEN_SKIP_INTERNAL
128 friend class KDGanttSplitterHandle;
129#endif
130 private:// Disabled copy constructor and operator=
131#if defined(Q_DISABLE_COPY)
132 KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & );
133 KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & );
134#endif
135};
136
137#ifndef DOXYGEN_SKIP_INTERNAL
138// This class was continued from a verbatim copy of the
139// QSplitterHandle pertaining to the Qt Enterprise License and the
140// GPL. It has only been renamed to KDGanttSplitterHandler in order to
141// avoid a symbol clash on some platforms.
142class KDGanttSplitterHandle : public QWidget
143{
144 Q_OBJECT
145#if QT_VERSION >= 232
146public:
147 KDGanttSplitterHandle( Qt::Orientation o,
148 KDGanttMinimizeSplitter *parent, const char* name=0 );
149 void setOrientation( Qt::Orientation o );
150 Qt::Orientation orientation() const { return orient; }
151
152 bool opaque() const { return s->opaqueResize(); }
153
154 QSize sizeHint() const;
155 void toggle();
156
157 int id() const { return myId; } // data->list.at(id())->wid == this
158 void setId( int i ) { myId = i; }
159
160protected:
161 QValueList<QPointArray> buttonRegions();
162 void paintEvent( QPaintEvent * );
163 void mouseMoveEvent( QMouseEvent * );
164 void mousePressEvent( QMouseEvent * );
165 void mouseReleaseEvent( QMouseEvent * );
166 int onButton( const QPoint& p );
167 void updateCursor( const QPoint& p );
168
169private:
170 QSize mSizeHint;
171 bool mUseOffset;
172 Qt::Orientation orient;
173 bool opaq;
174 int myId;
175
176 KDGanttMinimizeSplitter *s;
177 int _activeButton;
178 bool _collapsed;
179 int _origPos;
180#endif
181};
182#endif
183
184#endif // QT_NO_SPLITTER
185
186#endif // KDGANTTMINIMIZESPLITTER_H