javauis/lcdui_akn/lcdui/src/CMIDCanvasGraphicsItem.cpp
branchRCL_3
changeset 60 6c158198356e
parent 59 e5618cc85d74
--- a/javauis/lcdui_akn/lcdui/src/CMIDCanvasGraphicsItem.cpp	Thu Jul 15 18:31:06 2010 +0300
+++ b/javauis/lcdui_akn/lcdui/src/CMIDCanvasGraphicsItem.cpp	Thu Aug 19 09:48:13 2010 +0300
@@ -81,6 +81,12 @@
 {
     DEBUG("CMIDCanvasGraphicsItem::~CMIDCanvasGraphicsItem +");
 
+    // When disposing item first, removes the painter parent
+    if (iItemPainter)
+    {
+        iItemPainter->SetItem(NULL);
+    }
+    
     // Remove this component from the container if set.
     if (iComponentContainer)
     {
@@ -313,7 +319,7 @@
 void CMIDCanvasGraphicsItem::Dispose()
 {
     DEBUG("CMIDCanvasGraphicsItem::Dispose +");
-
+    
     delete this;
 
     DEBUG("CMIDCanvasGraphicsItem::Dispose -");
@@ -370,6 +376,15 @@
     }
 }
 
+void CMIDCanvasGraphicsItem::HandleForeground(TBool aForeground)
+{
+    // If Canvas goes to foreground and scaling is on,
+    // then we resize a CanvasGraphicsItem.
+    if (aForeground)
+    {
+        HandleChangeForScaling(EForegroundGained);
+    }
+}
 void CMIDCanvasGraphicsItem::HandleChangeForScaling(TChange aChange)
 {
     // Calling functions which set size and position.
@@ -380,7 +395,9 @@
     }
     SetPosition(iNonScaledPosition.iX, iNonScaledPosition.iY);
 
-    if (aChange == EResolutionChange || aChange == EFullscreenChange)
+    if (aChange == EResolutionChange
+            || aChange == EFullscreenChange
+            || aChange == EForegroundGained)
     {
         if (iUtils)
         {
@@ -406,4 +423,16 @@
 #endif // RD_JAVA_S60_RELEASE_9_2
 }
 
+void CMIDCanvasGraphicsItem::DeregisterCanvasGraphicsItem()
+{
+    // This method is called on item from painter, when painter is disposed 
+    // before disposal of item
+    if (iComponentContainer)
+    {
+        // Remove this component from the container if set.
+        iComponentContainer->UnregisterComponent(this);
+    }
+
+    iComponentContainer = NULL;
+}
 // End of file