idlehomescreen/widgetmanager/src/wmmaincontainer.cpp
branchRCL_3
changeset 9 f966699dea19
parent 5 c743ef5928ba
child 15 ff572dfe6d86
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
   293     // Do not let UI framework forward the keys to child controls as
   293     // Do not let UI framework forward the keys to child controls as
   294     // we have already done that.
   294     // we have already done that.
   295     return EKeyWasConsumed;
   295     return EKeyWasConsumed;
   296     }
   296     }
   297 
   297 
       
   298 // ---------------------------------------------------------
       
   299 // CWmMainContainer::HandleSearchKeyEventL
       
   300 // ---------------------------------------------------------
       
   301 //
   298 TKeyResponse CWmMainContainer::HandleSearchKeyEventL( 
   302 TKeyResponse CWmMainContainer::HandleSearchKeyEventL( 
   299         const TKeyEvent& aKeyEvent, 
   303         const TKeyEvent& aKeyEvent, 
   300         TEventCode aType )
   304         TEventCode aType )
   301     {
   305     {
   302     TKeyResponse keyResponse( EKeyWasNotConsumed );
   306     TKeyResponse keyResponse( EKeyWasNotConsumed );
   344         }
   348         }
   345 
   349 
   346     return keyResponse;
   350     return keyResponse;
   347     }
   351     }
   348 
   352 
       
   353 // ---------------------------------------------------------
       
   354 // CWmMainContainer::HandleListKeyEventL
       
   355 // ---------------------------------------------------------
       
   356 //
   349 TKeyResponse CWmMainContainer::HandleListKeyEventL( 
   357 TKeyResponse CWmMainContainer::HandleListKeyEventL( 
   350         const TKeyEvent& aKeyEvent, 
   358         const TKeyEvent& aKeyEvent, 
   351         TEventCode aType )
   359         TEventCode aType )
   352     {
   360     {
   353     TKeyResponse keyResponse( EKeyWasNotConsumed );
   361     TKeyResponse keyResponse( EKeyWasNotConsumed );
   380         }
   388         }
   381     
   389     
   382     return keyResponse;
   390     return keyResponse;
   383     }
   391     }
   384 
   392 
       
   393 // ---------------------------------------------------------
       
   394 // CWmMainContainer::HandleButtonKeyEventL
       
   395 // ---------------------------------------------------------
       
   396 //
   385 TKeyResponse CWmMainContainer::HandleButtonKeyEventL( 
   397 TKeyResponse CWmMainContainer::HandleButtonKeyEventL( 
   386         const TKeyEvent& aKeyEvent, 
   398         const TKeyEvent& aKeyEvent, 
   387         TEventCode aType )
   399         TEventCode aType )
   388     {
   400     {
   389     TKeyResponse keyResponse( EKeyWasNotConsumed );
   401     TKeyResponse keyResponse( EKeyWasNotConsumed );
   589         {
   601         {
   590         // ------------------------------------
   602         // ------------------------------------
   591         // focus is NOWHERE
   603         // focus is NOWHERE
   592         // ------------------------------------
   604         // ------------------------------------
   593         if ( aKeyEvent.iScanCode == EStdKeyUpArrow ||
   605         if ( aKeyEvent.iScanCode == EStdKeyUpArrow ||
   594                 aKeyEvent.iScanCode == EStdKeyDownArrow ||
   606             aKeyEvent.iScanCode == EStdKeyDownArrow )
   595                 aKeyEvent.iScanCode == EStdKeyLeftArrow ||
       
   596                 aKeyEvent.iScanCode == EStdKeyRightArrow )
       
   597             {
   607             {
   598             // no focus -> key hit -> focus list
   608             // no focus -> key hit -> focus list
   599             if ( aType == EEventKey )
   609             if ( aType == EEventKey )
       
   610                 {
   600                 SetFocusToWidgetList();
   611                 SetFocusToWidgetList();
   601             keyResponse = EKeyWasConsumed;
   612                 keyResponse = EKeyWasNotConsumed;
       
   613                 }
   602             }
   614             }
   603         }
   615         }
   604 
   616 
   605     return keyResponse;
   617     return keyResponse;
   606     }
   618     }
   714 			{
   726 			{
   715 	        // Check if user clicked a child control
   727 	        // Check if user clicked a child control
   716 	        CCoeControl* control = FindChildControlByPoint( aPointerEvent.iPosition );
   728 	        CCoeControl* control = FindChildControlByPoint( aPointerEvent.iPosition );
   717 	        if ( control && !control->IsFocused() )
   729 	        if ( control && !control->IsFocused() )
   718 	            {
   730 	            {
   719 	            // set focus to selected list box item.           
       
   720                 if ( control == iWidgetsList )
       
   721                     {
       
   722                     TInt itemIndex = iWidgetsList->CurrentListBoxItemIndex();
       
   723                     TBool itemPointed = iWidgetsList->View()->XYPosToItemIndex(
       
   724                             aPointerEvent.iPosition,
       
   725                             itemIndex );
       
   726                     if ( itemIndex >= 0 && itemPointed )
       
   727                         {
       
   728                         iWidgetsList->SetCurrentItemIndex( itemIndex );
       
   729                         }
       
   730                     }
       
   731 	            
       
   732 	            // remove focus from ALL other child controls.
   731 	            // remove focus from ALL other child controls.
   733 	            CCoeControlArray::TCursor cursor = Components().Begin();
   732 	            CCoeControlArray::TCursor cursor = Components().Begin();
   734 	            CCoeControl* c;
   733 	            CCoeControl* c;
   735 	            while ((c=cursor.Control<CCoeControl>()) != NULL )
   734 	            while ((c=cursor.Control<CCoeControl>()) != NULL )
   736 	                {
   735 	                {
   877 void CWmMainContainer::AddControlL( 
   876 void CWmMainContainer::AddControlL( 
   878                                 CCoeControl* aControl, 
   877                                 CCoeControl* aControl, 
   879                                 TInt aControlId )
   878                                 TInt aControlId )
   880     {
   879     {
   881     Components().AppendLC( aControl, aControlId ); // Ownership transfered 
   880     Components().AppendLC( aControl, aControlId ); // Ownership transfered 
   882     CleanupStack::Pop(aControl);    
   881     CleanupStack::Pop(aControl);
   883     iWmPlugin.ViewAppUi().AddToStackL( aControl );
   882     CAknView* view = iWmPlugin.ViewAppUi().View( 
       
   883             TUid::Uid(EWmMainContainerViewId) );
       
   884     if ( view )
       
   885 		{
       
   886         iWmPlugin.ViewAppUi().AddToStackL( *view, aControl );
       
   887 		}
       
   888 	else
       
   889 		{
       
   890         iWmPlugin.ViewAppUi().AddToStackL( aControl );
       
   891 		}
   884     aControl->MakeVisible( ETrue );
   892     aControl->MakeVisible( ETrue );
   885     }
   893     }
   886 
   894 
   887 // ---------------------------------------------------------
   895 // ---------------------------------------------------------
   888 // CWmMainContainer::PortalSelected
   896 // CWmMainContainer::PortalSelected
  1031                 hsContentFull = EFalse;
  1039                 hsContentFull = EFalse;
  1032                 break;
  1040                 break;
  1033                 }
  1041                 }
  1034             }
  1042             }
  1035         
  1043         
  1036         // do not deactivate wm if wrt widget already exists on hs,
  1044         // deactivate wm if there's not enough space to add widget to hs.
  1037         // instead of that show popup info note.
  1045         if ( !data->HsContentInfo().CanBeAdded() && !hsContentFull )
  1038         if ( CWmWidgetData::ECps == data->WidgetType() &&
       
  1039             !data->HsContentInfo().CanBeAdded() &&
       
  1040             !hsContentFull )
       
  1041             {
  1046             {
  1042             iWmPlugin.ExecuteCommandL();
  1047             iWmPlugin.ExecuteCommandL();
  1043             }
  1048             }
  1044         else
  1049         else
  1045             {
  1050             {
  1046             iWmPlugin.Deactivate();
  1051             iWmPlugin.CloseView();
  1047             }
  1052             }
  1048         }
  1053         }
  1049     }
  1054     }
  1050 
  1055 
  1051 // ---------------------------------------------------------------------------
  1056 // ---------------------------------------------------------------------------
  1145         iFindbox->SetFocus( EFalse );
  1150         iFindbox->SetFocus( EFalse );
  1146         iFindPaneIsVisible = EFalse;
  1151         iFindPaneIsVisible = EFalse;
  1147         iWidgetsList->SetFindPaneIsVisible( EFalse );
  1152         iWidgetsList->SetFindPaneIsVisible( EFalse );
  1148         
  1153         
  1149         LayoutControls();
  1154         LayoutControls();
  1150         iWidgetsList->SetFocus( ETrue );
       
  1151 
  1155 
  1152         // set soft key set
  1156         // set soft key set
  1153         CEikButtonGroupContainer* cbaGroup =
  1157         CEikButtonGroupContainer* cbaGroup =
  1154             CEikButtonGroupContainer::Current();
  1158             CEikButtonGroupContainer::Current();
  1155         cbaGroup->SetCommandSetL( R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT );
  1159         TInt cbaResourceId = ( AknLayoutUtils::MSKEnabled() ?
       
  1160                                     R_AVKON_SOFTKEYS_OPTIONS_BACK__SELECT : 
       
  1161                                     R_AVKON_SOFTKEYS_OPTIONS_BACK );
       
  1162 
       
  1163         cbaGroup->SetCommandSetL( cbaResourceId );
  1156         cbaGroup->DrawNow();
  1164         cbaGroup->DrawNow();
  1157 
  1165 
  1158         UpdateFocusMode();
  1166         UpdateFocusMode();
  1159         DrawNow();
  1167         DrawNow();
  1160         }
  1168         }
  1265 // ---------------------------------------------------------------------------
  1273 // ---------------------------------------------------------------------------
  1266 // CWmMainContainer::RemoveCtrlsFromStack
  1274 // CWmMainContainer::RemoveCtrlsFromStack
  1267 // ---------------------------------------------------------------------------
  1275 // ---------------------------------------------------------------------------
  1268 //
  1276 //
  1269 void CWmMainContainer::RemoveCtrlsFromStack()
  1277 void CWmMainContainer::RemoveCtrlsFromStack()
  1270     {    
  1278     {
  1271     for ( TInt i=0; i < CountComponentControls(); i++ ) 
  1279     for ( TInt i=0; i < CountComponentControls(); i++ ) 
  1272         {
  1280         {
  1273         CCoeControl* ctl = ComponentControl( i ) ;
  1281         CCoeControl* ctl = ComponentControl( i ) ;
  1274         if ( ctl )
  1282         if ( ctl )
  1275             {
  1283             {
  1373     AknLayoutUtils::LayoutControl( iWidgetsList, rect, listPane );
  1381     AknLayoutUtils::LayoutControl( iWidgetsList, rect, listPane );
  1374     
  1382     
  1375     iWidgetsList->DrawNow();
  1383     iWidgetsList->DrawNow();
  1376     }
  1384     }
  1377 
  1385 
       
  1386 // ----------------------------------------------------
       
  1387 // CWmMainContainer::ProcessForegroundEvent
       
  1388 // ----------------------------------------------------
       
  1389 //
       
  1390 void CWmMainContainer::ProcessForegroundEvent( TBool aForeground )
       
  1391     {
       
  1392     if ( aForeground )
       
  1393         {
       
  1394         // set init state when wm comes to foreground.
       
  1395 		// remove focus from all controls when activating view.
       
  1396         CCoeControl* control = NULL;
       
  1397         CCoeControlArray::TCursor cursor = Components().Begin();
       
  1398         while( ( control = cursor.Control<CCoeControl>() ) != NULL )
       
  1399             {
       
  1400             if( control->IsVisible() && control->IsFocused() )
       
  1401                 {
       
  1402                 control->SetFocus( EFalse, EDrawNow );
       
  1403                 }
       
  1404             cursor.Next();
       
  1405             }
       
  1406         UpdateFocusMode();
       
  1407         }
       
  1408     }
  1378 
  1409 
  1379 // End of File
  1410 // End of File
  1380 
  1411