1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
27 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
31 const TUid KUidApaDoorDocStream={0x10003A35};
33 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS
37 /** A wrapper for an embedded document that can be displayed in a user interface
38 as an icon or a glass door.
42 class CApaDoor : public CApaDoorBase
45 IMPORT_C static CApaDoor* NewLC(RFs& aFs, CApaDocument& aDoc,const TSize& aDefaultIconSizeInTwips); // call to create a new door in iconic format - restoration is achieved with TApaPictureFactory
46 IMPORT_C static CApaDoor* NewL(RFs& aFs, CApaDocument& aDoc,const TSize& aDefaultIconSizeInTwips); // call to create a new door in iconic format - restoration is achieved with TApaPictureFactory
47 IMPORT_C static CApaDoor* NewL(RFs& aFs, const CStreamStore& aStore,TStreamId aStreamId,CApaProcess& aProcess); // restoring constructor called by TApaPictureFactory
49 IMPORT_C void SetFormatToIconL();
50 IMPORT_C void SetFormatToGlassL();
51 IMPORT_C void SetFormatToTemporaryIconL(TBool aEnabled=ETrue);
53 IMPORT_C CApaDocument* DocumentL(TBool aCheckPassword=EFalse); // returns a pointer to the doc, restoring it if necessary. Checks password if required.
54 inline TDesC* Caption()const;
55 IMPORT_C TUid AppUidL()const;
56 // persistence methods
57 IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aHeadStreamId);
58 TStreamId StoreL(CStreamStore& aStore) const;
61 public: // from CPicture
62 void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect, MGraphicsDeviceMap* aMap)const; // draws according to current iPicFormat
63 void DetachFromStoreL(TDetach aDegree=EDetachFull); //lint !e1735 Virtual function has default parameter - Must use the same default as declared by CPicture
64 void GetOriginalSizeInTwips(TSize& aSize)const;
65 void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight);
66 void SetCropInTwips(const TMargins& aMargins);
67 TPictureCapability Capability() const;
68 void GetCropInTwips(TMargins& aMargins) const;
69 TInt ScaleFactorWidth() const;
70 TInt ScaleFactorHeight() const;
72 CApaDoor(RFs& aFs, CApaProcess& aProcess);
73 CApaDoor(RFs& aFs, CApaDocument& aDoc,const TSize& aDefaultIconSizeInTwips);
76 void SetIconSizeInTwips(TSize aSize); // for use of factory
78 void StoreDocL(CPersistentStore& aStore)const;
79 void RestoreDocL(const CPersistentStore& aStore);
80 void RestoreDoorStateL(const CStreamStore& aStore,const CStreamDictionary& streamDic);
81 static CStreamDictionary* ReadStreamDictionaryLC(const CStreamStore& aStore,TStreamId aStreamId);
82 static void CopyStoreL(const CEmbeddedStore& aSourceStore,RWriteStream& aTargetStream);
83 void ExternalizeStateStreamL(CStreamStore& aStore,CStreamDictionary& aStreamDict)const;
84 void InternalizeStateStreamL(const CStreamStore& aStore,const CStreamDictionary& aStreamDict,TSize aDefaultIconSize);
86 // required so CPicture's can be swizzled
87 void ExternalizeL(RWriteStream& aStream)const;
88 private: // from CApaDoorBase
89 TSize GlassDoorSize()const;
90 TUid AppUidFromStreamL() const;
93 HBufC* iAppCaption; // name of the app used to create the embedded object
94 CApaProcess* iApaProcess;
95 CApaDocument* iApaDoc;
96 CPicture* iPicture; // the current view of the door, either iconic or glass
97 CEmbeddedStore* iStore; // store containing the doc
98 CBufSeg* iStoreHost; // the host for the embedded store, if the door has been detached from its originating store
99 mutable TSize iIconSizeInTwips;
101 friend class TApaPictureFactory;
105 /** A factory class for instantiating and restoring an application's door.
107 A door factory object is constructed by the UI environment and can be accessed
108 by calling CEikonEnv::PictureFactory().
112 @see CEikonEnv::PictureFactory()
114 class TApaPictureFactory : public MPictureFactory
115 // Recognizes KUidPictureTypeDoor and creates CApaDoor pictures
118 IMPORT_C TApaPictureFactory(CApaProcess* aAppProcess);
119 inline void SetIconSize(TSize aIconSizeInTwips);
120 public: // from MPictureFactory
121 IMPORT_C void NewPictureL(TPictureHeader& aPictureHeader,const CStreamStore& aPictureStore)const; // used to create CApaDoor's during document restore only
123 IMPORT_C TApaPictureFactory();
125 CApaProcess* iApaProcess;
134 /** Gets the name of the application with which the embedded document is associated.
135 @return A pointer to a descriptor containing the name of the application. */
136 inline TDesC* CApaDoor::Caption()const
137 { return iAppCaption; }
139 /** Sets the size of the icon.
140 @param aIconSizeInTwips The size of the icon, in twips. */
141 inline void TApaPictureFactory::SetIconSize(TSize aIconSizeInTwips)
142 { iIconSize = aIconSizeInTwips; }
144 #endif // __APGDOOR_H__