webengine/webkitutils/HistoryProvider/HistoryView.cpp
branchRCL_3
changeset 49 919f36ff910f
parent 48 79859ed3eea9
equal deleted inserted replaced
48:79859ed3eea9 49:919f36ff910f
    44 const int KFastScrollAnimFactorInc = 40;
    44 const int KFastScrollAnimFactorInc = 40;
    45 const int KMaxAnimFactor = 100;
    45 const int KMaxAnimFactor = 100;
    46 const int KMinAnimFactor = 0;
    46 const int KMinAnimFactor = 0;
    47 const int KMinimumScroll = 20;
    47 const int KMinimumScroll = 20;
    48 
    48 
    49 #define KCenterImageBorderColor KRgbRed
    49 #define KCenterImageBorderColor TRgb(179,179,181)
    50 #define KSideImageBorderColor KRgbBlack
    50 #define KSideImageBorderColor KRgbBlack
       
    51 #define KSideImageMaskColor TRgb(170, 170, 170)
    51 
    52 
    52 // ============================= LOCAL FUNCTIONS ===============================
    53 // ============================= LOCAL FUNCTIONS ===============================
    53 
    54 
    54 TBool animRepaint(TAny* aAny)
    55 TBool animRepaint(TAny* aAny)
    55 {
    56 {
   139     delete m_repaintTimer;
   140     delete m_repaintTimer;
   140     if (m_autoScrollPeriodic) {
   141     if (m_autoScrollPeriodic) {
   141         m_autoScrollPeriodic->Cancel();
   142         m_autoScrollPeriodic->Cancel();
   142         delete m_autoScrollPeriodic;
   143         delete m_autoScrollPeriodic;
   143     }
   144     }
       
   145     delete m_maskBitmap;
   144 }
   146 }
   145 
   147 
   146 bool HistoryView::calcRepaintRect()
   148 bool HistoryView::calcRepaintRect()
   147 {
   149 {
   148     if (m_resizeFactor == KMaxAnimFactor) {
   150     if (m_resizeFactor == KMaxAnimFactor) {
   263 //
   265 //
   264 void HistoryView::updateDisplay()
   266 void HistoryView::updateDisplay()
   265 {
   267 {
   266     m_bitmapContext->Clear();
   268     m_bitmapContext->Clear();
   267     m_bitmapContext->Reset();
   269     m_bitmapContext->Reset();
       
   270     
       
   271     m_bitmapContext->SetPenColor(TRgb(45,44,50));
       
   272     m_bitmapContext->SetPenStyle(CGraphicsContext::ESolidPen);
       
   273     m_bitmapContext->SetBrushColor(KRgbDarkGray);
       
   274     m_bitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   275     m_bitmapContext->DrawRect(Rect());
       
   276 	m_bitmapContext->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   277     m_bitmapContext->SetPenStyle(CGraphicsContext::ENullPen);
       
   278 	
   268 
   279 
   269     // updateDisplay something to the bitmap
   280     // updateDisplay something to the bitmap
   270     m_centerEntry = m_historyController->entryByIndex( m_centerPageIndex );
   281     m_centerEntry = m_historyController->entryByIndex( m_centerPageIndex );
   271     HistoryEntry* leftEntry = m_historyController->entryByIndex( m_centerPageIndex-1 );
   282     HistoryEntry* leftEntry = m_historyController->entryByIndex( m_centerPageIndex-1 );
   272     HistoryEntry* rightEntry = m_historyController->entryByIndex( m_centerPageIndex+1 );
   283     HistoryEntry* rightEntry = m_historyController->entryByIndex( m_centerPageIndex+1 );
   273     if (leftEntry) {
   284     if (leftEntry) {
   274         if (!leftEntry->thumbnail()) {
   285         if (!leftEntry->thumbnail()) {
   275             TRAP_IGNORE(leftEntry->constructThumbnailL());
   286             TRAP_IGNORE(leftEntry->constructThumbnailL());
   276         }
   287         }
   277         if (leftEntry->thumbnail()) {
   288         if (leftEntry->thumbnail()) {
   278             m_bitmapContext->BitBlt( m_leftPlaceHolderRect.iTl, leftEntry->thumbnail(), TRect(TPoint(0,0), m_leftPlaceHolderRect.Size()) );
   289             if(!m_maskBitmap) {
   279         }
   290                 TSize maskBitmapSize(m_leftPlaceHolderRect.Size());
   280         m_bitmapContext->SetPenColor( KSideImageBorderColor );
   291                 TRAP_IGNORE(CreateMaskBitmapForLeftRightThumbnailL(maskBitmapSize, EGray256, KSideImageMaskColor));
   281         m_bitmapContext->DrawRect(m_leftPlaceHolderRect);
   292             }
       
   293             if(m_maskBitmap) {
       
   294                 m_bitmapContext->BitBltMasked(m_leftPlaceHolderRect.iTl, leftEntry->thumbnail(), TRect(TPoint(0,0), m_leftPlaceHolderRect.Size()), m_maskBitmap, EFalse);
       
   295             }
       
   296             else {
       
   297                 //if failed to create a mask, just draw the left entry thumbnail.
       
   298                 m_bitmapContext->BitBlt( m_leftPlaceHolderRect.iTl, leftEntry->thumbnail(), TRect(TPoint(0,0), m_leftPlaceHolderRect.Size()) );
       
   299             }
       
   300         }
   282     }
   301     }
   283     // updateDisplay the next thumbnail
   302     // updateDisplay the next thumbnail
   284     if (rightEntry) {
   303     if (rightEntry) {
   285         if (!rightEntry->thumbnail()) {
   304         if (!rightEntry->thumbnail()) {
   286             TRAP_IGNORE(rightEntry->constructThumbnailL());
   305             TRAP_IGNORE(rightEntry->constructThumbnailL());
   287         }
   306         }
   288         if (rightEntry->thumbnail()) {
   307         if (rightEntry->thumbnail()) {
   289             m_bitmapContext->BitBlt( m_rightPlaceHolderRect.iTl, rightEntry->thumbnail(), TRect(TPoint(0,0), m_rightPlaceHolderRect.Size()) );
   308             if(!m_maskBitmap) {
   290         }
   309                 TSize maskBitmapSize(m_rightPlaceHolderRect.Size());
   291         m_bitmapContext->SetPenColor( KSideImageBorderColor );
   310                 TRAP_IGNORE(CreateMaskBitmapForLeftRightThumbnailL(maskBitmapSize, EGray256, KSideImageMaskColor));
   292         m_bitmapContext->DrawRect(m_rightPlaceHolderRect);
   311             }
       
   312             if(m_maskBitmap) {
       
   313                 m_bitmapContext->BitBltMasked(m_rightPlaceHolderRect.iTl, rightEntry->thumbnail(), TRect(TPoint(0,0), m_rightPlaceHolderRect.Size()), m_maskBitmap, EFalse);
       
   314             }
       
   315             else {
       
   316                 //if failed to create a mask, just draw the right entry thumbnail.
       
   317                 m_bitmapContext->BitBlt( m_rightPlaceHolderRect.iTl, rightEntry->thumbnail(), TRect(TPoint(0,0), m_rightPlaceHolderRect.Size()) );
       
   318             }
       
   319         }
   293     }
   320     }
   294     // updateDisplay the center thumbnail
   321     // updateDisplay the center thumbnail
   295     if (m_centerEntry ) {
   322     if (m_centerEntry ) {
   296         if (!m_centerEntry->thumbnail()) {
   323         if (!m_centerEntry->thumbnail()) {
   297             TRAP_IGNORE(m_centerEntry->constructThumbnailL());
   324             TRAP_IGNORE(m_centerEntry->constructThumbnailL());
   298         }
   325         }
   299         if (m_centerEntry->thumbnail()) {
   326         if (m_centerEntry->thumbnail()) {
       
   327             m_bitmapContext->SetBrushColor(KRgbWhite);
       
   328             m_bitmapContext->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   329             m_bitmapContext->DrawRect(m_centerPlaceHolderRect);    
       
   330             m_bitmapContext->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   331             TSize bitSize = m_centerEntry->thumbnail()->SizeInPixels();
   300             m_bitmapContext->BitBlt( m_centerPlaceHolderRect.iTl, m_centerEntry->thumbnail(), TRect(TPoint(0,0), m_centerPlaceHolderRect.Size()) );
   332             m_bitmapContext->BitBlt( m_centerPlaceHolderRect.iTl, m_centerEntry->thumbnail(), TRect(TPoint(0,0), m_centerPlaceHolderRect.Size()) );
   301         }
   333         }
   302     }
   334     }
       
   335     
       
   336     //Draw border for center thumbnail
       
   337     m_bitmapContext->SetPenStyle( CGraphicsContext:: ESolidPen );
   303     m_bitmapContext->SetPenColor( KCenterImageBorderColor );
   338     m_bitmapContext->SetPenColor( KCenterImageBorderColor );
   304 
       
   305     m_bitmapContext->DrawRect( m_centerPlaceHolderRect );
   339     m_bitmapContext->DrawRect( m_centerPlaceHolderRect );
   306 
   340 
   307     // Reset Brush
   341     // Reset Brush
   308     m_bitmapContext->SetBrushColor(TRgb(255,255,255));
   342     m_bitmapContext->SetBrushColor(TRgb(255,255,255));
   309     m_bitmapContext->SetBrushStyle(CGraphicsContext::ENullBrush);
   343     m_bitmapContext->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   344     m_bitmapContext->SetPenStyle(CGraphicsContext::ENullPen);
   310   // updateState(-1);
   345   // updateState(-1);
   311 }
   346 }
   312 
   347 
   313 // ----------------------------------------------------------------------------
   348 // ----------------------------------------------------------------------------
   314 // HistoryView::getCenterEntryTitle
   349 // HistoryView::getCenterEntryTitle
   804             m_historyController->historyCallback()->navigationStateChanged(TBrCtlDefs::EStateHistoryEnd, false);
   839             m_historyController->historyCallback()->navigationStateChanged(TBrCtlDefs::EStateHistoryEnd, false);
   805         }
   840         }
   806 
   841 
   807     }
   842     }
   808 }
   843 }
       
   844 
       
   845 void HistoryView::CreateMaskBitmapForLeftRightThumbnailL(TSize& aSize, TDisplayMode aDisplayMode, TRgb aRgb)
       
   846 {
       
   847     if(m_maskBitmap) {
       
   848         delete m_maskBitmap;
       
   849         m_maskBitmap = NULL;
       
   850     }
       
   851     m_maskBitmap = new (ELeave) CFbsBitmap();
       
   852     User::LeaveIfError(m_maskBitmap->Create(aSize, aDisplayMode));
       
   853     CFbsBitmapDevice* maskBitmapDevice = CFbsBitmapDevice::NewL(m_maskBitmap);
       
   854     CFbsBitGc* maskBitmapContext;
       
   855     User::LeaveIfError(maskBitmapDevice->CreateContext(maskBitmapContext));
       
   856     maskBitmapContext->SetPenStyle( CGraphicsContext::ENullPen );
       
   857     maskBitmapContext->SetBrushColor( aRgb );
       
   858     maskBitmapContext->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   859     maskBitmapContext->DrawRect(TRect(TPoint(0,0), m_maskBitmap->SizeInPixels()));
       
   860     delete maskBitmapContext;
       
   861     delete maskBitmapDevice;
       
   862 }
   809 //  End of File
   863 //  End of File