examples/Graphics/Bitmaps/BitmapsGraphicsControl.cpp

00001 // Copyright (c) 2000-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 //
00015 
00016 #include "BitmapsGraphicsControl.h"
00017 
00018 #include <coemain.h>
00019 #include <coeaui.h>
00020 
00021 _LIT(KtxtSwiss,"Swiss");
00022 
00023 void CGraphicExampleControl::ConstructL(const TRect& aRect, MGraphicsExampleObserver* aGraphObserver, const CCoeControl& aParent)
00024         {
00025         // remember the graphics observer
00026         iGraphObserver=aGraphObserver;
00027         // create window
00028         CreateWindowL(&aParent);
00029         // construct font for messages
00030     TFontSpec spec(KtxtSwiss,213);
00031     iMessageFont=iCoeEnv->CreateScreenFontL(spec);
00032         // set rectangle to prescription
00033         SetRect(aRect);
00034         // go for it
00035         ActivateL();
00036         UpdateModelL(); // phase 0
00037         }
00038 
00039 CGraphicExampleControl::~CGraphicExampleControl()
00040         {
00041         iCoeEnv->ReleaseScreenFont(iMessageFont);
00042         }
00043 
00044 void CGraphicExampleControl::Quit()
00045         {
00046         iGraphObserver->NotifyGraphicExampleFinished();
00047         }
00048 
00049 void CGraphicExampleControl::NextPhaseL()
00050         {
00051         if (++iPhase >= iMaxPhases)
00052                 Quit();
00053         else
00054                 {
00055                 UpdateModelL();
00056                 DrawNow();
00057                 }
00058         }
00059 
00060 void CGraphicExampleControl::HandlePointerEventL(const TPointerEvent& aPointerEvent)
00061         {
00062         if (aPointerEvent.iType==TPointerEvent::EButton1Down) NextPhaseL();
00063         }
00064 
00065 TKeyResponse CGraphicExampleControl::OfferKeyEventL(
00066                         const TKeyEvent& aKeyEvent,TEventCode aType
00067                         )
00068         {
00069         if (aType!=EEventKey) return EKeyWasNotConsumed;
00070         TInt code=aKeyEvent.iCode;
00071         switch (code)
00072                 {
00073                 case ' ':
00074                         NextPhaseL();
00075                         break;
00076                 default:
00077                         return EKeyWasNotConsumed;
00078                 }
00079         return EKeyWasConsumed;
00080         }
00081 

Generated by  doxygen 1.6.2