|
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 |
|
93 // Setup colors, mainly try to fetch them from skins. |
|
94 // FIXME: investigate if this could be done somewhere else, so that we set them to |
|
95 // properties of grid |
|
96 |
|
97 CFormattedCellListBoxData::TColors colors; |
|
98 colors.iBack = iBackColor; |
|
99 colors.iText = iTextColor; |
|
100 |
|
101 if(aItemIsSelected) |
|
102 { |
|
103 // active month days |
|
104 if(aItemIsCurrent) |
|
105 { |
|
106 // highlighted day's number is drawn with grid highlight color |
|
107 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
108 colors.iText, |
|
109 KAknsIIDQsnTextColors, |
|
110 EAknsCIQsnTextColorsCG11); |
|
111 |
|
112 } |
|
113 else |
|
114 { |
|
115 // normal active months days' numbers are drawn |
|
116 // with month view text color |
|
117 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
118 colors.iText, |
|
119 KAknsIIDQsnTextColors, |
|
120 EAknsCIQsnTextColorsCG22); |
|
121 } |
|
122 |
|
123 } |
|
124 else |
|
125 { |
|
126 // passive month days |
|
127 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), |
|
128 colors.iText, |
|
129 KAknsIIDQsnTextColors, |
|
130 EAknsCIQsnTextColorsCG21); |
|
131 } |
|
132 |
|
133 // set underline if current day is today. |
|
134 // (current day is day of item.) |
|
135 TTime today( CalenDateUtils::Today() ); |
|
136 TTime currentDay( iCalendarMonthGrid->FirstDayOfGrid() +TTimeIntervalDays( aItemIndex ) ); |
|
137 |
|
138 TBool underline( CalenDateUtils::OnSameDay( today, currentDay ) ); |
|
139 iGc->SetUnderlineStyle( underline ? EUnderlineOn : EUnderlineOff ); |
|
140 |
|
141 TPtrC cellData( iModel->ItemText(aItemIndex) ); |
|
142 FormattedCellData()->Draw(Properties(aItemIndex), *iGc, &cellData, aItemTextRect, aItemIsCurrent, colors); |
|
143 |
|
144 TRACE_EXIT_POINT; |
|
145 } |
|
146 |
|
147 |
|
148 // End Of File |