textinput/peninputsplitqwerty/src/peninputsplitqwertywindow.cpp
branchRCL_3
changeset 50 5a1685599b76
parent 44 ecbabf52600f
child 56 8152b1f1763a
equal deleted inserted replaced
46:bd83ceabce89 50:5a1685599b76
    53 #include "peninputsplitqwertyenum.h"
    53 #include "peninputsplitqwertyenum.h"
    54 #include "peninputrangebarinfo.h"
    54 #include "peninputrangebarinfo.h"
    55 #include "peninputsplitqwertylafdatamgr.h"
    55 #include "peninputsplitqwertylafdatamgr.h"
    56 #include "peninputsplitqwertylangmeritpair.h"
    56 #include "peninputsplitqwertylangmeritpair.h"
    57 #include "peninputsplitqwertylayout.h"
    57 #include "peninputsplitqwertylayout.h"
       
    58 #include "peninputpopupbubble.h"
    58 
    59 
    59 #include <peninputaknvkbpreviewbubblerenderer.h>
    60 #include <peninputaknvkbpreviewbubblerenderer.h>
    60 #include <peninputlongpressbutton.h>
    61 #include <peninputlongpressbutton.h>
    61 
    62 
    62 // Constants
    63 // Constants
   213 //
   214 //
   214 void CPeninputSplitQwertyWindow::CreateAllControlsL()
   215 void CPeninputSplitQwertyWindow::CreateAllControlsL()
   215     {
   216     {
   216     // Range bar
   217     // Range bar
   217     AddRangeBarL();
   218     AddRangeBarL();
   218 
   219     
       
   220     // char count bubble   
       
   221     iSplitIndiBubble = CPopupBubbleCtrl::NewL(TRect(),UiLayout(),EPeninputWindowCtrlIdSplitIndiBubble);
       
   222     iSplitIndiBubble->SetTextColorIndex( EAknsCIQsnTextColorsCG67 );
       
   223     //Change the ID when ID into release
       
   224     iSplitIndiBubble->SetBitmapParamL(NULL,
       
   225                               NULL,
       
   226                               KAknsIIDQsnFrInputPreviewSideL,
       
   227                               KAknsIIDQsnFrInputPreviewMiddle,
       
   228                               KAknsIIDQsnFrInputPreviewSideR);
       
   229     AddControlL(iSplitIndiBubble);
       
   230    
   219     // Vkb control
   231     // Vkb control
   220     iVkbCtrl = CPeninputVkbCtrlExt::NewL( TRect(), 
   232     iVkbCtrl = CPeninputVkbCtrlExt::NewL( TRect(), 
   221                                           UiLayout(), 
   233                                           UiLayout(), 
   222                                           EPeninutWindowCtrlIdVkbCtrl, 
   234                                           EPeninutWindowCtrlIdVkbCtrl, 
   223                                           NULL  );
   235                                           NULL  );
   863         }
   875         }
   864         
   876         
   865     iNewDeadKeyBuf = KNullDesC;
   877     iNewDeadKeyBuf = KNullDesC;
   866     return EFalse;
   878     return EFalse;
   867     } 
   879     } 
       
   880 
       
   881 // ---------------------------------------------------------------------------
       
   882 // Handle virtual key down event
       
   883 // ---------------------------------------------------------------------------
       
   884 //
       
   885 void CPeninputSplitQwertyWindow::HandleVirtualKeyDownEvent()
       
   886 	{
       
   887     // Get DeadKey state
       
   888     TInt latchedFlag = CPeninputDataConverter::AnyToInt(
       
   889 				   iLayoutContext->RequestData( EAkninputDataTypeLatchedSet ));
       
   890     
       
   891     if ( latchedFlag )
       
   892     	{
       
   893 	    UnLatchDeadKey( iNewDeadKeyBuf );
       
   894 	    TBool deadKeyChange = ETrue;
       
   895 	    iLayoutContext->SetData( EAkninputDataTypeLatchedSet, &deadKeyChange );
       
   896     	}
       
   897 	}
   868 
   898 
   869 // ---------------------------------------------------------------------------
   899 // ---------------------------------------------------------------------------
   870 // Set dead key
   900 // Set dead key
   871 // ---------------------------------------------------------------------------
   901 // ---------------------------------------------------------------------------
   872 //     
   902 //     
  2104         }
  2134         }
  2105     
  2135     
  2106     TRAP_IGNORE( UpdateRangeCtrlsL() );
  2136     TRAP_IGNORE( UpdateRangeCtrlsL() );
  2107     }
  2137     }
  2108 
  2138 
       
  2139 // ---------------------------------------------------------------------------
       
  2140 // Set split indicator bubble image
       
  2141 // ---------------------------------------------------------------------------
       
  2142 //
       
  2143 void CPeninputSplitQwertyWindow::SetSplitIndiBubbleImageL( const TInt aImgID1,
       
  2144                                               const TInt aMaskID1,
       
  2145                                               const TInt aImgID2,
       
  2146                                               const TInt aMaskID2 )
       
  2147     {
       
  2148     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
  2149 
       
  2150     CFbsBitmap* bmp1 = NULL;
       
  2151     CFbsBitmap* mask1 = NULL;
       
  2152     
       
  2153     TInt colorIndex = EAknsCIQsnIconColorsCG30;
       
  2154 
       
  2155     AknsUtils::CreateColorIconL(skininstance,
       
  2156                                 KAknsIIDQsnIconColors,
       
  2157                                 KAknsIIDQsnIconColors,
       
  2158                                 colorIndex,
       
  2159                                 bmp1,
       
  2160                                 mask1,
       
  2161                                 AknIconUtils::AvkonIconFileName(),
       
  2162                                 aImgID1,
       
  2163                                 aMaskID1,
       
  2164                                 KRgbGray);
       
  2165     CleanupStack::PushL( bmp1 );
       
  2166     CleanupStack::PushL( mask1 );
       
  2167                                 
       
  2168     AknIconUtils::GetContentDimensions(bmp1, iSplitIndicatorSize);
       
  2169 
       
  2170     CFbsBitmap* bmp2 = NULL;
       
  2171     CFbsBitmap* mask2 = NULL;
       
  2172     AknsUtils::CreateColorIconL(skininstance,
       
  2173                                 KAknsIIDQsnIconColors,
       
  2174                                 KAknsIIDQsnIconColors,
       
  2175                                 colorIndex,
       
  2176                                 bmp2,
       
  2177                                 mask2,
       
  2178                                 AknIconUtils::AvkonIconFileName(),
       
  2179                                 aImgID2,
       
  2180                                 aMaskID2,
       
  2181                                 KRgbGray);
       
  2182  
       
  2183     CleanupStack::PushL( bmp2 );
       
  2184     CleanupStack::PushL( mask2 );
       
  2185     
       
  2186     AknIconUtils::GetContentDimensions(bmp2, iSplitIndicatorTextSize);
       
  2187     
       
  2188     TRect boundRect;
       
  2189     if (iSplitIndiBubble->HasText())
       
  2190         {
       
  2191         boundRect = iLafMgr->SplitIndiIconRectWithText();
       
  2192         }
       
  2193     else
       
  2194         {
       
  2195         boundRect = iLafMgr->SplitIndiIconRectWithoutText();
       
  2196         }
       
  2197     TRect imgrect, textrect;
       
  2198     
       
  2199     CalIndicatorRect(boundRect, imgrect, textrect, EIndiAlignCenter);
       
  2200     AknIconUtils::SetSize(bmp1, imgrect.Size(), EAspectRatioNotPreserved);
       
  2201     AknIconUtils::SetSize(mask1, imgrect.Size(), EAspectRatioNotPreserved);
       
  2202     AknIconUtils::SetSize(bmp2, textrect.Size(), EAspectRatioNotPreserved);
       
  2203     AknIconUtils::SetSize(mask2, textrect.Size(), EAspectRatioNotPreserved);
       
  2204 
       
  2205     CFbsBitmap* bmp3 = AknPenImageUtils::CombineTwoImagesL(bmp1, bmp2, bmp1->DisplayMode());
       
  2206     CFbsBitmap* mask3 = AknPenImageUtils::CombineTwoImagesL(mask1, mask2, EGray256);
       
  2207     
       
  2208     iSplitIndiBubble->SetBitmapParamL( bmp3, mask3, 
       
  2209                     KAknsIIDQsnFrInputPreviewSideL,
       
  2210                     KAknsIIDQsnFrInputPreviewMiddle,
       
  2211                     KAknsIIDQsnFrInputPreviewSideR );
       
  2212     
       
  2213     CleanupStack::PopAndDestroy( mask2 );
       
  2214     CleanupStack::PopAndDestroy( bmp2 );
       
  2215     CleanupStack::PopAndDestroy( mask1 );
       
  2216     CleanupStack::PopAndDestroy( bmp1 );
       
  2217     }
       
  2218 
       
  2219 // ---------------------------------------------------------------------------
       
  2220 // Calculate indicator rect
       
  2221 // ---------------------------------------------------------------------------
       
  2222 //
       
  2223 void CPeninputSplitQwertyWindow::CalIndicatorRect(const TRect& aBoundRect,
       
  2224                                           TRect& aRealRect1,
       
  2225                                           TRect& aRealRect2,
       
  2226                                           TIndicatorAlign aAlign) 
       
  2227     {
       
  2228     TInt imgAspectText = iSplitIndicatorTextSize.iWidth / iSplitIndicatorTextSize.iHeight;
       
  2229     TInt imgAspectIndi = iSplitIndicatorSize.iWidth / iSplitIndicatorSize.iHeight;
       
  2230     TSize imgSizeText( aBoundRect.Size().iHeight * imgAspectText, 
       
  2231                        aBoundRect.Size().iHeight );
       
  2232     TSize imgSizeIndi( aBoundRect.Size().iHeight * imgAspectIndi, 
       
  2233                                aBoundRect.Size().iHeight );
       
  2234     // check if the length of img > bound rect width
       
  2235     TInt nTotalWidth = imgSizeText.iWidth + imgSizeIndi.iWidth;
       
  2236     if( nTotalWidth > aBoundRect.Size().iWidth )
       
  2237         {
       
  2238         TReal nAspect = (TReal)imgSizeText.iWidth / nTotalWidth;
       
  2239         imgSizeText.iWidth = aBoundRect.Size().iWidth * nAspect;
       
  2240         imgSizeIndi.iWidth = aBoundRect.Size().iWidth - imgSizeText.iWidth;
       
  2241         imgSizeText.iHeight = imgSizeText.iWidth / imgAspectText;
       
  2242         // make sure the height of two rect is equal
       
  2243         imgSizeIndi.iHeight = imgSizeText.iHeight;
       
  2244         }
       
  2245     if( aAlign == EIndiAlignRight )
       
  2246         {
       
  2247         aRealRect2 = TRect(TPoint( aBoundRect.iBr.iX - imgSizeText.iWidth, aBoundRect.iTl.iY),
       
  2248                        imgSizeText);
       
  2249         aRealRect1 = TRect(TPoint(aRealRect2.iTl.iX - imgSizeIndi.iWidth, aRealRect2.iTl.iY),
       
  2250                        imgSizeIndi);
       
  2251         }
       
  2252     else if( aAlign == EIndiAlignCenter )
       
  2253         {
       
  2254         TInt offsetX = ( aBoundRect.Size().iWidth - imgSizeText.iWidth - imgSizeIndi.iWidth ) / 2;
       
  2255         TInt offsetY = ( aBoundRect.Size().iHeight - imgSizeText.iHeight ) / 2;
       
  2256         aRealRect2 = TRect( TPoint( aBoundRect.iBr.iX - imgSizeText.iWidth - offsetX, 
       
  2257                                    aBoundRect.iTl.iY + offsetY),
       
  2258                             imgSizeText );
       
  2259         aRealRect1 = TRect( TPoint(aRealRect2.iTl.iX - imgSizeIndi.iWidth, aRealRect2.iTl.iY),
       
  2260                        imgSizeIndi );
       
  2261         }
       
  2262     else if( aAlign == EIndiAlignLeft )
       
  2263         {
       
  2264         aRealRect1 = TRect( aBoundRect.iTl, imgSizeIndi );
       
  2265         aRealRect2 = TRect( TPoint( aRealRect1.iBr.iX, aRealRect1.iTl.iY ), imgSizeText );
       
  2266         }
       
  2267     }
       
  2268 
       
  2269 // ---------------------------------------------------------------------------
       
  2270 // Set split indicator bubble size with text
       
  2271 // ---------------------------------------------------------------------------
       
  2272 //
       
  2273 void CPeninputSplitQwertyWindow::SetSplitIndiBubbleSizeWithText()
       
  2274     {
       
  2275     if ( iSplitIndiBubble )
       
  2276         {
       
  2277         TAknTextLineLayout textLine = iLafMgr->SplitIndiText();
       
  2278         TRect bubbleRect = iLafMgr->SplitIndiRectWithText();
       
  2279         TRect iconRect = iLafMgr->SplitIndiIconRectWithText();
       
  2280         TSize offset;
       
  2281         offset.iHeight = iconRect.iTl.iY - bubbleRect.iTl.iY;
       
  2282         offset.iWidth = iconRect.iTl.iX - bubbleRect.iTl.iX;
       
  2283         TSize size( iconRect.Width(), iconRect.Height());
       
  2284         
       
  2285         iSplitIndiBubble->SetRect( bubbleRect );
       
  2286         iSplitIndiBubble->SetIconOffsetAndSize( offset, size );
       
  2287         iSplitIndiBubble->SetTextFormat( textLine );
       
  2288         iSplitIndiBubble->SetTextColorIndex( EAknsCIQsnTextColorsCG67 );
       
  2289         }
       
  2290     }
       
  2291 
       
  2292 // ---------------------------------------------------------------------------
       
  2293 // Set split indicator bubble size without text
       
  2294 // ---------------------------------------------------------------------------
       
  2295 //
       
  2296 void CPeninputSplitQwertyWindow::SetSplitIndiBubbleSizeWithoutText()
       
  2297     {
       
  2298     if ( iSplitIndiBubble )
       
  2299         {
       
  2300         TRect bubbleRect = iLafMgr->SplitIndiRectWithoutText();
       
  2301         TRect iconRect = iLafMgr->SplitIndiIconRectWithoutText();
       
  2302         TSize offset;
       
  2303         offset.iHeight = iconRect.iTl.iY - bubbleRect.iTl.iY;
       
  2304         offset.iWidth = iconRect.iTl.iX - bubbleRect.iTl.iX;
       
  2305         TSize size( iconRect.Width(), iconRect.Height());
       
  2306         
       
  2307         iSplitIndiBubble->SetRect( bubbleRect );
       
  2308         iSplitIndiBubble->SetIconOffsetAndSize( offset, size );
       
  2309         }
       
  2310     }
       
  2311 
       
  2312 // ---------------------------------------------------------------------------
       
  2313 // Update split indicator bubble
       
  2314 // ---------------------------------------------------------------------------
       
  2315 //
       
  2316 void CPeninputSplitQwertyWindow::UpdateSplitIndiBubbleL( TUint8* aData )
       
  2317     {
       
  2318     RDesReadStream readStream;
       
  2319     TFepIndicatorInfo indicatorData;
       
  2320 
       
  2321     TPtr8 countPtr( aData, 4*sizeof(TInt), 4*sizeof(TInt) );            
       
  2322     readStream.Open(countPtr);
       
  2323     CleanupClosePushL(readStream);
       
  2324 
       
  2325     indicatorData.iIndicatorImgID = readStream.ReadInt32L();
       
  2326     indicatorData.iIndicatorMaskID = readStream.ReadInt32L();
       
  2327     indicatorData.iIndicatorTextImgID = readStream.ReadInt32L();
       
  2328     indicatorData.iIndicatorTextMaskID = readStream.ReadInt32L();
       
  2329 
       
  2330     CleanupStack::PopAndDestroy(&readStream);
       
  2331     
       
  2332     if ( indicatorData.iIndicatorImgID != 0 && 
       
  2333         indicatorData.iIndicatorMaskID != 0 && 
       
  2334         indicatorData.iIndicatorTextImgID != 0 &&
       
  2335         indicatorData.iIndicatorTextMaskID != 0 )
       
  2336         { 
       
  2337         SetSplitIndicatorData( indicatorData );
       
  2338         
       
  2339 
       
  2340         SetSplitIndiBubbleImageL( indicatorData.iIndicatorImgID,
       
  2341                     indicatorData.iIndicatorMaskID,
       
  2342                     indicatorData.iIndicatorTextImgID,
       
  2343                     indicatorData.iIndicatorTextMaskID );
       
  2344                  
       
  2345         iSplitIndiBubble->Hide(EFalse);
       
  2346         }
       
  2347     }
       
  2348 
  2109 // End Of File
  2349 // End Of File