exampleapps/alfexanalogdialer/src/alfexanalogdialerappui.cpp
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2008-2008 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 member functions of CAlfExAnalogDialerAppUi.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include <avkon.hrh>
       
    21 #include <aknnotewrappers.h>
       
    22 #include <aknutils.h>
       
    23 #include <akndef.h>                 // KAknFullOrPartialForegroundGained/Lost
       
    24 
       
    25 #include <alf/alfcontrolgroup.h>
       
    26 #include <alf/alfdisplay.h>
       
    27 #include <uiacceltk/huidisplay.h>
       
    28 #include <uiacceltk/huiutil.h>
       
    29 #include <alf/alfcontrol.h>
       
    30 #include <alf/alfanchorlayout.h>
       
    31 #include <alf/alftextvisual.h>
       
    32 #include <alf/alfroster.h>
       
    33 #include <alf/alfevent.h>
       
    34 #include <alf/alfclientbase.h>
       
    35 #include <alf/alftransformation.h>
       
    36 
       
    37 #include "alfexanalogdialer.pan"
       
    38 #include "alfexanalogdialerappui.h"
       
    39 #include "alfexanalogdialer.hrh"
       
    40 
       
    41 #include "alfexanalogdialercontrol.h"
       
    42 
       
    43 // Identifier for the primary control group.
       
    44 const TInt KExAnalogControlPrimaryGroup = 1;
       
    45 
       
    46 // Location of image files of analog dialer
       
    47 _LIT(KAnalogDialerImagePath, "c:\\Data\\Images\\Pictures\\");
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CAlfExAnalogDialerAppUi
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CAlfExAnalogDialerAppUi::CAlfExAnalogDialerAppUi()
       
    54     {
       
    55 	// no implementation required
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // ConstructL
       
    60 // ConstructL is called by the application framework
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 void CAlfExAnalogDialerAppUi::ConstructL()
       
    64     {
       
    65     // Enable Avkon skins.
       
    66     BaseConstructL(EAknEnableSkin);
       
    67 
       
    68     // create ALF environment
       
    69     iEnv = CAlfEnv::NewL();    
       
    70 
       
    71     // set location of images
       
    72     iEnv->TextureManager().SetImagePathL(KAnalogDialerImagePath);
       
    73 
       
    74     // get the application screen area. Neither status pane nor softkeys exist
       
    75     TRect rect;
       
    76     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EApplicationWindow, rect);
       
    77     
       
    78     // create display
       
    79     CAlfDisplay& disp = iEnv->NewDisplayL(rect, CAlfEnv::ENewDisplayAsCoeControl);
       
    80     disp.SetClearBackgroundL(CAlfDisplay::EClearWithSkinBackground);
       
    81 
       
    82     // Create a control group.
       
    83     CAlfControlGroup& group = iEnv->NewControlGroupL(KExAnalogControlPrimaryGroup);
       
    84 
       
    85     // Create control for analog dialer and add it into control group
       
    86     CAlfExAnalogDialerControl* control = CAlfExAnalogDialerControl::NewLC(*iEnv);
       
    87     group.AppendL(control);
       
    88     CleanupStack::Pop(control);
       
    89     
       
    90     // Show the control group on the display.
       
    91     disp.Roster().ShowL( group );
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------------------------
       
    95 // ~CAlfExAnalogDialerAppUi()
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 CAlfExAnalogDialerAppUi::~CAlfExAnalogDialerAppUi()
       
    99     {
       
   100     delete iEnv;
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // HandleCommandL
       
   105 // Handle commands from framework
       
   106 // ---------------------------------------------------------------------------
       
   107 //
       
   108 void CAlfExAnalogDialerAppUi::HandleCommandL(TInt aCommand)
       
   109     {
       
   110     switch(aCommand)
       
   111         {
       
   112         case EEikCmdExit:
       
   113         case EAknSoftkeyExit:
       
   114             Exit();
       
   115             break;
       
   116         default:
       
   117             CAknAppUi::HandleCommandL(aCommand);
       
   118             break;
       
   119         }
       
   120     }
       
   121 
       
   122 // ----------------------------------------------------------
       
   123 // HandleResourceChangeL
       
   124 // Handle Resource Change Events: Display orientation switch
       
   125 // ----------------------------------------------------------
       
   126 //
       
   127 void CAlfExAnalogDialerAppUi::HandleResourceChangeL(TInt aType)
       
   128     {
       
   129     CAknAppUi::HandleResourceChangeL(aType);
       
   130 
       
   131     if(aType == KEikDynamicLayoutVariantSwitch)
       
   132         {
       
   133         CAlfControlGroup& group = iEnv->ControlGroup(KExAnalogControlPrimaryGroup);
       
   134         CAlfExAnalogDialerControl* control = static_cast<CAlfExAnalogDialerControl*> 
       
   135                                     ( group.FindControl(KAlfExAnalogDialerControlId));
       
   136         if (control)
       
   137             {
       
   138             // TODO: experimental code
       
   139             control->PrepareForLayoutSwitchL();
       
   140             }
       
   141 
       
   142         TRect rect;
       
   143         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EApplicationWindow, rect);
       
   144         iEnv->PrimaryDisplay().SetVisibleArea(rect);    
       
   145         if (control)
       
   146             {
       
   147             control->SwitchLayoutL();
       
   148             }
       
   149         }
       
   150     }
       
   151 
       
   152 // ----------------------------------------------------------
       
   153 // HandleWsEventL
       
   154 // Handle Resource Change Events: Display orientation switch
       
   155 // ----------------------------------------------------------
       
   156 //
       
   157 void CAlfExAnalogDialerAppUi::HandleWsEventL(   const TWsEvent& aEvent,
       
   158 	                                            CCoeControl*    aDestination)
       
   159     { 
       
   160     // When the application is put to the background, release resources.
       
   161     // This is not mandatory.
       
   162 	switch(aEvent.Type()) 
       
   163     	{ 
       
   164     	case KAknFullOrPartialForegroundLost:
       
   165         	//iEnv->Release();
       
   166         	break;
       
   167 
       
   168     	case KAknFullOrPartialForegroundGained:
       
   169         	//iEnv->RestoreL();
       
   170         	break;
       
   171     
       
   172       	default:
       
   173         	break;
       
   174     	}
       
   175 
       
   176     CAknAppUi::HandleWsEventL(aEvent, aDestination);
       
   177     }
       
   178 
       
   179