textinput/peninputvkbjp/src/peninputvkbwindow.cpp
changeset 0 eb1f2e154e89
child 7 6defe5d1bd39
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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     for ( TInt i = 0; i < iCtrlPool->ControlCount(); i++ )
       
   384         {
       
   385         if ( iCtrlPool )
       
   386             {
       
   387             iCtrlPool->ControlByIndex( i )->AddEventObserver( UiLayout() );
       
   388             }
       
   389         }
       
   390     }
       
   391 
       
   392 // --------------------------------------------------------------------------
       
   393 // CPeninputVkbWindow::PopupChoiceList
       
   394 // (other items were commented in a header)
       
   395 // --------------------------------------------------------------------------
       
   396 //
       
   397 void CPeninputVkbWindow::PopupChoiceList()
       
   398     {   // nop
       
   399     }
       
   400 
       
   401 // --------------------------------------------------------------------------
       
   402 // CPeninputVkbWindow::ReorganizeControls
       
   403 // (other items were commented in a header)
       
   404 // --------------------------------------------------------------------------
       
   405 //
       
   406 void CPeninputVkbWindow::ReorganizeControls( TInt aClientLayoutId, TBool aNeedReset )
       
   407     {
       
   408     TInt unitWidth = CPeninputDataConverter::AnyToInt
       
   409         ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
       
   410     TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   411         ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
       
   412 
       
   413     // First remove all controls in the client pane, but don't delete them
       
   414     CFepUiBaseCtrl* activCtrl = ClientPane()->ActiveControl();
       
   415     if (activCtrl)
       
   416         {    // we shuld remove active controls, because CControlGroup::Draw()  draw active controls.[for japanese]
       
   417         ClientPane()->RemoveControl(activCtrl);
       
   418         }
       
   419     ( const_cast<RPointerArray<CFepUiBaseCtrl>&>
       
   420         ( ClientPane()->ControlList() ) ).Reset();
       
   421     iVkbCtrl->SetRect( TRect( ClientPane()->Rect().iTl, TSize( 0, 0 ) ) );
       
   422 
       
   423     if (aNeedReset)
       
   424         {
       
   425         iVkbCtrl->Reset();
       
   426         }
       
   427 
       
   428     // Then add controls according to the configuration of clientlayout
       
   429     CPeninputClientLayoutInfo* clientLayout =
       
   430         ConfigInfo()->FindClientLayoutInfo( aClientLayoutId );
       
   431     RPointerArray<CPeninputControlInfo>& controlList =
       
   432         clientLayout->ControlInfoList();
       
   433 
       
   434     const TInt count = controlList.Count();
       
   435     TInt controlID = 0;
       
   436     TInt cols = 0;
       
   437     TInt rows = 0;
       
   438     CFepUiBaseCtrl* ctrl = NULL;
       
   439     TRect rect = ClientPane()->Rect();
       
   440 
       
   441     // Set rect for client area
       
   442     rect.SetSize( TSize( clientLayout->Columns() * unitWidth,
       
   443                          clientLayout->Rows() * unitHeight ) );
       
   444     ClientPane()->SetRect( rect );
       
   445 
       
   446     // Set owner rect
       
   447     SetWholeWindowRect( ClientPane()->Rect() );
       
   448 
       
   449     TPoint point = rect.iTl;
       
   450 
       
   451     for ( TInt i = 0; i < count; i++ )
       
   452         {
       
   453         controlID = controlList[i]->ControlID();
       
   454         ctrl = iCtrlPool->Control( controlID );
       
   455 
       
   456         if ( ctrl )
       
   457             {
       
   458             rect.iTl = point + TPoint
       
   459                 ( controlList[i]->BeginColumn() * unitWidth,
       
   460                   controlList[i]->BeginRow() * unitHeight
       
   461                 );
       
   462             cols = controlList[i]->EndColumn()
       
   463                 - controlList[i]->BeginColumn();
       
   464             rows = controlList[i]->EndRow() - controlList[i]->BeginRow();
       
   465             rect.SetSize( TSize( cols * unitWidth, rows * unitHeight ) );
       
   466 
       
   467             if ( ( ctrl->ControlType() | ECtrlButton ) == ECtrlButton )
       
   468                 {
       
   469                 ( static_cast<CAknFepCtrlButton*> (ctrl) )->SizeChanged
       
   470                     ( rect, ETrue );
       
   471                 }
       
   472             else if ( ctrl->ControlId() == EPeninutWindowCtrlIdVkbCtrl )
       
   473                 {
       
   474                 ( static_cast<CPeninputVkbCtrlExt*> (ctrl) )->SizeChanged
       
   475                     ( unitWidth, unitHeight, rect.iTl );
       
   476                 }
       
   477             else if ( ctrl->ControlId() == EPeninutWindowCtrlIdRangeBar )
       
   478                 {
       
   479                 rect = TRect( rect.iTl, TSize( unitWidth, unitHeight ) );
       
   480                 ( static_cast<CAknFepCtrlRangeBar*> (ctrl) )->SizeChanged
       
   481                     ( rect );
       
   482                 }
       
   483             AddNotOwnedControl( ctrl );
       
   484             }
       
   485         }
       
   486     }
       
   487 
       
   488 // --------------------------------------------------------------------------
       
   489 // CPeninputVkbWindow::GetScrollUpBtnResId
       
   490 // (other items were commented in a header)
       
   491 // --------------------------------------------------------------------------
       
   492 //
       
   493 TInt CPeninputVkbWindow::GetScrollUpBtnResId()
       
   494     {
       
   495     return R_PENINPUT_LAYOUT_VKB_SCROLL_UP;
       
   496     }
       
   497 
       
   498 // --------------------------------------------------------------------------
       
   499 // CPeninputVkbWindow::GetScrollDownBtnResId
       
   500 // (other items were commented in a header)
       
   501 // --------------------------------------------------------------------------
       
   502 //
       
   503 TInt CPeninputVkbWindow::GetScrollDownBtnResId()
       
   504     {
       
   505     return R_PENINPUT_LAYOUT_VKB_SCROLL_DOWN;
       
   506     }
       
   507 
       
   508 // --------------------------------------------------------------------------
       
   509 // CPeninputVkbWindow::DoCaseChange
       
   510 // (other items were commented in a header)
       
   511 // --------------------------------------------------------------------------
       
   512 //[Ref]CPeninputGenericVkbWindow::DoCaseChange
       
   513 // ECmdPenInputCase
       
   514 void CPeninputVkbWindow::DoCaseChange( TInt aNewCase )
       
   515     {
       
   516     TInt curCase = CPeninputDataConverter::AnyToInt
       
   517         ( iLayoutContext->RequestData( EPeninputDataTypeCase ) );
       
   518     TInt curRange = CPeninputDataConverter::AnyToInt
       
   519         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   520 
       
   521     if (aNewCase != curCase && curRange == ERangeEnglish)
       
   522         {
       
   523         // Set shift and caplock button
       
   524         TInt shfit;
       
   525         TInt capslock;
       
   526 
       
   527         CPeninputDataConverter::ShiftCapslockByCase( aNewCase,
       
   528             shfit, capslock );
       
   529 
       
   530         iLayoutContext->SetData( EPeninputDataTypeShiftDown, &shfit );
       
   531         ChangeButtonStatus( shfit, EPeninutWindowCtrlIdShiftBtn );
       
   532         iLayoutContext->SetData( EPeninputDataTypeCapslockDown, &capslock );
       
   533         ChangeButtonStatus( capslock, EPeninutWindowCtrlIdCapslockBtn );
       
   534         iLayoutContext->SetData( EPeninputDataTypeCase, &aNewCase );
       
   535 
       
   536         TInt vkblayout = ConfigInfo()->ShiftCapsSingleVkbLayoutByCase
       
   537             ( curRange, aNewCase );
       
   538 
       
   539         ChangeVkbLayout( vkblayout );
       
   540         }
       
   541     }
       
   542 
       
   543 // --------------------------------------------------------------------------
       
   544 // CPeninputVkbWindow::DoRangeChange
       
   545 // (other items were commented in a header)
       
   546 // --------------------------------------------------------------------------
       
   547 void CPeninputVkbWindow::DoRangeChange()
       
   548     {
       
   549     TInt currentRange = CPeninputDataConverter::AnyToInt
       
   550         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   551     switch (currentRange)
       
   552         {
       
   553         case ERangeHiraganaKanji:
       
   554         case ERangeHiraganaOnly:
       
   555             iCurrentJapanese = ERangeHiraganaKanji;
       
   556             break;
       
   557         case ERangeKatakana:
       
   558         case ERangeFullWidthKatakana:
       
   559             iCurrentJapanese = ERangeKatakana;
       
   560             break;
       
   561         default:
       
   562             {
       
   563             TInt permittedRange = CPeninputDataConverter::AnyToInt
       
   564                 ( iLayoutContext->RequestData( EPeninputDataTypePermittedRange ) );
       
   565             if (permittedRange & (ERangeHiraganaKanji | ERangeKatakana | ERangeFullWidthKatakana))
       
   566                 {
       
   567                 if (iCurrentJapanese == ERangeHiraganaKanji
       
   568                         && !(permittedRange & (ERangeHiraganaKanji | ERangeHiraganaOnly)))
       
   569                     {
       
   570                     iCurrentJapanese = ERangeKatakana;
       
   571                     }
       
   572                 else if (iCurrentJapanese == ERangeKatakana
       
   573                         && !(permittedRange & (ERangeKatakana | ERangeFullWidthKatakana)))
       
   574                     {
       
   575                     iCurrentJapanese = ERangeHiraganaKanji;
       
   576                     }
       
   577                 }
       
   578             }
       
   579             break;
       
   580         }
       
   581     if ( iRangeBar )
       
   582         {
       
   583         TInt hideRange  = currentRange;
       
   584         switch (currentRange)
       
   585             {
       
   586             case ERangeFullWidthKatakana:
       
   587                 hideRange = ERangeKatakana;
       
   588                 break;
       
   589             case ERangeFullWidthEnglish:
       
   590                 hideRange = ERangeEnglish;
       
   591                 break;
       
   592             case ERangeFullWidthNumeric:
       
   593                 hideRange = ERangeNumber;
       
   594                 break;
       
   595             case ERangeHiraganaOnly:
       
   596                 hideRange = ERangeHiraganaKanji;
       
   597                 break;
       
   598             default:
       
   599                 break;
       
   600             }
       
   601         iRangeBar->ActiveRange(hideRange);
       
   602 
       
   603         if (currentRange != ERangeHiraganaKanji
       
   604                 && currentRange != ERangeHiraganaOnly
       
   605                 && currentRange != ERangeFullWidthKatakana
       
   606                 && currentRange != ERangeKatakana)
       
   607             {
       
   608             if (iCurrentJapanese == ERangeHiraganaKanji)
       
   609                 {
       
   610                 iRangeBar->HideRange(ERangeKatakana);
       
   611                 }
       
   612             else
       
   613                 {
       
   614                 iRangeBar->HideRange(ERangeHiraganaKanji);
       
   615                 }
       
   616             }
       
   617         else if (ERangeHiraganaOnly == currentRange)
       
   618             {
       
   619             iRangeBar->SetPermittedRanges(0);  // dimmed all buttons
       
   620             }
       
   621         }
       
   622     UiLayout()->Draw();  // after rangebar changed, we must draw all.
       
   623     UpdateArea(Rect(), EFalse);
       
   624     }
       
   625 
       
   626 // ---------------------------------------------------------------------------
       
   627 // CPeninputVkbWindow::SetDimmed
       
   628 // Dim KeyBoard
       
   629 // (other items were commented in a header).
       
   630 // ---------------------------------------------------------------------------
       
   631 //
       
   632 void CPeninputVkbWindow::SetDimmed(TBool aDimFlag)
       
   633     {
       
   634     if (iVkbCtrl)
       
   635         {
       
   636         iVkbCtrl->SetDimmed(aDimFlag);
       
   637         if (aDimFlag)
       
   638             {
       
   639             iVkbCtrl->Draw();
       
   640             UpdateArea(iVkbCtrl->Rect(), EFalse);
       
   641             }
       
   642         }
       
   643     }
       
   644 
       
   645 // -----------------------------------------------------------------------------
       
   646 // CPeninputVkbWindow::Hide
       
   647 // Hide the control pool and all it's controls
       
   648 // (other items were commented in a header).
       
   649 // -----------------------------------------------------------------------------
       
   650 //
       
   651 void CPeninputVkbWindow::Hide(TBool aFlag)
       
   652     {
       
   653     CPeninputLayoutWindowJp::Hide(aFlag);
       
   654 
       
   655     // controls used/not used according to clientlauout
       
   656     CFepUiBaseCtrl* button = iCtrlPool->Control(EPeninutWindowCtrlIdCapslockBtn);
       
   657     if (button)
       
   658         {
       
   659         button->SetReady(!aFlag);
       
   660         }
       
   661     button = iCtrlPool->Control(EPeninutWindowCtrlIdShiftBtn);
       
   662     if (button)
       
   663         {
       
   664         button->SetReady(!aFlag);
       
   665         }
       
   666     button = iCtrlPool->Control(EPeninutWindowCtrlIdClear1Btn);
       
   667     if (button)
       
   668         {
       
   669         button->SetReady(!aFlag);
       
   670         }
       
   671     button = iCtrlPool->Control(EPeninutWindowCtrlIdClear2Btn);
       
   672     if (button)
       
   673         {
       
   674         button->SetReady(!aFlag);
       
   675         }
       
   676     }
       
   677 
       
   678 // ---------------------------------------------------------------------------
       
   679 // CPeninputVkbWindow::SetEnableSettingBtnJp
       
   680 // (other items were commented in a header)
       
   681 // ---------------------------------------------------------------------------
       
   682 //     
       
   683 void CPeninputVkbWindow::SetEnableSettingBtnJp(TBool aEnable)
       
   684     {
       
   685     if ( aEnable )
       
   686         {
       
   687         iTouchInputOptionButton->SetDimmed(EFalse);
       
   688         }
       
   689     else
       
   690         {
       
   691         iTouchInputOptionButton->SetDimmed(ETrue);
       
   692         iTouchInputOptionButton->SetActive(EFalse);
       
   693         } 
       
   694     }
       
   695 
       
   696 // -----------------------------------------------------------------------------
       
   697 // CPeninputVkbWindow::SetSizeToRangeButtons
       
   698 // (other items were commented in a header).
       
   699 // -----------------------------------------------------------------------------
       
   700 //
       
   701 void CPeninputVkbWindow::SetSizeToRangeButtons()
       
   702     {
       
   703     TInt currentRange = CPeninputDataConverter::AnyToInt
       
   704         ( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
       
   705     if (!currentRange)   // CurrentRange is not yet set.
       
   706         {
       
   707         TInt unitWidth = CPeninputDataConverter::AnyToInt
       
   708             ( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
       
   709         TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   710             ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
       
   711 
       
   712         CFepUiBaseCtrl* ctrl = iCtrlPool->Control( EPeninutWindowCtrlIdRangeBar );
       
   713         TRect rect = TRect( TPoint(0,0), TSize( unitWidth, unitHeight ) );
       
   714         static_cast<CAknFepCtrlRangeBar*> (ctrl)->SizeChanged(rect);
       
   715         }
       
   716     }
       
   717 
       
   718 // ---------------------------------------------------------------------------
       
   719 // CPeninputVkbWindow::CPeninputVkbWindow
       
   720 // (other items were commented in a header).
       
   721 // ---------------------------------------------------------------------------
       
   722 //
       
   723 CPeninputVkbWindow::CPeninputVkbWindow(CFepUiLayout* aUiLayout,
       
   724                                          MPeninputLayoutContext* aLayoutContext)
       
   725     : CPeninputLayoutWindowJp( aUiLayout, aLayoutContext ),
       
   726     iCurrentJapanese(ERangeHiraganaKanji)
       
   727     {
       
   728     }
       
   729 
       
   730 // --------------------------------------------------------------------------
       
   731 // CPeninputVkbWindow::AddButtonL
       
   732 // (other items were commented in a header)
       
   733 // --------------------------------------------------------------------------
       
   734 //
       
   735 CAknFepCtrlEventButton* CPeninputVkbWindow::AddButtonL(
       
   736     const TInt aControlId, const TInt aEventId, const TInt aResId,
       
   737     const TInt aUnicode, const TBool aIsRepeat )
       
   738     {
       
   739     CAknFepCtrlEventButton* button = NULL;
       
   740 
       
   741     if ( aIsRepeat )
       
   742         {
       
   743         button = CAknFepCtrlRepeatButton::NewL( UiLayout(), aControlId,
       
   744             aEventId, aUnicode );
       
   745         }
       
   746     else
       
   747         {
       
   748         button = CAknFepCtrlEventButton::NewL( UiLayout(), aControlId,
       
   749             aEventId, aUnicode );
       
   750         }
       
   751 
       
   752     CleanupStack::PushL( button );
       
   753     if ( button )
       
   754         {
       
   755         // Create the button from resource id
       
   756         button->SetResourceId( aResId );
       
   757         button->ConstructFromResourceL();
       
   758 
       
   759         // Add into the control pool
       
   760         if ( iCtrlPool )
       
   761             {
       
   762             iCtrlPool->AddControl( button );
       
   763             }
       
   764         }
       
   765     CleanupStack::Pop( button );
       
   766 
       
   767     return button;
       
   768     }
       
   769 
       
   770 
       
   771 // --------------------------------------------------------------------------
       
   772 // CPeninputVkbWindow::AddRangeBarL
       
   773 // (other items were commented in a header)
       
   774 // --------------------------------------------------------------------------
       
   775 //
       
   776 void CPeninputVkbWindow::AddRangeBarL()
       
   777     {
       
   778     // Range bar
       
   779     iRangeBar = CAknFepCtrlRangeBar::NewL( UiLayout(),
       
   780         EPeninutWindowCtrlIdRangeBar,
       
   781         CAknFepCtrlRangeBar::EBtnGroupHorizontal );
       
   782 
       
   783     // Set event id
       
   784     iRangeBar->SetEventIdForRange( EPeninputLayoutEventRange );
       
   785 
       
   786     iCtrlPool->AddControl( iRangeBar );
       
   787     }
       
   788 
       
   789 // ---------------------------------------------------------------------------
       
   790 // CPeninputVkbWindow::SetWholeWindowRect
       
   791 // [Ref]CPeninputLayoutWindow::SetWindowRect
       
   792 // (other items were commented in a header).
       
   793 // ---------------------------------------------------------------------------
       
   794 //
       
   795 void CPeninputVkbWindow::SetWholeWindowRect(const TRect& aRect)
       
   796     {
       
   797     TRect rect = aRect;
       
   798 
       
   799     TInt unitHeight = CPeninputDataConverter::AnyToInt
       
   800         ( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
       
   801     rect.iTl.iY = rect.iTl.iY - unitHeight;
       
   802 
       
   803     if (!iPredictiveWnd->Hiden())
       
   804         {
       
   805         TRect predictiveRect = aRect;
       
   806         predictiveRect.iTl.iY = predictiveRect.iBr.iY;
       
   807         predictiveRect.iBr.iY += iPredictiveWnd->Rect().Size().iHeight;
       
   808         iPredictiveWnd->SetRect(predictiveRect);
       
   809         rect.iBr.iY += iPredictiveWnd->Rect().Size().iHeight;
       
   810         }
       
   811 
       
   812     SetRect(rect);
       
   813 
       
   814 
       
   815     TRect shadowRect = TRect(TPoint(rect.iTl.iX - iShadowTlWidth,
       
   816                                     rect.iTl.iY - iShadowTlHeight),
       
   817                              TPoint(rect.iBr.iX + iShadowBrWidth,
       
   818                                     rect.iBr.iY + iShadowBrHeight));
       
   819 
       
   820     SetShadowRect(shadowRect);
       
   821     ICFDisableRegionUpdating();  // ICF::OnDeActivate()
       
   822     UiLayout()->SetShadowRect(shadowRect);
       
   823     ICFDisableRegionUpdating();  // ICF::OnDeActivate()
       
   824 
       
   825     HandleControlEvent(EPeninputLayoutEventMovePosition, NULL, KNullDesC);
       
   826     }
       
   827 
       
   828 // ---------------------------------------------------------------------------
       
   829 // CPeninputVkbWindow::AddContextFieldJpL
       
   830 // [ref]CPeninputLayoutWindow::AddContextFieldL( aResID )
       
   831 // (other items were commented in a header)
       
   832 // ---------------------------------------------------------------------------
       
   833 //
       
   834 void CPeninputVkbWindow::AddContextFieldJpL()
       
   835     {
       
   836     // Get reference CControlGroup of headerPane
       
   837     CControlGroup* headerPane = HeaderPane();
       
   838 
       
   839     User::LeaveIfNull( headerPane );
       
   840 
       
   841     // Input context field
       
   842     iInputContextField = CFepInputContextFieldJp::NewL( TRect(),
       
   843         UiLayout(), EPeninutWindowCtrlIdInputContextField );
       
   844 
       
   845     // Read resource
       
   846     TResourceReader resReader;
       
   847     CCoeEnv::Static()->CreateResourceReaderLC( resReader, R_PENINPUT_LAYOUT_ICF );
       
   848     ReadIcfInfo( resReader );
       
   849     CleanupStack::PopAndDestroy( 1 );
       
   850 
       
   851     // Transfer to headerPane
       
   852     headerPane->AddControlL( iInputContextField );
       
   853 
       
   854     iInputContextField->SetFocus(ETrue);
       
   855 
       
   856     // Add layout as event observer
       
   857     iInputContextField->AddEventObserver( UiLayout() );
       
   858     }
       
   859 
       
   860 // End Of File