|
1 /* |
|
2 * Copyright (c) 2006 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: Draws recurrence/alarm icons |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 //debug |
|
21 #include "calendarui_debug.h" |
|
22 |
|
23 // User includes |
|
24 #include "calenicondrawer.h" |
|
25 |
|
26 #include <calenservices.h> |
|
27 #include <CalenUid.h> |
|
28 |
|
29 // System includes |
|
30 #include <fbs.h> |
|
31 #include <eikapp.h> |
|
32 |
|
33 // Layout includes |
|
34 #include <aknlayoutscalable_apps.cdl.h> |
|
35 |
|
36 #include <AknsConstants.h> |
|
37 #include <AknsUtils.h> |
|
38 #include <gulicon.h> |
|
39 #include <avkon.mbg> |
|
40 #include <gdi.h> |
|
41 #include <fbs.h> |
|
42 |
|
43 #include <AknIconArray.h> |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CCalenIconDrawer::NewL |
|
49 // Two-phased constructor. |
|
50 // (other items were commented in a header). |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CCalenIconDrawer* CCalenIconDrawer::NewL( MCalenServices& aServices ) |
|
54 { |
|
55 TRACE_ENTRY_POINT; |
|
56 |
|
57 CCalenIconDrawer* self = new (ELeave) CCalenIconDrawer( aServices ); |
|
58 CleanupStack::PushL( self ); |
|
59 self->ConstructL(); |
|
60 CleanupStack::Pop( self ); |
|
61 |
|
62 TRACE_EXIT_POINT; |
|
63 return self; |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CCalenIconDrawer::ConstructL |
|
68 // Second phase construction. |
|
69 // (other items were commented in a header). |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void CCalenIconDrawer::ConstructL() |
|
73 { |
|
74 TRACE_ENTRY_POINT; |
|
75 |
|
76 // Create icons used by the viewer |
|
77 iIconIndices.AppendL( MCalenServices::ECalenAlarmIcon ); |
|
78 iIconIndices.AppendL( MCalenServices::ECalenRepeatIcon ); |
|
79 iIconIndices.AppendL( MCalenServices::ECalenRepeatExceptionIcon ); |
|
80 iIconIndices.AppendL( MCalenServices::ECalenNotePriorityLow ); |
|
81 iIconIndices.AppendL( MCalenServices::ECalenNotePriorityHigh ); |
|
82 iIconIndices.AppendL( MCalenServices::ECalenMapIcon ); |
|
83 |
|
84 iIconArray = CreateIconsL( iIconIndices ); |
|
85 isMapIconAdded = EFalse; |
|
86 //SetIconSizesFromLayout(); |
|
87 |
|
88 TRACE_EXIT_POINT; |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CCalenIconDrawer::SetIconSizesFromLayout |
|
93 // Calculate icon size from layout |
|
94 // (other items were commented in a header). |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CCalenIconDrawer::SetIconSizesFromLayout() |
|
98 { |
|
99 TRACE_ENTRY_POINT; |
|
100 |
|
101 TSize main_pane_size; |
|
102 AknLayoutUtils::LayoutMetricsSize (AknLayoutUtils::EMainPane, main_pane_size); |
|
103 TRect main_pane(main_pane_size); |
|
104 |
|
105 TAknLayoutRect main_cale_event_viewer_pane; |
|
106 main_cale_event_viewer_pane.LayoutRect(main_pane, AknLayoutScalable_Apps::main_cale_event_viewer_pane().LayoutLine() ); |
|
107 |
|
108 TAknLayoutRect listscroll_cale_event_viewer_pane; |
|
109 listscroll_cale_event_viewer_pane.LayoutRect(main_cale_event_viewer_pane.Rect(), AknLayoutScalable_Apps::listscroll_cale_event_viewer_pane().LayoutLine() ); |
|
110 |
|
111 TAknLayoutRect list_cale_ev2_pane; |
|
112 list_cale_ev2_pane.LayoutRect(listscroll_cale_event_viewer_pane.Rect(), AknLayoutScalable_Apps::list_cale_ev2_pane().LayoutLine() ); |
|
113 |
|
114 TAknLayoutRect icon_layout_rect; |
|
115 icon_layout_rect.LayoutRect( list_cale_ev2_pane.Rect(), AknLayoutScalable_Apps::field_cale_ev2_pane_g1(1).LayoutLine() ); |
|
116 iFirstIconRect = icon_layout_rect.Rect(); |
|
117 |
|
118 icon_layout_rect.LayoutRect( list_cale_ev2_pane.Rect(), AknLayoutScalable_Apps::field_cale_ev2_pane_g2(1).LayoutLine() ); |
|
119 iSecondIconRect = icon_layout_rect.Rect(); |
|
120 |
|
121 icon_layout_rect.LayoutRect( list_cale_ev2_pane.Rect(), AknLayoutScalable_Apps::field_cale_ev2_pane_g3(2).LayoutLine() ); |
|
122 iThirdIconRect = icon_layout_rect.Rect(); |
|
123 |
|
124 AknIconUtils::SetSize( iIconArray->At(iFirstIconIndex)->Bitmap(), iFirstIconRect.Size() ); |
|
125 AknIconUtils::SetSize( iIconArray->At(iSecondIconIndex)->Bitmap(), iSecondIconRect.Size() ); |
|
126 AknIconUtils::SetSize( iIconArray->At(iThirdIconIndex)->Bitmap(), iThirdIconRect.Size() ); |
|
127 |
|
128 TRACE_EXIT_POINT; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CCalenIconDrawer::CCalenIconDrawer |
|
133 // C++ constructor can NOT contain any code, that might leave. |
|
134 // (other items were commented in a header). |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 CCalenIconDrawer::CCalenIconDrawer( MCalenServices& aServices ) |
|
138 : iServices( aServices ) |
|
139 { |
|
140 TRACE_ENTRY_POINT; |
|
141 TRACE_EXIT_POINT; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CCalenIconDrawer::~CCalenIconDrawer |
|
146 // Destructor. |
|
147 // (other items were commented in a header). |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 CCalenIconDrawer::~CCalenIconDrawer() |
|
151 { |
|
152 TRACE_ENTRY_POINT; |
|
153 |
|
154 delete iIconArray; |
|
155 iIconIndices.Close(); |
|
156 |
|
157 TRACE_EXIT_POINT; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CCalenIconDrawer::Draw |
|
162 // Draw icon function |
|
163 // (other items were commented in a header). |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CCalenIconDrawer::Draw(CGraphicsContext& aGc, const TPoint& /*aTopLeft*/, |
|
167 const TRect& /*aClipRect*/, MGraphicsDeviceMap* /*aMap*/) const |
|
168 { |
|
169 TRACE_ENTRY_POINT; |
|
170 |
|
171 aGc.Reset(); |
|
172 switch (iIconCount) |
|
173 { |
|
174 case EThreeIcons: |
|
175 aGc.DrawBitmapMasked(iThirdIconRect, iIconArray->At(iThirdIconIndex)->Bitmap(), iThirdIconRect.Size(), iIconArray->At(iThirdIconIndex)->Mask(), ETrue); |
|
176 //lint -fallthrough |
|
177 case ETwoIcons: /* fall through... */ |
|
178 aGc.DrawBitmapMasked(iSecondIconRect, iIconArray->At(iSecondIconIndex)->Bitmap(), iSecondIconRect.Size(), iIconArray->At(iSecondIconIndex)->Mask(), ETrue); |
|
179 //lint -fallthrough |
|
180 case EOneIcon: /* fall through... */ |
|
181 aGc.DrawBitmapMasked(iFirstIconRect, iIconArray->At(iFirstIconIndex)->Bitmap(), iFirstIconRect.Size(), iIconArray->At(iFirstIconIndex)->Mask(), ETrue); |
|
182 //lint -fallthrough |
|
183 case ENoIcons: /* fall through... */ |
|
184 default: |
|
185 break; |
|
186 } |
|
187 |
|
188 TRACE_EXIT_POINT; |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CCalenIconDrawer::ExternalizeL |
|
193 // Pure virtual from CPicture, intentionally empty. |
|
194 // (other items were commented in a header). |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CCalenIconDrawer::ExternalizeL(RWriteStream& /*aStream*/) const |
|
198 { |
|
199 TRACE_ENTRY_POINT; |
|
200 TRACE_EXIT_POINT; |
|
201 } |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CCalenIconDrawer::GetOriginalSizeInTwips |
|
205 // Convert size to twips |
|
206 // (other items were commented in a header). |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 void CCalenIconDrawer::GetOriginalSizeInTwips( TSize& /*aSize*/ ) const |
|
210 { |
|
211 TRACE_ENTRY_POINT; |
|
212 TRACE_EXIT_POINT; |
|
213 } |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CCalenIconDrawer::HandleResourceChange |
|
217 // Handle resource change. e.g. screen resolution change |
|
218 // (other items were commented in a header). |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CCalenIconDrawer::HandleResourceChange() |
|
222 { |
|
223 TRACE_ENTRY_POINT; |
|
224 |
|
225 SetIconSizesFromLayout(); |
|
226 |
|
227 TRACE_EXIT_POINT; |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CCalenIconDrawer::AddIconL |
|
232 // Store icon index for reserved icon position |
|
233 // (other items were commented in a header). |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 void CCalenIconDrawer::AddIconL( MCalenServices::TCalenIcons aIconIndex) |
|
237 { |
|
238 TRACE_ENTRY_POINT; |
|
239 if(aIconIndex == MCalenServices::ECalenMapIcon) |
|
240 { |
|
241 isMapIconAdded = ETrue; |
|
242 } |
|
243 switch (iIconCount) |
|
244 { |
|
245 case ENoIcons: |
|
246 iFirstIconIndex = IconIndex( aIconIndex ); |
|
247 User::LeaveIfError( iFirstIconIndex == KErrNotFound ); |
|
248 iIconCount = EOneIcon; |
|
249 break; |
|
250 |
|
251 case EOneIcon: |
|
252 iSecondIconIndex = IconIndex( aIconIndex ); |
|
253 User::LeaveIfError( iSecondIconIndex == KErrNotFound ); |
|
254 iIconCount = ETwoIcons; |
|
255 break; |
|
256 |
|
257 case ETwoIcons: |
|
258 iThirdIconIndex = IconIndex( aIconIndex ); |
|
259 User::LeaveIfError( iThirdIconIndex == KErrNotFound ); |
|
260 iIconCount = EThreeIcons; |
|
261 break; |
|
262 |
|
263 case EThreeIcons: |
|
264 /* fall through... */ |
|
265 User::Leave(KErrNotSupported); |
|
266 break; |
|
267 } |
|
268 |
|
269 TRACE_EXIT_POINT; |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------- |
|
273 // CCalenIconDrawer::WidthInPixels |
|
274 // Count width of all icons in pixel |
|
275 // (other items were commented in a header). |
|
276 // --------------------------------------------------------- |
|
277 // |
|
278 TInt CCalenIconDrawer::WidthInPixels() |
|
279 { |
|
280 TRACE_ENTRY_POINT; |
|
281 |
|
282 TInt widthInPixels = 0; |
|
283 if (iIconCount) |
|
284 { |
|
285 // All icons are the same size |
|
286 widthInPixels = iIconCount * iFirstIconRect.Size().iWidth; |
|
287 } |
|
288 |
|
289 TRACE_EXIT_POINT; |
|
290 return widthInPixels; |
|
291 } |
|
292 |
|
293 // ---------------------------------------------------------------------------- |
|
294 // CCalenIconDrawer::CreateIconsL |
|
295 // Create array of icons according to icon indices array given |
|
296 // (other items were commented in a header). |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 CAknIconArray* CCalenIconDrawer::CreateIconsL( const RArray<MCalenServices::TCalenIcons>& aIndexArray ) |
|
300 { |
|
301 TRACE_ENTRY_POINT; |
|
302 |
|
303 const TInt iconCount( aIndexArray.Count() ); |
|
304 CAknIconArray* icons = new(ELeave) CAknIconArray( iconCount ); |
|
305 CleanupStack::PushL( icons ); |
|
306 icons->SetReserveL( iconCount ); |
|
307 |
|
308 for( TInt i=0; i<iconCount; ++i ) |
|
309 { |
|
310 icons->AppendL( iServices.GetIconL( static_cast<MCalenServices::TCalenIcons>(aIndexArray[i] ), KCalenMissedEventViewUidValue )); |
|
311 } |
|
312 CleanupStack::Pop( icons ); |
|
313 |
|
314 TRACE_EXIT_POINT; |
|
315 return icons; |
|
316 } |
|
317 |
|
318 // ---------------------------------------------------------------------------- |
|
319 // CCalenContainer::IconIndex |
|
320 // Get icon index of the icon array |
|
321 // (other items were commented in a header). |
|
322 // ---------------------------------------------------------------------------- |
|
323 // |
|
324 TInt CCalenIconDrawer::IconIndex( MCalenServices::TCalenIcons aType ) const |
|
325 { |
|
326 TRACE_ENTRY_POINT; |
|
327 |
|
328 TInt index( iIconIndices.Find( aType ) ); |
|
329 // User::LeaveIfError( index == KErrNotFound ); |
|
330 |
|
331 TRACE_EXIT_POINT; |
|
332 return index; |
|
333 } |
|
334 |
|
335 // End of File |