|
1 /* |
|
2 * Copyright (c) 2008 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: Calendar Thai Plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "calendarui_debug.h" |
|
20 |
|
21 #include <eikenv.h> |
|
22 #include <eiklabel.h> |
|
23 #include <bautils.h> |
|
24 #include <AknBidiTextUtils.h> |
|
25 #include <AknUtils.h> |
|
26 #include <avkon.hrh> |
|
27 |
|
28 #include "CalenThaiPlugin.h" |
|
29 |
|
30 |
|
31 // ============================ MEMBER FUNCTIONS ============================== |
|
32 |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 // ThaiYearL |
|
36 // Global method. |
|
37 // ---------------------------------------------------------------------------- |
|
38 // |
|
39 static TInt ThaiYearL(const TTime& aDate) |
|
40 { |
|
41 TRACE_ENTRY_POINT; |
|
42 |
|
43 TDateTime dt = aDate.DateTime(); |
|
44 TInt gregorianYear = dt.Year(); |
|
45 const TInt offset = 543; |
|
46 |
|
47 TRACE_EXIT_POINT; |
|
48 return gregorianYear + offset; |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // CCalenThaiPlugin::NewL |
|
53 // ---------------------------------------------------------------------------- |
|
54 // |
|
55 CCalenThaiPlugin* CCalenThaiPlugin::NewL(MCalenServices* aServices) |
|
56 { |
|
57 TRACE_ENTRY_POINT; |
|
58 |
|
59 CCalenThaiPlugin* self = new (ELeave) CCalenThaiPlugin(aServices ); |
|
60 CleanupStack::PushL(self); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop(self); |
|
63 |
|
64 TRACE_EXIT_POINT; |
|
65 return self; |
|
66 } |
|
67 |
|
68 // ---------------------------------------------------------------------------- |
|
69 // CCalenThaiPlugin::~CCalenThaiPlugin |
|
70 // ---------------------------------------------------------------------------- |
|
71 // |
|
72 CCalenThaiPlugin::~CCalenThaiPlugin() |
|
73 { |
|
74 TRACE_ENTRY_POINT; |
|
75 |
|
76 if(iLabelControl) |
|
77 { |
|
78 delete iLabelControl; |
|
79 iLabelControl = NULL; |
|
80 } |
|
81 |
|
82 if(iInfoBarText) |
|
83 { |
|
84 delete iInfoBarText; |
|
85 iInfoBarText = NULL; |
|
86 } |
|
87 |
|
88 if ( iServices ) |
|
89 { |
|
90 iServices->CancelNotifications(this); |
|
91 iServices->Release(); |
|
92 } |
|
93 |
|
94 TRACE_EXIT_POINT; |
|
95 } |
|
96 |
|
97 // ---------------------------------------------------------------------------- |
|
98 // CCalenThaiPlugin::CCalenThaiPlugin |
|
99 // ---------------------------------------------------------------------------- |
|
100 // |
|
101 CCalenThaiPlugin::CCalenThaiPlugin(MCalenServices* aServices) |
|
102 : iServices(aServices), |
|
103 iInfoBarText(NULL) |
|
104 { |
|
105 TRACE_ENTRY_POINT; |
|
106 TRACE_EXIT_POINT; |
|
107 } |
|
108 |
|
109 // ---------------------------------------------------------------------------- |
|
110 // CCalenThaiPlugin::ConstructL |
|
111 // ---------------------------------------------------------------------------- |
|
112 // |
|
113 void CCalenThaiPlugin::ConstructL() |
|
114 { |
|
115 TRACE_ENTRY_POINT; |
|
116 iServices->RegisterForNotificationsL( this, ECalenNotifyContextChanged ); |
|
117 iLabelControl = CCalenPluginLabel::NewL(*this); |
|
118 TRACE_EXIT_POINT; |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CCalenThaiPlugin::SetLabelContentL |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 void CCalenThaiPlugin::SetLabelContentL( CEikLabel& aLabel ) |
|
126 { |
|
127 TRACE_ENTRY_POINT; |
|
128 const CFont* labelFont = NULL; |
|
129 labelFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimarySmallFont,NULL); |
|
130 aLabel.SetFont( labelFont ); |
|
131 aLabel.SetLabelAlignment(ELayoutAlignCenter); |
|
132 aLabel.SetTextL( iThaiYearText ); |
|
133 TRACE_EXIT_POINT; |
|
134 } |
|
135 |
|
136 // ---------------------------------------------------------------------------- |
|
137 // CCalenThaiPlugin::UpdateCommonInfoL |
|
138 // ---------------------------------------------------------------------------- |
|
139 // |
|
140 void CCalenThaiPlugin::UpdateLocalizerInfoL() |
|
141 { |
|
142 TRACE_ENTRY_POINT; |
|
143 TTime focusTime = iServices->Context().FocusDateAndTimeL().TimeLocalL(); |
|
144 iThaiYearText.Num( ThaiYearL( focusTime ) ); |
|
145 TRACE_EXIT_POINT; |
|
146 } |
|
147 |
|
148 // ---------------------------------------------------------------------------- |
|
149 // CCalenThaiPlugin::GetCustomViewsL |
|
150 // ---------------------------------------------------------------------------- |
|
151 // |
|
152 void CCalenThaiPlugin::GetCustomViewsL( RPointerArray<CCalenView>& |
|
153 /*aCustomViewArray */) |
|
154 { |
|
155 TRACE_ENTRY_POINT; |
|
156 TRACE_EXIT_POINT; |
|
157 } |
|
158 // ---------------------------------------------------------------------------- |
|
159 // CCalenThaiPlugin::GetCustomSettingsL |
|
160 // ---------------------------------------------------------------------------- |
|
161 // |
|
162 void CCalenThaiPlugin::GetCustomSettingsL( RPointerArray<CAknSettingItem>& |
|
163 /*aCustomSettingArray */) |
|
164 { |
|
165 TRACE_ENTRY_POINT; |
|
166 TRACE_EXIT_POINT; |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CCalenThaiPlugin::HandleCommandL |
|
171 // ---------------------------------------------------------------------------- |
|
172 // |
|
173 TBool CCalenThaiPlugin::HandleCommandL( const TCalenCommand& |
|
174 /*aCommand*/) |
|
175 { |
|
176 TRACE_ENTRY_POINT; |
|
177 TRACE_EXIT_POINT; |
|
178 return EFalse; |
|
179 } |
|
180 |
|
181 // ---------------------------------------------------------------------------- |
|
182 // CCalenThaiPlugin::CalenCommandHandlerExtensionL |
|
183 // |
|
184 // ---------------------------------------------------------------------------- |
|
185 // |
|
186 TAny* CCalenThaiPlugin::CalenCommandHandlerExtensionL( TUid /*aExtensionUid*/ ) |
|
187 { |
|
188 TRACE_ENTRY_POINT; |
|
189 TRACE_EXIT_POINT; |
|
190 return NULL; |
|
191 } |
|
192 |
|
193 // ---------------------------------------------------------------------------- |
|
194 // CCalenThaiPlugin::InfobarL |
|
195 // This function is called in case of Avkon views |
|
196 // ---------------------------------------------------------------------------- |
|
197 // |
|
198 CCoeControl* CCalenThaiPlugin::InfobarL( const TRect& aRect ) |
|
199 { |
|
200 TRACE_ENTRY_POINT; |
|
201 if(!iLabelControl) |
|
202 { |
|
203 return NULL; |
|
204 } |
|
205 |
|
206 //Update the local information based on current context |
|
207 //from framework. |
|
208 UpdateLocalizerInfoL(); |
|
209 //Set the content for the label |
|
210 iLabelControl->SetRect(aRect); |
|
211 SetLabelContentL(*iLabelControl); |
|
212 TRACE_EXIT_POINT; |
|
213 return iLabelControl; |
|
214 } |
|
215 |
|
216 // ---------------------------------------------------------------------------- |
|
217 // CCalenThaiPlugin::InfobarL |
|
218 // This function is called in case of Hitchcock views |
|
219 // ---------------------------------------------------------------------------- |
|
220 // |
|
221 const TDesC& CCalenThaiPlugin::InfobarL() |
|
222 { |
|
223 TRACE_ENTRY_POINT; |
|
224 if(iInfoBarText) |
|
225 { |
|
226 delete iInfoBarText; |
|
227 iInfoBarText = NULL; |
|
228 } |
|
229 |
|
230 //Update the local information based on current context |
|
231 //from framework. |
|
232 UpdateLocalizerInfoL(); |
|
233 iInfoBarText = iThaiYearText.AllocLC(); |
|
234 CleanupStack::Pop(); |
|
235 |
|
236 TRACE_EXIT_POINT; |
|
237 return *iInfoBarText; |
|
238 } |
|
239 |
|
240 // ---------------------------------------------------------------------------- |
|
241 // CCalenThaiPlugin::CustomPreviewPaneL |
|
242 // ---------------------------------------------------------------------------- |
|
243 // |
|
244 MCalenPreview* CCalenThaiPlugin::CustomPreviewPaneL( TRect& /*aRect*/ ) |
|
245 { |
|
246 TRACE_ENTRY_POINT |
|
247 TRACE_EXIT_POINT |
|
248 return NULL; |
|
249 } |
|
250 |
|
251 // ---------------------------------------------------------------------------- |
|
252 // CCalenThaiPlugin::PreviewPaneL |
|
253 // ---------------------------------------------------------------------------- |
|
254 // |
|
255 CCoeControl* CCalenThaiPlugin::PreviewPaneL( TRect& /*aRect*/ ) |
|
256 { |
|
257 TRACE_ENTRY_POINT; |
|
258 UpdateLocalizerInfoL(); |
|
259 if(iLabelControl) |
|
260 { |
|
261 delete iLabelControl; |
|
262 iLabelControl = NULL; |
|
263 } |
|
264 iLabelControl = CCalenPluginLabel::NewL(*this); |
|
265 SetLabelContentL(*iLabelControl); |
|
266 |
|
267 TRACE_EXIT_POINT; |
|
268 return iLabelControl; |
|
269 } |
|
270 |
|
271 // ---------------------------------------------------------------------------- |
|
272 // CCalenThaiPlugin::HandleNotification |
|
273 // ---------------------------------------------------------------------------- |
|
274 // |
|
275 void CCalenThaiPlugin::HandleNotification(const TCalenNotification aNotification) |
|
276 { |
|
277 TRACE_ENTRY_POINT; |
|
278 if (aNotification == ECalenNotifyContextChanged) |
|
279 { |
|
280 TRAP_IGNORE(UpdateLocalizerInfoL()); |
|
281 } |
|
282 TRACE_EXIT_POINT; |
|
283 |
|
284 } |
|
285 // ---------------------------------------------------------------------------- |
|
286 // CCalenThaiPlugin::CommandHandlerL |
|
287 // ---------------------------------------------------------------------------- |
|
288 // |
|
289 MCalenCommandHandler* CCalenThaiPlugin::CommandHandlerL( TInt |
|
290 /*aCommand*/) |
|
291 { |
|
292 TRACE_ENTRY_POINT; |
|
293 TRACE_EXIT_POINT; |
|
294 return NULL; |
|
295 } |
|
296 // ---------------------------------------------------------------------------- |
|
297 // CCalenThaiPlugin::RemoveViewsFromCycle |
|
298 // ---------------------------------------------------------------------------- |
|
299 // |
|
300 void CCalenThaiPlugin::RemoveViewsFromCycle( RArray<TInt>& /*aViews*/ ) |
|
301 { |
|
302 TRACE_ENTRY_POINT; |
|
303 TRACE_EXIT_POINT; |
|
304 } |
|
305 |
|
306 // ---------------------------------------------------------------------------- |
|
307 // CCalenThaiPlugin::CanBeEnabledDisabled |
|
308 // ---------------------------------------------------------------------------- |
|
309 // |
|
310 TBool CCalenThaiPlugin::CanBeEnabledDisabled() |
|
311 { |
|
312 TRACE_ENTRY_POINT; |
|
313 TRACE_EXIT_POINT; |
|
314 return ETrue; |
|
315 } |
|
316 |
|
317 // ---------------------------------------------------------------------------- |
|
318 // CCalenThaiPlugin::CalenCustomisationExtensionL |
|
319 // ---------------------------------------------------------------------------- |
|
320 // |
|
321 TAny* CCalenThaiPlugin::CalenCustomisationExtensionL( TUid /*aExtensionUid*/ ) |
|
322 { |
|
323 TRACE_ENTRY_POINT; |
|
324 TRACE_EXIT_POINT; |
|
325 return NULL; |
|
326 } |
|
327 // ---------------------------------------------------------------------------- |
|
328 // CCalenThaiPlugin::CustomiseMenuPaneL |
|
329 // ---------------------------------------------------------------------------- |
|
330 // |
|
331 TBool CCalenThaiPlugin::CustomiseMenuPaneL( TInt /*aResourceId*/, |
|
332 CEikMenuPane* /*aMenuPane*/) |
|
333 { |
|
334 TRACE_ENTRY_POINT; |
|
335 TRACE_EXIT_POINT; |
|
336 return EFalse; |
|
337 } |
|
338 // ---------------------------------------------------------------------------- |
|
339 // CCalenPluginLabel::NewL |
|
340 // ---------------------------------------------------------------------------- |
|
341 // |
|
342 CCalenPluginLabel* CCalenPluginLabel::NewL(CCalenThaiPlugin& aPlugin) |
|
343 { |
|
344 TRACE_ENTRY_POINT; |
|
345 CCalenPluginLabel* self = new(ELeave)CCalenPluginLabel(aPlugin); |
|
346 CleanupStack::PushL(self); |
|
347 self->ConstructL(); |
|
348 CleanupStack::Pop(self); |
|
349 TRACE_EXIT_POINT; |
|
350 return self; |
|
351 } |
|
352 |
|
353 // ---------------------------------------------------------------------------- |
|
354 // CCalenPluginLabel::CCalenPluginLabel |
|
355 // ---------------------------------------------------------------------------- |
|
356 // |
|
357 CCalenPluginLabel::CCalenPluginLabel(CCalenThaiPlugin& aPlugin) : iPlugin(aPlugin) |
|
358 { |
|
359 TRACE_ENTRY_POINT; |
|
360 TRACE_EXIT_POINT; |
|
361 } |
|
362 |
|
363 // ---------------------------------------------------------------------------- |
|
364 // CCalenPluginLabel::ConstructL |
|
365 // ---------------------------------------------------------------------------- |
|
366 // |
|
367 void CCalenPluginLabel::ConstructL() |
|
368 { |
|
369 TRACE_ENTRY_POINT; |
|
370 TRACE_EXIT_POINT; |
|
371 } |
|
372 // ---------------------------------------------------------------------------- |
|
373 // CCalenPluginLabel::~CCalenPluginLabel |
|
374 // ---------------------------------------------------------------------------- |
|
375 // |
|
376 CCalenPluginLabel::~CCalenPluginLabel() |
|
377 { |
|
378 TRACE_ENTRY_POINT; |
|
379 TRACE_EXIT_POINT; |
|
380 } |
|
381 // ---------------------------------------------------------------------------- |
|
382 // CCalenPluginLabel::Draw |
|
383 // ---------------------------------------------------------------------------- |
|
384 // |
|
385 void CCalenPluginLabel::Draw( const TRect& aRect) const |
|
386 { |
|
387 TRACE_ENTRY_POINT; |
|
388 CEikLabel::Draw(aRect); |
|
389 TRACE_EXIT_POINT; |
|
390 } |
|
391 // ---------------------------------------------------------------------------- |
|
392 // CCalenPluginLabel::HandlePointerEventL |
|
393 // ---------------------------------------------------------------------------- |
|
394 // |
|
395 void CCalenPluginLabel::HandlePointerEventL(const TPointerEvent& |
|
396 /*aPointerEvent*/) |
|
397 { |
|
398 TRACE_ENTRY_POINT; |
|
399 TRACE_EXIT_POINT; |
|
400 } |
|
401 |
|
402 //EOF |
|
403 |
|
404 |
|
405 |