textinput/peninputsplititut/src/peninputsplititutlayout.cpp
changeset 0 eb1f2e154e89
child 7 a47de9135b21
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:  split itu-t layout
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <peninputsplititutnew.rsg>
       
    20 #include <peninputsplititutconfig_chinese.rsg>
       
    21 #include <skinlayout.cdl.h>
       
    22 #include <AknsDrawUtils.h>
       
    23 #include <AknsUtils.h>
       
    24 #include <AknUtils.h> 
       
    25 #include <peninputrawkeybutton.h>
       
    26 #include <peninputrepeatbutton.h>
       
    27 #include <peninputcommonbutton.h>
       
    28 #include <AknFepGlobalEnums.h>
       
    29 #include <aknfeppeninputenums.h>
       
    30 //#include <peninputdropdownlist.h>
       
    31 
       
    32 #include <s32mem.h>
       
    33 //#include <peninputlayoutbubblectrl.h>
       
    34 
       
    35 #include <peninputdataprovider.h>      
       
    36 #include <peninputcommonlayoutglobalenum.h>
       
    37 
       
    38 #include "peninputsplititutlayout.h"
       
    39 #include "peninputsplititutdatamgr.h"
       
    40 #include "peninputsplititutuimgrbase.h"
       
    41 #include "peninputsplititutuistatebase.h"
       
    42 #include "peninputsplititutchnuimgr.h"
       
    43 #include "peninputsplititutwesternuimgr.h"
       
    44 #include "peninputsplititutconverter.h"
       
    45 #include "peninputsplititutwindowmanager.h"
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CSplitItutUiLayout::NewL
       
    50 // (other items were commented in a header)
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CSplitItutUiLayout* CSplitItutUiLayout::NewL(MLayoutOwner* aLayoutOwner,
       
    54                                                  const TAny* aInitData)
       
    55     {
       
    56     CSplitItutUiLayout* layout = new (ELeave) CSplitItutUiLayout(aLayoutOwner);
       
    57 
       
    58     CleanupStack::PushL(layout);
       
    59     layout->ConstructL(aInitData);
       
    60     CleanupStack::Pop(layout);
       
    61 
       
    62     return layout;
       
    63     }
       
    64     
       
    65 // ---------------------------------------------------------------------------
       
    66 // CSplitItutUiLayout::CSplitItutUiLayout
       
    67 // (other items were commented in a header)
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CSplitItutUiLayout::CSplitItutUiLayout(MLayoutOwner* aLayoutOwner)
       
    71                                           :CFepUiLayout(aLayoutOwner)
       
    72     {
       
    73     }
       
    74 
       
    75 // ---------CSplitItutUiLayout----------------------------------------
       
    76 // CSplitItutUiLayout::~CSplitItutUiLayout
       
    77 // (other items were commented in a header)
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CSplitItutUiLayout::~CSplitItutUiLayout()
       
    81     {
       
    82     delete iDataMgr;
       
    83     delete iChnUiMgr;
       
    84     delete iWesternUiMgr;
       
    85     delete iWindowMgr;
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // CSplitItutUiLayout::ConstructL
       
    90 // (other items were commented in a header)
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 void CSplitItutUiLayout::ConstructL(const TAny* aInitData)
       
    94     {
       
    95     BaseConstructL();
       
    96 
       
    97     TPeninputLayoutData* layoutData = (TPeninputLayoutData*)aInitData;
       
    98     
       
    99     iDataMgr = CSplitItutDataMgr::NewL(this, layoutData->iPtiEngine );
       
   100     SetScreenSize(TItutDataConverter::AnyToSize(iDataMgr->RequestData(EScreenSize)));
       
   101 
       
   102     // western ui mgr is default ui mgr
       
   103     iWindowMgr = CSplitItutWindowManager::NewL(this, iDataMgr);
       
   104     iDataMgr->AddSubscriber(iWindowMgr);    
       
   105     iWesternUiMgr = CWesternSplitItutUiMgr::NewL(this, iDataMgr, iWindowMgr);
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------------------------
       
   109 // CSplitItutUiLayout::SimulateRawEvent
       
   110 // (other items were commented in a header)
       
   111 // ---------------------------------------------------------------------------
       
   112 //
       
   113 void CSplitItutUiLayout::SimulateRawEvent(TInt aScanCode, TRawEvent::TType aType)
       
   114     {
       
   115     TRawEvent event; 
       
   116     event.Set(aType,aScanCode);
       
   117     
       
   118     TPtrC eventPtr(reinterpret_cast<const TUint16*>(&event),sizeof(event)/sizeof(TUint16));
       
   119 
       
   120     SignalOwner(ESignalSimulateEvent,eventPtr);
       
   121     }
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CSplitItutUiLayout::HandleControlEvent
       
   125 // (other items were commented in a header)
       
   126 // ---------------------------------------------------------------------------
       
   127 //
       
   128 void CSplitItutUiLayout::HandleControlEvent(TInt aEventType, 
       
   129                                               CFepUiBaseCtrl* aCtrl, 
       
   130                                               const TDesC& aEventData)
       
   131     {
       
   132     TBool handled = EFalse;
       
   133 
       
   134     if (UiMgr())
       
   135         {
       
   136         TRAP_IGNORE(handled = UiMgr()->HandleCtrlEventL(aEventType,
       
   137                                                         aCtrl,
       
   138                                                         aEventData));
       
   139         }
       
   140 
       
   141     if (handled)
       
   142         {
       
   143         return;   
       
   144         }
       
   145 
       
   146     TRAP_IGNORE(iWindowMgr->HandleCtrlEventL(aEventType,
       
   147                                              aCtrl,
       
   148                                              aEventData));
       
   149    }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // CSplitItutUiLayout::HandleCommand
       
   153 // (other items were commented in a header)
       
   154 // ---------------------------------------------------------------------------
       
   155 //
       
   156 TInt CSplitItutUiLayout::HandleCommand(TInt aCmd, TUint8* aData)
       
   157     {
       
   158     if ( KErrNone == CFepUiLayout::HandleCommand( aCmd, aData ) )
       
   159         {
       
   160         return KErrNone;
       
   161         }
       
   162 
       
   163     TUint* data = (TUint*) aData;
       
   164 
       
   165     switch(aCmd)
       
   166         {
       
   167         case ECmdPenInputLanguage:
       
   168             {
       
   169             TRAP_IGNORE(SetInputLanguageL(*data));
       
   170             
       
   171             }
       
   172             break;
       
   173         case ECmdPenInputRange:
       
   174         	{
       
   175         	iDataMgr->SetLatinOnly( *data );
       
   176         	}
       
   177         	break;
       
   178         case ECmdPenInputFingerInputMode:
       
   179             {
       
   180             TRAP_IGNORE(SetInputModeL(*data));
       
   181             }
       
   182             break;
       
   183         case ECmdPenInputFingerKeyPress:
       
   184         case ECmdPenInputFingerLongKeyPress:
       
   185         case ECmdPenInputCase:
       
   186         case ECmdPenInputFingerMatchSelection:
       
   187             {
       
   188             if (UiMgr())
       
   189                 {
       
   190                 TInt handled = KErrNone;
       
   191                 TRAP_IGNORE(handled = UiMgr()->HandleCommandL(aCmd, aData));
       
   192                 return handled;
       
   193                 }
       
   194             }
       
   195             break;
       
   196         case ECmdPenInputFingerMatchList:
       
   197             {
       
   198             if (UiMgr())
       
   199                 {
       
   200                 TInt handled = KErrNone;
       
   201                 TRAP_IGNORE(handled = UiMgr()->HandleCommandL(aCmd, aData));
       
   202                 return handled;
       
   203                 }
       
   204             }
       
   205             break;
       
   206         case ECmdPenInputNoFreeSpace:
       
   207         	{
       
   208             TRAP_IGNORE(ChineseUiManager()->HandleCommandL(ECmdPenInputNoFreeSpace, NULL));
       
   209         	}        	
       
   210         case ECmdPenInputFingerMatchIndicator:
       
   211         case ECmdPenInputSendEditMenuData:
       
   212         case ECmdPenInputEnableSettingBtn:
       
   213         case ECmdPenInputDimArrowKeys:
       
   214         case ECmdPenInputRotation:
       
   215             {
       
   216             TRAP_IGNORE(iWindowMgr->HandleCommandL(aCmd, aData));
       
   217             }
       
   218             break;
       
   219         case ECmdPenInputIsSecretText:
       
   220             {
       
   221             TRAP_IGNORE(iWindowMgr->HandleCommandL(aCmd, aData));
       
   222             *data ? iIsSecret = ETrue: iIsSecret = EFalse;             
       
   223              if (UiMgr())
       
   224                 {
       
   225                 TInt handled = KErrNone;
       
   226                 TRAP_IGNORE(handled = UiMgr()->HandleCommandL(aCmd, aData));
       
   227                 return handled;
       
   228                 }
       
   229             }
       
   230             break;
       
   231         case ECmdPenInputEnableIndicatorButton:
       
   232             {
       
   233             TRAP_IGNORE(iWindowMgr->HandleCommandL(aCmd, aData));
       
   234             } 
       
   235         break;
       
   236                     
       
   237         case ECmdPenInputSymbolOfHardKeyOne:
       
   238         case ECmdPenInputInEditWordQueryDlg:
       
   239             {
       
   240             TRAP_IGNORE(iWindowMgr->HandleCommandL(aCmd, aData));
       
   241             }
       
   242             break;
       
   243         case ECmdPenInputIsNumberGrouping:
       
   244             {
       
   245             TRAP_IGNORE(iWindowMgr->HandleCommandL(aCmd, aData));
       
   246             }
       
   247             break;
       
   248         case ECmdPenInputEditorNumericKeyMap:
       
   249         	{
       
   250         	iDataMgr->SetNumericKeymap( *data );
       
   251         	}
       
   252             break;
       
   253         case ECmdPenInputEditorCustomNumericKeyMap:
       
   254         	{
       
   255         	iDataMgr->SetNumericKeymapData( (TInt*) data );
       
   256         	}
       
   257         	break;
       
   258         case ECmdPenInputPermittedRange:
       
   259         	{
       
   260         	iDataMgr->SetNumericOnly( *data );
       
   261         	}
       
   262         	break;
       
   263         case ECmdPenInputCharacterPreview:
       
   264             {
       
   265 //            iWindowMgr->ShowBubble(*aData);    
       
   266             }
       
   267             break; 
       
   268             
       
   269         default:
       
   270             break;
       
   271         }
       
   272 
       
   273     return KErrNone;
       
   274     }
       
   275 
       
   276 // ---------------------------------------------------------------------------
       
   277 // CSplitItutUiLayout::PenInputType
       
   278 // (other items were commented in a header)
       
   279 // ---------------------------------------------------------------------------
       
   280 //
       
   281 TInt CSplitItutUiLayout::PenInputType()
       
   282     {
       
   283     return EPluginInputModeItut;
       
   284     }
       
   285 
       
   286 // ---------------------------------------------------------------------------
       
   287 // CSplitItutUiLayout::SizeChanged
       
   288 // (other items were commented in a header)
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 TInt CSplitItutUiLayout::SizeChanged(const TAny* /*pData*/)
       
   292     {
       
   293     iDataMgr->ReadLafInfo();
       
   294 
       
   295     // set layout rect
       
   296     SetRect(TItutDataConverter::AnyToRect(iDataMgr->RequestData(ELayoutRect)));
       
   297         
       
   298     iWindowMgr->SizeChanged();
       
   299 
       
   300     return KErrNone;    
       
   301     }
       
   302 
       
   303 // ---------------------------------------------------------------------------
       
   304 // CSplitItutUiLayout::SubmitText
       
   305 // (other items were commented in a header)
       
   306 // ---------------------------------------------------------------------------
       
   307 //
       
   308 void CSplitItutUiLayout::SubmitText(const TDesC& aEventData)
       
   309     {
       
   310     SignalOwner(ESignalKeyEvent, aEventData);
       
   311     }
       
   312 
       
   313 // ---------------------------------------------------------------------------
       
   314 // CSplitItutUiLayout::OnSkinChange
       
   315 // (other items were commented in a header)
       
   316 // ---------------------------------------------------------------------------
       
   317 //
       
   318 TInt CSplitItutUiLayout::OnSkinChange()
       
   319     {
       
   320     CFepUiLayout::OnSkinChange();
       
   321     
       
   322     TInt err = iWindowMgr->OnSkinChange();
       
   323 
       
   324     return err;
       
   325     }
       
   326 
       
   327 // ---------------------------------------------------------------------------
       
   328 // CSplitItutUiLayout::PressOnCtrls
       
   329 // (other items were commented in a header)
       
   330 // ---------------------------------------------------------------------------
       
   331 //
       
   332 TBool CSplitItutUiLayout::PressOnCtrls(TPoint aPt)
       
   333     {
       
   334     const RPointerArray<CFepUiBaseCtrl>& ctrllist = RootControl()->ControlList();
       
   335 
       
   336     for (TInt i = 0; i < ctrllist.Count(); i++)
       
   337         {
       
   338         if (!ctrllist[i]->Hiden() && ctrllist[i]->Rect().Contains(aPt))
       
   339             {
       
   340             return ETrue;
       
   341             }
       
   342         }
       
   343 
       
   344     return EFalse;    
       
   345     }
       
   346 
       
   347 // ---------------------------------------------------------------------------
       
   348 // CSplitItutUiLayout::UiMgr
       
   349 // (other items were commented in a header)
       
   350 // ---------------------------------------------------------------------------
       
   351 //
       
   352 CSplitItutUiMgrBase* CSplitItutUiLayout::UiMgr()
       
   353     {
       
   354     if (iDataMgr->IsChinese())
       
   355        {
       
   356        iCurrentUiMgr = ChineseUiManager();
       
   357        }
       
   358     else
       
   359        {
       
   360        iCurrentUiMgr = iWesternUiMgr;
       
   361        }
       
   362 
       
   363     return iCurrentUiMgr;        
       
   364     }
       
   365     
       
   366 // ---------------------------------------------------------------------------
       
   367 // CSplitItutUiLayout::SetInputModeL
       
   368 // (other items were commented in a header)
       
   369 // ---------------------------------------------------------------------------
       
   370 //
       
   371 void CSplitItutUiLayout::SetInputModeL(TInt aMode)
       
   372     {
       
   373     // fix EJML-7HM6GM, e.g. both EStrokeFind and EStroke will be stored as EStroke
       
   374     if (aMode != iDataMgr->InputMode() || 
       
   375         aMode == EStroke || aMode == EStrokeFind ||
       
   376         aMode == EZhuyin || aMode == EZhuyinFind ||
       
   377         ( iDataMgr->IsNumericOnly() && iDataMgr->IsCharFlagChanged() ) )
       
   378         {
       
   379         // deactivate original uimgr first
       
   380         iDataMgr->SetInputModeL(aMode);
       
   381 
       
   382         UiMgr()->ActivateUiL();
       
   383         }
       
   384     }
       
   385 
       
   386 // ---------------------------------------------------------------------------
       
   387 // CSplitItutUiLayout::SetInputLanguageL
       
   388 // (other items were commented in a header)
       
   389 // ---------------------------------------------------------------------------
       
   390 //
       
   391 void CSplitItutUiLayout::SetInputLanguageL(TInt aLanguage)
       
   392     {
       
   393     TInt previousLang = iDataMgr->InputLanguage();
       
   394     iDataMgr->SetLanguageL(aLanguage);
       
   395     
       
   396     if (previousLang != aLanguage)
       
   397         {
       
   398         ApplyVariantLafDataL();   
       
   399         }
       
   400     }
       
   401 
       
   402 // ---------------------------------------------------------------------------
       
   403 // CSplitItutUiLayout::OnDeActivate
       
   404 // (other items were commented in a header)
       
   405 // ---------------------------------------------------------------------------
       
   406 //
       
   407 void CSplitItutUiLayout::OnDeActivate()
       
   408     {
       
   409     TRAP_IGNORE(UiMgr()->HandleCommandL(ECmdPenInputDeActive, NULL));
       
   410 
       
   411     CFepUiLayout::OnDeActivate();
       
   412     }
       
   413     
       
   414 // ---------------------------------------------------------------------------
       
   415 // CSplitItutUiLayout::OnActivate
       
   416 // (other items were commented in a header)
       
   417 // ---------------------------------------------------------------------------
       
   418 //
       
   419 void CSplitItutUiLayout::OnActivate()
       
   420     {
       
   421     CFepUiLayout::OnActivate();
       
   422 
       
   423     SetRect(TItutDataConverter::AnyToRect(iDataMgr->RequestData(ELayoutRect)));
       
   424     TPoint offset = TItutDataConverter::AnyToPoint(iDataMgr->RequestData(ELayoutOffset));
       
   425     LayoutOwner()->SetPosition( offset );   
       
   426 
       
   427     iWindowMgr->OnActivate();
       
   428     }
       
   429 
       
   430 // ---------------------------------------------------------------------------
       
   431 // CSplitItutUiLayout::UiLayout
       
   432 // (other items were commented in a header)
       
   433 // ---------------------------------------------------------------------------
       
   434 //
       
   435 CFepUiLayout* CSplitItutUiLayout::UiLayout()
       
   436     {
       
   437     return this;
       
   438     }
       
   439 
       
   440 // ---------------------------------------------------------------------------
       
   441 // CSplitItutUiLayout::HandleAppInfoChange
       
   442 // (other items were commented in a header)
       
   443 // ---------------------------------------------------------------------------
       
   444 //
       
   445 void CSplitItutUiLayout::HandleAppInfoChange(const TDesC& aInfo, 
       
   446                                                TPeninputAppInfo aType)
       
   447     {
       
   448     if ( aType == EAppIndicatorMsg )
       
   449         {
       
   450         TRAP_IGNORE(iWindowMgr->HandleAppInfoChangeL(aInfo));
       
   451         }
       
   452     }
       
   453     
       
   454 // ---------------------------------------------------------------------------
       
   455 // CSplitItutUiLayout::ShowArrowBtn
       
   456 // (other items were commented in a header)
       
   457 // ---------------------------------------------------------------------------
       
   458 //
       
   459 void CSplitItutUiLayout::ShowArrowBtn(TInt aShowFlag)
       
   460     {
       
   461     iWindowMgr->ShowArrowBtn(aShowFlag);    
       
   462     }
       
   463     
       
   464 // ---------------------------------------------------------------------------
       
   465 // CSplitItutUiLayout::ApplyVariantLafDataL
       
   466 // (other items were commented in a header)
       
   467 // ---------------------------------------------------------------------------
       
   468 //
       
   469 void CSplitItutUiLayout::ApplyVariantLafDataL(TBool aResolutionChange)
       
   470     {
       
   471     iWindowMgr->ApplyVariantLafDataL(aResolutionChange);
       
   472     }
       
   473     
       
   474 // ---------------------------------------------------------------------------
       
   475 // CSplitItutUiLayout::UiManager
       
   476 // (other items were commented in a header)
       
   477 // ---------------------------------------------------------------------------
       
   478 //
       
   479 CSplitItutWindowManager* CSplitItutUiLayout::UiManager()
       
   480     {
       
   481     return iWindowMgr;   
       
   482     }
       
   483 
       
   484 // ---------------------------------------------------------------------------
       
   485 // CSplitItutUiLayout::Control
       
   486 // (other items were commented in a header)
       
   487 // ---------------------------------------------------------------------------
       
   488 //
       
   489 CFepUiBaseCtrl* CSplitItutUiLayout::Control(TInt aCtrlId)
       
   490     {
       
   491     return iWindowMgr->Control(aCtrlId); 
       
   492     }
       
   493 
       
   494 // ---------------------------------------------------------------------------
       
   495 // CSplitItutUiLayout::ChineseUiManager
       
   496 // (other items were commented in a header)
       
   497 // ---------------------------------------------------------------------------
       
   498 //
       
   499 CSplitItutUiMgrBase* CSplitItutUiLayout::ChineseUiManager()
       
   500     {
       
   501     if (!iChnUiMgr)
       
   502         {
       
   503         TRAP_IGNORE( iChnUiMgr = CChnSplitItutUiMgr::NewL(this, iDataMgr, iWindowMgr) );
       
   504         }
       
   505         
       
   506     return iChnUiMgr;
       
   507         
       
   508     }
       
   509     
       
   510 // End Of File