--- a/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutbubblectrl.cpp Tue Aug 31 15:31:50 2010 +0300
+++ b/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutbubblectrl.cpp Wed Sep 01 12:23:33 2010 +0100
@@ -20,10 +20,13 @@
#include <AknsUtils.h>
#include <AknUtils.h>
#include <AknsDrawUtils.h>
+#include <AknBidiTextUtils.h>
#include "peninputlayoutbubblectrl.h"
#include "peninputlayout.h"
#include <peninputpluginutils.h>
+#include <imageconversion.h>
+#include "peninputcmd.h"
const TInt KShrinkSize = 10;
const TInt KDefaultTextColorIndex = EAknsCIQsnTextColorsCG60;
@@ -63,6 +66,8 @@
EXPORT_C CBubbleCtrl::~CBubbleCtrl()
{
+ Close();
+
if ( iText )
delete iText;
@@ -75,7 +80,9 @@
{
delete iForgroundBmpMask;
iForgroundBmpMask = NULL;
- }
+ }
+ delete iBitmap;
+ delete iMaskBitmap;
}
EXPORT_C void CBubbleCtrl::SetBitmapParam(CFbsBitmap* aBmpId,
@@ -100,29 +107,150 @@
EXPORT_C void CBubbleCtrl::Popup(const TRect& aRect)
{
- SetRect(aRect);
+ //SetRect(aRect);
if(iFreeze)
{
- iShowing = ETrue;
- SetHidenFlag(EFalse);
+ iShowing = ETrue;
+ SetRect(aRect);
+
+ SetHidenFlag(EFalse);
+ /*
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ struct SData
+ {
+ TRect rr;
+ TBool flag;
+ } data;
+ data.rr = aRect;
+ data.flag = ETrue;
+ TPtrC ptr;
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+
+ UiLayout()->SignalOwner(ESignalPopupArea,ptr);
+ }
+ */
return;
}
- if(!iShowing || aRect != Rect() || iNeedRedraw)
+ if( !iShowing || iNeedRedraw )
{
- iShowing = ETrue;
+ iShowing = ETrue;
+ SetRect(aRect);
+
TRect rect = Rect();
- SetRect(aRect);
+ //SetRect(aRect);
SetHidenFlag(EFalse);
BringToTop();
+
+ /*
//redraw the control under bubble control
if(aRect != rect)
- RootControl()->ReDrawRect(rect);
+ {
+ // signal the server to remove the pop area added before since the rect
+ // has been changed
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ struct SData
+ {
+ TRect rr;
+ TBool flag;
+ } data;
+
+ data.rr = rect;
+ data.flag = EFalse;
+ TPtrC ptr;
+
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+ UiLayout()->SignalOwner(ESignalPopupArea,ptr);
+ }
+ else
+ {
+ //redraw the control under bubble control
+ RootControl()->ReDrawRect(rect);
+ }
+ }
+ */
+ /*
+ // signal server to add the pop area
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ struct SData
+ {
+ TRect rr;
+ TBool flag;
+ } data;
+
+ data.rr = aRect;
+ data.flag = ETrue;
+ TPtrC ptr;
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+
+ UiLayout()->SignalOwner(ESignalPopupArea,ptr);
+ }
+ */
+
+ // signal server to copy the background as background bitmap for its own bitmap
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ //copy backgroud to bitmap. DrawFrame seems to have transparent effect,
+ //so we need copy the background first.
+ if(!iBitmap)
+ {
+ TRAP_IGNORE(CreateBmpDevL());
+ }
+
+ CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
+ gc->Activate( BitmapDevice() );
+ CFbsBitGc* layoutGc = static_cast<CFbsBitGc*>(
+ UiLayout()->LayoutOwner()->BitmapContext());
+ gc->BitBlt(TPoint(0,0),*layoutGc,Rect());
+
+ //ensure other pop up draws correctly on the background
+ struct SData
+ {
+ CFbsBitGc* gc;
+ CFbsBitmap* bmp;
+ TRect rect;
+ } data;
+
+ data.gc = gc;
+ data.bmp = iBitmap;
+ data.rect = Rect();
+ TPtrC ptr;
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+
+ UiLayout()->SignalOwner(ESignalDrawBackground,ptr);
+ }
Draw();
- rect.BoundingRect(aRect);
- UpdateAreaImmed(rect,ETrue);
+ // notify sever to draw the bubble bitmap on the screen
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ struct SData
+ {
+ TUint32 ctrl;
+ TBool flag;
+ TRect pos;
+ CFbsBitmap* bmp;
+ CFbsBitmap* mask;
+ } data;
+
+ data.ctrl = (TUint32)this;
+ data.flag = ETrue;
+ data.pos = Rect();
+ data.bmp = iBitmap;
+ data.mask = iMaskBitmap;
+ TPtrC ptr;
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+ UiLayout()->SignalOwner(ESignalUpdateBubble,ptr);
+ }
+ else
+ {
+ rect.BoundingRect(aRect);
+ UpdateAreaImmed(rect,ETrue);
+ }
iNeedRedraw = EFalse;
}
@@ -154,8 +282,23 @@
EXPORT_C void CBubbleCtrl::Close()
{
TRect rect = Rect();
-
- iShowing = EFalse;
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ SetHidenFlag(ETrue);
+ struct SData
+ {
+ TRect rr;
+ TBool flag;
+ } data;
+ data.rr = rect;
+ data.flag = EFalse;
+ TPtrC ptr;
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+
+ UiLayout()->SignalOwner(ESignalPopupArea,ptr);
+ }
+
+ iShowing = EFalse;
if( iFreeze )
{
@@ -170,12 +313,36 @@
}
else
{
- Clear();
- SetHidenFlag(ETrue);
- BringToBack();
-
- RootControl()->ReDrawRect(rect);
- UpdateAreaImmed(rect);
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ struct SData
+ {
+ TUint32 ctrl;
+ TBool flag;
+ TRect pos;
+ CFbsBitmap* bmp;
+ } data;
+
+ data.ctrl = (TUint32)this;
+ data.flag = EFalse;
+ data.pos = Rect();
+ data.bmp = iBitmap;
+
+ TPtrC ptr;
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+ UiLayout()->SignalOwner(ESignalUpdateBubble,ptr);
+
+ }
+ else
+ {
+
+ Clear();
+ SetHidenFlag(ETrue);
+ BringToBack();
+
+ RootControl()->ReDrawRect(rect);
+ UpdateAreaImmed(rect);
+ }
}
}
@@ -204,13 +371,17 @@
{
return;
}
-
+ if(UiLayout()->NotDrawToLayoutDevice() && !iBitmap)
+ {
+ TRAP_IGNORE(CreateBmpDevL());
+ }
+
CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
//mask bitmaps
DrawOpaqueMaskBackground();
- TRect rect = Rect();
+ TRect rect = GetRect();
TRect innerRect = rect;
if ( ( iLeftDiff == 0 ) && ( iTopDiff == 0 )
@@ -234,7 +405,8 @@
// Draw background
if ( iBgSkinId.iMajor )
{
- AknsDrawUtils::DrawFrame( AknsUtils::SkinInstance(),
+
+ AknsDrawUtils::DrawFrame( UiLayout()->SkinInstance(), //UiLayout()->SkinInstace()
*gc,
rect,
innerRect,
@@ -243,7 +415,7 @@
}
else if( iFirstBmpId.iMajor && iMiddleBmpId.iMajor && iLastBmpId.iMajor )
{
- AknPenInputDrawUtils::Draw3PiecesFrame( AknsUtils::SkinInstance(),
+ AknPenInputDrawUtils::Draw3PiecesFrame( UiLayout()->SkinInstance(),
*gc,
rect,
innerRect,
@@ -258,22 +430,28 @@
if ( iForgroundBmp )
{
- if( iForgroundBmp->SizeInPixels() != innerRect.Size() )
+ TRect iconRect;
+ iconRect.iTl = TPoint( innerRect.iTl.iX + iIconOffset.iWidth,
+ innerRect.iTl.iY + iIconOffset.iHeight );
+ iconRect.SetWidth( iIconSize.iWidth );
+ iconRect.SetHeight( iIconSize.iHeight );
+
+ if( iForgroundBmp->SizeInPixels() != iconRect.Size() )
{
- AknIconUtils::SetSize( iForgroundBmp, innerRect.Size(), EAspectRatioNotPreserved );
+ AknIconUtils::SetSize( iForgroundBmp, iconRect.Size(), EAspectRatioNotPreserved );
}
TRect srcRect( TPoint( 0, 0 ), iForgroundBmp->SizeInPixels() );
if( iForgroundBmpMask )
{
- if( iForgroundBmpMask->SizeInPixels() != innerRect.Size() )
+ if( iForgroundBmpMask->SizeInPixels() != iconRect.Size() )
{
- AknIconUtils::SetSize( iForgroundBmpMask, innerRect.Size(), EAspectRatioNotPreserved);
+ AknIconUtils::SetSize( iForgroundBmpMask, iconRect.Size(), EAspectRatioNotPreserved);
}
-
- gc->BitBltMasked( innerRect.iTl,
+ gc->SetBrushStyle( CGraphicsContext::ENullBrush );
+ gc->BitBltMasked( iconRect.iTl,
iForgroundBmp,
srcRect,
iForgroundBmpMask,
@@ -281,24 +459,45 @@
}
else
{
- gc->BitBlt( innerRect.iTl,
+ gc->BitBlt( iconRect.iTl,
iForgroundBmp,
srcRect );
}
}
- if ( iText )
+ if ( iText && iText->Length() > 0 )
{
gc->SetBrushStyle( CGraphicsContext::ENullBrush );
TAknLayoutText textLayout;
- textLayout.LayoutText(Rect(), iTextFormat);
+ textLayout.LayoutText(GetRect(), iTextFormat);
TRgb color( KRgbBlack ); // sane default for nonskinned case
if ( AknsUtils::AvkonSkinEnabled() )
{
- AknsUtils::GetCachedColor( AknsUtils::SkinInstance(),
+ AknsUtils::GetCachedColor( UiLayout()->SkinInstance(),
color, KAknsIIDQsnTextColors, iTextColorIndex );
}
- textLayout.DrawText(*gc, *iText, EFalse, color);
+ if ( iLangCode == ELangArabic ||
+ iLangCode == ELangHebrew ||
+ iLangCode == ELangFarsi ||
+ iLangCode == ELangUrdu )
+ {
+ const CFont* font = textLayout.Font();
+ HBufC* visualBuf = HBufC::New( iText->Length() + KAknBidiExtraSpacePerLine );
+ *visualBuf = *iText;
+ TPtr buf = visualBuf->Des();
+
+ AknBidiTextUtils::ConvertToVisualAndClip(*iText, buf, *font,
+ textLayout.TextRect().Size().iWidth,
+ textLayout.TextRect().Size().iWidth,
+ AknBidiTextUtils::ERightToLeft );
+ textLayout.DrawText(*gc, buf, EFalse, color);
+ delete visualBuf;
+ visualBuf = NULL;
+ }
+ else
+ {
+ textLayout.DrawText(*gc, *iText, EFalse, color);
+ }
}
}
@@ -356,6 +555,91 @@
iInvalidRect = TRect();
}
+TRect CBubbleCtrl::GetRect()
+ {
+ TRect r(Rect());
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ r.Move(-Rect().iTl.iX, -Rect().iTl.iY);
+ }
+ return r;
+ }
+
+
+void CBubbleCtrl::SetBmpDevice(CFbsBitGc* aGc,CFbsBitmapDevice* aDevice)
+ {
+ TAny* extension;
+
+ if(KErrNone == Extension_(KFepCtrlExtId,extension,0))
+ {
+ static_cast<CFepUiBaseCtrl::CFepUiBaseCtrlExtension*>(extension)->SetGc(aGc);
+ static_cast<CFepUiBaseCtrl::CFepUiBaseCtrlExtension*>(extension)->SetBmpDevice(aDevice);
+ }
+ }
+void CBubbleCtrl::CreateBmpDevL()
+ {
+ iBitmap = new ( ELeave ) CFbsBitmap;
+ //iMaskBitmap = new ( ELeave ) CFbsBitmap;
+ CreateOwnDeviceL(iBitmap,0);
+ }
+
+EXPORT_C void CBubbleCtrl::HandleResourceChange(TInt aType)
+ {
+ if(aType == KPenInputOwnDeviceChange)
+ {
+ if(UiLayout()->NotDrawToLayoutDevice() && !iBitmap)
+ {
+ TRAP_IGNORE(CreateBmpDevL());
+ }
+ }
+ else
+ CFepUiBaseCtrl::HandleResourceChange(aType);
+ }
+
+EXPORT_C void CBubbleCtrl::SetRect(const TRect& aRect)
+ {
+ if( !( UiLayout()->NotDrawToLayoutDevice()))
+ {
+ if( aRect != Rect())
+ {
+ CFepUiBaseCtrl::SetRect( aRect );
+ }
+ }
+ else
+ {
+ if( iShowing )
+ {
+ struct SData
+ {
+ TRect rr;
+ TBool flag;
+ } data;
+
+ // Remove the original region from list
+ data.rr = Rect();
+ data.flag = EFalse;
+ TPtrC ptrForRemove;
+ ptrForRemove.Set(
+ reinterpret_cast<const TUint16*>(&data), sizeof(data)/sizeof(TUint16));
+ UiLayout()->SignalOwner( ESignalPopupArea, ptrForRemove );
+
+ // Add the new region to list
+ data.rr = aRect;
+ data.flag = ETrue;
+ TPtrC ptrForAdd;
+ ptrForAdd.Set(
+ reinterpret_cast<const TUint16*>(&data), sizeof(data)/sizeof(TUint16));
+ UiLayout()->SignalOwner( ESignalPopupArea, ptrForAdd );
+ }
+
+ if( aRect != Rect())
+ {
+ CFepUiBaseCtrl::SetRect( aRect );
+ TRAP_IGNORE(ResizeDeviceL());
+ }
+ }
+ }
+
// ---------------------------------------------------------------------------
// CTooltipBubbleCtrl::NewL
// factory function
@@ -389,8 +673,8 @@
#ifdef RD_TACTILE_FEEDBACK
if(IsKindOfControl(ECtrlTactileFeedback) && !Hiden() && UiLayout())
{
- SetTactileFeedbackType(ETouchFeedbackSensitiveKeypad);
- UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(this),aRect,ETouchFeedbackSensitiveKeypad);
+ SetTactileFeedbackType(ETouchFeedbackSensitiveInput);
+ UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(this),aRect,ETouchFeedbackSensitiveInput);
}
#endif // RD_TACTILE_FEEDBACK
}