author | zautrix <zautrix> | 2005-03-26 11:15:27 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2005-03-26 11:15:27 (UTC) |
commit | bc8929ccca1ad8cd04f61366c78254803d9c1565 (patch) (unidiff) | |
tree | 9a99b7e9cefa3c32f90e494afb7e324c59cb8584 | |
parent | ef825f1805452ba2cfb30cd7a41c392d3961f01e (diff) | |
download | kdepimpi-bc8929ccca1ad8cd04f61366c78254803d9c1565.zip kdepimpi-bc8929ccca1ad8cd04f61366c78254803d9c1565.tar.gz kdepimpi-bc8929ccca1ad8cd04f61366c78254803d9c1565.tar.bz2 |
nf
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.cpp | 14 | ||||
-rw-r--r-- | microkde/KDGanttMinimizeSplitter.h | 1 |
2 files changed, 11 insertions, 4 deletions
diff --git a/microkde/KDGanttMinimizeSplitter.cpp b/microkde/KDGanttMinimizeSplitter.cpp index 84edc0d..c60b566 100644 --- a/microkde/KDGanttMinimizeSplitter.cpp +++ b/microkde/KDGanttMinimizeSplitter.cpp | |||
@@ -71,24 +71,25 @@ KDGanttSplitterHandle::KDGanttSplitterHandle( Qt::Orientation o, | |||
71 | { | 71 | { |
72 | 72 | ||
73 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { | 73 | if ( QApplication::desktop()->width() > 320 && QApplication::desktop()->width() < 650 ) { |
74 | mSizeHint = QSize(7,7); | 74 | mSizeHint = QSize(7,7); |
75 | mUseOffset = true; | 75 | mUseOffset = true; |
76 | } else { | 76 | } else { |
77 | mSizeHint = QSize(6,6); | 77 | mSizeHint = QSize(6,6); |
78 | mUseOffset = false; | 78 | mUseOffset = false; |
79 | } | 79 | } |
80 | s = parent; | 80 | s = parent; |
81 | setOrientation(o); | 81 | setOrientation(o); |
82 | setMouseTracking( true ); | 82 | setMouseTracking( true ); |
83 | mMouseDown = false; | ||
83 | //setMaximumHeight( 5 ); // test only | 84 | //setMaximumHeight( 5 ); // test only |
84 | } | 85 | } |
85 | 86 | ||
86 | QSize KDGanttSplitterHandle::sizeHint() const | 87 | QSize KDGanttSplitterHandle::sizeHint() const |
87 | { | 88 | { |
88 | return mSizeHint; | 89 | return mSizeHint; |
89 | } | 90 | } |
90 | 91 | ||
91 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) | 92 | void KDGanttSplitterHandle::setOrientation( Qt::Orientation o ) |
92 | { | 93 | { |
93 | orient = o; | 94 | orient = o; |
94 | #ifndef QT_NO_CURSOR | 95 | #ifndef QT_NO_CURSOR |
@@ -117,26 +118,26 @@ void KDGanttSplitterHandle::mouseMoveEvent( QMouseEvent *e ) | |||
117 | int min = pos; int max = pos; | 118 | int min = pos; int max = pos; |
118 | s->getRange( id(), &min, &max ); | 119 | s->getRange( id(), &min, &max ); |
119 | s->setRubberband( QMAX( min, QMIN(max, pos ))); | 120 | s->setRubberband( QMAX( min, QMIN(max, pos ))); |
120 | } | 121 | } |
121 | _collapsed = false; | 122 | _collapsed = false; |
122 | } | 123 | } |
123 | 124 | ||
124 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) | 125 | void KDGanttSplitterHandle::mousePressEvent( QMouseEvent *e ) |
125 | { | 126 | { |
126 | if ( e->button() == LeftButton ) { | 127 | if ( e->button() == LeftButton ) { |
127 | _activeButton = onButton( e->pos() ); | 128 | _activeButton = onButton( e->pos() ); |
128 | mouseOffset = s->pick(e->pos()); | 129 | mouseOffset = s->pick(e->pos()); |
129 | if ( _activeButton != 0) | 130 | mMouseDown = true; |
130 | repaint(); | 131 | repaint(); |
131 | updateCursor( e->pos() ); | 132 | updateCursor( e->pos() ); |
132 | } | 133 | } |
133 | } | 134 | } |
134 | 135 | ||
135 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) | 136 | void KDGanttSplitterHandle::updateCursor( const QPoint& p) |
136 | { | 137 | { |
137 | if ( onButton( p ) != 0 ) { | 138 | if ( onButton( p ) != 0 ) { |
138 | setCursor( arrowCursor ); | 139 | setCursor( arrowCursor ); |
139 | } | 140 | } |
140 | else { | 141 | else { |
141 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) | 142 | if ( orient == KDGanttMinimizeSplitter::Horizontal ) |
142 | setCursor( splitHCursor ); | 143 | setCursor( splitHCursor ); |
@@ -162,24 +163,25 @@ void KDGanttSplitterHandle::toggle() | |||
162 | s->moveSplitter( pos, id() ); | 163 | s->moveSplitter( pos, id() ); |
163 | _collapsed = true; | 164 | _collapsed = true; |
164 | } | 165 | } |
165 | else { | 166 | else { |
166 | s->moveSplitter( _origPos, id() ); | 167 | s->moveSplitter( _origPos, id() ); |
167 | _collapsed = false; | 168 | _collapsed = false; |
168 | } | 169 | } |
169 | repaint(); | 170 | repaint(); |
170 | } | 171 | } |
171 | 172 | ||
172 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) | 173 | void KDGanttSplitterHandle::mouseReleaseEvent( QMouseEvent *e ) |
173 | { | 174 | { |
175 | mMouseDown = false; | ||
174 | if ( _activeButton != 0 ) { | 176 | if ( _activeButton != 0 ) { |
175 | if ( onButton( e->pos() ) == _activeButton ) | 177 | if ( onButton( e->pos() ) == _activeButton ) |
176 | { | 178 | { |
177 | toggle(); | 179 | toggle(); |
178 | } | 180 | } |
179 | _activeButton = 0; | 181 | _activeButton = 0; |
180 | updateCursor( e->pos() ); | 182 | updateCursor( e->pos() ); |
181 | } | 183 | } |
182 | else { | 184 | else { |
183 | if ( !opaque() && e->button() == LeftButton ) { | 185 | if ( !opaque() && e->button() == LeftButton ) { |
184 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) | 186 | QCOORD pos = s->pick(parentWidget()->mapFromGlobal(e->globalPos())) |
185 | - mouseOffset; | 187 | - mouseOffset; |
@@ -268,26 +270,30 @@ void KDGanttSplitterHandle::paintEvent( QPaintEvent * ) | |||
268 | p.setPen( colorGroup().foreground() ); | 270 | p.setPen( colorGroup().foreground() ); |
269 | //p.drawRect( rect() ); | 271 | //p.drawRect( rect() ); |
270 | buffer.fill( colorGroup().background() ); | 272 | buffer.fill( colorGroup().background() ); |
271 | //buffer.fill( backgroundColor() ); | 273 | //buffer.fill( backgroundColor() ); |
272 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); | 274 | // parentWidget()->style().drawPrimitive( QStyle::PE_Panel, &p, rect(), parentWidget()->colorGroup()); |
273 | 275 | ||
274 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size | 276 | int sw = 8; // Hardcoded, given I didn't use styles anymore, I didn't like to use their size |
275 | 277 | ||
276 | // arrow color | 278 | // arrow color |
277 | QColor col; | 279 | QColor col; |
278 | if ( _activeButton ) | 280 | if ( _activeButton ) |
279 | col = colorGroup().background().dark( 250 ); | 281 | col = colorGroup().background().dark( 250 ); |
280 | else | 282 | else { |
281 | col = colorGroup().background().dark( 150 ); | 283 | if ( mMouseDown ) |
284 | col = Qt::white; | ||
285 | else | ||
286 | col = colorGroup().background().dark( 150 ); | ||
287 | } | ||
282 | //QColor col = backgroundColor().dark( 130 ); | 288 | //QColor col = backgroundColor().dark( 130 ); |
283 | p.setBrush( col ); | 289 | p.setBrush( col ); |
284 | p.setPen( col ); | 290 | p.setPen( col ); |
285 | 291 | ||
286 | QValueList<QPointArray> list = buttonRegions(); | 292 | QValueList<QPointArray> list = buttonRegions(); |
287 | int index = 1; | 293 | int index = 1; |
288 | if ( mUseOffset ) | 294 | if ( mUseOffset ) |
289 | p.translate( 0, 1 ); | 295 | p.translate( 0, 1 ); |
290 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { | 296 | for ( QValueList<QPointArray>::Iterator it = list.begin(); it != list.end(); ++it ) { |
291 | if ( index == _activeButton ) { | 297 | if ( index == _activeButton ) { |
292 | 298 | ||
293 | /* | 299 | /* |
diff --git a/microkde/KDGanttMinimizeSplitter.h b/microkde/KDGanttMinimizeSplitter.h index 8120d14..84d3d8e 100644 --- a/microkde/KDGanttMinimizeSplitter.h +++ b/microkde/KDGanttMinimizeSplitter.h | |||
@@ -160,24 +160,25 @@ public: | |||
160 | void setId( int i ) { myId = i; } | 160 | void setId( int i ) { myId = i; } |
161 | 161 | ||
162 | protected: | 162 | protected: |
163 | QValueList<QPointArray> buttonRegions(); | 163 | QValueList<QPointArray> buttonRegions(); |
164 | void paintEvent( QPaintEvent * ); | 164 | void paintEvent( QPaintEvent * ); |
165 | void mouseMoveEvent( QMouseEvent * ); | 165 | void mouseMoveEvent( QMouseEvent * ); |
166 | void mousePressEvent( QMouseEvent * ); | 166 | void mousePressEvent( QMouseEvent * ); |
167 | void mouseReleaseEvent( QMouseEvent * ); | 167 | void mouseReleaseEvent( QMouseEvent * ); |
168 | int onButton( const QPoint& p ); | 168 | int onButton( const QPoint& p ); |
169 | void updateCursor( const QPoint& p ); | 169 | void updateCursor( const QPoint& p ); |
170 | 170 | ||
171 | private: | 171 | private: |
172 | bool mMouseDown; | ||
172 | QSize mSizeHint; | 173 | QSize mSizeHint; |
173 | bool mUseOffset; | 174 | bool mUseOffset; |
174 | Qt::Orientation orient; | 175 | Qt::Orientation orient; |
175 | bool opaq; | 176 | bool opaq; |
176 | int myId; | 177 | int myId; |
177 | 178 | ||
178 | KDGanttMinimizeSplitter *s; | 179 | KDGanttMinimizeSplitter *s; |
179 | int _activeButton; | 180 | int _activeButton; |
180 | bool _collapsed; | 181 | bool _collapsed; |
181 | int _origPos; | 182 | int _origPos; |
182 | #endif | 183 | #endif |
183 | }; | 184 | }; |