javauis/lcdui_akn/lcdui/src/CMIDDisplayable.cpp
branchRCL_3
changeset 60 6c158198356e
parent 59 e5618cc85d74
equal deleted inserted replaced
59:e5618cc85d74 60:6c158198356e
   270                 LcduiMidletAttributeValues::KPositionBottom))
   270                 LcduiMidletAttributeValues::KPositionBottom))
   271     {
   271     {
   272         iSKPositionWithQwerty = ESoftkeysBottom;
   272         iSKPositionWithQwerty = ESoftkeysBottom;
   273     }
   273     }
   274     else
   274     else
   275     {//default value
   275     {
       
   276         //default value
   276         iSKPositionWithQwerty = ESoftkeysRight;
   277         iSKPositionWithQwerty = ESoftkeysRight;
   277     }
   278     }
   278 
   279 
   279     // initialization of keypad information
   280     // initialization of keypad information
   280     ReadOnScreenKeypadTypeFromSuiteSettings();
   281     ReadOnScreenKeypadTypeFromSuiteSettings();
   289         iFullscreenCanvasLabelCacheIsValid(EFalse)
   290         iFullscreenCanvasLabelCacheIsValid(EFalse)
   290 #ifdef RD_TACTILE_FEEDBACK
   291 #ifdef RD_TACTILE_FEEDBACK
   291         ,iPenInputServerConnected(EFalse)
   292         ,iPenInputServerConnected(EFalse)
   292 #endif //RD_TACTILE_FEEDBACK
   293 #endif //RD_TACTILE_FEEDBACK
   293         ,iIdOfMSKCommand(KErrNotFound)
   294         ,iIdOfMSKCommand(KErrNotFound)
       
   295         ,iRestoreOrientation(EFalse)
       
   296         ,iReleaseCnt(0)
   294 {
   297 {
   295 #ifdef RD_JAVA_S60_RELEASE_9_2
   298 #ifdef RD_JAVA_S60_RELEASE_9_2
   296     iSplitScreenKeyboard = EFalse;
   299     iSplitScreenKeyboard = EFalse;
   297 #endif // RD_JAVA_S60_RELEASE_9_2
   300 #endif // RD_JAVA_S60_RELEASE_9_2
   298     iAppUi = (CMIDAppUi*)java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->getLcduiChild();
   301     iAppUi = (CMIDAppUi*)java::ui::CoreUiAvkonLcdui::getInstance().getJavaUiAppUi()->getLcduiChild();
   357 
   360 
   358     iSoftKeys.ResetAndDestroy();
   361     iSoftKeys.ResetAndDestroy();
   359     delete iCommandList;
   362     delete iCommandList;
   360 
   363 
   361     if (iMenuHandler->GetDisplayable() == this)
   364     if (iMenuHandler->GetDisplayable() == this)
   362     {//this may happen when the application is exiting
   365     {
       
   366         //this may happen when the application is exiting
   363         iMenuHandler->SetDisplayable(NULL);
   367         iMenuHandler->SetDisplayable(NULL);
   364     }
   368     }
   365 
   369 
   366     DEBUG("- CMIDDisplayable::CMIDDisplayable");
   370     DEBUG("- CMIDDisplayable::CMIDDisplayable");
   367 }
   371 }
   370  * This means we are being deleted java side. We delete ourselves.
   374  * This means we are being deleted java side. We delete ourselves.
   371  * However before doing this we call ReplaceBehindAlertIfNeeded().
   375  * However before doing this we call ReplaceBehindAlertIfNeeded().
   372  **/
   376  **/
   373 void CMIDDisplayable::Dispose()
   377 void CMIDDisplayable::Dispose()
   374 {
   378 {
   375     if (iAppUi)
       
   376     {
       
   377         iAppUi->UnSetEnv();
       
   378     }
       
   379     ReplaceBehindAlertIfNeeded();
   379     ReplaceBehindAlertIfNeeded();
   380 
   380 
   381     delete this;
   381     delete this;
   382 }
   382 }
   383 
   383 
   394 {
   394 {
   395     if ((this != iUIManager->GetDefaultDisplayable())
   395     if ((this != iUIManager->GetDefaultDisplayable())
   396             && IsVisible()
   396             && IsVisible()
   397             && (iMenuHandler->GetDisplayable())
   397             && (iMenuHandler->GetDisplayable())
   398             && (iMenuHandler->GetDisplayable()->Component()->Type() == EAlert))
   398             && (iMenuHandler->GetDisplayable()->Component()->Type() == EAlert))
   399     {// In this case we are a faded displayable behind a dialog
   399     {
       
   400         // In this case we are a faded displayable behind a dialog
   400         TInt numDisplayables = iAppUi->Displayables().Count();
   401         TInt numDisplayables = iAppUi->Displayables().Count();
   401         TInt index = -1;
   402         TInt index = -1;
   402         TInt currentPosition = 999;
   403         TInt currentPosition = 999;
   403         for (TInt i = 0; i < numDisplayables; i++)
   404         for (TInt i = 0; i < numDisplayables; i++)
   404         {
   405         {
   630             {
   631             {
   631                 User::LeaveIfError(aItems.Append(item));
   632                 User::LeaveIfError(aItems.Append(item));
   632             }
   633             }
   633 #else
   634 #else
   634             User::LeaveIfError(aItems.Append(item));
   635             User::LeaveIfError(aItems.Append(item));
   635 #endif // RD_JAVA_S60_RELEASE_9_2        
   636 #endif // RD_JAVA_S60_RELEASE_9_2
   636         }
   637         }
   637     }
   638     }
   638 }
   639 }
   639 
   640 
   640 
   641 
   669 
   670 
   670         // Add form commands always
   671         // Add form commands always
   671         PopulateMenuItemsWithListL(aMenuType, aMenuItems, iCommandList, EFalse);
   672         PopulateMenuItemsWithListL(aMenuType, aMenuItems, iCommandList, EFalse);
   672     }
   673     }
   673     else if (aMenuType == CMIDMenuHandler::EHelpMenu)
   674     else if (aMenuType == CMIDMenuHandler::EHelpMenu)
   674     { // Add the Help commands only
   675     {
       
   676         // Add the Help commands only
   675         PopulateMenuItemsWithListL(aMenuType, aMenuItems, iCommandList, EFalse);
   677         PopulateMenuItemsWithListL(aMenuType, aMenuItems, iCommandList, EFalse);
   676     }
   678     }
   677     else if (aMenuType == CMIDMenuHandler::EOptionsMenu)
   679     else if (aMenuType == CMIDMenuHandler::EOptionsMenu)
   678     {
   680     {
   679         PopulateMenuItemsWithListL(aMenuType, aMenuItems, iItemCommandList, EFalse);
   681         PopulateMenuItemsWithListL(aMenuType, aMenuItems, iItemCommandList, EFalse);
   691     {
   693     {
   692         return;
   694         return;
   693     }
   695     }
   694 
   696 
   695     if (aCommandId == EAknSoftkeyContextOptions)
   697     if (aCommandId == EAknSoftkeyContextOptions)
   696     { // MSK command to show context sensitive menu -> open it
   698     {
       
   699         // MSK command to show context sensitive menu -> open it
   697         ShowOkOptionsMenuL();
   700         ShowOkOptionsMenuL();
   698     }
   701     }
   699     else if (aCommandId == KBuiltInMSKCommandId)
   702     else if (aCommandId == KBuiltInMSKCommandId)
   700     {
   703     {
   701         // Handle built-in command that is not accessible from menus, only in MSK.
   704         // Handle built-in command that is not accessible from menus, only in MSK.
   728         {
   731         {
   729             CMIDForm* form = static_cast<CMIDForm*>(iContentControl);
   732             CMIDForm* form = static_cast<CMIDForm*>(iContentControl);
   730             form->PostPendingUpEventL();
   733             form->PostPendingUpEventL();
   731         }
   734         }
   732     }
   735     }
   733 #endif // RD_JAVA_S60_RELEASE_9_2    
   736 #endif // RD_JAVA_S60_RELEASE_9_2
   734 }
   737 }
   735 
   738 
   736 #ifdef RD_SCALABLE_UI_V2
   739 #ifdef RD_SCALABLE_UI_V2
   737 /** */
   740 /** */
   738 // This function can be moved out from RD_SCALABLE_UI_V2 flag if needed.
   741 // This function can be moved out from RD_SCALABLE_UI_V2 flag if needed.
   750 /** */
   753 /** */
   751 void CMIDDisplayable::HandleStandardCommandL(const TCommandEntry& aCmdEntry)
   754 void CMIDDisplayable::HandleStandardCommandL(const TCommandEntry& aCmdEntry)
   752 {
   755 {
   753     TBool postJavaEvent = ETrue;
   756     TBool postJavaEvent = ETrue;
   754     if (aCmdEntry.iCommand->Id() < 0)
   757     if (aCmdEntry.iCommand->Id() < 0)
   755     { //non-midlet command, see if there is an observer
   758     {
       
   759         //non-midlet command, see if there is an observer
   756         if (aCmdEntry.iCommand->Observer())
   760         if (aCmdEntry.iCommand->Observer())
   757         {
   761         {
   758             postJavaEvent = !(aCmdEntry.iCommand->Observer()->ProcessCommandL(aCmdEntry.iCommand));
   762             postJavaEvent = !(aCmdEntry.iCommand->Observer()->ProcessCommandL(aCmdEntry.iCommand));
   759         }
   763         }
   760     }
   764     }
   768 /** */
   772 /** */
   769 void CMIDDisplayable::HandleItemCommandL(const TCommandEntry& aCmdEntry)
   773 void CMIDDisplayable::HandleItemCommandL(const TCommandEntry& aCmdEntry)
   770 {
   774 {
   771     TBool postJavaEvent = ETrue;
   775     TBool postJavaEvent = ETrue;
   772     if (aCmdEntry.iCommand->Id() < 0)
   776     if (aCmdEntry.iCommand->Id() < 0)
   773     { //non-midlet command, see if there is an observer
   777     {
       
   778         //non-midlet command, see if there is an observer
   774         if (aCmdEntry.iCommand->Observer())
   779         if (aCmdEntry.iCommand->Observer())
   775         {
   780         {
   776             postJavaEvent = !(aCmdEntry.iCommand->Observer()->ProcessCommandL(aCmdEntry.iCommand));
   781             postJavaEvent = !(aCmdEntry.iCommand->Observer()->ProcessCommandL(aCmdEntry.iCommand));
   777         }
   782         }
   778     }
   783     }
   988         CMIDForm* form = static_cast<CMIDForm*>(iContentControl);
   993         CMIDForm* form = static_cast<CMIDForm*>(iContentControl);
   989         ASSERT(form);
   994         ASSERT(form);
   990         form->HandleForegroundL(aForeground);
   995         form->HandleForegroundL(aForeground);
   991     }
   996     }
   992 
   997 
   993     HandleCanvasForeground(aForeground);
   998     // Notify canvas about gained foreground only if it is the current displayable
       
   999     if (!aForeground || iActive)
       
  1000     {
       
  1001         HandleCanvasForeground(aForeground);
       
  1002     }
   994 
  1003 
   995     if (aForeground)
  1004     if (aForeground)
   996     {
  1005     {
   997         //If MIDlet is sent to foreground and JAD-attribute BackgroundEvent=Pause,
  1006         // If MIDlet is sent to foreground and JAD-attribute BackgroundEvent=Pause,
   998         //then call startApp() method for the MIDlet.
  1007         // then call startApp() method for the MIDlet.
   999 
  1008 
  1000         if (iEnv.MidletAttributeIsSetToVal(LcduiMidletAttributes::KAttribBackgroundEvent,
  1009         if (iEnv.MidletAttributeIsSetToVal(LcduiMidletAttributes::KAttribBackgroundEvent,
  1001                                            LcduiMidletAttributeValues::KPauseValue))
  1010                                            LcduiMidletAttributeValues::KPauseValue))
  1002 
  1011 
  1003         {
  1012         {
  1004             iEnv.PostMidletEvent(EStart);
  1013             iEnv.PostMidletEvent(EStart);
       
  1014             iAppUi->SetPauseAppState(EFalse);
  1005         }
  1015         }
  1006     }
  1016     }
  1007     else //to background
  1017     else //to background
  1008     {
  1018     {
  1009 
  1019 
  1010         //If MIDlet is sent to background and JAD-attribute BackgroundEvent=Pause,
  1020         // If MIDlet is sent to background and JAD-attribute BackgroundEvent=Pause,
  1011         //then call pauseApp() method for the MIDlet.
  1021         // and window is not faded yet or window is already faded but pauseApp was not called yet,
       
  1022         // then call pauseApp() method for the MIDlet.
       
  1023         TBool isfaded = this->DrawableWindow()->IsFaded();
  1012 
  1024 
  1013         if (iEnv.MidletAttributeIsSetToVal(LcduiMidletAttributes::KAttribBackgroundEvent,
  1025         if (iEnv.MidletAttributeIsSetToVal(LcduiMidletAttributes::KAttribBackgroundEvent,
  1014                                            LcduiMidletAttributeValues::KPauseValue) &&
  1026                                            LcduiMidletAttributeValues::KPauseValue) && (!isfaded ||
  1015                 !this->DrawableWindow()->IsFaded())
  1027                                                    (isfaded && !iAppUi->GetPauseAppState())))
  1016 
  1028 
  1017         {
  1029         {
  1018             iEnv.PostMidletEvent(EPause);
  1030             iEnv.PostMidletEvent(EPause);
       
  1031             iAppUi->SetPauseAppState(ETrue);
  1019         }
  1032         }
  1020     }
  1033     }
  1021     DEBUG("- CMIDDisplayable::HandleForegroundL");
  1034     DEBUG("- CMIDDisplayable::HandleForegroundL");
  1022 }
  1035 }
  1023 
  1036 
  1028 void CMIDDisplayable::HandleResourceChangeL(TInt aType)
  1041 void CMIDDisplayable::HandleResourceChangeL(TInt aType)
  1029 {
  1042 {
  1030     DEBUG("+ CMIDDisplayable::HandleResourceChangeL");
  1043     DEBUG("+ CMIDDisplayable::HandleResourceChangeL");
  1031 
  1044 
  1032     if (aType == KEikDynamicLayoutVariantSwitch)
  1045     if (aType == KEikDynamicLayoutVariantSwitch)
  1033     { // dynamic orientation change
  1046     {
       
  1047         // dynamic orientation change
  1034 
  1048 
  1035         // Correct rect is set for displayable
  1049         // Correct rect is set for displayable
  1036         if (iActive && iCanvasKeypad)
  1050         if (iActive && iCanvasKeypad)
  1037         { //Update correct On-Screen Keypad type
  1051         {
       
  1052             //Update correct On-Screen Keypad type
  1038             UpdateOnScreenKeypadSettings();
  1053             UpdateOnScreenKeypadSettings();
  1039         }
  1054         }
  1040         UpdateDisplayableRect();
  1055         UpdateDisplayableRect();
  1041         SetRect(iDisplayableRect);
  1056         SetRect(iDisplayableRect);
  1042 
  1057 
  1043         // MIDlet icon is resized in cpane SizeChanged()
  1058         // MIDlet icon is resized in cpane SizeChanged()
  1044         if (!iActive && iContentControl)
  1059         if (!iActive && iContentControl)
  1045         {//The active displayable already gets this call by the CONE framework but
  1060         {
       
  1061             //The active displayable already gets this call by the CONE framework but
  1046             //background displayables don't, so for example a background form won't be
  1062             //background displayables don't, so for example a background form won't be
  1047             //re-laid-out if we don't call this here
  1063             //re-laid-out if we don't call this here
  1048             iContentControl->HandleResourceChange(aType);
  1064             iContentControl->HandleResourceChange(aType);
  1049         }
  1065         }
  1050 #ifdef RD_SCALABLE_UI_V2
  1066 #ifdef RD_SCALABLE_UI_V2
       
  1067         // When current Displayble is Canvas or popup Displayable and the last
       
  1068         // Displayble was Canvas, then OSK visual appearance is needed
       
  1069         //  to be change.
  1051         if (iUseOnScreenKeypad && iCanvasKeypad && (iActive || this->DrawableWindow()->IsFaded()))
  1070         if (iUseOnScreenKeypad && iCanvasKeypad && (iActive || this->DrawableWindow()->IsFaded()))
  1052         {
  1071         {
  1053             iCanvasKeypad->UpdateVisualAppearanceL(*iCanvas, iOnScreenKeyboardType, *this);
  1072             if (iActive)
       
  1073             {
       
  1074                 // Current is Canvas.
       
  1075                 iCanvasKeypad->UpdateVisualAppearanceL(*iCanvas, iOnScreenKeyboardType, *this);
       
  1076             }
       
  1077             else
       
  1078             {
       
  1079                 // Get current Displayable and the last fullscreen Displayble.
       
  1080                 MMIDDisplayable* current = iEnv.Current();
       
  1081                 const MMIDDisplayable* last = iEnv.LastFullscreenDisplayable();
       
  1082                 if (current && last && current->Component()
       
  1083                         && last->Component())
       
  1084                 {
       
  1085                     // Get types of Displayables.
       
  1086                     MMIDComponent::TType lastType = last->Component()->Type();
       
  1087                     MMIDComponent::TType currentType = current->Component()->Type();
       
  1088                     if (lastType == ECanvas)
       
  1089                     {
       
  1090                         if (currentType == EAlert)
       
  1091                         {
       
  1092                             // Current is Alert and the last fullscreen
       
  1093                             // Displayable was Canvas.
       
  1094                             iCanvasKeypad->UpdateVisualAppearanceL(
       
  1095                                 *iCanvas, iOnScreenKeyboardType, *this);
       
  1096                         }
       
  1097                         else if (currentType == ETextBox && current->IsPopupTextBox())
       
  1098                         {
       
  1099                             // Current is popup TextBox and the last fullscreen
       
  1100                             // Displayable was Canvas.
       
  1101                             iCanvasKeypad->UpdateVisualAppearanceL(
       
  1102                                 *iCanvas, iOnScreenKeyboardType, *this);
       
  1103                         }
       
  1104                     }
       
  1105                 }
       
  1106             }
  1054         }
  1107         }
  1055 #endif // RD_SCALABLE_UI_V2
  1108 #endif // RD_SCALABLE_UI_V2
  1056         iFullscreenCanvasLabelCacheIsValid = EFalse;
  1109         iFullscreenCanvasLabelCacheIsValid = EFalse;
  1057     }
  1110     }
  1058     else if (aType == KEikColorResourceChange ||
  1111     else if (aType == KEikColorResourceChange ||
  1059              aType == KAknsMessageSkinChange  ||
  1112              aType == KAknsMessageSkinChange  ||
  1060              aType == KUidValueCoeColorSchemeChangeEvent)
  1113              aType == KUidValueCoeColorSchemeChangeEvent)
  1061     { //skin or color change, may need to recreate ctx icon
  1114     {
       
  1115         //skin or color change, may need to recreate ctx icon
  1062         // send skin change event to non-active controls so they can also
  1116         // send skin change event to non-active controls so they can also
  1063         // reload graphics
  1117         // reload graphics
  1064         if (!iActive && iContentControl)
  1118         if (!iActive && iContentControl)
  1065         {
  1119         {
  1066             iContentControl->HandleResourceChange(aType);
  1120             iContentControl->HandleResourceChange(aType);
  1080     if ((aType == KEikInputLanguageChange) && iContentControl)
  1134     if ((aType == KEikInputLanguageChange) && iContentControl)
  1081     {
  1135     {
  1082         iContentControl->HandleResourceChange(aType);
  1136         iContentControl->HandleResourceChange(aType);
  1083     }
  1137     }
  1084 }
  1138 }
       
  1139 
       
  1140 #ifdef RD_JAVA_NGA_ENABLED
       
  1141 void CMIDDisplayable::HandleFullOrPartialForegroundL(TBool aFullOrPartialFg)
       
  1142 {
       
  1143     CMIDCanvas* canvas = GetContentCanvas();
       
  1144     if (canvas)
       
  1145     {
       
  1146         canvas->HandleFullOrPartialForegroundL(aFullOrPartialFg, iActive);
       
  1147     }
       
  1148 }
       
  1149 
       
  1150 void CMIDDisplayable::HandleFreeGraphicsMemory()
       
  1151 {
       
  1152     CMIDCanvas* canvas = GetContentCanvas();
       
  1153     if (canvas)
       
  1154     {
       
  1155         canvas->FreeGraphicsMemory(ETrue);
       
  1156     }
       
  1157 }
       
  1158 #endif // RD_JAVA_NGA_ENABLED
  1085 
  1159 
  1086 /**
  1160 /**
  1087  * The container has changed it available drawing space, so resize
  1161  * The container has changed it available drawing space, so resize
  1088  * the displayable to fit and post a size changed event.
  1162  * the displayable to fit and post a size changed event.
  1089  **/
  1163  **/
  1148 //
  1222 //
  1149 TRect CMIDDisplayable::GetCanvasRectFromLaf()
  1223 TRect CMIDDisplayable::GetCanvasRectFromLaf()
  1150 {
  1224 {
  1151     DEBUG("+ CMIDDisplayable::GetCanvasRectFromLaf");
  1225     DEBUG("+ CMIDDisplayable::GetCanvasRectFromLaf");
  1152 
  1226 
  1153     TRect resultRect;
  1227     TRect resultRect = TRect(0,0,0,0);
  1154     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, resultRect);
  1228     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, resultRect);
  1155     TAknLayoutRect canvasRect;
  1229     TAknLayoutRect canvasRect;
  1156     TAknLayoutRect mainPane;
  1230     TAknLayoutRect mainPane;
  1157     TAknLayoutRect mainMidpPane;
  1231     TAknLayoutRect mainMidpPane;
  1158 
  1232 
  1159     //Read canvasRect from LAF depending on keyboard type
  1233 #ifdef RD_JAVA_S60_RELEASE_9_2
  1160     switch (iOnScreenKeyboardType)
  1234     // If split screen is open, then it is needed return current size of Canvas.
  1161     {
  1235     if (iSplitScreenKeyboard)
  1162     case EOnScreenKeypadValueNo:
  1236     {
  1163         break;
  1237         CMIDCanvas* canvas = GetContentCanvas();
  1164     case EOnScreenKeypadValueNavigationKeys:
  1238         if (canvas)
  1165     {
  1239         {
  1166         if (iIsFullScreenMode)
  1240             resultRect = canvas->ViewRect();
  1167         {
  1241         }
  1168             if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
  1242     }
  1169             {
  1243     else
  1170                 canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(1).LayoutLine());
  1244     {
  1171             }
  1245 #endif // RD_JAVA_S60_RELEASE_9_2    
  1172             else //landscape
  1246         //Read canvasRect from LAF depending on keyboard type
  1173             {
  1247         switch (iOnScreenKeyboardType)
  1174                 canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(8).LayoutLine());
  1248         {
  1175             }
  1249         case EOnScreenKeypadValueNo:
  1176         }
  1250             break;
  1177         else //normal mode
  1251         case EOnScreenKeypadValueNavigationKeys:
  1178         {
  1252         {
  1179             if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
  1253             if (iIsFullScreenMode)
  1180             {
  1254             {
  1181                 mainPane.LayoutRect(resultRect, AknLayoutScalable_Avkon::main_pane(3).LayoutLine());
  1255                 if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
  1182                 mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::main_midp_pane(0).LayoutLine());
       
  1183                 canvasRect.LayoutRect(mainMidpPane.Rect(), AknLayoutScalable_Avkon::midp_canvas_pane(4).LayoutLine());
       
  1184             }
       
  1185             else //landscape
       
  1186             {
       
  1187                 mainPane.LayoutRect(resultRect, AknLayoutScalable_Avkon::main_pane(4).LayoutLine());
       
  1188                 mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::main_midp_pane(1).LayoutLine());
       
  1189                 canvasRect.LayoutRect(mainMidpPane.Rect(), AknLayoutScalable_Avkon::midp_canvas_pane(7).LayoutLine());
       
  1190             }
       
  1191         }
       
  1192         resultRect = canvasRect.Rect();
       
  1193         break;
       
  1194     }
       
  1195     case EOnScreenKeypadValueGameActions:
       
  1196     {
       
  1197         if (iIsFullScreenMode)
       
  1198         {
       
  1199             if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
       
  1200             {
       
  1201                 canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(2).LayoutLine());
       
  1202             }
       
  1203             else //landscape
       
  1204             {
       
  1205                 canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(3).LayoutLine());
       
  1206             }
       
  1207         }
       
  1208         else //normal mode
       
  1209         {
       
  1210             if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
       
  1211             {
       
  1212                 mainPane.LayoutRect(resultRect, AknLayoutScalable_Avkon::main_pane(3).LayoutLine());
       
  1213                 mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::main_midp_pane(0).LayoutLine());
       
  1214                 canvasRect.LayoutRect(mainMidpPane.Rect(), AknLayoutScalable_Avkon::midp_canvas_pane(5).LayoutLine());
       
  1215             }
       
  1216             else//landscape
       
  1217             {
       
  1218                 mainPane.LayoutRect(resultRect, AknLayoutScalable_Avkon::main_pane(4).LayoutLine());
       
  1219                 mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::main_midp_pane(1).LayoutLine());
       
  1220                 canvasRect.LayoutRect(mainMidpPane.Rect(), AknLayoutScalable_Avkon::midp_canvas_pane(6).LayoutLine());
       
  1221             }
       
  1222         }
       
  1223         resultRect = canvasRect.Rect();
       
  1224         break;
       
  1225     }
       
  1226     case EOnScreenKeypadValueLskRsk:
       
  1227     {
       
  1228         if (iIsFullScreenMode)
       
  1229         {
       
  1230             if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
       
  1231             {
       
  1232                 canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(11).LayoutLine());
       
  1233             }
       
  1234             else //landscape
       
  1235             {
       
  1236                 if (iSKPositionWithQwerty == ESoftkeysRight)
       
  1237                 {
  1256                 {
  1238                     canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(10).LayoutLine());
  1257                     canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(1).LayoutLine());
  1239                 }
  1258                 }
  1240                 else
  1259                 else //landscape
  1241                 {
  1260                 {
       
  1261                     canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(8).LayoutLine());
       
  1262                 }
       
  1263             }
       
  1264             else //normal mode
       
  1265             {
       
  1266                 if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
       
  1267                 {
       
  1268                     mainPane.LayoutRect(resultRect, AknLayoutScalable_Avkon::main_pane(3).LayoutLine());
       
  1269                     mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::main_midp_pane(0).LayoutLine());
       
  1270                     canvasRect.LayoutRect(mainMidpPane.Rect(), AknLayoutScalable_Avkon::midp_canvas_pane(4).LayoutLine());
       
  1271                 }
       
  1272                 else //landscape
       
  1273                 {
       
  1274                     mainPane.LayoutRect(resultRect, AknLayoutScalable_Avkon::main_pane(4).LayoutLine());
       
  1275                     mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::main_midp_pane(1).LayoutLine());
       
  1276                     canvasRect.LayoutRect(mainMidpPane.Rect(), AknLayoutScalable_Avkon::midp_canvas_pane(7).LayoutLine());
       
  1277                 }
       
  1278             }
       
  1279             resultRect = canvasRect.Rect();
       
  1280             break;
       
  1281         }
       
  1282         case EOnScreenKeypadValueGameActions:
       
  1283         {
       
  1284             if (iIsFullScreenMode)
       
  1285             {
       
  1286                 if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
       
  1287                 {
       
  1288                     canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(2).LayoutLine());
       
  1289                 }
       
  1290                 else //landscape
       
  1291                 {
       
  1292                     canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(3).LayoutLine());
       
  1293                 }
       
  1294             }
       
  1295             else //normal mode
       
  1296             {
       
  1297                 if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
       
  1298                 {
       
  1299                     mainPane.LayoutRect(resultRect, AknLayoutScalable_Avkon::main_pane(3).LayoutLine());
       
  1300                     mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::main_midp_pane(0).LayoutLine());
       
  1301                     canvasRect.LayoutRect(mainMidpPane.Rect(), AknLayoutScalable_Avkon::midp_canvas_pane(5).LayoutLine());
       
  1302                 }
       
  1303                 else//landscape
       
  1304                 {
       
  1305                     mainPane.LayoutRect(resultRect, AknLayoutScalable_Avkon::main_pane(4).LayoutLine());
       
  1306                     mainMidpPane.LayoutRect(mainPane.Rect(), AknLayoutScalable_Avkon::main_midp_pane(1).LayoutLine());
       
  1307                     canvasRect.LayoutRect(mainMidpPane.Rect(), AknLayoutScalable_Avkon::midp_canvas_pane(6).LayoutLine());
       
  1308                 }
       
  1309             }
       
  1310             resultRect = canvasRect.Rect();
       
  1311             break;
       
  1312         }
       
  1313         case EOnScreenKeypadValueLskRsk:
       
  1314         {
       
  1315             if (iIsFullScreenMode)
       
  1316             {
       
  1317                 if (!Layout_Meta_Data::IsLandscapeOrientation())  //portrait
       
  1318                 {
       
  1319                     canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(11).LayoutLine());
       
  1320                 }
       
  1321                 else //landscape
       
  1322                 {
       
  1323                     if (iSKPositionWithQwerty == ESoftkeysRight)
       
  1324                     {
       
  1325                         canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(10).LayoutLine());
       
  1326                     }
       
  1327                     else
       
  1328                     {
  1242 #ifdef RD_JAVA_S60_RELEASE_9_2
  1329 #ifdef RD_JAVA_S60_RELEASE_9_2
  1243                     canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(9).LayoutLine());
  1330                         canvasRect.LayoutRect(resultRect, AknLayoutScalable_Avkon::midp_canvas_pane(9).LayoutLine());
  1244 #else
  1331 #else
  1245                     resultRect = TRect(80,0,560,360); // Layout data not defined in older releases.
  1332                         resultRect = TRect(80,0,560,360); // Layout data not defined in older releases.
  1246                     DEBUG("- CMIDDisplayable::GetCanvasRectFromLaf");
  1333                         DEBUG("- CMIDDisplayable::GetCanvasRectFromLaf");
  1247                     return resultRect;
  1334                         return resultRect;
  1248 #endif // RD_JAVA_S60_RELEASE_9_2
  1335 #endif // RD_JAVA_S60_RELEASE_9_2
       
  1336                     }
  1249                 }
  1337                 }
  1250             }
  1338             }
  1251         }
  1339             else//normal mode
  1252         else//normal mode
  1340             {
  1253         {
  1341                 //no need to present LSK&RSK in OSK when in normal mode Canvas
  1254             //no need to present LSK&RSK in OSK when in normal mode Canvas
  1342                 resultRect = TRect(0,0,0,0);
  1255             resultRect = TRect(0,0,0,0);
  1343 
  1256 
  1344                 DEBUG("- CMIDDisplayable::GetCanvasRectFromLaf");
  1257             DEBUG("- CMIDDisplayable::GetCanvasRectFromLaf");
  1345                 return resultRect;
  1258             return resultRect;
  1346             }
  1259         }
  1347             resultRect = canvasRect.Rect();
  1260         resultRect = canvasRect.Rect();
  1348             break;
  1261         break;
  1349         }
  1262     }
  1350         }
  1263     default:
  1351 #ifdef RD_JAVA_S60_RELEASE_9_2
  1264     {
  1352     }
  1265         resultRect = TRect(0,0,0,0);
  1353 #endif // RD_JAVA_S60_RELEASE_9_2
  1266         break;
       
  1267     }
       
  1268     }
       
  1269 
  1354 
  1270     DEBUG("- CMIDDisplayable::GetCanvasRectFromLaf");
  1355     DEBUG("- CMIDDisplayable::GetCanvasRectFromLaf");
  1271     return resultRect;
  1356     return resultRect;
  1272 }
  1357 }
  1273 
  1358 
  1369     ASSERT(iContent);
  1454     ASSERT(iContent);
  1370 
  1455 
  1371     iActive = aCurrent;
  1456     iActive = aCurrent;
  1372     const TType type = iContent->Type();
  1457     const TType type = iContent->Type();
  1373 
  1458 
  1374     HandleCanvasForeground(aCurrent);
       
  1375 
       
  1376     if (aCurrent)
  1459     if (aCurrent)
  1377     {
  1460     {
       
  1461         HandleCanvasForeground(aCurrent);
       
  1462 
  1378         // when setting displayable as current remember to deactivate
  1463         // when setting displayable as current remember to deactivate
  1379         // the default displayable if it has not been done yet
  1464         // the default displayable if it has not been done yet
  1380         CMIDDisplayable* defaultDisplayable =
  1465         CMIDDisplayable* defaultDisplayable =
  1381             iUIManager->GetDefaultDisplayable();
  1466             iUIManager->GetDefaultDisplayable();
  1382         if (defaultDisplayable &&
  1467         if (defaultDisplayable &&
  1404     {
  1489     {
  1405         HandleDeactivated();
  1490         HandleDeactivated();
  1406     }
  1491     }
  1407 
  1492 
  1408     if (type == EAlert)
  1493     if (type == EAlert)
  1409     {// alerts do their on thing, they rely on sleeping dialogs in fact
  1494     {
       
  1495         // alerts do their on thing, they rely on sleeping dialogs in fact
  1410         CMIDAlert* alert = static_cast<CMIDAlert*>(iContentControl);
  1496         CMIDAlert* alert = static_cast<CMIDAlert*>(iContentControl);
  1411         TRAP_IGNORE(alert->HandleCurrentL(aCurrent));
  1497         TRAP_IGNORE(alert->HandleCurrentL(aCurrent));
  1412 
  1498 
  1413         UpdateTickerL();
  1499         UpdateTickerL();
  1414     }
  1500     }
  1415     else if (type == ETextBox && iIsPopupTextBox)
  1501     else if (type == ETextBox && iIsPopupTextBox)
  1416     {// Pop-up TextBox do their on thing, they rely on sleeping dialogs in fact
  1502     {
       
  1503         // Pop-up TextBox do their on thing, they rely on sleeping dialogs in fact
  1417         CMIDTextBoxDialogControl* textBoxDialogControl =
  1504         CMIDTextBoxDialogControl* textBoxDialogControl =
  1418             static_cast<CMIDTextBoxDialogControl*>(iContentControl);
  1505             static_cast<CMIDTextBoxDialogControl*>(iContentControl);
  1419         TRAP_IGNORE(textBoxDialogControl->HandleCurrentL(aCurrent));
  1506         TRAP_IGNORE(textBoxDialogControl->HandleCurrentL(aCurrent));
  1420     }
  1507     }
  1421     else
  1508     else
  1434                     !(iMenuHandler->GetDisplayable()->Component()->Type() == ETextBox &&
  1521                     !(iMenuHandler->GetDisplayable()->Component()->Type() == ETextBox &&
  1435                       iMenuHandler->GetDisplayable()->IsPopupTextBox()))
  1522                       iMenuHandler->GetDisplayable()->IsPopupTextBox()))
  1436             {
  1523             {
  1437                 MakeVisible(EFalse);
  1524                 MakeVisible(EFalse);
  1438             }
  1525             }
       
  1526 
       
  1527             // Notify canvas after changing the visibility
       
  1528             HandleCanvasForeground(aCurrent);
  1439         }
  1529         }
  1440 
  1530 
  1441         iContentControl->SetFocus(aCurrent);
  1531         iContentControl->SetFocus(aCurrent);
  1442 
  1532 
  1443         switch (type)
  1533         switch (type)
  1991         {
  2081         {
  1992             iDisplayableRect = canvasRect;
  2082             iDisplayableRect = canvasRect;
  1993         }
  2083         }
  1994 #endif //RD_SCALABLE_UI_V2
  2084 #endif //RD_SCALABLE_UI_V2
  1995         if (!iActive)
  2085         if (!iActive)
  1996         { // Restore pane visibility. There is one pane for all displayables.
  2086         {
       
  2087             // Restore pane visibility. There is one pane for all displayables.
  1997             // Only active displayable can decide about the pane visibility.
  2088             // Only active displayable can decide about the pane visibility.
  1998             // Others should not change it.
  2089             // Others should not change it.
  1999             pane->MakeVisible(paneVisible);
  2090             pane->MakeVisible(paneVisible);
  2000         }
  2091         }
  2001 
  2092 
  2010             iCba->SetBoundingRect(iDisplayableRect);
  2101             iCba->SetBoundingRect(iDisplayableRect);
  2011             // Control pane area has to be reduced
  2102             // Control pane area has to be reduced
  2012             iCba->ReduceRect(iDisplayableRect);
  2103             iCba->ReduceRect(iDisplayableRect);
  2013 
  2104 
  2014             if (!iActive)
  2105             if (!iActive)
  2015             { // Restore cba visibility. There is one cba for all displayables.
  2106             {
       
  2107                 // Restore cba visibility. There is one cba for all displayables.
  2016                 // Only active displayable can decide about the cba visibility.
  2108                 // Only active displayable can decide about the cba visibility.
  2017                 // Others should not change it.
  2109                 // Others should not change it.
  2018                 iCba->MakeVisible(cbaVisible);
  2110                 iCba->MakeVisible(cbaVisible);
  2019             }
  2111             }
  2020         }
  2112         }
  2048     // Displayable rect is updated and set
  2140     // Displayable rect is updated and set
  2049     UpdateDisplayableRect();
  2141     UpdateDisplayableRect();
  2050     SetRect(iDisplayableRect);
  2142     SetRect(iDisplayableRect);
  2051 
  2143 
  2052     if (iActive)
  2144     if (iActive)
  2053     { //this means we are the active displayable
  2145     {
       
  2146         //this means we are the active displayable
  2054         UpdateVisualAppearanceL();
  2147         UpdateVisualAppearanceL();
  2055     }
  2148     }
  2056 
  2149 
  2057     if (aFullScreen)
  2150     if (aFullScreen)
  2058     {
  2151     {
  2117 void CMIDDisplayable::SetMSKCommand(CMIDCommand* aMSKCommand)
  2210 void CMIDDisplayable::SetMSKCommand(CMIDCommand* aMSKCommand)
  2118 {
  2211 {
  2119     CMIDCommand* oldMSKCommand = iMSKCommand;
  2212     CMIDCommand* oldMSKCommand = iMSKCommand;
  2120     iMSKCommand = aMSKCommand;
  2213     iMSKCommand = aMSKCommand;
  2121     if (oldMSKCommand != iMSKCommand)
  2214     if (oldMSKCommand != iMSKCommand)
  2122     { // avoid unnecessary updating to avoid flickering
  2215     {
       
  2216         // avoid unnecessary updating to avoid flickering
  2123         TRAP_IGNORE(InitializeCbasL());
  2217         TRAP_IGNORE(InitializeCbasL());
  2124     }
  2218     }
  2125 }
  2219 }
  2126 
  2220 
  2127 void CMIDDisplayable::SetSelectCommand(CMIDCommand* aSelectCommand)
  2221 void CMIDDisplayable::SetSelectCommand(CMIDCommand* aSelectCommand)
  2128 {
  2222 {
  2129     if (aSelectCommand != iSelectCommand)
  2223     if (aSelectCommand != iSelectCommand)
  2130     { // avoid unnecessary updating to avoid flickering
  2224     {
       
  2225         // avoid unnecessary updating to avoid flickering
  2131         iSelectCommand = aSelectCommand;
  2226         iSelectCommand = aSelectCommand;
  2132         TRAP_IGNORE(InitializeCbasL());
  2227         TRAP_IGNORE(InitializeCbasL());
  2133     }
  2228     }
  2134 }
  2229 }
  2135 
  2230 
  2237 
  2332 
  2238 #ifdef RD_JAVA_S60_RELEASE_9_2
  2333 #ifdef RD_JAVA_S60_RELEASE_9_2
  2239     if (iSelectCommand)
  2334     if (iSelectCommand)
  2240 #else
  2335 #else
  2241     if (!iSelectCommandEnabled && iSelectCommand)
  2336     if (!iSelectCommandEnabled && iSelectCommand)
  2242 #endif // RD_JAVA_S60_RELEASE_9_2        
  2337 #endif // RD_JAVA_S60_RELEASE_9_2
  2243     {
  2338     {
  2244         // remove the select command
  2339         // remove the select command
  2245         for (TInt j = 0; j < lists.Count(); j++)
  2340         for (TInt j = 0; j < lists.Count(); j++)
  2246         {
  2341         {
  2247             if (lists[j])
  2342             if (lists[j])
  2344         if (iMSKCommand)
  2439         if (iMSKCommand)
  2345         {
  2440         {
  2346             // There is a explicitly set MSK command -> it takes the precedence and gets MSK
  2441             // There is a explicitly set MSK command -> it takes the precedence and gets MSK
  2347             TInt commandId = GetInternalCommandIdFor(iMSKCommand);
  2442             TInt commandId = GetInternalCommandIdFor(iMSKCommand);
  2348             if (commandId == KCommandIdNotFound)
  2443             if (commandId == KCommandIdNotFound)
  2349             {// it must be a built-in command, it is the only command not contained in the command lists
  2444             {
       
  2445                 // it must be a built-in command, it is the only command not contained in the command lists
  2350                 commandId = KBuiltInMSKCommandId;
  2446                 commandId = KBuiltInMSKCommandId;
  2351             }
  2447             }
  2352             iCba->SetCommandL(KMSKPositionInCBA, commandId, iMSKCommand->ShortLabel());
  2448             iCba->SetCommandL(KMSKPositionInCBA, commandId, iMSKCommand->ShortLabel());
  2353             iIdOfMSKCommand = commandId;
  2449             iIdOfMSKCommand = commandId;
  2354         }
  2450         }
  2355         else if (!iMSKCommand && (contextMenuSize == 1))
  2451         else if (!iMSKCommand && (contextMenuSize == 1))
  2356         {
  2452         {
  2357             // There is no explicitly set MSK command and just one for the context menu.
  2453             // There is no explicitly set MSK command and just one for the context menu.
  2358             // Instead of a menu, put the command to MSK directly.
  2454             // Instead of a menu, put the command to MSK directly.
  2359             RPointerArray<CMIDCommand> commands;
  2455             RPointerArray<CMIDCommand> commands;
  2360             GetOkOptionsMenuCommands(commands);
  2456             GetOkOptionsMenuCommandsL(commands);
  2361             ASSERT(commands.Count() == 1);
  2457             ASSERT(commands.Count() == 1);
  2362             CMIDCommand* command = commands[0];
  2458             CMIDCommand* command = commands[0];
  2363             commands.Close();
  2459             commands.Close();
  2364             iCba->SetCommandL(KMSKPositionInCBA,
  2460             iCba->SetCommandL(KMSKPositionInCBA,
  2365                               GetInternalCommandIdFor(command),
  2461                               GetInternalCommandIdFor(command),
  2473     {
  2569     {
  2474         TCommandEntry cmd;
  2570         TCommandEntry cmd;
  2475         cmd.iCommand = NULL;
  2571         cmd.iCommand = NULL;
  2476 
  2572 
  2477         if (iItemCommandList && iItemCommandList->Count() > 0)
  2573         if (iItemCommandList && iItemCommandList->Count() > 0)
  2478         {// there can only be one so pick the first one
  2574         {
       
  2575             // there can only be one so pick the first one
  2479             cmd = iItemCommandList->At(0);
  2576             cmd = iItemCommandList->At(0);
  2480 
  2577 
  2481             if (cmd.iCommand->IsMappedToSoftKey())
  2578             if (cmd.iCommand->IsMappedToSoftKey())
  2482             {
  2579             {
  2483                 HandleItemCommandL(cmd);
  2580                 HandleItemCommandL(cmd);
  2486         }
  2583         }
  2487         else if (iCommandList && iCommandList->Count() > 0)
  2584         else if (iCommandList && iCommandList->Count() > 0)
  2488         {
  2585         {
  2489             TInt index = iCommandList->HighestPriorityCommand(MMIDCommand::EOk);
  2586             TInt index = iCommandList->HighestPriorityCommand(MMIDCommand::EOk);
  2490             if (index == KErrNotFound)
  2587             if (index == KErrNotFound)
  2491             {// there can only be one so if the other one was KErrNotFound, this must be it
  2588             {
       
  2589                 // there can only be one so if the other one was KErrNotFound, this must be it
  2492                 index = iCommandList->HighestPriorityCommand(MMIDCommand::EItem);
  2590                 index = iCommandList->HighestPriorityCommand(MMIDCommand::EItem);
  2493             }
  2591             }
  2494             cmd = iCommandList->At(index);
  2592             cmd = iCommandList->At(index);
  2495 
  2593 
  2496             if (cmd.iCommand->IsMappedToSoftKey())
  2594             if (cmd.iCommand->IsMappedToSoftKey())
  2508     }
  2606     }
  2509 
  2607 
  2510     return EFalse;
  2608     return EFalse;
  2511 }
  2609 }
  2512 
  2610 
       
  2611 // ---------------------------------------------------------------------------
       
  2612 // See how many commands eligible for the screen or help - optins menu we have.
       
  2613 // If we have only one command call ProcessCommandL. Otherwise show
       
  2614 // options menu. In these two cases return ETrue. If zero or negative
       
  2615 // commands do nothing and return EFalse.
       
  2616 // ---------------------------------------------------------------------------
       
  2617 TBool CMIDDisplayable::ShowScreenOrHelpOptionsMenuL()
       
  2618 {
       
  2619     TBool ret = EFalse;
       
  2620     TInt numOkCommands = NumCommandsForOkOptionsMenu();
       
  2621     TInt numScreenOrHelpCommands = NumCommandsForScreenOrHelpOptionsMenu();
       
  2622     TInt screenOrHelpCmdIndex = GetHighestPriorityScreenOrHelpCommand();
       
  2623 
       
  2624     // There is no OK or ITEM command defined on form
       
  2625     // There are SCREEN or HELP commands
       
  2626     if (iCommandList && screenOrHelpCmdIndex != KErrNotFound && numOkCommands == 0)
       
  2627     {
       
  2628         CMIDCommand *command = NULL;
       
  2629         if (iCommandList->IsValidIndex(screenOrHelpCmdIndex))
       
  2630         {
       
  2631             command = iCommandList->At(screenOrHelpCmdIndex).iCommand;
       
  2632         }
       
  2633 
       
  2634         if (command && (command->CommandType() == MMIDCommand::EScreen ||
       
  2635                         command->CommandType() == MMIDCommand::EHelp) && iMenuHandler)
       
  2636         {
       
  2637             if (numScreenOrHelpCommands > 1)
       
  2638             {
       
  2639                 iMenuHandler->ShowMenuL(CMIDMenuHandler::EOptionsMenu);
       
  2640                 ret = ETrue;
       
  2641             }
       
  2642             else if (numScreenOrHelpCommands == 1)
       
  2643             {
       
  2644                 ProcessCommandL(iCommandList->CommandOffset());
       
  2645                 ret = ETrue;
       
  2646             }
       
  2647         }
       
  2648     }
       
  2649 
       
  2650     return ret;
       
  2651 }
  2513 
  2652 
  2514 // ---------------------------------------------------------------------------
  2653 // ---------------------------------------------------------------------------
  2515 // Return the number of commands that can be displayed in the ok-options menu.
  2654 // Return the number of commands that can be displayed in the ok-options menu.
  2516 // If form has set any item commands in iItemCommandList this means that there is
  2655 // If form has set any item commands in iItemCommandList this means that there is
  2517 // a form item focused and the commands for this item should be displayed in
  2656 // a form item focused and the commands for this item should be displayed in
  2566             }
  2705             }
  2567             ret++;
  2706             ret++;
  2568         }
  2707         }
  2569     }
  2708     }
  2570 
  2709 
       
  2710     return ret;
       
  2711 }
       
  2712 
       
  2713 // ---------------------------------------------------------------------------
       
  2714 // Return the number of commands that can be displayed in the screen or help - options menu.
       
  2715 // Form item screen or help commands are ignored
       
  2716 //
       
  2717 // TextBox/TextField device-provided commands:
       
  2718 // - "Fetch number"
       
  2719 // - "Call"
       
  2720 // - "Fetch e-mail address"
       
  2721 // are exception. Those are visible ONLY in Options menu so here they are
       
  2722 // removed from context menu commands count.
       
  2723 // ---------------------------------------------------------------------------
       
  2724 TInt CMIDDisplayable::NumCommandsForScreenOrHelpOptionsMenu() const
       
  2725 {
       
  2726     TInt ret = 0;
       
  2727 
       
  2728     // Add SCREEN and HELP commands from form
       
  2729     if (iCommandList)
       
  2730     {
       
  2731         TInt numCommands = iCommandList->Count();
       
  2732         for (TInt i = 0; i < numCommands; i++)
       
  2733         {
       
  2734             const CMIDCommand& command = *(iCommandList->At(i).iCommand);
       
  2735 
       
  2736             if (((command.CommandType() == MMIDCommand::EScreen) ||
       
  2737                     (command.CommandType() == MMIDCommand::EHelp)) &&
       
  2738                     (command.Id() != CMIDEdwinUtils::EMenuCommandFetchPhoneNumber) &&
       
  2739                     (command.Id() != CMIDEdwinUtils::EMenuCommandFetchEmailAddress) &&
       
  2740                     (command.Id() != CMIDEdwinUtils::EMenuCommandCreatePhoneCall))
       
  2741             {
       
  2742                 TBool selectCommand = (&command == iSelectCommand);
       
  2743                 if (selectCommand && !iSelectCommandEnabled)
       
  2744                 {
       
  2745                     continue;
       
  2746                 }
       
  2747                 ret++;
       
  2748             }
       
  2749         }
       
  2750     }
  2571     return ret;
  2751     return ret;
  2572 }
  2752 }
  2573 
  2753 
  2574 // ---------------------------------------------------------------------------
  2754 // ---------------------------------------------------------------------------
  2575 // Returns a pointer to the command in the iCommandList with the specified
  2755 // Returns a pointer to the command in the iCommandList with the specified
  2601 // they are not added to context menu commands array.
  2781 // they are not added to context menu commands array.
  2602 //
  2782 //
  2603 // If there are item commands, there are placed first. Form commands of ITEM
  2783 // If there are item commands, there are placed first. Form commands of ITEM
  2604 // and OK type are then included always.
  2784 // and OK type are then included always.
  2605 // ---------------------------------------------------------------------------
  2785 // ---------------------------------------------------------------------------
  2606 void CMIDDisplayable::GetOkOptionsMenuCommands(RPointerArray<CMIDCommand>& aCommands) const
  2786 void CMIDDisplayable::GetOkOptionsMenuCommandsL(RPointerArray<CMIDCommand>& aCommands) const
  2607 {
  2787 {
  2608     aCommands.Reset();
  2788     aCommands.Reset();
  2609     if (iItemCommandList && iItemCommandList->Count() > 0)
  2789     if (iItemCommandList && iItemCommandList->Count() > 0)
  2610     {
  2790     {
  2611         for (TInt i = 0; i < iItemCommandList->Count(); i++)
  2791         for (TInt i = 0; i < iItemCommandList->Count(); i++)
  2613             const CMIDCommand* command = iItemCommandList->At(i).iCommand;
  2793             const CMIDCommand* command = iItemCommandList->At(i).iCommand;
  2614             if ((command->Id() != CMIDEdwinUtils::EMenuCommandFetchPhoneNumber) &&
  2794             if ((command->Id() != CMIDEdwinUtils::EMenuCommandFetchPhoneNumber) &&
  2615                     (command->Id() != CMIDEdwinUtils::EMenuCommandFetchEmailAddress) &&
  2795                     (command->Id() != CMIDEdwinUtils::EMenuCommandFetchEmailAddress) &&
  2616                     (command->Id() != CMIDEdwinUtils::EMenuCommandCreatePhoneCall))
  2796                     (command->Id() != CMIDEdwinUtils::EMenuCommandCreatePhoneCall))
  2617             {
  2797             {
  2618                 aCommands.Append(command);
  2798                 aCommands.AppendL(command);
  2619             }
  2799             }
  2620         }
  2800         }
  2621     }
  2801     }
  2622 
  2802 
  2623     // add Form commands always
  2803     // add Form commands always
  2633         {
  2813         {
  2634             if (!iSelectCommandEnabled && command == iSelectCommand)
  2814             if (!iSelectCommandEnabled && command == iSelectCommand)
  2635             {
  2815             {
  2636                 continue;
  2816                 continue;
  2637             }
  2817             }
  2638             aCommands.Append(command);
  2818             aCommands.AppendL(command);
  2639         }
  2819         }
  2640     }
  2820     }
  2641 }
  2821 }
  2642 
  2822 
  2643 /**
  2823 /**
  2723     // If there is a context menu available, forward events to long tap detector
  2903     // If there is a context menu available, forward events to long tap detector
  2724 #ifdef RD_JAVA_S60_RELEASE_9_2
  2904 #ifdef RD_JAVA_S60_RELEASE_9_2
  2725     if (NumCommandsForOkOptionsMenu() > 0)
  2905     if (NumCommandsForOkOptionsMenu() > 0)
  2726 #else
  2906 #else
  2727     if (NumCommandsForOkOptionsMenu() > 1)
  2907     if (NumCommandsForOkOptionsMenu() > 1)
  2728 #endif // RD_JAVA_S60_RELEASE_9_2        
  2908 #endif // RD_JAVA_S60_RELEASE_9_2
  2729     {
  2909     {
  2730         iLongTapDetector->PointerEventL(aPointerEvent);
  2910         iLongTapDetector->PointerEventL(aPointerEvent);
  2731     }
  2911     }
  2732     if (aPointerEvent.iType == TPointerEvent::EButton1Up && iLongTapDetected)
  2912     if (aPointerEvent.iType == TPointerEvent::EButton1Up && iLongTapDetected)
  2733     {
  2913     {
  2756     {
  2936     {
  2757 #ifdef RD_JAVA_S60_RELEASE_9_2
  2937 #ifdef RD_JAVA_S60_RELEASE_9_2
  2758         PopulateMenuItemsWithListL(CMIDMenuHandler::EPopUpMenu, menuItems, iItemCommandList, EFalse);
  2938         PopulateMenuItemsWithListL(CMIDMenuHandler::EPopUpMenu, menuItems, iItemCommandList, EFalse);
  2759 #else
  2939 #else
  2760         PopulateMenuItemsWithListL(CMIDMenuHandler::EOkMenu, menuItems, iItemCommandList, EFalse);
  2940         PopulateMenuItemsWithListL(CMIDMenuHandler::EOkMenu, menuItems, iItemCommandList, EFalse);
  2761 #endif // RD_JAVA_S60_RELEASE_9_2        
  2941 #endif // RD_JAVA_S60_RELEASE_9_2
  2762     }
  2942     }
  2763 
  2943 
  2764     // Add form commands always
  2944     // Add form commands always
  2765 #ifdef RD_JAVA_S60_RELEASE_9_2
  2945 #ifdef RD_JAVA_S60_RELEASE_9_2
  2766     PopulateMenuItemsWithListL(CMIDMenuHandler::EPopUpMenu, menuItems, iCommandList, EFalse);
  2946     PopulateMenuItemsWithListL(CMIDMenuHandler::EPopUpMenu, menuItems, iCommandList, EFalse);
  2767 #else
  2947 #else
  2768     PopulateMenuItemsWithListL(CMIDMenuHandler::EOkMenu, menuItems, iCommandList, EFalse);
  2948     PopulateMenuItemsWithListL(CMIDMenuHandler::EOkMenu, menuItems, iCommandList, EFalse);
  2769 #endif // RD_JAVA_S60_RELEASE_9_2    
  2949 #endif // RD_JAVA_S60_RELEASE_9_2
  2770 #ifdef RD_JAVA_S60_RELEASE_9_2
  2950 #ifdef RD_JAVA_S60_RELEASE_9_2
  2771     if (menuItems.Count() > 0)
  2951     if (menuItems.Count() > 0)
  2772 #else
  2952 #else
  2773     if (menuItems.Count() > 1)
  2953     if (menuItems.Count() > 1)
  2774 #endif // RD_JAVA_S60_RELEASE_9_2        
  2954 #endif // RD_JAVA_S60_RELEASE_9_2
  2775     {
  2955     {
  2776         // recreate stylus popup menu because it does not have method
  2956         // recreate stylus popup menu because it does not have method
  2777         // for clearing the menu items
  2957         // for clearing the menu items
  2778         delete iStylusPopupMenu;
  2958         delete iStylusPopupMenu;
  2779         iStylusPopupMenu = NULL;
  2959         iStylusPopupMenu = NULL;
  2973     TDirectContentsRect rect(aRect);
  3153     TDirectContentsRect rect(aRect);
  2974     TInt index = iDirectContentsRects.Find(
  3154     TInt index = iDirectContentsRects.Find(
  2975                      rect, TIdentityRelation< TDirectContentsRect >(CMIDDisplayable::MatchDirectContentsRects));
  3155                      rect, TIdentityRelation< TDirectContentsRect >(CMIDDisplayable::MatchDirectContentsRects));
  2976     if (index == KErrNotFound)
  3156     if (index == KErrNotFound)
  2977     {
  3157     {
  2978         iDirectContentsRects.Append(rect);
  3158         TInt err = iDirectContentsRects.Append(rect);
  2979         UpdateDirectContentsRegion();
  3159         if (KErrNone == err)
       
  3160         {
       
  3161             UpdateDirectContentsRegion();
       
  3162         }
       
  3163         else
       
  3164         {
       
  3165             DEBUG_INT("CMIDDisplayable::AddDirectContentArea - RArray append error %d", err);
       
  3166         }
  2980     }
  3167     }
  2981     else
  3168     else
  2982     {
  3169     {
  2983         iDirectContentsRects[ index ].iRefCount++;
  3170         iDirectContentsRects[ index ].iRefCount++;
  2984     }
  3171     }
  3159     DEBUG("- CMIDDisplayable::RenewFullscreenCanvasLabelCacheL");
  3346     DEBUG("- CMIDDisplayable::RenewFullscreenCanvasLabelCacheL");
  3160 }
  3347 }
  3161 
  3348 
  3162 void CMIDDisplayable::HandleCanvasForeground(TBool aForeground)
  3349 void CMIDDisplayable::HandleCanvasForeground(TBool aForeground)
  3163 {
  3350 {
  3164     if (iContent && iContentControl &&
  3351     CMIDCanvas* canvas = GetContentCanvas();
  3165             (iContent->Type() == MMIDComponent::ECanvas ||
  3352     if (canvas)
  3166              iContent->Type() == MMIDComponent::EGameCanvas))
  3353     {
  3167     {
       
  3168         CMIDCanvas* canvas = static_cast<CMIDCanvas*>(iContentControl);
       
  3169         canvas->HandleForeground(aForeground);
  3354         canvas->HandleForeground(aForeground);
  3170     }
  3355     }
  3171 }
  3356 }
  3172 
  3357 
  3173 void CMIDDisplayable::HandleApplicationBackground()
  3358 void CMIDDisplayable::HandleApplicationBackground()
  3223     HideIndicator(pane, EEikStatusPaneUidMessage);
  3408     HideIndicator(pane, EEikStatusPaneUidMessage);
  3224     HideIndicator(pane, EEikStatusPaneUidClock);
  3409     HideIndicator(pane, EEikStatusPaneUidClock);
  3225     HideIndicator(pane, EEikStatusPaneUidDigitalClock);
  3410     HideIndicator(pane, EEikStatusPaneUidDigitalClock);
  3226 }
  3411 }
  3227 
  3412 
       
  3413 CMIDCanvas* CMIDDisplayable::GetContentCanvas()
       
  3414 {
       
  3415     CMIDCanvas* ret = NULL;
       
  3416     if (iContent && iContentControl &&
       
  3417             (iContent->Type() == MMIDComponent::ECanvas ||
       
  3418              iContent->Type() == MMIDComponent::EGameCanvas))
       
  3419     {
       
  3420         ret = static_cast<CMIDCanvas*>(iContentControl);
       
  3421     }
       
  3422     return ret;
       
  3423 }
       
  3424 
  3228 CPropertyWatch* CPropertyWatch::NewL(MMIDDisplayable* aDisplayable)
  3425 CPropertyWatch* CPropertyWatch::NewL(MMIDDisplayable* aDisplayable)
  3229 {
  3426 {
  3230     DEBUG("+ CPropertyWatch::NewL");
  3427     DEBUG("+ CPropertyWatch::NewL");
  3231 
  3428 
  3232     CPropertyWatch* self = new(ELeave) CPropertyWatch;
  3429     CPropertyWatch* self = new(ELeave) CPropertyWatch;
  3235     CleanupStack::Pop(self);
  3432     CleanupStack::Pop(self);
  3236 
  3433 
  3237     DEBUG("- CPropertyWatch::NewL");
  3434     DEBUG("- CPropertyWatch::NewL");
  3238 
  3435 
  3239     return self;
  3436     return self;
       
  3437 }
       
  3438 
       
  3439 void CMIDDisplayable::FixOrientation()
       
  3440 {
       
  3441     TBool tmpRestoreOrientation;
       
  3442 
       
  3443     if (!iAvkonAppUi)
       
  3444     {
       
  3445         return;
       
  3446     }
       
  3447 
       
  3448     iOldUiOrientation = iAvkonAppUi->Orientation();
       
  3449     tmpRestoreOrientation = (iOldUiOrientation == CAknAppUiBase::EAppUiOrientationUnspecified) ? ETrue : EFalse;
       
  3450 
       
  3451     // Fix the orientation when was set to unspecified only
       
  3452     if (tmpRestoreOrientation)
       
  3453     {
       
  3454         TRAP_IGNORE(iAvkonAppUi->SetOrientationL(CAknAppUiBase::EAppUiOrientationLandscape));
       
  3455 
       
  3456         iRestoreOrientation = ETrue;
       
  3457         ++iReleaseCnt;
       
  3458     }
       
  3459 
       
  3460 }
       
  3461 
       
  3462 void CMIDDisplayable::ReleaseOrientation()
       
  3463 {
       
  3464     if (!iAvkonAppUi)
       
  3465     {
       
  3466         return;
       
  3467     }
       
  3468 
       
  3469     if (iReleaseCnt > 0)
       
  3470     {
       
  3471         --iReleaseCnt;
       
  3472         if (iReleaseCnt == 0 && iRestoreOrientation)
       
  3473         {
       
  3474             TRAP_IGNORE(iAvkonAppUi->SetOrientationL(iOldUiOrientation));
       
  3475             iRestoreOrientation = EFalse;
       
  3476         }
       
  3477 
       
  3478     }
  3240 }
  3479 }
  3241 
  3480 
  3242 CPropertyWatch::CPropertyWatch()
  3481 CPropertyWatch::CPropertyWatch()
  3243         : CActive(0)
  3482         : CActive(0)
  3244 {
  3483 {