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: Preparing to draw a cell (setting color and underline).
|
|
15 |
* Moreover, drawing cell's bottom and right lines.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
//debug
|
|
21 |
#include "calendarui_debug.h"
|
|
22 |
|
|
23 |
// INCLUDE FILES
|
|
24 |
#include "calenmonthcelllistboxitemdrawer.h"
|
|
25 |
|
|
26 |
#include <calendateutils.h>
|
|
27 |
#include "calenmonthgrid.h"
|
|
28 |
|
|
29 |
#include <AknsSkinInstance.h>
|
|
30 |
#include <AknsUtils.h>
|
|
31 |
#include <eikfrlbd.h>
|
|
32 |
|
|
33 |
// ================= MEMBER FUNCTIONS =======================
|
|
34 |
|
|
35 |
// C++ constructor can NOT contain any code, that
|
|
36 |
// might leave.
|
|
37 |
//
|
|
38 |
CCalenMonthCellListBoxItemDrawer::CCalenMonthCellListBoxItemDrawer( MTextListBoxModel* aTextListBoxModel,
|
|
39 |
CCalenMonthGrid* aCalendarMonthGrid,
|
|
40 |
const CFont* aFont,
|
|
41 |
CFormattedCellListBoxData* aFormattedCellData)
|
|
42 |
: CFormattedCellListBoxItemDrawer( aTextListBoxModel, aFont, aFormattedCellData ),
|
|
43 |
iCalendarMonthGrid( aCalendarMonthGrid )
|
|
44 |
{
|
|
45 |
TRACE_ENTRY_POINT;
|
|
46 |
TRACE_EXIT_POINT;
|
|
47 |
}
|
|
48 |
|
|
49 |
// Destructor
|
|
50 |
CCalenMonthCellListBoxItemDrawer::~CCalenMonthCellListBoxItemDrawer()
|
|
51 |
{
|
|
52 |
TRACE_ENTRY_POINT;
|
|
53 |
TRACE_EXIT_POINT;
|
|
54 |
}
|
|
55 |
|
|
56 |
// ---------------------------------------------------------
|
|
57 |
// CCalenMonthCellListBoxItemDrawer::DrawItemText
|
|
58 |
// Prepareing to draw a cell(setting color and underline).
|
|
59 |
// And drawing cell's bottom and right lines.
|
|
60 |
// (other items were commented in a header).
|
|
61 |
// ---------------------------------------------------------
|
|
62 |
//
|
|
63 |
|
|
64 |
void CCalenMonthCellListBoxItemDrawer::DrawItemText(TInt aItemIndex, const TRect& aItemTextRect, TBool aItemIsCurrent, TBool /*aViewIsEmphasized*/, TBool aItemIsSelected) const
|
|
65 |
{
|
|
66 |
TRACE_ENTRY_POINT;
|
|
67 |
|
|
68 |
iGc->SetPenColor(iTextColor);
|
|
69 |
iGc->SetBrushColor(iBackColor);
|
|
70 |
|
|
71 |
SetupGc(aItemIndex);
|
|
72 |
|
|
73 |
// Skin support
|
|
74 |
MAknsSkinInstance *skin = AknsUtils::SkinInstance();
|
|
75 |
|
|
76 |
TBool skinUsed = EFalse;
|
|
77 |
if(FormattedCellData()->Control())
|
|
78 |
{
|
|
79 |
MAknsControlContext *cc = AknsDrawUtils::ControlContext( FormattedCellData()->Control() );
|
|
80 |
|
|
81 |
if(!cc)
|
|
82 |
{
|
|
83 |
cc = FormattedCellData()->SkinBackgroundContext();
|
|
84 |
}
|
|
85 |
skinUsed = AknsDrawUtils::Background( skin, cc, NULL, *iGc, aItemTextRect, KAknsDrawParamNoClearUnderImage);
|
|
86 |
}
|
|
87 |
|
|
88 |
if( !skinUsed )
|
|
89 |
{
|
|
90 |
iGc->Clear( aItemTextRect );
|
|
91 |
}
|
|
92 |
TTime today( CalenDateUtils::Today() );
|
|
93 |
TTime currentDay( iCalendarMonthGrid->FirstDayOfGrid() +TTimeIntervalDays( aItemIndex ) );
|
|
94 |
|
|
95 |
TBool underline( CalenDateUtils::OnSameDay( today, currentDay ) );
|
|
96 |
if (underline)
|
|
97 |
{
|
|
98 |
TRgb seeThroughBack;
|
|
99 |
AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
|
|
100 |
seeThroughBack,
|
|
101 |
KAknsIIDQsnOtherColors,
|
|
102 |
EAknsCIQsnOtherColorsCG24);
|
|
103 |
iGc->SetBrushColor(seeThroughBack);
|
|
104 |
iGc->SetPenColor(seeThroughBack);
|
|
105 |
iGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
|
|
106 |
iGc->DrawRect(aItemTextRect);
|
|
107 |
skinUsed = ETrue;
|
|
108 |
}
|
|
109 |
// Setup colors, mainly try to fetch them from skins.
|
|
110 |
// FIXME: investigate if this could be done somewhere else, so that we set them to
|
|
111 |
// properties of grid
|
|
112 |
|
|
113 |
CFormattedCellListBoxData::TColors colors;
|
|
114 |
colors.iBack = iBackColor;
|
|
115 |
colors.iText = iTextColor;
|
|
116 |
|
|
117 |
if (underline)
|
|
118 |
{
|
|
119 |
AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
|
|
120 |
colors.iText,
|
|
121 |
KAknsIIDQsnTextColors,
|
|
122 |
EAknsCIQsnTextColorsCG85);
|
|
123 |
}
|
|
124 |
else if(aItemIsSelected)
|
|
125 |
{
|
|
126 |
// active month days
|
|
127 |
if(aItemIsCurrent)
|
|
128 |
{
|
|
129 |
// highlighted day's number is drawn with grid highlight color
|
|
130 |
AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
|
|
131 |
colors.iText,
|
|
132 |
KAknsIIDQsnTextColors,
|
|
133 |
EAknsCIQsnTextColorsCG11);
|
|
134 |
|
|
135 |
}
|
|
136 |
else
|
|
137 |
{
|
|
138 |
// normal active months days' numbers are drawn
|
|
139 |
// with month view text color
|
|
140 |
AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
|
|
141 |
colors.iText,
|
|
142 |
KAknsIIDQsnTextColors,
|
|
143 |
EAknsCIQsnTextColorsCG22);
|
|
144 |
}
|
|
145 |
|
|
146 |
}
|
|
147 |
else
|
|
148 |
{
|
|
149 |
// passive month days
|
|
150 |
AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
|
|
151 |
colors.iText,
|
|
152 |
KAknsIIDQsnTextColors,
|
|
153 |
EAknsCIQsnTextColorsCG21);
|
|
154 |
}
|
|
155 |
|
|
156 |
// set underline if current day is today.
|
|
157 |
// (current day is day of item.)
|
|
158 |
|
|
159 |
iGc->SetUnderlineStyle( underline ? EUnderlineOn : EUnderlineOff );
|
|
160 |
|
|
161 |
TPtrC cellData( iModel->ItemText(aItemIndex) );
|
|
162 |
FormattedCellData()->Draw(Properties(aItemIndex), *iGc, &cellData, aItemTextRect, aItemIsCurrent, colors);
|
|
163 |
|
|
164 |
TRACE_EXIT_POINT;
|
|
165 |
}
|
|
166 |
|
|
167 |
|
|
168 |
// End Of File
|