epoc32/include/mw/apgdoor.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 epoc32/include/apgdoor.h@2fe1408b6811
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __APGDOOR_H__
    17 #define __APGDOOR_H__
    18 
    19 #if !defined(__E32STD_H__)
    20 #include <e32std.h>
    21 #endif
    22 #if !defined(__E32BASE_H__)
    23 #include <e32base.h>
    24 #endif
    25 #if !defined(__S32STD_H__)
    26 #include <s32std.h>
    27 #endif
    28 #if !defined(__GDI_H__)
    29 #include <gdi.h>
    30 #endif
    31 #if !defined(__APPARC_H__)
    32 #include <apparc.h>
    33 #endif
    34 #if !defined(__APADBASE_H__)
    35 #include <apadbase.h>
    36 #endif
    37 
    38 /**
    39 @internalAll
    40 */
    41 #ifdef _UNICODE
    42 #define KUidApaDoorDocStream KUidApaDoorDocStream16
    43 #else
    44 #define KUidApaDoorDocStream KUidApaDoorDocStream8
    45 #endif
    46 
    47 /**
    48 @internalComponent
    49 @deprecated
    50 */
    51 const TUid KUidApaDoorDocStream8={0x10000144};
    52 
    53 /**
    54 @internalComponent
    55 */
    56 const TUid KUidApaDoorDocStream16={0x10003A35};
    57 
    58 // classes defined:
    59 class CApaDoor;
    60 class TApaPictureFactory;
    61 //
    62 // classes referenced:
    63 class CEmbeddedStore;
    64 //
    65 
    66 class CApaDoor : public CApaDoorBase
    67 /** A wrapper for an embedded document that can be displayed in a user interface 
    68 as an icon or a glass door. 
    69 
    70 @publishedAll 
    71 @released */
    72 	{
    73 public:
    74 	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
    75 	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
    76 	IMPORT_C static CApaDoor* NewL(RFs& aFs, const CStreamStore& aStore,TStreamId aStreamId,CApaProcess& aProcess); // restoring constructor called by TApaPictureFactory
    77 	//
    78 	IMPORT_C void SetFormatToIconL();
    79 	IMPORT_C void SetFormatToGlassL();
    80 	IMPORT_C void SetFormatToTemporaryIconL(TBool aEnabled=ETrue);
    81 	//
    82 	IMPORT_C CApaDocument* DocumentL(TBool aCheckPassword=EFalse); // returns a pointer to the doc, restoring it if necessary. Checks password if required.
    83 	inline TDesC* Caption()const;
    84 	IMPORT_C TUid AppUidL()const;
    85 	//
    86 	// persistence methods
    87 	IMPORT_C void RestoreL(const CStreamStore& aStore,TStreamId aHeadStreamId);
    88 	TStreamId StoreL(CStreamStore& aStore) const;
    89 	//
    90 	IMPORT_C ~CApaDoor();
    91 	//
    92 	// from CPicture
    93 	void Draw(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,
    94 						MGraphicsDeviceMap* aMap)const; // draws according to current iPicFormat
    95 	void DetachFromStoreL(TDetach aDegree=EDetachFull); //lint !e1735 Virtual function has default parameter - Must use the same default as declared by CPicture
    96 	void GetOriginalSizeInTwips(TSize& aSize)const;
    97 	void SetScaleFactor(TInt aScaleFactorWidth,TInt aScaleFactorHeight);
    98 	void SetCropInTwips(const TMargins& aMargins);
    99 	TPictureCapability Capability() const;
   100 	void GetCropInTwips(TMargins& aMargins) const;
   101 	TInt ScaleFactorWidth() const;
   102 	TInt ScaleFactorHeight() const;
   103 private:
   104 	CApaDoor(RFs& aFs, CApaProcess& aProcess);
   105 	CApaDoor(RFs& aFs, CApaDocument& aDoc,const TSize& aDefaultIconSizeInTwips);
   106 	void ConstructL();
   107 	//
   108 	void SetIconSizeInTwips(TSize aSize); // for use of factory
   109 	//
   110 	void StoreDocL(CPersistentStore& aStore)const;
   111 	void RestoreDocL(const CPersistentStore& aStore);
   112 	void RestoreDoorStateL(const CStreamStore& aStore,const CStreamDictionary& streamDic);
   113 	static CStreamDictionary* ReadStreamDictionaryLC(const CStreamStore& aStore,TStreamId aStreamId);
   114 	static void CopyStoreL(const CEmbeddedStore& aSourceStore,RWriteStream& aTargetStream);
   115 	void ExternalizeStateStreamL(CStreamStore& aStore,CStreamDictionary& aStreamDict)const;
   116 	void InternalizeStateStreamL(const CStreamStore& aStore,const CStreamDictionary& aStreamDict,TSize aDefaultIconSize);
   117 	//
   118 	// required so CPicture's can be swizzled
   119 	void ExternalizeL(RWriteStream& aStream)const;
   120 	// from CApaDoorBase
   121 	virtual TSize GlassDoorSize()const;
   122 	TUid AppUidFromStreamL() const;
   123 private:
   124 	RFs& iFs;
   125 	HBufC* iAppCaption; // name of the app used to create the embedded object
   126 	CApaProcess* iApaProcess;
   127 	CApaDocument* iApaDoc;
   128 	CPicture* iPicture; // the current view of the door, either iconic or glass
   129 	CEmbeddedStore* iStore; // store containing the doc
   130 	CBufSeg* iStoreHost; // the host for the embedded store, if the door has been detached from its originating store
   131 	__MUTABLE TSize iIconSizeInTwips;
   132 	//
   133 	friend class TApaPictureFactory;
   134 	};
   135 
   136 
   137 class TApaPictureFactory : public MPictureFactory
   138 // Recognizes KUidPictureTypeDoor and creates CApaDoor pictures
   139 /** A factory class for instantiating and restoring an application's door.
   140 
   141 A door factory object is constructed by the UI environment and can be accessed 
   142 by calling CEikonEnv::PictureFactory().
   143 
   144 @publishedAll
   145 @released 
   146 @see CEikonEnv::PictureFactory()
   147 @see CApaDoor */
   148 	{
   149 public:
   150 	IMPORT_C TApaPictureFactory(CApaProcess* aAppProcess);
   151 	inline void SetIconSize(TSize aIconSizeInTwips);
   152 	//
   153 	// from MPictureFactory
   154 	IMPORT_C void NewPictureL(TPictureHeader& aPictureHeader,const CStreamStore& aPictureStore)const; // used to create CApaDoor's during document restore only 
   155 protected:
   156 	IMPORT_C TApaPictureFactory();
   157 	
   158 private:
   159 	CApaProcess* iApaProcess;
   160 	TSize iIconSize;
   161 	TInt iSpare;
   162 	};
   163 
   164 
   165 //
   166 // inlines
   167 //
   168 
   169 inline TDesC* CApaDoor::Caption()const 
   170 	/** Gets the name of the application with which the embedded document is associated.
   171 	
   172 	@return A pointer to a descriptor containing the name of the application. */
   173 	{ return iAppCaption; }
   174 
   175 inline void TApaPictureFactory::SetIconSize(TSize aIconSizeInTwips)
   176 	/** Sets the size of the icon.
   177 	
   178 	@param aIconSizeInTwips The size of the icon, in twips. */
   179 	{ iIconSize = aIconSizeInTwips; }
   180 
   181 #endif