39 #include "AknFepUIAvkonCtrlInputPane.h" |
39 #include "AknFepUIAvkonCtrlInputPane.h" |
40 #include "AknFepUIAvkonCtrlPinyinPopup.h" |
40 #include "AknFepUIAvkonCtrlPinyinPopup.h" |
41 #include "aknfepchineseuidataconv.h" |
41 #include "aknfepchineseuidataconv.h" |
42 #include "aknfepuilayoutdatamgr.h" |
42 #include "aknfepuilayoutdatamgr.h" |
43 |
43 |
|
44 |
44 CAknFepUICtrlInputPane* CAknFepUICtrlInputPane::NewL(RWindow& aParent, |
45 CAknFepUICtrlInputPane* CAknFepUICtrlInputPane::NewL(RWindow& aParent, |
45 TInputPaneLayout aPaneLayout, |
46 TInputPaneLayout aPaneLayout, |
46 CAknFepUiLayoutDataMgr* aLafDataMgr ) |
47 CAknFepUiLayoutDataMgr* aLafDataMgr ) |
47 { |
48 { |
48 CAknFepUICtrlInputPane* self = new(ELeave) CAknFepUICtrlInputPane(aPaneLayout,aLafDataMgr); |
49 CAknFepUICtrlInputPane* self = new(ELeave) CAknFepUICtrlInputPane(aPaneLayout,aLafDataMgr); |
68 void CAknFepUICtrlInputPane::SetText(const TDesC& aDes) |
69 void CAknFepUICtrlInputPane::SetText(const TDesC& aDes) |
69 { |
70 { |
70 // make sure that we only copy as many characters as we can show |
71 // make sure that we only copy as many characters as we can show |
71 if(iLayout == ELayoutPhraseInputPane) |
72 if(iLayout == ELayoutPhraseInputPane) |
72 { |
73 { |
73 TPtrC newText = aDes.Right(CalculateMaxTextLength(aDes)); |
74 TPtrC newText = aDes.Right( EMaxInputCharsInputPane ); |
74 TPtr ptr = iBuffer->Des(); |
75 TPtr ptr = iBuffer->Des(); |
75 |
76 |
76 if(ptr != newText) |
77 if(ptr != newText) |
77 { |
78 { |
78 ptr.Copy(newText); |
79 ptr.Copy(newText); |
114 if(!COMPARE_BOOLS(iHighlighted, aHighlighted)) |
115 if(!COMPARE_BOOLS(iHighlighted, aHighlighted)) |
115 { |
116 { |
116 iHighlighted = aHighlighted; |
117 iHighlighted = aHighlighted; |
117 // need to change highlight colors |
118 // need to change highlight colors |
118 LayoutContainedControls(); |
119 LayoutContainedControls(); |
119 DrawDeferred(); |
120 DrawNow(); |
120 } |
121 } |
121 } |
122 } |
122 |
123 |
123 TBool CAknFepUICtrlInputPane::Highlighted() const |
124 TBool CAknFepUICtrlInputPane::Highlighted() const |
124 { |
125 { |
196 } |
197 } |
197 } |
198 } |
198 |
199 |
199 TInt CAknFepUICtrlInputPane::LabelTextWidthInPixels() const |
200 TInt CAknFepUICtrlInputPane::LabelTextWidthInPixels() const |
200 { |
201 { |
201 TAknLayoutText layoutText = |
202 TAknTextLineLayout textLayout; |
202 CAknFepChineseUIDataConv::AnyToLayoutText( iLafDataMgr->RequestData( ELayoutInputPaneText )); |
203 if ( iLayout == ELayoutPhraseInputPane ) |
|
204 { |
|
205 textLayout = |
|
206 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData( EEEPTextLine )); |
|
207 |
|
208 } |
|
209 else if( iLayout == ELayoutPhrasePinyinPopupPane ) |
|
210 { |
|
211 textLayout = |
|
212 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData( EInputTextLayout )); |
|
213 } |
|
214 |
|
215 TAknLayoutText layoutText; |
|
216 layoutText.LayoutText( Rect(), textLayout ); |
|
217 |
|
218 // Get the text font |
203 const CFont* font = layoutText.Font(); |
219 const CFont* font = layoutText.Font(); |
204 |
220 |
205 TInt labelWidthInPixels = 0; |
221 TInt labelWidthInPixels = 0; |
206 if(font) |
222 if ( font ) |
207 { |
223 { |
208 TBufC<EMaxInputCharsInputPane> buf1; |
224 TBufC<EMaxInputCharsInputPane> buf1; |
209 TPtr ptr1 = buf1.Des(); |
225 TPtr ptr1 = buf1.Des(); |
210 GetText(ptr1); |
226 GetText(ptr1); |
211 TBufC<EMaxToneMarkLength> buf2; |
227 TBufC<EMaxToneMarkLength> buf2; |
212 TPtr ptr2 = buf2.Des(); |
228 TPtr ptr2 = buf2.Des(); |
213 GetToneMark(ptr2); |
229 GetToneMark(ptr2); |
214 labelWidthInPixels = font->TextWidthInPixels(ptr1); |
230 labelWidthInPixels = font->TextWidthInPixels(ptr1); |
215 labelWidthInPixels += font->TextWidthInPixels(ptr2); |
231 labelWidthInPixels += font->TextWidthInPixels(ptr2); |
216 } |
232 } |
217 TInt maxWidth = layoutText.TextRect().Width(); |
|
218 labelWidthInPixels = labelWidthInPixels > maxWidth? maxWidth:labelWidthInPixels; |
|
219 return labelWidthInPixels; |
233 return labelWidthInPixels; |
220 } |
234 } |
221 |
235 |
222 void CAknFepUICtrlInputPane::SizeChanged() |
236 void CAknFepUICtrlInputPane::SizeChanged() |
223 { |
237 { |
266 { |
280 { |
267 TBool skinnedDraw = EFalse; |
281 TBool skinnedDraw = EFalse; |
268 CWindowGc& gc = SystemGc(); |
282 CWindowGc& gc = SystemGc(); |
269 |
283 |
270 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
284 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
271 if(iHighlighted) |
285 TRect outerRect; |
272 { |
286 TRect innerRect; |
273 TRect outerRect; |
287 CalculateFrameRects(outerRect, innerRect); |
274 TRect innerRect; |
288 if ( iHighlighted ) |
275 CalculateFrameRects(outerRect, innerRect); |
289 { |
276 skinnedDraw = AknsDrawUtils::DrawFrame( |
290 // Highlight state |
277 skin, gc, outerRect, innerRect, KAknsIIDQsnFrList, KAknsIIDQsnFrListCenter); // or KAknsIIDDefault? |
291 skinnedDraw = AknsDrawUtils::DrawFrame( skin, gc, outerRect, innerRect, |
|
292 KAknsIIDQsnFrKeypadButtonFrPressed, KAknsIIDDefault ); // or KAknsIIDDefault? |
278 } |
293 } |
279 else |
294 else |
280 { |
295 { |
281 MAknsControlContext* cc = AknsDrawUtils::ControlContext(this); |
296 // Normal state |
282 skinnedDraw = AknsDrawUtils::Background(skin, cc, this, gc, Rect()); |
297 skinnedDraw = AknsDrawUtils::DrawFrame( skin, gc, outerRect, innerRect, |
|
298 KAknsIIDQsnFrKeypadButtonFrNormal, KAknsIIDDefault ); |
283 } |
299 } |
284 |
300 |
285 if(!skinnedDraw) |
301 if(!skinnedDraw) |
286 { |
302 { |
287 if(iHighlighted) |
303 if(iHighlighted) |
342 TBufC<EMaxInputChars> combinedBuffer; |
358 TBufC<EMaxInputChars> combinedBuffer; |
343 TPtr combinedPtr = combinedBuffer.Des(); |
359 TPtr combinedPtr = combinedBuffer.Des(); |
344 combinedPtr.Copy(*iBuffer); |
360 combinedPtr.Copy(*iBuffer); |
345 combinedPtr.Append(iToneMarkBuffer); |
361 combinedPtr.Append(iToneMarkBuffer); |
346 |
362 |
347 TRect rect = Rect(); |
363 TRect layoutRect = CAknFepChineseUIDataConv::AnyToRect( iLafDataMgr->RequestData( EPopupRectCandatate )); |
348 if(iLayout == ELayoutPhrasePinyinPopupPane) |
364 TAknWindowLineLayout layoutLineRectEntryPane = |
349 { |
365 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData( EEntryCLayout )); |
350 TAknLayoutRect layoutLineRectEntryPane = |
366 TAknLayoutRect layoutRectEntryPane; |
351 CAknFepChineseUIDataConv::AnyToLayoutRect( iLafDataMgr->RequestData( ELayoutLineRectEntryPane )); |
367 layoutRectEntryPane.LayoutRect( layoutRect, layoutLineRectEntryPane ); |
352 rect = layoutLineRectEntryPane.Rect(); |
368 |
353 } |
369 TAknTextLineLayout layoutLineText = |
354 // avoid accessing text layout member data |
370 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData( EEEPTextLine )); |
355 TAknLayoutRect labelRect; |
371 |
356 |
|
357 TAknWindowLineLayout layoutEntryItem = |
|
358 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutEntryItem)); |
|
359 labelRect.LayoutRect(rect, layoutEntryItem); |
|
360 TAknLayoutText layoutText; |
372 TAknLayoutText layoutText; |
361 TAknTextLineLayout entryTextLine = |
373 layoutText.LayoutText( layoutRectEntryPane.Rect(), layoutLineText ); |
362 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EEntryTextLayout)); |
374 |
363 layoutText.LayoutText(labelRect.Rect(),entryTextLine); |
375 TInt maxWidth = layoutText.TextRect().Width(); |
364 TInt maxWidth = layoutText.TextRect().Width(); |
376 const CFont* font = layoutText.Font(); |
365 |
|
366 TAknLayoutText layoutText1 = |
|
367 CAknFepChineseUIDataConv::AnyToLayoutText( iLafDataMgr->RequestData( ELayoutInputPaneText )); |
|
368 const CFont* font = layoutText1.Font(); |
|
369 |
377 |
370 TInt labelWidthInPixels = 0; |
378 TInt labelWidthInPixels = 0; |
371 if(font) |
379 if(font) |
372 { |
380 { |
373 TBufC<EMaxInputCharsInputPane> buf1; |
381 TBufC<EMaxInputCharsInputPane> buf1; |
405 } |
413 } |
406 |
414 |
407 void CAknFepUICtrlInputPane::LayoutContainedControls() |
415 void CAknFepUICtrlInputPane::LayoutContainedControls() |
408 { |
416 { |
409 TRect rect = Rect(); |
417 TRect rect = Rect(); |
|
418 TAknWindowLineLayout layoutEntryItem; |
|
419 TAknTextLineLayout textLayout; |
410 if(iLayout == ELayoutPhraseInputPane) |
420 if(iLayout == ELayoutPhraseInputPane) |
411 { |
421 { |
412 TAknWindowLineLayout layoutEntryItem = |
422 layoutEntryItem = |
413 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData(ELayoutEntryItem)); |
423 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData( EEntryCLayout )); |
414 iUnselectedStringHighlight.LayoutRect(rect, layoutEntryItem); |
424 |
|
425 textLayout = |
|
426 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData( EEEPTextLine )); |
|
427 |
415 } |
428 } |
416 else if(iLayout == ELayoutPhrasePinyinPopupPane) |
429 else if(iLayout == ELayoutPhrasePinyinPopupPane) |
417 { |
430 { |
418 iUnselectedStringHighlight.LayoutRect(rect, AKN_LAYOUT_WINDOW_Input_highlight_Line_1(rect)); |
431 layoutEntryItem = |
419 } |
432 CAknFepChineseUIDataConv::AnyToWindowLine( iLafDataMgr->RequestData( EInputLayout )); |
420 |
433 textLayout = |
421 // layout spelling label |
434 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData( EInputTextLayout )); |
422 TAknTextLineLayout textLayout = |
435 } |
423 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData(EEntryTextLayout)); |
436 |
|
437 iUnselectedStringHighlight.LayoutRect(rect, layoutEntryItem); |
|
438 |
424 TAknLayoutText layoutText; |
439 TAknLayoutText layoutText; |
425 TRect rectHighlight = iUnselectedStringHighlight.Rect(); |
|
426 TRect textRect; |
440 TRect textRect; |
427 |
441 |
428 layoutText.LayoutText(rectHighlight,textLayout); |
442 layoutText.LayoutText(rect,textLayout); |
429 textRect = layoutText.TextRect(); |
443 textRect = layoutText.TextRect(); |
430 TRgb labelTextColor = layoutText.Color(); |
444 TRgb labelTextColor = layoutText.Color(); |
431 |
445 |
432 TInt labelWidth = LabelTextWidthInPixels(); |
446 TInt labelWidth = LabelTextWidthInPixels(); |
433 if(textRect.Width() > labelWidth) |
447 if ( textRect.Width() < labelWidth ) |
434 { |
448 { |
435 textRect.SetWidth(labelWidth); |
449 textRect.SetWidth( labelWidth ); |
436 } |
450 } |
437 iLabel->SetRect(textRect); |
451 iLabel->SetRect( textRect ); |
438 const CFont* font = layoutText.Font(); |
452 const CFont* font = layoutText.Font(); |
439 iLabel->SetFont(font); |
453 iLabel->SetFont( font ); |
440 |
454 |
441 // layout tone mark label |
455 // layout tone mark label |
442 TRgb labelToneMarkTextColor = labelTextColor; |
456 TRgb labelToneMarkTextColor = labelTextColor; |
443 TRect toneMarkRect; |
457 TRect toneMarkRect; |
444 TPtrC ptr = *iBuffer; |
458 TPtrC ptr = *iBuffer; |
447 toneMarkOffset = iLabel->CalcMinimumSize(ptr).iWidth; |
461 toneMarkOffset = iLabel->CalcMinimumSize(ptr).iWidth; |
448 toneMarkRect.iTl.iX = textRect.iTl.iX + toneMarkOffset; |
462 toneMarkRect.iTl.iX = textRect.iTl.iX + toneMarkOffset; |
449 toneMarkRect.iTl.iY = textRect.iTl.iY; |
463 toneMarkRect.iTl.iY = textRect.iTl.iY; |
450 toneMarkRect.iBr.iY = textRect.iBr.iY; |
464 toneMarkRect.iBr.iY = textRect.iBr.iY; |
451 toneMarkRect.SetWidth(labelWidth - toneMarkOffset); |
465 toneMarkRect.SetWidth(labelWidth - toneMarkOffset); |
452 iLabelToneMark->SetRect(toneMarkRect); |
466 iLabelToneMark->SetRect( toneMarkRect ); |
453 iLabelToneMark->SetFont(font); |
467 iLabelToneMark->SetFont( font ); |
454 |
468 |
455 // once we have layed out the labels from LAF, override the colours from the skin if necessary |
469 // once we have layed out the labels from LAF, override the colours from the skin if necessary |
456 // as the skin utils will only return RGB values, not colour ids. |
470 // as the skin utils will only return RGB values, not colour ids. |
457 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
471 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
458 TInt colorIndex = EAknsCIQsnTextColorsCG19; |
472 TInt colorIndex = EAknsCIQsnTextColorsCG19; |
484 } |
498 } |
485 |
499 |
486 void CAknFepUICtrlInputPane::CalculateFrameRects(TRect& aOuterRect, TRect& aInnerRect) const |
500 void CAknFepUICtrlInputPane::CalculateFrameRects(TRect& aOuterRect, TRect& aInnerRect) const |
487 { |
501 { |
488 TRect windowRect = Rect(); |
502 TRect windowRect = Rect(); |
489 TRect entryRect = |
503 TAknTextLineLayout textLayout; |
490 CAknFepChineseUIDataConv::AnyToRect( iLafDataMgr->RequestData(EEntryPaneRect)); |
504 if ( iLayout == ELayoutPhraseInputPane ) |
491 |
505 { |
492 windowRect.SetHeight(entryRect.iBr.iY - entryRect.iTl.iY); |
506 textLayout = |
493 |
507 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData( EEEPTextLine )); |
494 TAknLayoutRect topLeft; |
508 |
495 topLeft.LayoutRect(windowRect,SkinLayout::Submenu_skin_placing_Line_2()); |
509 } |
496 |
510 else if( iLayout == ELayoutPhrasePinyinPopupPane ) |
497 TAknLayoutRect bottomRight; |
511 { |
498 bottomRight.LayoutRect(windowRect, SkinLayout::Submenu_skin_placing_Line_5()); |
512 textLayout = |
499 |
513 CAknFepChineseUIDataConv::AnyToTextLine( iLafDataMgr->RequestData( EInputTextLayout )); |
500 aOuterRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); |
514 } |
501 aInnerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl); |
515 TAknLayoutText layoutInputPaneText; |
502 if (aInnerRect.Width() <= 4) |
516 layoutInputPaneText.LayoutText( windowRect, textLayout ); |
503 { |
517 aInnerRect = layoutInputPaneText.TextRect(); |
504 aInnerRect.SetWidth(5); |
518 aOuterRect = windowRect; |
505 } |
|
506 } |
519 } |
507 |
520 |
508 TInt CAknFepUICtrlInputPane::CalculateMaxTextLength(const TDesC& aDes) const |
521 TInt CAknFepUICtrlInputPane::CalculateMaxTextLength(const TDesC& aDes) const |
509 { |
522 { |
510 TAknLayoutText layoutText = |
523 TAknLayoutText layoutText = |