157 } |
157 } |
158 |
158 |
159 /** |
159 /** |
160 * Inserts a new Item. |
160 * Inserts a new Item. |
161 */ |
161 */ |
162 void CMIDForm::InsertItemL(MMIDItem& aItem,TInt aIndex) |
162 void CMIDForm::InsertItemL(MMIDItem& aItem, TInt aIndex) |
163 { |
163 { |
164 DEBUG("CMIDForm::InsertItemL"); |
164 DEBUG("CMIDForm::InsertItemL"); |
165 |
165 |
166 User::LeaveIfError(iItems.Insert(&aItem,aIndex)); |
166 User::LeaveIfError(iItems.Insert(&aItem,aIndex)); |
167 CMIDControlItem& ci = ControlItem(aIndex); |
167 CMIDControlItem& ci = ControlItem(aIndex); |
336 if (iFocused != KErrNotFound) |
336 if (iFocused != KErrNotFound) |
337 { |
337 { |
338 CMIDControlItem& controlItem = ControlItem(iFocused); |
338 CMIDControlItem& controlItem = ControlItem(iFocused); |
339 TRect controlRect = GetControlRect(iFocused); |
339 TRect controlRect = GetControlRect(iFocused); |
340 TBool visible = RectPartiallyVisible(controlRect); |
340 TBool visible = RectPartiallyVisible(controlRect); |
|
341 |
|
342 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
343 TInt numItemCommands = controlItem.CommandList()->Count(); |
|
344 |
|
345 // If focused form item does not have any commands, |
|
346 // and select key was pressed try to show screen\help option menu. |
|
347 // ChoiceGroup and DateField handles this case separately. |
|
348 // Gauge enter key is also handled here, |
|
349 // so it would behave the same way as selection key. |
|
350 if (numItemCommands == 0 && aType == EEventKey && |
|
351 controlItem.Type() != MMIDComponent::EChoiceGroup && |
|
352 controlItem.Type() != MMIDComponent::EDateField && |
|
353 (aKeyEvent.iScanCode == EStdKeyDevice3 || |
|
354 (aKeyEvent.iScanCode == EStdKeyEnter && |
|
355 controlItem.Type() == MMIDComponent::EGauge))) |
|
356 { |
|
357 iDisplayable.ShowScreenOrHelpOptionsMenuL(); |
|
358 } |
|
359 #endif // RD_JAVA_S60_RELEASE_9_2 |
341 |
360 |
342 // arrow key events are not sent to the hidden focused item |
361 // arrow key events are not sent to the hidden focused item |
343 if ((visible || !isArrowKey) && |
362 if ((visible || !isArrowKey) && |
344 controlItem.OfferKeyEventL(aKeyEvent,aType) == EKeyWasConsumed) |
363 controlItem.OfferKeyEventL(aKeyEvent,aType) == EKeyWasConsumed) |
345 { |
364 { |
2312 KAknsIIDQsnBgAreaMainListGene, Rect(), ETrue, |
2331 KAknsIIDQsnBgAreaMainListGene, Rect(), ETrue, |
2313 KAknsIIDQsnBgColumnAB, Rect()) ; // Rect parameters are only place-holders |
2332 KAknsIIDQsnBgColumnAB, Rect()) ; // Rect parameters are only place-holders |
2314 |
2333 |
2315 // Background for highlighted item, frame rects are set later |
2334 // Background for highlighted item, frame rects are set later |
2316 iHighlightedBackgroundCc = CAknsFrameBackgroundControlContext::NewL( |
2335 iHighlightedBackgroundCc = CAknsFrameBackgroundControlContext::NewL( |
2317 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
2318 KAknsIIDQsnFrPopupPreview, |
|
2319 #else |
|
2320 KAknsIIDQsnFrInput, |
2336 KAknsIIDQsnFrInput, |
2321 #endif // RD_JAVA_S60_RELEASE_9_2 |
|
2322 TRect(), TRect(), ETrue); |
2337 TRect(), TRect(), ETrue); |
2323 |
2338 |
2324 iDisplayable.SetComponentL(*this); |
2339 iDisplayable.SetComponentL(*this); |
2325 |
2340 |
2326 // get the layout from shared data so we can tell what our |
2341 // get the layout from shared data so we can tell what our |
3154 void CMIDForm::InsertContainerItemsL(CMIDStringItem& aStringItem, |
3169 void CMIDForm::InsertContainerItemsL(CMIDStringItem& aStringItem, |
3155 CMIDItemLabel& aTextControl, TBool aIsStringItemContent) |
3170 CMIDItemLabel& aTextControl, TBool aIsStringItemContent) |
3156 { |
3171 { |
3157 TInt numLines = aTextControl.NumLines(); |
3172 TInt numLines = aTextControl.NumLines(); |
3158 for (TInt j = 0; j < numLines; j++) |
3173 for (TInt j = 0; j < numLines; j++) |
3159 { // insert every line as a CMIDLabelContainerItem |
3174 { |
3160 CreateAndAddLabelContainerItemL( |
3175 CEikLabel* label = aTextControl.LabelAtIdx(j); |
3161 aStringItem, *(aTextControl.LabelAtIdx(j)), aIsStringItemContent); |
3176 |
|
3177 if (label) |
|
3178 { |
|
3179 CGraphicsContext::TTextAlign align = aTextControl.LabelAtIdx(j)->iAlignment.TextAlign(); |
|
3180 |
|
3181 // If aLabel aligment is incorrect relayout aLabel |
|
3182 if ((align != CGraphicsContext::ERight && |
|
3183 iInitialAlignment == MMIDItem::ERight) || |
|
3184 (align != CGraphicsContext::ELeft && |
|
3185 iInitialAlignment == MMIDItem::ELeft) || |
|
3186 (align != CGraphicsContext::ECenter && |
|
3187 iInitialAlignment == MMIDItem::ECenter)) |
|
3188 { |
|
3189 aTextControl.LayoutItemLabel(); |
|
3190 } |
|
3191 |
|
3192 // insert every line as a CMIDLabelContainerItem |
|
3193 CreateAndAddLabelContainerItemL( |
|
3194 aStringItem, *(label), aIsStringItemContent); |
|
3195 } |
3162 |
3196 |
3163 if (j != (numLines-1)) |
3197 if (j != (numLines-1)) |
3164 { // insert a row break except for the last line |
3198 { // insert a row break except for the last line |
3165 CreateNewRowAndSetAsCurrentL(); |
3199 CreateNewRowAndSetAsCurrentL(); |
3166 } |
3200 } |
3545 return EFalse; |
3579 return EFalse; |
3546 } |
3580 } |
3547 return (aControlItem.iMMidItem->Type() == MMIDComponent::EChoiceGroup); |
3581 return (aControlItem.iMMidItem->Type() == MMIDComponent::EChoiceGroup); |
3548 } |
3582 } |
3549 |
3583 |
|
3584 TBool CMIDForm::IsPopupChoiceGroup(CMIDControlItem& aControlItem) |
|
3585 { |
|
3586 if (aControlItem.iMMidItem |
|
3587 && aControlItem.iMMidItem->Type() == MMIDComponent::EChoiceGroup) |
|
3588 { |
|
3589 CMIDChoiceGroupItem& cgItem = static_cast<CMIDChoiceGroupItem&>(aControlItem); |
|
3590 CMIDChoiceGroupControl* cgControl = |
|
3591 static_cast<CMIDChoiceGroupControl*>(cgItem.ComponentControl(1)); |
|
3592 if (cgControl && cgControl->ChoiceType() == MMIDChoiceGroup::EPopup) |
|
3593 { |
|
3594 return ETrue; |
|
3595 } |
|
3596 } |
|
3597 return EFalse; |
|
3598 } |
|
3599 |
3550 TBool CMIDForm::IsDateField(CMIDControlItem& aControlItem) |
3600 TBool CMIDForm::IsDateField(CMIDControlItem& aControlItem) |
3551 { |
3601 { |
3552 if (!aControlItem.iMMidItem) |
3602 if (!aControlItem.iMMidItem) |
3553 { |
3603 { |
3554 return EFalse; |
3604 return EFalse; |
3596 { |
3646 { |
3597 CMIDChoiceGroupItem* cgItem = static_cast<CMIDChoiceGroupItem*>(&item); |
3647 CMIDChoiceGroupItem* cgItem = static_cast<CMIDChoiceGroupItem*>(&item); |
3598 cgItem->PostPendingUpEventL(); |
3648 cgItem->PostPendingUpEventL(); |
3599 } |
3649 } |
3600 } |
3650 } |
|
3651 } |
|
3652 |
|
3653 TInt CMIDForm::FormRowIndex(CMIDFormRow* aRow) |
|
3654 { |
|
3655 return iRows.Find(aRow); |
|
3656 } |
|
3657 |
|
3658 CMIDFormRow* CMIDForm::FormRow(TInt aIndex) |
|
3659 { |
|
3660 if (iRows.Count() > aIndex) |
|
3661 { |
|
3662 return iRows[aIndex]; |
|
3663 } |
|
3664 return NULL; |
3601 } |
3665 } |
3602 #endif // RD_JAVA_S60_RELEASE_9_2 |
3666 #endif // RD_JAVA_S60_RELEASE_9_2 |
3603 |
3667 |
3604 // returns: The number of new lines before an item. |
3668 // returns: The number of new lines before an item. |
3605 // This only takes into account new lines that come from |
3669 // This only takes into account new lines that come from |
3967 return iPopupController; |
4031 return iPopupController; |
3968 } |
4032 } |
3969 |
4033 |
3970 TInt CMIDForm::GetMidpNaviPos() |
4034 TInt CMIDForm::GetMidpNaviPos() |
3971 { |
4035 { |
3972 // get main pane size from CEikAppU |
|
3973 TRect mainPane = iAvkonAppUi->ApplicationRect(); |
|
3974 |
|
3975 // get screen size in pixels |
|
3976 TAknLayoutRect mainMidpPane; |
4036 TAknLayoutRect mainMidpPane; |
|
4037 |
|
4038 // get main pane size from Avkon (size in pixels) |
|
4039 #ifdef RD_JAVA_S60_RELEASE_9_2 |
|
4040 TRect mainPane; |
|
4041 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPane); |
|
4042 mainMidpPane.LayoutRect(mainPane, |
|
4043 AknLayoutScalable_Avkon::main_midp_pane().LayoutLine()); |
|
4044 #else |
3977 mainMidpPane.LayoutRect(iEikonEnv->ScreenDevice()->SizeInPixels(), |
4045 mainMidpPane.LayoutRect(iEikonEnv->ScreenDevice()->SizeInPixels(), |
3978 AknLayoutScalable_Avkon::main_midp_pane().LayoutLine()); |
4046 AknLayoutScalable_Avkon::main_midp_pane().LayoutLine()); |
|
4047 #endif // RD_JAVA_S60_RELEASE_9_2 |
3979 |
4048 |
3980 // getting form size depends on screen orientation |
4049 // getting form size depends on screen orientation |
3981 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
4050 TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
3982 iMidpFormRect.LayoutRect(mainMidpPane.Rect(), |
4051 iMidpFormRect.LayoutRect(mainMidpPane.Rect(), |
3983 AknLayoutScalable_Avkon::midp_form_pane(variety).LayoutLine()); |
4052 AknLayoutScalable_Avkon::midp_form_pane(variety).LayoutLine()); |
4166 iHighlightTimer->Cancel(); |
4235 iHighlightTimer->Cancel(); |
4167 // Start highlight timer if some any control is tapped. |
4236 // Start highlight timer if some any control is tapped. |
4168 if (iPointedControl) |
4237 if (iPointedControl) |
4169 { |
4238 { |
4170 TInt highlightTimeout = iPhysics->HighlightDelay() * 1000; |
4239 TInt highlightTimeout = iPhysics->HighlightDelay() * 1000; |
|
4240 if (IsPopupChoiceGroup(*iPointedControl)) |
|
4241 { |
|
4242 highlightTimeout /= 2; |
|
4243 } |
4171 iHighlightTimer->Start(TTimeIntervalMicroSeconds32(highlightTimeout), |
4244 iHighlightTimer->Start(TTimeIntervalMicroSeconds32(highlightTimeout), |
4172 TTimeIntervalMicroSeconds32(highlightTimeout), |
4245 TTimeIntervalMicroSeconds32(highlightTimeout), |
4173 TCallBack(HighlightTimerCallback, this)); |
4246 TCallBack(HighlightTimerCallback, this)); |
4174 } |
4247 } |
4175 } |
4248 } |
4305 if (!iFlickStoppedOnDownEvent && |
4378 if (!iFlickStoppedOnDownEvent && |
4306 !(IsCustomItem(*iPointedControl) && aPointerEvent.iType == TPointerEvent::EDrag)) |
4379 !(IsCustomItem(*iPointedControl) && aPointerEvent.iType == TPointerEvent::EDrag)) |
4307 { |
4380 { |
4308 if (iFocused != KErrNotFound) |
4381 if (iFocused != KErrNotFound) |
4309 { |
4382 { |
4310 ControlItem(iFocused).HandlePointerEventL(aPointerEvent); |
4383 if (IsPopupChoiceGroup(*iPointedControl)) |
|
4384 { |
|
4385 iPointedControl->HandlePointerEventL(aPointerEvent); |
|
4386 } |
|
4387 else |
|
4388 { |
|
4389 ControlItem(iFocused).HandlePointerEventL(aPointerEvent); |
|
4390 } |
4311 } |
4391 } |
4312 |
4392 |
4313 if (LayoutPending()) |
4393 if (LayoutPending()) |
4314 { |
4394 { |
4315 LayoutFormL(); |
4395 LayoutFormL(); |