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