24 #include "CMIDForm.h" |
24 #include "CMIDForm.h" |
25 // API for items on rows |
25 // API for items on rows |
26 #include "CMIDControlItem.h" |
26 #include "CMIDControlItem.h" |
27 #include "CMIDItemLabel.h" |
27 #include "CMIDItemLabel.h" |
28 |
28 |
|
29 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
30 #include "CMIDLabelContainerItem.h" |
|
31 |
|
32 #include <AknsUtils.h> |
|
33 #include <aknlayoutscalable_avkon.cdl.h> |
|
34 |
|
35 // CONSTANTS |
|
36 // Default for Form separator line color's alpha value, used if not |
|
37 // found from skin. |
|
38 const TInt KDefaultSeparatorAlpha = 32; |
|
39 const TInt KDefaultSeparatorColor = 0; |
|
40 #endif // RD_JAVA_S60_RELEASE_9_2 |
29 |
41 |
30 CMIDFormRow* CMIDFormRow::NewL(CMIDForm& aForm) |
42 CMIDFormRow* CMIDFormRow::NewL(CMIDForm& aForm) |
31 { |
43 { |
32 CMIDFormRow* self = new(ELeave) CMIDFormRow(aForm); |
44 CMIDFormRow* self = new(ELeave) CMIDFormRow(aForm); |
33 CleanupStack::PushL(self); |
45 CleanupStack::PushL(self); |
61 |
73 |
62 CCoeControl* CMIDFormRow::ComponentControl(TInt aIndex) const |
74 CCoeControl* CMIDFormRow::ComponentControl(TInt aIndex) const |
63 { |
75 { |
64 return iItems[aIndex]; |
76 return iItems[aIndex]; |
65 } |
77 } |
|
78 |
|
79 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
80 void CMIDFormRow::Draw(const TRect& /*aRect*/) const |
|
81 { |
|
82 if (iSeparator) |
|
83 { |
|
84 CWindowGc& gc = SystemGc(); |
|
85 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
86 gc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
87 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
88 |
|
89 TRgb color; |
|
90 TInt err = AknsUtils::GetCachedColor(skin, |
|
91 color, |
|
92 KAknsIIDQsnTextColors, |
|
93 EAknsCIQsnTextColorsCG6); |
|
94 if (err != KErrNone) |
|
95 { |
|
96 color = KDefaultSeparatorColor; |
|
97 } |
|
98 |
|
99 TRgb colorFromSkin; |
|
100 // Get alpha value from skin, if not successful, default is used. |
|
101 err = AknsUtils::GetCachedColor(skin ? skin : AknsUtils::SkinInstance(), |
|
102 colorFromSkin, |
|
103 KAknsIIDQsnLineColors, |
|
104 EAknsCIQsnLineColorsCG15); |
|
105 |
|
106 color.SetAlpha(!err ? colorFromSkin.Red() : KDefaultSeparatorAlpha); |
|
107 gc.SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
108 gc.SetPenColor(color); |
|
109 |
|
110 // Draw line to upper part of the form row. |
|
111 TRect lineRect(Rect()); |
|
112 // Using same margin value with avkon list box separator lines. |
|
113 TInt gap = AknLayoutScalable_Avkon::listscroll_gen_pane(0).LayoutLine().it; |
|
114 lineRect.Shrink(gap, 0); |
|
115 lineRect.Move(0, 1); |
|
116 gc.DrawLine(TPoint(lineRect.iTl.iX, lineRect.iTl.iY), |
|
117 TPoint(lineRect.iBr.iX, lineRect.iTl.iY)); |
|
118 } |
|
119 } |
|
120 #endif // RD_JAVA_S60_RELEASE_9_2 |
66 |
121 |
67 void CMIDFormRow::SizeChanged() |
122 void CMIDFormRow::SizeChanged() |
68 { |
123 { |
69 TInt xOff = 0; |
124 TInt xOff = 0; |
70 |
125 |
161 else |
216 else |
162 { |
217 { |
163 User::LeaveIfError(iItems.Insert(aItem, 0)); |
218 User::LeaveIfError(iItems.Insert(aItem, 0)); |
164 } |
219 } |
165 iCurrentWidth += aItem->Size().iWidth; |
220 iCurrentWidth += aItem->Size().iWidth; |
|
221 |
|
222 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
223 SetSeparator(); |
|
224 #endif // RD_JAVA_S60_RELEASE_9_2 |
166 } |
225 } |
167 |
226 |
168 void CMIDFormRow::SetAlignment(MMIDItem::TLayout aAlignment) |
227 void CMIDFormRow::SetAlignment(MMIDItem::TLayout aAlignment) |
169 { |
228 { |
170 ASSERT((aAlignment == MMIDItem::ELeft) || (aAlignment == MMIDItem::ERight) || (aAlignment == MMIDItem::ECenter)); |
229 ASSERT((aAlignment == MMIDItem::ELeft) || (aAlignment == MMIDItem::ERight) || (aAlignment == MMIDItem::ECenter)); |
495 } |
554 } |
496 |
555 |
497 return ret; |
556 return ret; |
498 } |
557 } |
499 |
558 |
|
559 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
560 void CMIDFormRow::SetSeparator() |
|
561 { |
|
562 // Separator is not drawn above the first row. |
|
563 if (iForm.FormRowIndex(this) <= 0) |
|
564 { |
|
565 iSeparator = EFalse; |
|
566 return; |
|
567 } |
|
568 else |
|
569 { |
|
570 iSeparator = ETrue; |
|
571 } |
|
572 |
|
573 // Separator is not drawn if the rows includes only spacers |
|
574 if (!HasNonSpacerItems()) |
|
575 { |
|
576 iSeparator = EFalse; |
|
577 return; |
|
578 } |
|
579 |
|
580 if (Item(0)->HasLabel()) |
|
581 { |
|
582 iSeparator = ETrue; |
|
583 return; |
|
584 } |
|
585 else |
|
586 { |
|
587 // If the first item is other than StringItem then draw separator. |
|
588 if (!CMIDForm::IsLabelContainerItem(*Item(0))) |
|
589 { |
|
590 iSeparator = ETrue; |
|
591 return; |
|
592 } |
|
593 else |
|
594 { |
|
595 // If Button type StringItem then separator is drawn. |
|
596 if (CMIDForm::IsStringItemButton(*Item(0))) |
|
597 { |
|
598 iSeparator = ETrue; |
|
599 return; |
|
600 } |
|
601 |
|
602 CMIDLabelContainerItem* ucsi = static_cast<CMIDLabelContainerItem*>(Item(0)); |
|
603 // If the first item is label, then draw separator. |
|
604 if (ucsi && !ucsi->IsStringItemContent()) |
|
605 { |
|
606 iSeparator = ETrue; |
|
607 return; |
|
608 } |
|
609 else |
|
610 { |
|
611 // If the last item in the previous row is StringItem, |
|
612 // then do not draw separator. |
|
613 TInt prevRowIndex = iForm.FormRowIndex(this) - 1; |
|
614 if (prevRowIndex >= 0) |
|
615 { |
|
616 CMIDFormRow* prevRow = iForm.FormRow(prevRowIndex); |
|
617 TInt index = 0; |
|
618 if (prevRow) |
|
619 { |
|
620 index = prevRow->NumItems(); |
|
621 |
|
622 // If there are items in previous row check if row is StrinItem |
|
623 if (index >= 1) |
|
624 { |
|
625 CMIDControlItem* lastPrevItem = prevRow->Item(index - 1); |
|
626 |
|
627 if (lastPrevItem && CMIDForm::IsLabelContainerItem(*lastPrevItem)) |
|
628 { |
|
629 iSeparator = EFalse; |
|
630 return; |
|
631 } |
|
632 else |
|
633 { |
|
634 iSeparator = ETrue; |
|
635 return; |
|
636 } |
|
637 } |
|
638 else |
|
639 { |
|
640 iSeparator = ETrue; |
|
641 return; |
|
642 } |
|
643 } |
|
644 } |
|
645 } |
|
646 } |
|
647 } |
|
648 } |
|
649 #endif // RD_JAVA_S60_RELEASE_9_2 |
500 // End of File |
650 // End of File |