javauis/mmapi_akn/baseline/src/cmmaitemdisplay.cpp
branchRCL_3
changeset 19 04becd199f91
child 71 d5e927d5853b
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2002-2009 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 "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:  Bitmap display that draws to the Java CustomItem's bitmap.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  Include Files
       
    20 #include <jdebug.h>
       
    21 #include <lcdui.h>
       
    22 
       
    23 #include "cmmaitemdisplay.h"
       
    24 #include "cmmabitmapwindow.h"
       
    25 
       
    26 // CONSTRUCTION
       
    27 // Static constructor, leaves pointer to cleanup-stack
       
    28 CMMAItemDisplay* CMMAItemDisplay::NewLC(MMIDCustomItem* aCustomItem)
       
    29 {
       
    30     CMMAItemDisplay* self = new(ELeave) CMMAItemDisplay(aCustomItem);
       
    31     CleanupStack::PushL(self);
       
    32     self->Construct(&(aCustomItem->DirectContainer()));
       
    33     return self;
       
    34 }
       
    35 
       
    36 
       
    37 // Destructor (virtual by CBase)
       
    38 CMMAItemDisplay::~CMMAItemDisplay()
       
    39 {
       
    40 }
       
    41 
       
    42 
       
    43 CMMAItemDisplay::CMMAItemDisplay(MMIDCustomItem* aCustomItem)
       
    44         : iItem(aCustomItem)
       
    45 {
       
    46     iVisible = ETrue; // Item is visible at startup
       
    47 }
       
    48 
       
    49 void CMMAItemDisplay::SizeChangedL(CMMAItemDisplay* aDisplay,
       
    50                                    TInt /*aWidth*/,
       
    51                                    TInt /*aHeight*/)
       
    52 // currently width and height is ignored
       
    53 // may be used later to layout the image.
       
    54 {
       
    55     if (aDisplay->iWindow)
       
    56     {
       
    57         CFbsBitmap* bitmap = aDisplay->iItem->FrameBuffer();
       
    58         aDisplay->iWindow->SetDestinationBitmapL(bitmap);
       
    59     }
       
    60 }
       
    61 
       
    62 void CMMAItemDisplay::SetFullScreenL(TBool aFullScreen)
       
    63 {
       
    64     iFullScreen = aFullScreen;
       
    65     if (!iWindow)
       
    66     {
       
    67         return;
       
    68     }
       
    69     if (aFullScreen)
       
    70     {
       
    71         // switch to fullscreen
       
    72         iWindow->SetDrawRect(ScaleToFullScreen(
       
    73                                  iWindow->WindowSize(), iSourceSize));
       
    74     }
       
    75     else
       
    76     {
       
    77         // switch to normal screen
       
    78         iWindow->SetDrawRect(iUserRect);
       
    79     }
       
    80 }
       
    81 
       
    82 void CMMAItemDisplay::SetWindowL(MMMADisplayWindow* aWindow)
       
    83 {
       
    84     CMMADisplay::SetWindowL(aWindow);
       
    85     if (!iWindow)
       
    86     {
       
    87         DEBUG("CMMAItemDisplay::SetWindowL: NULL window, returning");
       
    88         return;
       
    89     }
       
    90     iSourceSize = iWindow->WindowSize();
       
    91     CFbsBitmap* bitmap = iItem->FrameBuffer();
       
    92 
       
    93     if (bitmap)
       
    94     {
       
    95         iWindow->SetDestinationBitmapL(bitmap);
       
    96     }
       
    97 }
       
    98 
       
    99 void CMMAItemDisplay::SetDisplayLocationL(const TPoint& /*aPosition*/)
       
   100 {
       
   101     // In item( USE_GUI_PRIMITIVE ) mode, this call will be ignored.
       
   102 }
       
   103 
       
   104 
       
   105 TPoint CMMAItemDisplay::DisplayLocation()
       
   106 {
       
   107     // Java Item's location is always 0, 0
       
   108     return TPoint(0, 0);
       
   109 }
       
   110 
       
   111 void CMMAItemDisplay::SourceSizeChanged(const TSize& aSourceSize)
       
   112 {
       
   113     DEBUG_INT("MMA::CMMAItemDisplay::SourceSizeChanged %d",
       
   114               aSourceSize.iWidth);
       
   115     DEBUG_INT("MMA::CMMAItemDisplay::SourceSizeChanged %d",
       
   116               aSourceSize.iHeight);
       
   117 
       
   118 #ifdef RD_JAVA_NGA_ENABLED
       
   119     if (iWindow)
       
   120     {
       
   121         TPoint topLeft(0, 0);
       
   122         iWindow->SetVideoCropRegion(TRect(topLeft, aSourceSize));
       
   123     }
       
   124 #endif
       
   125 
       
   126     iSourceSize = aSourceSize;
       
   127 
       
   128     if (iWindow)
       
   129     {
       
   130         TRect clientRect(iUserRect.iTl, aSourceSize);
       
   131 
       
   132         iWindow->SetDrawRect(clientRect);
       
   133         // Setting initial window size if not already set, actual size will
       
   134         // be set in MdcItemContentRectChanged()
       
   135         if (iWindow->WindowSize() == TSize())
       
   136         {
       
   137             iWindow->SetWindowRect(clientRect, MMMADisplay::EMmaThread);
       
   138         }
       
   139     }
       
   140 
       
   141     SetClippingRegion();
       
   142 
       
   143     if (iUserRect.IsEmpty())
       
   144     {
       
   145         // Java side hasn't set size.
       
   146         iUserRect.SetSize(iSourceSize);
       
   147     }
       
   148 }
       
   149 
       
   150 void CMMAItemDisplay::StaticSourceSize(CMMAItemDisplay* aDisplay,
       
   151                                        TSize* aSize)
       
   152 {
       
   153     *aSize = aDisplay->iUserRect.Size();
       
   154 }
       
   155 
       
   156 void CMMAItemDisplay::MdcItemContentRectChanged(const TRect& aContentRect,
       
   157         const TRect& aScreenRect)
       
   158 {
       
   159     if (iWindow)
       
   160     {
       
   161         // Change windows rect.
       
   162         iWindow->SetWindowRect(aScreenRect, MMMADisplay::EUiThread);
       
   163         TRect drawRect = aContentRect;
       
   164         drawRect.Move(- aScreenRect.iTl);
       
   165         iWindow->SetDrawRectThread(drawRect);
       
   166     }
       
   167     SetClippingRegion();
       
   168 }
       
   169 
       
   170 void CMMAItemDisplay::MdcContentBoundsChanged(const TRect& /*aRect*/)
       
   171 {
       
   172     // Do nothing in Item display
       
   173 }
       
   174 
       
   175 //  END OF FILE