Nokia N97 SDK
Example Applications Guide

MyViewContainer.cpp

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

© Nokia 2009

Back to top