examples/SFExamples/PIM/ContactStandard/src/s60_3rd/ContactStandardMainView.cpp

00001 // 
00002 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
00003 // All rights reserved.
00004 // This component and the accompanying materials are made available
00005 // under the terms of the License "Eclipse Public License v1.0"
00006 // which accompanies this distribution, and is available
00007 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00008 // 
00009 // Initial Contributors:
00010 // Nokia Corporation - initial contribution.
00011 // 
00012 // Contributors:
00013 // 
00014 // Description:
00015 // 
00016 
00017 #include <eikedwin.h>
00018 #include <eikenv.h>
00019 #include <aknutils.h>
00020 #include <ContactStandard.rsg>
00021 
00022 #include "ContactStandardMainView.h"
00023 
00024 CContactStandardMainView* CContactStandardMainView::NewL(const TRect& aRect)
00025         {
00026         CContactStandardMainView* self = CContactStandardMainView::NewLC(aRect);
00027         CleanupStack::Pop(self);
00028         return self;
00029         }
00030 
00031 CContactStandardMainView* CContactStandardMainView::NewLC(const TRect& aRect)
00032         {
00033         CContactStandardMainView* self = new (ELeave) CContactStandardMainView;
00034         CleanupStack::PushL(self);
00035         self->ConstructL(aRect);
00036         return self;
00037         }
00038 
00039 CContactStandardMainView::~CContactStandardMainView()
00040         {
00041         delete iEikEdwin;
00042         }
00043         
00044 void CContactStandardMainView::ConstructL(const TRect& aRect)
00045         {
00046         CreateWindowL();
00047         
00048         // Create an edwin on this control.
00049         iEikEdwin = new (ELeave) CEikEdwin();
00050         iEikEdwin->ConstructL(CEikEdwin::EReadOnly | CEikEdwin::ENoAutoSelection);
00051         iEikEdwin->SetContainerWindowL(*this);
00052         HBufC* message = ControlEnv()->AllocReadResourceLC(
00053                 R_CONTACTSTANDARD);
00054         iEikEdwin->SetTextL(message);
00055         CleanupStack::PopAndDestroy(message);
00056         
00057         SetRect(aRect);
00058         ActivateL();
00059         }
00060 
00061 void CContactStandardMainView::SetTextL(const TDesC& aText)
00062         {
00063         if (iEikEdwin)
00064                 {
00065                 iEikEdwin->SetTextL(&aText);
00066                 DrawNow();
00067                 }
00068         }
00069 
00070 TInt CContactStandardMainView::CountComponentControls() const
00071         {
00072         if (iEikEdwin)
00073                 {
00074                 return 1;
00075                 }
00076         return 0;
00077         }
00078 
00079 CCoeControl* CContactStandardMainView::ComponentControl(TInt aIndex) const
00080         {
00081         switch (aIndex)
00082                 {
00083                 case 0:
00084                         return iEikEdwin;
00085                 default:
00086                         break;
00087                 }
00088         return NULL;
00089         }
00090 
00091 void CContactStandardMainView::Draw(const TRect& /*aRect*/) const
00092         {
00093         CWindowGc& gc = SystemGc();
00094         gc.Clear();
00095         }
00096 
00097 void CContactStandardMainView::SizeChanged()
00098     {
00099     if (iEikEdwin)
00100                 {
00101                 TRect rect(Rect());
00102                 iEikEdwin->SetExtent(
00103                         TPoint(0, 0),
00104                         TSize(rect.Width(), rect.Height()));
00105                 }
00106     }
00107         
00108 // End of File

Generated by  doxygen 1.6.2