Nokia N97 SDK
Example Applications Guide

MyViewContainer2.cpp

00001 
00002 /*
00003 * ==============================================================================
00004 *  Name        : CMyViewContainer2.cpp
00005 *  Part of     : MyView
00006 *  Interface   :
00007 *  Description : Container for second view(CMyViewView2), does all drawing for
00008 *                second view
00009 *  Version     :
00010 *
00011 *  Copyright (c) 2002 - 2007 Nokia Corporation.
00012 *  This material, including documentation and any related
00013 *  computer programs, is protected by copyright controlled by
00014 *  Nokia Corporation.
00015 * ==============================================================================
00016 */
00017 
00018 
00019 // INCLUDE FILES
00020 #include "MyViewContainer2.h"
00021 
00022 #include <eiklabel.h>  // for example label control
00023 
00024 // ================= MEMBER FUNCTIONS =======================
00025 
00026 // ---------------------------------------------------------
00027 // CMyViewContainer2::ConstructL(const TRect& aRect)
00028 // EPOC two phased constructor
00029 // ---------------------------------------------------------
00030 //
00031 void CMyViewContainer2::ConstructL(const TRect& aRect)
00032     {
00033     CreateWindowL();
00034 
00035     iLabel = new (ELeave) CEikLabel;
00036     iLabel->SetContainerWindowL( *this );
00037     iLabel->SetTextL( _L("MyView 2\n\nSelect external view\nactivation from menu") );
00038 
00039     SetRect(aRect);
00040     ActivateL();
00041     }
00042 
00043 // Destructor
00044 CMyViewContainer2::~CMyViewContainer2()
00045     {
00046     delete iLabel;
00047     }
00048 
00049 // ---------------------------------------------------------
00050 // CMyViewContainer2::SizeChanged()
00051 // Called by framework when the view size is changed
00052 // ---------------------------------------------------------
00053 //
00054 void CMyViewContainer2::SizeChanged()
00055     {
00056     // TODO: Add here control resize code etc.
00057     iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
00058     }
00059 
00060 // ---------------------------------------------------------
00061 // CMyViewContainer2::CountComponentControls() const
00062 // ---------------------------------------------------------
00063 //
00064 TInt CMyViewContainer2::CountComponentControls() const
00065     {
00066     return 1; // return nbr of controls inside this container
00067     }
00068 
00069 // ---------------------------------------------------------
00070 // CMyViewContainer2::ComponentControl(TInt aIndex) const
00071 // ---------------------------------------------------------
00072 //
00073 CCoeControl* CMyViewContainer2::ComponentControl(TInt aIndex) const
00074     {
00075     switch ( aIndex )
00076         {
00077         case 0:
00078             return iLabel;
00079         default:
00080             return NULL;
00081         }
00082     }
00083 
00084 // ---------------------------------------------------------
00085 // CMyViewContainer2::Draw(const TRect& aRect) const
00086 // ---------------------------------------------------------
00087 //
00088 void CMyViewContainer2::Draw(const TRect& aRect) const
00089     {
00090     CWindowGc& gc = SystemGc();
00091 
00092     gc.SetPenStyle(CGraphicsContext::ENullPen);
00093     gc.SetBrushColor(KRgbBlue);
00094     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00095     gc.DrawRect(aRect);
00096     }
00097 
00098 // ---------------------------------------------------------
00099 // CMyViewContainer2::HandleControlEventL(
00100 //     CCoeControl* aControl,TCoeEvent aEventType)
00101 // ---------------------------------------------------------
00102 //
00103 void CMyViewContainer2::HandleControlEventL(
00104     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
00105     {
00106     // Add your control event handler code here
00107     }
00108 
00109 // End of File  

© Nokia 2009

Back to top