fep/aknfep/UiPlugins/AknFepUiInterface/AvkonImpl/src/AknFepUiAvkonCtrlJapaneseCandidatePane.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     1 /*
       
     2 * Copyright (c) 2002-2004 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:            Candidate list
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 // INCLUDE FILES
       
    30 #include <eikdef.h>
       
    31 #include <aknViewAppUi.h>
       
    32 #include <avkon.hrh>
       
    33 #include <aknPopup.h>
       
    34 #include <aknlists.h>
       
    35 #include <aknPopupHeadingPane.h>
       
    36 #include <AknsDrawUtils.h>
       
    37 #include <AknsBasicBackgroundControlContext.h>
       
    38 #include <AknLayout.lag>
       
    39 #include <aknfep.rsg>
       
    40 
       
    41 #include <skinlayout.cdl.h>
       
    42 #include <AknLayout2ScalableDef.h>
       
    43 #include <aknlayoutscalable_avkon.cdl.h>
       
    44 #include <layoutmetadata.cdl.h>
       
    45 
       
    46 #include "AknFepUiInterfacePanic.h"
       
    47 #include "AknFepUIAvkonCtrlJapaneseCandidateListbox.h"
       
    48 #include "AknFepUIAvkonCtrlJapaneseCandidateHeadingPane.h"
       
    49 #include "AknFepUIAvkonCtrlJapaneseCandidatePane.h"
       
    50 #include "AknFepUIManagerJapanese.h"
       
    51 
       
    52 // CONSTANTS
       
    53 const TInt KMaxTitleLength = 32;
       
    54 
       
    55 const TInt KMaxListRows = 7;
       
    56 const TInt KMinListRows = 5;
       
    57 const TInt KMaxListColumns = 9;
       
    58 const TInt KMinListColumns = 3;
       
    59 const TInt KLAFBaseListColumns = 3;
       
    60 const TInt KLAFBaseListRows = 1;
       
    61 
       
    62 const TInt KLAFBelowTextBaseline = 2;
       
    63 const TInt KLAFAboveTextBaseline = 1;
       
    64 const TInt KListboxMarge = 4;
       
    65 
       
    66 /**
       
    67 *  CAknFepUICtrlJapaneseCandidatePane class.
       
    68 *
       
    69 */
       
    70 
       
    71 // ============================ MEMBER FUNCTIONS ===============================
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // CAknFepUICtrlJapaneseCandidatePane::NewL
       
    75 // Two-phased constructor.
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 CAknFepUICtrlJapaneseCandidatePane* CAknFepUICtrlJapaneseCandidatePane::NewL(CAknFepUIManagerJapanese* aUiMng)
       
    79     {
       
    80     CAknFepUICtrlJapaneseCandidatePane* self =
       
    81         new(ELeave) CAknFepUICtrlJapaneseCandidatePane(aUiMng);
       
    82     CleanupStack::PushL(self);
       
    83     self->ConstructL();
       
    84     CleanupStack::Pop(self);    // self
       
    85     return self;
       
    86     }
       
    87 
       
    88 // -----------------------------------------------------------------------------
       
    89 // CAknFepUICtrlJapaneseCandidatePane::~CAknFepUICtrlJapaneseCandidatePane
       
    90 // Destructor
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 CAknFepUICtrlJapaneseCandidatePane::~CAknFepUICtrlJapaneseCandidatePane()
       
    94     {
       
    95     if (IsVisible())
       
    96         {
       
    97         HideWindow();
       
    98         }
       
    99     if (iListBox)
       
   100         {
       
   101         delete iListBox;
       
   102         iListBox = NULL;
       
   103         }
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CAknFepUICtrlJapaneseCandidatePane::ShowWindow
       
   108 // Show Pop-up list
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CAknFepUICtrlJapaneseCandidatePane::ShowWindow()
       
   112     {
       
   113     RWindow& window=Window();
       
   114     //Set ordinal position to top
       
   115     window.SetOrdinalPosition(0,ECoeWinPriorityFep);
       
   116     window.SetFaded(EFalse, RWindowTreeNode::EFadeIncludeChildren);
       
   117     window.SetPointerCapture(ETrue);
       
   118     TRAP_IGNORE( ActivateL());
       
   119     MakeVisible(ETrue);
       
   120     DrawNow();
       
   121     }
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // CAknFepUICtrlJapaneseCandidatePane::CloseCandidateList
       
   125 // Close Pop-up list
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 void CAknFepUICtrlJapaneseCandidatePane::CloseCandidateList()
       
   129     {
       
   130     CancelPopup();
       
   131     }
       
   132 
       
   133 // -----------------------------------------------------------------------------
       
   134 // CAknFepUICtrlJapaneseCandidatePane::SetCurrentItemIndex
       
   135 // Specify the cursor position of a pop-up list.
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CAknFepUICtrlJapaneseCandidatePane::SetCurrentItemIndexL(
       
   139         TInt aItemIndex,
       
   140         TBool aDraw)
       
   141     {
       
   142     CTextListBoxModel* model =
       
   143         static_cast<CTextListBoxModel*>(ListBox()->Model());
       
   144     TInt numOfItem = model->NumberOfItems();
       
   145     TBuf<KMaxTitleLength> title;
       
   146     title.Format(_L("%d / %d"), aItemIndex + 1, numOfItem);
       
   147     SetTitleL(title);
       
   148 
       
   149     if (aDraw)
       
   150         {
       
   151         iListBox->SetCurrentItemIndexAndDraw(aItemIndex);
       
   152         iTitle->DrawNow();
       
   153         }
       
   154     else
       
   155         {
       
   156         iListBox->SetCurrentItemIndex(aItemIndex);
       
   157         }
       
   158 
       
   159     }
       
   160 
       
   161 // -----------------------------------------------------------------------------
       
   162 // CAknFepUICtrlJapaneseCandidatePane::SetOffsetPosition
       
   163 // Specify the display position of a pop-up list
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 void CAknFepUICtrlJapaneseCandidatePane::SetOffsetPosition(TPoint aOffset)
       
   167     {
       
   168     iOffsetPosition = aOffset;
       
   169     }
       
   170 
       
   171 // -----------------------------------------------------------------------------
       
   172 // CAknFepUICtrlJapaneseCandidatePane::SetWindowPosition
       
   173 // Set the drawing position for candidate list popup window
       
   174 // -----------------------------------------------------------------------------
       
   175 //
       
   176 void CAknFepUICtrlJapaneseCandidatePane::SetWindowPosition(
       
   177         const TPoint& aLeftSideOfBaseLine, TInt aHeight, TInt aAscent)
       
   178     {
       
   179     // getting rectangle for main pane
       
   180     TRect screen =
       
   181         TRect(0, 0,
       
   182               AKN_LAYOUT_WINDOW_screen.iW, AKN_LAYOUT_WINDOW_screen.iH);
       
   183     TAknLayoutRect main_pane;
       
   184     main_pane.LayoutRect(screen, AKN_LAYOUT_WINDOW_main_pane(screen, 0, 1, 1));
       
   185     iMainPaneRect = main_pane.Rect();
       
   186 
       
   187     TInt leftPos = aLeftSideOfBaseLine.iX;
       
   188     if (leftPos < 0)
       
   189         {
       
   190         leftPos = iOffsetPosition.iX;
       
   191         }
       
   192 
       
   193     TPoint windowOffset(
       
   194         leftPos,
       
   195         aLeftSideOfBaseLine.iY + aHeight - aAscent - iMainPaneRect.iTl.iY);
       
   196     SetOffsetPosition(windowOffset);
       
   197 
       
   198     iSrcTextHeight = aHeight;
       
   199     }
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // CAknFepUICtrlJapaneseCandidatePane::ShowCandidateListL
       
   203 // Show Pop-up list
       
   204 // -----------------------------------------------------------------------------
       
   205 //
       
   206 void CAknFepUICtrlJapaneseCandidatePane::ShowCandidateListL(
       
   207         CDesCArrayFlat* aItems, TInt aIndex, TInt aResourceID)
       
   208     {
       
   209     __ASSERT_DEBUG(aItems->Count() > 0,
       
   210                    AknFepUiInterfacePanic(EAknFepUiInterfacePanicCandidatesEmpty));
       
   211 
       
   212     // Set listitems.
       
   213     CTextListBoxModel* model =
       
   214         static_cast<CTextListBoxModel*>(ListBox()->Model());
       
   215     model->SetItemTextArray(aItems);
       
   216     model->SetOwnershipType(ELbmDoesNotOwnItemArray);
       
   217 
       
   218     iMaximumColumns = MaximumColumns(model);
       
   219     iMaximumRows    = MaximumRows(model);
       
   220 
       
   221     SetCurrentItemIndexL(aIndex, EFalse);
       
   222     SetMaximumHeight(iMaximumRows);
       
   223 
       
   224     CAknFepUICtrlJapaneseCandidateListbox* listBox =
       
   225         static_cast<CAknFepUICtrlJapaneseCandidateListbox*>(ListBox());
       
   226 
       
   227     listBox->SetMaximumColumns(iMaximumColumns);
       
   228 
       
   229     // Show popup list
       
   230     TBool notShowingPopup = model->NumberOfItems() == 0 && iWindowType < 0x80;
       
   231     if (!notShowingPopup)
       
   232         {
       
   233         const TSize screenSize=iCoeEnv->ScreenDevice()->SizeInPixels();
       
   234         iPopoutCba->SetBoundingRect(TRect(screenSize));
       
   235         }
       
   236 
       
   237     // Create a CBA for use with the popup
       
   238     if (aResourceID)
       
   239         {
       
   240         UpdateCbaL(aResourceID);
       
   241         }
       
   242 
       
   243     SetupWindowLayout(iWindowType);
       
   244 
       
   245     iListBox->SetListBoxObserver(this);
       
   246     iPopoutCba->MakeVisible(ETrue);
       
   247 
       
   248     if (iMarkable)
       
   249         {
       
   250         // If markable, set the popup to observe event change events.
       
   251         // Call HandleControlEvent to set the CBA appropriate to the 1st item
       
   252         iListBox->SetObserver(this);
       
   253         HandleControlEventL(iListBox, EEventStateChanged);
       
   254         }
       
   255 
       
   256     if (IsVisible())
       
   257         {
       
   258         DrawDeferred();
       
   259         }
       
   260     else
       
   261         {
       
   262         ShowWindow();
       
   263         ActivateL();
       
   264         ShowWindowCbaL();
       
   265         }
       
   266     }
       
   267 
       
   268 // -----------------------------------------------------------------------------
       
   269 // CAknFepUICtrlJapaneseCandidatePane::HideWindow
       
   270 // Hide Pop-up list
       
   271 // -----------------------------------------------------------------------------
       
   272 //
       
   273 void CAknFepUICtrlJapaneseCandidatePane::HideWindow()
       
   274     {
       
   275     MakeVisible(EFalse);
       
   276     Window().SetPointerCapture(EFalse);
       
   277 
       
   278     iEikonEnv->RemoveFromStack(iPopoutCba);
       
   279 
       
   280     iPopoutCba->MakeVisible(EFalse);
       
   281     }
       
   282 
       
   283 // -----------------------------------------------------------------------------
       
   284 // CAknFepUICtrlJapaneseCandidatePane::CurrentItemIndexOfCandidate
       
   285 // Return a selected candidate item number currently
       
   286 // -----------------------------------------------------------------------------
       
   287 //
       
   288 TInt CAknFepUICtrlJapaneseCandidatePane::CurrentItemIndexOfCandidate()
       
   289     {
       
   290     return iListBox->CurrentItemIndex();
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CAknFepUICtrlJapaneseCandidatePane::MoveItem
       
   295 // Move a current item in an appointed direction
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 TInt CAknFepUICtrlJapaneseCandidatePane::MoveItem(
       
   299         TAknFepUICtrlScroll aDirection)
       
   300     {
       
   301     __ASSERT_DEBUG(iListBox->IsVisible(),
       
   302                    AknFepUiInterfacePanic(EAknFepUiInterfacePanicNoCandidatePane));
       
   303 
       
   304     TInt index = iListBox->CurrentItemIndex();
       
   305 
       
   306     CTextListBoxModel* model =
       
   307         static_cast<CTextListBoxModel*>(ListBox()->Model());
       
   308     const TInt numberOfItems = model->NumberOfItems();
       
   309 
       
   310     switch(aDirection)
       
   311         {
       
   312         case EScrollUp:
       
   313             {
       
   314             --index;
       
   315             if (index < 0)
       
   316                 index = numberOfItems - 1;
       
   317             }
       
   318         break;
       
   319 
       
   320         case EScrollDown:
       
   321             {
       
   322             ++index;
       
   323             if (index >= numberOfItems)
       
   324                 index = 0;
       
   325             }
       
   326         break;
       
   327 
       
   328         default:
       
   329             {
       
   330             //Panic
       
   331             AknFepUiInterfacePanic(EAknFepUiInterfacePanicCandidatePaneNotSupportScrollDirection);
       
   332             }
       
   333         break;
       
   334         }
       
   335     TRAPD(err, SetCurrentItemIndexL(index, ETrue));
       
   336     if (err != KErrNone)
       
   337         {
       
   338         HideWindow();
       
   339         index = 0;
       
   340         }
       
   341     return index;
       
   342     }
       
   343 
       
   344 // -----------------------------------------------------------------------------
       
   345 // CAknFepUICtrlJapaneseCandidatePane::SetupWindowLayout
       
   346 // Set up a window layout type
       
   347 // -----------------------------------------------------------------------------
       
   348 //
       
   349 void CAknFepUICtrlJapaneseCandidatePane::SetupWindowLayout(
       
   350         AknPopupLayouts::TAknPopupLayouts /*aType*/)
       
   351     {
       
   352     HandleSizeChanged(Layout(), Heading(), ListBox(), this);
       
   353     }
       
   354 
       
   355 // -----------------------------------------------------------------------------
       
   356 // CAknFepUICtrlJapaneseCandidatePane::AttemptExitL
       
   357 // Set the title for the selection list
       
   358 // -----------------------------------------------------------------------------
       
   359 //
       
   360 void CAknFepUICtrlJapaneseCandidatePane::AttemptExitL(TBool aAccept)
       
   361     {
       
   362     if (iReturn) //Always not null unless ExecuteLD leaves
       
   363         *iReturn = aAccept;
       
   364     }
       
   365 
       
   366 // -----------------------------------------------------------------------------
       
   367 // CAknFepUICtrlJapaneseCandidatePane::MopSupplyObject
       
   368 // -----------------------------------------------------------------------------
       
   369 //
       
   370 TTypeUid::Ptr CAknFepUICtrlJapaneseCandidatePane::MopSupplyObject(TTypeUid aId)
       
   371     {
       
   372     SetMopParent( iEikonEnv->EikAppUi() );
       
   373     return CAknPopupList::MopSupplyObject(aId);
       
   374     }
       
   375 
       
   376 // -----------------------------------------------------------------------------
       
   377 // CAknFepUICtrlJapanesePredictivePane::CAknFepUICtrlJapanesePredictivePane
       
   378 // Constructor
       
   379 // -----------------------------------------------------------------------------
       
   380 //
       
   381 CAknFepUICtrlJapaneseCandidatePane::CAknFepUICtrlJapaneseCandidatePane(CAknFepUIManagerJapanese* aUiMng)
       
   382     : iUiMng(aUiMng)
       
   383     {
       
   384     }
       
   385 
       
   386 // -----------------------------------------------------------------------------
       
   387 // CAknFepUICtrlJapaneseCandidatePane::ConstructL
       
   388 // Symbian 2nd phase constructor can leave.
       
   389 // -----------------------------------------------------------------------------
       
   390 //
       
   391 void CAknFepUICtrlJapaneseCandidatePane::ConstructL()
       
   392     {
       
   393     // Create listbox.
       
   394     CAknFepUICtrlJapaneseCandidateListbox* list =
       
   395                 new(ELeave) CAknFepUICtrlJapaneseCandidateListbox;
       
   396     // "iListBox" member variable is defined in CAknPopupList class.
       
   397     iListBox = list;
       
   398     CAknPopupList::ConstructL(
       
   399         iListBox, R_AKNFEP_SOFTKEYS_EMPTY_EMPTY_COMMIT, AknPopupLayouts::EMenuWindow);
       
   400 
       
   401     list->ConstructL(this, CEikListBox::ELeftDownInViewRect);
       
   402     list->CreateScrollBarFrameL(ETrue);
       
   403     list->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   404                                 CEikScrollBarFrame::EOff,
       
   405                                 CEikScrollBarFrame::EAuto);
       
   406     iEikonEnv->RemoveFromStack(this);
       
   407     SetNonFocusing();
       
   408     MakeVisible(EFalse);
       
   409     }
       
   410 
       
   411 // -----------------------------------------------------------------------------
       
   412 // CAknFepUICtrlJapaneseCandidatePane::SetTitleL
       
   413 // Set the title for the selection list
       
   414 // -----------------------------------------------------------------------------
       
   415 //
       
   416 void CAknFepUICtrlJapaneseCandidatePane::SetTitleL(const TDesC& aTitle)
       
   417     {
       
   418     if (!iTitle)
       
   419         {
       
   420         iTitle = new(ELeave) CAknFepUICtrlJapaneseCandidateHeadingPane;
       
   421         iTitle->SetContainerWindowL(*this);
       
   422         iTitle->ConstructL(aTitle);
       
   423         iTitle->SetMopParent(iListBox);
       
   424         }
       
   425     else
       
   426         {
       
   427         iTitle->SetTextL(aTitle);
       
   428         }
       
   429     }
       
   430 
       
   431 // -----------------------------------------------------------------------------
       
   432 // CAknFepUICtrlJapaneseCandidatePane::HandleSizeChanged
       
   433 // The handler function for size change
       
   434 // Original function is AknPopupLayouts::HandleSizeChanged()
       
   435 // -----------------------------------------------------------------------------
       
   436 //
       
   437 void CAknFepUICtrlJapaneseCandidatePane::HandleSizeChanged(
       
   438         TAknPopupWindowLayoutDef &aDef,
       
   439         CAknPopupHeadingPane *aHeading,
       
   440         CEikListBox *aListBox,
       
   441         CCoeControl *aWindowOwningControl)
       
   442     {
       
   443     if ( aHeading )
       
   444         {
       
   445         aHeading->SetLayout( CAknPopupHeadingPane::EListHeadingPane );
       
   446         aHeading->SetSkinFrameId(TAknsItemID());
       
   447         aHeading->SetSkinFrameCenterId(TAknsItemID());
       
   448         }
       
   449 
       
   450     TInt numofitems = aListBox->Model()->NumberOfItems();
       
   451 
       
   452     TInt minItems = iMaximumRows;
       
   453     TInt maxItems = KMaxListRows;
       
   454 
       
   455     if (aDef.iMaximumHeight)
       
   456         {
       
   457         maxItems = aDef.iMaximumHeight;
       
   458         }
       
   459     AknPopupLayouts::CheckRange(numofitems, minItems, maxItems);
       
   460     CalcPopupMenuWindow(aDef, iMainPaneRect, numofitems);
       
   461     SetupMenuPopupWindow(aDef, numofitems, aHeading != 0);
       
   462 
       
   463     CAknFepUICtrlJapaneseCandidateListbox* listbox =
       
   464         static_cast<CAknFepUICtrlJapaneseCandidateListbox*>(aListBox);
       
   465     listbox->SetMaximumColumns(iMaximumColumns);
       
   466     listbox->SetMaximumRows(iMaximumRows);
       
   467     SetMaximumHeight(iMaximumRows);
       
   468 
       
   469     aWindowOwningControl->SetRect(AknPopupLayouts::WindowRect(aDef));
       
   470     HandleSizeAndPositionOfComponents(aDef, aListBox, aHeading);
       
   471 
       
   472     TRect windowRect = AknPopupLayouts::WindowRect(aDef);
       
   473     MAknsControlContext *cc = AknsDrawUtils::ControlContext( aListBox );
       
   474     TBool defaultContext = EFalse;
       
   475     if (!cc)
       
   476         {
       
   477         cc = aListBox->View()->ItemDrawer()->SkinBackgroundControlContext();
       
   478         defaultContext = ETrue;
       
   479         }
       
   480 
       
   481     if (cc)
       
   482         {
       
   483         CAknsBasicBackgroundControlContext *bcc =
       
   484             (CAknsBasicBackgroundControlContext*)cc;
       
   485         TAknLayoutRect popupBgRect;
       
   486         popupBgRect.LayoutRect(
       
   487             windowRect,
       
   488             ELayoutEmpty,
       
   489             0, 0, ELayoutEmpty, ELayoutEmpty,
       
   490             windowRect.Size().iWidth, windowRect.Size().iHeight);
       
   491         bcc->SetBitmap(KAknsIIDQsnFrPopupCenter);
       
   492         if (defaultContext)
       
   493             {
       
   494             bcc->SetRect(popupBgRect.Rect());
       
   495             }
       
   496         bcc->SetParentPos(aWindowOwningControl->PositionRelativeToScreen());
       
   497         if (defaultContext)
       
   498             {
       
   499             bcc->SetParentPos(TPoint(0,0));
       
   500             }
       
   501         }
       
   502      }
       
   503 
       
   504 // -----------------------------------------------------------------------------
       
   505 // CAknFepUICtrlJapaneseCandidatePane::HandleDraw
       
   506 // The handler function for Draw
       
   507 // Original function is AknPopupLayouts::HandleDraw()
       
   508 // -----------------------------------------------------------------------------
       
   509 //
       
   510 void CAknFepUICtrlJapaneseCandidatePane::HandleDraw(CEikonEnv* /*aEikEnv*/,
       
   511                   CWindowGc& aGc,
       
   512                   const TAknPopupWindowLayoutDef& aDef,
       
   513                   CEikListBox* aListBox,
       
   514                   CAknPopupHeadingPane* aHeading)
       
   515     {
       
   516     TRect windowRect =
       
   517         AknPopupLayouts::MenuRect(const_cast<TAknPopupWindowLayoutDef&>(aDef));
       
   518     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
   519     MAknsControlContext *cc = AknsDrawUtils::ControlContext( aListBox );
       
   520     TBool windowFrameDrawn = EFalse;
       
   521     if (!cc)
       
   522         {
       
   523         cc = aListBox->View()->ItemDrawer()->SkinBackgroundControlContext();
       
   524         }
       
   525 
       
   526     if (cc)
       
   527         {
       
   528 		TRegionFix<2> dontDrawRegion;
       
   529 		TRegionFix<8> drawRegion;
       
   530 		if ( aListBox )
       
   531 		    {
       
   532 	    	dontDrawRegion.AddRect( aListBox->Rect() );
       
   533 		    }
       
   534 		if ( aHeading )
       
   535 		    {
       
   536 	    	dontDrawRegion.AddRect( aHeading->Rect() );
       
   537 		    }
       
   538 		drawRegion.AddRect( windowRect );
       
   539 		drawRegion.SubRegion( dontDrawRegion );
       
   540 
       
   541 		const TAknsItemID *popupBgId = &KAknsIIDQsnBgPopupBackground;
       
   542 		TAknLayoutRect popupBgRect;
       
   543         popupBgRect.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__background_slice__Line_1(windowRect));
       
   544 		AknsDrawUtils::DrawCachedImage(skin, aGc, popupBgRect.Rect(), *popupBgId);
       
   545 
       
   546 		const TAknsItemID *sliceId = &KAknsIIDQsnBgSlicePopup;
       
   547 		TAknLayoutRect sliceRect;
       
   548         sliceRect.LayoutRect(windowRect, SkinLayout::Popup_windows_skin_placing__background_slice__Line_2());
       
   549 		AknsDrawUtils::DrawCachedImage(skin, aGc, sliceRect.Rect(), *sliceId);
       
   550 
       
   551         // drawing frame
       
   552         TAknLayoutRect topLeft;
       
   553         topLeft.LayoutRect(
       
   554             windowRect,
       
   555             ELayoutEmpty, 0,0, ELayoutEmpty, ELayoutEmpty, KListboxMarge, KListboxMarge);
       
   556 
       
   557         TAknLayoutRect bottomRight;
       
   558         bottomRight.LayoutRect(
       
   559             windowRect,
       
   560             ELayoutEmpty,
       
   561             ELayoutEmpty, ELayoutEmpty, 0, 0, KListboxMarge, KListboxMarge);
       
   562 
       
   563         TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
       
   564         TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
       
   565         aGc.SetPenStyle(CGraphicsContext::ENullPen);
       
   566         const TAknsItemID *frameId = &KAknsIIDQsnFrPopup;
       
   567         const TAknsItemID *frameCenterId = &KAknsIIDQsnFrPopupCenter;
       
   568 		aGc.SetClippingRegion( drawRegion );
       
   569         windowFrameDrawn =
       
   570             AknsDrawUtils::DrawFrame(
       
   571                 skin, aGc,
       
   572                 outerRect, innerRect, *frameId, *frameCenterId);
       
   573 		aGc.CancelClippingRegion();
       
   574         }
       
   575 
       
   576     if (!windowFrameDrawn)
       
   577         {
       
   578         DrawWindowShadow(
       
   579             aGc, aDef.iCover,
       
   580             aDef.iSecond, aDef.iFirst, aDef.iOutline, aDef.iInside);
       
   581         }
       
   582     }
       
   583 
       
   584 // -----------------------------------------------------------------------------
       
   585 // CAknFepUICtrlJapaneseCandidatePane::CalcPopupMenuWindow
       
   586 // Set up the information on a pop-up window
       
   587 // Original function is AknPopupLayouts::CalcPopupMenuWindow()
       
   588 // -----------------------------------------------------------------------------
       
   589 //
       
   590 void CAknFepUICtrlJapaneseCandidatePane::CalcPopupMenuWindow(
       
   591         TAknPopupWindowLayoutDef &aDef,const TRect& aRect, TInt /*num*/)
       
   592     {
       
   593     TAknLayoutRect popup_menu_window;
       
   594 
       
   595     TBool sizeDesideFlag = EFalse;
       
   596     TInt adjustOffsetX = 0;
       
   597     TInt adjustOffsetY = 0;
       
   598     TInt i;
       
   599     TAknWindowLineLayout lafwidth =
       
   600         AknLayoutScalable_Avkon::popup_fep_japan_candidate_window(iMaximumColumns - KLAFBaseListColumns).LayoutLine();
       
   601 
       
   602     // calculating the number of indication line again in order to be able to arrange under a plan position
       
   603     for (i = iMaximumRows; i >= KLAFBaseListRows && !sizeDesideFlag; i--)
       
   604         {
       
   605         TAknWindowLineLayout laf =
       
   606             AknLayoutScalable_Avkon::popup_fep_japan_candidate_window(i).LayoutLine();
       
   607         laf.il = 0;
       
   608         laf.it = 0;
       
   609         laf.iW = lafwidth.iW;
       
   610         popup_menu_window.LayoutRect(aRect, laf);
       
   611         // calculate a drawing position Y
       
   612         TInt drawY = iMainPaneRect.iTl.iY + iOffsetPosition.iY
       
   613                          + KLAFBelowTextBaseline + popup_menu_window.Rect().Height();
       
   614         if (drawY < iMainPaneRect.iBr.iY)
       
   615             {
       
   616             adjustOffsetY = (-1) * KLAFBelowTextBaseline;
       
   617             iMaximumRows = i;
       
   618             sizeDesideFlag = ETrue;
       
   619             }
       
   620         if (iMaximumRows >= KMinListRows && i == KMinListRows)
       
   621             {
       
   622             break;
       
   623             }
       
   624         }
       
   625 
       
   626     // if popup window cannot be arranged under a plan positon, it try whether popup is arranged top or not.
       
   627     //
       
   628     for (i = iMaximumRows; i >= KLAFBaseListRows && !sizeDesideFlag; i--)
       
   629         {
       
   630         TAknWindowLineLayout laf =
       
   631             AknLayoutScalable_Avkon::popup_fep_japan_candidate_window(i).LayoutLine();
       
   632         laf.il = 0;
       
   633         laf.it = 0;
       
   634         laf.iW = lafwidth.iW;
       
   635         popup_menu_window.LayoutRect(aRect, laf);
       
   636         // calculate a drawing position Y
       
   637         TInt drawY = iMainPaneRect.iTl.iY + iOffsetPosition.iY - KLAFAboveTextBaseline
       
   638                     - iSrcTextHeight - popup_menu_window.Rect().Height();
       
   639         if (drawY > iMainPaneRect.iTl.iY)
       
   640             {
       
   641             adjustOffsetY = iSrcTextHeight + KLAFAboveTextBaseline + popup_menu_window.Rect().Height();
       
   642             iMaximumRows = i;
       
   643             sizeDesideFlag = ETrue;
       
   644             }
       
   645         if (iMaximumRows >= KMinListRows && i == KMinListRows)
       
   646             {
       
   647             break;
       
   648             }
       
   649         }
       
   650 
       
   651     // In case popup window cannot be arrange both under and top,
       
   652     // popup is shown on the bottom on screen.
       
   653     if (!sizeDesideFlag)
       
   654         {
       
   655         TAknWindowLineLayout laf =
       
   656             AknLayoutScalable_Avkon::popup_fep_japan_candidate_window(KMinListRows).LayoutLine();
       
   657         laf.il = 0;
       
   658         laf.it = 0;
       
   659         laf.iW = lafwidth.iW;
       
   660         popup_menu_window.LayoutRect(aRect, laf);
       
   661         adjustOffsetY = iMainPaneRect.iTl.iY + iOffsetPosition.iY + KLAFBelowTextBaseline
       
   662                       + popup_menu_window.Rect().Height()
       
   663                       - iMainPaneRect.iBr.iY;
       
   664         iMaximumRows = KMinListRows;
       
   665         sizeDesideFlag = ETrue;
       
   666         }
       
   667 
       
   668     adjustOffsetX =
       
   669         iMainPaneRect.iTl.iX
       
   670         + iOffsetPosition.iX
       
   671         + popup_menu_window.Rect().Width() - iMainPaneRect.iBr.iX;
       
   672     adjustOffsetX = (adjustOffsetX > 0) ? adjustOffsetX : 0;
       
   673     TPoint adjustOffset(-adjustOffsetX, -adjustOffsetY);
       
   674 
       
   675     aDef.iWindowRect = popup_menu_window.Rect();
       
   676     aDef.iWindowRect.Move(iOffsetPosition);
       
   677     aDef.iWindowRect.Move(adjustOffset);
       
   678 
       
   679     // getting a information of shadow in candidate list
       
   680     TRect window_rect = AknPopupLayouts::MenuRect(aDef);
       
   681 
       
   682     TAknWindowLineLayout laf1 =
       
   683         AKN_LAYOUT_WINDOW_Candidate_selection_pop_up_window_graphics_Line_1(
       
   684             aDef.iWindowRect);
       
   685     laf1.iW = TInt16(aDef.iWindowRect.Width());
       
   686     TAknWindowLineLayout laf2 =
       
   687         AKN_LAYOUT_WINDOW_Candidate_selection_pop_up_window_graphics_Line_2(
       
   688             aDef.iWindowRect);
       
   689     laf2.iW = TInt16(aDef.iWindowRect.Width() - 4);
       
   690     TAknWindowLineLayout laf3 =
       
   691         AKN_LAYOUT_WINDOW_Candidate_selection_pop_up_window_graphics_Line_3(
       
   692             aDef.iWindowRect);
       
   693     laf3.iW = TInt16(aDef.iWindowRect.Width() - 3);
       
   694     TAknWindowLineLayout laf4 =
       
   695         AKN_LAYOUT_WINDOW_Candidate_selection_pop_up_window_graphics_Line_4(
       
   696             aDef.iWindowRect);
       
   697     laf4.iW = TInt16(aDef.iWindowRect.Width() - 5);
       
   698 
       
   699     aDef.iCover.LayoutRect(window_rect, laf1);
       
   700     aDef.iSecond.LayoutRect(window_rect, laf2);
       
   701     aDef.iFirst.LayoutRect(window_rect, laf2);
       
   702     aDef.iOutline.LayoutRect(window_rect, laf3);
       
   703     aDef.iInside.LayoutRect(window_rect, laf4);
       
   704     aDef.iPopupMenuWindowOffset = TPoint(0, 0);
       
   705     }
       
   706 
       
   707 // -----------------------------------------------------------------------------
       
   708 // CAknFepUICtrlJapaneseCandidatePane::SetupMenuPopupWindow
       
   709 // Set up the information on a pop-up window
       
   710 // Original function is AknPopupLayouts::SetupMenuPopupWindow()
       
   711 // -----------------------------------------------------------------------------
       
   712 //
       
   713 void CAknFepUICtrlJapaneseCandidatePane::SetupMenuPopupWindow(
       
   714         TAknPopupWindowLayoutDef &aDef, TInt /*num*/, TBool /*heading*/)
       
   715     {
       
   716     AknPopupLayouts::SetupDefaults(aDef);
       
   717     TRect window_rect = AknPopupLayouts::MenuRect(aDef);
       
   718 
       
   719     // setting window size of listbox pane
       
   720     // Those arguments aren't used in it.
       
   721     TAknWindowLineLayout laf = AKN_LAYOUT_WINDOW_candidate_pane(0,0);
       
   722     TAknWindowLineLayout textWindowLayout =
       
   723         AKN_LAYOUT_WINDOW_list_single_popup_jap_candidate_pane(0,0);
       
   724     laf.ib = ELayoutEmpty;
       
   725     laf.iH = iMaximumRows * textWindowLayout.iH;
       
   726     aDef.iListRect.LayoutRect(window_rect, laf);
       
   727 
       
   728     // setting window size of heading pane
       
   729     //   calculating window size of heading pane based on a shadow of popup window
       
   730     //
       
   731     TAknTextLineLayout lafHead =
       
   732         AknLayoutScalable_Avkon::popup_fep_japan_candidate_window_t1().LayoutLine();
       
   733 
       
   734     TRect rectFirstShadow = aDef.iFirst.Rect();
       
   735     TRect rectListBox     = aDef.iListRect.Rect();
       
   736     laf.it = (TInt16)(rectFirstShadow.iTl.iY - window_rect.iTl.iY);
       
   737     laf.ib = ELayoutEmpty;
       
   738     laf.iH = (TInt16)(rectListBox.iTl.iY - rectFirstShadow.iTl.iY);
       
   739     aDef.iHeadingRect.LayoutRect(window_rect, laf);
       
   740 
       
   741     CAknFepUICtrlJapaneseCandidateHeadingPane* headingPane =
       
   742         static_cast<CAknFepUICtrlJapaneseCandidateHeadingPane*>(Heading());
       
   743     headingPane->SetParentRect(aDef.iWindowRect);
       
   744     }
       
   745 
       
   746 // -----------------------------------------------------------------------------
       
   747 // CAknFepUICtrlJapaneseCandidatePane::HandleSizeAndPositionOfComponents
       
   748 // The handler function for size and a location
       
   749 // Original function is AknPopupLayouts::HandleSizeAndPositionOfComponents()
       
   750 //
       
   751 //
       
   752 // -----------------------------------------------------------------------------
       
   753 //
       
   754 void CAknFepUICtrlJapaneseCandidatePane::HandleSizeAndPositionOfComponents(
       
   755         const TAknPopupWindowLayoutDef &aDef,
       
   756         CCoeControl *aContent,
       
   757         CAknPopupHeadingPane *aHeading)
       
   758     {
       
   759     TRect lbrect = aDef.iListRect.Rect();
       
   760     TRect headrect;
       
   761 
       
   762    if (AknLayoutUtils::ScalableLayoutInterfaceAvailable())
       
   763         {
       
   764         // set scroll size
       
   765         CAknFepUICtrlJapaneseCandidateListbox* listBox =
       
   766             static_cast<CAknFepUICtrlJapaneseCandidateListbox*>(aContent);
       
   767         CTextListBoxModel* model = static_cast<CTextListBoxModel*>(listBox->Model());
       
   768         const TInt items = model->NumberOfItems();
       
   769         if (items > listBox->MaximumRows())
       
   770             {
       
   771             TAknWindowLineLayout scrollllinelayout = AknLayoutScalable_Avkon::scroll_pane_cp30().LayoutLine();
       
   772             lbrect.iBr.iX -= scrollllinelayout.iW;
       
   773             }
       
   774         }
       
   775 
       
   776     // set listbox view rectangle
       
   777     aContent->SetRect(lbrect);
       
   778     if (aHeading)
       
   779         {
       
   780         headrect = aDef.iHeadingRect.Rect();
       
   781         aHeading->SetRect(headrect);
       
   782         }
       
   783 
       
   784     }
       
   785 
       
   786 // -----------------------------------------------------------------------------
       
   787 // CAknFepUICtrlJapaneseCandidatePane::DrawWindowShadow
       
   788 // Draw window shadow
       
   789 //
       
   790 // Original function is AknDrawWithSkins::DrawWindowShadow()
       
   791 // -----------------------------------------------------------------------------
       
   792 //
       
   793 void CAknFepUICtrlJapaneseCandidatePane::DrawWindowShadow(
       
   794         CWindowGc &aGc,
       
   795         const TAknLayoutRect &aCoverRect,
       
   796         const TAknLayoutRect &aSecondShadowRect,
       
   797         const TAknLayoutRect &aFirstShadowRect,
       
   798         const TAknLayoutRect &aOutlineFrameRect,
       
   799         const TAknLayoutRect &aInsideAreaRect)
       
   800     {
       
   801     MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
   802 
       
   803     TInt x2 = aFirstShadowRect.Rect().iTl.iX;
       
   804     TInt x3 = aSecondShadowRect.Rect().iTl.iX;
       
   805 
       
   806     TInt y2 = aFirstShadowRect.Rect().iTl.iY;
       
   807     TInt y3 = aSecondShadowRect.Rect().iTl.iY;
       
   808 
       
   809     TInt x4 = aOutlineFrameRect.Rect().iBr.iX;
       
   810     TInt x5 = aFirstShadowRect.Rect().iBr.iX;
       
   811     TInt x6 = aSecondShadowRect.Rect().iBr.iX;
       
   812 
       
   813     TInt y4 = aOutlineFrameRect.Rect().iBr.iY;
       
   814     TInt y5 = aFirstShadowRect.Rect().iBr.iY;
       
   815     TInt y6 = aSecondShadowRect.Rect().iBr.iY;
       
   816 
       
   817     aGc.SetBrushColor(aCoverRect.Color());
       
   818     AknsDrawUtils::Background(skin, NULL, NULL, aGc, aCoverRect.Rect());
       
   819     AknsDrawUtils::BackgroundBetweenRects(
       
   820         skin, NULL, NULL, aGc,
       
   821         TRect(x2,y2,x4-1,y4-1), aInsideAreaRect.Rect());
       
   822 
       
   823     aOutlineFrameRect.DrawOutLineRect(aGc);
       
   824     aGc.SetBrushColor(aFirstShadowRect.Color());
       
   825     aGc.Clear(TRect(x2,y4,x5,y5));
       
   826     aGc.Clear(TRect(x4,y2,x5,y4));
       
   827     aGc.SetBrushColor(aSecondShadowRect.Color());
       
   828     aGc.Clear(TRect(x3,y5,x6,y6));
       
   829     aGc.Clear(TRect(x5,y3,x6,y5));
       
   830     }
       
   831 
       
   832 // -----------------------------------------------------------------------------
       
   833 // CAknFepUICtrlJapaneseCandidatePane::MaximumColumns
       
   834 // This function returns maximum columns to be able to display in listbox.
       
   835 // -----------------------------------------------------------------------------
       
   836 TInt CAknFepUICtrlJapaneseCandidatePane::MaximumColumns(
       
   837         CTextListBoxModel* aModel)
       
   838     {
       
   839     TInt maximumCharacters = 0;
       
   840     TInt numberOfItems = aModel->NumberOfItems();
       
   841     TInt i;
       
   842     for (i = 0; i < numberOfItems; i++)
       
   843         {
       
   844         TPtrC text = aModel->ItemText(i);
       
   845         TInt textLength = text.Length();
       
   846         if (maximumCharacters < textLength)
       
   847             {
       
   848             maximumCharacters = textLength;
       
   849             }
       
   850         }
       
   851 
       
   852     TInt maximumColumns = Min(KMaxListColumns, maximumCharacters);
       
   853     maximumColumns = Max(KMinListColumns, maximumColumns);
       
   854 
       
   855     return maximumColumns;
       
   856     }
       
   857 
       
   858 // -----------------------------------------------------------------------------
       
   859 // CAknFepUICtrlJapaneseCandidatePane::MaximumRows
       
   860 // This function returns maximum rows to be able to display in listbox.
       
   861 // -----------------------------------------------------------------------------
       
   862 TInt CAknFepUICtrlJapaneseCandidatePane::MaximumRows(
       
   863         CTextListBoxModel* aModel)
       
   864     {
       
   865     TInt numberOfItems = aModel->NumberOfItems();
       
   866     TInt maximumRows = Min(KMaxListRows, numberOfItems);
       
   867 
       
   868     return maximumRows;
       
   869     }
       
   870 
       
   871 // -----------------------------------------------------------------------------
       
   872 // CAknFepUICtrlJapaneseCandidatePane::Draw
       
   873 // Called by the framework to draw the control
       
   874 // -----------------------------------------------------------------------------
       
   875 //
       
   876 void CAknFepUICtrlJapaneseCandidatePane::Draw(const TRect& /*aRect*/) const
       
   877     {
       
   878     CWindowGc& gc = SystemGc();
       
   879     gc.Clear();
       
   880     HandleDraw(iEikonEnv, gc, Layout(), iListBox, Heading());
       
   881     }
       
   882 
       
   883 // -----------------------------------------------------------------------------
       
   884 // CAknFepUICtrlJapaneseCandidatePane::OfferKeyEventL
       
   885 // Handle key events. When a key event occurs
       
   886 // -----------------------------------------------------------------------------
       
   887 //
       
   888 TKeyResponse CAknFepUICtrlJapaneseCandidatePane::OfferKeyEventL(
       
   889         const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/)
       
   890     {
       
   891     return EKeyWasNotConsumed;
       
   892     }
       
   893 
       
   894 void CAknFepUICtrlJapaneseCandidatePane::ShowWindowCbaL()
       
   895     {
       
   896     RDrawableWindow* cbaWindow = iPopoutCba->ButtonGroup()->AsControl()->DrawableWindow();
       
   897     cbaWindow->SetOrdinalPosition(0,ECoeWinPriorityFep);
       
   898     cbaWindow->SetFaded(EFalse, RWindowTreeNode::EFadeWindowOnly);
       
   899     cbaWindow->SetNonFading(ETrue);
       
   900     iEikonEnv->EikAppUi()->AddToStackL(iPopoutCba,
       
   901                                        ECoeStackPriorityFep,
       
   902                                        ECoeStackFlagRefusesFocus);
       
   903     iPopoutCba->ActivateL();
       
   904     iPopoutCba->MakeVisible(ETrue);
       
   905     iPopoutCba->DrawDeferred(); // to update the cba
       
   906     }
       
   907 
       
   908 // -----------------------------------------------------------------------------
       
   909 // CAknFepUICtrlJapaneseCandidatePane::ProcessCommandL
       
   910 // Processes events from the softkeys. Responds to EAknSoftkeyOk and EAknSoftkeyBack
       
   911 // -----------------------------------------------------------------------------
       
   912 //
       
   913 void CAknFepUICtrlJapaneseCandidatePane::ProcessCommandL(TInt aCommandId)
       
   914     {
       
   915     // Respond to softkey events
       
   916     switch (aCommandId)
       
   917         {
       
   918         case EAknFepSoftkeyCommit:
       
   919             iUiMng->HandleCommandL(aCommandId);
       
   920             break;
       
   921         case EAknFepSoftkeyRetroActiveHalf:
       
   922         case EAknFepSoftkeyRetroActiveFull:
       
   923             iUiMng->HandleCommandL(aCommandId);
       
   924             break;
       
   925         default:
       
   926             CAknPopupList::ProcessCommandL(aCommandId);
       
   927             break;
       
   928         }
       
   929     }
       
   930 
       
   931 // -----------------------------------------------------------------------------
       
   932 // CAknFepUICtrlJapaneseCandidatePane::UpdateCbaL
       
   933 // Changing the cba
       
   934 // -----------------------------------------------------------------------------
       
   935 //
       
   936 void CAknFepUICtrlJapaneseCandidatePane::UpdateCbaL(TInt aResourceID)
       
   937     {
       
   938     if (iCurrentResource == aResourceID)
       
   939         {
       
   940         return;
       
   941         }
       
   942 
       
   943     // store resource id
       
   944     iPopoutCba->SetCommandSetL( aResourceID );
       
   945     iCurrentResource = aResourceID;
       
   946     iPopoutCba->DrawDeferred();
       
   947     }
       
   948 
       
   949 // CallBack from ListBox
       
   950 // ---------------------------------------------------------------------------
       
   951 // CAknFepUICtrlJapaneseCandidatePane::HandleListBoxEventL
       
   952 // (other items were commented in a header).
       
   953 // ---------------------------------------------------------------------------
       
   954 //
       
   955 void CAknFepUICtrlJapaneseCandidatePane::HandleListBoxEventL(
       
   956     CEikListBox* /*aListBox*/, TListBoxEvent aEventType)
       
   957     {
       
   958     switch (aEventType)
       
   959         {
       
   960         case EEventItemDraggingActioned: // Item Moved
       
   961             DrawNow();
       
   962             break;
       
   963         case EEventItemClicked:
       
   964             {
       
   965             TKeyEvent ccpuStart = {EKeyOK, EStdKeyDevice3, 0, 0};
       
   966             iEikonEnv->SimulateKeyEventL(ccpuStart, EEventKey);
       
   967             }
       
   968             break;
       
   969         default:
       
   970            break;
       
   971         }
       
   972     }
       
   973 // End of File