calendarui/views/src/calendaylistboxitemdrawer.cpp
changeset 0 f979ecb2b13e
child 15 9711e452b5e9
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Customized drawing of CCalenDayListBoxData.
       
    15  *                DrawItemText() passes extended parameters to CCalenDayListBoxData.
       
    16  *
       
    17 */
       
    18 
       
    19 
       
    20 //debug
       
    21 #include "calendarui_debug.h"
       
    22 
       
    23 //  INCLUDE FILES
       
    24 #include "calendaylistboxitemdrawer.h"
       
    25 #include "calendaylistboxview.h"
       
    26 #include "calendaylistbox.h"
       
    27 #include "calendaycontainer.h"
       
    28 
       
    29 
       
    30 #include <AknUtils.h>
       
    31 #include <eikfrlbd.h>
       
    32 #include <aknlayoutscalable_apps.cdl.h>
       
    33 #define CHECK_IF_FIRSTLINE(a)  static_cast<CCalenDayListBoxView*>(iListBox->View())->IsFirstLineOfCell(a)
       
    34 
       
    35 // ================= MEMBER FUNCTIONS =======================
       
    36 
       
    37 // C++ constructor can NOT contain any code, that
       
    38 // might leave.
       
    39 //
       
    40 CCalenDayListBoxItemDrawer::CCalenDayListBoxItemDrawer( MTextListBoxModel* aTextListBoxModel,
       
    41                                                         const CFont* aFont,
       
    42                                                         CFormattedCellListBoxData* aFormattedCellData,
       
    43                                                         CEikListBox* aListBox )
       
    44     : CFormattedCellListBoxItemDrawer(aTextListBoxModel, aFont, aFormattedCellData),
       
    45       iListBox( aListBox )
       
    46     {
       
    47     TRACE_ENTRY_POINT;
       
    48     TRACE_EXIT_POINT;
       
    49     }
       
    50 
       
    51 // Destructor
       
    52 CCalenDayListBoxItemDrawer::~CCalenDayListBoxItemDrawer()
       
    53     {
       
    54     TRACE_ENTRY_POINT;
       
    55     TRACE_EXIT_POINT;
       
    56     }
       
    57 
       
    58 // ---------------------------------------------------------
       
    59 // CCalenDayListBoxItemDrawer::DrawItemText
       
    60 // passes a parameter to CFormattedCellListBoxData.
       
    61 // (other items were commented in a header).
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 _LIT(EEmptyString, "");
       
    65 void CCalenDayListBoxItemDrawer::DrawItemText
       
    66 (TInt aItemIndex,               // Item index
       
    67  const TRect& aItemTextRect,    // Item rect
       
    68  TBool aItemIsCurrent,          // Current Item flag
       
    69  TBool aViewIsEmphasized,   // ignored.
       
    70  TBool /*aItemIsSelected*/) const // Item hilighted flag
       
    71     {
       
    72     TRACE_ENTRY_POINT;
       
    73     
       
    74     // Based on AVKON CFormattedCellListBoxItemDrawer
       
    75     // Removed code is commented out 
       
    76     iGc->SetPenColor(iTextColor);
       
    77     iGc->SetBrushColor(iBackColor);
       
    78 
       
    79     TPtrC temp=iModel->ItemText(aItemIndex);
       
    80 
       
    81     SetupGc(aItemIndex);
       
    82 
       
    83     TBufC<KMaxTotalDataLength> target(EEmptyString);
       
    84 //     TBool removeicon = (!aItemIsSelected && !ItemMarkReverse()) || 
       
    85 //                         (aItemIsSelected && ItemMarkReverse());
       
    86 //     if( Flags() & EDrawMarkSelection && ItemMarkPosition() != -1 
       
    87 //         && removeicon)
       
    88 //     {
       
    89 //         TPtrC repl = ItemMarkReplacement();
       
    90 //         AknLAFUtils::ReplaceColumn(target.Des(), &temp, &repl, '\t', 
       
    91 //                                    ItemMarkPosition());
       
    92 //     }
       
    93 //     else
       
    94 //     {
       
    95     TPtrC empty(KNullDesC);
       
    96     AknLAFUtils::ReplaceColumn(target.Des(), &temp, &empty, '\t', -1);
       
    97 //     }
       
    98 
       
    99     CFormattedCellListBoxData::TColors colors;
       
   100     colors.iText=iTextColor;
       
   101     colors.iBack=iBackColor;
       
   102     colors.iHighlightedText=iHighlightedTextColor;
       
   103     colors.iHighlightedBack=iHighlightedBackColor;
       
   104 
       
   105 //    MAknsSkinInstance *skin = AknsUtils::SkinInstance();
       
   106 //     if(FormattedCellData()->Control())
       
   107 //     {
       
   108 //         MAknsControlContext *cc = AknsDrawUtils::ControlContext( 
       
   109 //                                   FormattedCellData()->Control() );
       
   110 //         if(!cc)
       
   111 //             cc = FormattedCellData()->SkinBackgroundContext();
       
   112 //         AknsDrawUtils::Background( skin, cc, FormattedCellData()->Control(),
       
   113 //                                    *iGc, aItemTextRect );
       
   114 //     }
       
   115 //     else
       
   116 //     {
       
   117 //         iGc->Clear(aItemTextRect);
       
   118 //     }
       
   119 
       
   120     TBool highlightShown = ETrue;
       
   121 
       
   122     if(FormattedCellData()->RespectFocus() && !aViewIsEmphasized)
       
   123         highlightShown = EFalse;
       
   124 
       
   125     FormattedCellData()->Draw(Properties(aItemIndex), *iGc, &target, 
       
   126                               aItemTextRect, aItemIsCurrent&&highlightShown, 
       
   127                               colors);
       
   128     
       
   129     
       
   130     
       
   131     if(CHECK_IF_FIRSTLINE(aItemIndex))
       
   132         {
       
   133         CCalenDayContainer::SItemInfo& itemInfo = 
       
   134                            static_cast<CCalenDayListBox*>(iListBox)->iDayContainer->FindItem(aItemIndex);
       
   135         iColor = itemInfo.iColor;
       
   136         }
       
   137     
       
   138 
       
   139     TAknWindowComponentLayout tempLayout =
       
   140                     AknLayoutScalable_Apps::list_cale_time_pane_g6(
       
   141                             aItemIndex - static_cast<CCalenDayListBox*> (iListBox)->TopItemIndex());
       
   142 
       
   143     TAknLayoutRect colourstrips;
       
   144     colourstrips.LayoutRect( aItemTextRect, tempLayout.LayoutLine() );
       
   145     TRect finalRect(colourstrips.Rect());
       
   146     finalRect.SetHeight(aItemTextRect.Height());
       
   147     iGc->DrawRect( colourstrips.Rect() );
       
   148     iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
   149     iGc->SetBrushColor( TRgb(iColor) );
       
   150     iGc->DrawRect( finalRect );
       
   151     
       
   152     iGc->Reset();
       
   153     
       
   154     TRACE_EXIT_POINT;
       
   155     }
       
   156 
       
   157 // End of File