author | zautrix <zautrix> | 2005-04-21 12:32:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-04-21 12:32:52 (UTC) |
commit | 0a13a3490ec3bf4735e3435f80f58fa7d50b4448 (patch) (unidiff) | |
tree | c7f28c49b52e479f47da0dce9f0bfe9189ecdca4 /microkde | |
parent | 4d96d7b681ce99d76746a843c289b75f5e7dba64 (diff) | |
download | kdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.zip kdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.tar.gz kdepimpi-0a13a3490ec3bf4735e3435f80f58fa7d50b4448.tar.bz2 |
rubberband fix
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 21 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.h | 5 |
2 files changed, 21 insertions, 5 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index fb5d4e3..72c4e60 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -7,108 +7,121 @@ | |||
7 | ** | 7 | ** |
8 | ** This file is part of the KDGantt library. | 8 | ** This file is part of the KDGantt library. |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** Licensees holding valid commercial KDGantt licenses may use this file in | 15 | ** Licensees holding valid commercial KDGantt licenses may use this file in |
16 | ** accordance with the KDGantt Commercial License Agreement provided with | 16 | ** accordance with the KDGantt Commercial License Agreement provided with |
17 | ** the Software. | 17 | ** the Software. |
18 | ** | 18 | ** |
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
21 | ** | 21 | ** |
22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for | 22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for |
23 | ** information about KDGantt Commercial License Agreements. | 23 | ** information about KDGantt Commercial License Agreements. |
24 | ** | 24 | ** |
25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this | 25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this |
26 | ** licensing are not clear to you. | 26 | ** licensing are not clear to you. |
27 | ** | 27 | ** |
28 | ** As a special exception, permission is given to link this program | 28 | ** As a special exception, permission is given to link this program |
29 | ** with any edition of Qt, and distribute the resulting executable, | 29 | ** with any edition of Qt, and distribute the resulting executable, |
30 | ** without including the source code for Qt in the source distribution. | 30 | ** without including the source code for Qt in the source distribution. |
31 | ** | 31 | ** |
32 | **********************************************************************/ | 32 | **********************************************************************/ |
33 | 33 | ||
34 | #include "KDGanttMinimizeSplitter.h" | 34 | #include "KDGanttMinimizeSplitter.h" |
35 | #ifndef QT_NO_SPLITTER___ | 35 | #ifndef QT_NO_SPLITTER___ |
36 | 36 | ||
37 | #include "qpainter.h" | 37 | #include "qpainter.h" |
38 | #include "qdrawutil.h" | 38 | #include "qdrawutil.h" |
39 | #include "qbitmap.h" | 39 | #include "qbitmap.h" |
40 | #if QT_VERSION >= 0x030000 | 40 | #if QT_VERSION >= 0x030000 |
41 | #include "qptrlist.h" | 41 | #include "qptrlist.h" |
42 | #include "qmemarray.h" | 42 | #include "qmemarray.h" |
43 | #else | 43 | #else |
44 | #include <qlist.h> | 44 | #include <qlist.h> |
45 | #include <qarray.h> | 45 | #include <qarray.h> |
46 | #define QPtrList QList | 46 | #define QPtrList QList |
47 | #define QMemArray QArray | 47 | #define QMemArray QArray |
48 | #endif | 48 | #endif |
49 | #include "qlayoutengine_p.h" | 49 | #include "qlayoutengine_p.h" |
50 | #include "qobjectlist.h" | 50 | #include "qobjectlist.h" |
51 | #include "qstyle.h" | 51 | #include "qstyle.h" |
52 | #include "qapplication.h" //sendPostedEvents | 52 | #include "qapplication.h" //sendPostedEvents |
53 | #include <qvaluelist.h> | 53 | #include <qvaluelist.h> |
54 | #include <qcursor.h> | 54 | #include <qcursor.h> |
55 | #include <qframe.h> | ||
55 | #ifndef KDGANTT_MASTER_CVS | 56 | #ifndef KDGANTT_MASTER_CVS |
56 | //#include "KDGanttMinimizeSplitter.moc" | 57 | //#include "KDGanttMinimizeSplitter.moc" |
57 | #endif | 58 | #endif |
58 | 59 | ||
59 | 60 | ||
60 | 61 | ||
61 | #ifndef DOXYGEN_SKIP_INTERNAL | 62 | #ifndef DOXYGEN_SKIP_INTERNAL |
62 | 63 | ||
63 | #if QT_VERSION >= 232 | 64 | #if QT_VERSION >= 232 |
64 | static int mouseOffset; | 65 | static int mouseOffset; |
65 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky | 66 | static int opaqueOldPos = -1; //### there's only one mouse, but this is a bit risky |
66 | 67 | ||
68 | class KDRubberBand: public QFrame | ||
69 | { | ||
70 | public: | ||
71 | KDRubberBand( QWidget *parent, const char * name, WFlags f ) :QFrame ( parent, name, f ) {;} | ||
72 | |||
73 | protected: | ||
74 | virtual void mousePressEvent ( QMouseEvent * ) | ||
75 | { | ||
76 | close(); | ||
77 | }; | ||
78 | |||
79 | }; | ||
67 | 80 | ||
68 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | 81 | KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, |
69 | KDGanttMinimizeSplitter *parent, const char * name ) | 82 | KDGanttMinimizeSplitter *parent, const char * name ) |
70 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) | 83 | : QWidget( parent, name ), _activeButton( 0 ), _collapsed( false ) |
71 | { | 84 | { |
72 | 85 | ||
73 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { | 86 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { |
74 | mSizeHint = QSize(7,7); | 87 | mSizeHint = QSize(7,7); |
75 | mUseOffset = true; | 88 | mUseOffset = true; |
76 | } else { | 89 | } else { |
77 | mSizeHint = QSize(6,6); | 90 | mSizeHint = QSize(6,6); |
78 | mUseOffset = false; | 91 | mUseOffset = false; |
79 | } | 92 | } |
80 | s = parent; | 93 | s = parent; |
81 | setOrientation(o); | 94 | setOrientation(o); |
82 | setMouseTracking( true ); | 95 | setMouseTracking( true ); |
83 | mMouseDown = false; | 96 | mMouseDown = false; |
84 | //setMaximumHeight( 5 ); // test only | 97 | //setMaximumHeight( 5 ); // test only |
85 | } | 98 | } |
86 | 99 | ||
87 | QSize KDGanttSplitterHandle::sizeHint() const | 100 | QSize KDGanttSplitterHandle::sizeHint() const |
88 | { | 101 | { |
89 | return mSizeHint; | 102 | return mSizeHint; |
90 | } | 103 | } |
91 | 104 | ||
92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 105 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) |
93 | { | 106 | { |
94 | orient = o; | 107 | orient = o; |
95 | #ifndef QT_NO_CURSOR | 108 | #ifndef QT_NO_CURSOR |
96 | if ( o == KDGanttMinimizeSplitter::Horizontal ) | 109 | if ( o == KDGanttMinimizeSplitter::Horizontal ) |
97 | setCursor( splitHCursor ); | 110 | setCursor( splitHCursor ); |
98 | else | 111 | else |
99 | setCursor( splitVCursor ); | 112 | setCursor( splitVCursor ); |
100 | #endif | 113 | #endif |
101 | } | 114 | } |
102 | 115 | ||
103 | 116 | ||
104 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | 117 | void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) |
105 | { | 118 | { |
106 | updateCursor( e->pos() ); | 119 | updateCursor( e->pos() ); |
107 | if ( !(e->state()&LeftButton) ) | 120 | if ( !(e->state()&LeftButton) ) |
108 | return; | 121 | return; |
109 | 122 | ||
110 | if ( _activeButton != 0) | 123 | if ( _activeButton != 0) |
111 | return; | 124 | return; |
112 | 125 | ||
113 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 126 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
114 | - mouseOffset; | 127 | - mouseOffset; |
@@ -144,98 +157,100 @@ void KDGanttSplitterHandle::updateCursor( const QPoint& p) | |||
144 | else | 157 | else |
145 | setCursor( splitVCursor ); | 158 | setCursor( splitVCursor ); |
146 | } | 159 | } |
147 | } | 160 | } |
148 | void KDGanttSplitterHandle::toggle() | 161 | void KDGanttSplitterHandle::toggle() |
149 | { | 162 | { |
150 | int pos; | 163 | int pos; |
151 | int min, max; | 164 | int min, max; |
152 | if ( !_collapsed ) { | 165 | if ( !_collapsed ) { |
153 | s->expandPos( id(), &min, &max ); | 166 | s->expandPos( id(), &min, &max ); |
154 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left | 167 | if ( s->minimizeDirection() == KDGanttMinimizeSplitter::Left |
155 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { | 168 | || s->minimizeDirection() == KDGanttMinimizeSplitter::Up ) { |
156 | pos = min; | 169 | pos = min; |
157 | } | 170 | } |
158 | else { | 171 | else { |
159 | pos = max; | 172 | pos = max; |
160 | } | 173 | } |
161 | 174 | ||
162 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); | 175 | _origPos = s->pick(mapToParent( QPoint( 0,0 ) )); |
163 | s->moveSplitter( pos, id() ); | 176 | s->moveSplitter( pos, id() ); |
164 | _collapsed = true; | 177 | _collapsed = true; |
165 | } | 178 | } |
166 | else { | 179 | else { |
167 | s->moveSplitter( _origPos, id() ); | 180 | s->moveSplitter( _origPos, id() ); |
168 | _collapsed = false; | 181 | _collapsed = false; |
169 | } | 182 | } |
170 | repaint(); | 183 | repaint(); |
171 | } | 184 | } |
172 | 185 | ||
173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 186 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
174 | { | 187 | { |
175 | mMouseDown = false; | 188 | mMouseDown = false; |
176 | if ( _activeButton != 0 ) { | 189 | if ( _activeButton != 0 ) { |
177 | if ( onButton( e->pos() ) == _activeButton ) | 190 | if ( onButton( e->pos() ) == _activeButton ) |
178 | { | 191 | { |
179 | toggle(); | 192 | toggle(); |
180 | } | 193 | } |
181 | _activeButton = 0; | 194 | _activeButton = 0; |
182 | updateCursor( e->pos() ); | 195 | updateCursor( e->pos() ); |
183 | } | 196 | } |
184 | else { | 197 | else { |
185 | if ( !opaque() && e->button() == LeftButton ) { | 198 | if ( !opaque() && e->button() == LeftButton ) { |
186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 199 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
187 | - mouseOffset; | 200 | - mouseOffset; |
188 | s->setRubberband( -1 ); | 201 | s->setRubberband( -1 ); |
189 | s->moveSplitter( pos, id() ); | 202 | s->moveSplitter( pos, id() ); |
190 | } | 203 | } |
191 | } | 204 | } |
192 | if ( s->rubberBand() ) | 205 | if ( s->rubberBand() ) { |
193 | s->rubberBand()->hide(); | 206 | //qDebug("hide rubberband "); |
207 | s->rubberBand()->close(); | ||
208 | } | ||
194 | repaint(); | 209 | repaint(); |
195 | } | 210 | } |
196 | 211 | ||
197 | int KDGanttSplitterHandle::onButton( const QPoint& p ) | 212 | int KDGanttSplitterHandle::onButton( const QPoint& p ) |
198 | { | 213 | { |
199 | QValueList<QPointArray> list = buttonRegions(); | 214 | QValueList<QPointArray> list = buttonRegions(); |
200 | int index = 1; | 215 | int index = 1; |
201 | int add = 12; | 216 | int add = 12; |
202 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 217 | for( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
203 | QRect rect = (*it).boundingRect(); | 218 | QRect rect = (*it).boundingRect(); |
204 | rect.setLeft( rect.left()- add ); | 219 | rect.setLeft( rect.left()- add ); |
205 | rect.setRight( rect.right() + add); | 220 | rect.setRight( rect.right() + add); |
206 | rect.setTop( rect.top()- add ); | 221 | rect.setTop( rect.top()- add ); |
207 | rect.setBottom( rect.bottom() + add); | 222 | rect.setBottom( rect.bottom() + add); |
208 | if ( rect.contains( p ) ) { | 223 | if ( rect.contains( p ) ) { |
209 | return index; | 224 | return index; |
210 | } | 225 | } |
211 | index++; | 226 | index++; |
212 | } | 227 | } |
213 | return 0; | 228 | return 0; |
214 | } | 229 | } |
215 | 230 | ||
216 | 231 | ||
217 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() | 232 | QValueList<QPointArray> KDGanttSplitterHandle::buttonRegions() |
218 | { | 233 | { |
219 | QValueList<QPointArray> list; | 234 | QValueList<QPointArray> list; |
220 | 235 | ||
221 | int sw = 8; | 236 | int sw = 8; |
222 | int yyy = 1; | 237 | int yyy = 1; |
223 | int xxx = 1; | 238 | int xxx = 1; |
224 | int voffset[] = { (int) -sw*3, (int) sw*3 }; | 239 | int voffset[] = { (int) -sw*3, (int) sw*3 }; |
225 | for ( int i = 0; i < 2; i++ ) { | 240 | for ( int i = 0; i < 2; i++ ) { |
226 | QPointArray arr; | 241 | QPointArray arr; |
227 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || | 242 | if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right || |
228 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { | 243 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left) { |
229 | int mid = height()/2 + voffset[i]; | 244 | int mid = height()/2 + voffset[i]; |
230 | arr.setPoints( 3, | 245 | arr.setPoints( 3, |
231 | 1-xxx, mid - sw + 4, | 246 | 1-xxx, mid - sw + 4, |
232 | sw-3-xxx, mid, | 247 | sw-3-xxx, mid, |
233 | 1-xxx, mid + sw -4); | 248 | 1-xxx, mid + sw -4); |
234 | } | 249 | } |
235 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || | 250 | else if ( !_collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Left || |
236 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { | 251 | _collapsed && s->minimizeDirection() == KDGanttMinimizeSplitter::Right ) { |
237 | int mid = height()/2 + voffset[i]; | 252 | int mid = height()/2 + voffset[i]; |
238 | arr.setPoints( 3, | 253 | arr.setPoints( 3, |
239 | sw-4, mid - sw + 4, | 254 | sw-4, mid - sw + 4, |
240 | 0, mid, | 255 | 0, mid, |
241 | sw-4, mid + sw - 4); | 256 | sw-4, mid + sw - 4); |
@@ -636,97 +651,97 @@ void KDGanttMinimizeSplitter::childEvent( QChildEvent *c ) | |||
636 | delete p->wid; //will call childEvent | 651 | delete p->wid; //will call childEvent |
637 | delete p; | 652 | delete p; |
638 | } | 653 | } |
639 | recalcId(); | 654 | recalcId(); |
640 | doResize(); | 655 | doResize(); |
641 | return; | 656 | return; |
642 | } | 657 | } |
643 | p = s; | 658 | p = s; |
644 | s = data->list.next(); | 659 | s = data->list.next(); |
645 | } | 660 | } |
646 | } | 661 | } |
647 | } | 662 | } |
648 | 663 | ||
649 | 664 | ||
650 | /*! | 665 | /*! |
651 | Shows a rubber band at position \a p. If \a p is negative, the | 666 | Shows a rubber band at position \a p. If \a p is negative, the |
652 | rubber band is removed. | 667 | rubber band is removed. |
653 | */ | 668 | */ |
654 | void KDGanttMinimizeSplitter::setRubberband( int p ) | 669 | void KDGanttMinimizeSplitter::setRubberband( int p ) |
655 | { | 670 | { |
656 | #ifdef DESKTOP_VERSION | 671 | #ifdef DESKTOP_VERSION |
657 | QPainter paint( this ); | 672 | QPainter paint( this ); |
658 | paint.setPen( gray ); | 673 | paint.setPen( gray ); |
659 | paint.setBrush( gray ); | 674 | paint.setBrush( gray ); |
660 | paint.setRasterOp( XorROP ); | 675 | paint.setRasterOp( XorROP ); |
661 | QRect r = contentsRect(); | 676 | QRect r = contentsRect(); |
662 | const int rBord = 3; //Themable???? | 677 | const int rBord = 3; //Themable???? |
663 | #if QT_VERSION >= 0x030000 | 678 | #if QT_VERSION >= 0x030000 |
664 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); | 679 | int sw = style().pixelMetric(QStyle::PM_SplitterWidth, this); |
665 | #else | 680 | #else |
666 | int sw = style().splitterWidth(); | 681 | int sw = style().splitterWidth(); |
667 | #endif | 682 | #endif |
668 | if ( orient == Horizontal ) { | 683 | if ( orient == Horizontal ) { |
669 | if ( opaqueOldPos >= 0 ) | 684 | if ( opaqueOldPos >= 0 ) |
670 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), | 685 | paint.drawRect( opaqueOldPos + sw/2 - rBord , r.y(), |
671 | 2*rBord, r.height() ); | 686 | 2*rBord, r.height() ); |
672 | if ( p >= 0 ) | 687 | if ( p >= 0 ) |
673 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); | 688 | paint.drawRect( p + sw/2 - rBord, r.y(), 2*rBord, r.height() ); |
674 | } else { | 689 | } else { |
675 | if ( opaqueOldPos >= 0 ) | 690 | if ( opaqueOldPos >= 0 ) |
676 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, | 691 | paint.drawRect( r.x(), opaqueOldPos + sw/2 - rBord, |
677 | r.width(), 2*rBord ); | 692 | r.width(), 2*rBord ); |
678 | if ( p >= 0 ) | 693 | if ( p >= 0 ) |
679 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); | 694 | paint.drawRect( r.x(), p + sw/2 - rBord, r.width(), 2*rBord ); |
680 | } | 695 | } |
681 | opaqueOldPos = p; | 696 | opaqueOldPos = p; |
682 | #else | 697 | #else |
683 | if ( !mRubberBand ) { | 698 | if ( !mRubberBand ) { |
684 | mRubberBand = new QFrame( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); | 699 | mRubberBand = new KDRubberBand( 0, "rubber", WStyle_NoBorder | WStyle_Customize | WStyle_StaysOnTop); |
685 | mRubberBand->setFrameStyle( Box | Raised ); | 700 | mRubberBand->setFrameStyle( Box | Raised ); |
686 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); | 701 | //mRubberBand->setPalette( QPalette ( Qt::red.light(),Qt::red.dark() ) ); |
687 | mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); | 702 | mRubberBand->setPalette( QPalette ( colorGroup().background().light(), colorGroup().background().dark() )); |
688 | } | 703 | } |
689 | QRect r = contentsRect(); | 704 | QRect r = contentsRect(); |
690 | static int rBord = 0; //Themable???? | 705 | static int rBord = 0; //Themable???? |
691 | if ( !rBord ) { | 706 | if ( !rBord ) { |
692 | if (QApplication::desktop()->width() <= 320 ) | 707 | if (QApplication::desktop()->width() <= 320 ) |
693 | rBord = 3; | 708 | rBord = 3; |
694 | else | 709 | else |
695 | rBord = 4; | 710 | rBord = 4; |
696 | } | 711 | } |
697 | int sw = style().splitterWidth(); | 712 | int sw = style().splitterWidth(); |
698 | if ( orient == Horizontal ) { | 713 | if ( orient == Horizontal ) { |
699 | if ( p >= 0 ) { | 714 | if ( p >= 0 ) { |
700 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); | 715 | QPoint geo = mapToGlobal (QPoint ( p + sw/2 - rBord, r.y())); |
701 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); | 716 | mRubberBand->setGeometry( geo.x(), geo.y(), 2*rBord, r.height() ); |
702 | } | 717 | } |
703 | } else { | 718 | } else { |
704 | if ( p >= 0 ) { | 719 | if ( p >= 0 ) { |
705 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); | 720 | QPoint geo = mapToGlobal (QPoint ( r.x(), p + sw/2 - rBord)); |
706 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); | 721 | mRubberBand->setGeometry( geo.x(), geo.y(), r.width(), 2*rBord); |
707 | } | 722 | } |
708 | } | 723 | } |
709 | opaqueOldPos = p; | 724 | opaqueOldPos = p; |
710 | if ( ! mRubberBand->isVisible() ) { | 725 | if ( ! mRubberBand->isVisible() ) { |
711 | mRubberBand->show(); | 726 | mRubberBand->show(); |
712 | } | 727 | } |
713 | #endif | 728 | #endif |
714 | } | 729 | } |
715 | 730 | ||
716 | 731 | ||
717 | /*! \reimp */ | 732 | /*! \reimp */ |
718 | bool KDGanttMinimizeSplitter::event( QEvent *e ) | 733 | bool KDGanttMinimizeSplitter::event( QEvent *e ) |
719 | { | 734 | { |
720 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { | 735 | if ( e->type() == QEvent::LayoutHint || ( e->type() == QEvent::Show && data->firstShow ) ) { |
721 | recalc( isVisible() ); | 736 | recalc( isVisible() ); |
722 | if ( e->type() == QEvent::Show ) | 737 | if ( e->type() == QEvent::Show ) |
723 | data->firstShow = FALSE; | 738 | data->firstShow = FALSE; |
724 | } | 739 | } |
725 | return QWidget::event( e ); | 740 | return QWidget::event( e ); |
726 | } | 741 | } |
727 | 742 | ||
728 | 743 | ||
729 | /*! | 744 | /*! |
730 | \obsolete | 745 | \obsolete |
731 | 746 | ||
732 | Draws the splitter handle in the rectangle described by \a x, \a y, | 747 | Draws the splitter handle in the rectangle described by \a x, \a y, |
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h index 585298d..3042e0a 100644 --- a/microkde/KDGanttMinimizeSplitter.h +++ b/microkde/KDGanttMinimizeSplitter.h | |||
@@ -1,151 +1,152 @@ | |||
1 | /* -*- Mode: C++ -*- | 1 | /* -*- Mode: C++ -*- |
2 | $Id$ | 2 | $Id$ |
3 | */ | 3 | */ |
4 | 4 | ||
5 | /**************************************************************************** | 5 | /**************************************************************************** |
6 | ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved. | 6 | ** Copyright (C) 2001-2004 Klarälvdalens Datakonsult AB. All rights reserved. |
7 | ** | 7 | ** |
8 | ** This file is part of the KDGantt library. | 8 | ** This file is part of the KDGantt library. |
9 | ** | 9 | ** |
10 | ** This file may be distributed and/or modified under the terms of the | 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 | 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 | 12 | ** Foundation and appearing in the file LICENSE.GPL included in the |
13 | ** packaging of this file. | 13 | ** packaging of this file. |
14 | ** | 14 | ** |
15 | ** Licensees holding valid commercial KDGantt licenses may use this file in | 15 | ** Licensees holding valid commercial KDGantt licenses may use this file in |
16 | ** accordance with the KDGantt Commercial License Agreement provided with | 16 | ** accordance with the KDGantt Commercial License Agreement provided with |
17 | ** the Software. | 17 | ** the Software. |
18 | ** | 18 | ** |
19 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 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. | 20 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
21 | ** | 21 | ** |
22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for | 22 | ** See http://www.klaralvdalens-datakonsult.se/Public/products/ for |
23 | ** information about KDGantt Commercial License Agreements. | 23 | ** information about KDGantt Commercial License Agreements. |
24 | ** | 24 | ** |
25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this | 25 | ** Contact info@klaralvdalens-datakonsult.se if any conditions of this |
26 | ** licensing are not clear to you. | 26 | ** licensing are not clear to you. |
27 | ** | 27 | ** |
28 | ** As a special exception, permission is given to link this program | 28 | ** As a special exception, permission is given to link this program |
29 | ** with any edition of Qt, and distribute the resulting executable, | 29 | ** with any edition of Qt, and distribute the resulting executable, |
30 | ** without including the source code for Qt in the source distribution. | 30 | ** without including the source code for Qt in the source distribution. |
31 | ** | 31 | ** |
32 | **********************************************************************/ | 32 | **********************************************************************/ |
33 | 33 | ||
34 | #ifndef KDGANTTMINIMIZESPLITTER_H | 34 | #ifndef KDGANTTMINIMIZESPLITTER_H |
35 | #define KDGANTTMINIMIZESPLITTER_H | 35 | #define KDGANTTMINIMIZESPLITTER_H |
36 | 36 | ||
37 | #ifndef QT_H | 37 | #ifndef QT_H |
38 | #include "qframe.h" | 38 | #include "qframe.h" |
39 | #include "qvaluelist.h" | 39 | #include "qvaluelist.h" |
40 | #endif // QT_H | 40 | #endif // QT_H |
41 | 41 | ||
42 | #ifndef QT_NO_SPLITTER___ | 42 | #ifndef QT_NO_SPLITTER___ |
43 | class QSplitterData; | 43 | class QSplitterData; |
44 | class QSplitterLayoutStruct; | 44 | class QSplitterLayoutStruct; |
45 | class KDGanttSplitterHandle; | 45 | class KDGanttSplitterHandle; |
46 | class KDRubberBand; | ||
46 | class KDGanttMinimizeSplitter : public QFrame | 47 | class KDGanttMinimizeSplitter : public QFrame |
47 | { | 48 | { |
48 | Q_OBJECT | 49 | Q_OBJECT |
49 | // Q_ENUMS( Direction ) | 50 | // Q_ENUMS( Direction ) |
50 | // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) | 51 | // Q_PROPERTY( Orientation orientation READ orientation WRITE setOrientation ) |
51 | // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) | 52 | // Q_PROPERTY( Direction minimizeDirection READ minimizeDirection WRITE setMinimizeDirection ) |
52 | 53 | ||
53 | public: | 54 | public: |
54 | enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; | 55 | enum ResizeMode { Stretch, KeepSize, FollowSizeHint }; |
55 | enum Direction { Left, Right, Up, Down }; | 56 | enum Direction { Left, Right, Up, Down }; |
56 | 57 | ||
57 | KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); | 58 | KDGanttMinimizeSplitter( QWidget* parent=0, const char* name=0 ); |
58 | KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); | 59 | KDGanttMinimizeSplitter( Orientation, QWidget* parent=0, const char* name=0 ); |
59 | ~KDGanttMinimizeSplitter(); | 60 | ~KDGanttMinimizeSplitter(); |
60 | 61 | ||
61 | virtual void setOrientation( Orientation ); | 62 | virtual void setOrientation( Orientation ); |
62 | Orientation orientation() const { return orient; } | 63 | Orientation orientation() const { return orient; } |
63 | 64 | ||
64 | void setMinimizeDirection( Direction ); | 65 | void setMinimizeDirection( Direction ); |
65 | Direction minimizeDirection() const; | 66 | Direction minimizeDirection() const; |
66 | 67 | ||
67 | #if QT_VERSION >= 232 | 68 | #if QT_VERSION >= 232 |
68 | virtual void setResizeMode( QWidget *w, ResizeMode ); | 69 | virtual void setResizeMode( QWidget *w, ResizeMode ); |
69 | virtual void setOpaqueResize( bool = TRUE ); | 70 | virtual void setOpaqueResize( bool = TRUE ); |
70 | bool opaqueResize() const; | 71 | bool opaqueResize() const; |
71 | 72 | ||
72 | void moveToFirst( QWidget * ); | 73 | void moveToFirst( QWidget * ); |
73 | void moveToLast( QWidget * ); | 74 | void moveToLast( QWidget * ); |
74 | 75 | ||
75 | void refresh() { recalc( TRUE ); } | 76 | void refresh() { recalc( TRUE ); } |
76 | QSize sizeHint() const; | 77 | QSize sizeHint() const; |
77 | QSize minimumSizeHint() const; | 78 | QSize minimumSizeHint() const; |
78 | 79 | ||
79 | QValueList<int> sizes() const; | 80 | QValueList<int> sizes() const; |
80 | void setSizes( QValueList<int> ); | 81 | void setSizes( QValueList<int> ); |
81 | KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} | 82 | KDGanttSplitterHandle* firstHandle(){ return mFirstHandle;} |
82 | void expandPos( int id, int* min, int* max ); | 83 | void expandPos( int id, int* min, int* max ); |
83 | QFrame* rubberBand() { return mRubberBand ;} | 84 | KDRubberBand* rubberBand() { return mRubberBand ;} |
84 | public slots: | 85 | public slots: |
85 | void toggle(); | 86 | void toggle(); |
86 | protected: | 87 | protected: |
87 | void childEvent( QChildEvent * ); | 88 | void childEvent( QChildEvent * ); |
88 | 89 | ||
89 | bool event( QEvent * ); | 90 | bool event( QEvent * ); |
90 | void resizeEvent( QResizeEvent * ); | 91 | void resizeEvent( QResizeEvent * ); |
91 | 92 | ||
92 | int idAfter( QWidget* ) const; | 93 | int idAfter( QWidget* ) const; |
93 | 94 | ||
94 | void moveSplitter( QCOORD pos, int id ); | 95 | void moveSplitter( QCOORD pos, int id ); |
95 | virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, | 96 | virtual void drawSplitter( QPainter*, QCOORD x, QCOORD y, |
96 | QCOORD w, QCOORD h ); | 97 | QCOORD w, QCOORD h ); |
97 | void styleChange( QStyle& ); | 98 | void styleChange( QStyle& ); |
98 | int adjustPos( int , int ); | 99 | int adjustPos( int , int ); |
99 | virtual void setRubberband( int ); | 100 | virtual void setRubberband( int ); |
100 | void getRange( int id, int*, int* ); | 101 | void getRange( int id, int*, int* ); |
101 | 102 | ||
102 | private: | 103 | private: |
103 | QFrame* mRubberBand; | 104 | KDRubberBand* mRubberBand; |
104 | void init(); | 105 | void init(); |
105 | void recalc( bool update = FALSE ); | 106 | void recalc( bool update = FALSE ); |
106 | void doResize(); | 107 | void doResize(); |
107 | void storeSizes(); | 108 | void storeSizes(); |
108 | void processChildEvents(); | 109 | void processChildEvents(); |
109 | QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); | 110 | QSplitterLayoutStruct *addWidget( QWidget*, bool first = FALSE ); |
110 | void recalcId(); | 111 | void recalcId(); |
111 | void moveBefore( int pos, int id, bool upLeft ); | 112 | void moveBefore( int pos, int id, bool upLeft ); |
112 | void moveAfter( int pos, int id, bool upLeft ); | 113 | void moveAfter( int pos, int id, bool upLeft ); |
113 | void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); | 114 | void setG( QWidget *w, int p, int s, bool isSplitter = FALSE ); |
114 | 115 | ||
115 | QCOORD pick( const QPoint &p ) const | 116 | QCOORD pick( const QPoint &p ) const |
116 | { return orient == Horizontal ? p.x() : p.y(); } | 117 | { return orient == Horizontal ? p.x() : p.y(); } |
117 | QCOORD pick( const QSize &s ) const | 118 | QCOORD pick( const QSize &s ) const |
118 | { return orient == Horizontal ? s.width() : s.height(); } | 119 | { return orient == Horizontal ? s.width() : s.height(); } |
119 | 120 | ||
120 | QCOORD trans( const QPoint &p ) const | 121 | QCOORD trans( const QPoint &p ) const |
121 | { return orient == Vertical ? p.x() : p.y(); } | 122 | { return orient == Vertical ? p.x() : p.y(); } |
122 | QCOORD trans( const QSize &s ) const | 123 | QCOORD trans( const QSize &s ) const |
123 | { return orient == Vertical ? s.width() : s.height(); } | 124 | { return orient == Vertical ? s.width() : s.height(); } |
124 | KDGanttSplitterHandle* mFirstHandle; | 125 | KDGanttSplitterHandle* mFirstHandle; |
125 | QSplitterData *data; | 126 | QSplitterData *data; |
126 | #endif | 127 | #endif |
127 | 128 | ||
128 | private: | 129 | private: |
129 | Orientation orient; | 130 | Orientation orient; |
130 | Direction _direction; | 131 | Direction _direction; |
131 | #ifndef DOXYGEN_SKIP_INTERNAL | 132 | #ifndef DOXYGEN_SKIP_INTERNAL |
132 | friend class KDGanttSplitterHandle; | 133 | friend class KDGanttSplitterHandle; |
133 | #endif | 134 | #endif |
134 | private:// Disabled copy constructor and operator= | 135 | private:// Disabled copy constructor and operator= |
135 | #if defined(Q_DISABLE_COPY) | 136 | #if defined(Q_DISABLE_COPY) |
136 | KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); | 137 | KDGanttMinimizeSplitter( const KDGanttMinimizeSplitter & ); |
137 | KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); | 138 | KDGanttMinimizeSplitter& operator=( const KDGanttMinimizeSplitter & ); |
138 | #endif | 139 | #endif |
139 | }; | 140 | }; |
140 | 141 | ||
141 | #ifndef DOXYGEN_SKIP_INTERNAL | 142 | #ifndef DOXYGEN_SKIP_INTERNAL |
142 | // This class was continued from a verbatim copy of the | 143 | // This class was continued from a verbatim copy of the |
143 | // QSplitterHandle pertaining to the Qt Enterprise License and the | 144 | // QSplitterHandle pertaining to the Qt Enterprise License and the |
144 | // GPL. It has only been renamed to KDGanttSplitterHandler in order to | 145 | // GPL. It has only been renamed to KDGanttSplitterHandler in order to |
145 | // avoid a symbol clash on some platforms. | 146 | // avoid a symbol clash on some platforms. |
146 | class KDGanttSplitterHandle : public QWidget | 147 | class KDGanttSplitterHandle : public QWidget |
147 | { | 148 | { |
148 | Q_OBJECT | 149 | Q_OBJECT |
149 | #if QT_VERSION >= 232 | 150 | #if QT_VERSION >= 232 |
150 | public: | 151 | public: |
151 | KDGanttSplitterHandle( Qt::Orientation o, | 152 | KDGanttSplitterHandle( Qt::Orientation o, |