23#include "KPrPageEffects.h"
29#include <tdeapplication.h>
31#include <krandomsequence.h>
34KPrPageEffects::KPrPageEffects( TQPaintDevice *dst,
const TQPixmap &pageTo, PageEffect effect, EffectSpeed speed )
35: m_dst( dst ), m_pageTo( pageTo ), m_pageFrom(m_pageTo.width(),m_pageTo.height()), m_effect(effect), m_speed(speed), m_effectStep(0)
36, m_width(m_pageTo.width()), m_height(m_pageTo.height()), m_finished(false)
38 if ( m_effect == PEF_RANDOM )
40 KRandomSequence random;
41 m_randomEffect =
static_cast<PageEffect
>( random.getLong( PEF_LAST_MARKER ) );
43 int div[] = { 100, 65, 30 };
45 m_stepWidth = (int) ( m_width / div[m_speed] );
46 m_stepHeight = (int) ( m_height / div[m_speed] );
50KPrPageEffects::~KPrPageEffects()
55bool KPrPageEffects::doEffect()
59 PageEffect effect = m_effect == PEF_RANDOM ? m_randomEffect : m_effect;
63 m_finished = effectNone();
66 m_finished = effectCloseHorizontal();
69 m_finished = effectCloseVertical();
72 m_finished = effectCloseFromAllDirections();
75 m_finished = effectOpenHorizontal();
78 m_finished = effectOpenVertical();
81 m_finished = effectOpenFromAllDirections();
83 case PEF_INTERLOCKING_HORZ_1:
84 m_finished = effectInterlockingHorizontal1();
86 case PEF_INTERLOCKING_HORZ_2:
87 m_finished = effectInterlockingHorizontal2();
89 case PEF_INTERLOCKING_VERT_1:
90 m_finished = effectInterlockingVertical1();
92 case PEF_INTERLOCKING_VERT_2:
93 m_finished = effectInterlockingVertical2();
96 m_finished = effectSurround1();
99 m_finished = effectFlyAway1();
102 m_finished = effectBlindsHorizontal();
105 m_finished = effectBlindsVertical();
108 m_finished = effectBoxIn();
111 m_finished = effectBoxOut();
113 case PEF_CHECKBOARD_ACROSS:
114 m_finished = effectCheckboardAcross();
116 case PEF_CHECKBOARD_DOWN:
117 m_finished = effectCheckboardDown();
120 m_finished = effectCoverDown();
122 case PEF_UNCOVER_DOWN:
123 m_finished = effectUncoverDown();
126 m_finished = effectCoverUp();
129 m_finished = effectUncoverUp();
132 m_finished = effectCoverLeft();
134 case PEF_UNCOVER_LEFT:
135 m_finished = effectUncoverLeft();
137 case PEF_COVER_RIGHT:
138 m_finished = effectCoverRight();
140 case PEF_UNCOVER_RIGHT:
141 m_finished = effectUncoverRight();
143 case PEF_COVER_LEFT_UP:
144 m_finished = effectCoverLeftUp();
146 case PEF_UNCOVER_LEFT_UP:
147 m_finished = effectUncoverLeftUp();
149 case PEF_COVER_LEFT_DOWN:
150 m_finished = effectCoverLeftDown();
152 case PEF_UNCOVER_LEFT_DOWN:
153 m_finished = effectUncoverLeftDown();
155 case PEF_COVER_RIGHT_UP:
156 m_finished = effectCoverRightUp();
158 case PEF_UNCOVER_RIGHT_UP:
159 m_finished = effectUncoverRightUp();
161 case PEF_COVER_RIGHT_DOWN:
162 m_finished = effectCoverRightDown();
164 case PEF_UNCOVER_RIGHT_DOWN:
165 m_finished = effectUncoverRightDown();
168 m_finished = effectDissolve();
170 case PEF_STRIPS_LEFT_UP:
171 m_finished = effectStripesLeftUp();
173 case PEF_STRIPS_LEFT_DOWN:
174 m_finished = effectStripesLeftDown();
176 case PEF_STRIPS_RIGHT_UP:
177 m_finished = effectStripesRightUp();
179 case PEF_STRIPS_RIGHT_DOWN:
180 m_finished = effectStripesRigthDown();
183 m_finished = effectMelting();
186 m_finished = effectCloseHorizontal();
195void KPrPageEffects::finish()
199 bitBlt( m_dst, 0, 0, &m_pageTo );
205bool KPrPageEffects::effectNone()
const
207 bitBlt( m_dst, 0, 0, &m_pageTo );
212bool KPrPageEffects::effectCloseHorizontal()
const
214 int h = m_effectStep * m_stepHeight;
216 bool finished =
false;
217 if ( h >= m_height / 2 )
223 bitBlt( m_dst, 0, 0, &m_pageTo, 0, m_height / 2 - h, m_width, h );
224 bitBlt( m_dst, 0, m_height - h, &m_pageTo, 0, m_height / 2, m_width, h );
230bool KPrPageEffects::effectCloseVertical()
const
232 int w = m_effectStep * m_stepWidth;
234 bool finished =
false;
235 if ( w >= m_width / 2 )
241 bitBlt( m_dst, 0, 0, &m_pageTo, m_width / 2 - w, 0, w, m_height );
242 bitBlt( m_dst, m_width - w, 0, &m_pageTo, m_width / 2, 0, w, m_height );
248bool KPrPageEffects::effectCloseFromAllDirections()
const
250 double fact = (double) m_height / (
double) m_width;
251 int h = (int)( m_effectStep * m_stepWidth * fact );
252 int w = m_effectStep * m_stepWidth;
254 bool finished =
false;
255 if ( h >= m_height / 2 )
259 if ( w >= m_width / 2 )
263 if ( h >= m_height / 2 && w >= m_width / 2 )
268 bitBlt( m_dst, 0, 0, &m_pageTo, m_width / 2 - w, m_height / 2 - h, w, h );
269 bitBlt( m_dst, m_width - w, 0, &m_pageTo, m_width / 2, m_height / 2 - h, w, h );
270 bitBlt( m_dst, 0, m_height - h, &m_pageTo, m_width / 2 - w, m_height / 2, w, h );
271 bitBlt( m_dst, m_width - w, m_height - h, &m_pageTo, m_width / 2, m_height / 2, w, h );
277bool KPrPageEffects::effectOpenHorizontal()
const
279 int h = m_effectStep * m_stepHeight;
281 bool finished =
false;
282 if ( h >= m_height / 2 )
288 bitBlt( m_dst, 0, m_height / 2 - h, &m_pageTo, 0, 0, m_width, h );
289 bitBlt( m_dst, 0, m_height / 2, &m_pageTo, 0, m_height - h, m_width, h );
295bool KPrPageEffects::effectOpenVertical()
const
297 int w = m_effectStep * m_stepWidth;
299 bool finished =
false;
300 if ( w >= m_width / 2 )
306 bitBlt( m_dst, m_width / 2 - w, 0, &m_pageTo, 0, 0, w, m_height );
307 bitBlt( m_dst, m_width / 2, 0, &m_pageTo, m_width - w, 0, w, m_height );
313bool KPrPageEffects::effectOpenFromAllDirections()
const
315 double fact = (double) m_height / (
double) m_width;
316 int h = (int)( m_effectStep * m_stepWidth * fact );
317 int w = m_effectStep * m_stepWidth;
319 bool finished =
false;
320 if ( h >= m_height / 2 )
324 if ( w >= m_width / 2 )
328 if ( h >= m_height / 2 && w >= m_width / 2 )
333 bitBlt( m_dst, m_width / 2 - w, m_height / 2 - h, &m_pageTo, 0, 0, w, h );
334 bitBlt( m_dst, m_width / 2, m_height / 2 - h, &m_pageTo, m_width - w, 0, w, h );
335 bitBlt( m_dst, m_width / 2 - w, m_height / 2, &m_pageTo, 0, m_height - h, w, h );
336 bitBlt( m_dst, m_width / 2, m_height / 2, &m_pageTo, m_width - w, m_height - h, w, h );
342bool KPrPageEffects::effectInterlockingHorizontal1()
const
344 int w = m_effectStep * m_stepWidth;
346 bool finished =
false;
353 int h = m_height / 4;
355 bitBlt( m_dst, w, 0, &m_pageTo, w, 0, m_stepWidth, h );
356 bitBlt( m_dst, m_width - w - m_stepWidth, h, &m_pageTo, m_width - w - m_stepWidth, h, m_stepWidth, h );
357 bitBlt( m_dst, w, 2 * h, &m_pageTo, w, 2 * h, m_stepWidth, h );
358 bitBlt( m_dst, m_width - w - m_stepWidth, 3 * h, &m_pageTo, m_width - w - m_stepWidth, 3 * h, m_stepWidth, m_height - 3 * h );
364bool KPrPageEffects::effectInterlockingHorizontal2()
const
366 int w = m_effectStep * m_stepWidth;
368 bool finished =
false;
375 int h = m_height / 4;
377 bitBlt( m_dst, m_width - w - m_stepWidth, 0, &m_pageTo, m_width - w - m_stepWidth, 0, m_stepWidth, h );
378 bitBlt( m_dst, w, h, &m_pageTo, w, h, m_stepWidth, h );
379 bitBlt( m_dst, m_width - w - m_stepWidth, 2 * h, &m_pageTo, m_width - w - m_stepWidth, 2 * h, m_stepWidth, h );
380 bitBlt( m_dst, w, 3 * h, &m_pageTo, w, 3 * h, m_stepWidth, h );
386bool KPrPageEffects::effectInterlockingVertical1()
const
388 int h = m_effectStep * m_stepHeight;
390 bool finished =
false;
399 bitBlt( m_dst, 0, h, &m_pageTo, 0, h, w, m_stepHeight );
400 bitBlt( m_dst, w, m_height - h - m_stepHeight, &m_pageTo, w, m_height - h - m_stepHeight, w, m_stepHeight );
401 bitBlt( m_dst, 2 * w, h, &m_pageTo, 2 * w, h, w, m_stepHeight );
402 bitBlt( m_dst, 3 * w, m_height - h - m_stepHeight, &m_pageTo, 3 * w, m_height - h - m_stepHeight, w, m_stepHeight );
408bool KPrPageEffects::effectInterlockingVertical2()
const
410 int h = m_effectStep * m_stepHeight;
412 bool finished =
false;
421 bitBlt( m_dst, 0, m_height - h - m_stepHeight, &m_pageTo, 0, m_height - h - m_stepHeight, w, m_stepHeight );
422 bitBlt( m_dst, w, h, &m_pageTo, w, h, w, m_stepHeight );
423 bitBlt( m_dst, 2 * w, m_height - h - m_stepHeight, &m_pageTo, 2 * w, m_height - h - m_stepHeight, w, m_stepHeight );
424 bitBlt( m_dst, 3 * w, h, &m_pageTo, 3 * w, h, w, m_stepHeight );
430bool KPrPageEffects::effectSurround1()
const
432 int div[] = { 20, 15, 10 };
433 int stepSize = m_height / div[m_speed];
434 int step = m_effectStep * stepSize;
436 int h = m_height / 10;
437 int w = m_width / 10;
441 bool finished =
false;
449 if ( step < m_height )
454 if ( step + stepSize >= m_height )
458 repaint_rh = m_height - repaint_h;
459 repaint_rw = step - m_height + repaint_w;
460 repaint_w = stepSize;
464 else if ( step < m_height + m_width - w )
467 rw = step - m_height + w;
469 if ( step + stepSize >= m_height + m_width - repaint_w )
473 repaint_rh = m_height - ( step - m_height + repaint_h - m_width + repaint_w + stepSize );
474 repaint_rw = m_width - repaint_w;
475 repaint_h = stepSize;
479 else if ( step < 2 * m_height - h + m_width - w )
481 rh = m_height - ( step - m_height + h - m_width + w + stepSize );
484 if ( step + stepSize >= 2 * m_height - repaint_h + m_width - repaint_w )
489 repaint_rw = m_width - ( step - 2 * m_height + repaint_h - m_width + 2 * repaint_w + stepSize );
490 repaint_w = stepSize;
494 else if ( step < 2 * m_height - h + 2 * m_width - 3 * w )
497 rw = m_width - ( step - 2 * m_height + h - m_width + 2 * w + stepSize );
499 if ( step + stepSize >= 2 * m_height - repaint_h + 2 * m_width - 3 * repaint_w )
503 repaint_rh = step - 2 * m_height + 2 * repaint_h - 2 * m_width + 3 * repaint_w;
504 repaint_rw = repaint_w;
505 repaint_h = stepSize;
509 else if ( step < 3 * m_height - 3 * h + 2 * m_width - 3 * w )
511 rh = step - 2 * m_height + 2 * h - 2 * m_width + 3 * w;
514 if ( step + stepSize >= 3 * m_height - 3 * repaint_h + 2 * m_width - 3 * repaint_w )
518 repaint_rh = m_height - 2 * repaint_h;
519 repaint_rw = step - 3 * m_height + 3 * repaint_h - 2 * m_width + 5 * repaint_w;
520 repaint_w = stepSize;
524 else if ( step < 3 * m_height - 3 * h + 3 * m_width - 6 * w )
526 rh = m_height - 2 * h;
527 rw = step - 3 * m_height + 3 * h - 2 * m_width + 5 * w;
529 if ( step + stepSize >= 3 * m_height - 3 * repaint_h + 3 * m_width - 6 * repaint_w )
533 repaint_rh = m_height - ( step - 3 * m_height + 5 * repaint_h - 3 * m_width + 6 * repaint_w + stepSize );
534 repaint_rw = m_width - 2 * repaint_w;
535 repaint_h = stepSize;
539 else if ( step < 4 * m_height - 6 * h + 3 * m_width - 6 * w )
541 rh = m_height - ( step - 3 * m_height + 5 * h - 3 * m_width + 6 * w + stepSize );
542 rw = m_width - 2 * w;
544 if ( step + stepSize >= 4 * m_height - 6 * repaint_h + 3 * m_width - 6 * repaint_w )
548 repaint_rh = repaint_h;
549 repaint_rw = m_width - ( step - 4 * m_height + 6 * repaint_h - 3 * m_width + 8 * repaint_w + stepSize );
550 repaint_w = stepSize;
554 else if ( step < 4 * m_height - 6 * h + 4 * m_width - 10 * w )
557 rw = m_width - ( step - 4 * m_height + 6 * h - 3 * m_width + 8 * w + stepSize );
559 if ( step + stepSize >= 4 * m_height - 6 * repaint_h + 4 * m_width - 10 * repaint_w )
563 repaint_rh = step - 4 * m_height + 8 * repaint_h - 4 * m_width + 10 * repaint_w;
564 repaint_rw = 2 * repaint_w;
565 repaint_h = stepSize;
569 else if ( step < 5 * m_height - 10 * h + 4 * m_width - 10 * w )
571 rh = step - 4 * m_height + 8 * h - 4 * m_width + 10 * w;
574 if ( step + stepSize >= 5 * m_height - 10 * repaint_h + 4 * m_width - 10 * repaint_w )
578 repaint_rh = m_height - 3 * repaint_h;
579 repaint_rw = step - 5 * m_height + 10 * repaint_h - 4 * m_width + 13 * repaint_w;
580 repaint_w = stepSize;
584 else if ( step < 5 * m_height - 10 * h + 5 * m_width - 15 * w )
586 rh = m_height - 3 * h;
587 rw = step - 5 * m_height + 10 * h - 4 * m_width + 13 * w;
589 if ( step + stepSize >= 5 * m_height - 10 * repaint_h + 5 * m_width - 15 * repaint_w )
593 repaint_rh = m_height - ( step - 5 * m_height + 13 * repaint_h - 5 * m_width + 15 * repaint_w + stepSize );
594 repaint_rw = m_width - 3 * repaint_w;
595 repaint_h = stepSize;
599 else if ( step < 6 * m_height - 15 * h + 5 * m_width - 15 * w )
601 rh = m_height - ( step - 5 * m_height + 13 * h - 5 * m_width + 15 * w + stepSize );
602 rw = m_width - 3 * w;
604 if ( step + stepSize >= 6 * m_height - 15 * repaint_h + 5 * m_width - 15 * repaint_w )
608 repaint_rh = 2 * repaint_h;
609 repaint_rw = m_width - ( step - 6 * m_height + 15 * repaint_h - 5 * m_width + 18 * repaint_w + stepSize );
610 repaint_w = stepSize;
614 else if ( step < 6 * m_height - 15 * h + 6 * m_width - 21 * w )
617 rw = m_width - ( step - 6 * m_height + 15 * h - 5 * m_width + 18 * w + stepSize );
619 if ( step + stepSize >= 6 * m_height - 15 * repaint_h + 6 * m_width - 21 * repaint_w )
623 repaint_rh = step - 6 * m_height + 18 * repaint_h - 6 * m_width + 21 * repaint_w;
624 repaint_rw = 3 * repaint_w;
625 repaint_h = stepSize;
629 else if ( step < 7 * m_height - 21 * h + 6 * m_width - 21 * w )
631 rh = step - 6 * m_height + 18 * h - 6 * m_width + 21 * w;
634 if ( step + stepSize >= 7 * m_height - 21 * repaint_h + 6 * m_width - 21 * repaint_w )
638 repaint_rh = m_height - 4 * repaint_h;
639 repaint_rw = step - 7 * m_height + 21 * repaint_h - 6 * m_width + 25 * repaint_w;
640 repaint_w = stepSize;
644 else if ( step < 7 * m_height - 21 * h + 7 * m_width - 28 * w )
646 rh = m_height - 4 * h;
647 rw = step - 7 * m_height + 21 * h - 6 * m_width + 25 * w;
649 if ( step + stepSize >= 7 * m_height - 21 * repaint_h + 7 * m_width - 28 * repaint_w )
653 repaint_rh = m_height - ( step - 7 * m_height + 25 * repaint_h - 7 * m_width + 28 * repaint_w + stepSize );
654 repaint_rw = m_width - 4 * repaint_w;
655 repaint_h = stepSize;
659 else if ( step < 8 * m_height - 28 * h + 7 * m_width - 28 * w )
661 rh = m_height - ( step - 7 * m_height + 25 * h - 7 * m_width + 28 * w + stepSize );
662 rw = m_width - 4 * w;
664 if ( step + stepSize >= 8 * m_height - 28 * repaint_h + 7 * m_width - 28 * repaint_w )
668 repaint_rh = 3 * repaint_h;
669 repaint_rw = m_width - ( step - 8 * m_height + 28 * repaint_h - 7 * m_width + 32 * repaint_w + stepSize );
670 repaint_w = stepSize;
674 else if ( step < 8 * m_height - 28 * h + 8 * m_width - 36 * w )
677 rw = m_width - ( step - 8 * m_height + 28 * h - 7 * m_width + 32 * w + stepSize );
679 if ( step + stepSize >= 8 * m_height - 28 * repaint_h + 8 * m_width - 36 * repaint_w )
683 repaint_rh = step - 8 * m_height + 32 * repaint_h - 8 * m_width + 36 * repaint_w;
684 repaint_rw = 4 * repaint_w;
685 repaint_h = stepSize;
689 else if ( step < 9 * m_height - 36 * h + 8 * m_width - 36 * w )
691 rh = step - 8 * m_height + 32 * h - 8 * m_width + 36 * w;
694 if ( step + stepSize >= 9 * m_height - 36 * repaint_h + 8 * m_width - 36 * repaint_w )
698 repaint_rh = m_height - 5 * repaint_h;
699 repaint_rw = step - 9 * m_height + 36 * repaint_h - 8 * m_width + 41 * repaint_w;
700 repaint_w = stepSize;
704 else if ( step < 9 * m_height - 36 * h + 9 * m_width - 45 * w )
706 rh = m_height - 5 * h;
707 rw = step - 9 * m_height + 36 * h - 8 * m_width + 41 * w;
709 if ( step + stepSize >= 9 * m_height - 36 * repaint_h + 9 * m_width - 45 * repaint_w )
713 repaint_rh = m_height - ( step - 9 * m_height + 41 * repaint_h - 9 * m_width + 45 * repaint_w + stepSize );
714 repaint_rw = m_width - 5 * repaint_w;
715 repaint_h = stepSize;
719 else if ( step < 10 * m_height - 45 * h + 9 * m_width - 45 * w )
721 rh = m_height - ( step - 9 * m_height + 41 * h - 9 * m_width + 45 * w + stepSize );
722 rw = m_width - 5 * w;
737 bitBlt( m_dst, rw, rh, &m_pageTo, rw, rh, w, h );
741 bitBlt( m_dst, repaint_rw, repaint_rh, &m_pageTo, repaint_rw, repaint_rh, repaint_w, repaint_h );
748bool KPrPageEffects::effectFlyAway1()
750 bool finished =
false;
751 int steps[] = { 20, 15, 10 };
752 int pSteps = steps[m_speed];
754 if ( m_effectStep == 0 )
756 bitBlt( &m_pageFrom, 0, 0, m_dst );
757 m_list.append( m_width );
758 m_list.append( m_height );
762 else if ( m_effectStep <= pSteps )
764 double dw = 1.0 - 83.0 / 100.0 * m_effectStep / (double)pSteps;
768 TQPixmap pix( m_pageFrom.xForm( m ) );
770 if ( m_effectStep == pSteps )
774 int h = pix.height();
775 int x = ( m_width - w ) / 2;
776 int y = ( m_height - h ) / 2;
778 int ow = *(m_list.at(0));
779 int oh = *(m_list.at(1));
780 int ox = *(m_list.at(2));
781 int oy = *(m_list.at(3));
783 bitBlt( m_dst, x, y, &pix, 0, 0 , w, h );
785 bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, ow, y - oy );
787 bitBlt( m_dst, ox, y, &m_pageTo, ox, y, x - ox, h );
789 bitBlt( m_dst, x + w, y, &m_pageTo, x + w, y, ( ow - w + 1 ) / 2, h );
791 bitBlt( m_dst, ox, y + h, &m_pageTo, ox, y + h, ow, ( oh - h + 1 ) / 2 );
798 else if ( m_effectStep <= 2 * pSteps )
800 int w = m_pageFrom.width();
801 int h = m_pageFrom.height();
802 int x = ( m_width - w ) / 2;
803 int y = ( m_height - h ) / 2 - ( m_height - h ) / 2 * ( m_effectStep - pSteps ) / pSteps;
805 int oy = *(m_list.at(3));
807 bitBlt( m_dst, x, y, &m_pageFrom, 0, 0 , w, h );
808 bitBlt( m_dst, x, y + h, &m_pageTo, x, y + h, w, oy - y);
812 else if ( m_effectStep <= 3 * pSteps )
814 int w = m_pageFrom.width();
815 int h = m_pageFrom.height();
816 int x = ( m_width - w ) / 2 - ( m_width - w ) / 2 * ( m_effectStep - 2 * pSteps ) / pSteps;
817 int y = ( m_height - h ) / 2 * ( m_effectStep - 2 * pSteps ) / pSteps;
819 int ox = *(m_list.at(2));
820 int oy = *(m_list.at(3));
822 bitBlt( m_dst, x, y, &m_pageFrom, 0, 0 , w, h );
823 bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, w, y - oy);
824 bitBlt( m_dst, x + w, oy, &m_pageTo, x + w, oy, x - ox, h );
831 int w = m_pageFrom.width();
832 int h = m_pageFrom.height();
833 int x = ( m_width - w ) / 2 * ( m_effectStep - 3 * pSteps ) / pSteps;
834 int y = ( m_height - h ) / 2 * ( m_effectStep - 2 * pSteps ) / pSteps;
836 int ox = *(m_list.at(2));
837 int oy = *(m_list.at(3));
839 bitBlt( m_dst, x, y, &m_pageFrom, 0, 0 , w, h );
840 bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, w, y - oy);
841 bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, x - ox, h );
858bool KPrPageEffects::effectBlindsHorizontal()
const
860 int h = m_effectStep * m_stepHeight;
861 int blockSize = m_height / 8;
863 bool finished =
false;
864 if ( h >= blockSize )
870 for (
int i=0; i < m_height; i += blockSize )
871 bitBlt( m_dst, 0, h + i, &m_pageTo, 0, h + i, m_width, m_stepHeight );
877bool KPrPageEffects::effectBlindsVertical()
const
879 int w = m_effectStep * m_stepWidth;
880 int blockSize = m_width / 8;
882 bool finished =
false;
883 if ( w >= blockSize )
889 for (
int i=0; i < m_width; i += blockSize )
890 bitBlt( m_dst, w + i, 0, &m_pageTo, w + i, 0, m_stepWidth, m_height );
896bool KPrPageEffects::effectBoxIn()
const
898 double fact = (double) m_height / (
double) m_width;
899 int h = (int)( m_effectStep * m_stepWidth * fact );
900 int stepHeight = (int)( ( m_effectStep + 1 ) * m_stepWidth * fact - h );
901 int w = m_effectStep * m_stepWidth;
903 bool finished =
false;
904 if ( h >= m_height / 2 )
908 if ( w >= m_width / 2 )
912 if ( h >= m_height / 2 && w >= m_width / 2 )
918 bitBlt( m_dst, w, h, &m_pageTo, w, h, m_width - 2 * w, stepHeight );
920 bitBlt( m_dst, w, h, &m_pageTo, w, h, m_stepWidth, m_height - 2 * h );
922 bitBlt( m_dst, m_width - w, h, &m_pageTo, m_width - w, h, m_stepWidth, m_height - 2 * h );
924 bitBlt( m_dst, w, m_height - h - stepHeight, &m_pageTo, w, m_height - h - stepHeight, m_width - 2 * w, stepHeight );
930bool KPrPageEffects::effectBoxOut()
const
932 double fact = (double) m_height / (
double) m_width;
933 int h = (int)( m_effectStep * m_stepWidth * fact );
934 int stepHeight = (int)( ( m_effectStep + 1 ) * m_stepWidth * fact - h );
935 int w = m_effectStep * m_stepWidth;
937 bool finished =
false;
938 if ( h >= m_height / 2 )
942 if ( w >= m_width / 2 )
946 if ( h >= m_height / 2 && w >= m_width / 2 )
951 bitBlt( m_dst, m_width / 2 - w - m_stepWidth, m_height / 2 - h - stepHeight,
952 &m_pageTo, m_width / 2 - w - m_stepWidth, m_height / 2 - h - stepHeight, 2 * ( w + m_stepWidth ), stepHeight );
953 bitBlt( m_dst, m_width / 2 - w - m_stepWidth, m_height / 2 - h,
954 &m_pageTo, m_width / 2 - w - m_stepWidth, m_height / 2 - h, m_stepWidth, 2 * h );
955 bitBlt( m_dst, m_width / 2 + w, m_height / 2 - h,
956 &m_pageTo, m_width / 2 + w, m_height / 2 - h, m_stepWidth, 2 * h );
957 bitBlt( m_dst, m_width / 2 - w - m_stepWidth, m_height / 2 + h,
958 &m_pageTo, m_width / 2 - w - m_stepWidth, m_height / 2 + h, 2 * ( w + m_stepWidth), stepHeight );
964bool KPrPageEffects::effectCheckboardAcross()
const
966 int w = m_effectStep * m_stepWidth;
967 int blockSize = m_height / 8;
969 bool finished =
false;
970 if ( w >= blockSize * 2 )
976 for (
int y = 0; y < m_height; y += blockSize )
978 int x = ( ( y / blockSize ) & 1 ) * blockSize;
980 if ( x == blockSize && w >= blockSize - m_stepWidth )
981 bitBlt( m_dst, w - blockSize, y, &m_pageTo, w - blockSize, y, m_stepWidth, blockSize );
983 for ( ; x < m_width; x += 2 * blockSize )
985 bitBlt( m_dst, x + w, y, &m_pageTo, x + w, y, m_stepWidth, blockSize );
993bool KPrPageEffects::effectCheckboardDown()
const
995 int h = m_effectStep * m_stepHeight;
996 int blockSize = m_height / 8;
998 bool finished =
false;
999 if ( h >= blockSize * 2 )
1005 for (
int x = 0; x < m_width; x += blockSize )
1007 int y = ( ( x / blockSize ) & 1 ) * blockSize;
1009 if ( y == blockSize && h >= blockSize - m_stepHeight )
1010 bitBlt( m_dst, x, h - blockSize, &m_pageTo, x, h - blockSize, blockSize, m_stepHeight );
1012 for ( ; y < m_width; y += 2 * blockSize )
1014 bitBlt( m_dst, x, y + h, &m_pageTo, x, y + h, blockSize, m_stepHeight );
1022bool KPrPageEffects::effectCoverDown()
const
1024 int h = m_effectStep * m_stepHeight;
1026 bool finished =
false;
1027 if ( h >= m_height )
1033 bitBlt( m_dst, 0, 0, &m_pageTo, 0, m_height - h, m_width, h );
1039bool KPrPageEffects::effectUncoverDown()
const
1041 int h = m_effectStep * m_stepHeight;
1043 bool finished =
false;
1044 if ( h >= m_height )
1050 bitBlt( m_dst, 0, h + m_stepHeight, m_dst, 0, h, m_width, m_height - h - m_stepHeight );
1051 bitBlt( m_dst, 0, h, &m_pageTo, 0, h, m_width, m_stepHeight );
1057bool KPrPageEffects::effectCoverUp()
const
1059 int h = m_effectStep * m_stepHeight;
1061 bool finished =
false;
1062 if ( h >= m_height )
1068 bitBlt( m_dst, 0, m_height - h, &m_pageTo, 0, 0, m_width, h );
1074bool KPrPageEffects::effectUncoverUp()
1076 if ( m_effectStep == 0 )
1077 bitBlt( &m_pageFrom, 0, 0, m_dst );
1079 int h = m_effectStep * m_stepHeight;
1081 bool finished =
false;
1082 if ( h >= m_height )
1088 bitBlt( m_dst, 0, 0, &m_pageFrom, 0, h + m_stepHeight, m_width, m_height - h - m_stepHeight );
1089 bitBlt( m_dst, 0, m_height - h - m_stepHeight, &m_pageTo, 0, m_height - h - m_stepHeight, m_width, m_stepHeight );
1095bool KPrPageEffects::effectCoverLeft()
const
1097 int w = m_effectStep * m_stepHeight;
1099 bool finished =
false;
1106 bitBlt( m_dst, m_width - w, 0, &m_pageTo, 0, 0, w, m_height );
1112bool KPrPageEffects::effectUncoverLeft()
1114 if ( m_effectStep == 0 )
1115 bitBlt( &m_pageFrom, 0, 0, m_dst );
1117 int w = m_effectStep * m_stepWidth;
1119 bool finished =
false;
1126 bitBlt( m_dst, 0, 0, &m_pageFrom, w + m_stepWidth, 0, m_width - w - m_stepWidth, m_height );
1127 bitBlt( m_dst, m_width - w - m_stepWidth, 0, &m_pageTo, m_width - w - m_stepWidth, 0, m_stepWidth, m_height );
1133bool KPrPageEffects::effectCoverRight()
const
1135 int w = m_effectStep * m_stepWidth;
1137 bool finished =
false;
1144 bitBlt( m_dst, 0, 0, &m_pageTo, m_width - w, 0, w, m_height );
1150bool KPrPageEffects::effectUncoverRight()
1152 if ( m_effectStep == 0 )
1153 bitBlt( &m_pageFrom, 0, 0, m_dst );
1155 int w = m_effectStep * m_stepWidth;
1157 bool finished =
false;
1164 bitBlt( m_dst, w + m_stepWidth, 0, &m_pageFrom, 0, 0, m_width - w - m_stepWidth, m_height );
1165 bitBlt( m_dst, w, 0, &m_pageTo, w, 0, m_stepWidth, m_height );
1171bool KPrPageEffects::effectCoverLeftUp()
const
1173 double fact = (double) m_height / (
double) m_width;
1174 int h = (int)( m_effectStep * m_stepWidth * fact );
1175 int w = m_effectStep * m_stepWidth;
1177 bool finished =
false;
1178 if ( h >= m_height )
1186 if ( h >= m_height && w >= m_width )
1191 bitBlt( m_dst, m_width - w, m_height - h, &m_pageTo, 0, 0, w, h );
1197bool KPrPageEffects::effectUncoverLeftUp()
1199 if ( m_effectStep == 0 )
1200 bitBlt( &m_pageFrom, 0, 0, m_dst );
1202 double fact = (double) m_height / (
double) m_width;
1203 int h = (int)( m_effectStep * m_stepWidth * fact );
1204 int w = m_effectStep * m_stepWidth;
1206 bool finished =
false;
1207 if ( h >= m_height )
1215 if ( h >= m_height && w >= m_width )
1221 bitBlt( m_dst, 0, 0, &m_pageFrom, w, h, m_width - w, m_height - h );
1222 bitBlt( m_dst, m_width - w, 0, &m_pageTo, m_width - w, 0, w, m_height );
1223 bitBlt( m_dst, 0, m_height - h, &m_pageTo, 0, m_height - h, m_width, h );
1229bool KPrPageEffects::effectCoverLeftDown()
const
1231 double fact = (double) m_height / (
double) m_width;
1232 int h = (int)( m_effectStep * m_stepWidth * fact );
1233 int w = m_effectStep * m_stepWidth;
1235 bool finished =
false;
1236 if ( h >= m_height )
1244 if ( h >= m_height && w >= m_width )
1249 bitBlt( m_dst, m_width - w, 0, &m_pageTo, 0, m_height - h, w, h );
1255bool KPrPageEffects::effectUncoverLeftDown()
1257 if ( m_effectStep == 0 )
1258 bitBlt( &m_pageFrom, 0, 0, m_dst );
1260 double fact = (double) m_height / (
double) m_width;
1261 int h = (int)( m_effectStep * m_stepWidth * fact );
1262 int w = m_effectStep * m_stepWidth;
1264 bool finished =
false;
1265 if ( h >= m_height )
1273 if ( h >= m_height && w >= m_width )
1279 bitBlt( m_dst, 0, h, &m_pageFrom, w, 0, m_width - w, m_height - h );
1280 bitBlt( m_dst, 0, 0, &m_pageTo, 0, 0, m_width, h );
1281 bitBlt( m_dst, m_width - w, h, &m_pageTo, m_width - w, h, w, m_height - h );
1287bool KPrPageEffects::effectCoverRightUp()
const
1289 double fact = (double) m_height / (
double) m_width;
1290 int h = (int)( m_effectStep * m_stepWidth * fact );
1291 int w = m_effectStep * m_stepWidth;
1293 bool finished =
false;
1294 if ( h >= m_height )
1302 if ( h >= m_height && w >= m_width )
1307 bitBlt( m_dst, 0, m_height - h, &m_pageTo, m_width - w, 0, w, h );
1313bool KPrPageEffects::effectUncoverRightUp()
1315 if ( m_effectStep == 0 )
1316 bitBlt( &m_pageFrom, 0, 0, m_dst );
1318 double fact = (double) m_height / (
double) m_width;
1319 int h = (int)( m_effectStep * m_stepWidth * fact );
1320 int w = m_effectStep * m_stepWidth;
1322 bool finished =
false;
1323 if ( h >= m_height )
1331 if ( h >= m_height && w >= m_width )
1336 bitBlt( m_dst, w, 0, &m_pageFrom, 0, h, m_width - w, m_height - h );
1337 bitBlt( m_dst, 0, 0, &m_pageTo, 0, 0, w, m_height );
1338 bitBlt( m_dst, w, m_height - h, &m_pageTo, w, m_height - h, m_width - w, h );
1344bool KPrPageEffects::effectCoverRightDown()
const
1346 double fact = (double) m_height / (
double) m_width;
1347 int h = (int)( m_effectStep * m_stepWidth * fact );
1348 int w = m_effectStep * m_stepWidth;
1350 bool finished =
false;
1351 if ( h >= m_height )
1359 if ( h >= m_height && w >= m_width )
1364 bitBlt( m_dst, 0, 0, &m_pageTo, m_width - w, m_height - h, w, h );
1370bool KPrPageEffects::effectUncoverRightDown()
1372 if ( m_effectStep == 0 )
1373 bitBlt( &m_pageFrom, 0, 0, m_dst );
1375 double fact = (double) m_height / (
double) m_width;
1376 int h = (int)( m_effectStep * m_stepWidth * fact );
1377 int w = m_effectStep * m_stepWidth;
1379 bool finished =
false;
1380 if ( h >= m_height )
1388 if ( h >= m_height && w >= m_width )
1393 bitBlt( m_dst, w, h, &m_pageFrom, 0, 0, m_width - w, m_height - h );
1394 bitBlt( m_dst, 0, 0, &m_pageTo, 0, 0, m_width, h );
1395 bitBlt( m_dst, 0, h, &m_pageTo, 0, h, w, m_height - h );
1401bool KPrPageEffects::effectDissolve()
1403 KRandomSequence random;
1405 int blockSize = m_height / 32;
1406 int rowno = ( m_height + blockSize - 1 ) / blockSize;
1407 int colno = ( m_width + blockSize - 1 ) / blockSize;
1408 int cellno = rowno * colno;
1410 if ( m_effectStep == 0 )
1412 for(
int c = 0; c < cellno; c++ )
1416 int steps[] = { 30, 60, 90 };
1417 int dissove = steps[m_speed];
1418 while ( !m_list.isEmpty() && dissove > 0 )
1422 int index = random.getLong( m_list.count() );
1423 TQValueListIterator<int> it = m_list.at( index );
1425 unsigned int x = ( *it % colno ) * blockSize;
1426 unsigned int y = ( *it / colno ) * blockSize;
1428 m_list.remove( it );
1430 bitBlt( m_dst, x, y, &m_pageTo, x, y, blockSize, blockSize );
1433 return m_list.isEmpty();
1437bool KPrPageEffects::effectStripesLeftUp()
const
1439 int wSteps = m_width / m_stepWidth + 1;
1440 int hSteps = m_height / m_stepWidth + 1;
1442 int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
1443 int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
1445 bool finished =
false;
1446 if ( m_effectStep >= wSteps + hSteps )
1451 int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
1453 for (
int x = xStart; x >= xStop; --x )
1455 bitBlt( m_dst, m_width - x * m_stepWidth, m_height - y * m_stepWidth,
1456 &m_pageTo, m_width - x * m_stepWidth, m_height - y * m_stepWidth , m_stepWidth, m_stepWidth );
1464bool KPrPageEffects::effectStripesLeftDown()
const
1466 int wSteps = m_width / m_stepWidth + 1;
1467 int hSteps = m_height / m_stepWidth + 1;
1469 int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
1470 int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
1472 bool finished =
false;
1473 if ( m_effectStep >= wSteps + hSteps )
1478 int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
1480 for (
int x = xStart; x >= xStop; --x )
1482 bitBlt( m_dst, m_width - x * m_stepWidth, ( y - 1 ) * m_stepWidth,
1483 &m_pageTo, m_width - x * m_stepWidth, ( y - 1 ) * m_stepWidth , m_stepWidth, m_stepWidth );
1491bool KPrPageEffects::effectStripesRightUp()
const
1493 int wSteps = m_width / m_stepWidth + 1;
1494 int hSteps = m_height / m_stepWidth + 1;
1496 int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
1497 int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
1499 bool finished =
false;
1500 if ( m_effectStep >= wSteps + hSteps )
1505 int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
1507 for (
int x = xStart; x >= xStop; --x )
1509 bitBlt( m_dst, ( x - 1 ) * m_stepWidth, m_height - y * m_stepWidth,
1510 &m_pageTo, ( x - 1 ) * m_stepWidth, m_height - y * m_stepWidth , m_stepWidth, m_stepWidth );
1518bool KPrPageEffects::effectStripesRigthDown()
const
1520 int wSteps = m_width / m_stepWidth + 1;
1521 int hSteps = m_height / m_stepWidth + 1;
1523 int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
1524 int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
1526 bool finished =
false;
1527 if ( m_effectStep >= wSteps + hSteps )
1532 int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
1534 for (
int x = xStart; x >= xStop; --x )
1536 bitBlt( m_dst, ( x - 1 ) * m_stepWidth, ( y - 1 ) * m_stepWidth,
1537 &m_pageTo, ( x - 1 ) * m_stepWidth, ( y - 1 ) * m_stepWidth , m_stepWidth, m_stepWidth );
1545bool KPrPageEffects::effectMelting()
1548 int max_melt = 2 * m_stepHeight;
1550 if ( m_effectStep == 0 )
1552 bitBlt( &m_pageFrom, 0, 0, m_dst );
1554 for(
int c = 0; c < count; c++ )
1558 int w = ( m_width + count - 1 ) / count;
1560 TQValueListIterator<int> it = m_list.begin();
1563 for (
int c = 0; c < count; c++ )
1567 KRandomSequence random;
1568 int grow = 1 + random.getLong( max_melt );
1570 if ( *it + grow >= m_height )
1572 grow = m_height - *it;
1576 if( *it < m_height )
1578 bitBlt( m_dst, x, *it, &m_pageTo, x, *it, w, grow );
1579 bitBlt( m_dst, x, *it + grow, &m_pageFrom, x, 0, w, m_height - *it - grow );
1586 return finished == 0;