camerauis/cameraapp/generic/src/CamTitlePane.cpp
branchRCL_3
changeset 54 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
53:61bc0f252b2b 54:bac7acad7cb3
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Class for displaying the title in the Status Pane*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <AknsControlContext.h>
       
    21 #include <Barsread.h>
       
    22 #include <AknsUtils.h>
       
    23 #include <AknsDrawUtils.h>
       
    24 #include <AknsSkinInstance.h>
       
    25 #include <AknsBasicBackgroundControlContext.h>
       
    26 
       
    27 #include "CamPostCaptureInfoDisplay.h"
       
    28 #include "CamTitlePane.h"
       
    29 
       
    30 #include <cameraapp.rsg>
       
    31 #include <vgacamsettings.rsg>
       
    32 
       
    33 // EXTERNAL DATA STRUCTURES
       
    34 
       
    35 // EXTERNAL FUNCTION PROTOTYPES  
       
    36 
       
    37 // CONSTANTS
       
    38 const TAknsItemID KNaviPaneMajorColour = KAknsIIDQsnTextColors;
       
    39 const TInt KNaviPaneMinorColour = EAknsCIQsnTextColorsCG1;
       
    40 
       
    41 // MACROS
       
    42 
       
    43 // LOCAL CONSTANTS AND MACROS
       
    44 
       
    45 // MODULE DATA STRUCTURES
       
    46 
       
    47 // LOCAL FUNCTION PROTOTYPES
       
    48 
       
    49 // FORWARD DECLARATIONS
       
    50 
       
    51 // ============================= LOCAL FUNCTIONS ===============================
       
    52 
       
    53 
       
    54 // ============================ MEMBER FUNCTIONS ===============================
       
    55 
       
    56 // -----------------------------------------------------------------------------
       
    57 // CCamTitlePane::CCamTitlePane
       
    58 // C++ default constructor can NOT contain any code, that
       
    59 // might leave.
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 CCamTitlePane::CCamTitlePane()
       
    63     {
       
    64     }
       
    65 
       
    66 // -----------------------------------------------------------------------------
       
    67 // CCamTitlePane::ConstructL
       
    68 // Symbian 2nd phase constructor can leave.
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 void CCamTitlePane::ConstructL()
       
    72     {
       
    73     // Read the resource to get pane position information    
       
    74     iTitlePaneLayoutRect.LayoutRect( Rect(), ROID(R_CAM_TITLE_PANE_RECT_ID));                  
       
    75     SetRect( iTitlePaneLayoutRect.Rect() );
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CCamTitlePane::NewL
       
    80 // Two-phased constructor.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CCamTitlePane* CCamTitlePane::NewL()
       
    84     {
       
    85     CCamTitlePane* self = new( ELeave ) CCamTitlePane;
       
    86     
       
    87     CleanupStack::PushL( self );
       
    88     self->ConstructL();
       
    89     CleanupStack::Pop( self );
       
    90 
       
    91     return self;
       
    92     }
       
    93 
       
    94     
       
    95 // Destructor
       
    96 CCamTitlePane::~CCamTitlePane()
       
    97   {
       
    98   PRINT( _L("Camera => ~CCamTitlePane" ))  
       
    99   delete iTextHbuf;
       
   100   PRINT( _L("Camera <= ~CCamTitlePane" ))  
       
   101   }
       
   102     
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CCamTitlePane::SetFromResourceL
       
   106 // Sets the title with the specified resource string
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 void CCamTitlePane::SetFromResourceL( TInt aResource )
       
   110     {
       
   111     TResourceReader reader; 
       
   112     iEikonEnv->CreateResourceReaderLC( reader, aResource );                
       
   113     
       
   114     if ( iTextHbuf != NULL )
       
   115         {
       
   116         delete iTextHbuf;
       
   117         iTextHbuf = NULL;
       
   118         }
       
   119     iTextHbuf = reader.ReadHBufC16L();
       
   120     CleanupStack::PopAndDestroy();  // resource reader
       
   121     DrawDeferred();
       
   122     }
       
   123 
       
   124 
       
   125 
       
   126 // -----------------------------------------------------------------------------
       
   127 // CCamTitlePane::SetTextL
       
   128 // Sets the title with the specified string
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 void CCamTitlePane::SetTextL( const TDesC& aText )
       
   132     {
       
   133     if ( iTextHbuf != NULL )
       
   134         {
       
   135         delete iTextHbuf;
       
   136         iTextHbuf = NULL;
       
   137         }
       
   138     iTextHbuf = aText.AllocL();
       
   139     DrawDeferred();
       
   140     }
       
   141     
       
   142     
       
   143 // ---------------------------------------------------------
       
   144 // CCamTitlePane::Draw
       
   145 // Draw control
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 void CCamTitlePane::Draw( const TRect& /*aRect*/ ) const
       
   149     {
       
   150     CWindowGc& gc=SystemGc();
       
   151 
       
   152     // Draw the background:
       
   153     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   154     MAknsControlContext* cc = AknsDrawUtils::ControlContext( this );
       
   155     AknsDrawUtils::Background( skin, cc, this, gc, Rect() );
       
   156     
       
   157     // Set drawing colour from layout information
       
   158     TRgb color = iTitleTextLayout.Color();
       
   159     
       
   160     // ...Color is not updated if it not found from the skin
       
   161     AknsUtils::GetCachedColor( skin, color,
       
   162         KNaviPaneMajorColour, KNaviPaneMinorColour );
       
   163 
       
   164     if ( iTextHbuf )
       
   165         {
       
   166         iTitleTextLayout.DrawText( gc, iTextHbuf->Des(), ETrue, color );             
       
   167         }    
       
   168     }
       
   169     
       
   170 
       
   171 // ---------------------------------------------------------
       
   172 // CCamTitlePane::SizeChanged
       
   173 // Called by framework when the component size is changed
       
   174 // ---------------------------------------------------------
       
   175 //
       
   176 void CCamTitlePane::SizeChanged()
       
   177     {
       
   178     if ( Rect().Size() != TSize( 0, 0 ) )
       
   179         {        
       
   180         if ( !AknLayoutUtils::LayoutMirrored() )
       
   181             {
       
   182             iTitleTextLayout.LayoutText( Rect(), ROID(R_CAM_TITLE_TEXT_LAYOUT_ID));
       
   183             }
       
   184         else
       
   185             {
       
   186             iTitleTextLayout.LayoutText( Rect(), ROID(R_CAM_TITLE_TEXT_LAYOUT_AH_ID));
       
   187             }
       
   188         }    
       
   189     }
       
   190     
       
   191 
       
   192 
       
   193 
       
   194 
       
   195 
       
   196 
       
   197 
       
   198 //  End of File