examples/Multimedia/CameraExample/Camera_AppView.cpp

Go to the documentation of this file.
00001 // Copyright (c) 2007-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 // This provides functions to draw the view and control.
00015 //
00016 
00017 
00018 
00022 #include "CameraExample.h"
00023 
00024 CCameraAppView::CCameraAppView()
00025         {
00026         }
00027 CCameraAppView* CCameraAppView::NewL(const TRect& aRect)
00028         {
00029         CCameraAppView* self = new(ELeave) CCameraAppView();
00030         CleanupStack::PushL(self);
00031         self->ConstructL(aRect);
00032         CleanupStack::Pop();
00033         return self;
00034         }
00035 
00036 CCameraAppView::~CCameraAppView()
00037         {
00038         delete iCameraText;
00039         }
00040 
00044 void CCameraAppView::ConstructL( const TRect& aRect )
00045     {
00046     
00047         // Fetch the text from the resource file.
00048         iCameraText= iEikonEnv->AllocReadResourceL( R_EXAMPLE_TEXT_BASICCAMERA );
00049         
00050         // The control is window-owning.
00051         CreateWindowL();
00052    
00053         // Extent of the control.
00054         SetRect(aRect);
00055 
00056         // The control is ready to draw, so notify the UI framework.
00057         ActivateL();
00058         }
00059 
00063 void CCameraAppView::DrawImage(CFbsBitmap* aImage) const
00064         {
00065         CWindowGc& gc = SystemGc();
00066         // Displays the window and enables it to receive events.
00067         gc.Activate(Window());
00068         TRect drawRect=Rect();
00069         TPoint pos;
00070         pos.iX = (3 * drawRect.iBr.iX / 4) - (aImage->SizeInPixels().iWidth / 2);
00071         pos.iY = (drawRect.iBr.iY - aImage->SizeInPixels().iWidth) / 2;
00072         // Perform a bitmap block transfer.
00073         gc.BitBlt(pos,aImage);
00074         TRect border(pos,aImage->SizeInPixels());
00075         // Grow the rectangle by 1 pixel left, right, top and botttom.
00076         border.Grow(1,1);
00077         // Draw and fill the rectangle.
00078         gc.DrawRect(border);
00079         gc.Deactivate();
00080         iCoeEnv->WsSession().Flush();
00081         }
00082  
00086 void CCameraAppView::Draw(const TRect& /*aRect*/) const
00087         {
00088         // Window graphics context
00089         CWindowGc& gc = SystemGc();
00090         
00091         // Area in which we shall draw
00092         TRect drawRect = Rect();
00093 
00094         // Font used for drawing text
00095         const CFont*  fontUsed;
00096 
00097         gc.Clear();
00098         
00099         // Use the title font supplied by the UI
00100         fontUsed = iEikonEnv->TitleFont();
00101         gc.UseFont( fontUsed );
00102 
00103         // Draw the text in the rectangle       
00104         gc.DrawText( *iCameraText,drawRect,60 + fontUsed->HeightInPixels(),CGraphicsContext::ECenter, 0 );
00105         
00106         // Discard the font.
00107         gc.DiscardFont();
00108         }
00109 
00113 TPoint CCameraAppView::DrawBorders(const TSize& aSize) const
00114         {
00115         CWindowGc& gc = SystemGc();
00116         // Displays the window and enables it to receive events.
00117         gc.Activate(Window());
00118         TRect drawRect(Rect());
00119         TPoint pos;
00120         pos.iX = (drawRect.iBr.iX / 4) - (aSize.iWidth / 2);
00121         pos.iY = (drawRect.iBr.iY - aSize.iWidth) / 2;
00122         TRect border(pos,aSize);
00123         // Grow the rectangle by 1 pixel left, right, top and botttom.
00124         border.Grow(1,1);
00125         gc.SetPenColor(KRgbBlack);
00126         gc.DrawRect(border);
00127         gc.Deactivate();
00128         iCoeEnv->WsSession().Flush();
00129         return pos;
00130         }

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