66
|
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 |
iGc->SetClippingRect(iListBox->View()->ViewRect());
|
|
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 |
TInt variantIndex = static_cast<CCalenDayListBox*>(iListBox)->iDayContainer->LayoutVariantIndex(CCalenDayContainer::EListScrollCaleDayPane);
|
|
130 |
// get the listbox rect.
|
|
131 |
TRect listBoxRect = iListBox->View()->ViewRect();
|
|
132 |
TAknWindowComponentLayout tempLayout = AknLayoutScalable_Apps::list_cale_time_pane_g6(variantIndex);
|
|
133 |
|
|
134 |
TAknLayoutRect colourstrips;
|
|
135 |
colourstrips.LayoutRect( aItemTextRect, tempLayout.LayoutLine() );
|
|
136 |
if(CHECK_IF_FIRSTLINE(aItemIndex))
|
|
137 |
{
|
|
138 |
iColorStripHeight = 0;
|
|
139 |
iColorStripRect.SetRect(colourstrips.Rect().iTl,colourstrips.Rect().iBr);
|
|
140 |
}
|
|
141 |
// get itemInfo for each line to set the color
|
|
142 |
CCalenDayContainer::SItemInfo& itemInfo =
|
|
143 |
static_cast<CCalenDayListBox*>(iListBox)->iDayContainer->FindItem(aItemIndex);
|
|
144 |
iColor = itemInfo.iColor;
|
|
145 |
|
|
146 |
if (aItemTextRect.iBr.iY > listBoxRect.iBr.iY)
|
|
147 |
{
|
|
148 |
iColorStripRect.SetRect(iColorStripRect.iTl.iX, iColorStripRect.iTl.iY,
|
|
149 |
iColorStripRect.iBr.iX, listBoxRect.iBr.iY);
|
|
150 |
}
|
|
151 |
else if (aItemTextRect.iTl.iY < listBoxRect.iTl.iY)
|
|
152 |
{
|
|
153 |
iColorStripRect.SetRect(colourstrips.Rect().iTl.iX, listBoxRect.iTl.iY,
|
|
154 |
colourstrips.Rect().iBr.iX, colourstrips.Rect().iBr.iY);
|
|
155 |
iColorStripHeight += iColorStripRect.Height();
|
|
156 |
iColorStripRect.SetHeight(iColorStripHeight);
|
|
157 |
}
|
|
158 |
else
|
|
159 |
{
|
|
160 |
iColorStripHeight += aItemTextRect.Height();
|
|
161 |
iColorStripRect.SetHeight(iColorStripHeight);
|
|
162 |
}
|
|
163 |
|
|
164 |
iGc->SetBrushStyle( CGraphicsContext::ESolidBrush );
|
|
165 |
iGc->SetBrushColor( TRgb(iColor) );
|
|
166 |
iGc->DrawRect( iColorStripRect );
|
|
167 |
|
|
168 |
iGc->Reset();
|
|
169 |
|
|
170 |
TRACE_EXIT_POINT;
|
|
171 |
}
|
|
172 |
|
|
173 |
// End of File
|