javauis/lcdui_akn/lcdui/src/CMIDCanvasGraphicsItem.cpp
branchRCL_3
changeset 18 9ac0a0a7da70
parent 14 04becd199f91
child 21 4376525cdefb
equal deleted inserted replaced
17:0fd27995241b 18:9ac0a0a7da70
    51 //
    51 //
    52 void CMIDCanvasGraphicsItem::ConstructL(const TCtorParams& aParams)
    52 void CMIDCanvasGraphicsItem::ConstructL(const TCtorParams& aParams)
    53 {
    53 {
    54     // Set painter
    54     // Set painter
    55     iItemPainter = aParams.iPainterHandle;
    55     iItemPainter = aParams.iPainterHandle;
       
    56     iItemPainter->SetItem(this);
    56     iComponentContainer = NULL;
    57     iComponentContainer = NULL;
    57     iUtils = aParams.iUtils;
    58     iUtils = aParams.iUtils;
    58 }
    59 }
    59 
    60 
    60 // ---------------------------------------------------------------------------
    61 // ---------------------------------------------------------------------------
    61 // CMIDCanvasGraphicsItem::CMIDCanvasGraphicsItem
    62 // CMIDCanvasGraphicsItem::CMIDCanvasGraphicsItem
    62 // ---------------------------------------------------------------------------
    63 // ---------------------------------------------------------------------------
    63 //
    64 //
    64 CMIDCanvasGraphicsItem::CMIDCanvasGraphicsItem()
    65 CMIDCanvasGraphicsItem::CMIDCanvasGraphicsItem() :
       
    66     iUtils(NULL)
    65 {
    67 {
    66     // No implementation.
    68     // No implementation.
    67 }
    69 }
    68 
    70 
    69 // ---------------------------------------------------------------------------
    71 // ---------------------------------------------------------------------------
   148     }
   150     }
   149 
   151 
   150     // Store container. NULL is ok.
   152     // Store container. NULL is ok.
   151     iComponentContainer = aComponentContainer;
   153     iComponentContainer = aComponentContainer;
   152 
   154 
       
   155     // Set item size and position is needed here.
       
   156     TSize size = iItemPainter->Size();
       
   157     SetSizeL(size.iWidth, size.iHeight);
       
   158     TPoint position = iItemPainter->Position();
       
   159     SetPosition(position.iX, position.iY);
       
   160 
       
   161     if (iUtils)
       
   162     {
       
   163         // Set canvas fullscreen size is needed here.
       
   164         iItemPainter->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect());
       
   165     }
       
   166 
   153     DEBUG("CMIDCanvasGraphicsItem::SetParentL -");
   167     DEBUG("CMIDCanvasGraphicsItem::SetParentL -");
   154 }
   168 }
   155 
   169 
   156 // ---------------------------------------------------------------------------
   170 // ---------------------------------------------------------------------------
   157 // CMIDCanvasGraphicsItem::SetDirectContainerL
   171 // CMIDCanvasGraphicsItem::SetDirectContainerL
   225 // (other items are commented in the header file)
   239 // (other items are commented in the header file)
   226 // ---------------------------------------------------------------------------
   240 // ---------------------------------------------------------------------------
   227 //
   241 //
   228 void CMIDCanvasGraphicsItem::SetSizeL(const TInt aWidth, const TInt aHeight)
   242 void CMIDCanvasGraphicsItem::SetSizeL(const TInt aWidth, const TInt aHeight)
   229 {
   243 {
       
   244     // We need store non-scaled size for possible resolution
       
   245     // and fullscreen mode changes.
       
   246     iNonScaledSize = TSize(aWidth, aHeight);
   230     DEBUG_INT2(
   247     DEBUG_INT2(
   231         "CMIDCanvasGraphicsItem::SetItemSize +, aWidth=%d, aHeight=%d",
   248         "CMIDCanvasGraphicsItem::SetItemSize +, aWidth=%d, aHeight=%d",
   232         aWidth, aHeight);
   249         aWidth, aHeight);
   233 
   250 
       
   251     // Set item size.
   234     iItemPainter->SetItemSizeL(aWidth, aHeight);
   252     iItemPainter->SetItemSizeL(aWidth, aHeight);
   235 
   253 
       
   254     // If parent is in fullscreen mode
       
   255     // then it tries scale viewing rect for painter.
       
   256     // Otherwise the non scaled size is set.
       
   257     if (IsScalingOn())
       
   258     {
       
   259         iItemPainter->SetViewSize(iUtils->DoScaling(iNonScaledSize));
       
   260     }
       
   261     else
       
   262     {
       
   263         iItemPainter->SetViewSize(iNonScaledSize);
       
   264     }
       
   265 
   236     DEBUG("CMIDCanvasGraphicsItem::SetItemSize -");
   266     DEBUG("CMIDCanvasGraphicsItem::SetItemSize -");
   237 }
   267 }
   238 
   268 
   239 // ---------------------------------------------------------------------------
   269 // ---------------------------------------------------------------------------
   240 // CMIDCanvasGraphicsItem::SetPosition
   270 // CMIDCanvasGraphicsItem::SetPosition
   243 //
   273 //
   244 void CMIDCanvasGraphicsItem::SetPosition(const TInt aX, const TInt aY)
   274 void CMIDCanvasGraphicsItem::SetPosition(const TInt aX, const TInt aY)
   245 {
   275 {
   246     DEBUG_INT2("CMIDCanvasGraphicsItem::SetPosition +, aX=%d, aY=%d", aX, aY);
   276     DEBUG_INT2("CMIDCanvasGraphicsItem::SetPosition +, aX=%d, aY=%d", aX, aY);
   247 
   277 
   248     iItemPainter->SetPosition(aX, aY);
   278     // We need store non-scaled size for possible resolution
       
   279     // and fullscreen mode changes.
       
   280     iNonScaledPosition = TPoint(aX, aY);
       
   281 
       
   282     // If parent is in fullscreen mode
       
   283     // then it tries scale position of item.
       
   284     // Otherwise the non scaled size is set.
       
   285     if (IsScalingOn())
       
   286     {
       
   287         TPoint origin = iUtils->DoScalingAndPositioning(iNonScaledPosition);
       
   288         iItemPainter->SetPosition(origin.iX, origin.iY);
       
   289     }
       
   290     else
       
   291     {
       
   292         iItemPainter->SetPosition(aX, aY);
       
   293     }
   249 
   294 
   250     DEBUG("CMIDCanvasGraphicsItem::SetPosition -");
   295     DEBUG("CMIDCanvasGraphicsItem::SetPosition -");
   251 }
   296 }
   252 
   297 
   253 // ---------------------------------------------------------------------------
   298 // ---------------------------------------------------------------------------
   264     DEBUG("CMIDCanvasGraphicsItem::Dispose -");
   309     DEBUG("CMIDCanvasGraphicsItem::Dispose -");
   265 }
   310 }
   266 
   311 
   267 // ---------------------------------------------------------------------------
   312 // ---------------------------------------------------------------------------
   268 // CMIDCanvasGraphicsItem::HandleFullscreenModeChange
   313 // CMIDCanvasGraphicsItem::HandleFullscreenModeChange
   269 // Intentionally this is not implemented.
   314 // (other items are commented in the header file)
   270 // CanavsGraohicsItem is not doing any action in this case.
       
   271 // ---------------------------------------------------------------------------
   315 // ---------------------------------------------------------------------------
   272 //
   316 //
   273 void CMIDCanvasGraphicsItem::HandleFullscreenModeChange()
   317 void CMIDCanvasGraphicsItem::HandleFullscreenModeChange()
   274 {
   318 {
       
   319     // Calling all functions which set size and position.
       
   320     TRAPD(err, SetSizeL(iNonScaledSize.iWidth, iNonScaledSize.iHeight));
       
   321     if (err != KErrNone)
       
   322     {
       
   323         DEBUG_INT("CMIDCanvasGraphicsItem::HandleFullscreenModeChange: SetSizeL method leave with %d code", err);
       
   324     }
       
   325     SetPosition(iNonScaledPosition.iX, iNonScaledPosition.iY);
       
   326 
       
   327     if (iUtils)
       
   328     {
       
   329         // Setting of fullscreen canvas rect.
       
   330         iItemPainter->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect());
       
   331     }
   275 }
   332 }
   276 
   333 
   277 // ---------------------------------------------------------------------------
   334 // ---------------------------------------------------------------------------
   278 // CMIDCanvasGraphicsItem::HandleResolutionChange
   335 // CMIDCanvasGraphicsItem::HandleResolutionChange
   279 // Intentionally this is not implemented.
   336 // (other items are commented in the header file)
   280 // CanavsGraohicsItem is not doing any action in this case.
       
   281 // ---------------------------------------------------------------------------
   337 // ---------------------------------------------------------------------------
   282 //
   338 //
   283 void CMIDCanvasGraphicsItem::HandleResolutionChange()
   339 void CMIDCanvasGraphicsItem::HandleResolutionChange()
   284 {
   340 {
       
   341     // Calling all functions which set size and position.
       
   342     TRAPD(err, SetSizeL(iNonScaledSize.iWidth, iNonScaledSize.iHeight));
       
   343     if (err != KErrNone)
       
   344     {
       
   345         DEBUG_INT("CMIDCanvasGraphicsItem::HandleFullscreenModeChange: SetSizeL method leave with %d code", err);
       
   346     }
       
   347     SetPosition(iNonScaledPosition.iX, iNonScaledPosition.iY);
       
   348     if (iUtils)
       
   349     {
       
   350         // Setting of fullscreen canvas rect.
       
   351         iItemPainter->SetOnScreenCanvasRect(iUtils->GetOnScreenCanvasRect());
       
   352     }
       
   353 }
       
   354 
       
   355 TBool CMIDCanvasGraphicsItem::IsScalingOn() const
       
   356 {
       
   357     return iUtils && iComponentContainer && iUtils->IsScalingEnabled() &&
       
   358            iComponentContainer->IsFullScreen();
   285 }
   359 }
   286 
   360 
   287 // End of file
   361 // End of file