textinput/peninputsplititut/src/peninputsplititutwindowmanager.cpp
changeset 0 eb1f2e154e89
child 5 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:  drop-down list control
       
    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 #include <s32mem.h>
       
    32 #include <peninputlabel.h>
       
    33 #include <peninputlayoutinputmodechoice.h>
       
    34 //#include <peninputlayoutbubblectrl.h>
       
    35 #include <peninputcommonlayoutglobalenum.h>
       
    36 
       
    37 #include "peninputsplititutwindowmanager.h"
       
    38 #include "peninputsplititutwindow.h"
       
    39 #include "peninputsplititutdatamgr.h"
       
    40 #include "peninputsplititutuimgrbase.h"
       
    41 #include "peninputsplititutuistatebase.h"
       
    42 #include "peninputsplititutconverter.h"
       
    43 
       
    44 
       
    45 // ============================ MEMBER FUNCTIONS =============================
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // CSplitItutWindowManager::NewL
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CSplitItutWindowManager* CSplitItutWindowManager::NewL(CSplitItutUiLayout* aLayoutOwner,
       
    52                                                        CSplitItutDataMgr* aDataMgr)
       
    53     {
       
    54     CSplitItutWindowManager* layout = new (ELeave) 
       
    55                                                 CSplitItutWindowManager(aLayoutOwner,aDataMgr);
       
    56     CleanupStack::PushL(layout);
       
    57     layout->ConstructL();
       
    58     CleanupStack::Pop(layout);
       
    59     return layout;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CSplitItutWindowManager::CSplitItutWindowManager
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CSplitItutWindowManager::CSplitItutWindowManager(CSplitItutUiLayout* aLayoutOwner,
       
    67                                                      CSplitItutDataMgr* aDataMgr)
       
    68                                           :iLayoutOwner(aLayoutOwner),
       
    69                                            iDataMgr(aDataMgr),
       
    70                                            iLastRawKeyDown(EStdKeyNull)
       
    71                                            
       
    72     {
       
    73     iInEditWordQueryDlg = EFalse;
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CSplitItutWindowManager::CSplitItutWindowManager
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 CSplitItutWindowManager::~CSplitItutWindowManager()
       
    81     {
       
    82     delete iWindow;
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CSplitItutWindowManager::SetPropertyL
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 void CSplitItutWindowManager::SetPropertyL(MItutPropertySubscriber::TItutProperty aPropertyName, 
       
    90                                         const TDesC& aPropertyValue)
       
    91     {
       
    92     iWindow->SetPropertyL(aPropertyName, aPropertyValue);
       
    93     
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CSplitItutWindowManager::ConstructL
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CSplitItutWindowManager::ConstructL()
       
   101     {
       
   102     iWindow = CSplitItutWindow::NewL(this, iLayoutOwner,iDataMgr);
       
   103     }
       
   104 
       
   105 // ---------------------------------------------------------------------------
       
   106 // CSplitItutWindowManager::SimulateRawEvent
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void CSplitItutWindowManager::SimulateRawEvent(TInt aScanCode, TRawEvent::TType aType)
       
   110     {
       
   111     iLayoutOwner->SimulateRawEvent(aScanCode, aType);
       
   112     }
       
   113                 
       
   114 // ---------------------------------------------------------------------------
       
   115 // CSplitItutWindowManager::HandleCtrlEventL
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CSplitItutWindowManager::HandleCtrlEventL(TInt aEventType, 
       
   119                                                  CFepUiBaseCtrl* aCtrl, 
       
   120                                                  const TDesC& aEventData)
       
   121     {
       
   122     switch(aEventType)
       
   123         {
       
   124         case EEventRawKeyDownEvent:
       
   125             {
       
   126             const TKeyEvent *key = reinterpret_cast<const TKeyEvent*>(aEventData.Ptr());
       
   127             SimulateRawEvent(key->iScanCode,TRawEvent::EKeyDown);
       
   128             SetLastRawKeyDown(key->iScanCode, ETrue, aCtrl);
       
   129             }
       
   130             break;
       
   131         case EEventRawKeyUpEvent:
       
   132             {
       
   133             const TKeyEvent *key = reinterpret_cast<const TKeyEvent*>(aEventData.Ptr());
       
   134             SimulateRawEvent(key->iScanCode,TRawEvent::EKeyUp);
       
   135             SetLastRawKeyDown(key->iScanCode, EFalse, aCtrl);
       
   136             }
       
   137             break;       
       
   138         case EEventButtonUp:
       
   139             {
       
   140 /*            else if (aCtrl->ControlId() == ECtrlIdArrowUp)
       
   141                 {
       
   142                 TRAP_IGNORE(iWindow->Icf()->HandleArrowBtnEventL(
       
   143                                                           CFepLayoutMultiLineIcf::EArrowUp));
       
   144                 }
       
   145             else if (aCtrl->ControlId() == ECtrlIdArrowDown)
       
   146                 {
       
   147                 TRAP_IGNORE(iWindow->Icf()->HandleArrowBtnEventL(
       
   148                                                           CFepLayoutMultiLineIcf::EArrowDown));
       
   149                 }*/
       
   150             if (aCtrl->ControlId() == ECtrlIdClose)
       
   151                 {
       
   152                 iLayoutOwner->SignalOwner(ESignalLayoutClosed);
       
   153                 }
       
   154             else if (aCtrl->ControlId() == ECtrlIdOptions)
       
   155                 {
       
   156                 iLayoutOwner->SignalOwner(ESignalLaunchOptionsMenu);
       
   157                 }               
       
   158             }
       
   159             break;
       
   160             
       
   161  /*       case EItutCmdArrowUp:
       
   162             {
       
   163             if (aCtrl->ControlId() == ECtrlIdArrowUp)
       
   164                 {
       
   165                 TRAP_IGNORE(iWindow->Icf()->HandleArrowBtnEventL(
       
   166                                                           CFepLayoutMultiLineIcf::EArrowUp));
       
   167                 }
       
   168             }
       
   169             break;
       
   170         case EItutCmdArrowDown:
       
   171             {
       
   172             if (aCtrl->ControlId() == ECtrlIdArrowDown)
       
   173                 {
       
   174                 TRAP_IGNORE(iWindow->Icf()->HandleArrowBtnEventL(
       
   175                                                           CFepLayoutMultiLineIcf::EArrowDown));
       
   176                 }
       
   177             }
       
   178             break;*/
       
   179         case EEventCapturePointer:
       
   180             {
       
   181             if (iRawKeyDown)
       
   182                 {
       
   183                 SimulateRawEvent(iLastRawKeyDown, TRawEvent::EKeyUp);
       
   184                 iRawKeyCtrl->CancelPointerDownL();
       
   185                 SetLastRawKeyDown(iLastRawKeyDown, EFalse, NULL);
       
   186                 }
       
   187             }
       
   188             break;      
       
   189         default:
       
   190             break;
       
   191         };
       
   192     }
       
   193 
       
   194 // ---------------------------------------------------------------------------
       
   195 // CSplitItutWindowManager::HandleCtrlEventL
       
   196 // ---------------------------------------------------------------------------
       
   197 //
       
   198 TBool CSplitItutWindowManager::HandleCommandL(TInt aCmd, TUint8* aData)
       
   199     {
       
   200     TBool handle = EFalse;
       
   201     TInt* data = (TInt*) aData;
       
   202     switch (aCmd)
       
   203         {
       
   204         case ECmdPenInputDimArrowKeys:
       
   205             {
       
   206             TBool IsDimArrowKeys = *aData;
       
   207             DimArrowKeys( IsDimArrowKeys );
       
   208             }
       
   209             break;
       
   210         case ECmdPenInputEnableSettingBtn:
       
   211             {
       
   212             CAknFepCtrlCommonButton * optionsbtn;
       
   213             TBool enable = *data;            
       
   214             optionsbtn = static_cast<CAknFepCtrlCommonButton *>(iWindow->Control(ECtrlIdOptions));
       
   215             if(optionsbtn && !enable)
       
   216                 {
       
   217                 optionsbtn->SetDimmed(ETrue);
       
   218                 handle = ETrue;
       
   219                 iDimOperationBtn = ETrue;
       
   220                 }
       
   221             else if(optionsbtn && enable)
       
   222                 {
       
   223                 optionsbtn->SetDimmed(EFalse);
       
   224                 handle = ETrue;
       
   225                 iDimOperationBtn = EFalse;
       
   226                 }
       
   227             break;
       
   228             }
       
   229         case ECmdPenInputSymbolOfHardKeyOne:
       
   230             {
       
   231             iWindow->SetHardKeyOneSymbol(aData);
       
   232             handle = ETrue;
       
   233             }
       
   234             break;
       
   235 
       
   236         case ECmdPenInputInEditWordQueryDlg:
       
   237             {
       
   238             iInEditWordQueryDlg = *data;
       
   239             }
       
   240             break;
       
   241         default:
       
   242             break;
       
   243             
       
   244         };
       
   245     return handle;
       
   246     }
       
   247 
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // CSplitItutWindowManager::SizeChanged
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 TInt CSplitItutWindowManager::SizeChanged()
       
   254     {
       
   255     return iWindow->SizeChanged();
       
   256     }
       
   257 
       
   258 // ---------------------------------------------------------------------------
       
   259 // CSplitItutWindowManager::SubmitText
       
   260 // ---------------------------------------------------------------------------
       
   261 //
       
   262 void CSplitItutWindowManager::SubmitText(const TDesC& aEventData)
       
   263     {
       
   264     iLayoutOwner->SignalOwner(ESignalKeyEvent, aEventData);
       
   265     }
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // CSplitItutWindowManager::OnSkinChange
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 TInt CSplitItutWindowManager::OnSkinChange()
       
   272     {
       
   273     TRAPD(err,
       
   274           iWindow->ConstructSpellCtrlFromResourceL(); 
       
   275           iWindow->ConstructItutKeypadFromResourceL(iWindow->ItutKeypad()->ResourceId()));
       
   276    
       
   277     iWindow->OnSkinChange();
       
   278     return err;
       
   279     }
       
   280 
       
   281 // ---------------------------------------------------------------------------
       
   282 // CSplitItutWindowManager::OnSkinChange
       
   283 // ---------------------------------------------------------------------------
       
   284 //
       
   285 void CSplitItutWindowManager::ShowArrowBtn(TInt aShowFlag)
       
   286     {
       
   287     iWindow->Control(ECtrlIdArrowLeft)->Hide(!(EBtnArrowLeft & aShowFlag));
       
   288     iWindow->Control(ECtrlIdArrowRight)->Hide(!(EBtnArrowRight & aShowFlag));
       
   289 //    iWindow->Control(ECtrlIdArrowUp)->Hide(!(EBtnArrowUp & aShowFlag));
       
   290 //    iWindow->Control(ECtrlIdArrowDown)->Hide(!(EBtnArrowDown & aShowFlag));
       
   291     }
       
   292     
       
   293 // ---------------------------------------------------------------------------
       
   294 // CSplitItutWindowManager::UiLayout
       
   295 // ---------------------------------------------------------------------------
       
   296 //
       
   297 CFepUiLayout* CSplitItutWindowManager::UiLayout()
       
   298     {
       
   299     return iLayoutOwner;
       
   300     }
       
   301     
       
   302 // ---------------------------------------------------------------------------
       
   303 // CSplitItutWindowManager::HandleAppInfoChangeL
       
   304 // ---------------------------------------------------------------------------
       
   305 //
       
   306 void CSplitItutWindowManager::HandleAppInfoChangeL(const TDesC& /*aInfo*/)
       
   307     {
       
   308     }
       
   309 
       
   310 // ---------------------------------------------------------------------------
       
   311 // CSplitItutWindowManager::ApplyVariantLafDataL
       
   312 // ---------------------------------------------------------------------------
       
   313 //
       
   314 void CSplitItutWindowManager::ApplyVariantLafDataL(TBool aResolutionChange)
       
   315     {
       
   316     iWindow->ApplyVariantLafDataL(aResolutionChange);
       
   317     }
       
   318 
       
   319 // ---------------------------------------------------------------------------
       
   320 // CSplitItutWindowManager::CreateChineseSpecificCtrlsIfNeededL
       
   321 // ---------------------------------------------------------------------------
       
   322 //
       
   323 void CSplitItutWindowManager::CreateChineseSpecificCtrlsIfNeededL()
       
   324     {
       
   325     iWindow->CreateChineseSpecificCtrlsIfNeededL();   
       
   326     }
       
   327     
       
   328     
       
   329 // ---------------------------------------------------------------------------
       
   330 // CSplitItutWindowManager::SetLastRawKeyDown
       
   331 // ---------------------------------------------------------------------------
       
   332 //
       
   333 void CSplitItutWindowManager::SetLastRawKeyDown(TInt aScanCode,  TBool aKeyDown, 
       
   334                                                   CFepUiBaseCtrl* aCtrl)
       
   335     {
       
   336     !aKeyDown ? iLastRawKeyDown = EStdKeyNull : iLastRawKeyDown = aScanCode;
       
   337     iRawKeyDown = aKeyDown;
       
   338     iRawKeyCtrl = aCtrl;
       
   339     } 
       
   340         
       
   341 // ---------------------------------------------------------------------------
       
   342 // CSplitItutWindowManager::Control
       
   343 // ---------------------------------------------------------------------------
       
   344 //
       
   345 CFepUiBaseCtrl* CSplitItutWindowManager::Control(TInt aCtrlId)  
       
   346     {
       
   347     return iWindow->Control(aCtrlId);   
       
   348     }
       
   349 
       
   350 // ---------------------------------------------------------------------------
       
   351 // CSplitItutWindowManager::OnActivate
       
   352 // ---------------------------------------------------------------------------
       
   353 //
       
   354 void CSplitItutWindowManager::OnActivate()
       
   355     {
       
   356     if (iDimOperationBtn)
       
   357         {
       
   358         static_cast<CAknFepCtrlCommonButton*>(Control(ECtrlIdOptions))->SetDimmed(ETrue);    
       
   359         }
       
   360     else
       
   361         {
       
   362         static_cast<CAknFepCtrlCommonButton*>(Control(ECtrlIdOptions))->SetDimmed(EFalse);      
       
   363         }
       
   364     }
       
   365     
       
   366 // ---------------------------------------------------------------------------
       
   367 // CSplitItutWindowManager::DimArrowKeys
       
   368 // ---------------------------------------------------------------------------
       
   369 //
       
   370 void CSplitItutWindowManager::DimArrowKeys( TBool aDimArrow )
       
   371     {
       
   372     if (iDataMgr->IsChinese())
       
   373         {
       
   374         CAknFepCtrlRawKeyButton * leftbtn;
       
   375         CAknFepCtrlRawKeyButton * rightbtn;
       
   376 //        CAknFepCtrlRawKeyButton * upbtn;
       
   377 //        CAknFepCtrlRawKeyButton * downbtn;
       
   378         leftbtn = static_cast<CAknFepCtrlRawKeyButton *>(iWindow->Control(ECtrlIdArrowLeft));
       
   379         rightbtn = static_cast<CAknFepCtrlRawKeyButton *>(iWindow->Control(ECtrlIdArrowRight));
       
   380 //        upbtn = static_cast<CAknFepCtrlRawKeyButton *>(iWindow->Control(ECtrlIdArrowUp));
       
   381 //        downbtn = static_cast<CAknFepCtrlRawKeyButton *>(iWindow->Control(ECtrlIdArrowDown));
       
   382 
       
   383         leftbtn->SetDimmed(aDimArrow);   
       
   384         rightbtn->SetDimmed(aDimArrow);   
       
   385 //        upbtn->SetDimmed(aDimArrow);   
       
   386 //        downbtn->SetDimmed(aDimArrow);   
       
   387 
       
   388         }
       
   389     else
       
   390         {
       
   391         CAknFepCtrlRawKeyButton * leftbtn;
       
   392         CAknFepCtrlRawKeyButton * rightbtn;
       
   393         leftbtn = static_cast<CAknFepCtrlRawKeyButton *>(iWindow->Control(ECtrlIdArrowLeft));
       
   394         rightbtn = static_cast<CAknFepCtrlRawKeyButton *>(iWindow->Control(ECtrlIdArrowRight));
       
   395 
       
   396         leftbtn->SetDimmed(aDimArrow);   
       
   397         rightbtn->SetDimmed(aDimArrow);   
       
   398         }                
       
   399     }
       
   400     
       
   401 // ---------------------------------------------------------------------------
       
   402 // CSplitItutWindowManager::ShowBubble
       
   403 // ---------------------------------------------------------------------------
       
   404 //
       
   405 void CSplitItutWindowManager::ShowBubble(TInt /*aShow*/)
       
   406     {
       
   407     /*
       
   408     CFepCtrlDropdownList* spell = 
       
   409         static_cast<CFepCtrlDropdownList*>(iWindow->Control(ECtrlIdSpellCandsList));
       
   410     CFepCtrlDropdownList* standard = 
       
   411         static_cast<CFepCtrlDropdownList*>(iWindow->Control(ECtrlIdStdCandsList));
       
   412     CFepCtrlDropdownList* punctuation = 
       
   413         static_cast<CFepCtrlDropdownList*>(iWindow->Control(ECtrlIdPuncCandsList));
       
   414     
       
   415     if (aShow > 0)
       
   416         {
       
   417     	TRect outrect,innerrect;
       
   418     	outrect = TItutDataConverter::AnyToRect(iDataMgr->RequestData(EPreviewBubbleRect));  
       
   419     	innerrect = TItutDataConverter::AnyToRect(iDataMgr->RequestData(EPreviewBubbleInnerRect));
       
   420         TAknTextLineLayout bubbleTextLayout = 
       
   421             TItutDataConverter::AnyToTextLine(iDataMgr->RequestData(EPreviewBubbleTextlayout));
       
   422         CFont* bubbleFont = TItutDataConverter::AnyToFont(iDataMgr->RequestData(EPreviewBubbleFont));
       
   423         
       
   424         spell->ShowBubble(ETrue);
       
   425         standard->ShowBubble(ETrue);
       
   426         punctuation->ShowBubble(ETrue);
       
   427 
       
   428         spell->SetBubbleBitmapParam(NULL,NULL,KAknsIIDQsnFrInputCharPreview); 	
       
   429      	
       
   430     	spell->SetTextFormat(bubbleTextLayout);
       
   431     	spell->SetBubbleTextFont(bubbleFont);
       
   432     	spell->SetBubbleSize(TSize(outrect.Width(),outrect.Height()));  // Read laf
       
   433     	spell->SetFrameDiff(innerrect.iTl.iX - outrect.iTl.iX,
       
   434     	               innerrect.iTl.iY - outrect.iTl.iY,
       
   435     	               outrect.iBr.iX - innerrect.iBr.iX,
       
   436     	               outrect.iBr.iY - innerrect.iBr.iY);
       
   437         
       
   438         standard->SetBubbleBitmapParam(NULL,NULL,KAknsIIDQsnFrInputCharPreview); 	
       
   439      	
       
   440     	standard->SetTextFormat(bubbleTextLayout);
       
   441     	standard->SetBubbleTextFont(bubbleFont);
       
   442     	standard->SetBubbleSize(TSize(outrect.Width(),outrect.Height()));  // Read laf
       
   443     	standard->SetFrameDiff(innerrect.iTl.iX - outrect.iTl.iX,
       
   444     	               innerrect.iTl.iY - outrect.iTl.iY,
       
   445     	               outrect.iBr.iX - innerrect.iBr.iX,
       
   446     	               outrect.iBr.iY - innerrect.iBr.iY);
       
   447     
       
   448         punctuation->SetBubbleBitmapParam(NULL,NULL,KAknsIIDQsnFrInputCharPreview); 	
       
   449      	
       
   450     	punctuation->SetTextFormat(bubbleTextLayout);
       
   451     	punctuation->SetBubbleTextFont(bubbleFont);
       
   452     	punctuation->SetBubbleSize(TSize(outrect.Width(),outrect.Height()));  // Read laf
       
   453     	punctuation->SetFrameDiff(innerrect.iTl.iX - outrect.iTl.iX,
       
   454     	               innerrect.iTl.iY - outrect.iTl.iY,
       
   455     	               outrect.iBr.iX - innerrect.iBr.iX,
       
   456     	               outrect.iBr.iY - innerrect.iBr.iY);
       
   457         }
       
   458     else
       
   459         {
       
   460         spell->ShowBubble(EFalse);
       
   461         standard->ShowBubble(EFalse);
       
   462         punctuation->ShowBubble(EFalse);
       
   463         }
       
   464     */
       
   465     }
       
   466          
       
   467 // End Of File