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 00017 #ifndef __CommonGraphicsControlFramework_H 00018 #define __CommonGraphicsControlFramework_H 00019 00020 #include <coecntrl.h> 00021 #include <s32file.h> 00022 00023 // 00024 // class MGraphicsExampleObserver 00025 // 00026 00027 class MGraphicsExampleObserver 00028 { 00029 public: 00030 virtual void NotifyGraphicExampleFinished()=0; 00031 virtual void NotifyStatus(const TDesC& aMessage)=0; 00032 }; 00033 00034 // 00035 // class CGraphicExampleControl 00036 // 00037 00038 /* 00039 Usage 00040 00041 Use this class as a base class for examples for the 00042 graphics layer. It uses CONE's facilities to provide 00043 an initailized graphics environment. 00044 00045 It creates a 600x200 window in which you can do your 00046 drawing. 00047 00048 it supports multiple phases, so you can do different drawings 00049 from one phase to another. Tap the spacebar or click the 00050 mouse (anywhere) to advance a phase. 00051 00052 Quit the program with CTRL-Q, or by advancing beyond the last 00053 phase. 00054 00055 Writing derived classes 00056 00057 A minimal derived class should have a Draw() function 00058 which puts a drawing onto the screen. 00059 00060 If you are using multiplephases, code a constructor which 00061 calls SetMaxPhases() specifying the number of phases. Have 00062 Draw() honour the phase number, available using Phase(). 00063 */ 00064 00065 #pragma warning(disable : 4100) 00066 // disable "parameter not used" warning on HandleKey() 00067 00068 class CGraphicExampleControl : public CCoeControl 00069 { 00070 public: 00071 // construct/destruct 00072 void ConstructL(const TRect& aRect, MGraphicsExampleObserver* aGraphObserver, const CCoeControl& aParent); 00073 // second-phase construction 00074 // when all initialized, calls GraphicTestEnvironmentComplete() 00075 ~CGraphicExampleControl(); 00076 // allow access by container 00077 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); 00078 // intercepts ctrl-Q and space; offers other keys to derived classes 00079 protected: 00080 // derived classes must provide these 00081 virtual void UpdateModelL() =0; // empty update model function 00082 virtual void Draw(const TRect& /* aRect */) const {}; // empty draw function 00083 // use Phase() in Draw() to tell what phase we're in 00084 TInt Phase() const { return iPhase; }; // get phase number 00085 void SetMaxPhases(TInt aMaxPhases) { iMaxPhases=aMaxPhases; }; 00086 // use this from derived-class constructor to set number of phases 00087 CFont* iMessageFont; // font for messages 00088 private: 00089 // functions provided for CCoeControl protocol 00090 void HandlePointerEventL(const TPointerEvent& aPointerEvent); 00091 // advances phase on pointer-down 00092 void Quit(); // does termination 00093 void NextPhaseL(); // advances phase: quits if all phases done 00094 // phase control for graphics examples 00095 TInt iPhase; // phase number 00096 TInt iMaxPhases; // maximum phases 00097 protected: 00098 MGraphicsExampleObserver* iGraphObserver; 00099 }; 00100 00101 #endif