kpresenter

KPrEffectHandler.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2004 Thorsten Zachmann <zachmann@kde.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include "KPrEffectHandler.h"
21
22#include "KPrObject.h"
23#include "KPrDocument.h"
24#include "KPrView.h"
25#include "KPrCanvas.h"
26
27#include <KoZoomHandler.h>
28#include <tdeapplication.h>
29
30#include <tqpainter.h>
31#include <tqpaintdevice.h>
32
33#include <unistd.h>
34
35
36KPrEffectHandler::KPrEffectHandler( PresStep step, bool back, TQPaintDevice *dst, TQPixmap *src,
37 const TQPtrList<KPrObject> &objects, KPrView *view, int _presSpeed )
38: m_effectStep(0), m_step(step), m_back(back), m_dst(dst),
39 m_paint(*src), m_objects(objects), m_view(view), m_soundEffect(TQString()),
40 m_objectTimer(1)
41{
42 m_src = new TQPixmap( *src );
43
44 TQPtrListIterator<KPrObject> it( m_objects );
45 for ( ; it.current(); ++it )
46 {
47 KPrObject *object = it.current();
48 if ( object->getAppearStep() == m_step.m_step
49 && ( m_step.m_subStep == 0
50 || ( object->getType() == OT_TEXT
51 && object->getEffect2() == EF2T_PARA ) ) )
52 {
53 m_appearEffectObjects.append( object );
54 if ( object->getAppearSoundEffect() )
55 {
56 m_soundEffect = object->getAppearSoundEffectFileName();
57 }
58
59 if ( object->getAppearTimer() > m_objectTimer )
60 {
61 m_objectTimer = object->getAppearTimer();
62 }
63 }
64 else if ( object->getDisappear() && object->getDisappearStep() == m_step.m_step )
65 {
66 m_disappearEffectObjects.append( object );
67 if ( object->getDisappearSoundEffect() )
68 {
69 m_soundEffect = object->getDisappearSoundEffectFileName();
70 }
71
72 if ( object->getDisappearTimer() > m_objectTimer )
73 {
74 m_objectTimer = object->getDisappearTimer();
75 }
76 }
77 }
78
79 float speedFactor = 150.0 / static_cast<float>( _presSpeed + 2 );
80 m_stepWidth = static_cast<int>( m_src->width() / speedFactor );
81 m_stepHeight = static_cast<int>( m_src->height() / speedFactor );
82 m_lastRepaintRects.setAutoDelete( true );
83}
84
85
86KPrEffectHandler::~KPrEffectHandler()
87{
88 delete m_src;
89}
90
91
92bool KPrEffectHandler::doEffect()
93{
94 if ( m_effectStep == 0 )
95 {
96 if ( !m_view->kPresenterDoc()->spManualSwitch() )
97 {
98 m_view->stopAutoPresTimer();
99 }
100
101 if ( !m_soundEffect.isNull() )
102 {
103 m_view->getCanvas()->stopSound();
104 m_view->getCanvas()->playSound( m_soundEffect );
105 }
106 }
107 if ( !m_appearEffectObjects.isEmpty() || !m_disappearEffectObjects.isEmpty() )
108 {
109 TQPtrList<TQRect> m_removeRects;
110 KPrObject *appearObject = m_appearEffectObjects.first();
111 KPrObject *disappearObject = m_disappearEffectObjects.first();
112 TQPtrListIterator<KPrObject> it( m_objects );
113 KPrObject *object;
114
115 while ( ( object = it.current() ) != 0 )
116 {
117 int speed[] = { 50, 35, 20 };
118
119 ++it;
120 if ( object == appearObject )
121 {
122 bool next = true;
123
124 double speedFactor = speed[object->getAppearSpeed()];
125
126 m_stepWidth = static_cast<int>( m_src->width() / speedFactor );
127 m_stepHeight = static_cast<int>( m_src->height() / speedFactor );
128
129 if ( doAppearEffectStep( object ) )
130 {
131 m_removeRects.append( m_repaintRects.getLast() );
132 if ( appearObject != m_appearEffectObjects.getLast() )
133 {
134 next = false;
135 }
136 m_appearEffectObjects.remove();
137
138 // add object to src
139 drawObject( object, 0, 0, m_src );
140 }
141 if ( next )
142 appearObject = m_appearEffectObjects.next();
143 else
144 appearObject = m_appearEffectObjects.current();
145 }
146 else if ( object == disappearObject )
147 {
148 bool next = true;
149
150 double speedFactor = speed[object->getDisappearSpeed()];
151
152 m_stepWidth = static_cast<int>( m_src->width() / speedFactor );
153 m_stepHeight = static_cast<int>( m_src->height() / speedFactor );
154
155 if ( doDisappearEffectStep( object ) )
156 {
157 if ( disappearObject != m_disappearEffectObjects.getLast() )
158 {
159 next = false;
160 }
161 m_disappearEffectObjects.remove();
162 }
163
164 if ( next )
165 disappearObject = m_disappearEffectObjects.next();
166 else
167 disappearObject = m_disappearEffectObjects.current();
168 }
169 }
170
171 ++m_effectStep;
172 TQRect *r;
173#if 0 // used for debugging effects
174 TQPtrListIterator<TQRect> it_debug(m_repaintRects);
175 while( ( r = it_debug.current() ) != 0 )
176 {
177 ++it_debug;
178 TQPainter p( &m_paint );
179 TQPen pen = TQPen( TQt::red, 1, TQt::DashLine );
180 p.setPen( pen );
181 p.drawRect( *r );
182 }
183
184 TQPtrListIterator<TQRect> it_debug2(m_lastRepaintRects);
185 while( ( r = it_debug2.current() ) != 0 )
186 {
187 ++it_debug2;
188 TQPainter p( &m_paint );
189 TQPen pen = TQPen( TQt::green, 1, TQt::DashLine );
190 p.setPen( pen );
191 p.drawRect( *r );
192 }
193 sleep( 1 );
194#endif
195
196 TQPtrListIterator<TQRect> it_r(m_repaintRects);
197#if 1
198 while( ( r = it_r.current() ) != 0 )
199 {
200 ++it_r;
201 //bitBlt( m_dst, r->x(), r->y(), &m_paint, r->x(), r->y(), r->width(), r->height() );
202 bitBlt( m_dst, r->x() - 5, r->y() - 5, &m_paint, r->x() - 5, r->y() - 5, r->width() + 10, r->height() + 10 );
203 }
204 TQPtrListIterator<TQRect> it2(m_lastRepaintRects);
205 while( ( r = it2.current() ) != 0 )
206 {
207 ++it2;
208 //bitBlt( m_dst, r->x(), r->y(), &m_paint, r->x(), r->y(), r->width(), r->height() );
209 bitBlt( m_dst, r->x() - 5, r->y() - 5, &m_paint, r->x() - 5, r->y() - 5, r->width() + 10, r->height() + 10 );
210 }
211#else
212 bitBlt( m_dst, 0, 0, &m_paint);
213#endif
214
215 m_lastRepaintRects = m_repaintRects;
216 TQPtrListIterator<TQRect> it3(m_removeRects);
217 while( ( r = it3.current() ) != 0 )
218 {
219 ++it3;
220 m_lastRepaintRects.remove( r );
221 }
222
223 m_repaintRects.clear();
224
225 m_paint = *m_src;
226
227 }
228 bool retval = ( m_appearEffectObjects.isEmpty() && m_disappearEffectObjects.isEmpty() );
229
230 if ( retval && !m_view->kPresenterDoc()->spManualSwitch() )
231 {
232 m_view->setAutoPresTimer( m_objectTimer );
233 }
234 return retval;
235}
236
237
238void KPrEffectHandler::finish()
239{
240 KPrObject *appearObject = m_appearEffectObjects.first();
241 KPrObject *disappearObject = m_disappearEffectObjects.first();
242 TQPtrListIterator<KPrObject> it( m_objects );
243 KPrObject *object;
244
245 while ( ( object = it.current() ) != 0 )
246 {
247 ++it;
248 if ( object == appearObject )
249 {
250 bool next = true;
251
252 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
253 m_repaintRects.append( new TQRect( objectRect ) );
254
255 if ( appearObject != m_appearEffectObjects.getLast() )
256 {
257 next = false;
258 }
259 m_appearEffectObjects.remove();
260
261 // add object to src
262 drawObject( object, 0, 0, m_src );
263
264 if ( next )
265 appearObject = m_appearEffectObjects.next();
266 else
267 appearObject = m_appearEffectObjects.current();
268 }
269 else if ( object == disappearObject )
270 {
271 bool next = true;
272
273 if ( disappearObject != m_disappearEffectObjects.getLast() )
274 {
275 next = false;
276 }
277 m_disappearEffectObjects.remove();
278
279 if ( next )
280 disappearObject = m_disappearEffectObjects.next();
281 else
282 disappearObject = m_disappearEffectObjects.current();
283 }
284 }
285 bitBlt( m_dst, 0, 0, m_src );
286
287 if ( !m_view->kPresenterDoc()->spManualSwitch() && m_objectTimer > 0 )
288 {
289 m_view->setAutoPresTimer( m_objectTimer );
290 }
291}
292
293
294bool KPrEffectHandler::doAppearEffectStep( KPrObject *object )
295{
296 bool positionReached = true;
297
298 switch( object->getEffect() )
299 {
300 case EF_NONE:
301 positionReached = appearNone( object );
302 break;
303 case EF_COME_LEFT:
304 positionReached = appearComeLeft( object );
305 break;
306 case EF_COME_TOP:
307 positionReached = appearComeTop( object );
308 break;
309 case EF_COME_RIGHT:
310 positionReached = appearComeRight( object );
311 break;
312 case EF_COME_BOTTOM:
313 positionReached = appearComeBottom( object );
314 break;
315 case EF_COME_LEFT_TOP:
316 positionReached = appearComeLeftTop( object );
317 break;
318 case EF_COME_LEFT_BOTTOM:
319 positionReached = appearComeLeftBottom( object );
320 break;
321 case EF_COME_RIGHT_TOP:
322 positionReached = appearComeRightTop( object );
323 break;
324 case EF_COME_RIGHT_BOTTOM:
325 positionReached = appearComeRightBottom( object );
326 break;
327 case EF_WIPE_LEFT:
328 positionReached = appearWipeLeft( object );
329 break;
330 case EF_WIPE_RIGHT:
331 positionReached = appearWipeRight( object );
332 break;
333 case EF_WIPE_TOP:
334 positionReached = appearWipeTop( object );
335 break;
336 case EF_WIPE_BOTTOM:
337 positionReached = appearWipeBottom( object );
338 break;
339 default:
340 break;
341 }
342 return positionReached;
343}
344
345
346bool KPrEffectHandler::doDisappearEffectStep( KPrObject *object )
347{
348 bool positionReached = true;
349
350 switch( object->getEffect3() )
351 {
352 case EF3_NONE:
353 break;
354 case EF3_GO_LEFT:
355 positionReached = disappearGoLeft( object );
356 break;
357 case EF3_GO_TOP:
358 positionReached = disappearGoTop( object );
359 break;
360 case EF3_GO_RIGHT:
361 positionReached = disappearGoRight( object );
362 break;
363 case EF3_GO_BOTTOM:
364 positionReached = disappearGoBottom( object );
365 break;
366 case EF3_GO_LEFT_TOP:
367 positionReached = disappearGoLeftTop( object );
368 break;
369 case EF3_GO_LEFT_BOTTOM:
370 positionReached = disappearGoLeftBottom( object );
371 break;
372 case EF3_GO_RIGHT_TOP:
373 positionReached = disappearGoRightTop( object );
374 break;
375 case EF3_GO_RIGHT_BOTTOM:
376 positionReached = disappearGoRightBottom( object );
377 break;
378 case EF3_WIPE_LEFT:
379 positionReached = disappearWipeLeft( object );
380 break;
381 case EF3_WIPE_RIGHT:
382 positionReached = disappearWipeRight( object );
383 break;
384 case EF3_WIPE_TOP:
385 positionReached = disappearWipeTop( object );
386 break;
387 case EF3_WIPE_BOTTOM:
388 positionReached = disappearWipeBottom( object );
389 break;
390 default:
391 break;
392 }
393 return positionReached;
394}
395
396bool KPrEffectHandler::appearNone( KPrObject *object )
397{
398 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
399 m_repaintRects.append( new TQRect( objectRect ) );
400 drawObject( object, 0, 0, &m_paint );
401 return true;
402}
403
404
405bool KPrEffectHandler::appearComeLeft( KPrObject *object )
406{
407 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
408 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
409 int ox = objectRect.x();
410 int xdiff = repaintRect.x() - ox;
411
412 bool positionReached = false;
413 int x = m_effectStep * m_stepWidth - objectRect.width();
414 if ( x >= ox )
415 {
416 x = ox;
417 positionReached = true;
418 }
419 repaintRect.moveLeft( x + xdiff );
420 m_repaintRects.append( new TQRect( repaintRect ) );
421
422 //kdDebug(33001) << "KPrEffectHandler appearComeLeft x = " << x << " " << positionReached << endl;
423 drawObject( object, x - ox, 0, &m_paint );
424
425 return positionReached;
426}
427
428
429bool KPrEffectHandler::appearComeTop( KPrObject *object )
430{
431 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
432 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
433 int oy = objectRect.y();
434 int ydiff = repaintRect.y() - oy;
435
436 bool positionReached = false;
437 int y = m_effectStep * m_stepHeight - objectRect.height();
438 if ( y >= oy )
439 {
440 y = oy;
441 positionReached = true;
442 }
443 repaintRect.moveTop( y + ydiff );
444 m_repaintRects.append( new TQRect( repaintRect ) );
445
446 //kdDebug(33001) << "KPrEffectHandler appearComeTop y = " << y << " " << positionReached << endl;
447 drawObject( object, 0, y - oy, &m_paint );
448
449 return positionReached;
450}
451
452
453bool KPrEffectHandler::appearComeRight( KPrObject *object )
454{
455 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
456 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
457 int ox = objectRect.x();
458 int xdiff = repaintRect.x() - ox;
459
460 bool positionReached = false;
461 int x = m_src->width() - m_effectStep * m_stepWidth;
462 if ( x <= ox )
463 {
464 x = ox;
465 positionReached = true;
466 }
467 repaintRect.moveLeft( x + xdiff );
468 m_repaintRects.append( new TQRect( repaintRect ) );
469
470 //kdDebug(33001) << "KPrEffectHandler appearComeRight x = " << x << " " << positionReached << endl;
471 drawObject( object, x - ox, 0, &m_paint );
472
473 return positionReached;
474}
475
476
477bool KPrEffectHandler::appearComeBottom( KPrObject *object )
478{
479 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
480 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
481 int oy = objectRect.y();
482 int ydiff = repaintRect.y() - oy;
483
484 bool positionReached = false;
485 int y = m_src->height() - m_effectStep * m_stepHeight;
486 if ( y <= oy )
487 {
488 y = oy;
489 positionReached = true;
490 }
491 repaintRect.moveTop( y + ydiff );
492 m_repaintRects.append( new TQRect( repaintRect ) );
493
494 //kdDebug(33001) << "KPrEffectHandler appearComeBottom y = " << y << " " << positionReached << endl;
495 drawObject( object, 0, y - oy, &m_paint );
496
497 return positionReached;
498}
499
500
501bool KPrEffectHandler::appearComeLeftTop( KPrObject *object )
502{
503 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
504 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
505 int ox = objectRect.x();
506 int oy = objectRect.y();
507 int xdiff = repaintRect.x() - ox;
508 int ydiff = repaintRect.y() - oy;
509
510 bool positionReached = false;
511 int x = m_effectStep * m_stepWidth - objectRect.width();
512 int y = m_effectStep * m_stepHeight - objectRect.height();
513
514 if ( x >= ox )
515 x = ox;
516
517 if ( y >= oy )
518 y = oy;
519
520 if ( x == ox && y == oy )
521 positionReached = true;
522
523 repaintRect.moveLeft( x + xdiff );
524 repaintRect.moveTop( y + ydiff );
525 m_repaintRects.append( new TQRect( repaintRect ) );
526
527 //kdDebug(33001) << "KPrEffectHandler appearComeLeftTop x = " << x << ",y = " << y << " " << positionReached << endl;
528 drawObject( object, x - ox, y - oy, &m_paint );
529
530 return positionReached;
531}
532
533
534bool KPrEffectHandler::appearComeLeftBottom( KPrObject *object )
535{
536 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
537 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
538 int ox = objectRect.x();
539 int oy = objectRect.y();
540 int xdiff = repaintRect.x() - ox;
541 int ydiff = repaintRect.y() - oy;
542
543 bool positionReached = false;
544 int x = m_effectStep * m_stepWidth - objectRect.width();
545 int y = m_src->height() - m_effectStep * m_stepHeight;
546
547 if ( x >= ox )
548 x = ox;
549
550 if ( y <= oy )
551 y = oy;
552
553 if ( x == ox && y == oy )
554 positionReached = true;
555
556 repaintRect.moveLeft( x + xdiff );
557 repaintRect.moveTop( y + ydiff );
558 m_repaintRects.append( new TQRect( repaintRect ) );
559
560 //kdDebug(33001) << "KPrEffectHandler appearComeLeftBottom x = " << x << ",y = " << y << " " << positionReached << endl;
561 drawObject( object, x - ox, y - oy, &m_paint );
562
563 return positionReached;
564}
565
566
567bool KPrEffectHandler::appearComeRightTop( KPrObject *object )
568{
569 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
570 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
571 int ox = objectRect.x();
572 int oy = objectRect.y();
573 int xdiff = repaintRect.x() - ox;
574 int ydiff = repaintRect.y() - oy;
575
576 bool positionReached = false;
577 int x = m_src->width() - m_effectStep * m_stepWidth;
578 int y = m_effectStep * m_stepHeight - objectRect.height();
579
580 if ( x <= ox )
581 x = ox;
582
583 if ( y >= oy )
584 y = oy;
585
586 if ( x == ox && y == oy )
587 positionReached = true;
588
589 repaintRect.moveLeft( x + xdiff );
590 repaintRect.moveTop( y + ydiff );
591 m_repaintRects.append( new TQRect( repaintRect ) );
592
593 //kdDebug(33001) << "KPrEffectHandler appearComeRightTop x = " << x << ",y = " << y << " " << positionReached << endl;
594 drawObject( object, x - ox, y - oy, &m_paint );
595
596 return positionReached;
597}
598
599
600bool KPrEffectHandler::appearComeRightBottom( KPrObject *object )
601{
602 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
603 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
604 int ox = objectRect.x();
605 int oy = objectRect.y();
606 int xdiff = repaintRect.x() - ox;
607 int ydiff = repaintRect.y() - oy;
608
609 bool positionReached = false;
610 int x = m_src->width() - m_effectStep * m_stepWidth;
611 int y = m_src->height() - m_effectStep * m_stepHeight;
612
613 if ( x <= ox )
614 x = ox;
615
616 if ( y <= oy )
617 y = oy;
618
619 if ( x == ox && y == oy )
620 positionReached = true;
621
622 repaintRect.moveLeft( x + xdiff );
623 repaintRect.moveTop( y + ydiff );
624 m_repaintRects.append( new TQRect( repaintRect ) );
625
626 //kdDebug(33001) << "KPrEffectHandler appearComeRightBottom x = " << x << ",y = " << y << " " << positionReached << endl;
627 drawObject( object, x - ox, y - oy, &m_paint );
628
629 return positionReached;
630}
631
632
633bool KPrEffectHandler::appearWipeLeft( KPrObject *object )
634{
635 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
636 int ow = repaintRect.width();
637
638 bool positionReached = false;
639 int w = m_effectStep * m_stepWidth;
640 if ( w >= ow )
641 {
642 w = ow;
643 positionReached = true;
644 }
645
646 repaintRect.setWidth( w );
647 m_repaintRects.append( new TQRect( repaintRect ) );
648 drawObject( object, 0, 0, &m_paint, &repaintRect );
649 //kdDebug(33001) << "KPrEffectHandler appearWipeLeft w = " << w << positionReached << endl;
650 return positionReached;
651}
652
653bool KPrEffectHandler::appearWipeRight( KPrObject *object )
654{
655 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
656 int ow = repaintRect.width();
657
658 bool positionReached = false;
659 int w = m_effectStep * m_stepWidth;
660 if ( w >= ow )
661 {
662 w = ow;
663 positionReached = true;
664 }
665
666 repaintRect.setLeft( repaintRect.right() - w );
667 m_repaintRects.append( new TQRect( repaintRect ) );
668 drawObject( object, 0, 0, &m_paint, &repaintRect );
669 //kdDebug(33001) << "KPrEffectHandler appearWipeLeft w = " << w << positionReached << endl;
670 return positionReached;
671}
672
673
674bool KPrEffectHandler::appearWipeTop( KPrObject *object )
675{
676 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
677 int oh = repaintRect.height();
678
679 bool positionReached = false;
680 int h = m_effectStep * m_stepHeight;
681 if ( h >= oh )
682 {
683 h = oh;
684 positionReached = true;
685 }
686
687 repaintRect.setHeight( h );
688 m_repaintRects.append( new TQRect( repaintRect ) );
689 drawObject( object, 0, 0, &m_paint, &repaintRect );
690 //kdDebug(33001) << "KPrEffectHandler appearWipeLeft h = " << h << positionReached << endl;
691 return positionReached;
692}
693
694
695bool KPrEffectHandler::appearWipeBottom( KPrObject *object )
696{
697 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
698 int oh = repaintRect.height();
699
700 bool positionReached = false;
701 int h = m_effectStep * m_stepHeight;
702 if ( h >= oh )
703 {
704 h = oh;
705 positionReached = true;
706 }
707
708 repaintRect.setTop( repaintRect.bottom() - h );
709 m_repaintRects.append( new TQRect( repaintRect ) );
710 drawObject( object, 0, 0, &m_paint, &repaintRect );
711 //kdDebug(33001) << "KPrEffectHandler appearWipeLeft h = " << h << positionReached << endl;
712 return positionReached;
713}
714
715
716bool KPrEffectHandler::disappearGoLeft( KPrObject *object )
717{
718 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
719 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
720 int ox = objectRect.x();
721
722 bool positionReached = false;
723 int x = m_effectStep * m_stepWidth;
724 if ( ox - x <= -objectRect.width() )
725 {
726 positionReached = true;
727 }
728 else
729 {
730 repaintRect.moveBy( -x, 0 );
731 m_repaintRects.append( new TQRect( repaintRect ) );
732 //kdDebug(33001) << "KPrEffectHandler disappearGoLeft x = " << -x + ox << " " << positionReached << endl;
733 drawObject( object, -x, 0, &m_paint );
734 }
735
736 return positionReached;
737}
738
739
740bool KPrEffectHandler::disappearGoTop( KPrObject *object )
741{
742 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
743 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
744 int oy = objectRect.y();
745
746 bool positionReached = false;
747 int y = m_effectStep * m_stepHeight;
748 if ( oy - y <= -objectRect.height() )
749 {
750 positionReached = true;
751 }
752 else
753 {
754 repaintRect.moveBy( 0, -y );
755 m_repaintRects.append( new TQRect( repaintRect ) );
756 //kdDebug(33001) << "KPrEffectHandler disappearGoTop y = " << -y + oy << " " << positionReached << endl;
757 drawObject( object, 0, -y, &m_paint );
758 }
759
760 return positionReached;
761}
762
763
764bool KPrEffectHandler::disappearGoRight( KPrObject *object )
765{
766 int ox = m_view->zoomHandler()->zoomItX( object->getRealRect().x() );
767 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
768
769 bool positionReached = false;
770 int x = m_effectStep * m_stepWidth;
771 if ( x + ox >= m_src->width() )
772 {
773 positionReached = true;
774 }
775 else
776 {
777 repaintRect.moveBy( x, 0 );
778 m_repaintRects.append( new TQRect( repaintRect ) );
779 //kdDebug(33001) << "KPrEffectHandler disappearGoRight x = " << x + ox << " " << positionReached << endl;
780 drawObject( object, x, 0, &m_paint );
781 }
782
783 return positionReached;
784}
785
786
787bool KPrEffectHandler::disappearGoBottom( KPrObject *object )
788{
789 int oy = m_view->zoomHandler()->zoomItY( object->getRealRect().y() );
790 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
791
792 bool positionReached = false;
793 int y = m_effectStep * m_stepHeight;
794 if ( oy + y >= m_src->height() )
795 {
796 positionReached = true;
797 }
798 else
799 {
800 repaintRect.moveBy( 0, y );
801 m_repaintRects.append( new TQRect( repaintRect ) );
802 //kdDebug(33001) << "KPrEffectHandler disappearGoBottom y = " << y + oy << " " << positionReached << endl;
803 drawObject( object, 0, y, &m_paint );
804 }
805
806 return positionReached;
807}
808
809
810bool KPrEffectHandler::disappearGoLeftTop( KPrObject *object )
811{
812 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
813 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
814 int ox = objectRect.x();
815 int oy = objectRect.y();
816
817 bool positionReached = false;
818 int x = m_effectStep * m_stepWidth;
819 int y = m_effectStep * m_stepHeight;
820 if ( ox - x <= -objectRect.width() || oy - y <= -objectRect.height() )
821 {
822 positionReached = true;
823 }
824 else
825 {
826 repaintRect.moveBy( -x, -y );
827 m_repaintRects.append( new TQRect( repaintRect ) );
828 //kdDebug(33001) << "KPrEffectHandler disappearGoLeftTop x = " << -x + ox << ", y = " << -y + oy << positionReached << endl;
829 drawObject( object, -x, -y, &m_paint );
830 }
831
832 return positionReached;
833}
834
835
836bool KPrEffectHandler::disappearGoLeftBottom( KPrObject *object )
837{
838 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
839 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
840 int ox = objectRect.x();
841 int oy = objectRect.y();
842
843 bool positionReached = false;
844 int x = m_effectStep * m_stepWidth;
845 int y = m_effectStep * m_stepHeight;
846 if ( ox - x <= -objectRect.width() || oy + y >= m_src->height() )
847 {
848 positionReached = true;
849 }
850 else
851 {
852 repaintRect.moveBy( -x, y );
853 m_repaintRects.append( new TQRect( repaintRect ) );
854 //kdDebug(33001) << "KPrEffectHandler disappearGoLeftTop x = " << -x + ox << ", y = " << y + oy << positionReached << endl;
855 drawObject( object, -x, y, &m_paint );
856 }
857
858 return positionReached;
859}
860
861
862bool KPrEffectHandler::disappearGoRightTop( KPrObject *object )
863{
864 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
865 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
866 int ox = objectRect.x();
867 int oy = objectRect.y();
868
869 bool positionReached = false;
870 int x = m_effectStep * m_stepWidth;
871 int y = m_effectStep * m_stepHeight;
872 if ( ox + x >= m_src->width() || oy - y <= -objectRect.height() )
873 {
874 positionReached = true;
875 }
876 else
877 {
878 repaintRect.moveBy( x, -y );
879 m_repaintRects.append( new TQRect( repaintRect ) );
880 //kdDebug(33001) << "KPrEffectHandler disappearGoLeftTop x = " << x + ox << ", y = " << -y + oy << positionReached << endl;
881 drawObject( object, x, -y, &m_paint );
882 }
883
884 return positionReached;
885}
886
887
888bool KPrEffectHandler::disappearGoRightBottom( KPrObject *object )
889{
890 TQRect objectRect = m_view->zoomHandler()->zoomRect( object->getRealRect() );
891 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
892 int ox = objectRect.x();
893 int oy = objectRect.y();
894
895 bool positionReached = false;
896 int x = m_effectStep * m_stepWidth;
897 int y = m_effectStep * m_stepHeight;
898 if ( ox + x >= m_src->width() || oy + y >= m_src->height() )
899 {
900 positionReached = true;
901 }
902 else
903 {
904 repaintRect.moveBy( x, y );
905 m_repaintRects.append( new TQRect( repaintRect ) );
906 //kdDebug(33001) << "KPrEffectHandler disappearGoLeftTop x = " << x + ox << ", y = " << y + oy << positionReached << endl;
907 drawObject( object, x, y, &m_paint );
908 }
909
910 return positionReached;
911}
912
913
914bool KPrEffectHandler::disappearWipeLeft( KPrObject *object )
915{
916 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
917 int ow = repaintRect.width();
918
919 bool positionReached = false;
920 int w = ow - m_effectStep * m_stepWidth;
921 if ( w <= 0 )
922 {
923 positionReached = true;
924 }
925 else
926 {
927 repaintRect.setWidth( w );
928 m_repaintRects.append( new TQRect( repaintRect ) );
929 drawObject( object, 0, 0, &m_paint, &repaintRect );
930 //kdDebug(33001) << "KPrEffectHandler appearWipeLeft w = " << w << positionReached << endl;
931 }
932 return positionReached;
933}
934
935
936bool KPrEffectHandler::disappearWipeRight( KPrObject *object )
937{
938 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
939 int ow = repaintRect.width();
940
941 bool positionReached = false;
942 int w = ow - m_effectStep * m_stepWidth;
943 if ( w <= 0 )
944 {
945 positionReached = true;
946 }
947 else
948 {
949 repaintRect.setLeft( repaintRect.right() - w );
950 m_repaintRects.append( new TQRect( repaintRect ) );
951 drawObject( object, 0, 0, &m_paint, &repaintRect );
952 //kdDebug(33001) << "KPrEffectHandler appearWipeLeft w = " << w << positionReached << endl;
953 }
954 return positionReached;
955}
956
957
958bool KPrEffectHandler::disappearWipeTop( KPrObject *object )
959{
960 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
961 int oh = repaintRect.height();
962
963 bool positionReached = false;
964 int h = oh - m_effectStep * m_stepHeight;
965 if ( h <= 0 )
966 {
967 positionReached = true;
968 }
969 else
970 {
971 repaintRect.setHeight( h );
972 m_repaintRects.append( new TQRect( repaintRect ) );
973 drawObject( object, 0, 0, &m_paint, &repaintRect );
974 //kdDebug(33001) << "KPrEffectHandler appearWipeLeft h = " << h << positionReached << endl;
975 }
976 return positionReached;
977}
978
979
980bool KPrEffectHandler::disappearWipeBottom( KPrObject *object )
981{
982 TQRect repaintRect = m_view->zoomHandler()->zoomRect( object->getRepaintRect() );
983 int oh = repaintRect.height();
984
985 bool positionReached = false;
986 int h = oh - m_effectStep * m_stepHeight;
987 if ( h <= 0 )
988 {
989 positionReached = true;
990 }
991 else
992 {
993 repaintRect.setTop( repaintRect.bottom() - h );
994 m_repaintRects.append( new TQRect( repaintRect ) );
995 drawObject( object, 0, 0, &m_paint, &repaintRect );
996 //kdDebug(33001) << "KPrEffectHandler appearWipeLeft h = " << h << positionReached << endl;
997 }
998 return positionReached;
999}
1000
1001
1002void KPrEffectHandler::drawObject( KPrObject *object, int x, int y, TQPixmap *screen, TQRect *clipRect )
1003{
1004 TQPainter p;
1005 p.begin( screen );
1006 if ( clipRect )
1007 {
1008 p.setClipRect( *clipRect, TQPainter::CoordPainter );
1009 }
1010
1011 p.translate( x, y );
1012
1013 if ( object->getAppearStep() == m_step.m_step && ! m_back )
1014 {
1015 object->setSubPresStep( m_step.m_subStep );
1016 object->doSpecificEffects( true );
1017 }
1018
1019 object->draw( &p, m_view->zoomHandler(), m_step.m_pageNumber, SM_NONE, false );
1020
1021 if ( object->getAppearStep() == m_step.m_step && ! m_back )
1022 {
1023 object->setSubPresStep( 0 );
1024 object->doSpecificEffects( false );
1025 }
1026
1027 p.translate( -x, -y );
1028
1029 // redraw objects which lie above the currenty drawn
1030 m_objects.findRef( object );
1031 KPrObject *obj;
1032 while ( ( obj = m_objects.next() ) != 0 )
1033 {
1034 if ( ( obj->getAppearStep() < m_step.m_step
1035 || obj->getAppearStep() == m_step.m_step && !m_appearEffectObjects.containsRef( obj ) )
1036 && ( ( obj->getDisappear() && obj->getDisappearStep() > m_step.m_step ) || ! obj->getDisappear() )
1037 && m_view->zoomHandler()->zoomRect( obj->getRealRect()).intersects(*m_repaintRects.getLast()) )
1038 {
1039 if ( obj->getAppearStep() == m_step.m_step && ! m_back )
1040 {
1041 obj->setSubPresStep( m_step.m_subStep );
1042 obj->doSpecificEffects( true );
1043 }
1044 obj->draw( &p, m_view->zoomHandler(), m_step.m_pageNumber, SM_NONE, false );
1045 if ( obj->getAppearStep() == m_step.m_step && ! m_back )
1046 {
1047 obj->setSubPresStep( 0 );
1048 obj->doSpecificEffects( false );
1049 }
1050 }
1051 }
1052
1053 p.end();
1054}
Class for keeping a presentation step m_pageNumber the current page number 0 based m_step the current...
Definition presstep.h:32