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 |
73 } |
76 } |
74 if( iForgroundBmpMask ) |
77 if( iForgroundBmpMask ) |
75 { |
78 { |
76 delete iForgroundBmpMask; |
79 delete iForgroundBmpMask; |
77 iForgroundBmpMask = NULL; |
80 iForgroundBmpMask = NULL; |
78 } |
81 } |
|
82 delete iBitmap; |
|
83 delete iMaskBitmap; |
79 } |
84 } |
80 |
85 |
81 EXPORT_C void CBubbleCtrl::SetBitmapParam(CFbsBitmap* aBmpId, |
86 EXPORT_C void CBubbleCtrl::SetBitmapParam(CFbsBitmap* aBmpId, |
82 CFbsBitmap* aMaskBmpId, |
87 CFbsBitmap* aMaskBmpId, |
83 TAknsItemID aBgSkinId) |
88 TAknsItemID aBgSkinId) |
115 SetRect(aRect); |
134 SetRect(aRect); |
116 SetHidenFlag(EFalse); |
135 SetHidenFlag(EFalse); |
117 BringToTop(); |
136 BringToTop(); |
118 //redraw the control under bubble control |
137 //redraw the control under bubble control |
119 if(aRect != rect) |
138 if(aRect != rect) |
120 RootControl()->ReDrawRect(rect); |
139 { |
|
140 // signal the server to remove the pop area added before since the rect |
|
141 // has been changed |
|
142 if(UiLayout()->NotDrawToLayoutDevice()) |
|
143 { |
|
144 struct SData |
|
145 { |
|
146 TRect rr; |
|
147 TBool flag; |
|
148 } data; |
|
149 |
|
150 data.rr = rect; |
|
151 data.flag = EFalse; |
|
152 TPtrC ptr; |
|
153 |
|
154 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
155 UiLayout()->SignalOwner(ESignalPopupArea,ptr); |
|
156 } |
|
157 else |
|
158 { |
|
159 //redraw the control under bubble control |
|
160 RootControl()->ReDrawRect(rect); |
|
161 } |
|
162 } |
|
163 |
|
164 // signal server to add the pop area |
|
165 if(UiLayout()->NotDrawToLayoutDevice()) |
|
166 { |
|
167 struct SData |
|
168 { |
|
169 TRect rr; |
|
170 TBool flag; |
|
171 } data; |
|
172 |
|
173 data.rr = aRect; |
|
174 data.flag = ETrue; |
|
175 TPtrC ptr; |
|
176 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
177 |
|
178 UiLayout()->SignalOwner(ESignalPopupArea,ptr); |
|
179 } |
|
180 |
|
181 // signal server to copy the background as background bitmap for its own bitmap |
|
182 if(UiLayout()->NotDrawToLayoutDevice()) |
|
183 { |
|
184 //copy backgroud to bitmap. DrawFrame seems to have transparent effect, |
|
185 //so we need copy the background first. |
|
186 if(!iBitmap) |
|
187 { |
|
188 TRAP_IGNORE(CreateBmpDevL()); |
|
189 } |
|
190 |
|
191 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
192 gc->Activate( BitmapDevice() ); |
|
193 CFbsBitGc* layoutGc = static_cast<CFbsBitGc*>( |
|
194 UiLayout()->LayoutOwner()->BitmapContext()); |
|
195 gc->BitBlt(TPoint(0,0),*layoutGc,Rect()); |
|
196 |
|
197 //ensure other pop up draws correctly on the background |
|
198 struct SData |
|
199 { |
|
200 CFbsBitGc* gc; |
|
201 CFbsBitmap* bmp; |
|
202 TRect rect; |
|
203 } data; |
|
204 |
|
205 data.gc = gc; |
|
206 data.bmp = iBitmap; |
|
207 data.rect = Rect(); |
|
208 TPtrC ptr; |
|
209 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
210 |
|
211 UiLayout()->SignalOwner(ESignalDrawBackground,ptr); |
|
212 } |
121 |
213 |
122 Draw(); |
214 Draw(); |
123 |
215 |
124 rect.BoundingRect(aRect); |
216 // notify sever to draw the bubble bitmap on the screen |
125 UpdateAreaImmed(rect,ETrue); |
217 if(UiLayout()->NotDrawToLayoutDevice()) |
|
218 { |
|
219 struct SData |
|
220 { |
|
221 TBool flag; |
|
222 TRect pos; |
|
223 CFbsBitmap* bmp; |
|
224 CFbsBitmap* mask; |
|
225 } data; |
|
226 |
|
227 data.flag = ETrue; |
|
228 data.pos = Rect(); |
|
229 data.bmp = iBitmap; |
|
230 data.mask = iMaskBitmap; |
|
231 TPtrC ptr; |
|
232 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
233 UiLayout()->SignalOwner(ESignalUpdateBubble,ptr); |
|
234 } |
|
235 else |
|
236 { |
|
237 rect.BoundingRect(aRect); |
|
238 UpdateAreaImmed(rect,ETrue); |
|
239 } |
126 |
240 |
127 iNeedRedraw = EFalse; |
241 iNeedRedraw = EFalse; |
128 } |
242 } |
129 } |
243 } |
130 EXPORT_C void CBubbleCtrl::SetBitmapParam(CFbsBitmap* aBmpId, |
244 EXPORT_C void CBubbleCtrl::SetBitmapParam(CFbsBitmap* aBmpId, |
168 iInvalidRect.BoundingRect( rect ); |
297 iInvalidRect.BoundingRect( rect ); |
169 } |
298 } |
170 } |
299 } |
171 else |
300 else |
172 { |
301 { |
173 Clear(); |
302 if(UiLayout()->NotDrawToLayoutDevice()) |
174 SetHidenFlag(ETrue); |
303 { |
175 BringToBack(); |
304 struct SData |
176 |
305 { |
177 RootControl()->ReDrawRect(rect); |
306 TBool flag; |
178 UpdateAreaImmed(rect); |
307 TRect pos; |
|
308 CFbsBitmap* bmp; |
|
309 } data; |
|
310 |
|
311 data.flag = EFalse; |
|
312 data.pos = Rect(); |
|
313 data.bmp = iBitmap; |
|
314 |
|
315 TPtrC ptr; |
|
316 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
317 UiLayout()->SignalOwner(ESignalUpdateBubble,ptr); |
|
318 |
|
319 } |
|
320 else |
|
321 { |
|
322 |
|
323 Clear(); |
|
324 SetHidenFlag(ETrue); |
|
325 BringToBack(); |
|
326 |
|
327 RootControl()->ReDrawRect(rect); |
|
328 UpdateAreaImmed(rect); |
|
329 } |
179 } |
330 } |
180 } |
331 } |
181 |
332 |
182 EXPORT_C void CBubbleCtrl::Hide(TBool aFlag) |
333 EXPORT_C void CBubbleCtrl::Hide(TBool aFlag) |
183 { |
334 { |
202 { |
353 { |
203 if(!AbleToDraw() || iFreeze ) //|| !iShowing ) |
354 if(!AbleToDraw() || iFreeze ) //|| !iShowing ) |
204 { |
355 { |
205 return; |
356 return; |
206 } |
357 } |
207 |
358 if(UiLayout()->NotDrawToLayoutDevice() && !iBitmap) |
|
359 { |
|
360 TRAP_IGNORE(CreateBmpDevL()); |
|
361 } |
|
362 |
208 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
363 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
209 |
364 |
210 //mask bitmaps |
365 //mask bitmaps |
211 DrawOpaqueMaskBackground(); |
366 DrawOpaqueMaskBackground(); |
212 |
367 |
213 TRect rect = Rect(); |
368 TRect rect = GetRect(); |
214 TRect innerRect = rect; |
369 TRect innerRect = rect; |
215 |
370 |
216 if ( ( iLeftDiff == 0 ) && ( iTopDiff == 0 ) |
371 if ( ( iLeftDiff == 0 ) && ( iTopDiff == 0 ) |
217 && ( iRightDiff == 0 ) && ( iBottomDiff == 0 ) ) |
372 && ( iRightDiff == 0 ) && ( iBottomDiff == 0 ) ) |
218 { |
373 { |
296 |
451 |
297 if ( iText && iText->Length() > 0 ) |
452 if ( iText && iText->Length() > 0 ) |
298 { |
453 { |
299 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
454 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
300 TAknLayoutText textLayout; |
455 TAknLayoutText textLayout; |
301 textLayout.LayoutText(Rect(), iTextFormat); |
456 textLayout.LayoutText(GetRect(), iTextFormat); |
302 TRgb color( KRgbBlack ); // sane default for nonskinned case |
457 TRgb color( KRgbBlack ); // sane default for nonskinned case |
303 if ( AknsUtils::AvkonSkinEnabled() ) |
458 if ( AknsUtils::AvkonSkinEnabled() ) |
304 { |
459 { |
305 AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), |
460 AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), |
306 color, KAknsIIDQsnTextColors, iTextColorIndex ); |
461 color, KAknsIIDQsnTextColors, iTextColorIndex ); |
307 } |
462 } |
308 textLayout.DrawText(*gc, *iText, ETrue, color); |
463 if ( iLangCode == ELangArabic || |
|
464 iLangCode == ELangHebrew || |
|
465 iLangCode == ELangFarsi || |
|
466 iLangCode == ELangUrdu ) |
|
467 { |
|
468 const CFont* font = textLayout.Font(); |
|
469 HBufC* visualBuf = HBufC::New( iText->Length() + KAknBidiExtraSpacePerLine ); |
|
470 *visualBuf = *iText; |
|
471 TPtr buf = visualBuf->Des(); |
|
472 |
|
473 AknBidiTextUtils::ConvertToVisualAndClip(*iText, buf, *font, |
|
474 textLayout.TextRect().Size().iWidth, |
|
475 textLayout.TextRect().Size().iWidth, |
|
476 AknBidiTextUtils::ERightToLeft ); |
|
477 textLayout.DrawText(*gc, buf, EFalse, color); |
|
478 delete visualBuf; |
|
479 visualBuf = NULL; |
|
480 } |
|
481 else |
|
482 { |
|
483 textLayout.DrawText(*gc, *iText, EFalse, color); |
|
484 } |
309 } |
485 } |
310 } |
486 } |
311 |
487 |
312 EXPORT_C void CBubbleCtrl::SetTextFormat(TAknTextLineLayout aTextFormat) |
488 EXPORT_C void CBubbleCtrl::SetTextFormat(TAknTextLineLayout aTextFormat) |
313 { |
489 { |
359 |
535 |
360 UpdateArea(iInvalidRect); |
536 UpdateArea(iInvalidRect); |
361 } |
537 } |
362 |
538 |
363 iInvalidRect = TRect(); |
539 iInvalidRect = TRect(); |
|
540 } |
|
541 |
|
542 TRect CBubbleCtrl::GetRect() |
|
543 { |
|
544 TRect r(Rect()); |
|
545 if(UiLayout()->NotDrawToLayoutDevice()) |
|
546 { |
|
547 r.Move(-Rect().iTl.iX, -Rect().iTl.iY); |
|
548 } |
|
549 return r; |
|
550 } |
|
551 |
|
552 |
|
553 void CBubbleCtrl::SetBmpDevice(CFbsBitGc* aGc,CFbsBitmapDevice* aDevice) |
|
554 { |
|
555 TAny* extension; |
|
556 |
|
557 if(KErrNone == Extension_(KFepCtrlExtId,extension,0)) |
|
558 { |
|
559 static_cast<CFepUiBaseCtrl::CFepUiBaseCtrlExtension*>(extension)->SetGc(aGc); |
|
560 static_cast<CFepUiBaseCtrl::CFepUiBaseCtrlExtension*>(extension)->SetBmpDevice(aDevice); |
|
561 } |
|
562 } |
|
563 void CBubbleCtrl::CreateBmpDevL() |
|
564 { |
|
565 iBitmap = new ( ELeave ) CFbsBitmap; |
|
566 //iMaskBitmap = new ( ELeave ) CFbsBitmap; |
|
567 CreateOwnDeviceL(iBitmap,0); |
|
568 } |
|
569 |
|
570 EXPORT_C void CBubbleCtrl::HandleResourceChange(TInt aType) |
|
571 { |
|
572 if(aType == KPenInputOwnDeviceChange) |
|
573 { |
|
574 if(UiLayout()->NotDrawToLayoutDevice() && !iBitmap) |
|
575 { |
|
576 TRAP_IGNORE(CreateBmpDevL()); |
|
577 } |
|
578 } |
|
579 else |
|
580 CFepUiBaseCtrl::HandleResourceChange(aType); |
|
581 } |
|
582 |
|
583 EXPORT_C void CBubbleCtrl::SetRect(const TRect& aRect) |
|
584 { |
|
585 if(aRect == Rect()) |
|
586 return; |
|
587 CFepUiBaseCtrl::SetRect(aRect); |
|
588 ResizeDeviceL(); |
364 } |
589 } |
365 |
590 |
366 // --------------------------------------------------------------------------- |
591 // --------------------------------------------------------------------------- |
367 // CTooltipBubbleCtrl::NewL |
592 // CTooltipBubbleCtrl::NewL |
368 // factory function |
593 // factory function |