textinput/peninputcommonctrlsjp/src/peninputlayoutwindowjp.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2009 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:  common layout window for UI interface of VKB and HWR : japanese
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // System includes
       
    20 #include <peninputcommonlayout.h>   // many includes
       
    21 #include <peninputinputcontextfield.h>
       
    22 #include <AknFepGlobalEnums.h>
       
    23 #include <aknlayoutscalable_avkon.cdl.h>
       
    24 #include <peninputrepeatbutton.h>   // CAknFepCtrlEventButton,CAknFepCtrlRepeatButton
       
    25 #include <peninputdataconverter.h>
       
    26 
       
    27 // User includes
       
    28 #include "peninputeventjp.h"  // EPeninutWindowCtrlIdCandidatePopupWindow, ...
       
    29 #include "peninputlayoutwindowjp.h"
       
    30 #include "peninputjapaneseview.h"
       
    31 #include "peninputcontextfieldjp.h"
       
    32 #include "peninputjapanesecandidatewnd.h"
       
    33 #include "peninputjapanesepredictivewnd.h"
       
    34 #include "peninputjapanesecandidatelistbox.h"
       
    35 #include "peninputjapanesepredictivelistbox.h"
       
    36 
       
    37 // ======== MEMBER FUNCTIONS ========
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // CPeninputLayoutWindowJp::~CPeninputLayoutWindowJp
       
    41 // (other items were commented in a header)
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 EXPORT_C CPeninputLayoutWindowJp::~CPeninputLayoutWindowJp()
       
    45     {
       
    46     delete iViewCandidate;
       
    47     delete iViewPrediction;
       
    48     delete iViewCharacterRange;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CPeninputLayoutWindowJp::HandleControlEvent
       
    53 // (other items were commented in a header).
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 EXPORT_C void CPeninputLayoutWindowJp::HandleControlEvent(TInt aEventType,
       
    57                                           CFepUiBaseCtrl* aCtrl,
       
    58                                           const TDesC& aEventData)
       
    59     {
       
    60     TInt* data = ( TInt* ) aEventData.Ptr();
       
    61     switch (aEventType)
       
    62         {
       
    63         case EPeninputLayoutEventMovePosition:
       
    64             {
       
    65             TSize shadowSize = ShadowRect().Size();
       
    66             if (iOpened && shadowSize.iWidth && shadowSize.iHeight)  // check if ready.
       
    67                 {
       
    68                 TPoint tl = UiLayout()->Position();
       
    69                 if ((tl.iX || tl.iY) &&
       
    70                     !CPeninputDataConverter::AnyToInt(iLayoutContext->RequestData(EAkninputDataTypeSizeChanging)) )
       
    71                     {
       
    72                     ChangeLayoutPosition(EPeninputPositionChangeTlJustify);
       
    73                     ICFDisableRegionUpdating();
       
    74                     }
       
    75                 TInt style = *( ( TUint16* ) aEventData.Ptr() );
       
    76                 if (EPeninputPositionChangeDataQuery != style)
       
    77                     {
       
    78                     style = EPeninputPositionChangeBrJustify;
       
    79                     }
       
    80                 ChangeLayoutPosition(style);
       
    81                 ICFDisableRegionUpdating();
       
    82                 }
       
    83             }
       
    84             break;
       
    85         case EEventSetDimmedSctBtn:
       
    86             {
       
    87             CAknFepCtrlEventButton* sctBtn = static_cast<CAknFepCtrlEventButton*>(iCtrlPool->Control(EPeninutWindowCtrlIdSymbolBtn));
       
    88             if (sctBtn)
       
    89                 {
       
    90                 TBool dimmFlag = (*data)? ETrue : EFalse;
       
    91                 sctBtn->SetDimmed(dimmFlag);
       
    92                 }
       
    93             }
       
    94             break;
       
    95         default:
       
    96             CPeninputLayoutWindow::HandleControlEvent(aEventType,aCtrl,aEventData);
       
    97             break;
       
    98         }
       
    99     }
       
   100 
       
   101 // --------------------------------------------------------------------------
       
   102 // CPeninputLayoutWindowJp::CreateAllControls
       
   103 // (other items were commented in a header)
       
   104 // --------------------------------------------------------------------------
       
   105 //
       
   106 EXPORT_C void CPeninputLayoutWindowJp::CreateAllControlsL()
       
   107     {
       
   108 
       
   109     AddCandidateWindowL();
       
   110 
       
   111     // befor predictivewnd, handle pointer event
       
   112     CAknFepCtrlEventButton* upButton = AddButtonL(
       
   113                 EPeninutWindowCtrlIdScrollUpBtn,
       
   114                 EPeninputLayoutEventScrollUp,
       
   115                 GetScrollUpBtnResId(),
       
   116                 EKeySpace, // dummy
       
   117                 ETrue);
       
   118 
       
   119     // befor predictivewnd, handle pointer event
       
   120     CAknFepCtrlEventButton* downButton = AddButtonL(
       
   121                 EPeninutWindowCtrlIdScrollDownBtn,
       
   122                 EPeninputLayoutEventScrollDown,
       
   123                 GetScrollDownBtnResId(),
       
   124                 EKeySpace, // dummy
       
   125                 ETrue);
       
   126 
       
   127     AddPredictiveWindowL();
       
   128 
       
   129     iPredictiveWnd->SetButtons(upButton, downButton);
       
   130 
       
   131     AddCharacterRangeWindowL();  // Hwr only
       
   132 
       
   133     }
       
   134 
       
   135 // --------------------------------------------------------------------------
       
   136 // CPeninputLayoutWindowJp::SetControlsFont
       
   137 // (other items were commented in a header)
       
   138 // --------------------------------------------------------------------------
       
   139 //
       
   140 EXPORT_C void CPeninputLayoutWindowJp::SetControlsFont()
       
   141     {
       
   142     TAknTextLineLayout textPaneTextLayout;
       
   143 
       
   144     if (EPluginInputModeVkb == iLayoutContext->LayoutType())
       
   145         {
       
   146         textPaneTextLayout = 
       
   147             AknLayoutScalable_Avkon::fep_vkb_top_text_pane_t1().LayoutLine();
       
   148         }
       
   149     else
       
   150         {
       
   151         textPaneTextLayout = 
       
   152             AknLayoutScalable_Avkon::fep_hwr_top_text_pane_t1().LayoutLine();
       
   153         }
       
   154 
       
   155     CFepInputContextField* icf = static_cast<CFepInputContextField*>
       
   156         ( Control( EPeninutWindowCtrlIdInputContextField ) );
       
   157 
       
   158     icf->SetFont( AknLayoutUtils::FontFromId
       
   159         ( textPaneTextLayout.iFont, NULL ) );
       
   160     TInt UnitHeight = *( static_cast<TInt*>( iLayoutContext->RequestData
       
   161                     ( EPeninputDataTypeUnitHeight ) ) );
       
   162     TInt UnitWidth = *( static_cast<TInt*>( iLayoutContext->RequestData
       
   163                     ( EPeninputDataTypeUnitWidth ) ) );
       
   164 
       
   165     // call listbox->SizeChanged()
       
   166     iCandidateWnd->UpdateMaximumRows(
       
   167                               UnitHeight
       
   168                              ,(EPluginInputModeVkb == iLayoutContext->LayoutType())? KPENINPUT_LAYOUT_VKB_POPUP_MAX_ROW_COUNT:KPENINPUT_LAYOUT_HWR_POPUP_MAX_ROW_COUNT);
       
   169 
       
   170     if (iCharacterRangeWnd)
       
   171         {
       
   172         // call listbox->SizeChanged()
       
   173         iCharacterRangeWnd->UpdateMaximumRows(UnitHeight,KPENINPUT_LAYOUT_HWR_POPUP_MAX_ROW_COUNT);
       
   174         }
       
   175 
       
   176     iPredictiveWnd->SetLineCount(KPENINPUT_LAYOUT_PREDICTIONPANE_ROW_COUNT);
       
   177 
       
   178     // call listbox->SizeChanged()
       
   179     iPredictiveWnd->SizeChanged(Rect().Size().iWidth, UnitWidth, UnitHeight);
       
   180     }
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CPeninputLayoutWindowJp:::ConstructFromResourceL
       
   184 // (other items were commented in a header).
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 EXPORT_C void CPeninputLayoutWindowJp::ConstructFromResourceL()
       
   188     {
       
   189     CPeninputLayoutWindow::ConstructFromResourceL();
       
   190     if (iCandidateWnd && iCandidateWnd->ListBox() && iCandidateWnd->ListBox()->ScrollBarFrame())
       
   191         {
       
   192         CAknDoubleSpanScrollBar* scrollBar =
       
   193             static_cast<CAknDoubleSpanScrollBar*>(iCandidateWnd->ListBox()->ScrollBarFrame()->GetScrollBarHandle(CEikScrollBar::EVertical));
       
   194         if (scrollBar)
       
   195             {
       
   196             scrollBar->HandleResourceChange(KAknsMessageSkinChange);
       
   197             }
       
   198         }
       
   199     }
       
   200 
       
   201 // ---------------------------------------------------------------------------
       
   202 // CPeninputLayoutWindowJp::HandlePointerDownEventL
       
   203 // Handle pointer down event
       
   204 // (other items were commented in a header).
       
   205 // ---------------------------------------------------------------------------
       
   206 //      
       
   207 EXPORT_C CFepUiBaseCtrl* CPeninputLayoutWindowJp::HandlePointerDownEventL(const TPoint& aPoint)
       
   208     {
       
   209     CFepUiBaseCtrl* ctrl = iCandidateWnd->HandlePointerDownEventL(aPoint);
       
   210     if (!ctrl && iCharacterRangeWnd)
       
   211         {
       
   212         ctrl = iCharacterRangeWnd->HandlePointerDownEventL(aPoint);
       
   213         }
       
   214     if (!ctrl)
       
   215         {
       
   216         ctrl = CAknFepCtrlBaseWindow::HandlePointerDownEventL(aPoint);
       
   217         }
       
   218     return ctrl;
       
   219     }
       
   220 
       
   221 // ---------------------------------------------------------------------------
       
   222 // CPeninputLayoutWindowJp::HandlePointerUpEventL
       
   223 // Handle pointer up event
       
   224 // (other items were commented in a header).
       
   225 // ---------------------------------------------------------------------------
       
   226 //    
       
   227 EXPORT_C CFepUiBaseCtrl* CPeninputLayoutWindowJp::HandlePointerUpEventL(const TPoint& aPoint)
       
   228     {
       
   229     CFepUiBaseCtrl* ctrl = iCandidateWnd->HandlePointerUpEventL(aPoint);
       
   230     if (!ctrl && iCharacterRangeWnd)
       
   231         {
       
   232         ctrl = iCharacterRangeWnd->HandlePointerUpEventL(aPoint);
       
   233         }
       
   234     if (!ctrl)
       
   235         ctrl = CPeninputLayoutWindow::HandlePointerUpEventL(aPoint);
       
   236     return ctrl;
       
   237     }
       
   238 
       
   239 // ---------------------------------------------------------------------------
       
   240 // CPeninputLayoutWindowJp::HandlePointerMoveEventL
       
   241 // Handle pointer move event
       
   242 // (other items were commented in a header).
       
   243 // ---------------------------------------------------------------------------
       
   244 //
       
   245 EXPORT_C CFepUiBaseCtrl* CPeninputLayoutWindowJp::HandlePointerMoveEventL(const TPoint& aPoint)
       
   246     {
       
   247     CFepUiBaseCtrl* ctrl = iCandidateWnd->HandlePointerMoveEventL(aPoint);
       
   248     if (!ctrl && iCharacterRangeWnd)
       
   249         {
       
   250         ctrl = iCharacterRangeWnd->HandlePointerMoveEventL(aPoint);
       
   251         }
       
   252     if (!ctrl)
       
   253         ctrl = CPeninputLayoutWindow::HandlePointerMoveEventL(aPoint);
       
   254     return ctrl;
       
   255     }
       
   256 
       
   257 // ---------------------------------------------------------------------------
       
   258 // CPeninputLayoutWindowJp::CandidateWindow
       
   259 // (other items were commented in a header).
       
   260 // ---------------------------------------------------------------------------
       
   261 //
       
   262 EXPORT_C CPeninputJapaneseCandidateWnd* CPeninputLayoutWindowJp::CandidateWindow()
       
   263     {
       
   264     return iCandidateWnd;
       
   265     }
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // CPeninputLayoutWindowJp::PredictiveWindow
       
   269 // (other items were commented in a header).
       
   270 // ---------------------------------------------------------------------------
       
   271 //
       
   272 EXPORT_C CPeninputJapanesePredictiveWnd* CPeninputLayoutWindowJp::PredictiveWindow()
       
   273     {
       
   274     return iPredictiveWnd;
       
   275     }
       
   276 
       
   277 // ---------------------------------------------------------------------------
       
   278 // CPeninputLayoutWindowJp::CharacterRangeWindow
       
   279 // (other items were commented in a header).
       
   280 // ---------------------------------------------------------------------------
       
   281 //
       
   282 EXPORT_C CPeninputJapaneseCandidateWnd* CPeninputLayoutWindowJp::CharacterRangeWindow()
       
   283     {
       
   284     return iCharacterRangeWnd;
       
   285     }
       
   286 
       
   287 // ---------------------------------------------------------------------------
       
   288 // CPeninputLayoutWindowJp::InputContextField
       
   289 // (other items were commented in a header).
       
   290 // ---------------------------------------------------------------------------
       
   291 //
       
   292 EXPORT_C CFepInputContextFieldJp* CPeninputLayoutWindowJp::InputContextField()
       
   293     {
       
   294     return static_cast<CFepInputContextFieldJp*>(Control(EPeninutWindowCtrlIdInputContextField));
       
   295     }
       
   296 
       
   297 // --------------------------------------------------------------------------
       
   298 // CPeninputLayoutWindowJp::Opened
       
   299 // (other items were commented in a header)
       
   300 // --------------------------------------------------------------------------
       
   301 //
       
   302 EXPORT_C void CPeninputLayoutWindowJp::Opened()
       
   303     {
       
   304     iOpened = ETrue;
       
   305     }
       
   306 
       
   307 // --------------------------------------------------------------------------
       
   308 // CPeninputLayoutWindowJp::Closed
       
   309 // (other items were commented in a header)
       
   310 // --------------------------------------------------------------------------
       
   311 //
       
   312 EXPORT_C void CPeninputLayoutWindowJp::Closed()
       
   313     {
       
   314     iOpened = EFalse;
       
   315     }
       
   316 
       
   317 // --------------------------------------------------------------------------
       
   318 // CPeninputLayoutWindowJp::ICFDisableRegionUpdating
       
   319 // (other items were commented in a header)
       
   320 // --------------------------------------------------------------------------
       
   321 //
       
   322 EXPORT_C void CPeninputLayoutWindowJp::ICFDisableRegionUpdating()
       
   323     {
       
   324     CFepInputContextField* icf = static_cast<CFepInputContextField*>
       
   325         ( Control( EPeninutWindowCtrlIdInputContextField ) );
       
   326 
       
   327     icf->OnDeActivate();
       
   328     }
       
   329 
       
   330 // --------------------------------------------------------------------------
       
   331 // CPeninputLayoutWindowJp::ICFEnableRegionUpdating
       
   332 // (other items were commented in a header)
       
   333 // --------------------------------------------------------------------------
       
   334 //
       
   335 EXPORT_C void CPeninputLayoutWindowJp::ICFEnableRegionUpdating()
       
   336     {
       
   337     CFepInputContextField* icf = static_cast<CFepInputContextField*>
       
   338         ( Control( EPeninutWindowCtrlIdInputContextField ) );
       
   339 
       
   340     icf->OnActivate();
       
   341     }
       
   342 
       
   343 // ------------------------------------------------------------------------
       
   344 // CPeninputLayoutWindow::CPeninputLayoutWindow
       
   345 // (other items were commented in a header)
       
   346 // ------------------------------------------------------------------------
       
   347 //
       
   348 EXPORT_C CPeninputLayoutWindowJp::CPeninputLayoutWindowJp( 
       
   349     CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext )
       
   350     : CPeninputLayoutWindow( aUiLayout, aLayoutContext ),
       
   351     iOpened(EFalse)
       
   352     { 
       
   353     }
       
   354 
       
   355 // ---------------------------------------------------------------------------
       
   356 // CPeninputLayoutWindowJp::AddButtonL
       
   357 // (other items were commented in a header).
       
   358 // ---------------------------------------------------------------------------
       
   359 //
       
   360 CAknFepCtrlEventButton* CPeninputLayoutWindowJp::AddButtonL(
       
   361     const TInt aControlId, const TInt aEventId, const TInt aResId,
       
   362     const TInt aUnicode, const TBool aIsRepeat )
       
   363     {
       
   364     CAknFepCtrlEventButton* button = NULL;
       
   365 
       
   366     if ( aIsRepeat )
       
   367         {
       
   368         button = CAknFepCtrlRepeatButton::NewL( UiLayout(), aControlId,
       
   369                                                 aEventId, aUnicode );
       
   370         }
       
   371     else
       
   372         {
       
   373         button = CAknFepCtrlEventButton::NewL( UiLayout(), aControlId,
       
   374                                                aEventId, aUnicode );
       
   375         }
       
   376 
       
   377     if ( button )
       
   378         {
       
   379         CleanupStack::PushL( button );
       
   380         // Read resource
       
   381         TResourceReader reader;
       
   382 
       
   383         CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
       
   384         button->SetResourceId( aResId );
       
   385         button->ConstructFromResourceL();
       
   386         // Pop and destroy reader
       
   387         CleanupStack::PopAndDestroy( 1 );
       
   388 
       
   389         AddControlL(button);
       
   390         CleanupStack::Pop( button );
       
   391         }
       
   392     return button;
       
   393     }
       
   394 
       
   395 // ---------------------------------------------------------------------------
       
   396 // CPeninputLayoutWindowJp::AddCandidateWindowL
       
   397 // (other items were commented in a header).
       
   398 // ---------------------------------------------------------------------------
       
   399 //
       
   400 void CPeninputLayoutWindowJp::AddCandidateWindowL()
       
   401     {
       
   402     iViewCandidate = new(ELeave) CPeninputJapaneseView;
       
   403     iViewCandidate->ConstructL();
       
   404     iCandidateWnd = CPeninputJapaneseCandidateWnd::NewL(UiLayout(), EPeninutWindowCtrlIdCandidatePopupWindow, iViewCandidate);
       
   405     iCandidateWnd->AddEventObserver(UiLayout());
       
   406     AddControlL(iCandidateWnd);
       
   407     iCandidateWnd->SetParent(NULL);
       
   408     iViewCandidate->SetListBox(iCandidateWnd->ListBox());
       
   409     }
       
   410 
       
   411 // ---------------------------------------------------------------------------
       
   412 // CPeninputLayoutWindowJp::AddPredictiveWindowL
       
   413 // (other items were commented in a header).
       
   414 // ---------------------------------------------------------------------------
       
   415 //
       
   416 void CPeninputLayoutWindowJp::AddPredictiveWindowL()
       
   417     {
       
   418     iViewPrediction = new(ELeave) CPeninputJapaneseView;
       
   419     iViewPrediction->ConstructL();
       
   420     iPredictiveWnd = CPeninputJapanesePredictiveWnd::NewL(UiLayout(), EPeninutWindowCtrlIdPredictionPane, iViewPrediction);
       
   421     iPredictiveWnd->AddEventObserver(UiLayout());
       
   422     AddControlL(iPredictiveWnd);
       
   423     iViewPrediction->SetListBox(iPredictiveWnd->ListBox());
       
   424     }
       
   425 
       
   426 // ---------------------------------------------------------------------------
       
   427 // CPeninputLayoutWindowJp::AddCandidateWindowL
       
   428 // (other items were commented in a header).
       
   429 // ---------------------------------------------------------------------------
       
   430 //
       
   431 void CPeninputLayoutWindowJp::AddCharacterRangeWindowL()
       
   432     {
       
   433     if (EPluginInputModeVkb != iLayoutContext->LayoutType())
       
   434         {
       
   435         iViewCharacterRange = new(ELeave) CPeninputJapaneseView;
       
   436         iViewCharacterRange->ConstructL();
       
   437         iCharacterRangeWnd = CPeninputJapaneseCandidateWnd::NewL(UiLayout(), EPeninutWindowCtrlIdCharacterRangePopupWindow, iViewCharacterRange);
       
   438         iCharacterRangeWnd->AddEventObserver(UiLayout());
       
   439         AddControlL(iCharacterRangeWnd);
       
   440         iCharacterRangeWnd->SetParent(NULL);
       
   441         iViewCharacterRange->SetListBox(iCharacterRangeWnd->ListBox());
       
   442         }
       
   443     }