18 |
18 |
19 #include <AknIconUtils.h> |
19 #include <AknIconUtils.h> |
20 #include <AknsUtils.h> |
20 #include <AknsUtils.h> |
21 #include <AknUtils.h> |
21 #include <AknUtils.h> |
22 #include <AknsDrawUtils.h> |
22 #include <AknsDrawUtils.h> |
|
23 #include <AknBidiTextUtils.h> |
23 |
24 |
24 #include "peninputlayoutbubblectrl.h" |
25 #include "peninputlayoutbubblectrl.h" |
25 #include "peninputlayout.h" |
26 #include "peninputlayout.h" |
26 #include <peninputpluginutils.h> |
27 #include <peninputpluginutils.h> |
|
28 #include <imageconversion.h> |
|
29 #include "peninputcmd.h" |
27 |
30 |
28 const TInt KShrinkSize = 10; |
31 const TInt KShrinkSize = 10; |
29 const TInt KDefaultTextColorIndex = EAknsCIQsnTextColorsCG60; |
32 const TInt KDefaultTextColorIndex = EAknsCIQsnTextColorsCG60; |
30 // ======== MEMBER FUNCTIONS ======== |
33 // ======== MEMBER FUNCTIONS ======== |
31 |
34 |
98 iBgSkinId = aBgSkinId; |
105 iBgSkinId = aBgSkinId; |
99 } |
106 } |
100 |
107 |
101 EXPORT_C void CBubbleCtrl::Popup(const TRect& aRect) |
108 EXPORT_C void CBubbleCtrl::Popup(const TRect& aRect) |
102 { |
109 { |
103 SetRect(aRect); |
110 //SetRect(aRect); |
104 |
111 |
105 if(iFreeze) |
112 if(iFreeze) |
106 { |
113 { |
107 iShowing = ETrue; |
114 iShowing = ETrue; |
108 SetHidenFlag(EFalse); |
115 SetRect(aRect); |
|
116 |
|
117 SetHidenFlag(EFalse); |
|
118 /* |
|
119 if(UiLayout()->NotDrawToLayoutDevice()) |
|
120 { |
|
121 struct SData |
|
122 { |
|
123 TRect rr; |
|
124 TBool flag; |
|
125 } data; |
|
126 data.rr = aRect; |
|
127 data.flag = ETrue; |
|
128 TPtrC ptr; |
|
129 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
130 |
|
131 UiLayout()->SignalOwner(ESignalPopupArea,ptr); |
|
132 } |
|
133 */ |
109 return; |
134 return; |
110 } |
135 } |
111 if(!iShowing || aRect != Rect() || iNeedRedraw) |
136 if( !iShowing || iNeedRedraw ) |
112 { |
137 { |
113 iShowing = ETrue; |
138 iShowing = ETrue; |
|
139 SetRect(aRect); |
|
140 |
114 TRect rect = Rect(); |
141 TRect rect = Rect(); |
115 SetRect(aRect); |
142 //SetRect(aRect); |
116 SetHidenFlag(EFalse); |
143 SetHidenFlag(EFalse); |
117 BringToTop(); |
144 BringToTop(); |
|
145 |
|
146 /* |
118 //redraw the control under bubble control |
147 //redraw the control under bubble control |
119 if(aRect != rect) |
148 if(aRect != rect) |
120 RootControl()->ReDrawRect(rect); |
149 { |
|
150 // signal the server to remove the pop area added before since the rect |
|
151 // has been changed |
|
152 if(UiLayout()->NotDrawToLayoutDevice()) |
|
153 { |
|
154 struct SData |
|
155 { |
|
156 TRect rr; |
|
157 TBool flag; |
|
158 } data; |
|
159 |
|
160 data.rr = rect; |
|
161 data.flag = EFalse; |
|
162 TPtrC ptr; |
|
163 |
|
164 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
165 UiLayout()->SignalOwner(ESignalPopupArea,ptr); |
|
166 } |
|
167 else |
|
168 { |
|
169 //redraw the control under bubble control |
|
170 RootControl()->ReDrawRect(rect); |
|
171 } |
|
172 } |
|
173 */ |
|
174 /* |
|
175 // signal server to add the pop area |
|
176 if(UiLayout()->NotDrawToLayoutDevice()) |
|
177 { |
|
178 struct SData |
|
179 { |
|
180 TRect rr; |
|
181 TBool flag; |
|
182 } data; |
|
183 |
|
184 data.rr = aRect; |
|
185 data.flag = ETrue; |
|
186 TPtrC ptr; |
|
187 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
188 |
|
189 UiLayout()->SignalOwner(ESignalPopupArea,ptr); |
|
190 } |
|
191 */ |
|
192 |
|
193 // signal server to copy the background as background bitmap for its own bitmap |
|
194 if(UiLayout()->NotDrawToLayoutDevice()) |
|
195 { |
|
196 //copy backgroud to bitmap. DrawFrame seems to have transparent effect, |
|
197 //so we need copy the background first. |
|
198 if(!iBitmap) |
|
199 { |
|
200 TRAP_IGNORE(CreateBmpDevL()); |
|
201 } |
|
202 |
|
203 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
204 gc->Activate( BitmapDevice() ); |
|
205 CFbsBitGc* layoutGc = static_cast<CFbsBitGc*>( |
|
206 UiLayout()->LayoutOwner()->BitmapContext()); |
|
207 gc->BitBlt(TPoint(0,0),*layoutGc,Rect()); |
|
208 |
|
209 //ensure other pop up draws correctly on the background |
|
210 struct SData |
|
211 { |
|
212 CFbsBitGc* gc; |
|
213 CFbsBitmap* bmp; |
|
214 TRect rect; |
|
215 } data; |
|
216 |
|
217 data.gc = gc; |
|
218 data.bmp = iBitmap; |
|
219 data.rect = Rect(); |
|
220 TPtrC ptr; |
|
221 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
222 |
|
223 UiLayout()->SignalOwner(ESignalDrawBackground,ptr); |
|
224 } |
121 |
225 |
122 Draw(); |
226 Draw(); |
123 |
227 |
124 rect.BoundingRect(aRect); |
228 // notify sever to draw the bubble bitmap on the screen |
125 UpdateAreaImmed(rect,ETrue); |
229 if(UiLayout()->NotDrawToLayoutDevice()) |
|
230 { |
|
231 struct SData |
|
232 { |
|
233 TUint32 ctrl; |
|
234 TBool flag; |
|
235 TRect pos; |
|
236 CFbsBitmap* bmp; |
|
237 CFbsBitmap* mask; |
|
238 } data; |
|
239 |
|
240 data.ctrl = (TUint32)this; |
|
241 data.flag = ETrue; |
|
242 data.pos = Rect(); |
|
243 data.bmp = iBitmap; |
|
244 data.mask = iMaskBitmap; |
|
245 TPtrC ptr; |
|
246 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
247 UiLayout()->SignalOwner(ESignalUpdateBubble,ptr); |
|
248 } |
|
249 else |
|
250 { |
|
251 rect.BoundingRect(aRect); |
|
252 UpdateAreaImmed(rect,ETrue); |
|
253 } |
126 |
254 |
127 iNeedRedraw = EFalse; |
255 iNeedRedraw = EFalse; |
128 } |
256 } |
129 } |
257 } |
130 EXPORT_C void CBubbleCtrl::SetBitmapParam(CFbsBitmap* aBmpId, |
258 EXPORT_C void CBubbleCtrl::SetBitmapParam(CFbsBitmap* aBmpId, |
202 { |
369 { |
203 if(!AbleToDraw() || iFreeze ) //|| !iShowing ) |
370 if(!AbleToDraw() || iFreeze ) //|| !iShowing ) |
204 { |
371 { |
205 return; |
372 return; |
206 } |
373 } |
207 |
374 if(UiLayout()->NotDrawToLayoutDevice() && !iBitmap) |
|
375 { |
|
376 TRAP_IGNORE(CreateBmpDevL()); |
|
377 } |
|
378 |
208 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
379 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
209 |
380 |
210 //mask bitmaps |
381 //mask bitmaps |
211 DrawOpaqueMaskBackground(); |
382 DrawOpaqueMaskBackground(); |
212 |
383 |
213 TRect rect = Rect(); |
384 TRect rect = GetRect(); |
214 TRect innerRect = rect; |
385 TRect innerRect = rect; |
215 |
386 |
216 if ( ( iLeftDiff == 0 ) && ( iTopDiff == 0 ) |
387 if ( ( iLeftDiff == 0 ) && ( iTopDiff == 0 ) |
217 && ( iRightDiff == 0 ) && ( iBottomDiff == 0 ) ) |
388 && ( iRightDiff == 0 ) && ( iBottomDiff == 0 ) ) |
218 { |
389 { |
256 DrawBackground(); |
428 DrawBackground(); |
257 } |
429 } |
258 |
430 |
259 if ( iForgroundBmp ) |
431 if ( iForgroundBmp ) |
260 { |
432 { |
261 if( iForgroundBmp->SizeInPixels() != innerRect.Size() ) |
433 TRect iconRect; |
|
434 iconRect.iTl = TPoint( innerRect.iTl.iX + iIconOffset.iWidth, |
|
435 innerRect.iTl.iY + iIconOffset.iHeight ); |
|
436 iconRect.SetWidth( iIconSize.iWidth ); |
|
437 iconRect.SetHeight( iIconSize.iHeight ); |
|
438 |
|
439 if( iForgroundBmp->SizeInPixels() != iconRect.Size() ) |
262 { |
440 { |
263 AknIconUtils::SetSize( iForgroundBmp, innerRect.Size(), EAspectRatioNotPreserved ); |
441 AknIconUtils::SetSize( iForgroundBmp, iconRect.Size(), EAspectRatioNotPreserved ); |
264 } |
442 } |
265 |
443 |
266 TRect srcRect( TPoint( 0, 0 ), iForgroundBmp->SizeInPixels() ); |
444 TRect srcRect( TPoint( 0, 0 ), iForgroundBmp->SizeInPixels() ); |
267 |
445 |
268 if( iForgroundBmpMask ) |
446 if( iForgroundBmpMask ) |
269 { |
447 { |
270 if( iForgroundBmpMask->SizeInPixels() != innerRect.Size() ) |
448 if( iForgroundBmpMask->SizeInPixels() != iconRect.Size() ) |
271 { |
449 { |
272 AknIconUtils::SetSize( iForgroundBmpMask, innerRect.Size(), EAspectRatioNotPreserved); |
450 AknIconUtils::SetSize( iForgroundBmpMask, iconRect.Size(), EAspectRatioNotPreserved); |
273 } |
451 } |
274 |
452 |
275 |
453 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
276 gc->BitBltMasked( innerRect.iTl, |
454 gc->BitBltMasked( iconRect.iTl, |
277 iForgroundBmp, |
455 iForgroundBmp, |
278 srcRect, |
456 srcRect, |
279 iForgroundBmpMask, |
457 iForgroundBmpMask, |
280 EFalse); |
458 EFalse); |
281 } |
459 } |
282 else |
460 else |
283 { |
461 { |
284 gc->BitBlt( innerRect.iTl, |
462 gc->BitBlt( iconRect.iTl, |
285 iForgroundBmp, |
463 iForgroundBmp, |
286 srcRect ); |
464 srcRect ); |
287 } |
465 } |
288 } |
466 } |
289 |
467 |
290 if ( iText ) |
468 if ( iText && iText->Length() > 0 ) |
291 { |
469 { |
292 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
470 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
293 TAknLayoutText textLayout; |
471 TAknLayoutText textLayout; |
294 textLayout.LayoutText(Rect(), iTextFormat); |
472 textLayout.LayoutText(GetRect(), iTextFormat); |
295 TRgb color( KRgbBlack ); // sane default for nonskinned case |
473 TRgb color( KRgbBlack ); // sane default for nonskinned case |
296 if ( AknsUtils::AvkonSkinEnabled() ) |
474 if ( AknsUtils::AvkonSkinEnabled() ) |
297 { |
475 { |
298 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
476 AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), |
299 color, KAknsIIDQsnTextColors, iTextColorIndex ); |
477 color, KAknsIIDQsnTextColors, iTextColorIndex ); |
300 } |
478 } |
301 textLayout.DrawText(*gc, *iText, EFalse, color); |
479 if ( iLangCode == ELangArabic || |
|
480 iLangCode == ELangHebrew || |
|
481 iLangCode == ELangFarsi || |
|
482 iLangCode == ELangUrdu ) |
|
483 { |
|
484 const CFont* font = textLayout.Font(); |
|
485 HBufC* visualBuf = HBufC::New( iText->Length() + KAknBidiExtraSpacePerLine ); |
|
486 *visualBuf = *iText; |
|
487 TPtr buf = visualBuf->Des(); |
|
488 |
|
489 AknBidiTextUtils::ConvertToVisualAndClip(*iText, buf, *font, |
|
490 textLayout.TextRect().Size().iWidth, |
|
491 textLayout.TextRect().Size().iWidth, |
|
492 AknBidiTextUtils::ERightToLeft ); |
|
493 textLayout.DrawText(*gc, buf, EFalse, color); |
|
494 delete visualBuf; |
|
495 visualBuf = NULL; |
|
496 } |
|
497 else |
|
498 { |
|
499 textLayout.DrawText(*gc, *iText, EFalse, color); |
|
500 } |
302 } |
501 } |
303 } |
502 } |
304 |
503 |
305 EXPORT_C void CBubbleCtrl::SetTextFormat(TAknTextLineLayout aTextFormat) |
504 EXPORT_C void CBubbleCtrl::SetTextFormat(TAknTextLineLayout aTextFormat) |
306 { |
505 { |
352 |
551 |
353 UpdateArea(iInvalidRect); |
552 UpdateArea(iInvalidRect); |
354 } |
553 } |
355 |
554 |
356 iInvalidRect = TRect(); |
555 iInvalidRect = TRect(); |
|
556 } |
|
557 |
|
558 TRect CBubbleCtrl::GetRect() |
|
559 { |
|
560 TRect r(Rect()); |
|
561 if(UiLayout()->NotDrawToLayoutDevice()) |
|
562 { |
|
563 r.Move(-Rect().iTl.iX, -Rect().iTl.iY); |
|
564 } |
|
565 return r; |
|
566 } |
|
567 |
|
568 |
|
569 void CBubbleCtrl::SetBmpDevice(CFbsBitGc* aGc,CFbsBitmapDevice* aDevice) |
|
570 { |
|
571 TAny* extension; |
|
572 |
|
573 if(KErrNone == Extension_(KFepCtrlExtId,extension,0)) |
|
574 { |
|
575 static_cast<CFepUiBaseCtrl::CFepUiBaseCtrlExtension*>(extension)->SetGc(aGc); |
|
576 static_cast<CFepUiBaseCtrl::CFepUiBaseCtrlExtension*>(extension)->SetBmpDevice(aDevice); |
|
577 } |
|
578 } |
|
579 void CBubbleCtrl::CreateBmpDevL() |
|
580 { |
|
581 iBitmap = new ( ELeave ) CFbsBitmap; |
|
582 //iMaskBitmap = new ( ELeave ) CFbsBitmap; |
|
583 CreateOwnDeviceL(iBitmap,0); |
|
584 } |
|
585 |
|
586 EXPORT_C void CBubbleCtrl::HandleResourceChange(TInt aType) |
|
587 { |
|
588 if(aType == KPenInputOwnDeviceChange) |
|
589 { |
|
590 if(UiLayout()->NotDrawToLayoutDevice() && !iBitmap) |
|
591 { |
|
592 TRAP_IGNORE(CreateBmpDevL()); |
|
593 } |
|
594 } |
|
595 else |
|
596 CFepUiBaseCtrl::HandleResourceChange(aType); |
|
597 } |
|
598 |
|
599 EXPORT_C void CBubbleCtrl::SetRect(const TRect& aRect) |
|
600 { |
|
601 if( !( UiLayout()->NotDrawToLayoutDevice())) |
|
602 { |
|
603 if( aRect != Rect()) |
|
604 { |
|
605 CFepUiBaseCtrl::SetRect( aRect ); |
|
606 } |
|
607 } |
|
608 else |
|
609 { |
|
610 if( iShowing ) |
|
611 { |
|
612 struct SData |
|
613 { |
|
614 TRect rr; |
|
615 TBool flag; |
|
616 } data; |
|
617 |
|
618 // Remove the original region from list |
|
619 data.rr = Rect(); |
|
620 data.flag = EFalse; |
|
621 TPtrC ptrForRemove; |
|
622 ptrForRemove.Set( |
|
623 reinterpret_cast<const TUint16*>(&data), sizeof(data)/sizeof(TUint16)); |
|
624 UiLayout()->SignalOwner( ESignalPopupArea, ptrForRemove ); |
|
625 |
|
626 // Add the new region to list |
|
627 data.rr = aRect; |
|
628 data.flag = ETrue; |
|
629 TPtrC ptrForAdd; |
|
630 ptrForAdd.Set( |
|
631 reinterpret_cast<const TUint16*>(&data), sizeof(data)/sizeof(TUint16)); |
|
632 UiLayout()->SignalOwner( ESignalPopupArea, ptrForAdd ); |
|
633 } |
|
634 |
|
635 if( aRect != Rect()) |
|
636 { |
|
637 CFepUiBaseCtrl::SetRect( aRect ); |
|
638 TRAP_IGNORE(ResizeDeviceL()); |
|
639 } |
|
640 } |
357 } |
641 } |
358 |
642 |
359 // --------------------------------------------------------------------------- |
643 // --------------------------------------------------------------------------- |
360 // CTooltipBubbleCtrl::NewL |
644 // CTooltipBubbleCtrl::NewL |
361 // factory function |
645 // factory function |
387 :CBubbleCtrl( aRect, aUiLayout, aCtrlId ) |
671 :CBubbleCtrl( aRect, aUiLayout, aCtrlId ) |
388 { |
672 { |
389 #ifdef RD_TACTILE_FEEDBACK |
673 #ifdef RD_TACTILE_FEEDBACK |
390 if(IsKindOfControl(ECtrlTactileFeedback) && !Hiden() && UiLayout()) |
674 if(IsKindOfControl(ECtrlTactileFeedback) && !Hiden() && UiLayout()) |
391 { |
675 { |
392 SetTactileFeedbackType(ETouchFeedbackSensitiveKeypad); |
676 SetTactileFeedbackType(ETouchFeedbackSensitiveInput); |
393 UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(this),aRect,ETouchFeedbackSensitiveKeypad); |
677 UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(this),aRect,ETouchFeedbackSensitiveInput); |
394 } |
678 } |
395 #endif // RD_TACTILE_FEEDBACK |
679 #endif // RD_TACTILE_FEEDBACK |
396 } |
680 } |
397 |
681 |
398 // --------------------------------------------------------------------------- |
682 // --------------------------------------------------------------------------- |