javauis/lcdui_akn/lcdui/src/CMIDCustomItem.cpp
branchRCL_3
changeset 24 6c158198356e
parent 14 04becd199f91
--- a/javauis/lcdui_akn/lcdui/src/CMIDCustomItem.cpp	Thu Jul 15 18:31:06 2010 +0300
+++ b/javauis/lcdui_akn/lcdui/src/CMIDCustomItem.cpp	Thu Aug 19 09:48:13 2010 +0300
@@ -54,6 +54,17 @@
 it needs to draw bitmaps with these sizes. @see KMaxScreenSizeFactor */
 const TInt KCIMaxScreenSizeFactor = 2;
 
+// ---------------------------------------------------------------------------
+// TLcduiEvent
+// ---------------------------------------------------------------------------
+//
+enum TLcduiEvent
+{
+    EFixUIOrientation,
+    EUnFixUIOrientation
+};
+
+
 CMIDCustomItem* CMIDCustomItem::NewL(
     MMIDEnv& aEnv, const TDesC& aLabel, CMIDUIManager* aUIManager)
 {
@@ -78,6 +89,8 @@
         , iRestoreDirectContentWhenUnfaded(EFalse)
         , iPreviousVisibility(EFalse)
         , iConsumerWaitingForDSAResourcesCallback(NULL)
+        , iUiFixed(EFalse)
+        , iUiToBeFixedLater(EFalse)
 {
     iMMidItem = this;
 
@@ -246,6 +259,12 @@
     {
         iDirectContent->MdcContainerDestroyed();
     }
+    
+    if (iUiFixed && iForm)
+    {
+        iForm->CurrentDisplayable().ReleaseOrientation();
+        iUiFixed = EFalse;
+    }
 
 #ifndef RD_JAVA_NGA_ENABLED
     if (iDirectAccess)
@@ -1328,10 +1347,24 @@
     {
         ChangeDirectContainerVisibility(ETrue);
     }
+    
+    if (iUiToBeFixedLater && iForm)
+    {
+        iForm->CurrentDisplayable().FixOrientation();
+        iUiFixed = ETrue;
+        iUiToBeFixedLater = EFalse;
+    }
 }
 
 void CMIDCustomItem::ItemRemovedFromForm()
 {
+    if (iUiFixed && iForm)
+    {
+        iForm->CurrentDisplayable().ReleaseOrientation();
+        iUiFixed = EFalse;
+        iUiToBeFixedLater = EFalse;
+    }
+
     CMIDItem::ItemRemovedFromForm();
 
     ChangeDirectContainerVisibility(EFalse);
@@ -1524,6 +1557,52 @@
 }
 
 // ---------------------------------------------------------------------------
+// From class MDirectContainer.
+// CMIDCustomItem::MdcFixUIOrientation(TBool aEnableFix)
+// ---------------------------------------------------------------------------
+// 
+
+void CMIDCustomItem::MdcFixUIOrientation(TBool aEnableFix)
+{
+    if (aEnableFix)
+    {
+        iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EFixUIOrientation);
+    }
+    else
+    {
+        iEnv.ToLcduiObserver().InvokeLcduiEvent(*this, EUnFixUIOrientation);
+    }     
+}
+
+void CMIDCustomItem::HandleLcduiEvent(int aType)
+{
+   switch (aType)
+   {
+       case EFixUIOrientation:
+           if (!iUiFixed)
+           {
+               if (iForm)
+               {
+                   iForm->CurrentDisplayable().FixOrientation();
+                   iUiFixed = ETrue;
+                   iUiToBeFixedLater = EFalse;
+               }
+               else
+               {
+                   iUiToBeFixedLater = ETrue;
+               }
+           }
+           break;
+       case EUnFixUIOrientation:
+           if (iForm && iUiFixed)
+           {
+               iForm->CurrentDisplayable().ReleaseOrientation();
+               iUiFixed = EFalse;
+               iUiToBeFixedLater = EFalse;
+           }
+           break;    
+    }
+}
 //
 // ---------------------------------------------------------------------------
 //