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 #ifndef __EmbeddingGraphicsControl_H 00017 #define __EmbeddingGraphicsControl_H 00018 00019 #include <coecntrl.h> 00020 #include <s32file.h> 00021 00022 // For Picture example 00023 00024 // CSmileyPicture 00025 00026 00027 #include "CommonGraphicsControlFramework.h" 00028 00029 class CSmileyPicture : public CPicture 00030 { 00031 public: 00032 enum TMood { EHappy, ENeutral, ESad }; // various moods 00033 enum TSizeSpec { ELarge, EMedium, ESmall }; // sizes 00034 00035 // creating 00036 CSmileyPicture(); 00037 static CSmileyPicture* NewL(TMood aMood, TSizeSpec aSizeSpec); // from scratch 00038 static CSmileyPicture* NewL(const CStreamStore& aStore, TStreamId aStreamId); // from stream 00039 TStreamId StoreL(CStreamStore& aStore) const; 00040 void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, 00041 MGraphicsDeviceMap* aMap)const; 00042 00043 void SetMood(TMood aMood); // set mood 00044 TMood Mood(); // get mood 00045 void SetSize(TSizeSpec aSizeSpec); // set size 00046 TSizeSpec Size(); // get size 00047 TInt SpecToFactor() const; 00048 00049 void GetOriginalSizeInTwips(TSize& aSize) const; 00050 00051 // only needed for cropping and scaling 00052 void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight); 00053 void SetCropInTwips(const TMargins& aMargins); 00054 TPictureCapability Capability() const; 00055 void GetCropInTwips(TMargins& aMargins) const; 00056 TInt ScaleFactorWidth() const; 00057 TInt ScaleFactorHeight() const; 00058 private: 00059 // streaming 00060 void ExternalizeL(RWriteStream& aStream) const; // externalize state 00061 void InternalizeL(RReadStream& aStream); // internalize state 00062 private: 00063 // member data - size and details of whether happy or sad 00064 TMood iMood; 00065 TSizeSpec iSizeSpec; 00066 }; 00067 00068 // sundry derived classes 00069 00070 class CPictureControl : public CGraphicExampleControl 00071 { 00072 public: 00073 CPictureControl(); 00074 ~CPictureControl() { delete(iPicture); }; 00075 void UpdateModelL(); 00076 void Draw(const TRect& aRect) const; 00077 private: 00078 enum TDocStatus { EFalse, EHeader, EPicture }; 00079 TStreamId StoreHeaderL(CStreamStore& aStore) const; 00080 void StoreHeaderComponentsL(CStoreMap& aMap,CStreamStore& aStore) const; 00081 void RestoreHeaderL(CStreamStore& aStore, TStreamId aId); 00082 00083 TZoomFactor testZf; 00084 MGraphicsDeviceMap* testMap; 00085 00086 TDocStatus iValidDocument; // if false, then Draw() draws gray screen 00087 CSmileyPicture* iPicture; // if there, then draw 00088 TPictureHeader iHeader; // if no iPicture, draw outline to specified size 00089 TPoint iOffset; // offset of picture from top-left 00090 CFileStore* iStore; // stream store for persistence 00091 TStreamId iHeaderId; // root stream of store 00092 }; 00093 00094 00095 #endif
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.