S60 3rd Edition SDK for Symbian OS
Example Applications Guide

IsvTelInfoAppContainer.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : IsvTelInfoAppContainer.cpp
00004 *  Part of     : IsvTelInfoApp
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2005-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include <aknutils.h> // for AKN_LAF_COLOR
00018 #include <eikenv.h>
00019 #include <eiklabel.h> // for label
00020 #include <aknform.h>  // for form control
00021 #include <eikseced.h> // for secret editor
00022 #include <eikedwin.h> // for edwins
00023 #include <IsvTelInfoApp.rsg>
00024 #include "IsvTelInfoApp.hrh"
00025 #include "IsvTelInfoAppView.h"
00026 #include "IsvTelInfoAppContainer.h"
00027 #include "IsvTelInfoAppDlg.h"
00028 
00029 // MACROS
00030 #define ISVINFOAPP_BACKGROUND_COLOR AKN_LAF_COLOR( 219 )
00031 
00032 // CONSTANTS
00033 const TInt KIsvTelInfoAppCountComponent = 1;
00034 const TInt KIsvTelInfoAppMessageBufLength = 256;
00035 
00036 // ================= MEMBER FUNCTIONS =========================================
00037 
00038 // ----------------------------------------------------------------------------
00039 // CIsvTelInfoAppContainer::CIsvTelInfoAppContainer( CIsvTelInfoAppView* )
00040 // Overload constructor.
00041 // ----------------------------------------------------------------------------
00042 //
00043 CIsvTelInfoAppContainer::CIsvTelInfoAppContainer( 
00044     CIsvTelInfoAppView* aView )
00045 :   iView( aView ),
00046     iLabel( NULL )
00047     {
00048     }
00049 
00050 // ----------------------------------------------------------------------------
00051 // void CIsvTelInfoAppContainer::ConstructL( const TRect& )
00052 // EPOC constructor.
00053 // ----------------------------------------------------------------------------
00054 //
00055 void CIsvTelInfoAppContainer::ConstructL( const TRect& aRect )
00056     {
00057     // Creates window.
00058     CreateWindowL();
00059 
00060     // Creates label object.
00061     CreateLabelL();
00062 
00063     SetRect( aRect ); // Sets rectangle of frame.
00064     ActivateL(); // Activates the window. (Ready to draw)
00065     }
00066 
00067 // ----------------------------------------------------------------------------
00068 // CIsvTelInfoAppContainer::~CIsvTelInfoAppContainer()
00069 // Destructor.
00070 // ----------------------------------------------------------------------------
00071 //
00072 CIsvTelInfoAppContainer::~CIsvTelInfoAppContainer()
00073     {
00074     delete iLabel;
00075     }
00076 
00077 // ----------------------------------------------------------------------------
00078 // void CIsvTelInfoAppContainer::SetTextToLabelL( TInt )
00079 //
00080 // ----------------------------------------------------------------------------
00081 //
00082 void CIsvTelInfoAppContainer::SetTextToLabelL( TInt aResourceId )
00083     {
00084     TBuf<KIsvTelInfoAppMessageBufLength> messageString( NULL );
00085     iCoeEnv->ReadResource( messageString, aResourceId );
00086     iLabel->SetTextL( messageString );
00087     }
00088 
00089 // ----------------------------------------------------------------------------
00090 // void CIsvTelInfoAppContainer::DisplayFormL( TInt, TInt )
00091 //
00092 // ----------------------------------------------------------------------------
00093 //
00094 void CIsvTelInfoAppContainer::DisplayFormL( 
00095     TInt aResourceId,
00096     TInt aPageId)
00097     {
00098     CIsvTelInfoAppDlg* form = CIsvTelInfoAppDlg::NewL();
00099     form->SetTitlePane(iView->GetTitlePaneL());
00100     form->SetContainer(this);
00101     form->SetDlgPage(aPageId);
00102     form->ExecuteLD( aResourceId );
00103     }
00104 
00105 // ----------------------------------------------------------------------------
00106 // void CIsvTelInfoAppContainer::BringToForeGroundL( )
00107 //
00108 // ----------------------------------------------------------------------------
00109 //
00110 void CIsvTelInfoAppContainer::BringToForeGroundL( )
00111     {
00112     iView->ActivateViewL(iView->ViewId());
00113     }
00114 
00115 // ----------------------------------------------------------------------------
00116 // void CIsvTelInfoAppContainer::CreateLabelL()
00117 // Creates label object.
00118 // ----------------------------------------------------------------------------
00119 //
00120 void CIsvTelInfoAppContainer::CreateLabelL()
00121     {
00122     if ( !iLabel )
00123         {
00124         iLabel = new( ELeave ) CEikLabel;
00125         iLabel->SetContainerWindowL( *this );
00126         iLabel->SetAlignment( EHCenterVCenter );
00127 #ifdef __AVKON_APAC__
00128         iLabel->SetFont( ApacPlain16() );
00129 #else
00130         iLabel->SetFont( LatinBold19() );
00131 #endif
00132         }
00133     SetTextToLabelL( R_ISVTELINFOAPP_TEXT_LABEL_TITLE );
00134     }
00135 
00136 // ----------------------------------------------------------------------------
00137 // TKeyResponse CIsvTelInfoAppContainer::OfferKeyEventL( const TKeyEvent&,
00138 //  TEventCode )
00139 // Handles the key events.
00140 // ----------------------------------------------------------------------------
00141 //
00142 TKeyResponse CIsvTelInfoAppContainer::OfferKeyEventL(
00143     const TKeyEvent& aKeyEvent,
00144     TEventCode aType )
00145     {
00146     if ( aType != EEventKey ) // Is not key event?
00147         {
00148         return EKeyWasNotConsumed;
00149         }
00150     switch ( aKeyEvent.iCode ) // The code of key event is...
00151         {
00152         default:
00153             return EKeyWasNotConsumed;
00154         }
00155     }
00156 
00157 // ----------------------------------------------------------------------------
00158 // void CIsvTelInfoAppContainer::SizeChanged()
00159 // Called by framework when the view size is changed
00160 // ----------------------------------------------------------------------------
00161 //
00162 void CIsvTelInfoAppContainer::SizeChanged()
00163     {
00164     iLabel->SetRect( Rect() );
00165     }
00166 
00167 // ----------------------------------------------------------------------------
00168 // TInt CIsvTelInfoAppContainer::CountComponentControls() const
00169 // Returns number of component.
00170 // ----------------------------------------------------------------------------
00171 //
00172 TInt CIsvTelInfoAppContainer::CountComponentControls() const
00173     {
00174     // returns nbr of controls inside this container
00175     return KIsvTelInfoAppCountComponent;
00176     }
00177 
00178 // ----------------------------------------------------------------------------
00179 // CCoeControl* CIsvTelInfoAppContainer::ComponentControl( TInt ) const
00180 // Returns pointer to particular component.
00181 // ----------------------------------------------------------------------------
00182 //
00183 CCoeControl* CIsvTelInfoAppContainer::ComponentControl( TInt aIndex ) const
00184     {
00185     switch ( aIndex ) // Component is...
00186         {
00187         case EIsvTelInfoAppComponentLabel: // Label object.
00188             return iLabel;
00189         default: // Exception : returns NULL value.
00190             return NULL;
00191         }
00192     }
00193 
00194 // ----------------------------------------------------------------------------
00195 // void CIsvTelInfoAppContainer::Draw( const TRect& ) const
00196 // Clears the window's rectangle.
00197 // ----------------------------------------------------------------------------
00198 //
00199 void CIsvTelInfoAppContainer::Draw( const TRect& aRect ) const
00200     {
00201     CWindowGc& gc = SystemGc();
00202     gc.SetPenStyle( CGraphicsContext::ENullPen );
00203     gc.SetBrushColor( ISVINFOAPP_BACKGROUND_COLOR );
00204     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
00205     gc.DrawRect( aRect );
00206     }
00207 
00208 // End of File

© Nokia 2006

Back to top