textinput/peninputhwrfscn/src/peninputhwrfscnbkgnd.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2005-2006 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 for chinese peninput full screen controlbar background
       
    15 *
       
    16 */
       
    17 
       
    18 // INCLUDE
       
    19 
       
    20 #include <aknlayoutscalable_apps.cdl.h>
       
    21 #include <aknlayoutscalable_avkon.cdl.h>
       
    22 #include <AknLayoutDef.h>
       
    23 #include <AknUtils.h>
       
    24 #include <AknsUtils.h>
       
    25 #include <AknIconUtils.h>
       
    26 #include <coemain.h>
       
    27 #include <s32mem.h>
       
    28 #include <barsread.h> 
       
    29 #include <peninputhwrfscn.mbg>
       
    30 
       
    31 #include "peninputhwrfscnbkgnd.h"
       
    32 
       
    33 const TInt KInvalidImg = -1 ;
       
    34 const TInt KInvalidResId = -1;
       
    35 
       
    36 // ---------------------------------------------------------------------------
       
    37 // Symbian Constructor
       
    38 // ---------------------------------------------------------------------------
       
    39 //
       
    40 CPeninputHwrfscnBkgnd* CPeninputHwrfscnBkgnd::NewL( CFepUiLayout* aLayout, TInt aCtrlId )
       
    41     {
       
    42     CPeninputHwrfscnBkgnd* self = NewLC( aLayout, aCtrlId );
       
    43     CleanupStack::Pop( self );
       
    44     return self;
       
    45     }
       
    46 
       
    47 // ---------------------------------------------------------------------------
       
    48 // Symbian Constructor
       
    49 // ---------------------------------------------------------------------------
       
    50 //
       
    51 CPeninputHwrfscnBkgnd* CPeninputHwrfscnBkgnd::NewLC( CFepUiLayout* aLayout, TInt aCtrlId )
       
    52     {
       
    53     CPeninputHwrfscnBkgnd* self = new(ELeave) CPeninputHwrfscnBkgnd( aLayout, aCtrlId );
       
    54     
       
    55     CleanupStack::PushL( self );
       
    56     self->ConstructL();
       
    57     return self;
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // c++ destructor
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CPeninputHwrfscnBkgnd::~CPeninputHwrfscnBkgnd()
       
    65     {
       
    66     
       
    67     }
       
    68     
       
    69 // ---------------------------------------------------------------------------
       
    70 // Draw window.
       
    71 // ---------------------------------------------------------------------------
       
    72 //
       
    73 void CPeninputHwrfscnBkgnd::Draw()
       
    74     {
       
    75     if( !AbleToDraw() )
       
    76         {
       
    77         return;
       
    78         }
       
    79     
       
    80     CFbsBitGc* gc = static_cast<CFbsBitGc*>( BitGc() );
       
    81     gc->Activate( BitmapDevice() );
       
    82     gc->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
    83     gc->SetBrushColor( BkColor() );
       
    84     gc->SetPenStyle(CGraphicsContext::ENullPen );
       
    85     gc->SetPenSize( TSize(0,0) );
       
    86     
       
    87     for ( TInt i = 0; i < iCtrlList.Count(); i++ )        
       
    88         {
       
    89         CFepUiBaseCtrl* ctrl = iCtrlList[i];
       
    90         
       
    91         if( !ctrl->Hiden() )
       
    92             {
       
    93             TRect rect = ctrl->Rect();
       
    94             if ( rect.Height() > 0 && rect.Width() > 0  )
       
    95                 {
       
    96                 if ( BackgroundBmp() )
       
    97                     {
       
    98                     gc->DrawBitmap( rect, BackgroundBmp() );
       
    99                     }
       
   100                 else
       
   101                     {
       
   102                     gc->DrawRect( rect );
       
   103                     }
       
   104                 }
       
   105             }
       
   106         }
       
   107     
       
   108     CControlGroup::Draw();
       
   109     }
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // Construct control from resource.
       
   113 // ---------------------------------------------------------------------------
       
   114 //
       
   115 void CPeninputHwrfscnBkgnd::ConstructFromResourceL()
       
   116     {
       
   117     CControlGroup::ConstructFromResourceL();
       
   118     
       
   119     if ( iResourceId == KInvalidResId )
       
   120         {
       
   121         User::Leave( KErrArgument );
       
   122         }    
       
   123     TResourceReader reader;
       
   124     CCoeEnv::Static()->CreateResourceReaderLC( reader, iResourceId );
       
   125     
       
   126     TPtrC bmpFileName = reader.ReadTPtrC();
       
   127     TInt32 imgMajorSkinId = reader.ReadInt32();
       
   128 
       
   129     TAknsItemID id;
       
   130     
       
   131     MAknsSkinInstance* skininstance = AknsUtils::SkinInstance();
       
   132     const TInt16 bmpId = reader.ReadInt16();
       
   133     const TInt16 bmpMskId = reader.ReadInt16();
       
   134     const TInt16 skinitemid = reader.ReadInt16();   
       
   135     id.Set( TInt(imgMajorSkinId), skinitemid );
       
   136     
       
   137     if ( bmpId != KInvalidImg )
       
   138         {
       
   139         CFbsBitmap* bmpImage = NULL;
       
   140         CFbsBitmap* bmpMask = NULL;
       
   141         if ( bmpMskId != KInvalidImg )
       
   142             {
       
   143             AknsUtils::CreateIconL( skininstance, 
       
   144                                     id,
       
   145                                     bmpImage,
       
   146                                     bmpMask,
       
   147                                     bmpFileName,
       
   148                                     bmpId,
       
   149                                     bmpMskId);
       
   150             }
       
   151         else
       
   152             {
       
   153             AknsUtils::CreateIconL( skininstance,
       
   154                                     id,
       
   155                                     bmpImage,
       
   156                                     bmpFileName,
       
   157                                     bmpId);
       
   158             }
       
   159         TSize size( 8, 8 );
       
   160         AknIconUtils::SetSize( bmpImage, size, EAspectRatioNotPreserved );
       
   161         AknIconUtils::SetSize( bmpMask, size, EAspectRatioNotPreserved );
       
   162         
       
   163         SetBackgroundBmp( bmpImage );
       
   164         SetBackgroundMaskBmp( bmpMask ); 
       
   165         }
       
   166     
       
   167     CleanupStack::PopAndDestroy(); // reader
       
   168     
       
   169     if ( !iFirstTimeConstruct )
       
   170         {
       
   171         Draw();
       
   172         }
       
   173     
       
   174     iFirstTimeConstruct = EFalse;
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // c++ constructor
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 CPeninputHwrfscnBkgnd::CPeninputHwrfscnBkgnd( CFepUiLayout* aLayout, TInt aCtrlId )
       
   182     : CControlGroup( aLayout, aCtrlId ), iFirstTimeConstruct( ETrue )
       
   183     {
       
   184     
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // Symbian second-phase constructor
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 void CPeninputHwrfscnBkgnd::ConstructL()
       
   192     {
       
   193     BaseConstructL();
       
   194     }