textinput/peninputvkbjp/src/peninputvkbwindow.cpp
branchRCL_3
changeset 44 ecbabf52600f
equal deleted inserted replaced
43:ebd48d2de13c 44:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2002-2007 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:  vkb main window area implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // system includes
       
    20 #include <peninputvkbwindowjp.rsg>
       
    21 #include <peninputvkbwindowconfiginfo_32.rsg>
       
    22 
       
    23 #include <peninputcontextfieldjp.h>
       
    24 #include <peninputcommonlayout.h>
       
    25 #include <peninputrepeatbutton.h>
       
    26 #include <peninputrangebar.h>
       
    27 #include <peninputdataconverter.h>
       
    28 #include <peninputclientlayoutinfo.h>
       
    29 #include <AknIconUtils.h>
       
    30 #include <aknlayoutscalable_avkon.cdl.h>
       
    31 #include <peninputjapanesepredictivewnd.h>
       
    32 #include <aknfeppeninputenums.h>    //command from fep or IME to plugin. for vkb/hwr
       
    33 #include <peninputcommonlayoutglobalenum.h>  // EPeninputLayoutEventEnter
       
    34 #include <peninputeventjp.h>
       
    35 
       
    36 // user includes
       
    37 #include "peninputvkb.hrh"      // EPeninputLayoutVkbEventResetShift
       
    38 #include "peninputvkbwindow.h"
       
    39 #include "peninputvkbctrlextjp.h"
       
    40 
       
    41 // Constants
       
    42 _LIT( KVkbWindowResourceFile,
       
    43       "z:\\resource\\plugins\\peninputvkbwindowjp.RSC" );
       
    44 _LIT( KConfigurationResourceFile,
       
    45       "z:\\resource\\plugins\\peninputvkbwindowconfiginfo_32.RSC" );
       
    46 
       
    47 // ======== MEMBER FUNCTIONS ========
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CPeninputVkbWindow::NewL
       
    51 // (other items were commented in a header).
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CPeninputVkbWindow* CPeninputVkbWindow::NewL(CFepUiLayout* aUiLayout,
       
    55                                          MPeninputLayoutContext* aLayoutContext)
       
    56     {
       
    57     CPeninputVkbWindow* self = CPeninputVkbWindow::NewLC(aUiLayout, aLayoutContext);
       
    58     CleanupStack::Pop(self);
       
    59     return self;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CPeninputVkbWindow::NewLC
       
    64 // (other items were commented in a header).
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 CPeninputVkbWindow* CPeninputVkbWindow::NewLC(CFepUiLayout* aUiLayout,
       
    68                                          MPeninputLayoutContext* aLayoutContext)
       
    69     {
       
    70     CPeninputVkbWindow* self = new (ELeave) CPeninputVkbWindow(aUiLayout, aLayoutContext);
       
    71     CleanupStack::PushL(self);
       
    72     self->ConstructL();
       
    73     return self;
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // CPeninputVkbWindow::~CPeninputVkbWindow
       
    78 // (other items were commented in a header).
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 CPeninputVkbWindow::~CPeninputVkbWindow()
       
    82     {
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // CPeninputVkbWindow::HandleControlEvent
       
    87 // (other items were commented in a header).
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 void CPeninputVkbWindow::HandleControlEvent(TInt aEventType,
       
    91                                           CFepUiBaseCtrl* aCtrl,
       
    92                                           const TDesC& aEventData)
       
    93     {
       
    94 
       
    95     TInt* data = (TInt*) aEventData.Ptr();
       
    96     switch (aEventType)
       
    97         {
       
    98         case EPeninputLayoutVkbEventResetShift:
       
    99             {
       
   100             HandleShiftBtnClicked();
       
   101             }
       
   102             break;
       
   103         case EPeninputLayoutEventSetPermittedRange:  // from datamgr
       
   104             {  // [Ref]CPeninputLayoutWindow::HandleControlEvent
       
   105             // Set range of range bar component
       
   106             CFepUiBaseCtrl* bar =
       
   107                 iCtrlPool->Control( EPeninutWindowCtrlIdRangeBar );
       
   108             if ( bar )
       
   109                 {
       
   110                 CAknFepCtrlRangeBar* rangebar =
       
   111                     static_cast<CAknFepCtrlRangeBar*>( bar );
       
   112                 rangebar->SetPermittedRanges( *data );
       
   113                 }
       
   114             }
       
   115             break;
       
   116         default:
       
   117             //Call this function in base class
       
   118             CPeninputLayoutWindowJp::HandleControlEvent(aEventType,aCtrl,aEventData);
       
   119             break;
       
   120         }
       
   121     }
       
   122 
       
   123 // --------------------------------------------------------------------------
       
   124 // CPeninputVkbWindow::GetWindowConfigResId
       
   125 // (other items were commented in a header)
       
   126 // --------------------------------------------------------------------------
       
   127 //
       
   128 TInt CPeninputVkbWindow::GetWindowConfigResId()
       
   129     {
       
   130     return R_PENINPUT_LAYOUT_CONFIG_INFO;
       
   131     }
       
   132 
       
   133 // --------------------------------------------------------------------------
       
   134 // CPeninputVkbWindow::GetWindowResId
       
   135 // (other items were commented in a header)
       
   136 // --------------------------------------------------------------------------
       
   137 //
       
   138 TInt CPeninputVkbWindow::GetWindowResId()
       
   139     {
       
   140     return R_PENINPUT_LAYOUT_VKB_WINDOW;
       
   141     }
       
   142 
       
   143 // --------------------------------------------------------------------------
       
   144 // CPeninputVkbWindow::GetWindowConfigResFileName
       
   145 // (other items were commented in a header)
       
   146 // --------------------------------------------------------------------------
       
   147 //
       
   148 const TDesC& CPeninputVkbWindow::GetWindowConfigResFileName(
       
   149     TInt /* aLangID */ )    // LangId : 32 fixed
       
   150     {
       
   151     return KConfigurationResourceFile();
       
   152     }
       
   153 
       
   154 // --------------------------------------------------------------------------
       
   155 // CPeninputVkbWindow::GetWindowResFileName
       
   156 // (other items were commented in a header)
       
   157 // --------------------------------------------------------------------------
       
   158 //
       
   159 const TDesC& CPeninputVkbWindow::GetWindowResFileName()
       
   160     {
       
   161     return KVkbWindowResourceFile();
       
   162     }
       
   163 
       
   164 // --------------------------------------------------------------------------
       
   165 // CPeninputVkbWindow::ChangeUnitSize
       
   166 // (other items were commented in a header)
       
   167 // --------------------------------------------------------------------------
       
   168 //
       
   169 const TRect CPeninputVkbWindow::ChangeUnitSize()
       
   170     {
       
   171     TAknWindowLineLayout appWnd;
       
   172     TAknWindowLineLayout mainPane;
       
   173     TAknWindowLineLayout wndLayout;
       
   174     TAknWindowLineLayout unitGrid;
       
   175     TAknLayoutRect mainPaneRect;
       
   176     TAknLayoutRect wndRect;
       
   177     TAknLayoutRect unitRect;
       
   178 
       
   179     appWnd = AknLayoutScalable_Avkon::application_window( 0 ).LayoutLine();
       
   180 
       
   181     if (appWnd.iW > appWnd.iH)
       
   182         {
       
   183         // landscape
       
   184         mainPane = AknLayoutScalable_Avkon::main_pane(4).LayoutLine();
       
   185         }
       
   186     else
       
   187         {
       
   188         // portrait
       
   189         mainPane = AknLayoutScalable_Avkon::main_pane(1).LayoutLine();
       
   190         }
       
   191 
       
   192     mainPaneRect.LayoutRect( appWnd.Rect(), mainPane );
       
   193 
       
   194     TInt clientLayoutId = CPeninputDataConverter::AnyToInt
       
   195         ( iLayoutContext->RequestData( EPeninputDataTypeClientLayout ) );
       
   196     if (EPeninputClientLayoutLatin == clientLayoutId)
       
   197         {
       
   198         wndLayout = AknLayoutScalable_Avkon::popup_fep_vkb_window(0).LayoutLine();
       
   199         unitGrid = AknLayoutScalable_Avkon::aid_size_cell_vkb(0).LayoutLine();
       
   200         }
       
   201     else if (!iPredictiveWnd->Hiden())
       
   202         {
       
   203         wndLayout = AknLayoutScalable_Avkon::popup_fep_vkb_window(5).LayoutLine();
       
   204         unitGrid = AknLayoutScalable_Avkon::aid_size_cell_vkb(7).LayoutLine();
       
   205         }
       
   206     else
       
   207         {
       
   208         wndLayout = AknLayoutScalable_Avkon::popup_fep_vkb_window(4).LayoutLine();
       
   209         unitGrid = AknLayoutScalable_Avkon::aid_size_cell_vkb(6).LayoutLine();
       
   210         }
       
   211     wndRect.LayoutRect(mainPaneRect.Rect(), wndLayout);
       
   212 
       
   213     unitRect.LayoutRect(wndRect.Rect(), unitGrid);
       
   214 
       
   215     TRect vkbWndRect = TRect(0,
       
   216                              0,
       
   217                              wndRect.Rect().Width(),
       
   218                              wndRect.Rect().Height());
       
   219 
       
   220     TInt unitWidth = unitRect.Rect().Width();
       
   221     TInt unitHeight = unitRect.Rect().Height();
       
   222 
       
   223     iLayoutContext->SetData( EPeninputDataTypeUnitWidth, &unitWidth );
       
   224     iLayoutContext->SetData( EPeninputDataTypeUnitHeight, &unitHeight );
       
   225 
       
   226     return vkbWndRect;
       
   227     }
       
   228 
       
   229 // --------------------------------------------------------------------------
       
   230 // CPeninputVkbWindow::ChangeUnitSize
       
   231 // (other items were commented in a header)
       
   232 // --------------------------------------------------------------------------
       
   233 void CPeninputVkbWindow::ChangeClientSize()
       
   234     {
       
   235     TAknTextLineLayout keypadText;
       
   236 
       
   237     TInt unitWidth = CPeninputDataConverter::AnyToInt
       
   238         ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
       
   239     TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   240         ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
       
   241 
       
   242     keypadText =
       
   243         AknLayoutScalable_Avkon::cell_vkb_keypad_pane_t1().LayoutLine();
       
   244 
       
   245     // 1.Read data from scalable
       
   246     TInt unitCharWidth = unitWidth - 2 * keypadText.il;
       
   247     TInt unitCharHeight = unitHeight - 2 * keypadText.il;
       
   248     TPoint charLeftTop = TPoint( keypadText.il, keypadText.il );
       
   249 
       
   250     // Modify keypad font
       
   251     const CFont* font = NULL;
       
   252     font = AknLayoutUtils::FontFromId( keypadText.iFont, NULL);
       
   253     iVkbCtrl->SetFont( const_cast<CFont*> (font) );
       
   254 
       
   255     TInt clientLayoutId = CPeninputDataConverter::AnyToInt
       
   256         ( iLayoutContext->RequestData( EPeninputDataTypeClientLayout ) );
       
   257     CPeninputClientLayoutInfo* clientLayout =
       
   258         ConfigInfo()->FindClientLayoutInfo( clientLayoutId );
       
   259 
       
   260     if ( clientLayout )
       
   261         {
       
   262         // 2.Change self rect
       
   263         TInt width = clientLayout->Columns() * unitWidth;
       
   264         TInt height = clientLayout->Rows() * unitHeight;
       
   265         TRect rect = TRect( ClientPane()->Rect().iTl,
       
   266                             TSize( width, height ) );
       
   267 
       
   268         ClientPane()->SetRect( rect );
       
   269         // 3.Change the postion and size of controls in current layout
       
   270         ReorganizeControls( clientLayout->LayoutID(), EFalse );
       
   271         }
       
   272 
       
   273     // 4.Recalculate all keys in all vkblayouts
       
   274     RPointerArray<CPeninputVkbLayoutInfo>& vkbList =
       
   275         ConfigInfo()->VkbLayoutInfoList();
       
   276     const TInt count = vkbList.Count();
       
   277 
       
   278     for ( TInt i = 0; i < count; i++ )
       
   279         {
       
   280         vkbList[i]->ResetSize( unitWidth, unitHeight, unitCharWidth,
       
   281             unitCharHeight, charLeftTop, font );
       
   282         }
       
   283 
       
   284     TInt vkbLayoutid = CPeninputDataConverter::AnyToInt
       
   285         ( iLayoutContext->RequestData( EPeninputDataTypeVkbLayout ) );
       
   286     CPeninputVkbLayoutInfo* vkbLayout =
       
   287         ConfigInfo()->FindVkbLayoutInfo( vkbLayoutid );
       
   288 
       
   289     // Calculate current vkblayout according current layout
       
   290     if ( vkbLayout )
       
   291         {
       
   292         TRect rect = iVkbCtrl->Rect();
       
   293 
       
   294         rect.SetSize( vkbLayout->GetRealSize( unitWidth, unitHeight ) );
       
   295         iVkbCtrl->SetRect( rect );
       
   296         // Make the true draw
       
   297         UpdateArea( iVkbCtrl->Rect(), EFalse );
       
   298         }
       
   299     }
       
   300 
       
   301 // --------------------------------------------------------------------------
       
   302 // CPeninputVkbWindow::CreateAllControls
       
   303 // (other items were commented in a header)
       
   304 // --------------------------------------------------------------------------
       
   305 //
       
   306 void CPeninputVkbWindow::CreateAllControlsL()
       
   307     {
       
   308     CPeninputLayoutWindowJp::CreateAllControlsL();
       
   309 
       
   310     if (iInputContextField)
       
   311         {
       
   312         HeaderPane()->RemoveControl(static_cast<CFepUiBaseCtrl*>(iInputContextField));
       
   313         iInputContextField = NULL;
       
   314         }
       
   315     AddContextFieldJpL();
       
   316 
       
   317     // Range bar
       
   318     AddRangeBarL();
       
   319 
       
   320     // Vkb control
       
   321     TAknTextLineLayout keypadText;
       
   322 
       
   323     keypadText =
       
   324         AknLayoutScalable_Avkon::cell_vkb_keypad_pane_t1().LayoutLine();
       
   325     iVkbCtrl = CPeninputVkbCtrlExtJp::NewL( TRect(), UiLayout(),
       
   326         EPeninutWindowCtrlIdVkbCtrl,
       
   327         AknLayoutUtils::FontFromId( keypadText.iFont, NULL ) );
       
   328 
       
   329     iVkbLayout->SetVkbKeyboard( iVkbCtrl );
       
   330     iCtrlPool->AddControl( iVkbCtrl );
       
   331 
       
   332     // Backspace button  3 Unit
       
   333     AddButtonL( EPeninutWindowCtrlIdClear1Btn,
       
   334                 EPeninputLayoutEventBack,
       
   335                 R_PENINPUT_LAYOUT_VKB_CLEAR_1,
       
   336                 EKeyBackspace,
       
   337                 ETrue );
       
   338 
       
   339     // Backspace button  1 Unit
       
   340     AddButtonL( EPeninutWindowCtrlIdClear2Btn,
       
   341                 EPeninputLayoutEventBack,
       
   342                 R_PENINPUT_LAYOUT_VKB_CLEAR_2,
       
   343                 EKeyBackspace,
       
   344                 ETrue );
       
   345 
       
   346     // Enter button
       
   347     AddButtonL( EPeninutWindowCtrlIdEnterBtn,
       
   348                 EPeninputLayoutEventEnter,
       
   349                 R_PENINPUT_LAYOUT_VKB_ENTER,
       
   350                 EKeyEnter );
       
   351 
       
   352     // Tab button
       
   353     AddButtonL( EPeninutWindowCtrlIdTabBtn,
       
   354                 EPeninputLayoutEventTab,
       
   355                 R_PENINPUT_LAYOUT_VKB_TAB,
       
   356                 EKeyTab );
       
   357 
       
   358     // Capslock button
       
   359     AddButtonL( EPeninutWindowCtrlIdCapslockBtn,
       
   360                 EPeninputLayoutEventCapslock,
       
   361                 R_PENINPUT_LAYOUT_VKB_CAPSLOCK );
       
   362 
       
   363     // Shift button
       
   364     AddButtonL( EPeninutWindowCtrlIdShiftBtn,
       
   365                 EPeninputLayoutEventShift,
       
   366                 R_PENINPUT_LAYOUT_VKB_SHIFT );
       
   367 
       
   368     // Space button
       
   369     AddButtonL( EPeninutWindowCtrlIdSpaceBtn,
       
   370                 EPeninputLayoutEventSpace,
       
   371                 R_PENINPUT_LAYOUT_VKB_SPACE,
       
   372                 EKeySpace );
       
   373 
       
   374     // SCT button
       
   375     AddButtonL( EPeninutWindowCtrlIdSymbolBtn,
       
   376                 EPeninputLayoutEventSct,
       
   377                 R_PENINPUT_LAYOUT_VKB_SCT );
       
   378 
       
   379     // Switch to hwr button
       
   380     AddButtonL( EPeninutWindowCtrlIdSwitchToHwrBtn,
       
   381                 EPeninputLayoutEventToHwr,
       
   382                 R_PENINPUT_LAYOUT_VKB_HWR );
       
   383     
       
   384     if( iCtrlPool != NULL )
       
   385         {
       
   386         for ( TInt i = 0; i < iCtrlPool->ControlCount(); i++ )
       
   387             {
       
   388             iCtrlPool->ControlByIndex( i )->AddEventObserver( UiLayout() );
       
   389             }
       
   390         }
       
   391     }
       
   392 
       
   393 // --------------------------------------------------------------------------
       
   394 // CPeninputVkbWindow::PopupChoiceList
       
   395 // (other items were commented in a header)
       
   396 // --------------------------------------------------------------------------
       
   397 //
       
   398 void CPeninputVkbWindow::PopupChoiceList()
       
   399     {   // nop
       
   400     }
       
   401 
       
   402 // --------------------------------------------------------------------------
       
   403 // CPeninputVkbWindow::ReorganizeControls
       
   404 // (other items were commented in a header)
       
   405 // --------------------------------------------------------------------------
       
   406 //
       
   407 void CPeninputVkbWindow::ReorganizeControls( TInt aClientLayoutId, TBool aNeedReset )
       
   408     {
       
   409     TInt unitWidth = CPeninputDataConverter::AnyToInt
       
   410         ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
       
   411     TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   412         ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
       
   413 
       
   414     // First remove all controls in the client pane, but don't delete them
       
   415     CFepUiBaseCtrl* activCtrl = ClientPane()->ActiveControl();
       
   416     if (activCtrl)
       
   417         {    // we shuld remove active controls, because CControlGroup::Draw()  draw active controls.[for japanese]
       
   418         ClientPane()->RemoveControl(activCtrl);
       
   419         }
       
   420     ( const_cast<RPointerArray<CFepUiBaseCtrl>&>
       
   421         ( ClientPane()->ControlList() ) ).Reset();
       
   422     iVkbCtrl->SetRect( TRect( ClientPane()->Rect().iTl, TSize( 0, 0 ) ) );
       
   423 
       
   424     if (aNeedReset)
       
   425         {
       
   426         iVkbCtrl->Reset();
       
   427         }
       
   428 
       
   429     // Then add controls according to the configuration of clientlayout
       
   430     CPeninputClientLayoutInfo* clientLayout =
       
   431         ConfigInfo()->FindClientLayoutInfo( aClientLayoutId );
       
   432     RPointerArray<CPeninputControlInfo>& controlList =
       
   433         clientLayout->ControlInfoList();
       
   434 
       
   435     const TInt count = controlList.Count();
       
   436     TInt controlID = 0;
       
   437     TInt cols = 0;
       
   438     TInt rows = 0;
       
   439     CFepUiBaseCtrl* ctrl = NULL;
       
   440     TRect rect = ClientPane()->Rect();
       
   441 
       
   442     // Set rect for client area
       
   443     rect.SetSize( TSize( clientLayout->Columns() * unitWidth,
       
   444                          clientLayout->Rows() * unitHeight ) );
       
   445     ClientPane()->SetRect( rect );
       
   446 
       
   447     // Set owner rect
       
   448     SetWholeWindowRect( ClientPane()->Rect() );
       
   449 
       
   450     TPoint point = rect.iTl;
       
   451 
       
   452     for ( TInt i = 0; i < count; i++ )
       
   453         {
       
   454         controlID = controlList[i]->ControlID();
       
   455         ctrl = iCtrlPool->Control( controlID );
       
   456 
       
   457         if ( ctrl )
       
   458             {
       
   459             rect.iTl = point + TPoint
       
   460                 ( controlList[i]->BeginColumn() * unitWidth,
       
   461                   controlList[i]->BeginRow() * unitHeight
       
   462                 );
       
   463             cols = controlList[i]->EndColumn()
       
   464                 - controlList[i]->BeginColumn();
       
   465             rows = controlList[i]->EndRow() - controlList[i]->BeginRow();
       
   466             rect.SetSize( TSize( cols * unitWidth, rows * unitHeight ) );
       
   467 
       
   468             if ( ( ctrl->ControlType() | ECtrlButton ) == ECtrlButton )
       
   469                 {
       
   470                 ( static_cast<CAknFepCtrlButton*> (ctrl) )->SizeChanged
       
   471                     ( rect, ETrue );
       
   472                 }
       
   473             else if ( ctrl->ControlId() == EPeninutWindowCtrlIdVkbCtrl )
       
   474                 {
       
   475                 ( static_cast<CPeninputVkbCtrlExt*> (ctrl) )->SizeChanged
       
   476                     ( unitWidth, unitHeight, rect.iTl );
       
   477                 }
       
   478             else if ( ctrl->ControlId() == EPeninutWindowCtrlIdRangeBar )
       
   479                 {
       
   480                 rect = TRect( rect.iTl, TSize( unitWidth, unitHeight ) );
       
   481                 ( static_cast<CAknFepCtrlRangeBar*> (ctrl) )->SizeChanged
       
   482                     ( rect );
       
   483                 }
       
   484             AddNotOwnedControl( ctrl );
       
   485             }
       
   486         }
       
   487     }
       
   488 
       
   489 // --------------------------------------------------------------------------
       
   490 // CPeninputVkbWindow::GetScrollUpBtnResId
       
   491 // (other items were commented in a header)
       
   492 // --------------------------------------------------------------------------
       
   493 //
       
   494 TInt CPeninputVkbWindow::GetScrollUpBtnResId()
       
   495     {
       
   496     return R_PENINPUT_LAYOUT_VKB_SCROLL_UP;
       
   497     }
       
   498 
       
   499 // --------------------------------------------------------------------------
       
   500 // CPeninputVkbWindow::GetScrollDownBtnResId
       
   501 // (other items were commented in a header)
       
   502 // --------------------------------------------------------------------------
       
   503 //
       
   504 TInt CPeninputVkbWindow::GetScrollDownBtnResId()
       
   505     {
       
   506     return R_PENINPUT_LAYOUT_VKB_SCROLL_DOWN;
       
   507     }
       
   508 
       
   509 // --------------------------------------------------------------------------
       
   510 // CPeninputVkbWindow::DoCaseChange
       
   511 // (other items were commented in a header)
       
   512 // --------------------------------------------------------------------------
       
   513 //[Ref]CPeninputGenericVkbWindow::DoCaseChange
       
   514 // ECmdPenInputCase
       
   515 void CPeninputVkbWindow::DoCaseChange( TInt aNewCase )
       
   516     {
       
   517     TInt curCase = CPeninputDataConverter::AnyToInt
       
   518         ( iLayoutContext->RequestData( EPeninputDataTypeCase ) );
       
   519     TInt curRange = CPeninputDataConverter::AnyToInt
       
   520         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   521 
       
   522     if (aNewCase != curCase && curRange == ERangeEnglish)
       
   523         {
       
   524         // Set shift and caplock button
       
   525         TInt shfit;
       
   526         TInt capslock;
       
   527 
       
   528         CPeninputDataConverter::ShiftCapslockByCase( aNewCase,
       
   529             shfit, capslock );
       
   530 
       
   531         iLayoutContext->SetData( EPeninputDataTypeShiftDown, &shfit );
       
   532         ChangeButtonStatus( shfit, EPeninutWindowCtrlIdShiftBtn );
       
   533         iLayoutContext->SetData( EPeninputDataTypeCapslockDown, &capslock );
       
   534         ChangeButtonStatus( capslock, EPeninutWindowCtrlIdCapslockBtn );
       
   535         iLayoutContext->SetData( EPeninputDataTypeCase, &aNewCase );
       
   536 
       
   537         TInt vkblayout = ConfigInfo()->ShiftCapsSingleVkbLayoutByCase
       
   538             ( curRange, aNewCase );
       
   539 
       
   540         ChangeVkbLayout( vkblayout );
       
   541         }
       
   542     }
       
   543 
       
   544 // --------------------------------------------------------------------------
       
   545 // CPeninputVkbWindow::DoRangeChange
       
   546 // (other items were commented in a header)
       
   547 // --------------------------------------------------------------------------
       
   548 void CPeninputVkbWindow::DoRangeChange()
       
   549     {
       
   550     TInt currentRange = CPeninputDataConverter::AnyToInt
       
   551         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   552     switch (currentRange)
       
   553         {
       
   554         case ERangeHiraganaKanji:
       
   555         case ERangeHiraganaOnly:
       
   556             iCurrentJapanese = ERangeHiraganaKanji;
       
   557             break;
       
   558         case ERangeKatakana:
       
   559         case ERangeFullWidthKatakana:
       
   560             iCurrentJapanese = ERangeKatakana;
       
   561             break;
       
   562         default:
       
   563             {
       
   564             TInt permittedRange = CPeninputDataConverter::AnyToInt
       
   565                 ( iLayoutContext->RequestData( EPeninputDataTypePermittedRange ) );
       
   566             if (permittedRange & (ERangeHiraganaKanji | ERangeKatakana | ERangeFullWidthKatakana))
       
   567                 {
       
   568                 if (iCurrentJapanese == ERangeHiraganaKanji
       
   569                         && !(permittedRange & (ERangeHiraganaKanji | ERangeHiraganaOnly)))
       
   570                     {
       
   571                     iCurrentJapanese = ERangeKatakana;
       
   572                     }
       
   573                 else if (iCurrentJapanese == ERangeKatakana
       
   574                         && !(permittedRange & (ERangeKatakana | ERangeFullWidthKatakana)))
       
   575                     {
       
   576                     iCurrentJapanese = ERangeHiraganaKanji;
       
   577                     }
       
   578                 }
       
   579             }
       
   580             break;
       
   581         }
       
   582     if ( iRangeBar )
       
   583         {
       
   584         TInt hideRange  = currentRange;
       
   585         switch (currentRange)
       
   586             {
       
   587             case ERangeFullWidthKatakana:
       
   588                 hideRange = ERangeKatakana;
       
   589                 break;
       
   590             case ERangeFullWidthEnglish:
       
   591                 hideRange = ERangeEnglish;
       
   592                 break;
       
   593             case ERangeFullWidthNumeric:
       
   594                 hideRange = ERangeNumber;
       
   595                 break;
       
   596             case ERangeHiraganaOnly:
       
   597                 hideRange = ERangeHiraganaKanji;
       
   598                 break;
       
   599             default:
       
   600                 break;
       
   601             }
       
   602         iRangeBar->ActiveRange(hideRange);
       
   603 
       
   604         if (currentRange != ERangeHiraganaKanji
       
   605                 && currentRange != ERangeHiraganaOnly
       
   606                 && currentRange != ERangeFullWidthKatakana
       
   607                 && currentRange != ERangeKatakana)
       
   608             {
       
   609             if (iCurrentJapanese == ERangeHiraganaKanji)
       
   610                 {
       
   611                 iRangeBar->HideRange(ERangeKatakana);
       
   612                 }
       
   613             else
       
   614                 {
       
   615                 iRangeBar->HideRange(ERangeHiraganaKanji);
       
   616                 }
       
   617             }
       
   618         else if (ERangeHiraganaOnly == currentRange)
       
   619             {
       
   620             iRangeBar->SetPermittedRanges(0);  // dimmed all buttons
       
   621             }
       
   622         }
       
   623     UiLayout()->Draw();  // after rangebar changed, we must draw all.
       
   624     UpdateArea(Rect(), EFalse);
       
   625     }
       
   626 
       
   627 // ---------------------------------------------------------------------------
       
   628 // CPeninputVkbWindow::SetDimmed
       
   629 // Dim KeyBoard
       
   630 // (other items were commented in a header).
       
   631 // ---------------------------------------------------------------------------
       
   632 //
       
   633 void CPeninputVkbWindow::SetDimmed(TBool aDimFlag)
       
   634     {
       
   635     if (iVkbCtrl)
       
   636         {
       
   637         iVkbCtrl->SetDimmed(aDimFlag);
       
   638         if (aDimFlag)
       
   639             {
       
   640             iVkbCtrl->Draw();
       
   641             UpdateArea(iVkbCtrl->Rect(), EFalse);
       
   642             }
       
   643         }
       
   644     }
       
   645 
       
   646 // -----------------------------------------------------------------------------
       
   647 // CPeninputVkbWindow::Hide
       
   648 // Hide the control pool and all it's controls
       
   649 // (other items were commented in a header).
       
   650 // -----------------------------------------------------------------------------
       
   651 //
       
   652 void CPeninputVkbWindow::Hide(TBool aFlag)
       
   653     {
       
   654     CPeninputLayoutWindowJp::Hide(aFlag);
       
   655 
       
   656     // controls used/not used according to clientlauout
       
   657     CFepUiBaseCtrl* button = iCtrlPool->Control(EPeninutWindowCtrlIdCapslockBtn);
       
   658     if (button)
       
   659         {
       
   660         button->SetReady(!aFlag);
       
   661         }
       
   662     button = iCtrlPool->Control(EPeninutWindowCtrlIdShiftBtn);
       
   663     if (button)
       
   664         {
       
   665         button->SetReady(!aFlag);
       
   666         }
       
   667     button = iCtrlPool->Control(EPeninutWindowCtrlIdClear1Btn);
       
   668     if (button)
       
   669         {
       
   670         button->SetReady(!aFlag);
       
   671         }
       
   672     button = iCtrlPool->Control(EPeninutWindowCtrlIdClear2Btn);
       
   673     if (button)
       
   674         {
       
   675         button->SetReady(!aFlag);
       
   676         }
       
   677     }
       
   678 
       
   679 // ---------------------------------------------------------------------------
       
   680 // CPeninputVkbWindow::SetEnableSettingBtnJp
       
   681 // (other items were commented in a header)
       
   682 // ---------------------------------------------------------------------------
       
   683 //     
       
   684 void CPeninputVkbWindow::SetEnableSettingBtnJp(TBool aEnable)
       
   685     {
       
   686     if ( aEnable )
       
   687         {
       
   688         iTouchInputOptionButton->SetDimmed(EFalse);
       
   689         }
       
   690     else
       
   691         {
       
   692         iTouchInputOptionButton->SetDimmed(ETrue);
       
   693         iTouchInputOptionButton->SetActive(EFalse);
       
   694         } 
       
   695     }
       
   696 
       
   697 // -----------------------------------------------------------------------------
       
   698 // CPeninputVkbWindow::SetSizeToRangeButtons
       
   699 // (other items were commented in a header).
       
   700 // -----------------------------------------------------------------------------
       
   701 //
       
   702 void CPeninputVkbWindow::SetSizeToRangeButtons()
       
   703     {
       
   704     TInt currentRange = CPeninputDataConverter::AnyToInt
       
   705         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   706     if (!currentRange)   // CurrentRange is not yet set.
       
   707         {
       
   708         TInt unitWidth = CPeninputDataConverter::AnyToInt
       
   709             ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
       
   710         TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   711             ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
       
   712 
       
   713         CFepUiBaseCtrl* ctrl = iCtrlPool->Control( EPeninutWindowCtrlIdRangeBar );
       
   714         TRect rect = TRect( TPoint(0,0), TSize( unitWidth, unitHeight ) );
       
   715         
       
   716         if( ctrl != NULL )
       
   717             {
       
   718             static_cast<CAknFepCtrlRangeBar*> (ctrl)->SizeChanged(rect);
       
   719             }
       
   720         }
       
   721     }
       
   722 
       
   723 // ---------------------------------------------------------------------------
       
   724 // CPeninputVkbWindow::CPeninputVkbWindow
       
   725 // (other items were commented in a header).
       
   726 // ---------------------------------------------------------------------------
       
   727 //
       
   728 CPeninputVkbWindow::CPeninputVkbWindow(CFepUiLayout* aUiLayout,
       
   729                                          MPeninputLayoutContext* aLayoutContext)
       
   730     : CPeninputLayoutWindowJp( aUiLayout, aLayoutContext ),
       
   731     iCurrentJapanese(ERangeHiraganaKanji)
       
   732     {
       
   733     }
       
   734 
       
   735 // --------------------------------------------------------------------------
       
   736 // CPeninputVkbWindow::AddButtonL
       
   737 // (other items were commented in a header)
       
   738 // --------------------------------------------------------------------------
       
   739 //
       
   740 CAknFepCtrlEventButton* CPeninputVkbWindow::AddButtonL(
       
   741     const TInt aControlId, const TInt aEventId, const TInt aResId,
       
   742     const TInt aUnicode, const TBool aIsRepeat )
       
   743     {
       
   744     CAknFepCtrlEventButton* button = NULL;
       
   745 
       
   746     if ( aIsRepeat )
       
   747         {
       
   748         button = CAknFepCtrlRepeatButton::NewL( UiLayout(), aControlId,
       
   749             aEventId, aUnicode );
       
   750         }
       
   751     else
       
   752         {
       
   753         button = CAknFepCtrlEventButton::NewL( UiLayout(), aControlId,
       
   754             aEventId, aUnicode );
       
   755         }
       
   756 
       
   757     CleanupStack::PushL( button );
       
   758     if ( button )
       
   759         {
       
   760         // Create the button from resource id
       
   761         button->SetResourceId( aResId );
       
   762         button->ConstructFromResourceL();
       
   763 
       
   764         // Add into the control pool
       
   765         if ( iCtrlPool )
       
   766             {
       
   767             iCtrlPool->AddControl( button );
       
   768             }
       
   769         }
       
   770     CleanupStack::Pop( button );
       
   771 
       
   772     return button;
       
   773     }
       
   774 
       
   775 
       
   776 // --------------------------------------------------------------------------
       
   777 // CPeninputVkbWindow::AddRangeBarL
       
   778 // (other items were commented in a header)
       
   779 // --------------------------------------------------------------------------
       
   780 //
       
   781 void CPeninputVkbWindow::AddRangeBarL()
       
   782     {
       
   783     // Range bar
       
   784     iRangeBar = CAknFepCtrlRangeBar::NewL( UiLayout(),
       
   785         EPeninutWindowCtrlIdRangeBar,
       
   786         CAknFepCtrlRangeBar::EBtnGroupHorizontal );
       
   787 
       
   788     // Set event id
       
   789     iRangeBar->SetEventIdForRange( EPeninputLayoutEventRange );
       
   790 
       
   791     iCtrlPool->AddControl( iRangeBar );
       
   792     }
       
   793 
       
   794 // ---------------------------------------------------------------------------
       
   795 // CPeninputVkbWindow::SetWholeWindowRect
       
   796 // [Ref]CPeninputLayoutWindow::SetWindowRect
       
   797 // (other items were commented in a header).
       
   798 // ---------------------------------------------------------------------------
       
   799 //
       
   800 void CPeninputVkbWindow::SetWholeWindowRect(const TRect& aRect)
       
   801     {
       
   802     TRect rect = aRect;
       
   803 
       
   804     TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   805         ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
       
   806     rect.iTl.iY = rect.iTl.iY - unitHeight;
       
   807 
       
   808     if (!iPredictiveWnd->Hiden())
       
   809         {
       
   810         TRect predictiveRect = aRect;
       
   811         predictiveRect.iTl.iY = predictiveRect.iBr.iY;
       
   812         predictiveRect.iBr.iY += iPredictiveWnd->Rect().Size().iHeight;
       
   813         iPredictiveWnd->SetRect(predictiveRect);
       
   814         rect.iBr.iY += iPredictiveWnd->Rect().Size().iHeight;
       
   815         }
       
   816 
       
   817     SetRect(rect);
       
   818 
       
   819 
       
   820     TRect shadowRect = TRect(TPoint(rect.iTl.iX - iShadowTlWidth,
       
   821                                     rect.iTl.iY - iShadowTlHeight),
       
   822                              TPoint(rect.iBr.iX + iShadowBrWidth,
       
   823                                     rect.iBr.iY + iShadowBrHeight));
       
   824 
       
   825     SetShadowRect(shadowRect);
       
   826     ICFDisableRegionUpdating();  // ICF::OnDeActivate()
       
   827     UiLayout()->SetShadowRect(shadowRect);
       
   828     ICFDisableRegionUpdating();  // ICF::OnDeActivate()
       
   829 
       
   830     HandleControlEvent(EPeninputLayoutEventMovePosition, NULL, KNullDesC);
       
   831     }
       
   832 
       
   833 // ---------------------------------------------------------------------------
       
   834 // CPeninputVkbWindow::AddContextFieldJpL
       
   835 // [ref]CPeninputLayoutWindow::AddContextFieldL( aResID )
       
   836 // (other items were commented in a header)
       
   837 // ---------------------------------------------------------------------------
       
   838 //
       
   839 void CPeninputVkbWindow::AddContextFieldJpL()
       
   840     {
       
   841     // Get reference CControlGroup of headerPane
       
   842     CControlGroup* headerPane = HeaderPane();
       
   843 
       
   844     User::LeaveIfNull( headerPane );
       
   845 
       
   846     // Input context field
       
   847     iInputContextField = CFepInputContextFieldJp::NewL( TRect(),
       
   848         UiLayout(), EPeninutWindowCtrlIdInputContextField );
       
   849 
       
   850     // Read resource
       
   851     TResourceReader resReader;
       
   852     CCoeEnv::Static()->CreateResourceReaderLC( resReader, R_PENINPUT_LAYOUT_ICF );
       
   853     ReadIcfInfo( resReader );
       
   854     CleanupStack::PopAndDestroy( 1 );
       
   855 
       
   856     // Transfer to headerPane
       
   857     headerPane->AddControlL( iInputContextField );
       
   858 
       
   859     iInputContextField->SetFocus(ETrue);
       
   860 
       
   861     // Add layout as event observer
       
   862     iInputContextField->AddEventObserver( UiLayout() );
       
   863     }
       
   864 
       
   865 // End Of File