kpresenter

KPrPageEffects.cpp
1/* This file is part of the KDE project
2 Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
3 Copyright (C) 2002 Ariya Hidayat <ariya@kde.org>
4 Copyright (C) 2002 Harri Porten <porten@kde.org>
5 Copyright (C) 2004 Thorsten Zachmann <zachmann@kde.org>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21*/
22
23#include "KPrPageEffects.h"
24
25#include <tqpixmap.h>
26#include <tqwidget.h>
27#include <tqwmatrix.h>
28
29#include <tdeapplication.h>
30#include <kdebug.h>
31#include <krandomsequence.h>
32
33
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)
37{
38 if ( m_effect == PEF_RANDOM )
39 {
40 KRandomSequence random;
41 m_randomEffect = static_cast<PageEffect>( random.getLong( PEF_LAST_MARKER ) );
42 }
43 int div[] = { 100, 65, 30 };
44
45 m_stepWidth = (int) ( m_width / div[m_speed] );
46 m_stepHeight = (int) ( m_height / div[m_speed] );
47}
48
49
50KPrPageEffects::~KPrPageEffects()
51{
52}
53
54
55bool KPrPageEffects::doEffect()
56{
57 if ( !m_finished )
58 {
59 PageEffect effect = m_effect == PEF_RANDOM ? m_randomEffect : m_effect;
60 switch ( effect )
61 {
62 case PEF_NONE:
63 m_finished = effectNone();
64 break;
65 case PEF_CLOSE_HORZ:
66 m_finished = effectCloseHorizontal();
67 break;
68 case PEF_CLOSE_VERT:
69 m_finished = effectCloseVertical();
70 break;
71 case PEF_CLOSE_ALL:
72 m_finished = effectCloseFromAllDirections();
73 break;
74 case PEF_OPEN_HORZ:
75 m_finished = effectOpenHorizontal();
76 break;
77 case PEF_OPEN_VERT:
78 m_finished = effectOpenVertical();
79 break;
80 case PEF_OPEN_ALL:
81 m_finished = effectOpenFromAllDirections();
82 break;
83 case PEF_INTERLOCKING_HORZ_1:
84 m_finished = effectInterlockingHorizontal1();
85 break;
86 case PEF_INTERLOCKING_HORZ_2:
87 m_finished = effectInterlockingHorizontal2();
88 break;
89 case PEF_INTERLOCKING_VERT_1:
90 m_finished = effectInterlockingVertical1();
91 break;
92 case PEF_INTERLOCKING_VERT_2:
93 m_finished = effectInterlockingVertical2();
94 break;
95 case PEF_SURROUND1:
96 m_finished = effectSurround1();
97 break;
98 case PEF_FLY1:
99 m_finished = effectFlyAway1();
100 break;
101 case PEF_BLINDS_HOR:
102 m_finished = effectBlindsHorizontal();
103 break;
104 case PEF_BLINDS_VER:
105 m_finished = effectBlindsVertical();
106 break;
107 case PEF_BOX_IN:
108 m_finished = effectBoxIn();
109 break;
110 case PEF_BOX_OUT:
111 m_finished = effectBoxOut();
112 break;
113 case PEF_CHECKBOARD_ACROSS:
114 m_finished = effectCheckboardAcross();
115 break;
116 case PEF_CHECKBOARD_DOWN:
117 m_finished = effectCheckboardDown();
118 break;
119 case PEF_COVER_DOWN:
120 m_finished = effectCoverDown();
121 break;
122 case PEF_UNCOVER_DOWN:
123 m_finished = effectUncoverDown();
124 break;
125 case PEF_COVER_UP:
126 m_finished = effectCoverUp();
127 break;
128 case PEF_UNCOVER_UP:
129 m_finished = effectUncoverUp();
130 break;
131 case PEF_COVER_LEFT:
132 m_finished = effectCoverLeft();
133 break;
134 case PEF_UNCOVER_LEFT:
135 m_finished = effectUncoverLeft();
136 break;
137 case PEF_COVER_RIGHT:
138 m_finished = effectCoverRight();
139 break;
140 case PEF_UNCOVER_RIGHT:
141 m_finished = effectUncoverRight();
142 break;
143 case PEF_COVER_LEFT_UP:
144 m_finished = effectCoverLeftUp();
145 break;
146 case PEF_UNCOVER_LEFT_UP:
147 m_finished = effectUncoverLeftUp();
148 break;
149 case PEF_COVER_LEFT_DOWN:
150 m_finished = effectCoverLeftDown();
151 break;
152 case PEF_UNCOVER_LEFT_DOWN:
153 m_finished = effectUncoverLeftDown();
154 break;
155 case PEF_COVER_RIGHT_UP:
156 m_finished = effectCoverRightUp();
157 break;
158 case PEF_UNCOVER_RIGHT_UP:
159 m_finished = effectUncoverRightUp();
160 break;
161 case PEF_COVER_RIGHT_DOWN:
162 m_finished = effectCoverRightDown();
163 break;
164 case PEF_UNCOVER_RIGHT_DOWN:
165 m_finished = effectUncoverRightDown();
166 break;
167 case PEF_DISSOLVE:
168 m_finished = effectDissolve();
169 break;
170 case PEF_STRIPS_LEFT_UP:
171 m_finished = effectStripesLeftUp();
172 break;
173 case PEF_STRIPS_LEFT_DOWN:
174 m_finished = effectStripesLeftDown();
175 break;
176 case PEF_STRIPS_RIGHT_UP:
177 m_finished = effectStripesRightUp();
178 break;
179 case PEF_STRIPS_RIGHT_DOWN:
180 m_finished = effectStripesRigthDown();
181 break;
182 case PEF_MELTING:
183 m_finished = effectMelting();
184 break;
185 default:
186 m_finished = effectCloseHorizontal();
187 break;
188 }
189 ++m_effectStep;
190 }
191 return m_finished;
192}
193
194
195void KPrPageEffects::finish()
196{
197 if ( !m_finished )
198 {
199 bitBlt( m_dst, 0, 0, &m_pageTo );
200 m_finished = true;
201 }
202}
203
204
205bool KPrPageEffects::effectNone() const
206{
207 bitBlt( m_dst, 0, 0, &m_pageTo );
208 return true;
209}
210
211
212bool KPrPageEffects::effectCloseHorizontal() const
213{
214 int h = m_effectStep * m_stepHeight;
215
216 bool finished = false;
217 if ( h >= m_height / 2 )
218 {
219 h = m_height / 2;
220 finished = true;
221 }
222
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 );
225
226 return finished;
227}
228
229
230bool KPrPageEffects::effectCloseVertical() const
231{
232 int w = m_effectStep * m_stepWidth;
233
234 bool finished = false;
235 if ( w >= m_width / 2 )
236 {
237 w = m_width / 2;
238 finished = true;
239 }
240
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 );
243
244 return finished;
245}
246
247
248bool KPrPageEffects::effectCloseFromAllDirections() const
249{
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;
253
254 bool finished = false;
255 if ( h >= m_height / 2 )
256 {
257 h = m_height / 2;
258 }
259 if ( w >= m_width / 2 )
260 {
261 w = m_width / 2;
262 }
263 if ( h >= m_height / 2 && w >= m_width / 2 )
264 {
265 finished = true;
266 }
267
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 );
272
273 return finished;
274}
275
276
277bool KPrPageEffects::effectOpenHorizontal() const
278{
279 int h = m_effectStep * m_stepHeight;
280
281 bool finished = false;
282 if ( h >= m_height / 2 )
283 {
284 h = m_height / 2;
285 finished = true;
286 }
287
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 );
290
291 return finished;
292}
293
294
295bool KPrPageEffects::effectOpenVertical() const
296{
297 int w = m_effectStep * m_stepWidth;
298
299 bool finished = false;
300 if ( w >= m_width / 2 )
301 {
302 w = m_width / 2;
303 finished = true;
304 }
305
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 );
308
309 return finished;
310}
311
312
313bool KPrPageEffects::effectOpenFromAllDirections() const
314{
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;
318
319 bool finished = false;
320 if ( h >= m_height / 2 )
321 {
322 h = m_height / 2;
323 }
324 if ( w >= m_width / 2 )
325 {
326 w = m_width / 2;
327 }
328 if ( h >= m_height / 2 && w >= m_width / 2 )
329 {
330 finished = true;
331 }
332
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 );
337
338 return finished;
339}
340
341
342bool KPrPageEffects::effectInterlockingHorizontal1() const
343{
344 int w = m_effectStep * m_stepWidth;
345
346 bool finished = false;
347 if ( w >= m_width )
348 {
349 w = m_width;
350 finished = true;
351 }
352
353 int h = m_height / 4;
354
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 );
359
360 return finished;
361}
362
363
364bool KPrPageEffects::effectInterlockingHorizontal2() const
365{
366 int w = m_effectStep * m_stepWidth;
367
368 bool finished = false;
369 if ( w >= m_width )
370 {
371 w = m_width;
372 finished = true;
373 }
374
375 int h = m_height / 4;
376
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 );
381
382 return finished;
383}
384
385
386bool KPrPageEffects::effectInterlockingVertical1() const
387{
388 int h = m_effectStep * m_stepHeight;
389
390 bool finished = false;
391 if ( h >= m_height )
392 {
393 h = m_height;
394 finished = true;
395 }
396
397 int w = m_width / 4;
398
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 );
403
404 return finished;
405}
406
407
408bool KPrPageEffects::effectInterlockingVertical2() const
409{
410 int h = m_effectStep * m_stepHeight;
411
412 bool finished = false;
413 if ( h >= m_height )
414 {
415 h = m_height;
416 finished = true;
417 }
418
419 int w = m_width / 4;
420
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 );
425
426 return finished;
427}
428
429
430bool KPrPageEffects::effectSurround1() const
431{
432 int div[] = { 20, 15, 10 };
433 int stepSize = m_height / div[m_speed];
434 int step = m_effectStep * stepSize;
435
436 int h = m_height / 10;
437 int w = m_width / 10;
438 int repaint_h = h;
439 int repaint_w = w;
440
441 bool finished = false;
442 bool repaint= false;
443 int rh = 0;
444 int rw = 0;
445 int repaint_rh = 0;
446 int repaint_rw = 0;
447
448 // 1
449 if ( step < m_height )
450 {
451 rh = step;
452 rw = 0;
453 h = stepSize;
454 if ( step + stepSize >= m_height )
455 {
456 repaint = true;
457
458 repaint_rh = m_height - repaint_h;
459 repaint_rw = step - m_height + repaint_w;
460 repaint_w = stepSize;
461 }
462 }
463 // 2
464 else if ( step < m_height + m_width - w )
465 {
466 rh = m_height - h;
467 rw = step - m_height + w;
468 w = stepSize;
469 if ( step + stepSize >= m_height + m_width - repaint_w )
470 {
471 repaint = true;
472
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;
476 }
477 }
478 // 3
479 else if ( step < 2 * m_height - h + m_width - w )
480 {
481 rh = m_height - ( step - m_height + h - m_width + w + stepSize );
482 rw = m_width - w;
483 h = stepSize;
484 if ( step + stepSize >= 2 * m_height - repaint_h + m_width - repaint_w )
485 {
486 repaint = true;
487
488 repaint_rh = 0;
489 repaint_rw = m_width - ( step - 2 * m_height + repaint_h - m_width + 2 * repaint_w + stepSize );
490 repaint_w = stepSize;
491 }
492 }
493 // 4
494 else if ( step < 2 * m_height - h + 2 * m_width - 3 * w )
495 {
496 rh = 0;
497 rw = m_width - ( step - 2 * m_height + h - m_width + 2 * w + stepSize );
498 w = stepSize;
499 if ( step + stepSize >= 2 * m_height - repaint_h + 2 * m_width - 3 * repaint_w )
500 {
501 repaint = true;
502
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;
506 }
507 }
508 // 5
509 else if ( step < 3 * m_height - 3 * h + 2 * m_width - 3 * w )
510 {
511 rh = step - 2 * m_height + 2 * h - 2 * m_width + 3 * w;
512 rw = w;
513 h = stepSize;
514 if ( step + stepSize >= 3 * m_height - 3 * repaint_h + 2 * m_width - 3 * repaint_w )
515 {
516 repaint = true;
517
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;
521 }
522 }
523 // 6
524 else if ( step < 3 * m_height - 3 * h + 3 * m_width - 6 * w )
525 {
526 rh = m_height - 2 * h;
527 rw = step - 3 * m_height + 3 * h - 2 * m_width + 5 * w;
528 w = stepSize;
529 if ( step + stepSize >= 3 * m_height - 3 * repaint_h + 3 * m_width - 6 * repaint_w )
530 {
531 repaint = true;
532
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;
536 }
537 }
538 // 7
539 else if ( step < 4 * m_height - 6 * h + 3 * m_width - 6 * w )
540 {
541 rh = m_height - ( step - 3 * m_height + 5 * h - 3 * m_width + 6 * w + stepSize );
542 rw = m_width - 2 * w;
543 h = stepSize;
544 if ( step + stepSize >= 4 * m_height - 6 * repaint_h + 3 * m_width - 6 * repaint_w )
545 {
546 repaint = true;
547
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;
551 }
552 }
553 // 8
554 else if ( step < 4 * m_height - 6 * h + 4 * m_width - 10 * w )
555 {
556 rh = h;
557 rw = m_width - ( step - 4 * m_height + 6 * h - 3 * m_width + 8 * w + stepSize );
558 w = stepSize;
559 if ( step + stepSize >= 4 * m_height - 6 * repaint_h + 4 * m_width - 10 * repaint_w )
560 {
561 repaint = true;
562
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;
566 }
567 }
568 // 9
569 else if ( step < 5 * m_height - 10 * h + 4 * m_width - 10 * w )
570 {
571 rh = step - 4 * m_height + 8 * h - 4 * m_width + 10 * w;
572 rw = 2 * w;
573 h = stepSize;
574 if ( step + stepSize >= 5 * m_height - 10 * repaint_h + 4 * m_width - 10 * repaint_w )
575 {
576 repaint = true;
577
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;
581 }
582 }
583 // 10
584 else if ( step < 5 * m_height - 10 * h + 5 * m_width - 15 * w )
585 {
586 rh = m_height - 3 * h;
587 rw = step - 5 * m_height + 10 * h - 4 * m_width + 13 * w;
588 w = stepSize;
589 if ( step + stepSize >= 5 * m_height - 10 * repaint_h + 5 * m_width - 15 * repaint_w )
590 {
591 repaint = true;
592
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;
596 }
597 }
598 // 11
599 else if ( step < 6 * m_height - 15 * h + 5 * m_width - 15 * w )
600 {
601 rh = m_height - ( step - 5 * m_height + 13 * h - 5 * m_width + 15 * w + stepSize );
602 rw = m_width - 3 * w;
603 h = stepSize;
604 if ( step + stepSize >= 6 * m_height - 15 * repaint_h + 5 * m_width - 15 * repaint_w )
605 {
606 repaint = true;
607
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;
611 }
612 }
613 // 12
614 else if ( step < 6 * m_height - 15 * h + 6 * m_width - 21 * w )
615 {
616 rh = 2 * h;
617 rw = m_width - ( step - 6 * m_height + 15 * h - 5 * m_width + 18 * w + stepSize );
618 w = stepSize;
619 if ( step + stepSize >= 6 * m_height - 15 * repaint_h + 6 * m_width - 21 * repaint_w )
620 {
621 repaint = true;
622
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;
626 }
627 }
628 // 13
629 else if ( step < 7 * m_height - 21 * h + 6 * m_width - 21 * w )
630 {
631 rh = step - 6 * m_height + 18 * h - 6 * m_width + 21 * w;
632 rw = 3 * w;
633 h = stepSize;
634 if ( step + stepSize >= 7 * m_height - 21 * repaint_h + 6 * m_width - 21 * repaint_w )
635 {
636 repaint = true;
637
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;
641 }
642 }
643 // 14
644 else if ( step < 7 * m_height - 21 * h + 7 * m_width - 28 * w )
645 {
646 rh = m_height - 4 * h;
647 rw = step - 7 * m_height + 21 * h - 6 * m_width + 25 * w;
648 w = stepSize;
649 if ( step + stepSize >= 7 * m_height - 21 * repaint_h + 7 * m_width - 28 * repaint_w )
650 {
651 repaint = true;
652
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;
656 }
657 }
658 // 15
659 else if ( step < 8 * m_height - 28 * h + 7 * m_width - 28 * w )
660 {
661 rh = m_height - ( step - 7 * m_height + 25 * h - 7 * m_width + 28 * w + stepSize );
662 rw = m_width - 4 * w;
663 h = stepSize;
664 if ( step + stepSize >= 8 * m_height - 28 * repaint_h + 7 * m_width - 28 * repaint_w )
665 {
666 repaint = true;
667
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;
671 }
672 }
673 // 16
674 else if ( step < 8 * m_height - 28 * h + 8 * m_width - 36 * w )
675 {
676 rh = 3 * h;
677 rw = m_width - ( step - 8 * m_height + 28 * h - 7 * m_width + 32 * w + stepSize );
678 w = stepSize;
679 if ( step + stepSize >= 8 * m_height - 28 * repaint_h + 8 * m_width - 36 * repaint_w )
680 {
681 repaint = true;
682
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;
686 }
687 }
688 // 17
689 else if ( step < 9 * m_height - 36 * h + 8 * m_width - 36 * w )
690 {
691 rh = step - 8 * m_height + 32 * h - 8 * m_width + 36 * w;
692 rw = 4 * w;
693 h = stepSize;
694 if ( step + stepSize >= 9 * m_height - 36 * repaint_h + 8 * m_width - 36 * repaint_w )
695 {
696 repaint = true;
697
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;
701 }
702 }
703 // 18
704 else if ( step < 9 * m_height - 36 * h + 9 * m_width - 45 * w )
705 {
706 rh = m_height - 5 * h;
707 rw = step - 9 * m_height + 36 * h - 8 * m_width + 41 * w;
708 w = stepSize;
709 if ( step + stepSize >= 9 * m_height - 36 * repaint_h + 9 * m_width - 45 * repaint_w )
710 {
711 repaint = true;
712
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;
716 }
717 }
718 // 19
719 else if ( step < 10 * m_height - 45 * h + 9 * m_width - 45 * w )
720 {
721 rh = m_height - ( step - 9 * m_height + 41 * h - 9 * m_width + 45 * w + stepSize );
722 rw = m_width - 5 * w;
723 h = stepSize;
724 }
725 // 20
726 /*else if ( step < 8 * m_height - 28 * h + 8 * m_width - 36 * w )
727 {
728 rh = 3 * h;
729 rw = m_width - ( step - 8 * m_height + 28 * h - 7 * m_width + 32 * w + stepSize );
730 w = stepSize;
731 }*/
732 else
733 {
734 finished = true;
735 }
736
737 bitBlt( m_dst, rw, rh, &m_pageTo, rw, rh, w, h );
738
739 if ( repaint )
740 {
741 bitBlt( m_dst, repaint_rw, repaint_rh, &m_pageTo, repaint_rw, repaint_rh, repaint_w, repaint_h );
742 }
743
744 return finished;
745}
746
747
748bool KPrPageEffects::effectFlyAway1()
749{
750 bool finished = false;
751 int steps[] = { 20, 15, 10 };
752 int pSteps = steps[m_speed];
753
754 if ( m_effectStep == 0 )
755 {
756 bitBlt( &m_pageFrom, 0, 0, m_dst );
757 m_list.append( m_width );
758 m_list.append( m_height );
759 m_list.append( 0 );
760 m_list.append( 0 );
761 }
762 else if ( m_effectStep <= pSteps )
763 {
764 double dw = 1.0 - 83.0 / 100.0 * m_effectStep / (double)pSteps;
765
766 TQWMatrix m;
767 m.scale( dw, dw );
768 TQPixmap pix( m_pageFrom.xForm( m ) );
769
770 if ( m_effectStep == pSteps )
771 m_pageFrom = pix;
772
773 int w = pix.width();
774 int h = pix.height();
775 int x = ( m_width - w ) / 2;
776 int y = ( m_height - h ) / 2;
777
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));
782
783 bitBlt( m_dst, x, y, &pix, 0, 0 , w, h );
784 // top
785 bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, ow, y - oy );
786 // left
787 bitBlt( m_dst, ox, y, &m_pageTo, ox, y, x - ox, h );
788 // right
789 bitBlt( m_dst, x + w, y, &m_pageTo, x + w, y, ( ow - w + 1 ) / 2, h );
790 // bottom
791 bitBlt( m_dst, ox, y + h, &m_pageTo, ox, y + h, ow, ( oh - h + 1 ) / 2 );
792
793 *(m_list.at(0)) = w;
794 *(m_list.at(1)) = h;
795 *(m_list.at(2)) = x;
796 *(m_list.at(3)) = y;
797 }
798 else if ( m_effectStep <= 2 * pSteps )
799 {
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;
804
805 int oy = *(m_list.at(3));
806
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);
809
810 *(m_list.at(3)) = y;
811 }
812 else if ( m_effectStep <= 3 * pSteps )
813 {
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;
818
819 int ox = *(m_list.at(2));
820 int oy = *(m_list.at(3));
821
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 );
825
826 *(m_list.at(2)) = x;
827 *(m_list.at(3)) = y;
828 }
829 else
830 {
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;
835
836 int ox = *(m_list.at(2));
837 int oy = *(m_list.at(3));
838
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 );
842
843 if ( x >= m_height )
844 {
845 finished = true;
846 }
847 else
848 {
849 *(m_list.at(2)) = x;
850 *(m_list.at(3)) = y;
851 }
852 }
853
854 return finished;
855}
856
857
858bool KPrPageEffects::effectBlindsHorizontal() const
859{
860 int h = m_effectStep * m_stepHeight;
861 int blockSize = m_height / 8;
862
863 bool finished = false;
864 if ( h >= blockSize )
865 {
866 h = blockSize;
867 finished = true;
868 }
869
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 );
872
873 return finished;
874}
875
876
877bool KPrPageEffects::effectBlindsVertical() const
878{
879 int w = m_effectStep * m_stepWidth;
880 int blockSize = m_width / 8;
881
882 bool finished = false;
883 if ( w >= blockSize )
884 {
885 w = blockSize;
886 finished = true;
887 }
888
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 );
891
892 return finished;
893}
894
895
896bool KPrPageEffects::effectBoxIn() const
897{
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;
902
903 bool finished = false;
904 if ( h >= m_height / 2 )
905 {
906 h = m_height / 2;
907 }
908 if ( w >= m_width / 2 )
909 {
910 w = m_width / 2;
911 }
912 if ( h >= m_height / 2 && w >= m_width / 2 )
913 {
914 finished = true;
915 }
916
917 // top
918 bitBlt( m_dst, w, h, &m_pageTo, w, h, m_width - 2 * w, stepHeight );
919 // left
920 bitBlt( m_dst, w, h, &m_pageTo, w, h, m_stepWidth, m_height - 2 * h );
921 //right
922 bitBlt( m_dst, m_width - w, h, &m_pageTo, m_width - w, h, m_stepWidth, m_height - 2 * h );
923 // bottom
924 bitBlt( m_dst, w, m_height - h - stepHeight, &m_pageTo, w, m_height - h - stepHeight, m_width - 2 * w, stepHeight );
925
926 return finished;
927}
928
929
930bool KPrPageEffects::effectBoxOut() const
931{
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;
936
937 bool finished = false;
938 if ( h >= m_height / 2 )
939 {
940 h = m_height / 2;
941 }
942 if ( w >= m_width / 2 )
943 {
944 w = m_width / 2;
945 }
946 if ( h >= m_height / 2 && w >= m_width / 2 )
947 {
948 finished = true;
949 }
950
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 );
959
960 return finished;
961}
962
963
964bool KPrPageEffects::effectCheckboardAcross() const
965{
966 int w = m_effectStep * m_stepWidth;
967 int blockSize = m_height / 8;
968
969 bool finished = false;
970 if ( w >= blockSize * 2 )
971 {
972 w = blockSize * 2;
973 finished = true;
974 }
975
976 for ( int y = 0; y < m_height; y += blockSize )
977 {
978 int x = ( ( y / blockSize ) & 1 ) * blockSize;
979
980 if ( x == blockSize && w >= blockSize - m_stepWidth )
981 bitBlt( m_dst, w - blockSize, y, &m_pageTo, w - blockSize, y, m_stepWidth, blockSize );
982
983 for ( ; x < m_width; x += 2 * blockSize )
984 {
985 bitBlt( m_dst, x + w, y, &m_pageTo, x + w, y, m_stepWidth, blockSize );
986 }
987 }
988
989 return finished;
990}
991
992
993bool KPrPageEffects::effectCheckboardDown() const
994{
995 int h = m_effectStep * m_stepHeight;
996 int blockSize = m_height / 8;
997
998 bool finished = false;
999 if ( h >= blockSize * 2 )
1000 {
1001 h = blockSize * 2;
1002 finished = true;
1003 }
1004
1005 for ( int x = 0; x < m_width; x += blockSize )
1006 {
1007 int y = ( ( x / blockSize ) & 1 ) * blockSize;
1008
1009 if ( y == blockSize && h >= blockSize - m_stepHeight )
1010 bitBlt( m_dst, x, h - blockSize, &m_pageTo, x, h - blockSize, blockSize, m_stepHeight );
1011
1012 for ( ; y < m_width; y += 2 * blockSize )
1013 {
1014 bitBlt( m_dst, x, y + h, &m_pageTo, x, y + h, blockSize, m_stepHeight );
1015 }
1016 }
1017
1018 return finished;
1019}
1020
1021
1022bool KPrPageEffects::effectCoverDown() const
1023{
1024 int h = m_effectStep * m_stepHeight;
1025
1026 bool finished = false;
1027 if ( h >= m_height )
1028 {
1029 h = m_height;
1030 finished = true;
1031 }
1032
1033 bitBlt( m_dst, 0, 0, &m_pageTo, 0, m_height - h, m_width, h );
1034
1035 return finished;
1036}
1037
1038
1039bool KPrPageEffects::effectUncoverDown() const
1040{
1041 int h = m_effectStep * m_stepHeight;
1042
1043 bool finished = false;
1044 if ( h >= m_height )
1045 {
1046 h = m_height;
1047 finished = true;
1048 }
1049
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 );
1052
1053 return finished;
1054}
1055
1056
1057bool KPrPageEffects::effectCoverUp() const
1058{
1059 int h = m_effectStep * m_stepHeight;
1060
1061 bool finished = false;
1062 if ( h >= m_height )
1063 {
1064 h = m_height;
1065 finished = true;
1066 }
1067
1068 bitBlt( m_dst, 0, m_height - h, &m_pageTo, 0, 0, m_width, h );
1069
1070 return finished;
1071}
1072
1073
1074bool KPrPageEffects::effectUncoverUp()
1075{
1076 if ( m_effectStep == 0 )
1077 bitBlt( &m_pageFrom, 0, 0, m_dst );
1078
1079 int h = m_effectStep * m_stepHeight;
1080
1081 bool finished = false;
1082 if ( h >= m_height )
1083 {
1084 h = m_height;
1085 finished = true;
1086 }
1087
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 );
1090
1091 return finished;
1092}
1093
1094
1095bool KPrPageEffects::effectCoverLeft() const
1096{
1097 int w = m_effectStep * m_stepHeight;
1098
1099 bool finished = false;
1100 if ( w >= m_width )
1101 {
1102 w = m_width;
1103 finished = true;
1104 }
1105
1106 bitBlt( m_dst, m_width - w, 0, &m_pageTo, 0, 0, w, m_height );
1107
1108 return finished;
1109}
1110
1111
1112bool KPrPageEffects::effectUncoverLeft()
1113{
1114 if ( m_effectStep == 0 )
1115 bitBlt( &m_pageFrom, 0, 0, m_dst );
1116
1117 int w = m_effectStep * m_stepWidth;
1118
1119 bool finished = false;
1120 if ( w >= m_width )
1121 {
1122 w = m_width;
1123 finished = true;
1124 }
1125
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 );
1128
1129 return finished;
1130}
1131
1132
1133bool KPrPageEffects::effectCoverRight() const
1134{
1135 int w = m_effectStep * m_stepWidth;
1136
1137 bool finished = false;
1138 if ( w >= m_width )
1139 {
1140 w = m_width;
1141 finished = true;
1142 }
1143
1144 bitBlt( m_dst, 0, 0, &m_pageTo, m_width - w, 0, w, m_height );
1145
1146 return finished;
1147}
1148
1149
1150bool KPrPageEffects::effectUncoverRight()
1151{
1152 if ( m_effectStep == 0 )
1153 bitBlt( &m_pageFrom, 0, 0, m_dst );
1154
1155 int w = m_effectStep * m_stepWidth;
1156
1157 bool finished = false;
1158 if ( w >= m_width )
1159 {
1160 w = m_width;
1161 finished = true;
1162 }
1163
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 );
1166
1167 return finished;
1168}
1169
1170
1171bool KPrPageEffects::effectCoverLeftUp() const
1172{
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;
1176
1177 bool finished = false;
1178 if ( h >= m_height )
1179 {
1180 h = m_height;
1181 }
1182 if ( w >= m_width )
1183 {
1184 w = m_width;
1185 }
1186 if ( h >= m_height && w >= m_width )
1187 {
1188 finished = true;
1189 }
1190
1191 bitBlt( m_dst, m_width - w, m_height - h, &m_pageTo, 0, 0, w, h );
1192
1193 return finished;
1194}
1195
1196
1197bool KPrPageEffects::effectUncoverLeftUp()
1198{
1199 if ( m_effectStep == 0 )
1200 bitBlt( &m_pageFrom, 0, 0, m_dst );
1201
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;
1205
1206 bool finished = false;
1207 if ( h >= m_height )
1208 {
1209 h = m_height;
1210 }
1211 if ( w >= m_width )
1212 {
1213 w = m_width;
1214 }
1215 if ( h >= m_height && w >= m_width )
1216 {
1217 finished = true;
1218 }
1219
1220 // fix only copy what is nesseccary
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 );
1224
1225 return finished;
1226}
1227
1228
1229bool KPrPageEffects::effectCoverLeftDown() const
1230{
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;
1234
1235 bool finished = false;
1236 if ( h >= m_height )
1237 {
1238 h = m_height;
1239 }
1240 if ( w >= m_width )
1241 {
1242 w = m_width;
1243 }
1244 if ( h >= m_height && w >= m_width )
1245 {
1246 finished = true;
1247 }
1248
1249 bitBlt( m_dst, m_width - w, 0, &m_pageTo, 0, m_height - h, w, h );
1250
1251 return finished;
1252}
1253
1254
1255bool KPrPageEffects::effectUncoverLeftDown()
1256{
1257 if ( m_effectStep == 0 )
1258 bitBlt( &m_pageFrom, 0, 0, m_dst );
1259
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;
1263
1264 bool finished = false;
1265 if ( h >= m_height )
1266 {
1267 h = m_height;
1268 }
1269 if ( w >= m_width )
1270 {
1271 w = m_width;
1272 }
1273 if ( h >= m_height && w >= m_width )
1274 {
1275 finished = true;
1276 }
1277
1278 // fix only copy what is nesseccary
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 );
1282
1283 return finished;
1284}
1285
1286
1287bool KPrPageEffects::effectCoverRightUp() const
1288{
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;
1292
1293 bool finished = false;
1294 if ( h >= m_height )
1295 {
1296 h = m_height;
1297 }
1298 if ( w >= m_width )
1299 {
1300 w = m_width;
1301 }
1302 if ( h >= m_height && w >= m_width )
1303 {
1304 finished = true;
1305 }
1306
1307 bitBlt( m_dst, 0, m_height - h, &m_pageTo, m_width - w, 0, w, h );
1308
1309 return finished;
1310}
1311
1312
1313bool KPrPageEffects::effectUncoverRightUp()
1314{
1315 if ( m_effectStep == 0 )
1316 bitBlt( &m_pageFrom, 0, 0, m_dst );
1317
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;
1321
1322 bool finished = false;
1323 if ( h >= m_height )
1324 {
1325 h = m_height;
1326 }
1327 if ( w >= m_width )
1328 {
1329 w = m_width;
1330 }
1331 if ( h >= m_height && w >= m_width )
1332 {
1333 finished = true;
1334 }
1335 // only draw what nesseccary
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 );
1339
1340 return finished;
1341}
1342
1343
1344bool KPrPageEffects::effectCoverRightDown() const
1345{
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;
1349
1350 bool finished = false;
1351 if ( h >= m_height )
1352 {
1353 h = m_height;
1354 }
1355 if ( w >= m_width )
1356 {
1357 w = m_width;
1358 }
1359 if ( h >= m_height && w >= m_width )
1360 {
1361 finished = true;
1362 }
1363
1364 bitBlt( m_dst, 0, 0, &m_pageTo, m_width - w, m_height - h, w, h );
1365
1366 return finished;
1367}
1368
1369
1370bool KPrPageEffects::effectUncoverRightDown()
1371{
1372 if ( m_effectStep == 0 )
1373 bitBlt( &m_pageFrom, 0, 0, m_dst );
1374
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;
1378
1379 bool finished = false;
1380 if ( h >= m_height )
1381 {
1382 h = m_height;
1383 }
1384 if ( w >= m_width )
1385 {
1386 w = m_width;
1387 }
1388 if ( h >= m_height && w >= m_width )
1389 {
1390 finished = true;
1391 }
1392 // only draw what nesseccary
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 );
1396
1397 return finished;
1398}
1399
1400
1401bool KPrPageEffects::effectDissolve()
1402{
1403 KRandomSequence random;
1404
1405 int blockSize = m_height / 32; // small enough
1406 int rowno = ( m_height + blockSize - 1 ) / blockSize;
1407 int colno = ( m_width + blockSize - 1 ) / blockSize;
1408 int cellno = rowno * colno;
1409
1410 if ( m_effectStep == 0 )
1411 {
1412 for( int c = 0; c < cellno; c++ )
1413 m_list.append( c );
1414 }
1415
1416 int steps[] = { 30, 60, 90 };
1417 int dissove = steps[m_speed];
1418 while ( !m_list.isEmpty() && dissove > 0 )
1419 {
1420 --dissove;
1421
1422 int index = random.getLong( m_list.count() );
1423 TQValueListIterator<int> it = m_list.at( index );
1424
1425 unsigned int x = ( *it % colno ) * blockSize;
1426 unsigned int y = ( *it / colno ) * blockSize;
1427
1428 m_list.remove( it );
1429
1430 bitBlt( m_dst, x, y, &m_pageTo, x, y, blockSize, blockSize );
1431 }
1432
1433 return m_list.isEmpty();
1434}
1435
1436
1437bool KPrPageEffects::effectStripesLeftUp() const
1438{
1439 int wSteps = m_width / m_stepWidth + 1;
1440 int hSteps = m_height / m_stepWidth + 1;
1441
1442 int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
1443 int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
1444
1445 bool finished = false;
1446 if ( m_effectStep >= wSteps + hSteps )
1447 {
1448 finished = true;
1449 }
1450
1451 int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
1452
1453 for ( int x = xStart; x >= xStop; --x )
1454 {
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 );
1457 ++y;
1458 }
1459
1460 return finished;
1461}
1462
1463
1464bool KPrPageEffects::effectStripesLeftDown() const
1465{
1466 int wSteps = m_width / m_stepWidth + 1;
1467 int hSteps = m_height / m_stepWidth + 1;
1468
1469 int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
1470 int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
1471
1472 bool finished = false;
1473 if ( m_effectStep >= wSteps + hSteps )
1474 {
1475 finished = true;
1476 }
1477
1478 int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
1479
1480 for ( int x = xStart; x >= xStop; --x )
1481 {
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 );
1484 ++y;
1485 }
1486
1487 return finished;
1488}
1489
1490
1491bool KPrPageEffects::effectStripesRightUp() const
1492{
1493 int wSteps = m_width / m_stepWidth + 1;
1494 int hSteps = m_height / m_stepWidth + 1;
1495
1496 int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
1497 int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
1498
1499 bool finished = false;
1500 if ( m_effectStep >= wSteps + hSteps )
1501 {
1502 finished = true;
1503 }
1504
1505 int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
1506
1507 for ( int x = xStart; x >= xStop; --x )
1508 {
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 );
1511 ++y;
1512 }
1513
1514 return finished;
1515}
1516
1517
1518bool KPrPageEffects::effectStripesRigthDown() const
1519{
1520 int wSteps = m_width / m_stepWidth + 1;
1521 int hSteps = m_height / m_stepWidth + 1;
1522
1523 int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
1524 int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
1525
1526 bool finished = false;
1527 if ( m_effectStep >= wSteps + hSteps )
1528 {
1529 finished = true;
1530 }
1531
1532 int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
1533
1534 for ( int x = xStart; x >= xStop; --x )
1535 {
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 );
1538 ++y;
1539 }
1540
1541 return finished;
1542}
1543
1544
1545bool KPrPageEffects::effectMelting()
1546{
1547 int count = 32;
1548 int max_melt = 2 * m_stepHeight;
1549
1550 if ( m_effectStep == 0 )
1551 {
1552 bitBlt( &m_pageFrom, 0, 0, m_dst );
1553
1554 for( int c = 0; c < count; c++ )
1555 m_list.append( 0 );
1556 }
1557
1558 int w = ( m_width + count - 1 ) / count;
1559
1560 TQValueListIterator<int> it = m_list.begin();
1561
1562 int finished = 32;
1563 for ( int c = 0; c < count; c++ )
1564 {
1565 int x = c * w;
1566
1567 KRandomSequence random;
1568 int grow = 1 + random.getLong( max_melt );
1569
1570 if ( *it + grow >= m_height )
1571 {
1572 grow = m_height - *it;
1573 --finished;
1574 }
1575
1576 if( *it < m_height )
1577 {
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 );
1580
1581 *it += grow;
1582 }
1583 ++it;
1584 }
1585
1586 return finished == 0;
1587}
1588
1589