textinput/peninputgenericitut/src/peninputitutwesternuimgr.cpp
changeset 0 eb1f2e154e89
child 50 5a1685599b76
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2002-2005 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:  drop-down list control
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "peninputitutwesternuimgr.h"
       
    20 #include "peninputgenericitutdata.h"
       
    21 #include "peninputgenericitutdatamgr.h"
       
    22 #include "peninputitutwesternuistatenonpredict.h"
       
    23 #include "peninputitutwesternuistatecusotmization.h"
       
    24 #include "peninputitutwesternuistatematchselection.h"
       
    25 #include "peninputgenericitutlayoutcontext.h"
       
    26 #include "peninputgenericitutcustomization.h"
       
    27 #include "peninputitutcustomizationresourcemgr.h"
       
    28 #include "peninputitutwesternuistatespelling.h"
       
    29 #include "peninputgenericitutlayout.h"
       
    30 #include "peninputgenericitutwindowmanager.h"
       
    31 
       
    32 CWesternItutUiMgr* CWesternItutUiMgr::NewL(MItutLayoutContext* aContext, 
       
    33                                            CGenericItutDataMgr* aDataMgr,
       
    34                                            CGenericItutWindowManager* aUiManager)
       
    35     {
       
    36     CWesternItutUiMgr* self = new (ELeave) CWesternItutUiMgr(aContext, aDataMgr,aUiManager);
       
    37     CleanupStack::PushL(self);
       
    38     self->ConstructL(); 
       
    39     CleanupStack::Pop(self);
       
    40     return self;
       
    41     }
       
    42 
       
    43 CWesternItutUiMgr::~CWesternItutUiMgr()
       
    44     {
       
    45     if (iCurrentState)
       
    46         {
       
    47         iCurrentState->OnExit();
       
    48         }
       
    49         
       
    50     delete iNormalState;
       
    51     delete iCustomerState;
       
    52     delete iMatchSelState;
       
    53     delete iSpellState;
       
    54     }
       
    55 
       
    56 CWesternItutUiMgr::CWesternItutUiMgr(MItutLayoutContext* aContext,
       
    57                                      CGenericItutDataMgr* aDataMgr,
       
    58                                      CGenericItutWindowManager* aUiManager)
       
    59                                     :CGenericItutUiMgrBase(aContext, aDataMgr,aUiManager)
       
    60     {
       
    61     iDataMgr = aDataMgr;
       
    62     }
       
    63 
       
    64 void CWesternItutUiMgr::ConstructL()
       
    65     {
       
    66     CGenericItutUiMgrBase::ConstructL();
       
    67 
       
    68     iNormalState = CWesternItutUiStateNonPredict::NewL(this);
       
    69     iCustomerState = CWesternItutUiStateCustomization::NewL(this);
       
    70     iMatchSelState = CWesternItutUiStateMatchSelection::NewL(this);
       
    71     iSpellState = CWesternItutUiStateSpelling::NewL(this);
       
    72     }
       
    73 
       
    74 TBool CWesternItutUiMgr::HandleCtrlEventL(TInt aEventType, 
       
    75                                           CFepUiBaseCtrl* aCtrl, 
       
    76                                           const TDesC& aEventData)
       
    77     {
       
    78     if (!iCurrentState)
       
    79         {
       
    80         return EFalse;
       
    81         }
       
    82 
       
    83     return iCurrentState->HandleCtrlEventL(aEventType, aCtrl, aEventData);
       
    84     }
       
    85 
       
    86 void CWesternItutUiMgr::SetCurrentStateL(TUiState aNewState)
       
    87     {
       
    88     if (iCurrentState && aNewState == iCurrentState->StateType())
       
    89     	{
       
    90         return;    		
       
    91     	}
       
    92     
       
    93     CGenericItutUiStateBase* newstate = NULL;
       
    94 
       
    95     switch (aNewState)
       
    96         {
       
    97         case CGenericItutUiMgrBase::EStateWesternStandby:
       
    98             {
       
    99             newstate = iNormalState;
       
   100             }
       
   101             break;
       
   102         case CGenericItutUiMgrBase::EStateCustomization:
       
   103             {
       
   104             newstate = iCustomerState;
       
   105             }
       
   106             break;
       
   107         case CGenericItutUiMgrBase::EStateMatchSelection:
       
   108             {
       
   109             newstate = iMatchSelState;
       
   110             }
       
   111             break;
       
   112         case CGenericItutUiMgrBase::EStateSpelling:
       
   113             {
       
   114             newstate = iSpellState;
       
   115             }
       
   116             break;
       
   117         default:
       
   118             return;    
       
   119         }
       
   120 
       
   121     if (iCurrentState)
       
   122         {
       
   123         iCurrentState->OnExit();
       
   124         }
       
   125 
       
   126     iCurrentState = newstate;    
       
   127     if(DataMgr()->IsUpdate())  
       
   128     	{
       
   129     	DataMgr()->SetUpdate(EFalse);
       
   130     	CGenericItutUiLayout* itutLayout = 
       
   131 			static_cast<CGenericItutUiLayout*>( LayoutContext()->UiLayout() );
       
   132 		itutLayout->SizeChanged( NULL );
       
   133     	}
       
   134     iCurrentState->OnEntryL();
       
   135     }
       
   136 
       
   137 void CWesternItutUiMgr::ActivateUiL()
       
   138     {
       
   139     if (iCurrentState)
       
   140         {
       
   141         iCurrentState->OnEntryL();
       
   142         }
       
   143     else
       
   144         {
       
   145         SetCurrentStateL(CGenericItutUiMgrBase::EStateWesternStandby);
       
   146         }
       
   147     }
       
   148 
       
   149 void CWesternItutUiMgr::DeactivateUI()
       
   150     {
       
   151     if (iCurrentState)
       
   152         {
       
   153         iCurrentState->OnExit();
       
   154         //iCurrentState = NULL;
       
   155         }
       
   156     }
       
   157 
       
   158 TInt CWesternItutUiMgr::HandleCommandL(TInt aCmd, TUint8* aData)
       
   159     {
       
   160     if (aCmd == EItutExtCmdCustomerState || 
       
   161         aCmd == ECmdPenInputFingerMatchSelection ||
       
   162         aCmd == ECmdPenInputFingerSpelling)
       
   163         {
       
   164         if (!(*(reinterpret_cast<TBool*>(aData))))
       
   165             {
       
   166             // state not on
       
   167             SetCurrentStateL(CGenericItutUiMgrBase::EStateWesternStandby);
       
   168 
       
   169             return KErrNone;
       
   170             }
       
   171         }
       
   172 
       
   173     switch (aCmd)
       
   174         {
       
   175         case EItutExtCmdCustomerState:
       
   176             {
       
   177             SetCurrentStateL(CGenericItutUiMgrBase::EStateCustomization);
       
   178             return KErrNone;
       
   179             }
       
   180         case ECmdPenInputFingerMatchSelection:
       
   181             {
       
   182             SetCurrentStateL(CGenericItutUiMgrBase::EStateMatchSelection);
       
   183             return KErrNone;    
       
   184             }
       
   185         case ECmdPenInputFingerSpelling:
       
   186             {
       
   187             SetCurrentStateL(CGenericItutUiMgrBase::EStateSpelling);
       
   188             UiManager()->ResetIndicatorL(UiManager()->Control(ECtrlIdSpellIndicator));
       
   189             return KErrNone;
       
   190             }
       
   191         case ECmdPenInputDeActive:            
       
   192         	{
       
   193             if (iCurrentState && 
       
   194                 iCurrentState->StateType() == CGenericItutUiMgrBase::EStateMatchSelection)
       
   195             	{
       
   196             	SetCurrentStateL(CGenericItutUiMgrBase::EStateWesternStandby);	
       
   197             	}
       
   198             }
       
   199             break;
       
   200         case ECmdPenInputCase:
       
   201             {
       
   202             if (iCurrentState)
       
   203                 {
       
   204                 iLayoutContext->DataMgr()->SetCase(*((TUint*) aData));
       
   205                 return KErrNone;
       
   206                 }
       
   207             }
       
   208             break;
       
   209         case EItutCmdCheckIcfEmpty:
       
   210             {
       
   211             if (iCurrentState && 
       
   212                 iCurrentState->StateType() == CGenericItutUiMgrBase::EStateSpelling)
       
   213                 {
       
   214                 iCurrentState->HandleCommandL(aCmd, aData);
       
   215                 }
       
   216                 
       
   217             }
       
   218             break;            
       
   219         default:
       
   220             break;
       
   221         }
       
   222 
       
   223     if (iCurrentState)
       
   224         {
       
   225         return iCurrentState->HandleCommandL(aCmd, aData);
       
   226         }
       
   227 
       
   228     return KErrNotSupported;
       
   229     }
       
   230 
       
   231 // End Of File