textinput/peninputsplititut/src/peninputsplititutwesternuistatespelling.cpp
branchRCL_3
changeset 5 a47de9135b21
child 18 b1ea1642412e
equal deleted inserted replaced
3:f5a1e66df979 5:a47de9135b21
       
     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 <AknFepGlobalEnums.h>
       
    20 #include <peninputsplititutnew.rsg>
       
    21 #include <peninputlayoutmultilineicf.h>
       
    22 #include <StringLoader.h>
       
    23 #include <peninputcommonbutton.h>
       
    24 #include <peninputlayout.h>
       
    25 #include <peninputcmd.h>
       
    26 #include <peninputlabel.h>
       
    27 
       
    28 #include "peninputsplititutwesternuistatespelling.h"
       
    29 #include "peninputsplititutuimgrbase.h"
       
    30 #include "peninputsplititutdatamgr.h"
       
    31 #include "peninputsplititutlayoutcontext.h"
       
    32 #include "peninputsplititutconverter.h"
       
    33 #include "peninputsplititutlayout.h"
       
    34 #include "peninputcommonbgctrl.h"
       
    35 #include "peninputsplititutwindowmanager.h"
       
    36 #include "peninputsplititutwindow.h"
       
    37 
       
    38 CWesternSplitItutUiStateSpelling* CWesternSplitItutUiStateSpelling::NewL(CSplitItutUiMgrBase* aOwner)
       
    39     {
       
    40     CWesternSplitItutUiStateSpelling* self = new (ELeave) CWesternSplitItutUiStateSpelling(aOwner);
       
    41     CleanupStack::PushL(self);
       
    42     self->ConstructL(); 
       
    43     CleanupStack::Pop(self);
       
    44     return self;
       
    45     }
       
    46 
       
    47 CWesternSplitItutUiStateSpelling::~CWesternSplitItutUiStateSpelling()
       
    48     {
       
    49     }
       
    50 
       
    51 CWesternSplitItutUiStateSpelling::CWesternSplitItutUiStateSpelling(CSplitItutUiMgrBase* aOwner)
       
    52                                                         :CSplitItutUiStateBase(aOwner)
       
    53     {
       
    54     iICF = static_cast<CFepLayoutMultiLineIcf*>(iOwner->LayoutContext()->Control(ECtrlIdICF));
       
    55     }
       
    56 
       
    57 void CWesternSplitItutUiStateSpelling::ConstructL()
       
    58     {
       
    59     CSplitItutUiStateBase::ConstructL();
       
    60     }
       
    61 
       
    62 void CWesternSplitItutUiStateSpelling::CreateTextBtnIfNeededL(CAknFepCtrlCommonButton*& aBtn, 
       
    63                                                          TInt aCtrlId,
       
    64                                                          TInt aCtrlPos,
       
    65                                                          TInt aTextResId,
       
    66                                                          TAknTextLineLayout aTextFormat)
       
    67     {
       
    68     if (!aBtn)
       
    69         {
       
    70         aBtn = CAknFepCtrlCommonButton::NewL(iOwner->LayoutContext()->UiLayout(), 
       
    71                                              aCtrlId,
       
    72                                              KAknsIIDQsnFrFunctionButtonNormal,
       
    73                                              KAknsIIDQsnFrFunctionButtonPressed,
       
    74                                              KAknsIIDQsnFrFunctionButtonInactive);
       
    75         aBtn->SetRect(TItutDataConverter::AnyToRect(iOwner->DataMgr()->RequestData(aCtrlPos)));
       
    76         HBufC* btntext = StringLoader::LoadLC(aTextResId);
       
    77         aBtn->SetTextFormat(aTextFormat);
       
    78         aBtn->SetTextL(*btntext);
       
    79         aBtn->SetTextColorIndex( EAknsCIQsnTextColorsCG65 );
       
    80         CleanupStack::PopAndDestroy(btntext);
       
    81         iOwner->LayoutContext()->UiLayout()->AddControlL(aBtn);
       
    82         }
       
    83     }
       
    84 
       
    85 void CWesternSplitItutUiStateSpelling::OnEntryL()
       
    86     {
       
    87     TInt keypadResId = KInvalidResId;
       
    88     switch (iOwner->DataMgr()->InputMode())
       
    89         {
       
    90         case ENumber:
       
    91             keypadResId = R_FINGER_INPUT_KEYPAD_NUMBER;
       
    92             break;
       
    93         case ELatin:
       
    94             keypadResId = iOwner->DataMgr()->KeypadResourceId();
       
    95             break;
       
    96         default:
       
    97             break;                
       
    98         }
       
    99     //hide bubble in the first place.    
       
   100     iICF->HideBubble();
       
   101 
       
   102     // update resource id of keypad    
       
   103     iOwner->DataMgr()->NotifyChangeControlLayout(
       
   104         MItutPropertySubscriber::EItutPropertyKeypadResourceId, keypadResId);
       
   105 
       
   106     // hide not needed controls
       
   107     //iOwner->LayoutContext()->Control(ECtrlIdArrowLeft)->Hide(ETrue);
       
   108     //iOwner->LayoutContext()->Control(ECtrlIdArrowRight)->Hide(ETrue);
       
   109     iOwner->LayoutContext()->ShowArrowBtn( EBtnArrowLeft | EBtnArrowRight );
       
   110     iOwner->LayoutContext()->Control(ECtrlIdOptions)->Hide(ETrue);
       
   111     iOwner->LayoutContext()->Control(ECtrlIdClose)->Hide(ETrue);
       
   112     
       
   113     TAknTextLineLayout btntextformat = TItutDataConverter::AnyToTextLine(
       
   114                                                iOwner->DataMgr()->RequestData(EBtnTextLine));
       
   115     CreateTextBtnIfNeededL(iOk, ECtrlIdOkBtn, EItutPosOk, R_PENINPUT_FINGER_OK, btntextformat);
       
   116     iOk->SetReady(ETrue);
       
   117     iOk->Hide(EFalse);
       
   118     iICF->IsEmpty() ? iOk->SetDimmed(ETrue) : iOk->SetDimmed(EFalse);
       
   119 
       
   120     CreateTextBtnIfNeededL(iCancel, ECtrlIdCancelBtn, EItutPosCancel, 
       
   121                            R_PENINPUT_FINGER_CANCEL, btntextformat);
       
   122     iCancel->SetReady(ETrue);
       
   123     iCancel->Hide(EFalse);
       
   124 
       
   125     iOwner->DataMgr()->SetSpellMode(ETrue);
       
   126     iICF->SetLineSeparatorAfterPrompt(ETrue);
       
   127     
       
   128     ReCalcLayoutL();
       
   129 
       
   130     iICF->Hide( EFalse );
       
   131     iOwner->DataMgr()->SetUpdate(ETrue);
       
   132     }
       
   133 
       
   134 void CWesternSplitItutUiStateSpelling::OnExit()
       
   135     {    
       
   136     iOk->Hide(ETrue);
       
   137     iCancel->Hide(ETrue);
       
   138     iOwner->DataMgr()->SetSpellMode(EFalse);
       
   139     iICF->Hide( ETrue );
       
   140     iOwner->LayoutContext()->ShowArrowBtn(0);
       
   141     }
       
   142 
       
   143 CSplitItutUiMgrBase::TUiState CWesternSplitItutUiStateSpelling::StateType()
       
   144     {
       
   145     return CSplitItutUiMgrBase::EStateSpelling;
       
   146     }
       
   147 
       
   148 TInt CWesternSplitItutUiStateSpelling::HandleCommandL(TInt aCmd, TUint8* /*aData*/)
       
   149     {
       
   150     switch (aCmd) 
       
   151         {
       
   152         case EItutExtCmdSizeChanged:
       
   153             {
       
   154 			ReCalcLayoutL();
       
   155             return KErrNone;
       
   156             }
       
   157         
       
   158        	case EItutCmdCheckIcfEmpty:
       
   159        	    {
       
   160 		    iICF->IsEmpty() ? iOk->SetDimmed(ETrue) : iOk->SetDimmed(EFalse);
       
   161             return KErrNone;
       
   162        	    }
       
   163         default:
       
   164             break;
       
   165         }
       
   166 
       
   167     return KErrNotSupported;    
       
   168     }
       
   169 
       
   170 TBool CWesternSplitItutUiStateSpelling::HandleCtrlEventL(TInt aEventType, 
       
   171                                                     CFepUiBaseCtrl* aCtrl, 
       
   172                                                     const TDesC& /*aEventData*/)
       
   173     {
       
   174     switch (aEventType)
       
   175         {
       
   176         case EEventButtonUp:
       
   177             {
       
   178             TInt ctrlid = aCtrl->ControlId();
       
   179 
       
   180             if (ctrlid != ECtrlIdOkBtn && ctrlid != ECtrlIdCancelBtn)
       
   181                 {
       
   182                 return EFalse;
       
   183                 }
       
   184 
       
   185             TBuf<4> buf;
       
   186             TBool exitbyok = (ctrlid == ECtrlIdOkBtn);
       
   187             buf.Append(reinterpret_cast<TText*>(&exitbyok), sizeof(TBool)/sizeof(TText));
       
   188             
       
   189             iOwner->LayoutContext()->UiLayout()->SignalOwner(ESignalExitSpellMode, buf);
       
   190             return ETrue;
       
   191             }
       
   192         default:
       
   193             break;
       
   194         }
       
   195 
       
   196     return EFalse;    
       
   197     }
       
   198 
       
   199 void CWesternSplitItutUiStateSpelling::ReCalcLayoutL()
       
   200 	{
       
   201 	// Update "OK" and "Cancel" position
       
   202     TAknTextLineLayout btntextformat = TItutDataConverter::AnyToTextLine(
       
   203                                                  iOwner->DataMgr()->RequestData(EBtnTextLine));
       
   204     TRect btnrect = TItutDataConverter::AnyToRect(iOwner->DataMgr()->RequestData(EItutPosOk));
       
   205     iOk->SetTextFormat(btntextformat);
       
   206     iOk->SizeChanged(btnrect, btnrect, ETrue);
       
   207 
       
   208     btnrect = TItutDataConverter::AnyToRect(iOwner->DataMgr()->RequestData(EItutPosCancel));
       
   209     iCancel->SetTextFormat(btntextformat);
       
   210     iCancel->SizeChanged(btnrect, btnrect, ETrue);
       
   211 
       
   212     // Update key position
       
   213     iOwner->LayoutContext()->ApplyVariantLafDataForSpellL();	
       
   214 	}
       
   215 	
       
   216 // End Of File