webengine/pagescaler/src/minimap.cpp
changeset 0 dd21522fd290
child 17 c8a366e56285
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "minimap.h"
       
    22 
       
    23 #include <fbs.h>
       
    24 #include <gdi.h>
       
    25 #include <bitstd.h>
       
    26 #include <w32std.h>
       
    27 #include <coecntrl.h>
       
    28 
       
    29 #include "minimapgenerator.h"
       
    30 #include "minimaptimer.h"
       
    31 
       
    32 // MACROS
       
    33 
       
    34 // EXTERNAL DATA STRUCTURES
       
    35 
       
    36 // EXTERNAL FUNCTION PROTOTYPES
       
    37 
       
    38 // CONSTANTS
       
    39 
       
    40 const TInt KDefaultZoomOutPercent = 325; // 3.0x minimap zoom out by default
       
    41 
       
    42 //const TInt KDefaultTransparency = 15; // % transparent
       
    43 // This is the transparency that is the starting point in fade effect
       
    44 const TInt KDefaultTransparency = 95; // % transparent
       
    45 // This is the transparency that is visible when the fade effect is finished and the minimap is on
       
    46 const TInt KDefaultViewingTransparency = 15; // % transparent
       
    47 // Higher the KFadeEffectSpeed, the faster the fade effect. This tells directly 
       
    48 // how much the percentage amount the transparency of the minimap is changed 
       
    49 // every 0.03 second when the fade effect is shown.
       
    50 // The suitable value depends on the performance of the hardware
       
    51 // but if you consider a pure emulator, 5 is fine for the KFadeEffectSpeed
       
    52 // but for example in Nokia E50 device something like 10 looks about the same.
       
    53 const TInt KFadeEffectSpeed = 5;
       
    54 // How often updated
       
    55 const TInt KUpdateFreq = 30000;// 0.03 second
       
    56 
       
    57 const TInt KDefaultWidthPercent = 67;
       
    58 const TInt KDefaultHeightPercent = 78;
       
    59 const TInt KDefaultOffsetX = 0;
       
    60 const TInt KDefaultOffsetY = 3;
       
    61 const CPageScaler::TPosition KDefaultPosition = CPageScaler::ETopRight;
       
    62 
       
    63 
       
    64 const TInt KBorderWidthPermille = 20; // width of the border
       
    65 const TInt KMaxBorderAlpha = 128; // how dark is the shadow around the minimap
       
    66 // defines a box relative to minimap edges. if view center goes outside this box
       
    67 // the view is recentered (50%==always center)
       
    68 const TInt KHScrollAreaPercent = 33; // horizontal distance in percent
       
    69 const TInt KVScrollAreaPercent = 50; // verical distance in percent
       
    70 const TInt KHScrollAreaPercentWithTouch1 = 20; // horizontal distance in percent when to scrol
       
    71 const TInt KVScrollAreaPercentWithTouch1 = 20; // verical distance in percent when to scrol
       
    72 const TInt KHScrollAreaPercentWithTouch2 = 25; // horizontal distance in percent amount to scroll (scroll to the right only)
       
    73 const TInt KVScrollAreaPercentWithTouch2 = 25; // verical distance in percent amount to scroll (scroll up only)
       
    74 const TInt KUpdateDelayComplete = 45000000; // 45s
       
    75 const TInt KUpdateDelayLoading = 7000000; // 7s
       
    76 const TInt KUpdateDelayFullScreen = 4000000; // 4s
       
    77 const TInt KUpdateCbDelayComplete = 100000; // 0.1s
       
    78 const TInt KUpdateCbDelayLoading = 1000000; // 1s
       
    79 
       
    80 // MACROS
       
    81 
       
    82 // LOCAL CONSTANTS AND MACROS
       
    83 
       
    84 // MODULE DATA STRUCTURES
       
    85 
       
    86 // LOCAL FUNCTION PROTOTYPES
       
    87 
       
    88 // FORWARD DECLARATIONS
       
    89 
       
    90 // ============================= LOCAL FUNCTIONS ===============================
       
    91 
       
    92 
       
    93 // ============================ MEMBER FUNCTIONS ===============================
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CMinimap:CMinimap
       
    97 // C++ default constructor can NOT contain any code, that
       
    98 // might leave.
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 CMinimap::CMinimap(MPageScalerCallback& aCallback, TDisplayMode aMode, TBool aLowQuality)
       
   102     : iCallback(&aCallback),
       
   103       iZoomOutLevel(KDefaultZoomOutPercent),
       
   104       iTransparency(KDefaultTransparency),
       
   105       iDisplayMode(aMode),
       
   106       iWidthPercent(KDefaultWidthPercent),
       
   107       iHeightPercent(KDefaultHeightPercent),
       
   108       iMinimapUpdating( EFalse ),
       
   109       iLowQuality( aLowQuality )
       
   110     {
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CMinimap::ConstructL
       
   115 // Symbian 2nd phase constructor can leave.
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CMinimap::ConstructL()
       
   119     {
       
   120     iGenerator = CMinimapGenerator::NewL(*this);
       
   121     iUpdateCbTimer = CMinimapTimer::NewL(*this, &UpdateCbTimerCbL, CActive::EPriorityStandard - 1 );
       
   122     iUpdateTimer = CMinimapTimer::NewL(*this, &UpdateTimerCbL);
       
   123     iVisibilityTimer = CMinimapTimer::NewL(*this, &VisibilityTimerCbL);
       
   124     iFadeTimer = CMinimapTimer::NewL(*this, &UpdateTransparency);
       
   125     SetRelativePosition(KDefaultOffsetX,KDefaultOffsetY,KDefaultPosition);
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CMinimap::NewL
       
   130 // Two-phased constructor.
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 CMinimap* CMinimap::NewL(MPageScalerCallback& aCallback, TDisplayMode aMode, TBool aLowQuality)
       
   134     {
       
   135     CMinimap* self = new( ELeave ) CMinimap(aCallback, aMode, aLowQuality);
       
   136 
       
   137     CleanupStack::PushL( self );
       
   138     self->ConstructL();
       
   139     CleanupStack::Pop();
       
   140 
       
   141     return self;
       
   142     }
       
   143 
       
   144 
       
   145 // Destructor
       
   146 CMinimap::~CMinimap()
       
   147     {
       
   148     delete iGenerator;
       
   149     delete iUpdateCbTimer;
       
   150     delete iUpdateTimer;
       
   151     delete iVisibilityTimer;
       
   152     delete iFadeTimer;
       
   153     delete iMinimapBitmapGc;
       
   154     delete iMinimapBitmapDevice;
       
   155     delete iMinimapBitmap;
       
   156     
       
   157     delete iMinimapMaskBitmapGc;
       
   158     delete iMinimapMaskBitmapDevice;
       
   159     delete iMinimapMaskBitmap;
       
   160     
       
   161     iSprite.Close();
       
   162     
       
   163 #if ENABLE_MINIMAP_COLORING
       
   164     delete iMinimapColoringBitmap;
       
   165     delete iMinimapColoringBitmapMask;
       
   166     delete iMinimapColoringBitmapMaskDevice;
       
   167     delete iMinimapColoringBitmapMaskGc;
       
   168 #endif
       
   169     }
       
   170 
       
   171 
       
   172 // -----------------------------------------------------------------------------
       
   173 // CMinimap::SetRelativePosition
       
   174 //
       
   175 //
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 void CMinimap::SetRelativePosition(TInt aXDist, TInt aYDist, TPosition aPos)
       
   179     {
       
   180     //negative == relative to right/bottom edge
       
   181     iXDist = (aPos==ETopRight || aPos==EBottomRight)?-aXDist-1:aXDist;
       
   182     iYDist = (aPos==EBottomLeft || aPos==EBottomRight)?-aYDist-1:aYDist;
       
   183     }
       
   184 
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CMinimap::SetVisibleUntil
       
   188 //
       
   189 //
       
   190 // -----------------------------------------------------------------------------
       
   191 //
       
   192 void CMinimap::SetVisibleUntil(TTimeIntervalMicroSeconds32 aUntil)
       
   193     {
       
   194     iVisibilityTimer->Start(aUntil);
       
   195     if (!iVisible)
       
   196         {
       
   197         SetVisible(ETrue);
       
   198         iCallback->ScaledPageChanged(Rect(), EFalse, EFalse);
       
   199         }
       
   200         iFadeDirection = ETrue;
       
   201         UpdateTransparency();
       
   202     }
       
   203 
       
   204 void CMinimap::UpdateTransparency()
       
   205 {
       
   206     if (iFullScreenMode) return;
       
   207   
       
   208 	TInt delay = KUpdateFreq;
       
   209 	iFadeTimer->Cancel();
       
   210 	if (iFadeDirection) 
       
   211 	{
       
   212 		if (iTransparency > KDefaultViewingTransparency) 
       
   213 		{
       
   214 			iTransparency -= KFadeEffectSpeed;
       
   215 			iFadeTimer->Start(delay);
       
   216 			iCallback->ScaledPageChanged(Rect(), EFalse, EFalse);
       
   217 		}
       
   218 		else 
       
   219 		{
       
   220 			iTransparency = KDefaultViewingTransparency;
       
   221 		}
       
   222 	}
       
   223 	else 
       
   224 	{
       
   225 		if (iTransparency < KDefaultTransparency) 
       
   226 		{
       
   227 			iTransparency += KFadeEffectSpeed;
       
   228 			iFadeTimer->Start(delay);
       
   229 			iCallback->ScaledPageChanged(Rect(), EFalse, EFalse);
       
   230 		}
       
   231 		else 
       
   232 		{
       
   233 			iTransparency = KDefaultTransparency;
       
   234 			iVisible = EFalse;
       
   235 			iCallback->ScaledPageChanged(Rect(), EFalse, EFalse);
       
   236 		}
       
   237 	}
       
   238     }
       
   239 
       
   240 // -----------------------------------------------------------------------------
       
   241 // CMinimap::Rect
       
   242 //
       
   243 //
       
   244 // -----------------------------------------------------------------------------
       
   245 //
       
   246 TRect CMinimap::Rect() const
       
   247     {
       
   248     if (iFullScreenMode)
       
   249         {
       
   250         return iContainerRect;
       
   251         }
       
   252 
       
   253     if (!iMinimapBitmap)
       
   254         {
       
   255         return TRect();
       
   256         }
       
   257 
       
   258     TSize ressize(iMinimapBitmap->SizeInPixels());
       
   259 
       
   260     TPoint respoint;
       
   261     respoint.iX = iXDist<0?
       
   262         iContainerRect.Width()+iXDist-ressize.iWidth+1:iXDist;
       
   263     respoint.iY = iYDist<0?
       
   264         iContainerRect.Height()+iYDist-ressize.iHeight+1:iYDist;
       
   265 
       
   266     return TRect(respoint, ressize);
       
   267     }
       
   268 
       
   269 // -----------------------------------------------------------------------------
       
   270 // CMinimap::MinimapRect
       
   271 //
       
   272 // Rectangle containing the actual minimap (excluding borders)
       
   273 // -----------------------------------------------------------------------------
       
   274 //
       
   275 TRect CMinimap::MinimapRect() const
       
   276     {
       
   277     TSize s;
       
   278     if (iFullScreenMode)
       
   279         {
       
   280         s = CalcSize();
       
   281         //center
       
   282         TPoint p((iContainerRect.Width()-s.iWidth)/2,(iContainerRect.Height()-s.iHeight)/2);
       
   283         return TRect(p,s);
       
   284         }
       
   285     else if (iMinimapBitmap)
       
   286         {
       
   287         s = iMinimapBitmap->SizeInPixels();
       
   288         }
       
   289     TInt bw = BorderWidth();
       
   290     if (s.iWidth<=bw*2 || s.iHeight<=bw*2)
       
   291         {
       
   292         return TRect();
       
   293         }
       
   294     // borders
       
   295     s -= TSize(bw*2,bw*2);
       
   296     return TRect(TPoint(bw,1),s);
       
   297     }
       
   298 
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // CMinimap::IndicatorRect
       
   302 //
       
   303 // Calculate the main view indicator on minimap
       
   304 // -----------------------------------------------------------------------------
       
   305 //
       
   306 TRect CMinimap::IndicatorRect() const
       
   307     {
       
   308     TRect vp(iCallback->DocumentViewport());
       
   309     TRect minimapVp(ViewportOnDocument());
       
   310     vp.Move(-minimapVp.iTl); //make vp relative to minimapVp
       
   311     TRect res = FromDocCoords(vp); //translate vp to mmap coords
       
   312     // borders
       
   313     res.Move(MinimapRect().iTl);
       
   314     // so that view area is within the indicator
       
   315     res.Grow(1,1);
       
   316     // ensure it is within the bounds
       
   317     TRect mr = MinimapRect();
       
   318     if (res.iTl.iX<mr.iTl.iX)
       
   319         {
       
   320         res.iTl.iX = mr.iTl.iX;
       
   321         }
       
   322     if (res.iTl.iY<mr.iTl.iY)
       
   323         {
       
   324         res.iTl.iY = mr.iTl.iY;
       
   325         }
       
   326     if (res.iBr.iX>mr.iBr.iX)
       
   327         {
       
   328         res.iBr.iX = mr.iBr.iX;
       
   329         }
       
   330     if (res.iBr.iY>mr.iBr.iY)
       
   331         {
       
   332         res.iBr.iY = mr.iBr.iY;
       
   333         }
       
   334     return res;
       
   335     }
       
   336 
       
   337 // -----------------------------------------------------------------------------
       
   338 // CMinimap::DocumentStarted
       
   339 //
       
   340 // Event from client: new document is being loaded
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 void CMinimap::DocumentStarted()
       
   344     {
       
   345     iDocumentComplete = EFalse;
       
   346     iViewportOnDocument = TRect();
       
   347     iUpdateTimer->Cancel();
       
   348     iUpdateCbTimer->Cancel();
       
   349     iVisibilityTimer->Cancel();
       
   350     iGenerator->Clear();
       
   351     TRAP_IGNORE(CheckAndCreateMinimapBitmapsL());
       
   352     iNeedsUpdate = EFalse;
       
   353     // keep bitmaps during loading to avoid constant realloc
       
   354     iGenerator->SetKeepsBitmaps(ETrue);
       
   355     iGenerator->VisitArea(iCallback->DocumentViewport());
       
   356     }
       
   357 
       
   358 // -----------------------------------------------------------------------------
       
   359 // CMinimap::DocumentChanged
       
   360 //
       
   361 // Event from client: changes in document
       
   362 // -----------------------------------------------------------------------------
       
   363 //
       
   364 void CMinimap::DocumentChangedL()
       
   365     {
       
   366     TTimeIntervalMicroSeconds32 delay(
       
   367         iDocumentComplete?KUpdateCbDelayComplete:KUpdateCbDelayLoading);
       
   368     iUpdateCbTimer->Start( delay );
       
   369     }
       
   370 
       
   371 // -----------------------------------------------------------------------------
       
   372 // CMinimap::DocumentChangedCbL
       
   373 //
       
   374 // Event from client: changes in document
       
   375 // -----------------------------------------------------------------------------
       
   376 //
       
   377 void CMinimap::DocumentChangedCbL()
       
   378     {
       
   379 #ifdef __OOM__
       
   380     // disable updating when memory is low
       
   381     if( iGenerator->IsCollectingMemory() ) return;
       
   382 #endif
       
   383 
       
   384     iGenerator->Invalidate();
       
   385     if( !iLowQuality )
       
   386         {
       
   387         CheckAndCreateMinimapBitmapsL();
       
   388         if (iUpdateTimer->IsActive())
       
   389             {
       
   390             // timer running, update when it completes
       
   391             iNeedsUpdate = ETrue;
       
   392             }
       
   393         else
       
   394             {
       
   395             if (iCallback->DocumentSize().iHeight>5)
       
   396                 {
       
   397                 iViewportOnDocument = CalcViewportOnDocument();
       
   398                 iGenerator->UpdateL();
       
   399                 iNeedsUpdate = EFalse;
       
   400                 // don't do another update for..
       
   401                 TTimeIntervalMicroSeconds32 delay(
       
   402                     iFullScreenMode?KUpdateDelayFullScreen:iDocumentComplete?KUpdateDelayComplete:KUpdateDelayLoading);
       
   403                 iUpdateTimer->Start(delay);
       
   404                 }
       
   405             }
       
   406         }
       
   407     else
       
   408         {
       
   409         iNeedsUpdate = ETrue;
       
   410 
       
   411         // don't start updating if the minimap is not visible
       
   412         if( iVisible )
       
   413             {
       
   414             if (iCallback->DocumentSize().iHeight>5)
       
   415                 {
       
   416                 iViewportOnDocument = CalcViewportOnDocument();
       
   417                 iGenerator->UpdateL();
       
   418                 iUpdateTimer->Start( 0 );
       
   419                 }
       
   420             }
       
   421         }
       
   422     }
       
   423 
       
   424 // -----------------------------------------------------------------------------
       
   425 // CMinimap::DocumentViewportMoved
       
   426 //
       
   427 // Event from client: view position changed
       
   428 // -----------------------------------------------------------------------------
       
   429 //
       
   430 void CMinimap::DocumentViewportMoved()
       
   431     {
       
   432     iViewportOnDocument = CalcViewportOnDocument();
       
   433 #if ENABLE_MINIMAP_COLORING
       
   434     iGenerator->VisitArea(iCallback->DocumentViewport());
       
   435 #endif
       
   436     iGenerator->ScrollL();
       
   437     if ( iVisible )
       
   438         {
       
   439         TRAP_IGNORE(iGenerator->UpdateL(ETrue));
       
   440         }
       
   441     else if( !iLowQuality )
       
   442         {
       
   443         iNeedsUpdate = ETrue;
       
   444         if (!iUpdateTimer->IsActive())
       
   445             {
       
   446             TTimeIntervalMicroSeconds32 delay(
       
   447                 iDocumentComplete?KUpdateDelayComplete:KUpdateDelayLoading);
       
   448             iUpdateTimer->Start(delay);
       
   449             }
       
   450         }
       
   451     else
       
   452         iNeedsUpdate = ETrue;
       
   453     }
       
   454 
       
   455 // -----------------------------------------------------------------------------
       
   456 // CMinimap::SetMaxSize
       
   457 //
       
   458 // set maximum size for the minimap
       
   459 // -----------------------------------------------------------------------------
       
   460 //
       
   461 void CMinimap::SetPercentSize(TInt aWidthPercent, TInt aHeightPercent)
       
   462     {
       
   463     iWidthPercent = aWidthPercent;
       
   464     iHeightPercent = aHeightPercent;
       
   465     TRAP_IGNORE(CheckAndCreateMinimapBitmapsL());
       
   466     }
       
   467 
       
   468 // -----------------------------------------------------------------------------
       
   469 // CMinimap::DocumentCompleted
       
   470 //
       
   471 // Event from client: document loading completed
       
   472 // -----------------------------------------------------------------------------
       
   473 //
       
   474 void CMinimap::DocumentCompleted()
       
   475     {
       
   476     // this event is triggered by the minimap updating, not by 
       
   477     // the main document.
       
   478     if( iMinimapUpdating ) return;
       
   479 
       
   480     iNeedsUpdate = ETrue;
       
   481     iDocumentComplete = ETrue;
       
   482     
       
   483     if( iVisible || !iLowQuality )
       
   484         {
       
   485         iUpdateTimer->Start(0);
       
   486         }
       
   487     
       
   488     // we can delete the buffers now
       
   489     iGenerator->SetKeepsBitmaps(EFalse);
       
   490     }
       
   491 
       
   492 // -----------------------------------------------------------------------------
       
   493 // CMinimap::ViewportOnMinimap
       
   494 //
       
   495 // Area the minimap view covers in minimap coordinates
       
   496 // -----------------------------------------------------------------------------
       
   497 //
       
   498 TRect CMinimap::ViewportOnMinimap() const
       
   499     {
       
   500     return FromDocCoords(iViewportOnDocument);
       
   501     }
       
   502 
       
   503 
       
   504 // -----------------------------------------------------------------------------
       
   505 // CMinimap::ViewportOnDocument
       
   506 //
       
   507 // Area the minimap view covers in document coordinates
       
   508 // -----------------------------------------------------------------------------
       
   509 //
       
   510 TRect CMinimap::ViewportOnDocument() const
       
   511     {
       
   512     return iViewportOnDocument;
       
   513     }
       
   514 
       
   515 // -----------------------------------------------------------------------------
       
   516 // CMinimap::CalcSize
       
   517 //
       
   518 // Calculate minimap view size
       
   519 // -----------------------------------------------------------------------------
       
   520 //
       
   521 TSize CMinimap::CalcSize() const
       
   522     {
       
   523     TSize res, max;
       
   524     TSize mms = FromDocCoords(iCallback->DocumentSize());
       
   525     if (iFullScreenMode)
       
   526         {
       
   527         max = iContainerRect.Size();
       
   528         }
       
   529     else
       
   530         {
       
   531         TSize s( iContainerRect.Size() );
       
   532         s.iWidth = s.iWidth * iWidthPercent / 100;
       
   533         s.iHeight = s.iHeight * iHeightPercent / 100;
       
   534         max = s ;
       
   535         }
       
   536     TInt bw = BorderWidth();
       
   537     res.iWidth = Min(mms.iWidth+2*bw,max.iWidth);
       
   538     res.iHeight = Min(mms.iHeight+2*bw,max.iHeight);
       
   539     return res;
       
   540     }
       
   541 
       
   542 
       
   543 // -----------------------------------------------------------------------------
       
   544 // CMinimap::CalcViewportOnDocument
       
   545 //
       
   546 // Calculate the area the minimap view covers in document coordinates
       
   547 // -----------------------------------------------------------------------------
       
   548 //
       
   549 TRect CMinimap::CalcViewportOnDocument() const
       
   550     {
       
   551     TPoint mvp(iViewportOnDocument.iTl);
       
   552 
       
   553     TRect docvp(iCallback->DocumentViewport());
       
   554     TSize docs(iCallback->DocumentSize());
       
   555     TSize ms(ToDocCoords(MinimapRect().Size()));
       
   556     TPoint docc(docvp.Center());
       
   557 
       
   558     if (!iCallback->TouchScrolling())
       
   559         {
       
   560         // scroll if not within 1/3 center area
       
   561         // check x-direction
       
   562         if (docc.iX<mvp.iX+ms.iWidth*KHScrollAreaPercent/100 ||
       
   563             docc.iX>mvp.iX+ms.iWidth*(100-KHScrollAreaPercent)/100)
       
   564             {
       
   565             // far enough from the center, re-center the view
       
   566             mvp.iX = docc.iX-ms.iWidth/2;
       
   567             if (mvp.iX+ms.iWidth>docs.iWidth)
       
   568                 {
       
   569                 mvp.iX=docs.iWidth-ms.iWidth;
       
   570                 }
       
   571             if (mvp.iX<0)
       
   572                 {
       
   573                 mvp.iX=0;
       
   574                 }
       
   575             }
       
   576         // y-direction
       
   577         if (docc.iY<mvp.iY+ms.iHeight*KVScrollAreaPercent/100 ||
       
   578             docc.iY>mvp.iY+ms.iHeight*(100-KVScrollAreaPercent)/100)
       
   579             {
       
   580             // far enough from the center, re-center the view
       
   581             mvp.iY = docc.iY-ms.iHeight/2;
       
   582             if (mvp.iY+ms.iHeight>docs.iHeight)
       
   583                 {
       
   584                 mvp.iY=docs.iHeight-ms.iHeight;
       
   585                 }
       
   586             if (mvp.iY<0)
       
   587                 {
       
   588                 mvp.iY=0;
       
   589                 }
       
   590             }
       
   591         }
       
   592     else
       
   593         {
       
   594         // check x-direction
       
   595         TBool moved = EFalse;
       
   596         if (docc.iX<mvp.iX+ms.iWidth*KHScrollAreaPercentWithTouch1/100)
       
   597             {
       
   598             mvp.iX = docc.iX-ms.iWidth*KHScrollAreaPercentWithTouch2/100;
       
   599             moved = ETrue;
       
   600             }
       
   601         else if (docc.iX>mvp.iX+ms.iWidth*(100-KHScrollAreaPercentWithTouch1)/100)
       
   602             {
       
   603             mvp.iX = docc.iX-ms.iWidth*(100-KHScrollAreaPercentWithTouch1)/100;
       
   604             moved = ETrue;
       
   605             }
       
   606         if (moved)
       
   607             {
       
   608             if (mvp.iX+ms.iWidth>docs.iWidth)
       
   609                 {
       
   610                 mvp.iX=docs.iWidth-ms.iWidth;
       
   611                 }
       
   612             if (mvp.iX<0)
       
   613                 {
       
   614                 mvp.iX=0;
       
   615                 }
       
   616             }
       
   617         // y-direction
       
   618         moved = EFalse;
       
   619         if (docc.iY<mvp.iY+ms.iHeight*KVScrollAreaPercentWithTouch1/100)
       
   620             {
       
   621             mvp.iY = docc.iY-ms.iHeight*KVScrollAreaPercentWithTouch2/80;
       
   622             moved = ETrue;
       
   623             }
       
   624         else if (docc.iY>mvp.iY+ms.iHeight*(100-KVScrollAreaPercentWithTouch1)/100)
       
   625             {
       
   626             mvp.iY = docc.iY-ms.iHeight*(100-KVScrollAreaPercentWithTouch1)/100;
       
   627             moved = ETrue;
       
   628             }
       
   629 
       
   630         if (moved)
       
   631             {
       
   632             if (mvp.iY+ms.iHeight>docs.iHeight)
       
   633                 {
       
   634                 mvp.iY=docs.iHeight-ms.iHeight;
       
   635                 }
       
   636             if (mvp.iY<0)
       
   637                 {
       
   638                 mvp.iY=0;
       
   639                 }
       
   640             }
       
   641         }
       
   642     return TRect(mvp,ms);
       
   643     }
       
   644 
       
   645 
       
   646 
       
   647 template<class GC> void CMinimap::DrawT(GC& aGc, const TRect& /*aRect*/) const
       
   648     {
       
   649     TRect r(MinimapRect());
       
   650     aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
       
   651     aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   652     aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   653     iGenerator->Draw(aGc, r);
       
   654 
       
   655 #if ENABLE_MINIMAP_COLORING
       
   656     // coloring
       
   657 
       
   658     // build up the mask
       
   659     TRect mmapVpOnDoc(ViewportOnDocument());
       
   660     iMinimapColoringBitmapMaskGc->SetBrushColor(TRgb(60, 60, 60));
       
   661     iMinimapColoringBitmapMaskGc->DrawRect(iMinimapColoringBitmap->SizeInPixels());
       
   662     iGenerator->DrawColoringMask(*iMinimapColoringBitmapMaskGc, mmapVpOnDoc);
       
   663 
       
   664     // paint the coloring
       
   665     aGc.AlphaBlendBitmaps(r.iTl,
       
   666                      iMinimapColoringBitmap,
       
   667                      iMinimapColoringBitmap->SizeInPixels(),
       
   668                      iMinimapColoringBitmapMask,
       
   669                      TPoint(0,0));
       
   670 #endif
       
   671 
       
   672     // draw the position indicator
       
   673     aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   674     aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   675     aGc.SetPenSize(TSize(1,1));
       
   676     aGc.SetPenColor(TRgb(255,0,0));
       
   677     aGc.DrawRect(IndicatorRect());
       
   678     }
       
   679 
       
   680 // -----------------------------------------------------------------------------
       
   681 // CMinimap::Draw
       
   682 //
       
   683 //
       
   684 // -----------------------------------------------------------------------------
       
   685 //
       
   686 void CMinimap::Draw(CWindowGc& aGc, const TRect& aRect) const
       
   687     {
       
   688     if (iFullScreenMode)
       
   689         {
       
   690         // clear the background
       
   691         aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   692         aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   693         aGc.SetBrushColor(TRgb(220,220,255));
       
   694         aGc.SetPenColor(TRgb(220,220,255));
       
   695         aGc.DrawRect(iContainerRect);
       
   696 
       
   697         // get the bitmap
       
   698         DrawT(aGc,aRect);
       
   699         }
       
   700     else
       
   701         {
       
   702         TRect rectToDraw(Rect());
       
   703         // draw the minimap only if the document is larger than the screen
       
   704         TSize docsize(iGenerator->DocSize());
       
   705         if (iVisible && iMinimapBitmap && aRect.Intersects(rectToDraw)
       
   706             && (docsize.iWidth>iContainerRect.Width() || docsize.iHeight>iContainerRect.Height()))
       
   707             {
       
   708             // get the bitmap
       
   709             DrawT(*iMinimapBitmapGc,aRect);
       
   710 
       
   711             // set the transparency to the alpha channel
       
   712             iMinimapBitmapGc->SetDrawMode(CGraphicsContext::EDrawModeAND);
       
   713             iMinimapBitmapGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   714             iMinimapBitmapGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   715             iMinimapBitmapGc->SetBrushColor(TRgb(0xff,0xff,0xff,255*(100-iTransparency)/100));
       
   716             iMinimapBitmapGc->DrawRect(MinimapRect());
       
   717 
       
   718             // blit to screen
       
   719             aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
       
   720             aGc.SetBrushStyle(CGraphicsContext::ENullBrush);
       
   721             aGc.BitBlt(rectToDraw.iTl, iMinimapBitmap);
       
   722             }
       
   723         }
       
   724     }
       
   725 
       
   726 // -----------------------------------------------------------------------------
       
   727 // CMinimap::FromDocCoords
       
   728 //
       
   729 // Coordinate space translation from document to minimap
       
   730 // -----------------------------------------------------------------------------
       
   731 //
       
   732 TRect CMinimap::FromDocCoords(const TRect& aFrom) const
       
   733     {
       
   734     return TRect(FromDocCoords(aFrom.iTl),FromDocCoords(aFrom.Size()));
       
   735     }
       
   736 
       
   737 // -----------------------------------------------------------------------------
       
   738 // CMinimap::FromDocCoords
       
   739 //
       
   740 // Coordinate space translation from document to minimap
       
   741 // -----------------------------------------------------------------------------
       
   742 //
       
   743 TPoint CMinimap::FromDocCoords(const TPoint& aFrom) const
       
   744     {
       
   745     TPoint res;
       
   746     res.iX = aFrom.iX*100/iZoomOutLevel;
       
   747     res.iY = aFrom.iY*100/iZoomOutLevel;
       
   748     return res;
       
   749     }
       
   750 
       
   751 // -----------------------------------------------------------------------------
       
   752 // CMinimap::FromDocCoords
       
   753 //
       
   754 // Coordinate space translation from document to minimap
       
   755 // -----------------------------------------------------------------------------
       
   756 //
       
   757 TSize CMinimap::FromDocCoords(const TSize& aFrom) const
       
   758     {
       
   759     TSize res;
       
   760     res.iWidth = aFrom.iWidth*100/iZoomOutLevel;
       
   761     res.iHeight = aFrom.iHeight*100/iZoomOutLevel;
       
   762     return res;
       
   763     }
       
   764 
       
   765 // -----------------------------------------------------------------------------
       
   766 // CMinimap::ToDocCoords
       
   767 //
       
   768 // Coordinate space translation from minimap to document
       
   769 // -----------------------------------------------------------------------------
       
   770 //
       
   771 TPoint CMinimap::ToDocCoords(const TPoint& aFrom) const
       
   772     {
       
   773     TPoint res;
       
   774     res.iX = aFrom.iX*iZoomOutLevel/100;
       
   775     res.iY = aFrom.iY*iZoomOutLevel/100;
       
   776     return res;
       
   777     }
       
   778 
       
   779 
       
   780 // -----------------------------------------------------------------------------
       
   781 // CMinimap::ToDocCoords
       
   782 //
       
   783 // Coordinate space translation from minimap to document
       
   784 // -----------------------------------------------------------------------------
       
   785 //
       
   786 TSize CMinimap::ToDocCoords(const TSize& aFrom) const
       
   787     {
       
   788     TSize res;
       
   789     res.iWidth = aFrom.iWidth*iZoomOutLevel/100;
       
   790     res.iHeight = aFrom.iHeight*iZoomOutLevel/100;
       
   791     return res;
       
   792     }
       
   793 
       
   794 // -----------------------------------------------------------------------------
       
   795 // CMinimap::ToDocCoords
       
   796 //
       
   797 // Coordinate space translation from minimap to document
       
   798 // -----------------------------------------------------------------------------
       
   799 //
       
   800 TRect CMinimap::ToDocCoords(const TRect& aFrom) const
       
   801     {
       
   802     return TRect(ToDocCoords(aFrom.iTl),ToDocCoords(aFrom.Size()));
       
   803     }
       
   804     
       
   805     
       
   806 
       
   807 // -----------------------------------------------------------------------------
       
   808 // CMinimap::CheckAndCreateMinimapBitmapsL
       
   809 //
       
   810 // Creates mask and buffer if needed
       
   811 // -----------------------------------------------------------------------------
       
   812 //
       
   813 void CMinimap::CheckAndCreateMinimapBitmapsL()
       
   814     {
       
   815     // low quality minimap only updates when it is visible
       
   816     if( !iVisible && iLowQuality ) 
       
   817         return;
       
   818 
       
   819     TSize minimapSize(CalcSize());
       
   820     if (!iFullScreenMode)
       
   821         {
       
   822         TDisplayMode temp = iDisplayMode;
       
   823         iDisplayMode = EColor16MA;
       
   824         TSize oldsize;
       
   825         if (iMinimapBitmap)
       
   826             {
       
   827             oldsize = iMinimapBitmap->SizeInPixels();
       
   828             }
       
   829         if (minimapSize!=oldsize)
       
   830             {
       
   831             CheckAndCreateBitmapL( minimapSize,iMinimapBitmap,iMinimapBitmapDevice,iMinimapBitmapGc);
       
   832             if (iMinimapBitmap)
       
   833                 {
       
   834                 // draw shadowed border
       
   835                 iMinimapBitmapGc->Clear();
       
   836                 TRect r(minimapSize);
       
   837                 iMinimapBitmapGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
       
   838                 iMinimapBitmapGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   839                 iMinimapBitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   840                 // wider shadow to bottom, no shadow to top
       
   841                 TInt bw = BorderWidth();
       
   842                 for (TInt n=1;n<=2*bw-1;n++)
       
   843                     {
       
   844                     iMinimapBitmapGc->SetPenColor(TRgb(0,0,0,n*n*KMaxBorderAlpha/(2*2*bw*bw)));
       
   845                     iMinimapBitmapGc->DrawRect(r);
       
   846                     r.iTl.iX += n%2;
       
   847                     r.iBr.iX -= n%2;
       
   848                     r.iBr.iY -= 1;
       
   849                     }
       
   850                 iMinimapBitmapGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
       
   851                 }
       
   852             //create mask
       
   853             CheckAndCreateBitmapL( minimapSize, iMinimapMaskBitmap,iMinimapMaskBitmapDevice,iMinimapMaskBitmapGc);
       
   854             if (iMinimapMaskBitmap)
       
   855                 {
       
   856                     //Draw mask
       
   857                 iMinimapMaskBitmapGc->Clear();
       
   858                 TRect r(minimapSize);
       
   859                 iMinimapMaskBitmapGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   860                 iMinimapMaskBitmapGc->SetPenStyle( CGraphicsContext::ENullPen );
       
   861                 iMinimapMaskBitmapGc->SetPenColor( TRgb( 30, 30, 30 ) );
       
   862                 iMinimapMaskBitmapGc->SetBrushColor( TRgb( 30, 30, 30 ) );
       
   863                 iMinimapMaskBitmapGc->DrawRect( r );
       
   864     
       
   865                 iMinimapMaskBitmapGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   866                 iMinimapMaskBitmapGc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   867                 
       
   868                 // wider shadow to bottom, no shadow to top
       
   869                 TInt bw = BorderWidth();
       
   870                 for (TInt n=1;n<=2*bw-1;n++)
       
   871                     {
       
   872                     TInt grade = 85*n/(2*bw);
       
   873                     iMinimapMaskBitmapGc->SetPenColor(TRgb(255-grade,255-grade,255-grade));
       
   874                     iMinimapMaskBitmapGc->DrawRect(r);
       
   875                     r.iTl.iX += n%2;
       
   876                     r.iBr.iX -= n%2;
       
   877                     r.iBr.iY -= 1;
       
   878                     }
       
   879                 }
       
   880             }
       
   881         iDisplayMode = temp;
       
   882         }
       
   883 #if ENABLE_MINIMAP_COLORING
       
   884     InitColoringL(MinimapRect().Size());
       
   885 #endif
       
   886     }
       
   887 
       
   888 
       
   889 // -----------------------------------------------------------------------------
       
   890 // CMinimap::CheckAndCreateBitmapL
       
   891 //
       
   892 // Creates bitmap, device and mask if needed
       
   893 // -----------------------------------------------------------------------------
       
   894 //
       
   895 TBool CMinimap::CheckAndCreateBitmapL(TSize aSize, CFbsBitmap*& aBm, CFbsBitmapDevice*& aDev, CFbsBitGc*& aGc)
       
   896     {
       
   897     if ( aSize.iWidth==0 || aSize.iHeight==0 )
       
   898         {
       
   899         // delete bitmap if there was one
       
   900         delete aGc;
       
   901         delete aDev;
       
   902         delete aBm;
       
   903         aGc = 0;
       
   904         aDev = 0;
       
   905         aBm = 0;
       
   906         return EFalse;
       
   907         }
       
   908     else
       
   909         {
       
   910         if ( aBm && aSize != aBm->SizeInPixels() )
       
   911             {
       
   912             // resize if different size
       
   913             User::LeaveIfError(aDev->Resize(aSize));
       
   914             aGc->Resized();
       
   915             }
       
   916         else if ( !aBm )
       
   917             {
       
   918             // create new
       
   919             CFbsBitmap* bm = new (ELeave) CFbsBitmap;
       
   920             CleanupStack::PushL(bm);
       
   921             User::LeaveIfError(bm->Create(aSize,iDisplayMode));
       
   922             CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(bm);
       
   923             CleanupStack::PushL(dev);
       
   924             User::LeaveIfError(dev->CreateContext(aGc));
       
   925             aDev = dev;
       
   926             aBm = bm;
       
   927             CleanupStack::Pop(2);
       
   928             }
       
   929         }
       
   930     return ETrue;
       
   931     }
       
   932 
       
   933 // -----------------------------------------------------------------------------
       
   934 // CMinimap::InitColoring
       
   935 //
       
   936 // Creates (if needed) and initializes bitmaps for mmap coloring
       
   937 // -----------------------------------------------------------------------------
       
   938 //
       
   939 #if ENABLE_MINIMAP_COLORING
       
   940 void CMinimap::InitColoringL(const TSize aSize)
       
   941     {
       
   942     if(!iMinimapColoringBitmap || aSize!=iMinimapColoringBitmap->SizeInPixels())
       
   943         {
       
   944         delete iMinimapColoringBitmap;
       
   945         iMinimapColoringBitmap = 0;
       
   946         iMinimapColoringBitmap = new (ELeave) CFbsBitmap();
       
   947 
       
   948         User::LeaveIfError(iMinimapColoringBitmap->Create(aSize, iDisplayMode));
       
   949         CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(iMinimapColoringBitmap);
       
   950         CleanupStack::PushL(device);
       
   951         CFbsBitGc* gc;
       
   952         User::LeaveIfError(device->CreateContext(gc));
       
   953 
       
   954         gc->SetPenStyle(CGraphicsContext::ENullPen);
       
   955         gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   956         gc->SetBrushColor(KRgbYellow);
       
   957         gc->DrawRect(aSize);
       
   958 
       
   959         delete gc;
       
   960         gc = 0;
       
   961         CleanupStack::PopAndDestroy(device);
       
   962         device = 0;
       
   963         }
       
   964 
       
   965     if(iMinimapColoringBitmapMask && aSize != iMinimapColoringBitmapMask->SizeInPixels())
       
   966         {
       
   967         User::LeaveIfError(iMinimapColoringBitmapMaskDevice->Resize(aSize));
       
   968         iMinimapColoringBitmapMaskGc->Resized();
       
   969         }
       
   970     else if(!iMinimapColoringBitmapMask)
       
   971         {
       
   972         iMinimapColoringBitmapMask = new (ELeave) CFbsBitmap();
       
   973         User::LeaveIfError(iMinimapColoringBitmapMask->Create(aSize, EGray256));
       
   974         iMinimapColoringBitmapMaskDevice = CFbsBitmapDevice::NewL(iMinimapColoringBitmapMask);
       
   975         User::LeaveIfError(iMinimapColoringBitmapMaskDevice->CreateContext(iMinimapColoringBitmapMaskGc));
       
   976         }
       
   977 
       
   978     iMinimapColoringBitmapMaskGc->SetPenStyle(CGraphicsContext::ENullPen);
       
   979     iMinimapColoringBitmapMaskGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   980     }
       
   981 #else
       
   982 void CMinimap::InitColoringL(const TSize) { }
       
   983 #endif
       
   984 
       
   985 // -----------------------------------------------------------------------------
       
   986 // CMinimap::SetTransparency
       
   987 //
       
   988 // Timer callback
       
   989 // -----------------------------------------------------------------------------
       
   990 //
       
   991 void CMinimap::SetTransparency(TInt aPercent)
       
   992     {
       
   993     if (iTransparency!=aPercent)
       
   994         {
       
   995         iTransparency = aPercent;
       
   996         }
       
   997     }
       
   998 
       
   999 
       
  1000 // -----------------------------------------------------------------------------
       
  1001 // CMinimap::UpdateCbTimerCbL
       
  1002 //
       
  1003 // Timer callback
       
  1004 // -----------------------------------------------------------------------------
       
  1005 //
       
  1006 void CMinimap::UpdateCbTimerCbL()
       
  1007     {
       
  1008     iMinimapUpdating = ETrue;
       
  1009     DocumentChangedCbL();
       
  1010     iMinimapUpdating = EFalse;
       
  1011     }
       
  1012 // -----------------------------------------------------------------------------
       
  1013 // CMinimap::UpdateTimerCbL
       
  1014 //
       
  1015 // Timer callback
       
  1016 // -----------------------------------------------------------------------------
       
  1017 //
       
  1018 void CMinimap::UpdateTimerCbL()
       
  1019     {
       
  1020     iMinimapUpdating = ETrue;
       
  1021 
       
  1022 #ifdef __OOM__
       
  1023     if( iGenerator->IsCollectingMemory() ) return;
       
  1024 #endif
       
  1025     if (iNeedsUpdate)
       
  1026         {
       
  1027         iViewportOnDocument = CalcViewportOnDocument();
       
  1028         CheckAndCreateMinimapBitmapsL();
       
  1029         iGenerator->UpdateL();
       
  1030         }
       
  1031     iNeedsUpdate = EFalse;
       
  1032     iMinimapUpdating = EFalse;
       
  1033     }
       
  1034 
       
  1035 // -----------------------------------------------------------------------------
       
  1036 // CMinimap::VisibilityTimerCbL
       
  1037 //
       
  1038 // Timer callback
       
  1039 // -----------------------------------------------------------------------------
       
  1040 //
       
  1041 void CMinimap::VisibilityTimerCbL()
       
  1042     {
       
  1043     iFadeDirection = EFalse;
       
  1044     iSprite.Close();
       
  1045     UpdateTransparency();
       
  1046     }
       
  1047 
       
  1048 // -----------------------------------------------------------------------------
       
  1049 // CMinimap::ScaledPage
       
  1050 //
       
  1051 // Scaled Page
       
  1052 // -----------------------------------------------------------------------------
       
  1053 //
       
  1054  CFbsBitmap* CMinimap::ScaledPage() const
       
  1055     {
       
  1056     return iGenerator->ScaledPage();
       
  1057     }
       
  1058 
       
  1059 // -----------------------------------------------------------------------------
       
  1060 // CMinimap::ContainerRect
       
  1061 //
       
  1062 // Rectangle used to detemine the paint area
       
  1063 // -----------------------------------------------------------------------------
       
  1064 //
       
  1065 TRect CMinimap::ContainerRect() const
       
  1066     {
       
  1067     return iContainerRect;
       
  1068     }
       
  1069 
       
  1070 
       
  1071 // -----------------------------------------------------------------------------
       
  1072 // CMinimap::SetContainerRect
       
  1073 //
       
  1074 // Set the rectangle used to detemine the paint area
       
  1075 // -----------------------------------------------------------------------------
       
  1076 //
       
  1077 void CMinimap::SetContainerRect(const TRect& aRect)
       
  1078     {
       
  1079     iContainerRect = aRect;
       
  1080     iViewportOnDocument = CalcViewportOnDocument();
       
  1081     TRAP_IGNORE(CheckAndCreateMinimapBitmapsL());
       
  1082     }
       
  1083 
       
  1084 
       
  1085 // -----------------------------------------------------------------------------
       
  1086 // CMinimap::FullScreenMode
       
  1087 //
       
  1088 // Paint full area
       
  1089 // -----------------------------------------------------------------------------
       
  1090 //
       
  1091 TBool CMinimap::FullScreenMode() const
       
  1092     {
       
  1093     return iFullScreenMode;
       
  1094     }
       
  1095 
       
  1096 // -----------------------------------------------------------------------------
       
  1097 // CMinimap::SetFullScreenMode
       
  1098 //
       
  1099 // Paint full area
       
  1100 // -----------------------------------------------------------------------------
       
  1101 //
       
  1102 void CMinimap::SetFullScreenMode(TBool aFullScreenMode)
       
  1103     {
       
  1104     iFullScreenMode = aFullScreenMode;
       
  1105     iViewportOnDocument = CalcViewportOnDocument();
       
  1106     TRAP_IGNORE(CheckAndCreateMinimapBitmapsL());
       
  1107     if (iFullScreenMode) 
       
  1108         {
       
  1109         iVisibilityTimer->Cancel();
       
  1110         }
       
  1111     else 
       
  1112         {
       
  1113         iVisibilityTimer->StartOrContinue();
       
  1114         }
       
  1115     }
       
  1116 
       
  1117 // -----------------------------------------------------------------------------
       
  1118 // CMinimap::ConstructSprite
       
  1119 //
       
  1120 //
       
  1121 // -----------------------------------------------------------------------------
       
  1122 //
       
  1123 void CMinimap::ConstructSprite()
       
  1124     {
       
  1125     CCoeControl& view = iCallback->PageControlView();
       
  1126     iSprite = RWsSprite(view.ControlEnv()->WsSession());
       
  1127     RWindowTreeNode *window =  (RDrawableWindow* )view.DrawableWindow();
       
  1128     iSprite.Construct(*window,Rect().iTl,ESpriteNoChildClip);
       
  1129 
       
  1130     TSpriteMember spriteMem;
       
  1131     spriteMem.iBitmap = iMinimapBitmap;
       
  1132     spriteMem.iMaskBitmap = iMinimapMaskBitmap;
       
  1133     spriteMem.iInvertMask = ETrue;
       
  1134 
       
  1135     iSprite.AppendMember(spriteMem);
       
  1136     iSprite.Activate();
       
  1137     }
       
  1138 
       
  1139 // -----------------------------------------------------------------------------
       
  1140 // CPageOverview::SetVisible
       
  1141 //
       
  1142 //
       
  1143 // -----------------------------------------------------------------------------
       
  1144 //
       
  1145 void CMinimap::SetVisible(TBool aVisible)
       
  1146     {
       
  1147     if (aVisible && !iVisible)
       
  1148         {
       
  1149         iVisible = aVisible;
       
  1150         UpdateNow();
       
  1151         if(!iFullScreenMode)
       
  1152             {
       
  1153             ConstructSprite();
       
  1154             }
       
  1155         }
       
  1156     iVisible = aVisible;
       
  1157     
       
  1158     if(!aVisible && !iFullScreenMode)
       
  1159         {
       
  1160         iSprite.Close();
       
  1161         }
       
  1162     
       
  1163     }
       
  1164 
       
  1165 // -----------------------------------------------------------------------------
       
  1166 // CPageOverview::UpdateNow
       
  1167 //
       
  1168 // Force update
       
  1169 // -----------------------------------------------------------------------------
       
  1170 //
       
  1171 void CMinimap::UpdateNow()
       
  1172     {
       
  1173     if (iUpdateCbTimer->IsActive())
       
  1174         {
       
  1175         iUpdateCbTimer->Cancel();
       
  1176         iUpdateTimer->Cancel();
       
  1177         DocumentChangedCbL();
       
  1178         }
       
  1179     else
       
  1180         {
       
  1181         iUpdateTimer->Cancel();
       
  1182         UpdateTimerCbL();
       
  1183         }
       
  1184     }
       
  1185 
       
  1186 
       
  1187 TInt CMinimap::BorderWidth() const
       
  1188     {
       
  1189     return KBorderWidthPermille*Max(iContainerRect.Width(),iContainerRect.Height())/1000;
       
  1190     }
       
  1191 
       
  1192 #ifdef __OOM__
       
  1193 void CMinimap::DeleteMinimapBitmap()
       
  1194     {
       
  1195     // disable updating
       
  1196     if (iUpdateCbTimer->IsActive())
       
  1197         {
       
  1198         iUpdateCbTimer->Cancel();
       
  1199         iUpdateTimer->Cancel();
       
  1200         }
       
  1201 
       
  1202     // delete the minimap
       
  1203     delete iMinimapBitmap;
       
  1204     iMinimapBitmap = 0;
       
  1205     delete iMinimapBitmapDevice;
       
  1206     iMinimapBitmapDevice = 0;
       
  1207     delete iMinimapBitmapGc;
       
  1208     iMinimapBitmapGc = 0;
       
  1209     }
       
  1210 #endif
       
  1211 //  End of File