idlehomescreen/widgetmanager/src/wmmaincontainer.cpp
changeset 4 4d54b72983ae
parent 2 08c6ee43b396
child 5 c743ef5928ba
equal deleted inserted replaced
3:fb3763350a08 4:4d54b72983ae
   194 // CWmMainContainer::LayoutControls
   194 // CWmMainContainer::LayoutControls
   195 // ---------------------------------------------------------
   195 // ---------------------------------------------------------
   196 //
   196 //
   197 void CWmMainContainer::LayoutControls()
   197 void CWmMainContainer::LayoutControls()
   198 	{
   198 	{
   199     TBool landscape = Layout_Meta_Data::IsLandscapeOrientation();
   199     TRect rect( Rect() );
   200 
   200 
   201     TAknWindowLineLayout listPane = 
   201     // determine layout type
   202                 AknLayoutScalable_Apps::listscroll_wgtman_pane(landscape ? 1 : 0).LayoutLine();
   202     iLandscape = Layout_Meta_Data::IsLandscapeOrientation();
   203 
   203     iMirrored = Layout_Meta_Data::IsMirrored();
   204     TAknWindowLineLayout btnPane = 
   204     
   205                 AknLayoutScalable_Apps::wgtman_btn_pane(landscape ? 1 : 0).LayoutLine();
   205     // layout iPortalButtons
   206 
   206 	if ( iConfiguration->PortalButtonCount() == 1 )
   207 	TRect rect = Rect();	
       
   208     
       
   209 	if ( landscape )
       
   210 	    {
   207 	    {
   211         if ( Layout_Meta_Data::IsMirrored() )
   208 	    // one button
   212             {
   209 	    TAknWindowLineLayout btnPane = AknLayoutScalable_Apps
   213             iLayout = ELandscapeMirrored;
   210 	       ::wgtman_btn_pane( iLandscape ? 1 : 0 ).LayoutLine();
   214             }
   211 	    AknLayoutUtils::LayoutControl( iPortalButtonOne, rect, btnPane );
   215         else
       
   216             {
       
   217             iLayout = ELandscape;
       
   218             }
       
   219 	    }
   212 	    }
   220 	else
   213 	else
   221 	    {
   214 	    {
   222         iLayout = EPortrait;
   215 	    // two buttons
       
   216         // **********************************
       
   217         // we do not have layouts for two buttons yet - layout manually
       
   218         TAknWindowLineLayout btnPane = AknLayoutScalable_Apps
       
   219             ::wgtman_btn_pane( iLandscape ? 1 : 0 ).LayoutLine();
       
   220 	    TAknLayoutRect layoutrect;
       
   221 	    layoutrect.LayoutRect( rect, btnPane );
       
   222 	    TRect r( layoutrect.Rect() );
       
   223 	    TRect r1, r2;
       
   224 	    const TInt gap = 3;
       
   225 	    if ( iLandscape )
       
   226 	        {
       
   227 	        r1 = TRect( r.iTl, TSize( r.Width(), r.Height() / 2 - gap ) );
       
   228 	        r2 = r1;
       
   229             r2.Move( 0, r.Height() / 2 + gap );
       
   230 	        }
       
   231 	    else
       
   232 	        {
       
   233             r1 = TRect( r.iTl, TSize( r.Width() / 2 - gap, r.Height() ) );
       
   234             r2 = r1;
       
   235             if (iMirrored) r1.Move( r.Width() / 2 + gap, 0 );
       
   236             else r2.Move( r.Width() / 2 + gap, 0 );
       
   237             }
       
   238         iPortalButtonOne->SetRect( r1 );
       
   239         iPortalButtonTwo->SetRect( r2 );
       
   240         // *************************************
   223 	    }
   241 	    }
   224 	
   242     
   225     // portal button layout
   243 	// layout iWidgetsList
   226 	// todo: 2-button layout
   244     TAknWindowLineLayout listPane = AknLayoutScalable_Apps
   227     AknLayoutUtils::LayoutControl( iPortalButtonOne, rect, btnPane );
   245         ::listscroll_wgtman_pane( iLandscape ? 1 : 0 ).LayoutLine();
   228     
       
   229     if( iFindbox && iFindPaneIsVisible )
   246     if( iFindbox && iFindPaneIsVisible )
   230         {
   247         {
   231 		TAknLayoutRect layoutRect;
   248 		TAknLayoutRect layoutRect;
   232         layoutRect.LayoutRect( rect, listPane );
   249         layoutRect.LayoutRect( rect, listPane );
   233 		iWidgetsList->SetRect( layoutRect.Rect() );
   250 		iWidgetsList->SetRect( layoutRect.Rect() );
   418     if ( iWidgetsList->IsFocused() )
   435     if ( iWidgetsList->IsFocused() )
   419         {
   436         {
   420         // ------------------------------------
   437         // ------------------------------------
   421         // focus is in the WIDGETS LIST
   438         // focus is in the WIDGETS LIST
   422         // ------------------------------------
   439         // ------------------------------------
   423         if ( iLayout == EPortrait &&
   440         if ( !iLandscape &&
   424                 aKeyEvent.iScanCode == EStdKeyUpArrow &&
   441                 aKeyEvent.iScanCode == EStdKeyUpArrow &&
   425                 iWidgetsList->CurrentItemIndex() == 0 )
   442                 iWidgetsList->CurrentItemIndex() == 0 )
   426             {
   443             {
   427             // widget list top -> up -> ovi button (portrait)
   444             // widget list top -> up -> ovi button (portrait)
   428             if ( aType == EEventKey )
   445             if ( aType == EEventKey )
   429                 SetFocusToPortalButton( 0 );
   446                 SetFocusToPortalButton( 0 );
   430             keyResponse = EKeyWasConsumed;
   447             keyResponse = EKeyWasConsumed;
   431             }
   448             }
   432         else if ( iLayout == EPortrait &&
   449         else if ( !iLandscape &&
   433                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
   450                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
   434                 iWidgetsList->CurrentItemIndex() ==
   451                 iWidgetsList->CurrentItemIndex() ==
   435                    iWidgetsList->Model()->NumberOfItems() - 1 )
   452                    iWidgetsList->Model()->NumberOfItems() - 1 )
   436             {
   453             {
   437             // widget list bottom -> down -> ovi button (portrait)
   454             // widget list bottom -> down -> ovi button (portrait)
   438             if ( aType == EEventKey )
   455             if ( aType == EEventKey )
   439                 SetFocusToPortalButton( 0 );
   456                 SetFocusToPortalButton( 0 );
   440             keyResponse = EKeyWasConsumed;
   457             keyResponse = EKeyWasConsumed;
   441             }
   458             }
   442         else if ( iLayout == ELandscape &&
   459         else if ( iLandscape && !iMirrored &&
   443                 aKeyEvent.iScanCode == EStdKeyRightArrow )
   460                 aKeyEvent.iScanCode == EStdKeyRightArrow )
   444             {
   461             {
   445             // widget list -> right -> ovi button (landscape)
   462             // widget list -> right -> ovi button (landscape normal)
   446             if ( aType == EEventKey )
   463             if ( aType == EEventKey )
   447                 SetFocusToPortalButton( 0 );
   464                 SetFocusToPortalButton( 0 );
   448             keyResponse = EKeyWasConsumed;
   465             keyResponse = EKeyWasConsumed;
   449             }
   466             }
   450         else if ( iLayout == ELandscapeMirrored &&
   467         else if ( iLandscape && iMirrored &&
   451                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
   468                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
   452             {
   469             {
   453             // widget list -> left -> ovi button (landscape mirrored)
   470             // widget list -> left -> ovi button (landscape mirrored)
   454             if ( aType == EEventKey )
   471             if ( aType == EEventKey )
   455                 SetFocusToPortalButton( 0 );
   472                 SetFocusToPortalButton( 0 );
   459     else if ( iPortalButtonOne->IsFocused() )
   476     else if ( iPortalButtonOne->IsFocused() )
   460         {
   477         {
   461         // ------------------------------------
   478         // ------------------------------------
   462         // focus is in the FIRST PORTAL BUTTON
   479         // focus is in the FIRST PORTAL BUTTON
   463         // ------------------------------------
   480         // ------------------------------------
   464         if ( iLayout == EPortrait &&
   481         if ( !iLandscape &&
   465                 aKeyEvent.iScanCode == EStdKeyDownArrow )
   482                 aKeyEvent.iScanCode == EStdKeyDownArrow )
   466             {
   483             {
   467             // left portal -> down -> widget list top
   484             // left portal -> down -> widget list top (portrait)
   468             if ( aType == EEventKey )
   485             if ( aType == EEventKey )
   469                 SetFocusToWidgetList( 0 );
   486                 SetFocusToWidgetList( 0 );
   470             keyResponse = EKeyWasConsumed;
   487             keyResponse = EKeyWasConsumed;
   471             }
   488             }
   472         else if ( iLayout == EPortrait &&
   489         else if ( !iLandscape &&
   473                 aKeyEvent.iScanCode == EStdKeyUpArrow )
   490                 aKeyEvent.iScanCode == EStdKeyUpArrow )
   474             {
   491             {
   475             // left portal -> up -> widget list bottom
   492             // left portal -> up -> widget list bottom (portrait)
   476             if ( aType == EEventKey )
   493             if ( aType == EEventKey )
   477                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
   494                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
   478             keyResponse = EKeyWasConsumed;
   495             keyResponse = EKeyWasConsumed;
   479             }
   496             }
   480         else if ( iLayout == EPortrait &&
   497         else if ( !iLandscape && !iMirrored &&
   481                 aKeyEvent.iScanCode == EStdKeyRightArrow &&
   498                 aKeyEvent.iScanCode == EStdKeyRightArrow &&
   482                 iConfiguration->PortalButtonCount() > 1 )
   499                 iConfiguration->PortalButtonCount() > 1 )
   483             {
   500             {
   484             // left portal -> right -> right portal
   501             // left portal -> right -> right portal (portrait normal)
   485             if ( aType == EEventKey )
   502             if ( aType == EEventKey )
   486                 SetFocusToPortalButton( 1 );
   503                 SetFocusToPortalButton( 1 );
   487             keyResponse = EKeyWasConsumed;
   504             keyResponse = EKeyWasConsumed;
   488             }
   505             }
   489         else if ( iLayout == ELandscape &&
   506         else if ( !iLandscape && iMirrored &&
       
   507                 aKeyEvent.iScanCode == EStdKeyLeftArrow &&
       
   508                 iConfiguration->PortalButtonCount() > 1 )
       
   509             {
       
   510             // right portal -> left -> left portal (portrait mirrored)
       
   511             if ( aType == EEventKey )
       
   512                 SetFocusToPortalButton( 1 );
       
   513             keyResponse = EKeyWasConsumed;
       
   514             }
       
   515         else if ( iLandscape && !iMirrored &&
   490                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
   516                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
   491             {
   517             {
   492             // upper portal -> left -> widget list
   518             // upper portal -> left -> widget list (landscape normal)
   493             if ( aType == EEventKey )
   519             if ( aType == EEventKey )
   494                 SetFocusToWidgetList();
   520                 SetFocusToWidgetList();
   495             keyResponse = EKeyWasConsumed;
   521             keyResponse = EKeyWasConsumed;
   496             }
   522             }
   497         else if ( iLayout == ELandscapeMirrored &&
   523         else if ( iLandscape && iMirrored &&
   498                 aKeyEvent.iScanCode == EStdKeyRightArrow )
   524                 aKeyEvent.iScanCode == EStdKeyRightArrow )
   499             {
   525             {
   500             // upper portal -> right -> widget list (mirrored)
   526             // upper portal -> right -> widget list (landscape mirrored)
   501             if ( aType == EEventKey )
   527             if ( aType == EEventKey )
   502                 SetFocusToWidgetList();
   528                 SetFocusToWidgetList();
   503             keyResponse = EKeyWasConsumed;
   529             keyResponse = EKeyWasConsumed;
   504             }
   530             }
   505         else if ( ( iLayout == ELandscape ||
   531         else if ( iLandscape &&
   506                 iLayout == ELandscapeMirrored ) &&
       
   507                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
   532                 aKeyEvent.iScanCode == EStdKeyDownArrow &&
   508                 iConfiguration->PortalButtonCount() > 1 )
   533                 iConfiguration->PortalButtonCount() > 1 )
   509             {
   534             {
   510             // upper portal -> down -> lower portal
   535             // upper portal -> down -> lower portal (landscape)
   511             if ( aType == EEventKey )
   536             if ( aType == EEventKey )
   512                 SetFocusToPortalButton( 1 );
   537                 SetFocusToPortalButton( 1 );
   513             keyResponse = EKeyWasConsumed;
   538             keyResponse = EKeyWasConsumed;
   514             }
   539             }
   515         }
   540         }
   516     else if ( iPortalButtonTwo && iPortalButtonTwo->IsFocused() )
   541     else if ( iPortalButtonTwo && iPortalButtonTwo->IsFocused() )
   517         {
   542         {
   518         // ------------------------------------
   543         // ------------------------------------
   519         // focus is in the SECOND PORTAL BUTTON
   544         // focus is in the SECOND PORTAL BUTTON
   520         // ------------------------------------
   545         // ------------------------------------
   521         if ( iLayout == EPortrait &&
   546         if ( !iLandscape &&
   522                 aKeyEvent.iScanCode == EStdKeyDownArrow )
   547                 aKeyEvent.iScanCode == EStdKeyDownArrow )
   523             {
   548             {
   524             // right portal -> down -> widget list top
   549             // right portal -> down -> widget list top (portrait)
   525             if ( aType == EEventKey )
   550             if ( aType == EEventKey )
   526                 SetFocusToWidgetList( 0 );
   551                 SetFocusToWidgetList( 0 );
   527             keyResponse = EKeyWasConsumed;
   552             keyResponse = EKeyWasConsumed;
   528             }
   553             }
   529         else if ( iLayout == EPortrait &&
   554         else if ( !iLandscape &&
   530                 aKeyEvent.iScanCode == EStdKeyUpArrow )
   555                 aKeyEvent.iScanCode == EStdKeyUpArrow )
   531             {
   556             {
   532             // right portal -> up -> widget list bottom
   557             // right portal -> up -> widget list bottom (portrait)
   533             if ( aType == EEventKey )
   558             if ( aType == EEventKey )
   534                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
   559                 SetFocusToWidgetList( iWidgetsList->Model()->NumberOfItems()-1 );
   535             keyResponse = EKeyWasConsumed;
   560             keyResponse = EKeyWasConsumed;
   536             }
   561             }
   537         else if ( iLayout == EPortrait &&
   562         else if ( !iLandscape && !iMirrored &&
       
   563                 aKeyEvent.iScanCode == EStdKeyLeftArrow &&
       
   564                 iConfiguration->PortalButtonCount() > 1 )
       
   565             {
       
   566             // right portal -> left -> left portal (portrait normal)
       
   567             if ( aType == EEventKey )
       
   568                 SetFocusToPortalButton( 0 );
       
   569             keyResponse = EKeyWasConsumed;
       
   570             }
       
   571         else if ( !iLandscape && iMirrored &&
   538                 aKeyEvent.iScanCode == EStdKeyRightArrow &&
   572                 aKeyEvent.iScanCode == EStdKeyRightArrow &&
   539                 iConfiguration->PortalButtonCount() > 1 )
   573                 iConfiguration->PortalButtonCount() > 1 )
   540             {
   574             {
   541             // right portal -> right -> left portal
   575             // left portal -> right -> right portal (portrait mirrored)
   542             if ( aType == EEventKey )
   576             if ( aType == EEventKey )
   543                 SetFocusToPortalButton( 0 );
   577                 SetFocusToPortalButton( 0 );
   544             keyResponse = EKeyWasConsumed;
   578             keyResponse = EKeyWasConsumed;
   545             }
   579             }
   546         else if ( iLayout == ELandscape &&
   580         else if ( iLandscape && !iMirrored &&
   547                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
   581                 aKeyEvent.iScanCode == EStdKeyLeftArrow )
   548             {
   582             {
   549             // lower portal -> left -> widget list
   583             // lower portal -> left -> widget list (landscape normal)
   550             if ( aType == EEventKey )
   584             if ( aType == EEventKey )
   551                 SetFocusToWidgetList();
   585                 SetFocusToWidgetList();
   552             keyResponse = EKeyWasConsumed;
   586             keyResponse = EKeyWasConsumed;
   553             }
   587             }
   554         else if ( iLayout == ELandscapeMirrored &&
   588         else if ( iLandscape && iMirrored &&
   555                 aKeyEvent.iScanCode == EStdKeyRightArrow )
   589                 aKeyEvent.iScanCode == EStdKeyRightArrow )
   556             {
   590             {
   557             // lower portal -> right -> widget list (mirrored)
   591             // lower portal -> right -> widget list (landscape mirrored)
   558             if ( aType == EEventKey )
   592             if ( aType == EEventKey )
   559                 SetFocusToWidgetList();
   593                 SetFocusToWidgetList();
   560             keyResponse = EKeyWasConsumed;
   594             keyResponse = EKeyWasConsumed;
   561             }
   595             }
   562         else if ( ( iLayout == ELandscape ||
   596         else if ( iLandscape &&
   563                 iLayout == ELandscapeMirrored ) &&
       
   564                 aKeyEvent.iScanCode == EStdKeyUpArrow )
   597                 aKeyEvent.iScanCode == EStdKeyUpArrow )
   565             {
   598             {
   566             // lower portal -> up -> upper portal
   599             // lower portal -> up -> upper portal (landscape)
   567             if ( aType == EEventKey )
   600             if ( aType == EEventKey )
   568                 SetFocusToPortalButton( 0 );
   601                 SetFocusToPortalButton( 0 );
   569             keyResponse = EKeyWasConsumed;
   602             keyResponse = EKeyWasConsumed;
   570             }
   603             }
   571         }
   604         }
   703 	            // set focus to selected list box item.           
   736 	            // set focus to selected list box item.           
   704                 if ( control == iWidgetsList )
   737                 if ( control == iWidgetsList )
   705                     {
   738                     {
   706                     TInt itemIndex = iWidgetsList->CurrentListBoxItemIndex();
   739                     TInt itemIndex = iWidgetsList->CurrentListBoxItemIndex();
   707                     TBool itemPointed = iWidgetsList->View()->XYPosToItemIndex(
   740                     TBool itemPointed = iWidgetsList->View()->XYPosToItemIndex(
   708                             aPointerEvent.iParentPosition,
   741                             aPointerEvent.iPosition,
   709                             itemIndex );
   742                             itemIndex );
   710                     if ( itemIndex >= 1 && itemPointed )
   743                     if ( itemIndex >= 0 && itemPointed )
   711                         {
   744                         {
   712                         iWidgetsList->SetCurrentItemIndex( itemIndex - 1 );
   745                         iWidgetsList->SetCurrentItemIndex( itemIndex );
   713                         }
   746                         }
   714                     }
   747                     }
   715 
   748 	            
   716 	            // Set focus to the control that was clicked
       
   717 	            control->SetFocus( ETrue );
       
   718 	            // remove focus from ALL other child controls.
   749 	            // remove focus from ALL other child controls.
   719 	            CCoeControlArray::TCursor cursor = Components().Begin();
   750 	            CCoeControlArray::TCursor cursor = Components().Begin();
   720 	            CCoeControl* c;
   751 	            CCoeControl* c;
   721 	            while ((c=cursor.Control<CCoeControl>()) != NULL )
   752 	            while ((c=cursor.Control<CCoeControl>()) != NULL )
   722 	                {
   753 	                {
   723 	                if ( c != control && c->IsFocused() ) c->SetFocus( EFalse );
   754 	                if ( c != control && c->IsFocused() ) c->SetFocus( EFalse );
   724 	                cursor.Next();
   755 	                cursor.Next();
   725 	                }
   756 	                }
       
   757 	            
       
   758 	            // Set focus to the control that was clicked
       
   759 	            control->SetFocus( ETrue );
       
   760 	                            
   726 	            // update focus mode accordingly
   761 	            // update focus mode accordingly
   727 	            UpdateFocusMode();
   762 	            UpdateFocusMode();
   728 	            // repaint
   763 	            // repaint
   729 	            DrawDeferred();
   764 	            DrawDeferred();
   730 	            }
   765 	            }
   865     iWmPlugin.ViewAppUi().AddToStackL( aControl );
   900     iWmPlugin.ViewAppUi().AddToStackL( aControl );
   866     aControl->MakeVisible( ETrue );
   901     aControl->MakeVisible( ETrue );
   867     }
   902     }
   868 
   903 
   869 // ---------------------------------------------------------
   904 // ---------------------------------------------------------
   870 // CWmMainContainer::WmPlugin
       
   871 // ---------------------------------------------------------
       
   872 //
       
   873 CWmPlugin& CWmMainContainer::WmPlugin()
       
   874     {    
       
   875     return iWmPlugin;
       
   876     }
       
   877 
       
   878 // ---------------------------------------------------------
       
   879 // CWmMainContainer::PortalSelected
   905 // CWmMainContainer::PortalSelected
   880 // ---------------------------------------------------------
   906 // ---------------------------------------------------------
   881 //
   907 //
   882 TBool CWmMainContainer::PortalSelected()
   908 TBool CWmMainContainer::PortalSelected()
   883     {    
   909     {    
   974 // CWmMainContainer::CanDoDetails
  1000 // CWmMainContainer::CanDoDetails
   975 // ---------------------------------------------------------
  1001 // ---------------------------------------------------------
   976 //
  1002 //
   977 TBool CWmMainContainer::CanDoDetails()
  1003 TBool CWmMainContainer::CanDoDetails()
   978     {
  1004     {
   979     return WidgetSelected();
  1005     return ( WidgetSelected() && iWidgetsList->WidgetData() );
   980     }
  1006     }
   981 
  1007 
   982 // ---------------------------------------------------------
  1008 // ---------------------------------------------------------
   983 // CWmMainContainer::CanDoHelp
  1009 // CWmMainContainer::CanDoHelp
   984 // ---------------------------------------------------------
  1010 // ---------------------------------------------------------
  1255 // ---------------------------------------------------------------------------
  1281 // ---------------------------------------------------------------------------
  1256 //
  1282 //
  1257 void CWmMainContainer::HandleListBoxEventL(
  1283 void CWmMainContainer::HandleListBoxEventL(
  1258         CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
  1284         CEikListBox* /*aListBox*/, TListBoxEvent aEventType )
  1259     {
  1285     {
  1260     if ( !iClosingDown && ( aEventType == EEventEnterKeyPressed ||
  1286     if ( aEventType == EEventEnterKeyPressed ||
  1261             aEventType == EEventItemSingleClicked ) )
  1287         aEventType == EEventItemSingleClicked )
  1262         {
  1288         {
  1263         AddWidgetToHomeScreenL();
  1289         if ( iFindPaneIsVisible )
       
  1290             {
       
  1291             DeactivateFindPaneL();
       
  1292             }
       
  1293         else if ( !iClosingDown )
       
  1294             {
       
  1295             AddWidgetToHomeScreenL();
       
  1296             }
  1264         }
  1297         }
  1265     }
  1298     }
  1266 
  1299 
  1267 // ----------------------------------------------------
  1300 // ----------------------------------------------------
  1268 // CWmMainContainer::LaunchDetailsDialogL
  1301 // CWmMainContainer::LaunchDetailsDialogL