examples/Multimedia/AudioClientEx/CMediaClientView.cpp

00001 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
00002 // All rights reserved.
00003 // This component and the accompanying materials are made available
00004 // under the terms of "Eclipse Public License v1.0"
00005 // which accompanies this distribution, and is available
00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
00007 //
00008 // Initial Contributors:
00009 // Nokia Corporation - initial contribution.
00010 //
00011 // Contributors:
00012 //
00013 // Description:
00014 // MediaClientView.cpp
00015 //
00016 
00017 // The view is very simple: it simply writes a string
00018 // describing the current state of the application
00019 #include <audioclientex.rsg>
00020 #include "CMediaClientView.h"
00021 #include "CMediaClientDocument.h"
00022 #include "CMediaClientEngine.h"
00023 
00024 #include <eikenv.h>
00025 
00026 
00027 CMediaClientView* CMediaClientView::NewL(const TRect& aRect, CMediaClientEngine& aEngine)
00028     {
00029     CMediaClientView* new_object = new (ELeave) CMediaClientView(aEngine);
00030     CleanupStack::PushL(new_object);
00031     new_object->ConstructL(aRect);
00032     CleanupStack::Pop();
00033 
00034     return new_object;
00035     }
00036 
00037 // Set up
00038 void CMediaClientView::ConstructL(const TRect& aRect) 
00039     {    
00040     CreateWindowL();
00041     Window().SetShadowDisabled(ETrue);
00042     SetRect(aRect);
00043 
00044     ActivateL();
00045     }
00046 
00047 CMediaClientView::CMediaClientView(CMediaClientEngine& aEngine)
00048 :iEngine(aEngine)
00049         {
00050         }
00051 
00052 CMediaClientView::~CMediaClientView()
00053     {
00054     }
00055 
00056 void CMediaClientView::SetDescription(const TDesC& aDescription)
00057         {
00058         iDescription = aDescription;
00059         }
00060 
00061 // Update the view
00062 void CMediaClientView::Draw(const TRect& /*aRect*/) const
00063     {
00064     CWindowGc& gc = SystemGc();
00065 
00066     TInt boxHeight=Rect().Height(); // get height of text box
00067     const CFont* font=iEikonEnv->TitleFont();
00068     TInt textHeight(font->HeightInPixels()); // system font height
00069     TInt offset=(textHeight+boxHeight)/2; // 1/2 font ht below halfway down box
00070     TInt margin=0; // margin is zero
00071     
00072     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);    
00073     gc.SetBrushColor(KRgbWhite);
00074     gc.SetPenColor(KRgbBlack);    
00075     gc.UseFont(font);
00076 
00077         gc.DrawRect(Rect());
00078     gc.DrawText(iDescription, Rect(), offset, CGraphicsContext::ECenter, margin);
00079     }
00080 

Generated on Thu Jan 21 10:32:59 2010 for TB10.1 Example Applications by  doxygen 1.5.3