1 /* |
|
2 * Copyright (c) 2002-2005 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: Implementation of range bar |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // system includes |
|
20 //#include <peninputpluginutils.h> |
|
21 #include <aknlayoutscalable_avkon.cdl.h> |
|
22 #include <AknsUtils.h> |
|
23 #include <AknLayoutDef.h> |
|
24 #include <AknUtils.h> |
|
25 #include <barsread.h> |
|
26 |
|
27 // user includes |
|
28 #include <peninputrangebar.h> |
|
29 #include <peninputbutton.h> |
|
30 #include <peninputmultimodebutton.h> |
|
31 #include <peninputcommonctrls.hrh> |
|
32 #include <peninputpluginutils.h> |
|
33 #include <peninputcommonbutton.h> |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CAknFepCtrlRangeBar::CAknFepCtrlRangeBar |
|
39 // C++ constructor |
|
40 // (other items were commented in a header). |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CAknFepCtrlRangeBar::CAknFepCtrlRangeBar(CFepUiLayout* aUiLayout, TInt aControlId, |
|
44 TButtonGroupStyle aStyle) |
|
45 : CControlGroup(aUiLayout, aControlId, EFalse), iFirstTimeConstruct(ETrue) |
|
46 { |
|
47 iStyle = aStyle; |
|
48 //iActionStyle = ERangeBarActionStyleHide; |
|
49 iActionStyle = ERangeBarUsingIndicatorStyle; |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CAknFepCtrlRangeBar::~CAknFepCtrlRangeBar |
|
54 // C++ destructor |
|
55 // (other items were commented in a header). |
|
56 // --------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C CAknFepCtrlRangeBar::~CAknFepCtrlRangeBar() |
|
59 { |
|
60 iIndicators.ResetAndDestroy(); |
|
61 iIndicators.Close(); |
|
62 iCellRects.Close(); |
|
63 iCellInnerRects.Close(); |
|
64 } |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CAknFepCtrlRangeBar::NewL |
|
68 // Two-phased constructor. |
|
69 // (other items were commented in a header). |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 EXPORT_C CAknFepCtrlRangeBar* CAknFepCtrlRangeBar::NewL(CFepUiLayout* aUiLayout, TInt aControlId, |
|
73 TButtonGroupStyle aStyle) |
|
74 { |
|
75 CAknFepCtrlRangeBar* self = new (ELeave) CAknFepCtrlRangeBar (aUiLayout, aControlId, aStyle); |
|
76 CleanupStack::PushL(self); |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop(self); |
|
79 return self; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CAknFepCtrlRangeBar::NewLC |
|
84 // Two-phased constructor. |
|
85 // (other items were commented in a header). |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C CAknFepCtrlRangeBar* CAknFepCtrlRangeBar::NewLC(CFepUiLayout* aUiLayout, |
|
89 TInt aControlId, |
|
90 TButtonGroupStyle aStyle) |
|
91 { |
|
92 CAknFepCtrlRangeBar* self = new (ELeave) CAknFepCtrlRangeBar (aUiLayout, aControlId, aStyle); |
|
93 CleanupStack::PushL(self); |
|
94 self->ConstructL(); |
|
95 return self; |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CAknFepCtrlRangeBar::ConstructL |
|
100 // Construct the instance |
|
101 // (other items were commented in a header). |
|
102 // --------------------------------------------------------------------------- |
|
103 // |
|
104 EXPORT_C void CAknFepCtrlRangeBar::ConstructL() |
|
105 { |
|
106 // Construct the base control first |
|
107 CControlGroup::ConstructL(); |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CAknFepCtrlRangeBar::HandlePointerDownEventL |
|
112 // Implement the pointer down handler |
|
113 // (other items were commented in a header). |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CFepUiBaseCtrl* CAknFepCtrlRangeBar::HandlePointerDownEventL(const TPoint& aPoint) |
|
117 { |
|
118 CFepUiBaseCtrl* ctrl = CControlGroup::HandlePointerDownEventL( aPoint ); |
|
119 return ctrl; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // CAknFepCtrlRangeBar::SizeChanged |
|
124 // Implement the SizeChanged handler |
|
125 // (other items were commented in a header). |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C void CAknFepCtrlRangeBar::SizeChanged(const TRect aRect) |
|
129 { |
|
130 SetCellRect(aRect); |
|
131 |
|
132 if( iCellChanged ) |
|
133 { |
|
134 SetRect(aRect); |
|
135 |
|
136 iActionStyle == ERangeBarUsingIndicatorStyle ? |
|
137 UpdateIndicatorRectForUsingIndicatorStyle(EFalse) : |
|
138 UpdateIndicatorRect(EFalse); |
|
139 } |
|
140 else |
|
141 { |
|
142 iIsReloadImages = ETrue; |
|
143 SetWholeRect(); |
|
144 //Draw(); |
|
145 SetIndicatorRect(); |
|
146 } |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CAknFepCtrlRangeBar::ConstructFromResourceL |
|
151 // Construct the range bar from the resource |
|
152 // (other items were commented in a header). |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 EXPORT_C void CAknFepCtrlRangeBar::ConstructFromResourceL(TResourceReader& aReader) |
|
156 { |
|
157 //destroy all previous range buttons |
|
158 |
|
159 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
160 { |
|
161 CAknFepCtrlCommonButton* button = iIndicators[ ii ]->iIndicator; |
|
162 if (button) |
|
163 { |
|
164 RemoveControl(button); |
|
165 } |
|
166 } |
|
167 |
|
168 iIndicators.ResetAndDestroy(); |
|
169 |
|
170 const TInt countRanges = aReader.ReadInt16(); |
|
171 |
|
172 if (countRanges <= 0) |
|
173 { |
|
174 User::Leave(KErrArgument); |
|
175 } |
|
176 |
|
177 // Create range indicator buttons |
|
178 for (TInt ii = 0; ii < countRanges; ++ii) |
|
179 { |
|
180 AddRangeL(aReader); |
|
181 } |
|
182 |
|
183 const TInt defaultRangeIndex = aReader.ReadInt16(); |
|
184 |
|
185 if (defaultRangeIndex >= 0 && defaultRangeIndex < iIndicators.Count()) |
|
186 { |
|
187 SetRange(iIndicators[defaultRangeIndex]->iInputRange); |
|
188 } |
|
189 |
|
190 iFirstTimeConstruct = EFalse; |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // CAknFepCtrlRangeBar::SetIndicatorRect() |
|
195 // Re-calculate the position and layout |
|
196 // (other items were commented in a header). |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 void CAknFepCtrlRangeBar::SetIndicatorRect() |
|
200 { |
|
201 TRect rect(iIndicatorRect); |
|
202 TInt count = iIndicators.Count(); |
|
203 TInt lastPos = -1; |
|
204 |
|
205 for (TInt ii = 0; ii < count; ++ii) |
|
206 { |
|
207 if ( ii != 0 && |
|
208 (iActionStyle != ERangeBarUsingIndicatorStyle || |
|
209 lastPos != iIndicators[ii]->iPosIdx ) ) |
|
210 { |
|
211 if (iStyle == EBtnGroupVertical) |
|
212 { |
|
213 rect.Move(0, iIndicatorRect.Height()); |
|
214 } |
|
215 else |
|
216 { |
|
217 rect.Move(iIndicatorRect.Width(), 0); |
|
218 } |
|
219 } |
|
220 lastPos = iIndicators[ii]->iPosIdx; |
|
221 |
|
222 TRect innerRect; |
|
223 AknPenImageUtils::CalculateGraphicRect( rect, innerRect ); |
|
224 |
|
225 if (iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) |
|
226 { |
|
227 static_cast<CAknFepCtrlMultiModeButton*>(iIndicators[ii]->iIndicator)-> |
|
228 SizeChanged(rect, innerRect, iIsReloadImages); |
|
229 } |
|
230 else |
|
231 { |
|
232 static_cast<CAknFepCtrlCommonButton*>(iIndicators[ii]->iIndicator)-> |
|
233 SizeChanged(rect, innerRect, iIsReloadImages); |
|
234 } |
|
235 } |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------------------------- |
|
239 // CAknFepCtrlRangeBar::Draw() |
|
240 // Re-calculate the position and layout |
|
241 // (other items were commented in a header). |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 EXPORT_C void CAknFepCtrlRangeBar::Draw() |
|
245 { |
|
246 if(!AbleToDraw()) |
|
247 return; |
|
248 |
|
249 CControlGroup::Draw(); |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------------------------- |
|
253 // CAknFepCtrlRangeBar::RefreshUI |
|
254 // Refresh the component |
|
255 // (other items were commented in a header). |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 EXPORT_C void CAknFepCtrlRangeBar::RefreshUI() |
|
259 { |
|
260 // this function not called anymore |
|
261 SetIndicatorRect(); |
|
262 |
|
263 // Flush the gc memory to the LCD device |
|
264 UpdateArea(iEraseRect, EFalse); |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------------------------- |
|
268 // CAknFepCtrlRangeBar::HandleControlEvent |
|
269 // responding on button up event |
|
270 // (other items were commented in a header). |
|
271 // --------------------------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C void CAknFepCtrlRangeBar::HandleControlEvent(TInt aEventType, CFepUiBaseCtrl* aCtrl, |
|
274 const TDesC& /*aEventData*/) |
|
275 { |
|
276 if (aEventType == EEventButtonUp) |
|
277 { |
|
278 // get aCtrl's index |
|
279 TBool ctrlExist = EFalse; |
|
280 TInt ctrlIndex = 0; |
|
281 |
|
282 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
283 { |
|
284 if ((iIndicators[ii]->iIndicator == aCtrl) |
|
285 && (!(iIndicators[ii]->iIndicator->IsDimmed()))) |
|
286 { |
|
287 ctrlExist = ETrue; |
|
288 ctrlIndex = ii; |
|
289 break; |
|
290 } |
|
291 } |
|
292 |
|
293 if (!ctrlExist) |
|
294 { |
|
295 return; |
|
296 } |
|
297 |
|
298 TBool needSendEvent = EFalse; |
|
299 |
|
300 // aCtrl's index is ctrlIndex |
|
301 if ( (ActiveControl() != aCtrl) |
|
302 || (iIndicators[ctrlIndex]->iCtrlType == EButtonTypePopupMode) ) |
|
303 { |
|
304 needSendEvent = ETrue; |
|
305 } |
|
306 else // press active button again |
|
307 { |
|
308 // only meaningful when it is multimode button |
|
309 if (iIndicators[ctrlIndex]->iCtrlType == EButtonTypeMultiMode) |
|
310 { |
|
311 CAknFepCtrlMultiModeButton* button = static_cast<CAknFepCtrlMultiModeButton*>(iIndicators[ctrlIndex]->iIndicator); |
|
312 |
|
313 // change range: user press mixed range multimode button, and range is changed |
|
314 if (iIndicators[ctrlIndex]->iRangeType == ERangeTypeMixed) |
|
315 { |
|
316 if ((button->NextMode() != KErrNotFound) && |
|
317 (button->RangeOfGivenMode(button->CurrentMode()) != |
|
318 button->RangeOfGivenMode(button->NextMode()))) |
|
319 { |
|
320 // change range |
|
321 ReportEventToObserver(iEventIdForRange, |
|
322 button->RangeOfGivenMode(button->NextMode())); |
|
323 } |
|
324 else if (button->RangeOfGivenMode(button->CurrentMode()) == |
|
325 button->RangeOfGivenMode(button->NextMode())) |
|
326 { |
|
327 // mixed range multimode button: change case |
|
328 ReportEventToObserver(iEventIdForCase, button->NextMode()); |
|
329 } |
|
330 } |
|
331 else |
|
332 { |
|
333 // single range multimode button: change case |
|
334 ReportEventToObserver(iEventIdForCase, button->NextMode()); |
|
335 } |
|
336 } |
|
337 else |
|
338 { |
|
339 if ( iIndicators[ctrlIndex]->iInputRange != iInputRange ) |
|
340 { |
|
341 needSendEvent = ETrue; |
|
342 } |
|
343 } |
|
344 } |
|
345 |
|
346 if ( needSendEvent ) |
|
347 { |
|
348 // press another button instead of active button, it will send range event |
|
349 if ((iIndicators[ctrlIndex]->iCtrlType == EButtonTypeMultiMode) && |
|
350 (iIndicators[ctrlIndex]->iRangeType == ERangeTypeMixed)) |
|
351 { |
|
352 CAknFepCtrlMultiModeButton* button = |
|
353 static_cast<CAknFepCtrlMultiModeButton*>(aCtrl); |
|
354 |
|
355 if ((button) && |
|
356 (button->IsGivenRangeSupported( |
|
357 button->RangeOfGivenMode(button->CurrentMode())))) |
|
358 { |
|
359 ReportEventToObserver(iEventIdForRange, |
|
360 button->RangeOfGivenMode(button->CurrentMode())); |
|
361 } |
|
362 } |
|
363 else |
|
364 { |
|
365 // for single range multimode button and normal button |
|
366 ReportEventToObserver(iEventIdForRange, iIndicators[ctrlIndex]->iInputRange); |
|
367 } |
|
368 } |
|
369 |
|
370 // make sure the normal button press effect for : |
|
371 // using indicator style, and EIndicatorActionStyleNormal |
|
372 if (iActionStyle == ERangeBarUsingIndicatorStyle && |
|
373 iIndicators[ctrlIndex]->iActionStyle == EIndicatorActionStyleNormal && |
|
374 iIndicators[ctrlIndex]->iIndicator->IsActive()) |
|
375 { |
|
376 iIndicators[ctrlIndex]->iIndicator->SetHighlight(EFalse); |
|
377 } |
|
378 |
|
379 if ( iActionStyle == ERangeBarUsingIndicatorStyle && |
|
380 iIndicators[ctrlIndex]->iActionStyle != EIndicatorActionStyleHighLight ) |
|
381 { |
|
382 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
383 { |
|
384 if(iIndicators[ ii ]->iActionStyle == EIndicatorActionStyleHighLight |
|
385 && ii != ctrlIndex) |
|
386 { |
|
387 iIndicators[ ii ]->iIndicator->SetHighlight( |
|
388 iIndicators[ ii ]->iIndicator->IsActive() ); |
|
389 } |
|
390 } |
|
391 } |
|
392 } |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // CAknFepCtrlRangeBar::SetRange |
|
397 // set current input range |
|
398 // (other items were commented in a header). |
|
399 // --------------------------------------------------------------------------- |
|
400 // |
|
401 EXPORT_C TBool CAknFepCtrlRangeBar::SetRange(const TInt aRange) |
|
402 { |
|
403 // if set range in a mixed range multimode button, |
|
404 // should use detailed range, but not mixed range |
|
405 TBool ret = EFalse; |
|
406 |
|
407 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
408 { |
|
409 CAknFepCtrlCommonButton* button = iIndicators[ ii ]->iIndicator; |
|
410 |
|
411 if ((button) && (!(button->IsDimmed()))) |
|
412 { |
|
413 if ((iIndicators[ii]->iInputRange == aRange) || |
|
414 ((iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) && |
|
415 (iIndicators[ii]->iRangeType == ERangeTypeMixed) && |
|
416 (static_cast<CAknFepCtrlMultiModeButton*>(button)->IsGivenRangeSupported(aRange)))) |
|
417 { |
|
418 // 1st condition: normal button or single range multimode button |
|
419 // 2nd condition: mixed range multimode button |
|
420 if (!(iIndicators[ii]->iInputRange == aRange)) |
|
421 { |
|
422 // mixed range multimode button |
|
423 static_cast<CAknFepCtrlMultiModeButton*>(button)->SetRange(aRange); |
|
424 } |
|
425 |
|
426 iInputRange = aRange; |
|
427 |
|
428 SetActiveCtrl(button); |
|
429 |
|
430 ret = ETrue; |
|
431 } |
|
432 else |
|
433 { |
|
434 button->SetActive(EFalse); |
|
435 } |
|
436 } |
|
437 } |
|
438 |
|
439 if ( iActionStyle == ERangeBarActionStyleHighLight ) |
|
440 { |
|
441 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
442 { |
|
443 iIndicators[ ii ]->iIndicator->SetHighlight( iIndicators[ ii ]->iIndicator->IsActive() ); |
|
444 } |
|
445 } |
|
446 else |
|
447 { |
|
448 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
449 { |
|
450 if(iIndicators[ ii ]->iActionStyle == EIndicatorActionStyleHighLight) |
|
451 { |
|
452 iIndicators[ ii ]->iIndicator->SetHighlight( iIndicators[ ii ]->iIndicator->IsActive() ); |
|
453 } |
|
454 } |
|
455 } |
|
456 return ret; |
|
457 } |
|
458 |
|
459 // --------------------------------------------------------------------------- |
|
460 // CAknFepCtrlRangeBar::SetCaseL |
|
461 // set mode of given range |
|
462 // (other items were commented in a header). |
|
463 // --------------------------------------------------------------------------- |
|
464 // |
|
465 EXPORT_C void CAknFepCtrlRangeBar::SetCaseL(const TInt aRange, const TInt aModeIndex) |
|
466 { |
|
467 // aRange is detailed range, it only meaningful for multimodebutton |
|
468 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
469 { |
|
470 CAknFepCtrlMultiModeButton* button = static_cast<CAknFepCtrlMultiModeButton*> |
|
471 (iIndicators[ii]->iIndicator); |
|
472 if ((iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) && |
|
473 ((iIndicators[ii]->iInputRange == aRange) || |
|
474 ((iIndicators[ii]->iRangeType == ERangeTypeMixed) && |
|
475 (button->IsGivenRangeSupported(aRange))))) |
|
476 { |
|
477 if (iIndicators[ii]->iRangeType == ERangeTypeMixed) |
|
478 { |
|
479 button->SetRange(aRange); |
|
480 } |
|
481 |
|
482 if (button->IsActive()) |
|
483 { |
|
484 button->SetCurrentModeL(EBtnBmpActive, aModeIndex); |
|
485 } |
|
486 else |
|
487 { |
|
488 button->SetCurrentModeL(EBtnBmpNonActive, aModeIndex); |
|
489 } |
|
490 |
|
491 break; |
|
492 } |
|
493 } |
|
494 } |
|
495 |
|
496 // --------------------------------------------------------------------------- |
|
497 // CAknFepCtrlRangeBar::SetPermittedRanges |
|
498 // set permitted ranges |
|
499 // (other items were commented in a header). |
|
500 // --------------------------------------------------------------------------- |
|
501 // |
|
502 EXPORT_C void CAknFepCtrlRangeBar::SetPermittedRanges(const TInt aPermitted) |
|
503 { |
|
504 // aPermitted only include detailed range, not mixed |
|
505 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
506 { |
|
507 TBool needDimButton = EFalse; |
|
508 CAknFepCtrlCommonButton* button= iIndicators[ii]->iIndicator; |
|
509 |
|
510 if ((iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) && |
|
511 (iIndicators[ii]->iRangeType == ERangeTypeMixed)) |
|
512 { |
|
513 // mixed multi button |
|
514 RArray<TInt> rangeList; |
|
515 TRAP_IGNORE(static_cast<CAknFepCtrlMultiModeButton*> |
|
516 (button)->GetRangeListL(rangeList)); |
|
517 |
|
518 needDimButton = ETrue; |
|
519 TInt disableIdx = -1; |
|
520 |
|
521 for (TInt ii = 0; ii < rangeList.Count(); ii++) |
|
522 { |
|
523 if (aPermitted & rangeList[ii]) |
|
524 { |
|
525 static_cast<CAknFepCtrlMultiModeButton*>(button)->SetPermittedRange( |
|
526 rangeList[ii], ETrue); |
|
527 needDimButton = EFalse; |
|
528 } |
|
529 else |
|
530 { |
|
531 static_cast<CAknFepCtrlMultiModeButton*>(button)->SetPermittedRange( |
|
532 rangeList[ii], EFalse); |
|
533 disableIdx = ii; |
|
534 } |
|
535 } |
|
536 |
|
537 // disable mode can only after permitted modes are all setted. |
|
538 if ( disableIdx >= 0 ) |
|
539 { |
|
540 static_cast<CAknFepCtrlMultiModeButton*>(button)->DisableOneModes( |
|
541 rangeList[disableIdx]); |
|
542 } |
|
543 |
|
544 rangeList.Reset(); |
|
545 rangeList.Close(); |
|
546 } |
|
547 else if (!(aPermitted & iIndicators[ii]->iInputRange)) |
|
548 { |
|
549 // disable a normal or single range multi button |
|
550 needDimButton = ETrue; |
|
551 |
|
552 if (iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) |
|
553 { |
|
554 TRAP_IGNORE(static_cast<CAknFepCtrlMultiModeButton*>(button)->SetCurrentModeL( |
|
555 EBtnBmpNonActive , 0)); |
|
556 } |
|
557 } |
|
558 |
|
559 if (needDimButton) |
|
560 { |
|
561 button->SetDimmed(ETrue); |
|
562 button->SetActive(EFalse); |
|
563 } |
|
564 else |
|
565 { |
|
566 button->SetDimmed(EFalse); |
|
567 } |
|
568 } |
|
569 |
|
570 if ( iActionStyle == ERangeBarUsingIndicatorStyle ) |
|
571 { |
|
572 for(TInt n = 0; n < iIndicators.Count(); n++) |
|
573 { |
|
574 for( TInt m = n+1; m < iIndicators.Count(); m++ ) |
|
575 { |
|
576 if( iIndicators[n]->iPosIdx == iIndicators[m]->iPosIdx ) |
|
577 { |
|
578 TBool nDimmed = iIndicators[n]->iIndicator->IsDimmed(); |
|
579 TBool mDimmed = iIndicators[m]->iIndicator->IsDimmed(); |
|
580 |
|
581 if ( nDimmed != mDimmed ) |
|
582 { |
|
583 iIndicators[n]->iIndicator->Hide(nDimmed); |
|
584 iIndicators[m]->iIndicator->Hide(mDimmed); |
|
585 } |
|
586 } |
|
587 } |
|
588 } |
|
589 } |
|
590 //RefreshUI(); |
|
591 } |
|
592 |
|
593 // --------------------------------------------------------------------------- |
|
594 // CAknFepCtrlRangeBar::SetPermittedRange |
|
595 // set permitted ranges |
|
596 // (other items were commented in a header). |
|
597 // --------------------------------------------------------------------------- |
|
598 // |
|
599 EXPORT_C void CAknFepCtrlRangeBar::SetPermittedRange(const TInt aRangeId, TBool aPermit) |
|
600 { |
|
601 // this function has take consideration of mixed range multimodebutton |
|
602 // aRangeId is detailed range here |
|
603 TBool needDimButton = EFalse; |
|
604 TBool findButton = EFalse; |
|
605 TInt buttonIdx = 0; |
|
606 |
|
607 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
608 { |
|
609 CAknFepCtrlCommonButton* button = iIndicators[ii]->iIndicator; |
|
610 |
|
611 if ((iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) && |
|
612 (iIndicators[ii]->iRangeType == ERangeTypeMixed)) |
|
613 { |
|
614 // mixed multi button |
|
615 if (static_cast<CAknFepCtrlMultiModeButton*>(button)->IsGivenRangeSupported(aRangeId)) |
|
616 { |
|
617 findButton = ETrue; |
|
618 buttonIdx = ii; |
|
619 |
|
620 static_cast<CAknFepCtrlMultiModeButton*>(button)->SetPermittedRange(aRangeId, |
|
621 aPermit); |
|
622 |
|
623 RArray<TInt> rangeList; |
|
624 |
|
625 TRAP_IGNORE(static_cast<CAknFepCtrlMultiModeButton*>(button)->GetRangeListL( |
|
626 rangeList)); |
|
627 |
|
628 if ( (!aPermit) && (rangeList.Count() == 1) ) |
|
629 { |
|
630 needDimButton = ETrue; |
|
631 } |
|
632 |
|
633 rangeList.Reset(); |
|
634 rangeList.Close(); |
|
635 |
|
636 break; |
|
637 } |
|
638 } |
|
639 else |
|
640 { |
|
641 // normal or single range multi button |
|
642 if (iIndicators[ii]->iInputRange == aRangeId) |
|
643 { |
|
644 findButton = ETrue; |
|
645 buttonIdx = ii; |
|
646 |
|
647 if (!aPermit) |
|
648 { |
|
649 needDimButton = ETrue; |
|
650 |
|
651 if (iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) |
|
652 { |
|
653 TRAP_IGNORE( |
|
654 static_cast<CAknFepCtrlMultiModeButton*>(button)->SetCurrentModeL( |
|
655 EBtnBmpNonActive , 0)); |
|
656 } |
|
657 } |
|
658 break; |
|
659 } |
|
660 } |
|
661 } |
|
662 |
|
663 if (findButton) |
|
664 { |
|
665 CAknFepCtrlCommonButton* button = iIndicators[buttonIdx]->iIndicator; |
|
666 |
|
667 if (!needDimButton) |
|
668 { |
|
669 button->SetDimmed(EFalse); |
|
670 } |
|
671 else |
|
672 { |
|
673 button->SetDimmed(ETrue); |
|
674 button->SetActive(EFalse); |
|
675 } |
|
676 } |
|
677 |
|
678 //RefreshUI(); |
|
679 } |
|
680 |
|
681 // --------------------------------------------------------------------------- |
|
682 // CAknFepCtrlRangeBar::SetPermittedCase |
|
683 // set permitted ranges |
|
684 // (other items were commented in a header). |
|
685 // --------------------------------------------------------------------------- |
|
686 // |
|
687 EXPORT_C void CAknFepCtrlRangeBar::SetPermittedCase(const TInt aRangeId, |
|
688 const TInt aRealCaseId, |
|
689 TBool aPermit) |
|
690 { |
|
691 // aRangeId is detailed range here |
|
692 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
693 { |
|
694 if (((iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) && |
|
695 (iIndicators[ii]->iInputRange == aRangeId)) || |
|
696 ((iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) && |
|
697 (iIndicators[ii]->iRangeType == ERangeTypeMixed) && |
|
698 (static_cast<CAknFepCtrlMultiModeButton*>(iIndicators[ii]->iIndicator)->IsGivenRangeSupported(aRangeId)))) |
|
699 { |
|
700 // single range multimode button OR mixed range multimode button |
|
701 static_cast<CAknFepCtrlMultiModeButton*>(iIndicators[ii]->iIndicator)->SetPermittedModes(aRangeId, aRealCaseId, aPermit); |
|
702 break; |
|
703 } |
|
704 } |
|
705 } |
|
706 |
|
707 // --------------------------------------------------------------------------- |
|
708 // CAknFepCtrlRangeBar::HideRange |
|
709 // hide given range |
|
710 // (other items were commented in a header). |
|
711 // --------------------------------------------------------------------------- |
|
712 // |
|
713 EXPORT_C void CAknFepCtrlRangeBar::HideRange(const TInt aRange) |
|
714 { |
|
715 // mixed range multimode button is not considerred here |
|
716 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
717 { |
|
718 if ( ( iIndicators[ ii ] ) && |
|
719 ( iIndicators[ ii ]->iInputRange == aRange ) && |
|
720 ( !iIndicators[ ii ]->iIsHide)) |
|
721 { |
|
722 iIndicators[ii]->iIndicator->Hide(ETrue); |
|
723 |
|
724 iIndicators[ ii ]->iIsHide = ETrue; |
|
725 |
|
726 if( iCellChanged ) |
|
727 { |
|
728 UpdateIndicatorRect(EFalse); |
|
729 } |
|
730 else |
|
731 { |
|
732 SetWholeRect(); |
|
733 iIsReloadImages = EFalse; |
|
734 //Draw(); |
|
735 SetIndicatorRect(); |
|
736 } |
|
737 |
|
738 break; |
|
739 } |
|
740 } |
|
741 } |
|
742 |
|
743 // --------------------------------------------------------------------------- |
|
744 // CAknFepCtrlRangeBar::HideRangeUsingIndicatorStyle |
|
745 // hide given range |
|
746 // (other items were commented in a header). |
|
747 // --------------------------------------------------------------------------- |
|
748 // |
|
749 EXPORT_C void CAknFepCtrlRangeBar::HideRangeUsingIndicatorStyle(const TInt aRange) |
|
750 { |
|
751 // mixed range multimode button is not considerred here |
|
752 TInt indiIdx = IndicatorIdxByRange(aRange); |
|
753 |
|
754 if (indiIdx == KErrNotFound) |
|
755 return; |
|
756 |
|
757 HideRangeForHidingIndicatorStyle(indiIdx, ETrue); |
|
758 |
|
759 UpdateIndicatorRectForUsingIndicatorStyle(EFalse); |
|
760 } |
|
761 |
|
762 // --------------------------------------------------------------------------- |
|
763 // CAknFepCtrlRangeBar::ShowRange |
|
764 // show given range |
|
765 // (other items were commented in a header). |
|
766 // --------------------------------------------------------------------------- |
|
767 // |
|
768 EXPORT_C void CAknFepCtrlRangeBar::ShowRange(const TInt aRange) |
|
769 { |
|
770 // mixed range multimode button is not considerred here |
|
771 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
772 { |
|
773 if ( ( iIndicators[ ii ] ) && |
|
774 ( iIndicators[ ii ]->iInputRange == aRange ) && |
|
775 ( iIndicators[ ii ]->iIsHide)) |
|
776 { |
|
777 iIndicators[ii]->iIndicator->Hide(EFalse); |
|
778 iIndicators[ ii ]->iIsHide = EFalse; |
|
779 |
|
780 if( iCellChanged ) |
|
781 { |
|
782 UpdateIndicatorRect(ETrue); |
|
783 } |
|
784 else |
|
785 { |
|
786 SetWholeRect(); |
|
787 iIsReloadImages = EFalse; |
|
788 |
|
789 //Draw(); |
|
790 SetIndicatorRect(); |
|
791 } |
|
792 |
|
793 break; |
|
794 } |
|
795 } |
|
796 } |
|
797 |
|
798 // --------------------------------------------------------------------------- |
|
799 // CAknFepCtrlRangeBar::ShowRangeUsingIndicatorStyle |
|
800 // show given range |
|
801 // (other items were commented in a header). |
|
802 // --------------------------------------------------------------------------- |
|
803 // |
|
804 EXPORT_C void CAknFepCtrlRangeBar::ShowRangeUsingIndicatorStyle(const TInt aRange) |
|
805 { |
|
806 // mixed range multimode button is not considerred here |
|
807 TInt indiIdx = IndicatorIdxByRange(aRange); |
|
808 |
|
809 if (indiIdx == KErrNotFound) |
|
810 return; |
|
811 |
|
812 HideRangeForHidingIndicatorStyle(indiIdx, EFalse); |
|
813 |
|
814 UpdateIndicatorRectForUsingIndicatorStyle(EFalse); |
|
815 } |
|
816 |
|
817 // --------------------------------------------------------------------------- |
|
818 // CAknFepCtrlRangeBar::AddRangeL |
|
819 // add range |
|
820 // (other items were commented in a header). |
|
821 // --------------------------------------------------------------------------- |
|
822 // |
|
823 EXPORT_C void CAknFepCtrlRangeBar::AddRangeL(TResourceReader& aReader) |
|
824 { |
|
825 const TInt16 rangeId = aReader.ReadInt16(); |
|
826 const TInt16 rangeType = aReader.ReadInt16(); |
|
827 const TInt16 ctrlId = aReader.ReadInt16(); |
|
828 const TInt16 ctrlType = aReader.ReadInt16(); |
|
829 const TInt32 resId = aReader.ReadInt32(); |
|
830 const TInt actionStyle = aReader.ReadInt16(); |
|
831 TBool hide = aReader.ReadInt16(); |
|
832 TInt posidx = aReader.ReadInt16(); |
|
833 |
|
834 CAknFepCtrlCommonButton* button = NULL; |
|
835 |
|
836 if (ctrlType != EButtonTypeMultiMode) |
|
837 { |
|
838 // normal button |
|
839 button = CAknFepCtrlCommonButton::NewLC(UiLayout(), ctrlId, |
|
840 KAknsIIDQsnFrFunctionButtonNormal, |
|
841 KAknsIIDQsnFrFunctionButtonPressed, |
|
842 KAknsIIDQsnFrFunctionButtonInactive ); |
|
843 button->SetResourceId(resId); |
|
844 button->ConstructFromResourceL(); |
|
845 } |
|
846 else |
|
847 { |
|
848 // Multiple display type button |
|
849 button = CAknFepCtrlMultiModeButton::NewLC(UiLayout(), ctrlId, |
|
850 KAknsIIDQsnFrFunctionButtonNormal, |
|
851 KAknsIIDQsnFrFunctionButtonPressed, |
|
852 KAknsIIDQsnFrFunctionButtonInactive); |
|
853 |
|
854 button->SetResourceId(resId); |
|
855 button->ConstructFromResourceL(); |
|
856 } |
|
857 |
|
858 button->AddEventObserver( this ); |
|
859 |
|
860 AddControlL( button ); |
|
861 CleanupStack::Pop(button); // button |
|
862 |
|
863 TAknFepRangeIndicator* indicator = new (ELeave) TAknFepRangeIndicator; |
|
864 CleanupStack::PushL( indicator ); |
|
865 |
|
866 indicator->iCtrlType = ctrlType; |
|
867 indicator->iInputRange = rangeId; |
|
868 indicator->iRangeType = rangeType; |
|
869 indicator->iCtrlId = ctrlId; |
|
870 //indicator->iIsHide = EFalse; |
|
871 indicator->iIsHide = hide; |
|
872 if (hide) |
|
873 button->Hide(ETrue); |
|
874 indicator->iIndicator = button; |
|
875 indicator->iActionStyle = actionStyle; |
|
876 indicator->iPosIdx = posidx; |
|
877 |
|
878 User::LeaveIfError( iIndicators.Append(indicator) ); |
|
879 CleanupStack::Pop(indicator); // indicator |
|
880 } |
|
881 |
|
882 // --------------------------------------------------------------------------- |
|
883 // CAknFepCtrlRangeBar::GetCase |
|
884 // get mode of given range |
|
885 // (other items were commented in a header). |
|
886 // --------------------------------------------------------------------------- |
|
887 // |
|
888 EXPORT_C TInt CAknFepCtrlRangeBar::GetCase(TInt aRange) const |
|
889 { |
|
890 // get current real case of aRange |
|
891 // aRange is detailed range here, for mixed range multimode button, it contained in one range of it |
|
892 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
893 { |
|
894 if (iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) |
|
895 { |
|
896 CAknFepCtrlMultiModeButton* button = static_cast<CAknFepCtrlMultiModeButton*> |
|
897 (iIndicators[ii]->iIndicator); |
|
898 |
|
899 if ( ( (iIndicators[ii]->iRangeType == ERangeTypeMixed) && |
|
900 (button->IsGivenRangeSupported(aRange)) && |
|
901 ((button->RangeOfGivenMode(button->CurrentMode()) == aRange)) ) |
|
902 || (iIndicators[ii]->iInputRange == aRange)) |
|
903 { |
|
904 return button->GetRealCaseByMode(button->CurrentMode()); |
|
905 } |
|
906 } |
|
907 } |
|
908 |
|
909 return KErrNotFound; |
|
910 } |
|
911 |
|
912 // ----------------------------------------------------------------------------- |
|
913 // Implementation of CAknFepCtrlRangeBar::SetFont |
|
914 // ----------------------------------------------------------------------------- |
|
915 // |
|
916 EXPORT_C void CAknFepCtrlRangeBar::SetFont(const CFont* aFont) |
|
917 { |
|
918 iFont = aFont; |
|
919 |
|
920 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
921 { |
|
922 if (iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) |
|
923 { |
|
924 static_cast<CAknFepCtrlMultiModeButton*>(iIndicators[ii]->iIndicator)->SetFont(iFont); |
|
925 |
|
926 break; |
|
927 } |
|
928 } |
|
929 } |
|
930 |
|
931 // ----------------------------------------------------------------------------- |
|
932 // Implementation of CAknFepCtrlRangeBar::Move |
|
933 // ----------------------------------------------------------------------------- |
|
934 // |
|
935 EXPORT_C void CAknFepCtrlRangeBar::Move(const TPoint& aOffset) |
|
936 { |
|
937 CControlGroup::Move(aOffset); |
|
938 |
|
939 iIndicatorRect.Move(aOffset); |
|
940 } |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // CAknFepCtrlRangeBar::SetEventIdForRange |
|
944 // set event id when range is clicked |
|
945 // (other items were commented in a header). |
|
946 // ----------------------------------------------------------------------------- |
|
947 // |
|
948 EXPORT_C void CAknFepCtrlRangeBar::SetEventIdForRange(TInt aEventId) |
|
949 { |
|
950 iEventIdForRange = aEventId; |
|
951 } |
|
952 |
|
953 // ----------------------------------------------------------------------------- |
|
954 // CAknFepCtrlRangeBar::SetEventIdForCase |
|
955 // set event id when case is clicked |
|
956 // (other items were commented in a header). |
|
957 // ----------------------------------------------------------------------------- |
|
958 // |
|
959 EXPORT_C void CAknFepCtrlRangeBar::SetEventIdForCase(TInt aEventId) |
|
960 { |
|
961 iEventIdForCase = aEventId; |
|
962 } |
|
963 |
|
964 |
|
965 // ----------------------------------------------------------------------------- |
|
966 // CAknFepCtrlRangeBar::ShowAllRanges |
|
967 // Display all ranges whether it is IsHide |
|
968 // (other items were commented in a header). |
|
969 // ----------------------------------------------------------------------------- |
|
970 // |
|
971 EXPORT_C void CAknFepCtrlRangeBar::ShowAllRanges() |
|
972 { |
|
973 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
974 { |
|
975 iIndicators[ii]->iIsHide = EFalse; |
|
976 iIndicators[ii]->iIndicator->Hide(EFalse); |
|
977 } |
|
978 |
|
979 if( iCellChanged ) |
|
980 { |
|
981 iActionStyle == ERangeBarUsingIndicatorStyle ? |
|
982 UpdateIndicatorRectForUsingIndicatorStyle(EFalse) : |
|
983 UpdateIndicatorRect(EFalse); |
|
984 } |
|
985 else |
|
986 { |
|
987 SetWholeRect(); |
|
988 iIsReloadImages = EFalse; |
|
989 //Draw(); |
|
990 SetIndicatorRect(); |
|
991 } |
|
992 } |
|
993 |
|
994 // ----------------------------------------------------------------------------- |
|
995 // CAknFepCtrlRangeBar::SetWholeRect |
|
996 // Set rect of whole range bar |
|
997 // (other items were commented in a header). |
|
998 // ----------------------------------------------------------------------------- |
|
999 // |
|
1000 void CAknFepCtrlRangeBar::SetWholeRect() |
|
1001 { |
|
1002 if (iStyle == EBtnGroupVertical) |
|
1003 { |
|
1004 SetRect(TRect(iIndicatorRect.iTl, |
|
1005 TPoint(iIndicatorRect.iTl.iX + iIndicatorRect.Width(), |
|
1006 iIndicatorRect.iTl.iY + |
|
1007 iIndicatorRect.Height() * (NumOfControls() - NumOfHidedRange())))); |
|
1008 } |
|
1009 else |
|
1010 { |
|
1011 SetRect(TRect(iIndicatorRect.iTl, |
|
1012 TPoint(iIndicatorRect.iTl.iX + |
|
1013 iIndicatorRect.Width() * (NumOfControls() - NumOfHidedRange()), |
|
1014 iIndicatorRect.iTl.iY + iIndicatorRect.Height()))); |
|
1015 } |
|
1016 } |
|
1017 |
|
1018 // ----------------------------------------------------------------------------- |
|
1019 // CAknFepCtrlRangeBar::NumOfHidedRange |
|
1020 // Get number of hided input ranges |
|
1021 // (other items were commented in a header). |
|
1022 // ----------------------------------------------------------------------------- |
|
1023 // |
|
1024 TInt CAknFepCtrlRangeBar::NumOfHidedRange() |
|
1025 { |
|
1026 TInt numOfHidedRange = 0; |
|
1027 |
|
1028 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
1029 { |
|
1030 if (iIndicators[ ii ]->iIsHide) |
|
1031 { |
|
1032 numOfHidedRange++; |
|
1033 } |
|
1034 } |
|
1035 |
|
1036 return numOfHidedRange; |
|
1037 } |
|
1038 |
|
1039 |
|
1040 // ----------------------------------------------------------------------------- |
|
1041 // CAknFepCtrlRangeBar::SetActionStyle |
|
1042 // set action style |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 // |
|
1045 EXPORT_C void CAknFepCtrlRangeBar::SetActionStyle(TRangeBarActionStyle aActionStyle) |
|
1046 { |
|
1047 iActionStyle = aActionStyle; |
|
1048 } |
|
1049 |
|
1050 // ----------------------------------------------------------------------------- |
|
1051 // CAknFepCtrlRangeBar::IndicatorIdxByRange |
|
1052 // get indicator index by range |
|
1053 // ----------------------------------------------------------------------------- |
|
1054 // |
|
1055 TInt CAknFepCtrlRangeBar::IndicatorIdxByRange(TInt aRange) |
|
1056 { |
|
1057 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
1058 { |
|
1059 if ( IsMixedRange(ii) ) |
|
1060 { |
|
1061 CAknFepCtrlMultiModeButton* button = static_cast<CAknFepCtrlMultiModeButton*> |
|
1062 (iIndicators[ii]->iIndicator); |
|
1063 if ( button->RangeOfGivenMode(button->NextMode()) == aRange || |
|
1064 button->RangeOfGivenMode(button->CurrentMode()) == aRange ) |
|
1065 { |
|
1066 return ii; |
|
1067 } |
|
1068 } |
|
1069 else if (iIndicators[ii]->iInputRange == aRange) |
|
1070 { |
|
1071 return ii; |
|
1072 } |
|
1073 } |
|
1074 |
|
1075 return KErrNotFound; |
|
1076 } |
|
1077 |
|
1078 // ----------------------------------------------------------------------------- |
|
1079 // CAknFepCtrlRangeBar::ActiveRange |
|
1080 // active range |
|
1081 // ----------------------------------------------------------------------------- |
|
1082 // |
|
1083 EXPORT_C void CAknFepCtrlRangeBar::ActiveRange(TInt aRange) |
|
1084 { |
|
1085 TInt indiIdx = IndicatorIdxByRange(aRange); |
|
1086 |
|
1087 if (indiIdx == KErrNotFound) |
|
1088 return; |
|
1089 |
|
1090 if (iActionStyle == ERangeBarActionStyleHide || |
|
1091 (iActionStyle == ERangeBarUsingIndicatorStyle && |
|
1092 iIndicators[indiIdx]->iActionStyle == EIndicatorActionStyleHide)) |
|
1093 { |
|
1094 TBool needChange = EFalse; |
|
1095 |
|
1096 if (!iIndicators[indiIdx]->iIndicator->IsDimmed() && iIndicators[indiIdx]->iIndicator) |
|
1097 { |
|
1098 needChange = ETrue; |
|
1099 iInputRange = iIndicators[indiIdx]->iInputRange; |
|
1100 SetActiveCtrl(iIndicators[indiIdx]->iIndicator); |
|
1101 } |
|
1102 |
|
1103 if (needChange) |
|
1104 { |
|
1105 if (iActionStyle == ERangeBarActionStyleHide) |
|
1106 { |
|
1107 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
1108 { |
|
1109 if (ii == indiIdx) |
|
1110 { |
|
1111 iIndicators[ii]->iIndicator->Hide(ETrue); |
|
1112 iIndicators[ii]->iIsHide = ETrue; |
|
1113 } |
|
1114 else if (iIndicators[ii]->iIsHide) |
|
1115 { |
|
1116 iIndicators[ii]->iIsHide = EFalse; |
|
1117 iIndicators[ii]->iIndicator->Hide(EFalse); |
|
1118 } |
|
1119 } |
|
1120 if (iCellChanged ) |
|
1121 { |
|
1122 UpdateIndicatorRect( EFalse ); |
|
1123 } |
|
1124 else |
|
1125 { |
|
1126 SetWholeRect(); |
|
1127 iIsReloadImages = EFalse; |
|
1128 //Draw(); |
|
1129 SetIndicatorRect(); |
|
1130 } |
|
1131 } |
|
1132 else |
|
1133 { |
|
1134 HideRangeForHidingIndicatorStyle(indiIdx, ETrue); |
|
1135 UpdateIndicatorRectForUsingIndicatorStyle(EFalse); |
|
1136 } |
|
1137 } |
|
1138 } |
|
1139 else |
|
1140 { |
|
1141 // whole range bar's action style is highlight, or it depends on each indicator's |
|
1142 // action style, which is highlight or just visible |
|
1143 SetRange(aRange); |
|
1144 } |
|
1145 |
|
1146 for (TInt ii = 0; ii < iIndicators.Count(); ++ii) |
|
1147 { |
|
1148 TBool highlight = |
|
1149 iIndicators[ii]->iIndicator->IsActive() && !iIndicators[ii]->iIndicator->Hiden(); |
|
1150 iIndicators[ii]->iIndicator->SetHighlight(highlight); |
|
1151 } |
|
1152 } |
|
1153 |
|
1154 // ----------------------------------------------------------------------------- |
|
1155 // CAknFepCtrlRangeBar::IsMixedRange |
|
1156 // Judge if button in given index has mixed range |
|
1157 // (other items were commented in a header). |
|
1158 // ----------------------------------------------------------------------------- |
|
1159 // |
|
1160 TBool CAknFepCtrlRangeBar::IsMixedRange(const TInt aIndex) |
|
1161 { |
|
1162 if ((aIndex >= 0) && |
|
1163 (aIndex <= iIndicators.Count()-1) && |
|
1164 (iIndicators[aIndex]->iCtrlType == EButtonTypeMultiMode) && |
|
1165 (iIndicators[aIndex]->iRangeType == ERangeTypeMixed)) |
|
1166 { |
|
1167 return ETrue; |
|
1168 } |
|
1169 |
|
1170 return EFalse; |
|
1171 } |
|
1172 |
|
1173 // ----------------------------------------------------------------------------- |
|
1174 // CAknFepCtrlRangeBar::ReportEventToObserver |
|
1175 // Report range or case event to observer |
|
1176 // (other items were commented in a header). |
|
1177 // ----------------------------------------------------------------------------- |
|
1178 // |
|
1179 void CAknFepCtrlRangeBar::ReportEventToObserver(const TInt aEventId, const TInt aEventData) |
|
1180 { |
|
1181 TPtrC ptr; |
|
1182 TInt sendData = aEventData; |
|
1183 ptr.Set(reinterpret_cast<TText*>(&sendData),sizeof(aEventData)); |
|
1184 |
|
1185 ReportEvent(aEventId, ptr); |
|
1186 } |
|
1187 |
|
1188 EXPORT_C void CAknFepCtrlRangeBar::SetDispalyCellRectsL( const RArray<TRect>& aRects, |
|
1189 const RArray<TRect>& aInnerRects ) |
|
1190 { |
|
1191 iCellChanged = ETrue; |
|
1192 iCellRects.Close(); |
|
1193 iCellInnerRects.Close(); |
|
1194 for( TInt i = 0; i < aRects.Count(); i++ ) |
|
1195 { |
|
1196 iCellRects.AppendL( aRects[i] ); |
|
1197 } |
|
1198 |
|
1199 for( TInt i = 0; i < aInnerRects.Count(); i++ ) |
|
1200 { |
|
1201 iCellInnerRects.AppendL( aInnerRects[i] ); |
|
1202 } |
|
1203 |
|
1204 iActionStyle == ERangeBarUsingIndicatorStyle ? |
|
1205 UpdateIndicatorRectForUsingIndicatorStyle(ETrue) : |
|
1206 UpdateIndicatorRect(ETrue); |
|
1207 } |
|
1208 |
|
1209 void CAknFepCtrlRangeBar::UpdateIndicatorRect( TBool aUpdateImage) |
|
1210 { |
|
1211 TInt index = 0; |
|
1212 for (TInt ii = 0; ii < iIndicators.Count() && iCellRects.Count() > 0; ++ii) |
|
1213 { |
|
1214 TPoint offset( iIndicatorRect.iTl.iX, iIndicatorRect.iTl.iY ); |
|
1215 if (!iIndicators[ii]->iIsHide ) |
|
1216 { |
|
1217 CAknFepCtrlCommonButton* button = iIndicators[ii]->iIndicator; |
|
1218 if( button ) |
|
1219 { |
|
1220 TInt n = index++; |
|
1221 TRect btnRect( iCellRects[n] ); |
|
1222 TRect btnInnerRect( iCellInnerRects[n] ); |
|
1223 //btnRect.Move( offset ); |
|
1224 if (iIndicators[ii]->iCtrlType == EButtonTypeMultiMode) |
|
1225 { |
|
1226 static_cast<CAknFepCtrlMultiModeButton*>(iIndicators[ii]->iIndicator)-> |
|
1227 SizeChanged(btnRect, btnInnerRect, aUpdateImage); |
|
1228 } |
|
1229 else |
|
1230 { |
|
1231 static_cast<CAknFepCtrlCommonButton*>(iIndicators[ii]->iIndicator)-> |
|
1232 SizeChanged(btnRect, btnInnerRect, aUpdateImage); |
|
1233 } |
|
1234 } |
|
1235 if( index == iCellRects.Count() ) |
|
1236 break; |
|
1237 } |
|
1238 } |
|
1239 } |
|
1240 |
|
1241 void CAknFepCtrlRangeBar::UpdateIndicatorRectForUsingIndicatorStyle(TBool aUpdateImage) |
|
1242 { |
|
1243 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
1244 { |
|
1245 if (/*!iIndicators[ii]->iIsHide && */ |
|
1246 iIndicators[ii]->iIndicator && |
|
1247 iIndicators[ii]->iPosIdx >= 0 && |
|
1248 iIndicators[ii]->iPosIdx < iCellRects.Count()) |
|
1249 { |
|
1250 iIndicators[ii]->iIndicator->SizeChanged(iCellRects[iIndicators[ii]->iPosIdx], |
|
1251 iCellInnerRects[iIndicators[ii]->iPosIdx], |
|
1252 aUpdateImage); |
|
1253 } |
|
1254 } |
|
1255 } |
|
1256 |
|
1257 void CAknFepCtrlRangeBar::HideRangeForHidingIndicatorStyle(TInt aIdx, |
|
1258 TBool aHide) |
|
1259 { |
|
1260 RArray<TInt> permitRangeInxArray; |
|
1261 TInt maxPos = 0; |
|
1262 |
|
1263 // Get all the permitted range index array |
|
1264 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
1265 { |
|
1266 maxPos = iIndicators[ii]->iPosIdx > maxPos ? iIndicators[ii]->iPosIdx : maxPos; |
|
1267 |
|
1268 if( !(iIndicators[ii]->iIndicator->IsDimmed() ) && iIndicators[ii]->iPosIdx >=0 ) |
|
1269 { |
|
1270 permitRangeInxArray.Append(ii); |
|
1271 } |
|
1272 } |
|
1273 |
|
1274 TBool showAllPermittedRange = ETrue; |
|
1275 |
|
1276 // compare the position for every permitted range |
|
1277 if( permitRangeInxArray.Count() == maxPos + 1 ) |
|
1278 { |
|
1279 for(TInt n = 0; n < permitRangeInxArray.Count(); n++) |
|
1280 { |
|
1281 for( TInt m = n+1; m < permitRangeInxArray.Count(); m++ ) |
|
1282 { |
|
1283 if( iIndicators[permitRangeInxArray[n]]->iPosIdx == |
|
1284 iIndicators[permitRangeInxArray[m]]->iPosIdx ) |
|
1285 { |
|
1286 showAllPermittedRange = EFalse; |
|
1287 break; |
|
1288 } |
|
1289 } |
|
1290 } |
|
1291 } |
|
1292 else |
|
1293 { |
|
1294 showAllPermittedRange = EFalse; |
|
1295 } |
|
1296 |
|
1297 permitRangeInxArray.Reset(); |
|
1298 permitRangeInxArray.Close(); |
|
1299 |
|
1300 if( !showAllPermittedRange ) // hide style |
|
1301 { |
|
1302 if (iIndicators[aIdx]->iIsHide != aHide && |
|
1303 iIndicators[aIdx]->iIndicator) |
|
1304 { |
|
1305 TBool canShowNext = ETrue; |
|
1306 |
|
1307 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
1308 { |
|
1309 if (ii != aIdx && iIndicators[ii]->iPosIdx == iIndicators[aIdx]->iPosIdx) |
|
1310 { |
|
1311 if ( iIndicators[ii]->iIndicator->IsDimmed() ) |
|
1312 { |
|
1313 canShowNext = EFalse; |
|
1314 } |
|
1315 else |
|
1316 { |
|
1317 iIndicators[ii]->iIndicator->Hide(!aHide); |
|
1318 iIndicators[ii]->iIsHide = !aHide; |
|
1319 } |
|
1320 |
|
1321 if (aHide) |
|
1322 break; |
|
1323 } |
|
1324 } |
|
1325 |
|
1326 iIndicators[aIdx]->iIndicator->Hide( canShowNext && aHide); |
|
1327 iIndicators[aIdx]->iIsHide = canShowNext && aHide; |
|
1328 } |
|
1329 } |
|
1330 else |
|
1331 { |
|
1332 // Set the range for special state |
|
1333 for (TInt ii = 0; ii < iIndicators.Count(); ii++) |
|
1334 { |
|
1335 if( iIndicators[ii]->iIndicator->IsDimmed() ) |
|
1336 { |
|
1337 iIndicators[ii]->iIndicator->Hide(ETrue); |
|
1338 iIndicators[ii]->iIsHide = ETrue; |
|
1339 } |
|
1340 else |
|
1341 { |
|
1342 iIndicators[ii]->iIndicator->Hide(EFalse); |
|
1343 iIndicators[ii]->iIsHide = EFalse; |
|
1344 } |
|
1345 } |
|
1346 |
|
1347 } |
|
1348 } |
|
1349 // End Of File |
|