fep/frontendprocessor/test/feps/TFEP4.H
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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 //
       
    15 
       
    16 #if !defined(__TFEP4_H__)
       
    17 #define __TFEP4_H__
       
    18 
       
    19 #if !defined(__E32STD_H__)
       
    20 #include <e32std.h>
       
    21 #endif
       
    22 
       
    23 #if !defined(__E32BASE_H__)
       
    24 #include <e32base.h>
       
    25 #endif
       
    26 
       
    27 #if !defined(__W32STD_H__)
       
    28 #include <w32std.h>
       
    29 #endif
       
    30 
       
    31 #if !defined(__FRMTLAY_H__)
       
    32 #include <frmtlay.h>
       
    33 #endif
       
    34 
       
    35 #if !defined(__COEMAIN_H__)
       
    36 #include <coemain.h>
       
    37 #endif
       
    38 
       
    39 #if !defined(__COECNTRL_H__)
       
    40 #include <coecntrl.h>
       
    41 #endif
       
    42 
       
    43 #if !defined(__FEPBASE_H__)
       
    44 #include <fepbase.h>
       
    45 #endif
       
    46 
       
    47 #if !defined(__FEPITFR_H__)
       
    48 #include <fepitfr.h>
       
    49 #endif
       
    50 
       
    51 #if !defined(__EIKDIALG_H__)
       
    52 #include <techview/eikdialg.h>
       
    53 #endif
       
    54 
       
    55 #include "pytable.h"
       
    56 
       
    57 class TTstTextBackup
       
    58 	{
       
    59 public:
       
    60 	TTstTextBackup(TDes& aText);
       
    61 	void PushOntoCleanupStackL();
       
    62 	void PopOffCleanupStack();
       
    63 private:
       
    64 	static void Cleanup(TAny* aTextBackup);
       
    65 private:
       
    66 	TCleanupItem iCleanupItem;
       
    67 	TDes& iOriginal;
       
    68 	HBufC* iBackup;
       
    69 	};
       
    70 
       
    71 class CTstInsertionPoint : public CBase
       
    72 	{
       
    73 public:
       
    74 	enum
       
    75 		{
       
    76 		EWidth=5,
       
    77 		EHeight=3
       
    78 		};
       
    79 public:
       
    80 	static CTstInsertionPoint* NewL(RWindowBase& aWindow, CCoeEnv& aCoeEnv);
       
    81 	virtual ~CTstInsertionPoint();
       
    82 	void SetPosition(const TPoint& aPosition);
       
    83 	void SetOn(TBool aOn);
       
    84 private:
       
    85 	enum
       
    86 		{
       
    87 		EFlagOn=0x00000001
       
    88 		};
       
    89 private:
       
    90 	CTstInsertionPoint(RWsSession& aWindowServerSession);
       
    91 	void ConstructL(RWindowBase& aWindow, TDisplayMode aDisplayMode);
       
    92 	static CFbsBitmap* CreateBitmapL(TDisplayMode aDisplayMode);
       
    93 	void DoSetOn(TBool aOn);
       
    94 private:
       
    95 	TSpriteMember iSpriteMember;
       
    96 	RWsSprite iSprite;
       
    97 	TPoint iPosition;
       
    98 	TUint iFlags;
       
    99 	};
       
   100 
       
   101 class TTstArrayOfOneCtrlCharacter : private CCoeFep::MModifiedCharacter
       
   102 	{
       
   103 public:
       
   104 	TTstArrayOfOneCtrlCharacter(TUint aCharacter);
       
   105 	TArray<CCoeFep::MModifiedCharacter> ArrayOfModifiedCharacters(); // this function is deliberately non-const so that its client is not tempted to create an anonymous (temporary) TTstArrayOfOneCtrlCharacter object whose lifetime may turn out to be too short
       
   106 private:
       
   107 	static TInt NumberOfModifiedCharacters(const CBase* aThis); // aThis is really a TTstArrayOfOneCtrlCharacter
       
   108 	static const TAny* ModifiedCharacter(const CBase* aThis, TInt aIndex); // aThis is really a TTstArrayOfOneCtrlCharacter
       
   109 	// from CCoeFep::MModifiedCharacter
       
   110 	virtual TUint CharacterCode() const;
       
   111 	virtual TUint ModifierMask() const;
       
   112 	virtual TUint ModifierValues() const;
       
   113 private:
       
   114 	TUint iCharacter;
       
   115 	};
       
   116 
       
   117 class CFont;
       
   118 class TCharFormat;
       
   119 class CTstFep;
       
   120 
       
   121 class CTstControl : public CCoeControl, private MFormCustomDraw, private MFepInlineTextFormatRetriever, private MFepPointerEventHandlerDuringInlineEdit, private CCoeFep::MDeferredFunctionCall
       
   122 	{
       
   123 public:
       
   124 	static CTstControl* NewL(CTstFep& aFep);
       
   125 	virtual ~CTstControl();
       
   126 	void CancelTransaction();
       
   127 	void IsOnHasChangedState();
       
   128 	void OfferPointerEventL(CCoeFep::TEventResponse& aEventResponse, const TPointerEvent& aPointerEvent, const CCoeControl* aWindowOwningControl);
       
   129 	static TInt NumberOfAttributes();
       
   130 	static TUid AttributeAtIndex(TInt aIndex);
       
   131 	void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const;
       
   132 	void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream);
       
   133 	static void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream, TBool aInlineEditingEnabled, TInt aInputMethod);
       
   134 	static void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream, TBool& aInlineEditingEnabled, TInt& aInputMethod);
       
   135 	void HandleGainingForeground();
       
   136 	void HandleLosingForeground();
       
   137 	void HandleChangeInFocus();
       
   138 	void HandleDestructionOfFocusedItem();
       
   139 private:
       
   140 	typedef void (*FChangeFunction)(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter);
       
   141 	enum {EArrowHeadSize=4};
       
   142 //	enum {ENumberOfHexadecimalDigitsPerCharacterCode=2*sizeof(TText)};
       
   143 	enum {ENumberOfHexadecimalDigitsPerCharacterCode=5};
       
   144 	enum
       
   145 		{
       
   146 		EMaximumLengthOfBuffer=25,
       
   147 		EMaximumLengthOfDisplayOfContextInformation=15
       
   148 		};
       
   149 	enum
       
   150 		{
       
   151 		ETstInlineEditingEnabledUid=0x100014a2,
       
   152 		ETstInputMethodUid=0x100014a1
       
   153 		};
       
   154 	enum
       
   155 		{
       
   156 		EInputMethodPlain,
       
   157 		EInputMethodHexadecimalCharacterCode,
       
   158 		EInputMethodPinYin,
       
   159 		// the next one must always be the last value in the enum
       
   160 		EInputMethodOnePastTheLast
       
   161 		};
       
   162 	enum
       
   163 		{
       
   164 		EFlagForeground						=0x00000001,
       
   165 		EFlagWindowIsBeingDragged			=0x00000002,
       
   166 		EFlagInlineEditingEnabled			=0x00000004,
       
   167 		EFlagInsideInlineEditingTransaction	=0x00000008,
       
   168 		EFlagHasNoCompositionWindow			=0x00000010
       
   169 		};
       
   170 	enum
       
   171 		{
       
   172 		EGapLeftOfEachLine			=1,
       
   173 		EGapAboveCompositionLine	=1,
       
   174 		EGapBelowCompositionLine	=CTstInsertionPoint::EHeight+1,
       
   175 		EGapAboveTopStatusLine		=1,
       
   176 		EGapBetweenEachStatusLine	=1,
       
   177 		EGapBelowBottomStatusLine	=1
       
   178 		};
       
   179 	class CStateInformation : public MCoeFepAwareTextEditor_Extension1::CState
       
   180 		{
       
   181 	public:
       
   182 		static CStateInformation* NewLC(TInt aMeaninglessNumber);
       
   183 		virtual ~CStateInformation();
       
   184 		inline void IncrementMeaninglessNumber() {++*iMeaninglessNumber;}
       
   185 		inline TInt MeaninglessNumber() const {return *iMeaninglessNumber;}
       
   186 	private:
       
   187 		CStateInformation();
       
   188 		void ConstructL(TInt aMeaninglessNumber);
       
   189 	private:
       
   190 		TInt* iMeaninglessNumber; // this TInt is not "in-line" as we want to test that CStateInformation's destructor gets called
       
   191 		};
       
   192 private:
       
   193 	CTstControl(CTstFep& aFep);
       
   194 	void ConstructL();
       
   195 	static void SetForeground(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter);
       
   196 	static void SetFocus(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter);
       
   197 	static void SetFlagInlineEditingEnabled(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter);
       
   198 	static void SetInputMethod(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter);
       
   199 	static void SetInputCapabilities(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter);
       
   200 	static void SetFlag(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter, TUint aFlag);
       
   201 	void ChangeSetupAndResetBufferAndDrawNow(FChangeFunction aChangeFunction, TInt aParameter=0);
       
   202 	void InsertCompositionCharacterAndDrawNowL(TUint aCharacterCode);
       
   203 	void SetInlineTextL(MCoeFepAwareTextEditor& aFepAwareTextEditor);
       
   204 	void CancelInlineEdit(MCoeFepAwareTextEditor& aFepAwareTextEditor);
       
   205 	void CommitInlineEditL(MCoeFepAwareTextEditor& aFepAwareTextEditor);
       
   206 	void ResetBuffer();
       
   207 	void SetPositionOfInsertionPointInBuffer(TInt aPositionOfInsertionPointInBuffer);
       
   208 	void SetPositionOfInsertionPointInBuffer(TInt aPositionOfInsertionPointInBuffer, TInt aPositionOfAnchorInBuffer);
       
   209 	TPoint PositionOfInsertionPointOnWindow() const;
       
   210 	TInt PositionInBuffer(TInt aX) const;
       
   211 	TBool IsLegalNonDigitForRealNumber(const TCharUC& aKeyCodeInUpperCase) const;
       
   212 	static void GetFormatAtDocumentPosition(TCharFormat& aFormat, TInt aDocumentPosition, const MCoeFepAwareTextEditor& aFepAwareTextEditor);
       
   213 	static TInt NumberOfCharactersInBuffer(const CBase* aControl); // aControl is really a CTstControl
       
   214 	static const TAny* CharacterInBuffer(const CBase* aControl, TInt aIndex); // aControl is really a CTstControl
       
   215 public:
       
   216 	// from CCoeControl
       
   217 	virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aEventCode);
       
   218 private:
       
   219 	// from CCoeControl
       
   220 	virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   221 	virtual void Draw(const TRect& aRect) const;
       
   222 	// from MFormCustomDraw
       
   223 	virtual void DrawText(const TParam& aParam, const TLineInfo& aLineInfo, const TCharFormat& aFormat, const TDesC& aText, const TPoint& aTextOrigin, TInt aExtraPixels) const;
       
   224 	// from MFepInlineTextFormatRetriever
       
   225 	virtual void GetFormatOfFepInlineText(TCharFormat& aFormat, TInt& aNumberOfCharactersWithSameFormat, TInt aPositionOfCharacter) const;
       
   226 	// from MFepPointerEventHandlerDuringInlineEdit
       
   227 	virtual void HandlePointerEventInInlineTextL(TPointerEvent::TType aType, TUint aModifiers, TInt aPositionInInlineText);
       
   228 	// from CCoeFep::MDeferredFunctionCall
       
   229 	virtual void ExecuteFunctionL();
       
   230 private:
       
   231 	CTstFep& iFep;
       
   232 	TInt iInputMethod;
       
   233 	TUint iFlags;
       
   234 	TUint iCharacterCode; // used by CCoeFep::MDeferredFunctionCall::ExecuteFunctionL, and also independently by CharacterInBuffer
       
   235 	TBuf<EMaximumLengthOfBuffer> iBuffer;
       
   236 	TCursorSelection iSelectedCompositionText;
       
   237 	TCoeInputCapabilities iInputCapabilities;
       
   238 	CFont* iCompositionFont;
       
   239 	CFont* iStatusFont;
       
   240 	CTstInsertionPoint* iInsertionPoint;
       
   241 	TPoint iPositionOnWindowBeingDragged;
       
   242 private:
       
   243 	CPinyinSelector iPinYinSelector;
       
   244 	};
       
   245 
       
   246 class CTstFep : public CCoeFep
       
   247 	{
       
   248 public:
       
   249 	CTstFep(CCoeEnv& aConeEnvironment);
       
   250 	void ConstructL(const CCoeFepParameters& aFepParameters);
       
   251 	virtual ~CTstFep();
       
   252 	inline void MakeDeferredFunctionCall(MDeferredFunctionCall& aDeferredFunctionCall) {CCoeFep::MakeDeferredFunctionCall(aDeferredFunctionCall);}
       
   253 	inline void SimulateKeyEventsL(const TArray<TUint>& aArrayOfCharacters) {CCoeFep::SimulateKeyEventsL(aArrayOfCharacters);}
       
   254 	inline void SimulateKeyEventsL(const TArray<MModifiedCharacter>& aArrayOfModifiedCharacters) {CCoeFep::SimulateKeyEventsL(aArrayOfModifiedCharacters);}
       
   255 	inline void WriteAttributeDataAndBroadcastL(TUid aAttributeUid) {CCoeFep::WriteAttributeDataAndBroadcastL(aAttributeUid);}
       
   256 	inline TBool IsOn() const {return CCoeFep::IsOn();}
       
   257 private:
       
   258 	// from CCoeFep
       
   259 	virtual void CancelTransaction();
       
   260 	virtual void IsOnHasChangedState();
       
   261 	virtual void OfferKeyEventL(TEventResponse& aEventResponse, const TKeyEvent& aKeyEvent, TEventCode aEventCode);
       
   262 	virtual void OfferPointerEventL(TEventResponse& aEventResponse, const TPointerEvent& aPointerEvent, const CCoeControl* aWindowOwningControl);
       
   263 	virtual void OfferPointerBufferReadyEventL(TEventResponse& aEventResponse, const CCoeControl* aWindowOwningControl);
       
   264 	// from MFepAttributeStorer (via CCoeFep)
       
   265 	virtual TInt NumberOfAttributes() const;
       
   266 	virtual TUid AttributeAtIndex(TInt aIndex) const;
       
   267 	virtual void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const;
       
   268 	virtual void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream);
       
   269 	// from MCoeForegroundObserver (via CCoeFep)
       
   270 	virtual void HandleGainingForeground();
       
   271 	virtual void HandleLosingForeground();
       
   272 	// from MCoeFocusObserver (via CCoeFep)
       
   273 	virtual void HandleChangeInFocus();
       
   274 	virtual void HandleDestructionOfFocusedItem();
       
   275 private:
       
   276 	CTstControl* iControl;
       
   277 	};
       
   278 
       
   279 class TTstResourceFileId : public TCleanupItem
       
   280 	{
       
   281 public:
       
   282 	TTstResourceFileId(CCoeEnv& aConeEnvironment, TInt aResourceFileId);
       
   283 private:
       
   284 	static void UnloadResourceFile(TAny* aThis);
       
   285 private:
       
   286 	CCoeEnv& iConeEnvironment;
       
   287 	TInt iResourceFileId;
       
   288 	};
       
   289 
       
   290 class CTstSettingsDialog : public CEikDialog, private MFepAttributeStorer
       
   291 	{
       
   292 public:
       
   293 	CTstSettingsDialog();
       
   294 private:
       
   295 	// from CEikDialog
       
   296 	virtual TBool OkToExitL(TInt aButtonId);
       
   297 	virtual void PreLayoutDynInitL();
       
   298 	// from MFepAttributeStorer
       
   299 	virtual TInt NumberOfAttributes() const;
       
   300 	virtual TUid AttributeAtIndex(TInt aIndex) const;
       
   301 	virtual void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const;
       
   302 	virtual void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream);
       
   303 private:
       
   304 	TBool iInlineEditingEnabled;
       
   305 	TInt iInputMethod;
       
   306 	TUid iUid;
       
   307 	};
       
   308 	
       
   309 
       
   310 
       
   311 #endif
       
   312