kpresenter

KPrPageEffects.cpp

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00004    Copyright (C) 2002 Ariya Hidayat <ariya@kde.org>
00005    Copyright (C) 2002 Harri Porten <porten@kde.org>
00006    Copyright (C) 2004 Thorsten Zachmann <zachmann@kde.org>
00007 
00008    This library is free software; you can redistribute it and/or
00009    modify it under the terms of the GNU Library General Public
00010    License as published by the Free Software Foundation; either
00011    version 2 of the License, or (at your option) any later version.
00012 
00013    This library is distributed in the hope that it will be useful,
00014    but WITHOUT ANY WARRANTY; without even the implied warranty of
00015    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016    Library General Public License for more details.
00017 
00018    You should have received a copy of the GNU Library General Public License
00019    along with this library; see the file COPYING.LIB.  If not, write to
00020    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
00022 */
00023 
00024 #include "KPrPageEffects.h"
00025 
00026 #include <qpixmap.h>
00027 #include <qwidget.h>
00028 #include <qwmatrix.h>
00029 
00030 #include <kapplication.h>
00031 #include <kdebug.h>
00032 #include <krandomsequence.h>
00033 
00034 
00035 KPrPageEffects::KPrPageEffects( QPaintDevice *dst, const QPixmap &pageTo, PageEffect effect, EffectSpeed speed )
00036 : m_dst( dst ), m_pageTo( pageTo ), m_pageFrom(m_pageTo.width(),m_pageTo.height()), m_effect(effect), m_speed(speed), m_effectStep(0)
00037 , m_width(m_pageTo.width()), m_height(m_pageTo.height()), m_finished(false)
00038 {
00039     if ( m_effect == PEF_RANDOM )
00040     {
00041         KRandomSequence random;
00042         m_randomEffect = static_cast<PageEffect>( random.getLong( PEF_LAST_MARKER ) );
00043     }
00044     int div[] = { 100, 65, 30 };
00045 
00046     m_stepWidth = (int) ( m_width / div[m_speed] );
00047     m_stepHeight = (int) ( m_height / div[m_speed] );
00048 }
00049 
00050 
00051 KPrPageEffects::~KPrPageEffects()
00052 {
00053 }
00054 
00055 
00056 bool KPrPageEffects::doEffect()
00057 {
00058     if ( !m_finished )
00059     {
00060         PageEffect effect = m_effect == PEF_RANDOM ? m_randomEffect : m_effect;
00061         switch ( effect )
00062         {
00063             case PEF_NONE:
00064                 m_finished = effectNone();
00065                 break;
00066             case PEF_CLOSE_HORZ:
00067                 m_finished = effectCloseHorizontal();
00068                 break;
00069             case PEF_CLOSE_VERT:
00070                 m_finished = effectCloseVertical();
00071                 break;
00072             case PEF_CLOSE_ALL:
00073                 m_finished = effectCloseFromAllDirections();
00074                 break;
00075             case PEF_OPEN_HORZ:
00076                 m_finished = effectOpenHorizontal();
00077                 break;
00078             case PEF_OPEN_VERT:
00079                 m_finished = effectOpenVertical();
00080                 break;
00081             case PEF_OPEN_ALL:
00082                 m_finished = effectOpenFromAllDirections();
00083                 break;
00084             case PEF_INTERLOCKING_HORZ_1:
00085                 m_finished = effectInterlockingHorizontal1();
00086                 break;
00087             case PEF_INTERLOCKING_HORZ_2:
00088                 m_finished = effectInterlockingHorizontal2();
00089                 break;
00090             case PEF_INTERLOCKING_VERT_1:
00091                 m_finished = effectInterlockingVertical1();
00092                 break;
00093             case PEF_INTERLOCKING_VERT_2:
00094                 m_finished = effectInterlockingVertical2();
00095                 break;
00096             case PEF_SURROUND1:
00097                 m_finished = effectSurround1();
00098                 break;
00099             case PEF_FLY1:
00100                 m_finished = effectFlyAway1();
00101                 break;
00102             case PEF_BLINDS_HOR:
00103                 m_finished = effectBlindsHorizontal();
00104                 break;
00105             case PEF_BLINDS_VER:
00106                 m_finished = effectBlindsVertical();
00107                 break;
00108             case PEF_BOX_IN:
00109                 m_finished = effectBoxIn();
00110                 break;
00111             case PEF_BOX_OUT:
00112                 m_finished = effectBoxOut();
00113                 break;
00114             case PEF_CHECKBOARD_ACROSS:
00115                 m_finished = effectCheckboardAcross();
00116                 break;
00117             case PEF_CHECKBOARD_DOWN:
00118                 m_finished = effectCheckboardDown();
00119                 break;
00120             case PEF_COVER_DOWN:
00121                 m_finished = effectCoverDown();
00122                 break;
00123             case PEF_UNCOVER_DOWN:
00124                 m_finished = effectUncoverDown();
00125                 break;
00126             case PEF_COVER_UP:
00127                 m_finished = effectCoverUp();
00128                 break;
00129             case PEF_UNCOVER_UP:
00130                 m_finished = effectUncoverUp();
00131                 break;
00132             case PEF_COVER_LEFT:
00133                 m_finished = effectCoverLeft();
00134                 break;
00135             case PEF_UNCOVER_LEFT:
00136                 m_finished = effectUncoverLeft();
00137                 break;
00138             case PEF_COVER_RIGHT:
00139                 m_finished = effectCoverRight();
00140                 break;
00141             case PEF_UNCOVER_RIGHT:
00142                 m_finished = effectUncoverRight();
00143                 break;
00144             case PEF_COVER_LEFT_UP:
00145                 m_finished = effectCoverLeftUp();
00146                 break;
00147             case PEF_UNCOVER_LEFT_UP:
00148                 m_finished = effectUncoverLeftUp();
00149                 break;
00150             case PEF_COVER_LEFT_DOWN:
00151                 m_finished = effectCoverLeftDown();
00152                 break;
00153             case PEF_UNCOVER_LEFT_DOWN:
00154                 m_finished = effectUncoverLeftDown();
00155                 break;
00156             case PEF_COVER_RIGHT_UP:
00157                 m_finished = effectCoverRightUp();
00158                 break;
00159             case PEF_UNCOVER_RIGHT_UP:
00160                 m_finished = effectUncoverRightUp();
00161                 break;
00162             case PEF_COVER_RIGHT_DOWN:
00163                 m_finished = effectCoverRightDown();
00164                 break;
00165             case PEF_UNCOVER_RIGHT_DOWN:
00166                 m_finished = effectUncoverRightDown();
00167                 break;
00168             case PEF_DISSOLVE:
00169                 m_finished = effectDissolve();
00170                 break;
00171             case PEF_STRIPS_LEFT_UP:
00172                 m_finished = effectStripesLeftUp();
00173                 break;
00174             case PEF_STRIPS_LEFT_DOWN:
00175                 m_finished = effectStripesLeftDown();
00176                 break;
00177             case PEF_STRIPS_RIGHT_UP:
00178                 m_finished = effectStripesRightUp();
00179                 break;
00180             case PEF_STRIPS_RIGHT_DOWN:
00181                 m_finished = effectStripesRigthDown();
00182                 break;
00183             case PEF_MELTING:
00184                 m_finished = effectMelting();
00185                 break;
00186             default:    
00187                 m_finished = effectCloseHorizontal();
00188                 break;
00189         }
00190         ++m_effectStep;
00191     }
00192     return m_finished;
00193 }
00194 
00195 
00196 void KPrPageEffects::finish()
00197 {
00198     if ( !m_finished )
00199     {
00200         bitBlt( m_dst, 0, 0, &m_pageTo );
00201         m_finished = true;
00202     }
00203 }
00204 
00205 
00206 bool KPrPageEffects::effectNone() const
00207 {
00208     bitBlt( m_dst, 0, 0, &m_pageTo );
00209     return true;
00210 }
00211 
00212 
00213 bool KPrPageEffects::effectCloseHorizontal()  const
00214 {
00215     int h = m_effectStep * m_stepHeight;
00216 
00217     bool finished = false;
00218     if ( h >= m_height / 2 )
00219     {
00220         h = m_height / 2;
00221         finished = true;
00222     }
00223 
00224     bitBlt( m_dst, 0, 0, &m_pageTo, 0, m_height / 2 - h, m_width, h );
00225     bitBlt( m_dst, 0, m_height - h, &m_pageTo, 0, m_height / 2, m_width, h );
00226 
00227     return finished;
00228 }
00229 
00230 
00231 bool KPrPageEffects::effectCloseVertical()  const
00232 {
00233     int w = m_effectStep * m_stepWidth;
00234 
00235     bool finished = false;
00236     if ( w >= m_width / 2 )
00237     {
00238         w = m_width / 2;
00239         finished = true;
00240     }
00241 
00242     bitBlt( m_dst, 0, 0, &m_pageTo, m_width / 2 - w, 0, w, m_height );
00243     bitBlt( m_dst, m_width - w, 0, &m_pageTo, m_width / 2, 0, w, m_height );
00244 
00245     return finished;
00246 }
00247 
00248 
00249 bool KPrPageEffects::effectCloseFromAllDirections()  const
00250 {
00251     double fact = (double) m_height / (double) m_width;
00252     int h = (int)( m_effectStep * m_stepWidth * fact );
00253     int w = m_effectStep * m_stepWidth;
00254 
00255     bool finished = false;
00256     if ( h >= m_height / 2 )
00257     {
00258         h = m_height / 2;
00259     }
00260     if ( w >= m_width / 2 )
00261     {
00262         w = m_width / 2;
00263     }
00264     if ( h >= m_height / 2 && w >= m_width / 2 )
00265     {
00266         finished = true;
00267     }
00268 
00269     bitBlt( m_dst, 0, 0, &m_pageTo, m_width / 2 - w, m_height / 2 - h, w, h );
00270     bitBlt( m_dst, m_width - w, 0, &m_pageTo, m_width / 2, m_height / 2 - h, w, h );
00271     bitBlt( m_dst, 0, m_height - h, &m_pageTo, m_width / 2 - w, m_height / 2, w, h );
00272     bitBlt( m_dst, m_width - w, m_height - h, &m_pageTo, m_width / 2, m_height / 2, w, h );
00273 
00274     return finished;
00275 }
00276 
00277 
00278 bool KPrPageEffects::effectOpenHorizontal()  const
00279 {
00280     int h = m_effectStep * m_stepHeight;
00281 
00282     bool finished = false;
00283     if ( h >= m_height / 2 )
00284     {
00285         h = m_height / 2;
00286         finished = true;
00287     }
00288 
00289     bitBlt( m_dst, 0, m_height / 2 - h, &m_pageTo, 0, 0, m_width, h );
00290     bitBlt( m_dst, 0, m_height / 2, &m_pageTo, 0, m_height - h, m_width, h );
00291 
00292     return finished;
00293 }
00294 
00295 
00296 bool KPrPageEffects::effectOpenVertical()  const
00297 {
00298     int w = m_effectStep * m_stepWidth;
00299 
00300     bool finished = false;
00301     if ( w >= m_width / 2 )
00302     {
00303         w = m_width / 2;
00304         finished = true;
00305     }
00306 
00307     bitBlt( m_dst, m_width / 2 - w, 0, &m_pageTo, 0, 0, w, m_height );
00308     bitBlt( m_dst, m_width / 2, 0, &m_pageTo, m_width - w, 0, w, m_height );
00309 
00310     return finished;
00311 }
00312 
00313 
00314 bool KPrPageEffects::effectOpenFromAllDirections()  const
00315 {
00316     double fact = (double) m_height / (double) m_width;
00317     int h = (int)( m_effectStep * m_stepWidth * fact );
00318     int w = m_effectStep * m_stepWidth;
00319 
00320     bool finished = false;
00321     if ( h >= m_height / 2 )
00322     {
00323         h = m_height / 2;
00324     }
00325     if ( w >= m_width / 2 )
00326     {
00327         w = m_width / 2;
00328     }
00329     if ( h >= m_height / 2 && w >= m_width / 2 )
00330     {
00331         finished = true;
00332     }
00333 
00334     bitBlt( m_dst, m_width / 2 - w, m_height / 2 - h, &m_pageTo, 0, 0, w, h );
00335     bitBlt( m_dst, m_width / 2, m_height / 2 - h, &m_pageTo, m_width - w, 0, w, h );
00336     bitBlt( m_dst, m_width / 2 - w, m_height / 2, &m_pageTo, 0, m_height - h, w, h );
00337     bitBlt( m_dst, m_width / 2, m_height / 2, &m_pageTo, m_width - w, m_height - h, w, h );
00338 
00339     return finished;
00340 }
00341 
00342 
00343 bool KPrPageEffects::effectInterlockingHorizontal1() const
00344 {
00345     int w = m_effectStep * m_stepWidth;
00346 
00347     bool finished = false;
00348     if ( w >= m_width  )
00349     {
00350         w = m_width;
00351         finished = true;
00352     }
00353 
00354     int h = m_height / 4;
00355 
00356     bitBlt( m_dst, w, 0, &m_pageTo, w, 0, m_stepWidth, h );
00357     bitBlt( m_dst, m_width - w - m_stepWidth, h, &m_pageTo, m_width - w - m_stepWidth, h, m_stepWidth, h );
00358     bitBlt( m_dst, w, 2 * h, &m_pageTo, w, 2 * h, m_stepWidth, h );
00359     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 );
00360 
00361     return finished;
00362 }
00363 
00364 
00365 bool KPrPageEffects::effectInterlockingHorizontal2() const
00366 {
00367     int w = m_effectStep * m_stepWidth;
00368 
00369     bool finished = false;
00370     if ( w >= m_width  )
00371     {
00372         w = m_width;
00373         finished = true;
00374     }
00375 
00376     int h = m_height / 4;
00377 
00378     bitBlt( m_dst, m_width - w - m_stepWidth, 0, &m_pageTo, m_width - w - m_stepWidth, 0, m_stepWidth, h );
00379     bitBlt( m_dst, w, h, &m_pageTo, w, h, m_stepWidth, h );
00380     bitBlt( m_dst, m_width - w - m_stepWidth, 2 * h, &m_pageTo, m_width - w - m_stepWidth, 2 * h, m_stepWidth, h );
00381     bitBlt( m_dst, w, 3 * h, &m_pageTo, w, 3 * h, m_stepWidth, h );
00382 
00383     return finished;
00384 }
00385 
00386 
00387 bool KPrPageEffects::effectInterlockingVertical1() const
00388 {
00389     int h = m_effectStep * m_stepHeight;
00390 
00391     bool finished = false;
00392     if ( h >= m_height )
00393     {
00394         h = m_height;
00395         finished = true;
00396     }
00397 
00398     int w = m_width / 4;
00399 
00400     bitBlt( m_dst, 0, h, &m_pageTo, 0, h, w, m_stepHeight );
00401     bitBlt( m_dst, w, m_height - h - m_stepHeight, &m_pageTo, w, m_height - h - m_stepHeight, w, m_stepHeight );
00402     bitBlt( m_dst, 2 * w, h, &m_pageTo, 2 * w, h, w, m_stepHeight );
00403     bitBlt( m_dst, 3 * w, m_height - h - m_stepHeight, &m_pageTo, 3 * w, m_height - h - m_stepHeight, w, m_stepHeight );
00404 
00405     return finished;
00406 }
00407 
00408 
00409 bool KPrPageEffects::effectInterlockingVertical2() const
00410 {
00411     int h = m_effectStep * m_stepHeight;
00412 
00413     bool finished = false;
00414     if ( h >= m_height  )
00415     {
00416         h = m_height;
00417         finished = true;
00418     }
00419 
00420     int w = m_width / 4;
00421 
00422     bitBlt( m_dst, 0, m_height - h - m_stepHeight, &m_pageTo, 0, m_height - h - m_stepHeight, w, m_stepHeight );
00423     bitBlt( m_dst, w, h, &m_pageTo, w, h, w, m_stepHeight );
00424     bitBlt( m_dst, 2 * w, m_height - h - m_stepHeight, &m_pageTo, 2 * w, m_height - h - m_stepHeight, w, m_stepHeight );
00425     bitBlt( m_dst, 3 * w, h, &m_pageTo, 3 * w, h, w, m_stepHeight );
00426 
00427     return finished;
00428 }
00429 
00430 
00431 bool KPrPageEffects::effectSurround1() const
00432 {
00433     int div[] = { 20, 15, 10 };
00434     int stepSize = m_height / div[m_speed];
00435     int step = m_effectStep * stepSize;
00436 
00437     int h = m_height / 10;
00438     int w = m_width / 10;
00439     int repaint_h = h;
00440     int repaint_w = w;
00441 
00442     bool finished = false;
00443     bool repaint= false;
00444     int rh = 0;
00445     int rw = 0;
00446     int repaint_rh = 0;
00447     int repaint_rw = 0;
00448 
00449     // 1
00450     if ( step < m_height )
00451     {
00452         rh = step;
00453         rw = 0;
00454         h = stepSize;
00455         if ( step + stepSize >= m_height )
00456         {
00457             repaint = true;
00458 
00459             repaint_rh = m_height - repaint_h;
00460             repaint_rw = step - m_height + repaint_w;
00461             repaint_w = stepSize;
00462         }
00463     }
00464     // 2
00465     else if ( step < m_height + m_width - w )
00466     {
00467         rh = m_height - h;
00468         rw = step - m_height + w;
00469         w = stepSize;
00470         if ( step + stepSize >= m_height + m_width - repaint_w )
00471         {
00472             repaint = true;
00473 
00474             repaint_rh = m_height - ( step - m_height + repaint_h - m_width + repaint_w + stepSize );
00475             repaint_rw = m_width - repaint_w;
00476             repaint_h = stepSize;
00477         }
00478     }
00479     // 3
00480     else if ( step < 2 * m_height - h + m_width - w )
00481     {
00482         rh = m_height - ( step - m_height + h - m_width + w + stepSize );
00483         rw = m_width - w;
00484         h = stepSize;
00485         if ( step + stepSize >=  2 * m_height - repaint_h + m_width - repaint_w )
00486         {
00487             repaint = true;
00488 
00489             repaint_rh = 0;
00490             repaint_rw = m_width - ( step - 2 * m_height + repaint_h - m_width + 2 * repaint_w + stepSize );
00491             repaint_w = stepSize;
00492         }
00493     }
00494     // 4
00495     else if ( step < 2 * m_height - h + 2 * m_width - 3 * w )
00496     {
00497         rh = 0;
00498         rw = m_width - ( step - 2 * m_height + h - m_width + 2 * w + stepSize );
00499         w = stepSize;
00500         if ( step + stepSize >= 2 * m_height - repaint_h + 2 * m_width - 3 * repaint_w )
00501         {
00502             repaint = true;
00503 
00504             repaint_rh = step - 2 * m_height + 2 * repaint_h - 2 * m_width + 3 * repaint_w;
00505             repaint_rw = repaint_w;
00506             repaint_h = stepSize;
00507         }
00508     }
00509     // 5
00510     else if ( step < 3 * m_height - 3 * h + 2 * m_width - 3 * w )
00511     {
00512         rh = step - 2 * m_height + 2 * h - 2 * m_width + 3 * w;
00513         rw = w;
00514         h = stepSize;
00515         if ( step + stepSize >=  3 * m_height - 3 * repaint_h + 2 * m_width - 3 * repaint_w )
00516         {
00517             repaint = true;
00518 
00519             repaint_rh = m_height - 2 * repaint_h;
00520             repaint_rw = step - 3 * m_height + 3 * repaint_h - 2 * m_width + 5 * repaint_w;
00521             repaint_w = stepSize;
00522         }
00523     }
00524     // 6
00525     else if ( step < 3 * m_height - 3 * h + 3 * m_width - 6 * w )
00526     {
00527         rh = m_height - 2 * h;
00528         rw = step - 3 * m_height + 3 * h - 2 * m_width + 5 * w;
00529         w = stepSize;
00530         if ( step + stepSize >= 3 * m_height - 3 * repaint_h + 3 * m_width - 6 * repaint_w )
00531         {
00532             repaint = true;
00533 
00534             repaint_rh = m_height - ( step - 3 * m_height + 5 * repaint_h - 3 * m_width + 6 * repaint_w + stepSize );
00535             repaint_rw = m_width - 2 * repaint_w;
00536             repaint_h = stepSize;
00537         }
00538     }
00539     // 7
00540     else if ( step < 4 * m_height - 6 * h + 3 * m_width - 6 * w )
00541     {
00542         rh = m_height - ( step - 3 * m_height + 5 * h - 3 * m_width + 6 * w + stepSize );
00543         rw = m_width - 2 * w;
00544         h = stepSize;
00545         if ( step + stepSize >= 4 * m_height - 6 * repaint_h + 3 * m_width - 6 * repaint_w )
00546         {
00547             repaint = true;
00548 
00549             repaint_rh = repaint_h;
00550             repaint_rw = m_width - ( step - 4 * m_height + 6 * repaint_h - 3 * m_width + 8 * repaint_w + stepSize );
00551             repaint_w = stepSize;
00552         }
00553     }
00554     // 8
00555     else if ( step < 4 * m_height - 6 * h + 4 * m_width - 10 * w )
00556     {
00557         rh = h;
00558         rw = m_width - ( step - 4 * m_height + 6 * h - 3 * m_width + 8 * w + stepSize );
00559         w = stepSize;
00560         if ( step + stepSize >= 4 * m_height - 6 * repaint_h + 4 * m_width - 10 * repaint_w )
00561         {
00562             repaint = true;
00563 
00564             repaint_rh = step - 4 * m_height + 8 * repaint_h - 4 * m_width + 10 * repaint_w;
00565             repaint_rw = 2 * repaint_w;
00566             repaint_h = stepSize;
00567         }
00568     }
00569     // 9
00570     else if ( step < 5 * m_height - 10 * h + 4 * m_width - 10 * w )
00571     {
00572         rh = step - 4 * m_height + 8 * h - 4 * m_width + 10 * w;
00573         rw = 2 * w;
00574         h = stepSize;
00575         if ( step + stepSize >= 5 * m_height - 10 * repaint_h + 4 * m_width - 10 * repaint_w )
00576         {
00577             repaint = true;
00578 
00579             repaint_rh = m_height - 3 * repaint_h;
00580             repaint_rw = step - 5 * m_height + 10 * repaint_h - 4 * m_width + 13 * repaint_w;
00581             repaint_w = stepSize;
00582         }
00583     }
00584     // 10
00585     else if ( step < 5 * m_height - 10 * h + 5 * m_width - 15 * w )
00586     {
00587         rh = m_height - 3 * h;
00588         rw = step - 5 * m_height + 10 * h - 4 * m_width + 13 * w;
00589         w = stepSize;
00590         if ( step + stepSize >= 5 * m_height - 10 * repaint_h + 5 * m_width - 15 * repaint_w )
00591         {
00592             repaint = true;
00593 
00594             repaint_rh = m_height - ( step - 5 * m_height + 13 * repaint_h - 5 * m_width + 15 * repaint_w + stepSize );
00595             repaint_rw = m_width - 3 * repaint_w;
00596             repaint_h = stepSize;
00597         }
00598     }
00599     // 11
00600     else if ( step < 6 * m_height - 15 * h + 5 * m_width - 15 * w )
00601     {
00602         rh = m_height - ( step - 5 * m_height + 13 * h - 5 * m_width + 15 * w + stepSize );
00603         rw = m_width - 3 * w;
00604         h = stepSize;
00605         if ( step + stepSize >= 6 * m_height - 15 * repaint_h + 5 * m_width - 15 * repaint_w )
00606         {
00607             repaint = true;
00608 
00609             repaint_rh = 2 * repaint_h;
00610             repaint_rw = m_width - ( step - 6 * m_height + 15 * repaint_h - 5 * m_width + 18 * repaint_w + stepSize );
00611             repaint_w = stepSize;
00612         }
00613     }
00614     // 12
00615     else if ( step < 6 * m_height - 15 * h + 6 * m_width - 21 * w )
00616     {
00617         rh = 2 * h;
00618         rw = m_width - ( step - 6 * m_height + 15 * h - 5 * m_width + 18 * w + stepSize );
00619         w = stepSize;
00620         if ( step + stepSize >= 6 * m_height - 15 * repaint_h + 6 * m_width - 21 * repaint_w )
00621         {
00622             repaint = true;
00623 
00624             repaint_rh = step - 6 * m_height + 18 * repaint_h - 6 * m_width + 21 * repaint_w;
00625             repaint_rw = 3 * repaint_w;
00626             repaint_h = stepSize;
00627         }
00628     }
00629     // 13
00630     else if ( step < 7 * m_height - 21 * h + 6 * m_width - 21 * w )
00631     {
00632         rh = step - 6 * m_height + 18 * h - 6 * m_width + 21 * w;
00633         rw = 3 * w;
00634         h = stepSize;
00635         if ( step + stepSize >= 7 * m_height - 21 * repaint_h + 6 * m_width - 21 * repaint_w )
00636         {
00637             repaint = true;
00638 
00639             repaint_rh = m_height - 4 * repaint_h;
00640             repaint_rw = step - 7 * m_height + 21 * repaint_h - 6 * m_width + 25 * repaint_w;
00641             repaint_w = stepSize;
00642         }
00643     }
00644     // 14
00645     else if ( step < 7 * m_height - 21 * h + 7 * m_width - 28 * w )
00646     {
00647         rh = m_height - 4 * h;
00648         rw = step - 7 * m_height + 21 * h - 6 * m_width + 25 * w;
00649         w = stepSize;
00650         if ( step + stepSize >= 7 * m_height - 21 * repaint_h + 7 * m_width - 28 * repaint_w )
00651         {
00652             repaint = true;
00653 
00654             repaint_rh = m_height - ( step - 7 * m_height + 25 * repaint_h - 7 * m_width + 28 * repaint_w + stepSize );
00655             repaint_rw = m_width - 4 * repaint_w;
00656             repaint_h = stepSize;
00657         }
00658     }
00659     // 15
00660     else if ( step < 8 * m_height - 28 * h + 7 * m_width - 28 * w )
00661     {
00662         rh = m_height - ( step - 7 * m_height + 25 * h - 7 * m_width + 28 * w + stepSize );
00663         rw = m_width - 4 * w;
00664         h = stepSize;
00665         if ( step + stepSize >= 8 * m_height - 28 * repaint_h + 7 * m_width - 28 * repaint_w )
00666         {
00667             repaint = true;
00668 
00669             repaint_rh = 3 * repaint_h;
00670             repaint_rw = m_width - ( step - 8 * m_height + 28 * repaint_h - 7 * m_width + 32 * repaint_w + stepSize );
00671             repaint_w = stepSize;
00672         }
00673     }
00674     // 16
00675     else if ( step < 8 * m_height - 28 * h + 8 * m_width - 36 * w )
00676     {
00677         rh = 3 * h;
00678         rw = m_width - ( step - 8 * m_height + 28 * h - 7 * m_width + 32 * w + stepSize );
00679         w = stepSize;
00680         if ( step + stepSize >= 8 * m_height - 28 * repaint_h + 8 * m_width - 36 * repaint_w )
00681         {
00682             repaint = true;
00683 
00684             repaint_rh = step - 8 * m_height + 32 * repaint_h - 8 * m_width + 36 * repaint_w;
00685             repaint_rw = 4 * repaint_w;
00686             repaint_h = stepSize;
00687         }
00688     }
00689     // 17
00690     else if ( step < 9 * m_height - 36 * h + 8 * m_width - 36 * w )
00691     {
00692         rh = step - 8 * m_height + 32 * h - 8 * m_width + 36 * w;
00693         rw = 4 * w;
00694         h = stepSize;
00695         if ( step + stepSize >= 9 * m_height - 36 * repaint_h + 8 * m_width - 36 * repaint_w )
00696         {
00697             repaint = true;
00698 
00699             repaint_rh = m_height - 5 * repaint_h;
00700             repaint_rw = step - 9 * m_height + 36 * repaint_h - 8 * m_width + 41 * repaint_w;
00701             repaint_w = stepSize;
00702         }
00703     }
00704     // 18
00705     else if ( step < 9 * m_height - 36 * h + 9 * m_width - 45 * w )
00706     {
00707         rh = m_height - 5 * h;
00708         rw = step - 9 * m_height + 36 * h - 8 * m_width + 41 * w;
00709         w = stepSize;
00710         if ( step + stepSize >= 9 * m_height - 36 * repaint_h + 9 * m_width - 45 * repaint_w )
00711         {
00712             repaint = true;
00713 
00714             repaint_rh = m_height - ( step - 9 * m_height + 41 * repaint_h - 9 * m_width + 45 * repaint_w + stepSize );
00715             repaint_rw = m_width - 5 * repaint_w;
00716             repaint_h = stepSize;
00717         }
00718     }
00719     // 19
00720     else if ( step < 10 * m_height - 45 * h + 9 * m_width - 45 * w )
00721     {
00722         rh = m_height - ( step - 9 * m_height + 41 * h - 9 * m_width + 45 * w + stepSize );
00723         rw = m_width - 5 * w;
00724         h = stepSize;
00725     }
00726     // 20
00727     /*else if ( step < 8 * m_height - 28 * h + 8 * m_width - 36 * w )
00728     {
00729         rh = 3 * h;
00730         rw = m_width - ( step - 8 * m_height + 28 * h - 7 * m_width + 32 * w + stepSize );
00731         w = stepSize;
00732     }*/
00733     else
00734     {
00735         finished = true;
00736     }
00737 
00738     bitBlt( m_dst, rw, rh, &m_pageTo, rw, rh, w, h );
00739 
00740     if ( repaint )
00741     {
00742         bitBlt( m_dst, repaint_rw, repaint_rh, &m_pageTo, repaint_rw, repaint_rh, repaint_w, repaint_h );
00743     }
00744 
00745     return finished;
00746 }
00747 
00748 
00749 bool KPrPageEffects::effectFlyAway1()
00750 {
00751     bool finished = false;
00752     int steps[] = { 20, 15, 10 };
00753     int pSteps = steps[m_speed];
00754 
00755     if ( m_effectStep == 0 )
00756     {
00757         bitBlt( &m_pageFrom, 0, 0, m_dst );
00758         m_list.append( m_width );
00759         m_list.append( m_height );
00760         m_list.append( 0 );
00761         m_list.append( 0 );
00762     }
00763     else if ( m_effectStep <= pSteps )
00764     {
00765         double dw = 1.0 - 83.0 / 100.0 * m_effectStep / (double)pSteps;
00766 
00767         QWMatrix m;
00768         m.scale( dw, dw );
00769         QPixmap pix( m_pageFrom.xForm( m ) );
00770 
00771         if ( m_effectStep == pSteps )
00772             m_pageFrom = pix;
00773         
00774         int w = pix.width();
00775         int h = pix.height();
00776         int x = ( m_width - w ) / 2;
00777         int y = ( m_height - h ) / 2;
00778 
00779         int ow = *(m_list.at(0));
00780         int oh = *(m_list.at(1));
00781         int ox = *(m_list.at(2));
00782         int oy = *(m_list.at(3));
00783         
00784         bitBlt( m_dst, x, y, &pix, 0, 0 , w, h );
00785         // top
00786         bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, ow, y - oy );
00787         // left
00788         bitBlt( m_dst, ox, y, &m_pageTo, ox, y, x - ox, h );
00789         // right
00790         bitBlt( m_dst, x + w, y, &m_pageTo, x + w, y, ( ow - w + 1 ) / 2, h );
00791         // bottom
00792         bitBlt( m_dst, ox, y + h, &m_pageTo, ox, y + h, ow, ( oh - h + 1 ) / 2 );
00793         
00794         *(m_list.at(0)) = w;
00795         *(m_list.at(1)) = h;
00796         *(m_list.at(2)) = x;
00797         *(m_list.at(3)) = y;
00798     }
00799     else if ( m_effectStep <= 2 * pSteps )
00800     {
00801         int w = m_pageFrom.width();
00802         int h = m_pageFrom.height();
00803         int x = ( m_width - w ) / 2;
00804         int y = ( m_height - h ) / 2 - ( m_height - h ) / 2 * ( m_effectStep - pSteps ) / pSteps;
00805 
00806         int oy = *(m_list.at(3));
00807 
00808         bitBlt( m_dst, x, y, &m_pageFrom, 0, 0 , w, h );
00809         bitBlt( m_dst, x, y + h, &m_pageTo, x, y + h, w, oy - y);
00810 
00811         *(m_list.at(3)) = y;
00812     }
00813     else if ( m_effectStep <= 3 * pSteps )
00814     {
00815         int w = m_pageFrom.width();
00816         int h = m_pageFrom.height();
00817         int x = ( m_width - w ) / 2 - ( m_width - w ) / 2 * ( m_effectStep - 2 * pSteps ) / pSteps;
00818         int y = ( m_height - h ) / 2 * ( m_effectStep - 2 * pSteps ) / pSteps;
00819 
00820         int ox = *(m_list.at(2));
00821         int oy = *(m_list.at(3));
00822 
00823         bitBlt( m_dst, x, y, &m_pageFrom, 0, 0 , w, h );
00824         bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, w, y - oy);
00825         bitBlt( m_dst, x + w, oy, &m_pageTo, x + w, oy, x - ox, h );
00826 
00827         *(m_list.at(2)) = x;
00828         *(m_list.at(3)) = y;
00829     }
00830     else 
00831     {
00832         int w = m_pageFrom.width();
00833         int h = m_pageFrom.height();
00834         int x = ( m_width - w ) / 2 * ( m_effectStep - 3 * pSteps ) / pSteps;
00835         int y = ( m_height - h ) / 2 * ( m_effectStep - 2 * pSteps ) / pSteps;
00836 
00837         int ox = *(m_list.at(2));
00838         int oy = *(m_list.at(3));
00839 
00840         bitBlt( m_dst, x, y, &m_pageFrom, 0, 0 , w, h );
00841         bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, w, y - oy);
00842         bitBlt( m_dst, ox, oy, &m_pageTo, ox, oy, x - ox, h );
00843 
00844         if ( x >= m_height )
00845         {
00846             finished = true;
00847         }
00848         else
00849         {
00850             *(m_list.at(2)) = x;
00851             *(m_list.at(3)) = y;
00852         }
00853     }
00854       
00855     return finished;
00856 }
00857 
00858 
00859 bool KPrPageEffects::effectBlindsHorizontal() const
00860 {
00861     int h = m_effectStep * m_stepHeight;
00862     int blockSize = m_height / 8;
00863 
00864     bool finished = false;
00865     if ( h >= blockSize )
00866     {
00867         h = blockSize;
00868         finished = true;
00869     }
00870 
00871     for ( int i=0; i < m_height; i += blockSize )
00872         bitBlt( m_dst, 0, h + i, &m_pageTo, 0, h + i, m_width, m_stepHeight );
00873 
00874     return finished;
00875 }
00876 
00877 
00878 bool KPrPageEffects::effectBlindsVertical() const
00879 {
00880     int w = m_effectStep * m_stepWidth;
00881     int blockSize = m_width / 8;
00882 
00883     bool finished = false;
00884     if ( w >= blockSize )
00885     {
00886         w = blockSize;
00887         finished = true;
00888     }
00889 
00890     for ( int i=0; i < m_width; i += blockSize )
00891         bitBlt( m_dst, w + i, 0, &m_pageTo, w + i, 0, m_stepWidth, m_height );
00892 
00893     return finished;
00894 }
00895 
00896 
00897 bool KPrPageEffects::effectBoxIn() const
00898 {
00899     double fact = (double) m_height / (double) m_width;
00900     int h = (int)( m_effectStep * m_stepWidth * fact );
00901     int stepHeight = (int)( ( m_effectStep + 1 ) * m_stepWidth * fact - h );
00902     int w = m_effectStep * m_stepWidth;
00903 
00904     bool finished = false;
00905     if ( h >= m_height / 2 )
00906     {
00907         h = m_height / 2;
00908     }
00909     if ( w >= m_width / 2 )
00910     {
00911         w = m_width / 2;
00912     }
00913     if ( h >= m_height / 2 && w >= m_width / 2 )
00914     {
00915         finished = true;
00916     }
00917 
00918     // top
00919     bitBlt( m_dst, w, h, &m_pageTo, w, h, m_width - 2 * w, stepHeight );
00920     // left
00921     bitBlt( m_dst, w, h, &m_pageTo, w, h, m_stepWidth, m_height - 2 * h );
00922     //right
00923     bitBlt( m_dst, m_width - w, h, &m_pageTo, m_width - w, h, m_stepWidth, m_height - 2 * h );
00924     // bottom
00925     bitBlt( m_dst, w, m_height - h - stepHeight, &m_pageTo, w, m_height - h - stepHeight, m_width - 2 * w, stepHeight );
00926 
00927     return finished;
00928 }
00929 
00930 
00931 bool KPrPageEffects::effectBoxOut() const
00932 {
00933     double fact = (double) m_height / (double) m_width;
00934     int h = (int)( m_effectStep * m_stepWidth * fact );
00935     int stepHeight = (int)( ( m_effectStep + 1 ) * m_stepWidth * fact - h );
00936     int w = m_effectStep * m_stepWidth;
00937 
00938     bool finished = false;
00939     if ( h >= m_height / 2 )
00940     {
00941         h = m_height / 2;
00942     }
00943     if ( w >= m_width / 2 )
00944     {
00945         w = m_width / 2;
00946     }
00947     if ( h >= m_height / 2 && w >= m_width / 2 )
00948     {
00949         finished = true;
00950     }
00951 
00952     bitBlt( m_dst, m_width / 2 - w - m_stepWidth, m_height / 2 - h - stepHeight, 
00953             &m_pageTo, m_width / 2 - w - m_stepWidth, m_height / 2 - h - stepHeight, 2 * ( w + m_stepWidth ), stepHeight );
00954     bitBlt( m_dst, m_width / 2 - w - m_stepWidth, m_height / 2 - h, 
00955             &m_pageTo, m_width / 2 - w - m_stepWidth, m_height / 2 - h, m_stepWidth, 2 * h );
00956     bitBlt( m_dst, m_width / 2 + w, m_height / 2 - h, 
00957            &m_pageTo, m_width / 2 + w, m_height / 2 - h, m_stepWidth, 2 * h );
00958     bitBlt( m_dst, m_width / 2 - w - m_stepWidth, m_height / 2 + h, 
00959             &m_pageTo, m_width / 2 - w - m_stepWidth, m_height / 2 + h, 2 * ( w + m_stepWidth), stepHeight );
00960 
00961     return finished;
00962 }
00963 
00964 
00965 bool KPrPageEffects::effectCheckboardAcross() const
00966 {
00967     int w = m_effectStep * m_stepWidth;
00968     int blockSize = m_height / 8;
00969 
00970     bool finished = false;
00971     if ( w >= blockSize * 2 )
00972     {
00973         w = blockSize * 2;
00974         finished = true;
00975     }
00976 
00977     for ( int y = 0; y < m_height; y += blockSize )
00978     {
00979         int x = ( ( y / blockSize ) & 1 ) * blockSize;
00980 
00981         if ( x == blockSize && w >= blockSize - m_stepWidth )
00982             bitBlt( m_dst, w - blockSize, y, &m_pageTo, w - blockSize, y, m_stepWidth, blockSize );
00983 
00984         for ( ; x < m_width; x += 2 * blockSize )
00985         {
00986             bitBlt( m_dst, x + w, y, &m_pageTo, x + w, y, m_stepWidth, blockSize );
00987         }
00988     }
00989 
00990     return finished;
00991 }
00992 
00993 
00994 bool KPrPageEffects::effectCheckboardDown() const
00995 {
00996     int h = m_effectStep * m_stepHeight;
00997     int blockSize = m_height / 8;
00998 
00999     bool finished = false;
01000     if ( h >= blockSize * 2 )
01001     {
01002         h = blockSize * 2;
01003         finished = true;
01004     }
01005 
01006     for ( int x = 0; x < m_width; x += blockSize )
01007     {
01008         int y = ( ( x / blockSize ) & 1 ) * blockSize;
01009 
01010         if ( y == blockSize && h >= blockSize - m_stepHeight )
01011             bitBlt( m_dst, x, h - blockSize, &m_pageTo, x, h - blockSize, blockSize, m_stepHeight );
01012 
01013         for ( ; y < m_width; y += 2 * blockSize )
01014         {
01015             bitBlt( m_dst, x, y + h, &m_pageTo, x, y + h, blockSize, m_stepHeight );
01016         }
01017     }
01018 
01019     return finished;
01020 }
01021 
01022 
01023 bool KPrPageEffects::effectCoverDown() const
01024 {
01025     int h = m_effectStep * m_stepHeight;
01026 
01027     bool finished = false;
01028     if ( h >= m_height )
01029     {
01030         h = m_height;
01031         finished = true;
01032     }
01033 
01034     bitBlt( m_dst, 0, 0, &m_pageTo, 0, m_height - h, m_width, h );
01035 
01036     return finished;
01037 }
01038 
01039 
01040 bool KPrPageEffects::effectUncoverDown() const
01041 {
01042     int h = m_effectStep * m_stepHeight;
01043 
01044     bool finished = false;
01045     if ( h >= m_height )
01046     {
01047         h = m_height;
01048         finished = true;
01049     }
01050 
01051     bitBlt( m_dst, 0, h + m_stepHeight, m_dst, 0, h, m_width, m_height - h - m_stepHeight );
01052     bitBlt( m_dst, 0, h, &m_pageTo, 0, h, m_width, m_stepHeight );
01053 
01054     return finished;
01055 }
01056 
01057 
01058 bool KPrPageEffects::effectCoverUp() const
01059 {
01060     int h = m_effectStep * m_stepHeight;
01061 
01062     bool finished = false;
01063     if ( h >= m_height )
01064     {
01065         h = m_height;
01066         finished = true;
01067     }
01068 
01069     bitBlt( m_dst, 0, m_height - h, &m_pageTo, 0, 0, m_width, h );
01070 
01071     return finished;
01072 }
01073 
01074 
01075 bool KPrPageEffects::effectUncoverUp()
01076 {
01077     if ( m_effectStep == 0 )
01078         bitBlt( &m_pageFrom, 0, 0, m_dst );
01079 
01080     int h = m_effectStep * m_stepHeight;
01081 
01082     bool finished = false;
01083     if ( h >= m_height )
01084     {
01085         h = m_height;
01086         finished = true;
01087     }
01088 
01089     bitBlt( m_dst, 0, 0, &m_pageFrom, 0, h + m_stepHeight, m_width, m_height - h - m_stepHeight );
01090     bitBlt( m_dst, 0, m_height - h - m_stepHeight, &m_pageTo, 0, m_height - h - m_stepHeight, m_width, m_stepHeight );
01091 
01092     return finished;
01093 }
01094 
01095 
01096 bool KPrPageEffects::effectCoverLeft() const
01097 {
01098     int w = m_effectStep * m_stepHeight;
01099 
01100     bool finished = false;
01101     if ( w >= m_width )
01102     {
01103         w = m_width;
01104         finished = true;
01105     }
01106 
01107     bitBlt( m_dst, m_width - w, 0, &m_pageTo, 0, 0, w, m_height );
01108 
01109     return finished;
01110 }
01111 
01112 
01113 bool KPrPageEffects::effectUncoverLeft()
01114 {
01115     if ( m_effectStep == 0 )
01116         bitBlt( &m_pageFrom, 0, 0, m_dst );
01117 
01118     int w = m_effectStep * m_stepWidth;
01119 
01120     bool finished = false;
01121     if ( w >= m_width )
01122     {
01123         w = m_width;
01124         finished = true;
01125     }
01126 
01127     bitBlt( m_dst, 0, 0, &m_pageFrom, w + m_stepWidth, 0, m_width - w - m_stepWidth, m_height );
01128     bitBlt( m_dst, m_width - w - m_stepWidth, 0, &m_pageTo, m_width - w - m_stepWidth, 0, m_stepWidth, m_height );
01129 
01130     return finished;
01131 }
01132 
01133 
01134 bool KPrPageEffects::effectCoverRight() const
01135 {
01136     int w = m_effectStep * m_stepWidth;
01137 
01138     bool finished = false;
01139     if ( w >= m_width )
01140     {
01141         w = m_width;
01142         finished = true;
01143     }
01144 
01145     bitBlt( m_dst, 0, 0, &m_pageTo, m_width - w, 0, w, m_height );
01146 
01147     return finished;
01148 }
01149 
01150 
01151 bool KPrPageEffects::effectUncoverRight()
01152 {
01153     if ( m_effectStep == 0 )
01154         bitBlt( &m_pageFrom, 0, 0, m_dst );
01155 
01156     int w = m_effectStep * m_stepWidth;
01157 
01158     bool finished = false;
01159     if ( w >= m_width )
01160     {
01161         w = m_width;
01162         finished = true;
01163     }
01164 
01165     bitBlt( m_dst, w + m_stepWidth, 0, &m_pageFrom, 0, 0, m_width - w - m_stepWidth, m_height );
01166     bitBlt( m_dst, w, 0, &m_pageTo, w, 0, m_stepWidth, m_height );
01167 
01168     return finished;
01169 }
01170 
01171 
01172 bool KPrPageEffects::effectCoverLeftUp() const
01173 {
01174     double fact = (double) m_height / (double) m_width;
01175     int h = (int)( m_effectStep * m_stepWidth * fact );
01176     int w = m_effectStep * m_stepWidth;
01177 
01178     bool finished = false;
01179     if ( h >= m_height )
01180     {
01181         h = m_height;
01182     }
01183     if ( w >= m_width )
01184     {
01185         w = m_width;
01186     }
01187     if ( h >= m_height && w >= m_width )
01188     {
01189         finished = true;
01190     }
01191 
01192     bitBlt( m_dst, m_width - w, m_height - h, &m_pageTo, 0, 0, w, h );
01193 
01194     return finished;
01195 }
01196 
01197 
01198 bool KPrPageEffects::effectUncoverLeftUp()
01199 {
01200     if ( m_effectStep == 0 )
01201         bitBlt( &m_pageFrom, 0, 0, m_dst );
01202 
01203     double fact = (double) m_height / (double) m_width;
01204     int h = (int)( m_effectStep * m_stepWidth * fact );
01205     int w = m_effectStep * m_stepWidth;
01206 
01207     bool finished = false;
01208     if ( h >= m_height )
01209     {
01210         h = m_height;
01211     }
01212     if ( w >= m_width )
01213     {
01214         w = m_width;
01215     }
01216     if ( h >= m_height && w >= m_width )
01217     {
01218         finished = true;
01219     }
01220 
01221     // fix only copy what is nesseccary
01222     bitBlt( m_dst, 0, 0, &m_pageFrom, w, h, m_width - w, m_height - h );
01223     bitBlt( m_dst, m_width - w, 0, &m_pageTo, m_width - w, 0, w, m_height );
01224     bitBlt( m_dst, 0, m_height - h, &m_pageTo, 0, m_height - h, m_width, h );
01225 
01226     return finished;
01227 }
01228 
01229 
01230 bool KPrPageEffects::effectCoverLeftDown() const
01231 {
01232     double fact = (double) m_height / (double) m_width;
01233     int h = (int)( m_effectStep * m_stepWidth * fact );
01234     int w = m_effectStep * m_stepWidth;
01235 
01236     bool finished = false;
01237     if ( h >= m_height )
01238     {
01239         h = m_height;
01240     }
01241     if ( w >= m_width )
01242     {
01243         w = m_width;
01244     }
01245     if ( h >= m_height && w >= m_width )
01246     {
01247         finished = true;
01248     }
01249 
01250     bitBlt( m_dst, m_width - w, 0, &m_pageTo, 0, m_height - h, w, h );
01251 
01252     return finished;
01253 }
01254 
01255 
01256 bool KPrPageEffects::effectUncoverLeftDown()
01257 {
01258     if ( m_effectStep == 0 )
01259         bitBlt( &m_pageFrom, 0, 0, m_dst );
01260 
01261     double fact = (double) m_height / (double) m_width;
01262     int h = (int)( m_effectStep * m_stepWidth * fact );
01263     int w = m_effectStep * m_stepWidth;
01264 
01265     bool finished = false;
01266     if ( h >= m_height )
01267     {
01268         h = m_height;
01269     }
01270     if ( w >= m_width )
01271     {
01272         w = m_width;
01273     }
01274     if ( h >= m_height && w >= m_width )
01275     {
01276         finished = true;
01277     }
01278 
01279     // fix only copy what is nesseccary
01280     bitBlt( m_dst, 0, h, &m_pageFrom, w, 0, m_width - w, m_height - h );
01281     bitBlt( m_dst, 0, 0, &m_pageTo, 0, 0, m_width, h );
01282     bitBlt( m_dst, m_width - w, h, &m_pageTo, m_width - w, h, w, m_height - h );
01283 
01284     return finished;
01285 }
01286 
01287 
01288 bool KPrPageEffects::effectCoverRightUp() const
01289 {
01290     double fact = (double) m_height / (double) m_width;
01291     int h = (int)( m_effectStep * m_stepWidth * fact );
01292     int w = m_effectStep * m_stepWidth;
01293 
01294     bool finished = false;
01295     if ( h >= m_height )
01296     {
01297         h = m_height;
01298     }
01299     if ( w >= m_width )
01300     {
01301         w = m_width;
01302     }
01303     if ( h >= m_height && w >= m_width )
01304     {
01305         finished = true;
01306     }
01307 
01308     bitBlt( m_dst, 0, m_height - h, &m_pageTo, m_width - w, 0, w, h );
01309 
01310     return finished;
01311 }
01312 
01313 
01314 bool KPrPageEffects::effectUncoverRightUp()
01315 {
01316     if ( m_effectStep == 0 )
01317         bitBlt( &m_pageFrom, 0, 0, m_dst );
01318 
01319     double fact = (double) m_height / (double) m_width;
01320     int h = (int)( m_effectStep * m_stepWidth * fact );
01321     int w = m_effectStep * m_stepWidth;
01322 
01323     bool finished = false;
01324     if ( h >= m_height )
01325     {
01326         h = m_height;
01327     }
01328     if ( w >= m_width )
01329     {
01330         w = m_width;
01331     }
01332     if ( h >= m_height && w >= m_width )
01333     {
01334         finished = true;
01335     }
01336     // only draw what nesseccary
01337     bitBlt( m_dst, w, 0, &m_pageFrom, 0, h, m_width - w, m_height - h );
01338     bitBlt( m_dst, 0, 0, &m_pageTo, 0, 0, w, m_height );
01339     bitBlt( m_dst, w, m_height - h, &m_pageTo, w, m_height - h, m_width - w, h );
01340 
01341     return finished;
01342 }
01343 
01344 
01345 bool KPrPageEffects::effectCoverRightDown() const
01346 {
01347     double fact = (double) m_height / (double) m_width;
01348     int h = (int)( m_effectStep * m_stepWidth * fact );
01349     int w = m_effectStep * m_stepWidth;
01350 
01351     bool finished = false;
01352     if ( h >= m_height )
01353     {
01354         h = m_height;
01355     }
01356     if ( w >= m_width )
01357     {
01358         w = m_width;
01359     }
01360     if ( h >= m_height && w >= m_width )
01361     {
01362         finished = true;
01363     }
01364 
01365     bitBlt( m_dst, 0, 0, &m_pageTo, m_width - w, m_height - h, w, h );
01366 
01367     return finished;
01368 }
01369 
01370 
01371 bool KPrPageEffects::effectUncoverRightDown()
01372 {
01373     if ( m_effectStep == 0 )
01374         bitBlt( &m_pageFrom, 0, 0, m_dst );
01375 
01376     double fact = (double) m_height / (double) m_width;
01377     int h = (int)( m_effectStep * m_stepWidth * fact );
01378     int w = m_effectStep * m_stepWidth;
01379 
01380     bool finished = false;
01381     if ( h >= m_height )
01382     {
01383         h = m_height;
01384     }
01385     if ( w >= m_width )
01386     {
01387         w = m_width;
01388     }
01389     if ( h >= m_height && w >= m_width )
01390     {
01391         finished = true;
01392     }
01393     // only draw what nesseccary
01394     bitBlt( m_dst, w, h, &m_pageFrom, 0, 0, m_width - w, m_height - h );
01395     bitBlt( m_dst, 0, 0, &m_pageTo, 0, 0, m_width, h );
01396     bitBlt( m_dst, 0, h, &m_pageTo, 0, h, w, m_height - h );
01397 
01398     return finished;
01399 }
01400 
01401 
01402 bool KPrPageEffects::effectDissolve()
01403 {
01404     KRandomSequence random;
01405 
01406     int blockSize = m_height / 32; // small enough
01407     int rowno = ( m_height + blockSize - 1 ) / blockSize;
01408     int colno = ( m_width + blockSize - 1 ) / blockSize;
01409     int cellno = rowno * colno;
01410   
01411     if ( m_effectStep == 0 )
01412     {
01413         for( int c = 0; c < cellno; c++ )
01414             m_list.append( c );
01415     }
01416 
01417     int steps[] = { 30, 60, 90 };
01418     int dissove = steps[m_speed];
01419     while ( !m_list.isEmpty() && dissove > 0 )
01420     {
01421         --dissove;
01422 
01423         int index = random.getLong( m_list.count() );
01424         QValueListIterator<int> it = m_list.at( index );
01425         
01426         unsigned int x = ( *it % colno ) * blockSize;
01427         unsigned int y = ( *it / colno ) * blockSize;
01428 
01429         m_list.remove( it );
01430 
01431         bitBlt( m_dst, x, y, &m_pageTo, x, y, blockSize, blockSize );
01432     }
01433 
01434     return m_list.isEmpty();
01435 }
01436 
01437 
01438 bool KPrPageEffects::effectStripesLeftUp() const
01439 {
01440     int wSteps = m_width / m_stepWidth + 1;
01441     int hSteps = m_height / m_stepWidth + 1;
01442 
01443     int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
01444     int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
01445 
01446     bool finished = false;
01447     if ( m_effectStep >= wSteps + hSteps )
01448     {
01449         finished = true;
01450     }
01451 
01452     int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
01453 
01454     for ( int x = xStart; x >= xStop; --x )
01455     {
01456         bitBlt( m_dst, m_width - x * m_stepWidth, m_height - y * m_stepWidth,
01457                 &m_pageTo, m_width - x * m_stepWidth, m_height - y * m_stepWidth , m_stepWidth, m_stepWidth );
01458         ++y;
01459     }
01460 
01461     return finished;
01462 }
01463 
01464 
01465 bool KPrPageEffects::effectStripesLeftDown() const
01466 {
01467     int wSteps = m_width / m_stepWidth + 1;
01468     int hSteps = m_height / m_stepWidth + 1;
01469 
01470     int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
01471     int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
01472 
01473     bool finished = false;
01474     if ( m_effectStep >= wSteps + hSteps )
01475     {
01476         finished = true;
01477     }
01478 
01479     int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
01480 
01481     for ( int x = xStart; x >= xStop; --x )
01482     {
01483         bitBlt( m_dst, m_width - x * m_stepWidth, ( y - 1 ) * m_stepWidth,
01484                 &m_pageTo, m_width - x * m_stepWidth, ( y - 1 ) * m_stepWidth , m_stepWidth, m_stepWidth );
01485         ++y;
01486     }
01487 
01488     return finished;
01489 }
01490 
01491 
01492 bool KPrPageEffects::effectStripesRightUp() const
01493 {
01494     int wSteps = m_width / m_stepWidth + 1;
01495     int hSteps = m_height / m_stepWidth + 1;
01496 
01497     int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
01498     int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
01499 
01500     bool finished = false;
01501     if ( m_effectStep >= wSteps + hSteps )
01502     {
01503         finished = true;
01504     }
01505 
01506     int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
01507 
01508     for ( int x = xStart; x >= xStop; --x )
01509     {
01510         bitBlt( m_dst, ( x - 1 ) * m_stepWidth, m_height - y * m_stepWidth,
01511                 &m_pageTo, ( x - 1 ) * m_stepWidth, m_height - y * m_stepWidth , m_stepWidth, m_stepWidth );
01512         ++y;
01513     }
01514 
01515     return finished;
01516 }
01517 
01518 
01519 bool KPrPageEffects::effectStripesRigthDown() const
01520 {
01521     int wSteps = m_width / m_stepWidth + 1;
01522     int hSteps = m_height / m_stepWidth + 1;
01523 
01524     int xStart = m_effectStep < wSteps ? m_effectStep : wSteps;
01525     int xStop = 1 > m_effectStep - hSteps + 1 ? 1 : m_effectStep - hSteps + 1;
01526 
01527     bool finished = false;
01528     if ( m_effectStep >= wSteps + hSteps )
01529     {
01530         finished = true;
01531     }
01532 
01533     int y = m_effectStep - wSteps + 1 > 1 ? m_effectStep - wSteps + 1 : 1;
01534 
01535     for ( int x = xStart; x >= xStop; --x )
01536     {
01537         bitBlt( m_dst, ( x - 1 ) * m_stepWidth, ( y - 1 ) * m_stepWidth,
01538                 &m_pageTo, ( x - 1 ) * m_stepWidth, ( y - 1 ) * m_stepWidth , m_stepWidth, m_stepWidth );
01539         ++y;
01540     }
01541 
01542     return finished;
01543 }
01544 
01545 
01546 bool KPrPageEffects::effectMelting()
01547 {
01548     int count = 32;
01549     int max_melt = 2 * m_stepHeight;
01550 
01551     if ( m_effectStep == 0 )
01552     {
01553         bitBlt( &m_pageFrom, 0, 0, m_dst );
01554 
01555         for( int c = 0; c < count; c++ )
01556             m_list.append( 0 );
01557     }
01558 
01559     int w = ( m_width + count - 1 ) / count;
01560 
01561     QValueListIterator<int> it = m_list.begin();
01562 
01563     int finished = 32;
01564     for ( int c = 0; c < count; c++ )
01565     {
01566         int x = c * w;
01567 
01568         KRandomSequence random;
01569         int grow = 1 + random.getLong( max_melt );
01570 
01571         if ( *it + grow >= m_height )
01572         {
01573             grow = m_height - *it;
01574             --finished;
01575         }
01576 
01577         if( *it < m_height )
01578         {
01579             bitBlt( m_dst, x, *it, &m_pageTo, x, *it, w, grow );
01580             bitBlt( m_dst, x, *it + grow, &m_pageFrom, x, 0, w, m_height - *it - grow );
01581 
01582             *it += grow;
01583         }
01584         ++it;
01585     }
01586     
01587     return finished == 0;
01588 }
01589 
01590 
KDE Home | KDE Accessibility Home | Description of Access Keys