appfw/apparchitecture/tef/TSTAPP.H
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2007-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21 
       
    22 #ifndef __TSTAPP_H__
       
    23 #define __TSTAPP_H__
       
    24 
       
    25 #if !defined(__APPARC_H__)
       
    26 #include <apparc.h>
       
    27 #endif
       
    28 
       
    29 #include <eikapp.h>
       
    30 #include <eikdoc.h>
       
    31 #include <apgdoor.h>
       
    32 #include <eikappui.h>
       
    33 
       
    34 // classes defined:
       
    35 class CTestApp;
       
    36 class CTestAppDoc;
       
    37 //
       
    38 
       
    39 #define KTestAppDefaultFileName _L("TestApp.doc")
       
    40 const TInt KTestAppUidValue=10;
       
    41 const TUid KUidTestApp={KTestAppUidValue};
       
    42 const TUid KUidTestAppHeadStream={200};
       
    43 const TInt KNarrowRelUidValue=268435578;
       
    44 const TUid KUidNarrowRel={KNarrowRelUidValue}; // so it'll run under arm...
       
    45 #define KTestAppUidType TUidType(KUidNarrowRel,KUidApp,KUidTestApp)
       
    46 
       
    47 
       
    48 class CTestApp : public CEikApplication
       
    49 	{
       
    50 public:
       
    51 	static CTestApp* NewL(); // the gated function
       
    52 	// from CApaApplication
       
    53 	void PreDocConstructL();
       
    54 	CEikDocument* CreateDocumentL();
       
    55 	TDesC& Caption(); // return the app title in current system language
       
    56 	TUid AppDllUid()const;
       
    57 	
       
    58 	CDictionaryStore* OpenIniFileLC(RFs& aFs)const;
       
    59 	void Capability(TDes8& aInfo)const;
       
    60 	~CTestApp();
       
    61 
       
    62 private:
       
    63 	CTestApp();
       
    64 	void ConstructL();
       
    65 	
       
    66 private:
       
    67 	TBuf<8> iCaption;
       
    68 	RFs iFs;
       
    69 	};
       
    70 
       
    71 class CBasicAppUi : public CEikAppUi
       
    72 	{
       
    73 public:
       
    74 	inline CBasicAppUi() {}
       
    75 private:
       
    76 	virtual void ConstructL();
       
    77 	};
       
    78 
       
    79 class CTestAppDoc : public CEikDocument, public MApaEmbeddedDocObserver
       
    80 	{
       
    81 public:
       
    82 	static CTestAppDoc* NewL(CEikApplication& aApp);
       
    83 	~CTestAppDoc();
       
    84 
       
    85 	inline void EmbedNewDocL(const TApaApplicationFactory& aTestFac); // exported so I can call it from testcode
       
    86 	inline void EditEmbeddedDocL(TInt aDocNum) {EmbeddedDoor(aDocNum)->DocumentL()->EditL(this);}
       
    87 	inline CApaDoor* EmbeddedDoor(TInt aDocNum)const {return (CApaDoor*)((*iEmbedList)[aDocNum].iPicture.AsPtr());}
       
    88 	virtual CEikAppUi* CreateAppUiL();
       
    89 	
       
    90 // from MApaEmbeddedDocObserver
       
    91 	void NotifyExit(MApaEmbeddedDocObserver::TExitMode aMode);
       
    92 // from CApaDocument
       
    93 	void NewDocumentL(); 
       
    94 	CFileStore* CreateFileStoreLC(RFs& aFs,const TDesC& aFileName);
       
    95 	void SaveL();
       
    96 	//
       
    97 	void PrintL(const CStreamStore& aSourceStore);
       
    98 	void EditL(MApaEmbeddedDocObserver* aContainer,TBool aReadOnly); 
       
    99 	TBool IsEmpty()const; // return ETrue if the document is empty
       
   100 	TBool HasChanged()const;
       
   101 	//
       
   102 	// storage functions
       
   103 	void StoreL(CStreamStore& aStore,CStreamDictionary& aStreamDic)const;
       
   104 	void RestoreL(const CStreamStore& aStore,const CStreamDictionary& aStreamDic);
       
   105 	void DetachFromStoreL(CPicture::TDetach aDegree);
       
   106 
       
   107 protected:
       
   108 	CTestAppDoc(CEikApplication& aApp);
       
   109 	void ConstructL();
       
   110 
       
   111 	void InternalizeL(RReadStream& aStream);
       
   112 	void ExternalizeL(RWriteStream& aStream)const;
       
   113 	void StoreComponentsL(CStreamStore& aStore,CStoreMap& aMap)const;
       
   114 	void RestoreComponentsL(const CStreamStore& aStore);
       
   115 
       
   116 	// utility functions
       
   117 public:
       
   118 	TInt iValue; // the "contents" of this test document
       
   119 	CArrayFixFlat<TPictureHeader>* iEmbedList;
       
   120 	CStreamStore* iStore;
       
   121 	TBool iHasChanged;
       
   122 	};
       
   123 
       
   124 inline void CTestAppDoc::EmbedNewDocL(const TApaApplicationFactory& aTestFac)
       
   125 	{
       
   126 	TPictureHeader header;
       
   127 	header.iPictureType = KUidPictureTypeDoor;
       
   128 
       
   129 	CApaDocument* doc=Process()->AddNewDocumentL(aTestFac);
       
   130 
       
   131 	RFs& fs=Process()->FsSession();
       
   132 	header.iPicture = CApaDoor::NewLC(fs,*doc,TSize(500,500));
       
   133 
       
   134 	iEmbedList->AppendL(header);
       
   135 	CleanupStack::Pop(); // iPicture
       
   136 	}
       
   137 
       
   138 
       
   139 #endif
       
   140