|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // apgdoor.h |
|
15 // |
|
16 |
|
17 #ifndef __APGDOOR_H__ |
|
18 #define __APGDOOR_H__ |
|
19 |
|
20 #include <e32std.h> |
|
21 #include <e32base.h> |
|
22 #include <s32std.h> |
|
23 #include <gdi.h> |
|
24 #include <apparc.h> |
|
25 #include <apadbase.h> |
|
26 |
|
27 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
28 /** |
|
29 @internalAll |
|
30 */ |
|
31 const TUid KUidApaDoorDocStream={0x10003A35}; |
|
32 |
|
33 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
34 // classes referenced |
|
35 class CEmbeddedStore; |
|
36 |
|
37 /** A wrapper for an embedded document that can be displayed in a user interface |
|
38 as an icon or a glass door. |
|
39 |
|
40 @publishedAll |
|
41 @released */ |
|
42 class CApaDoor : public CApaDoorBase |
|
43 { |
|
44 public: |
|
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 |
|
48 |
|
49 IMPORT_C void SetFormatToIconL(); |
|
50 IMPORT_C void SetFormatToGlassL(); |
|
51 IMPORT_C void SetFormatToTemporaryIconL(TBool aEnabled=ETrue); |
|
52 |
|
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; |
|
59 |
|
60 IMPORT_C ~CApaDoor(); |
|
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; |
|
71 private: |
|
72 CApaDoor(RFs& aFs, CApaProcess& aProcess); |
|
73 CApaDoor(RFs& aFs, CApaDocument& aDoc,const TSize& aDefaultIconSizeInTwips); |
|
74 void ConstructL(); |
|
75 |
|
76 void SetIconSizeInTwips(TSize aSize); // for use of factory |
|
77 |
|
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); |
|
85 |
|
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; |
|
91 private: |
|
92 RFs& iFs; |
|
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; |
|
100 private: |
|
101 friend class TApaPictureFactory; |
|
102 }; |
|
103 |
|
104 |
|
105 /** A factory class for instantiating and restoring an application's door. |
|
106 |
|
107 A door factory object is constructed by the UI environment and can be accessed |
|
108 by calling CEikonEnv::PictureFactory(). |
|
109 |
|
110 @publishedAll |
|
111 @released |
|
112 @see CEikonEnv::PictureFactory() |
|
113 @see CApaDoor */ |
|
114 class TApaPictureFactory : public MPictureFactory |
|
115 // Recognizes KUidPictureTypeDoor and creates CApaDoor pictures |
|
116 { |
|
117 public: |
|
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 |
|
122 protected: |
|
123 IMPORT_C TApaPictureFactory(); |
|
124 private: |
|
125 CApaProcess* iApaProcess; |
|
126 TSize iIconSize; |
|
127 TInt iSpare; |
|
128 }; |
|
129 |
|
130 // |
|
131 // inlines |
|
132 // |
|
133 |
|
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; } |
|
138 |
|
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; } |
|
143 |
|
144 #endif // __APGDOOR_H__ |