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 "GraphicsControl.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, 00024 const CCoeControl& aParent) 00025 { 00026 // remember the graphics observer 00027 iGraphObserver=aGraphObserver; 00028 // create window 00029 CreateWindowL(&aParent); 00030 // construct font for messages 00031 TFontSpec spec(KtxtSwiss,213); 00032 iMessageFont=iCoeEnv->CreateScreenFontL(spec); 00033 // set rectangle to prescription 00034 SetRect(aRect); 00035 // go for it 00036 ActivateL(); 00037 UpdateModelL(); // phase 0 00038 } 00039 00040 CGraphicExampleControl::~CGraphicExampleControl() 00041 { 00042 iCoeEnv->ReleaseScreenFont(iMessageFont); 00043 } 00044 00045 void CGraphicExampleControl::Quit() 00046 { 00047 iGraphObserver->NotifyGraphicExampleFinished(); 00048 } 00049 00050 void CGraphicExampleControl::NextPhaseL() 00051 { 00052 if (++iPhase >= iMaxPhases) 00053 Quit(); 00054 else 00055 { 00056 UpdateModelL(); 00057 DrawNow(); 00058 } 00059 } 00060 00061 void CGraphicExampleControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) 00062 { 00063 if (aPointerEvent.iType==TPointerEvent::EButton1Down) NextPhaseL(); 00064 } 00065 00066 TKeyResponse CGraphicExampleControl::OfferKeyEventL( 00067 const TKeyEvent& aKeyEvent,TEventCode aType 00068 ) 00069 { 00070 if (aType!=EEventKey) return EKeyWasNotConsumed; 00071 TInt code=aKeyEvent.iCode; 00072 switch (code) 00073 { 00074 case ' ': 00075 NextPhaseL(); 00076 break; 00077 default: 00078 return EKeyWasNotConsumed; 00079 } 00080 return EKeyWasConsumed; 00081 } 00082
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.