cmmanager/cmmgr/Framework/Src/cmdesticondialog.cpp
branchRCL_3
changeset 58 83ca720e2b9a
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of CCmDestinationIconDialog
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <uikon.hrh>
       
    20 #include <e32std.h>
       
    21 #include <eikcapc.h>
       
    22 
       
    23 #include <aknlayoutscalable_avkon.cdl.h>
       
    24 #include <layoutmetadata.cdl.h>
       
    25 
       
    26 #include <aknborders.h>
       
    27 #include <aknconsts.h>
       
    28 #include <AknUtils.h>
       
    29 #include <aknPopupHeadingPane.h>
       
    30 #include <AknSettingCache.h>
       
    31 
       
    32 #include <AknLayout.lag>
       
    33 #include <e32property.h>
       
    34 
       
    35 #include <cmmanager.rsg>
       
    36 
       
    37 #include "cmmanager.hrh"
       
    38 #include "cmdesticondialog.h"
       
    39 #include "cmdesticonmap.h"
       
    40 
       
    41 // ============================ MEMBER FUNCTIONS ===============================
       
    42 
       
    43 // ----------------------------------------------------------------------------
       
    44 // CCmDestinationIconDialog class
       
    45 // CCmDestinationIconDialog() - constructor
       
    46 // ----------------------------------------------------------------------------
       
    47 //
       
    48 CCmDestinationIconDialog::CCmDestinationIconDialog( TInt& aIconIndex )
       
    49     : iIconIndex(&aIconIndex)
       
    50     {
       
    51     CEikDialog::SetBorder( AknBorderId::EAknBorderNotePopup );
       
    52     }
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CCmDestinationIconDialog::~CCmDestinationIconDialog()
       
    56 // -----------------------------------------------------------------------------
       
    57 //
       
    58 CCmDestinationIconDialog::~CCmDestinationIconDialog()
       
    59     {
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CCmDestinationIconDialog::HandleResourceChange()
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 void CCmDestinationIconDialog::HandleResourceChange(TInt aType)
       
    67     {
       
    68     CAknDialog::HandleResourceChange(aType);
       
    69 
       
    70     if (aType==KEikDynamicLayoutVariantSwitch)
       
    71         {
       
    72         }
       
    73     }
       
    74 
       
    75 // -----------------------------------------------------------------------------
       
    76 // CCmDestinationIconDialog::OkToExitL()
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 TBool CCmDestinationIconDialog::OkToExitL(TInt aButtonId)
       
    80     {
       
    81     CCmDestinationIconMap* iconmapControl = 
       
    82         STATIC_CAST(CCmDestinationIconMap*, Control(ECmDestIconMapContentId));
       
    83     // Selection key / select softkey adds a iconacter only if 5-key was not 
       
    84     // used to select multiple icons before.
       
    85     if ( aButtonId == EAknSoftkeyOk || aButtonId == EAknSoftkeySelect )
       
    86         {
       
    87         TKeyEvent key;
       
    88         key.iCode=EKeyOK;
       
    89         key.iModifiers=0;
       
    90         iconmapControl->OfferKeyEventL(key, EEventKey);
       
    91         }
       
    92     return(ETrue);
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CCmDestinationIconDialog::PreLayoutDynInitL()
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 void CCmDestinationIconDialog::PreLayoutDynInitL()
       
   100     {
       
   101     CCmDestinationIconMap* iconmapControl = 
       
   102        STATIC_CAST( CCmDestinationIconMap*, Control( ECmDestIconMapContentId ));
       
   103     CAknPopupHeadingPane* headingPane =
       
   104        STATIC_CAST( CAknPopupHeadingPane*, Control( EAknSCTQueryHeadingId ));
       
   105 
       
   106     iconmapControl->SetIndex(*iIconIndex);    
       
   107 
       
   108     SetLineNonFocusing(EAknSCTQueryHeadingId);
       
   109 
       
   110     // add title    
       
   111     CEikonEnv* env = CEikonEnv::Static();
       
   112     HBufC* title = env->AllocReadResourceL( R_CMMANAGERUI_PRMPT_SELECT_ICON );
       
   113     CleanupStack::PushL( title );
       
   114     headingPane->SetTextL( *title );
       
   115     CleanupStack::PopAndDestroy( title );
       
   116     title = NULL;
       
   117 
       
   118 #ifdef RD_SCALABLE_UI_V2
       
   119 
       
   120 	iconmapControl->SetObserver(this);
       
   121 	
       
   122 #endif // RD_SCALABLE_UI_V2
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // CCmDestinationIconDialog::SetSizeAndPosition()
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 void CCmDestinationIconDialog::SetSizeAndPosition( const TSize& aSize )
       
   130     {
       
   131     SetBorder( TGulBorder::ENone ); // No Dialog borders in SCT.
       
   132     CAknDialog::SetSizeAndPosition( aSize );
       
   133     }
       
   134 
       
   135 // -----------------------------------------------------------------------------
       
   136 // CCmDestinationIconDialog::OfferKeyEventL()
       
   137 // -----------------------------------------------------------------------------
       
   138 //
       
   139 TKeyResponse CCmDestinationIconDialog::OfferKeyEventL(
       
   140                              const TKeyEvent& aKeyEvent, TEventCode aModifiers )
       
   141     {
       
   142     if ( aModifiers == EEventKey )
       
   143         {
       
   144         TUint code=aKeyEvent.iCode;
       
   145         CCmDestinationIconMap* iconmapControl =
       
   146                             STATIC_CAST( CCmDestinationIconMap*, 
       
   147                                          Control( ECmDestIconMapContentId ));
       
   148 
       
   149         switch ( code )
       
   150             {
       
   151             case EKeyLeftArrow:
       
   152             case EKeyRightArrow:
       
   153             case EKeyUpArrow:
       
   154             case EKeyDownArrow:
       
   155                 {
       
   156                 TKeyResponse res(
       
   157                     iconmapControl->OfferKeyEventL( aKeyEvent, aModifiers ));
       
   158                 return res;
       
   159                 }
       
   160                 
       
   161             case EKeyEnter:
       
   162                 // change fro EKeyEnter to EKeyOK
       
   163                 {
       
   164                 TKeyEvent keyEvent;
       
   165                 keyEvent.iCode = EKeyOK;
       
   166                 keyEvent.iScanCode = aKeyEvent.iScanCode;
       
   167                 keyEvent.iModifiers = aKeyEvent.iModifiers;
       
   168                 keyEvent.iRepeats = aKeyEvent.iRepeats;
       
   169 
       
   170                 TKeyResponse res( CEikDialog::OfferKeyEventL( keyEvent, aModifiers ) );
       
   171                 // It seems Avkon doesn't continue to call OkToExitL after this OfferKeyEventL.
       
   172                 // So, we may have to positively exit by calling TryExitL so that user's selected
       
   173                 // Icon will be return back to caller (i.e., CDestDlg).
       
   174                 TryExitL( EAknSoftkeyOk );
       
   175                 return res;
       
   176                 }
       
   177                 
       
   178             default:
       
   179                 break;
       
   180             }
       
   181         }
       
   182         
       
   183     return CEikDialog::OfferKeyEventL( aKeyEvent, aModifiers );
       
   184     }
       
   185 
       
   186 // -----------------------------------------------------------------------------
       
   187 // CCmDestinationIconDialog::ExecuteLD()
       
   188 // -----------------------------------------------------------------------------
       
   189 //
       
   190 TInt CCmDestinationIconDialog::ExecuteLD()
       
   191     {
       
   192     // Prepare real icon map
       
   193     CEikDialog::PrepareLC( R_ICONSEL_DIALOG );
       
   194     return(RunLD());
       
   195     }
       
   196 
       
   197 // -----------------------------------------------------------------------------
       
   198 // CCmDestinationIconDialog::CEikDialog_Reserved_1()
       
   199 // -----------------------------------------------------------------------------
       
   200 //
       
   201 void CCmDestinationIconDialog::CEikDialog_Reserved_1()
       
   202     {
       
   203     }
       
   204 
       
   205 // -----------------------------------------------------------------------------
       
   206 // CCmDestinationIconDialog::CEikDialog_Reserved_2()
       
   207 // -----------------------------------------------------------------------------
       
   208 //
       
   209 void CCmDestinationIconDialog::CEikDialog_Reserved_2()
       
   210     {
       
   211     }
       
   212 
       
   213 // -----------------------------------------------------------------------------
       
   214 // CCmDestinationIconDialog::CCmDestinationIconDialog_Reserved()
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 void CCmDestinationIconDialog::CAknIconMapDialog_Reserved()
       
   218     {
       
   219     }
       
   220 
       
   221 // -----------------------------------------------------------------------------
       
   222 // CCmDestinationIconDialog::CreateCustomControlL()
       
   223 // Virtual function override from the base class to implement the custom control
       
   224 // -----------------------------------------------------------------------------
       
   225 //    
       
   226 SEikControlInfo CCmDestinationIconDialog::CreateCustomControlL(
       
   227     TInt aControlType)
       
   228     {
       
   229     CCmDestinationIconMap *control= NULL;
       
   230     if ( aControlType == KCmDestIconMapType )
       
   231         {
       
   232         control = CCmDestinationIconMap::NewL();
       
   233         }
       
   234     SEikControlInfo info;
       
   235     info.iControl = control;
       
   236     info.iFlags = 0;
       
   237     info.iTrailerTextId = 0;
       
   238     return info;
       
   239     }
       
   240 
       
   241 #ifdef RD_SCALABLE_UI_V2
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CCmDestinationIconDialog::HandleControlEventL
       
   245 // Handles the event.
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 void CCmDestinationIconDialog::HandleControlEventL( 
       
   249                                                 CCoeControl* /*aControl*/,
       
   250                                                 TCoeEvent aEventType )
       
   251     {
       
   252     if( aEventType == EEventStateChanged)
       
   253 		{
       
   254 	    iConSelected = ETrue;
       
   255 		}
       
   256     } 
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CCmDestinationIconDialog::HandleDialogPageEventL
       
   260 // Handles the event.
       
   261 // -----------------------------------------------------------------------------
       
   262 //
       
   263 void CCmDestinationIconDialog::HandleDialogPageEventL(TInt aEventID)
       
   264 	{
       
   265     if ( AknLayoutUtils::PenEnabled() && ( aEventID == 
       
   266          MEikDialogPageObserver::EDialogPageTapped && iConSelected ) )
       
   267 	    {
       
   268 	    TryExitL( EAknSoftkeyOk );
       
   269 	    }
       
   270 	}
       
   271 	
       
   272 #endif //RD_SCALABLE_UI_V2
       
   273 
       
   274 //  End of File