textinput/peninputarc/src/peninputlayoutcontrol/peninputaknvkbpreviewbubblerenderer.cpp
branchRCL_3
changeset 21 ecbabf52600f
parent 5 a47de9135b21
equal deleted inserted replaced
20:ebd48d2de13c 21:ecbabf52600f
       
     1 /*
       
     2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0""
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation of vkb window class
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 
       
    20 // User includes
       
    21 #include "peninputaknvkbpreviewbubblerenderer.h"
       
    22 #include "peninputfloatbubble.h"
       
    23 
       
    24 // Constants
       
    25 // Modify warning
       
    26 //const TInt KDefaultBubbleSize = 50;
       
    27 
       
    28 // Member functions
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // Symbian constructor
       
    32 // ---------------------------------------------------------------------------
       
    33 // 
       
    34 EXPORT_C CPeninputAknVkbPreviewBubbleRenderer* CPeninputAknVkbPreviewBubbleRenderer::NewL()
       
    35     {
       
    36     CPeninputAknVkbPreviewBubbleRenderer* self = new( ELeave) CPeninputAknVkbPreviewBubbleRenderer;
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39     CleanupStack::Pop( self );
       
    40     return self;
       
    41     }
       
    42 
       
    43 // ---------------------------------------------------------------------------
       
    44 // C++ destructor
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 CPeninputAknVkbPreviewBubbleRenderer::~CPeninputAknVkbPreviewBubbleRenderer()
       
    48     {
       
    49     delete iBubbleCtrlEx;
       
    50     
       
    51     iBubbleCtrlEx = NULL;
       
    52     }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // Attach this extension to a virtual keyboard object.
       
    56 // ---------------------------------------------------------------------------
       
    57 //
       
    58 void CPeninputAknVkbPreviewBubbleRenderer::Attach()
       
    59     {
       
    60     iRefCount++;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // Detach this extension from a virtual keyboard object.
       
    65 // ---------------------------------------------------------------------------
       
    66 //
       
    67 void CPeninputAknVkbPreviewBubbleRenderer::Detach()
       
    68     {
       
    69     iRefCount--;
       
    70     if ( iRefCount < 1 ) 
       
    71         {
       
    72         delete this;
       
    73         }
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------------------------
       
    77 // Enable preview bubble.
       
    78 // ---------------------------------------------------------------------------
       
    79 //
       
    80 void CPeninputAknVkbPreviewBubbleRenderer::ShowBubble( TBool aFlag )
       
    81     {
       
    82     if ( aFlag && ( NULL == iBubbleCtrlEx ) )
       
    83         {
       
    84         TRAP_IGNORE( iBubbleCtrlEx = CPeninputFloatingBubble::NewL() );
       
    85         }
       
    86     }
       
    87 
       
    88 // ---------------------------------------------------------------------------
       
    89 // Draw preview bubble.
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void CPeninputAknVkbPreviewBubbleRenderer::DrawBubble( CVirtualKey* aKey,  
       
    93                                                        const TPoint& aVkbPos, 
       
    94                                                        const TPoint& aLayoutPos, 
       
    95                                                        const TSize& aBubbleSize  )
       
    96     {   
       
    97     if ( iBubbleCtrlEx )
       
    98         {
       
    99         TRect rect = aKey->Rect();
       
   100         rect.Move( aVkbPos.iX, aVkbPos.iY );
       
   101         rect.Move( aLayoutPos.iX, aLayoutPos.iY ); //now is in screen coord-sys
       
   102     
       
   103         TInt x = rect.Center().iX - aBubbleSize.iWidth / 2;
       
   104         TInt y = rect.iTl.iY - aBubbleSize.iHeight - 5;
       
   105     
       
   106         TRect rcBubble( TPoint(x,y), aBubbleSize );
       
   107         if( aKey->DisplayUnicode() && aKey->DisplayUnicode()->Length() != 0 )
       
   108             {
       
   109             iBubbleCtrlEx->SetText( *aKey->DisplayUnicode() );        
       
   110             }
       
   111         else
       
   112             {
       
   113             iBubbleCtrlEx->SetText( aKey->KeyUnicodes() );            
       
   114             }
       
   115         
       
   116         iBubbleCtrlEx->Show( rcBubble );
       
   117         iBubbleCtrlEx->DrawDeferred();
       
   118         }    
       
   119     }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // Clear preview bubble.
       
   123 // ---------------------------------------------------------------------------
       
   124 //
       
   125 void CPeninputAknVkbPreviewBubbleRenderer::ClearBubble()
       
   126     {
       
   127     if ( iBubbleCtrlEx )
       
   128         {
       
   129         iBubbleCtrlEx->Hide();
       
   130         }    
       
   131     }
       
   132 
       
   133 // ---------------------------------------------------------------------------
       
   134 // Set icon and background of bubble.
       
   135 // ---------------------------------------------------------------------------
       
   136 //
       
   137 void CPeninputAknVkbPreviewBubbleRenderer::SetBubbleBitmapParam( CFbsBitmap* /*aBmpId*/, 
       
   138                                                                  CFbsBitmap* /*aMaskBmpId*/, 
       
   139                                                                  TAknsItemID aBgSkinId )
       
   140     {
       
   141     if( iBubbleCtrlEx )
       
   142         {
       
   143         iBubbleCtrlEx->SetBackgroundImage( aBgSkinId );
       
   144         }    
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // Set text format
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CPeninputAknVkbPreviewBubbleRenderer::SetTextFormat( TAknTextLineLayout aTextFormat )
       
   152     {
       
   153     if( iBubbleCtrlEx )
       
   154         {
       
   155         iBubbleCtrlEx->SetTextFormat( aTextFormat );
       
   156         }    
       
   157     }
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // Set margin of bubble
       
   161 // ---------------------------------------------------------------------------
       
   162 //
       
   163 void CPeninputAknVkbPreviewBubbleRenderer::SetFrameDiff( TInt /*aLeftDiff*/, 
       
   164                                                          TInt /*aTopDiff*/, 
       
   165                                                          TInt /*aRightDiff*/,
       
   166                                                          TInt /*aBottomDiff*/ )
       
   167     {
       
   168     }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // C++ constructor
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 CPeninputAknVkbPreviewBubbleRenderer::CPeninputAknVkbPreviewBubbleRenderer()
       
   175     {
       
   176     }
       
   177 
       
   178 // ---------------------------------------------------------------------------
       
   179 // Symbian constructor
       
   180 // ---------------------------------------------------------------------------
       
   181 //
       
   182 void CPeninputAknVkbPreviewBubbleRenderer::ConstructL()
       
   183     {
       
   184     }