textinput/peninputcommonctrlsjp/src/peninputjapanesecandidatecelllistboxdata.cpp
changeset 0 eb1f2e154e89
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:  Candidate list CellListBoxData
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <AknBidiTextUtils.h>  // KAknBidiExtraSpacePerLine
       
    20 #include <AknUtils.h>  // KMaxColumnDataLength others
       
    21 
       
    22 #include "peninputjapanesecandidatecelllistboxdata.h"
       
    23 
       
    24 const TInt KLayoutTempValue_5 = 5;
       
    25 
       
    26 // ============================ MEMBER FUNCTIONS ===============================
       
    27 
       
    28 // -----------------------------------------------------------------------------
       
    29 // CPeninputJapaneseCandidateCellListBoxData::NewL
       
    30 // Two-phased constructor.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 CPeninputJapaneseCandidateCellListBoxData*
       
    34     CPeninputJapaneseCandidateCellListBoxData::NewL()
       
    35     {
       
    36     CPeninputJapaneseCandidateCellListBoxData* self =
       
    37             new(ELeave) CPeninputJapaneseCandidateCellListBoxData;
       
    38     self->ConstructLD();
       
    39     return self;
       
    40     }
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // CPeninputJapaneseCandidateCellListBoxData::Draw
       
    44 // Draw items
       
    45 // -----------------------------------------------------------------------------
       
    46 //
       
    47 void CPeninputJapaneseCandidateCellListBoxData::Draw(
       
    48         TListItemProperties aProperties,
       
    49         CWindowGc& aGc,
       
    50         const TDesC* aText,
       
    51         const TRect& aRect,
       
    52         TBool aHighlight, 
       
    53         const TColors& aColors) const
       
    54     {
       
    55     const TRect &aItemRect = aRect;
       
    56 
       
    57     DrawDefaultHighlight(aGc, aItemRect, aHighlight);
       
    58 
       
    59     // Draw the actual items.
       
    60     DrawFormattedCandidate(aProperties, aGc, aText, aItemRect, aHighlight, aColors);
       
    61 
       
    62     aGc.Reset();
       
    63 
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CPeninputJapaneseCandidateCellListBoxData::DrawDefaultHighlight
       
    68 // Draw highlight item
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CPeninputJapaneseCandidateCellListBoxData::DrawDefaultHighlight(
       
    72         CWindowGc& aGc,
       
    73         const TRect& aItemRect,
       
    74         TBool aHighlight) const
       
    75     {
       
    76     if (aHighlight)
       
    77         {
       
    78         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
    79         TBool highlightDrawn = EFalse;
       
    80         MAknsControlContext* cc = AknsDrawUtils::ControlContext(Control());
       
    81         if (cc)
       
    82             {
       
    83             TAknLayoutRect topLeft;
       
    84             topLeft.LayoutRect(aItemRect,
       
    85                                ELayoutEmpty,
       
    86                                1, 1, ELayoutEmpty, ELayoutEmpty, KLayoutTempValue_5, KLayoutTempValue_5);
       
    87 
       
    88             TAknLayoutRect bottomRight;
       
    89             bottomRight.LayoutRect(aItemRect,
       
    90                                    ELayoutEmpty,
       
    91                                    ELayoutEmpty, ELayoutEmpty, 1, 0, KLayoutTempValue_5,KLayoutTempValue_5);
       
    92 
       
    93             TRect outerRect =
       
    94                         TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
       
    95             TRect innerRect =
       
    96                         TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
       
    97             aGc.SetPenStyle(CGraphicsContext::ENullPen);
       
    98 
       
    99             const TAknsItemID* skinHighlightFrameId =
       
   100                                                 &KAknsIIDQsnFrList;
       
   101             const TAknsItemID* skinHighlightFrameCenterId =
       
   102                                                 &KAknsIIDQsnFrListCenter;
       
   103             highlightDrawn = AknsDrawUtils::DrawFrame(
       
   104                                                 skin,
       
   105                                                 aGc,
       
   106                                                 outerRect, innerRect,
       
   107                                                 *skinHighlightFrameId,
       
   108                                                 *skinHighlightFrameCenterId);
       
   109             }
       
   110 
       
   111         if (!highlightDrawn)
       
   112             {
       
   113             TAknLayoutRect highlightshadow;
       
   114             TAknLayoutRect highlight;
       
   115             highlightshadow.LayoutRect(
       
   116                     aItemRect,
       
   117                     AKN_LAYOUT_WINDOW_List_pane_highlight_graphics__various__Line_1(aItemRect));
       
   118             highlight.LayoutRect(
       
   119                     aItemRect,
       
   120                     AKN_LAYOUT_WINDOW_List_pane_highlight_graphics__various__Line_2(aItemRect));
       
   121 
       
   122             highlightshadow.DrawRect(aGc);
       
   123             highlight.DrawRect(aGc);
       
   124             }
       
   125         }
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CPeninputJapaneseCandidateCellListBoxData::DrawFormattedCandidate
       
   130 // Draw one item
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 void CPeninputJapaneseCandidateCellListBoxData::DrawFormattedCandidate( TListItemProperties&/* aProperties*/,
       
   134                                           CWindowGc& aGc,
       
   135                                           const TDesC* aText,
       
   136                                           const TRect& aItemRect,
       
   137                                           TBool /*aHighlight*/,
       
   138                                           const TColors& aColors ) const
       
   139     {
       
   140     TRect textRect(aItemRect);
       
   141     textRect.iTl.iX += 3;
       
   142     
       
   143     const CFont* font=SubCellFont(0);
       
   144     if (font==NULL)
       
   145         {
       
   146         font=CEikonEnv::Static()->NormalFont();
       
   147         }
       
   148     
       
   149     TInt extraVerticalSpace=(textRect.Height()-font->HeightInPixels());
       
   150     TInt baseLineOffset=extraVerticalSpace/2+font->AscentInPixels();
       
   151     TPtrC text;
       
   152     TextUtils::ColumnText(text,0, aText);
       
   153 
       
   154     TBuf<KMaxColumnDataLength + KAknBidiExtraSpacePerLine> clipbuf = 
       
   155         text.Left(KMaxColumnDataLength);
       
   156                     TInt maxClipWidth = textRect.Size().iWidth;
       
   157                     
       
   158                     TBool clipped = AknBidiTextUtils::ConvertToVisualAndClip(
       
   159                         text.Left(KMaxColumnDataLength), 
       
   160                         clipbuf,
       
   161                         *font,
       
   162                         textRect.Size().iWidth, 
       
   163                         maxClipWidth );
       
   164     aGc.UseFont(font);
       
   165     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
       
   166     aGc.SetPenColor(aColors.iText);
       
   167     aGc.SetPenStyle(CGraphicsContext::ESolidPen);
       
   168     aGc.DrawText(clipbuf, textRect, baseLineOffset, CGraphicsContext::ELeft, 0);
       
   169     aGc.DiscardFont();
       
   170     return;
       
   171     }
       
   172 
       
   173 // End of File