|
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(__TFEP3_H__) |
|
17 #define __TFEP3_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 class TTstTextBackup |
|
56 { |
|
57 public: |
|
58 TTstTextBackup(TDes& aText); |
|
59 void PushOntoCleanupStackL(); |
|
60 void PopOffCleanupStack(); |
|
61 private: |
|
62 static void Cleanup(TAny* aTextBackup); |
|
63 private: |
|
64 TCleanupItem iCleanupItem; |
|
65 TDes& iOriginal; |
|
66 HBufC* iBackup; |
|
67 }; |
|
68 |
|
69 class CTstInsertionPoint : public CBase |
|
70 { |
|
71 public: |
|
72 enum |
|
73 { |
|
74 EWidth=5, |
|
75 EHeight=3 |
|
76 }; |
|
77 public: |
|
78 static CTstInsertionPoint* NewL(RWindowBase& aWindow, CCoeEnv& aCoeEnv); |
|
79 virtual ~CTstInsertionPoint(); |
|
80 void SetPosition(const TPoint& aPosition); |
|
81 void SetOn(TBool aOn); |
|
82 private: |
|
83 enum |
|
84 { |
|
85 EFlagOn=0x00000001 |
|
86 }; |
|
87 private: |
|
88 CTstInsertionPoint(RWsSession& aWindowServerSession); |
|
89 void ConstructL(RWindowBase& aWindow, TDisplayMode aDisplayMode); |
|
90 static CFbsBitmap* CreateBitmapL(TDisplayMode aDisplayMode); |
|
91 void DoSetOn(TBool aOn); |
|
92 private: |
|
93 TSpriteMember iSpriteMember; |
|
94 RWsSprite iSprite; |
|
95 TPoint iPosition; |
|
96 TUint iFlags; |
|
97 }; |
|
98 |
|
99 class CFont; |
|
100 class TCharFormat; |
|
101 class CTstFep; |
|
102 |
|
103 class CTstControl : public CCoeControl, private MFormCustomDraw, private MFepInlineTextFormatRetriever, private MFepPointerEventHandlerDuringInlineEdit, private CCoeFep::MDeferredFunctionCall |
|
104 { |
|
105 |
|
106 |
|
107 public: |
|
108 static CTstControl* NewL(CTstFep& aFep); |
|
109 virtual ~CTstControl(); |
|
110 void CancelTransaction(); |
|
111 void IsOnHasChangedState(); |
|
112 void OfferPointerEventL(CCoeFep::TEventResponse& aEventResponse, const TPointerEvent& aPointerEvent, const CCoeControl* aWindowOwningControl); |
|
113 static TInt NumberOfAttributes(); |
|
114 static TUid AttributeAtIndex(TInt aIndex); |
|
115 void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const; |
|
116 void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream); |
|
117 static void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream, TBool aInlineEditingEnabled, TInt aInputMethod); |
|
118 static void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream, TBool& aInlineEditingEnabled, TInt& aInputMethod); |
|
119 void HandleGainingForeground(); |
|
120 void HandleLosingForeground(); |
|
121 void HandleChangeInFocus(); |
|
122 void HandleDestructionOfFocusedItem(); |
|
123 |
|
124 |
|
125 // CMoveCursorTimer - moves the cursor in Fep in NumberKeyPadMode |
|
126 class CMoveCursorTimer: public CTimer |
|
127 { |
|
128 public: |
|
129 ~CMoveCursorTimer(); |
|
130 static CMoveCursorTimer* NewL(CTstControl& aControl); |
|
131 void ConstructL(); |
|
132 |
|
133 void RunL(); |
|
134 void StartTimer(); |
|
135 |
|
136 private: |
|
137 CMoveCursorTimer(CTstControl& aControl); |
|
138 CTstControl& iControl; |
|
139 }; |
|
140 |
|
141 private: |
|
142 typedef void (*FChangeFunction)(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
143 enum {EArrowHeadSize=4}; |
|
144 enum {ENumberOfHexadecimalDigitsPerCharacterCode=2*sizeof(TText)}; |
|
145 enum |
|
146 { |
|
147 EMaximumLengthOfBuffer=26, |
|
148 EMaximumLengthOfDisplayOfContextInformation=15 |
|
149 }; |
|
150 enum |
|
151 { |
|
152 ETstInlineEditingEnabledUid=0x1000677C, |
|
153 ETstInputMethodUid=0x1000677B |
|
154 }; |
|
155 enum |
|
156 { |
|
157 EInputMethodPlain, |
|
158 EInputMethodHexadecimalCharacterCode, |
|
159 EInputMethodNumberKeyPad, |
|
160 // the next one must always be the last value in the enum |
|
161 EInputMethodOnePastTheLast |
|
162 }; |
|
163 enum |
|
164 { |
|
165 EFlagForeground =0x00000001, |
|
166 EFlagWindowIsBeingDragged =0x00000002, |
|
167 EFlagInlineEditingEnabled =0x00000004, |
|
168 EFlagInsideInlineEditingTransaction =0x00000008, |
|
169 EFlagHasNoCompositionWindow =0x00000010 |
|
170 }; |
|
171 enum |
|
172 { |
|
173 EGapLeftOfEachLine =1, |
|
174 EGapAboveCompositionLine =1, |
|
175 EGapBelowCompositionLine =CTstInsertionPoint::EHeight+1, |
|
176 EGapAboveTopStatusLine =1, |
|
177 EGapBetweenEachStatusLine =1, |
|
178 EGapBelowBottomStatusLine =1 |
|
179 }; |
|
180 private: |
|
181 CTstControl(CTstFep& aFep); |
|
182 void ConstructL(); |
|
183 static void SetForeground(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
184 static void SetFocus(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
185 static void SetFlagInlineEditingEnabled(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
186 static void SetInputMethod(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
187 static void SetInputCapabilities(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
188 static void SetFlag(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter, TUint aFlag); |
|
189 void ChangeSetupAndResetBufferAndDrawNow(FChangeFunction aChangeFunction, TInt aParameter=0); |
|
190 void InsertCompositionCharacterAndDrawNowL(TUint aCharacterCode); |
|
191 void SetInlineTextL(MCoeFepAwareTextEditor& aFepAwareTextEditor); |
|
192 void CancelInlineEdit(MCoeFepAwareTextEditor& aFepAwareTextEditor); |
|
193 void CommitInlineEditL(MCoeFepAwareTextEditor& aFepAwareTextEditor); |
|
194 void ResetBuffer(); |
|
195 void SetPositionOfInsertionPointInBuffer(TInt aPositionOfInsertionPointInBuffer); |
|
196 TPoint PositionOfInsertionPointOnWindow() const; |
|
197 static void GetFormatAtDocumentPosition(TCharFormat& aFormat, TInt aDocumentPosition, const MCoeFepAwareTextEditor& aFepAwareTextEditor); |
|
198 static TInt NumberOfCharactersInBuffer(const CBase* aControl); // aControl is really a CTstControl |
|
199 static const TAny* CharacterInBuffer(const CBase* aControl, TInt aIndex); // aControl is really a CTstControl |
|
200 public: |
|
201 // from CCoeControl |
|
202 virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aEventCode); |
|
203 private: |
|
204 // from CCoeControl |
|
205 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
206 virtual void Draw(const TRect& aRect) const; |
|
207 // from MFormCustomDraw |
|
208 virtual void DrawText(const TParam& aParam, const TLineInfo& aLineInfo, const TCharFormat& aFormat, const TDesC& aText, const TPoint& aTextOrigin, TInt aExtraPixels) const; |
|
209 // from MFepInlineTextFormatRetriever |
|
210 virtual void GetFormatOfFepInlineText(TCharFormat& aFormat, TInt& aNumberOfCharactersWithSameFormat, TInt aPositionOfCharacter) const; |
|
211 // from MFepPointerEventHandlerDuringInlineEdit |
|
212 virtual void HandlePointerEventInInlineTextL(TPointerEvent::TType aType, TUint aModifiers, TInt aPositionInInlineText); |
|
213 // from CCoeFep::MDeferredFunctionCall |
|
214 virtual void ExecuteFunctionL(); |
|
215 private: |
|
216 |
|
217 friend class CMoveCursorTimer; |
|
218 |
|
219 CTstFep& iFep; |
|
220 TInt iInputMethod; |
|
221 TUint iFlags; |
|
222 TUint iCharacterCode; // used by CCoeFep::MDeferredFunctionCall::ExecuteFunctionL, and also independently by CharacterInBuffer |
|
223 TBuf<EMaximumLengthOfBuffer> iBuffer; |
|
224 TCursorSelection iSelectedCompositionText; |
|
225 TCoeInputCapabilities iInputCapabilities; |
|
226 CFont* iCompositionFont; |
|
227 CFont* iStatusFont; |
|
228 CTstInsertionPoint* iInsertionPoint; |
|
229 TPoint iPositionOnWindowBeingDragged; |
|
230 // data below used by the NumberKeyPad InputMethod |
|
231 CMoveCursorTimer* iMoveCursorTimer; |
|
232 TInt iCountKeyPressed; |
|
233 TUint iLastKeyPressed; |
|
234 }; |
|
235 |
|
236 class CTstFep : public CCoeFep |
|
237 { |
|
238 public: |
|
239 CTstFep(CCoeEnv& aConeEnvironment); |
|
240 void ConstructL(const CCoeFepParameters& aFepParameters); |
|
241 virtual ~CTstFep(); |
|
242 inline void MakeDeferredFunctionCall(MDeferredFunctionCall& aDeferredFunctionCall) {CCoeFep::MakeDeferredFunctionCall(aDeferredFunctionCall);} |
|
243 inline void SimulateKeyEventsL(const TArray<TUint>& aArrayOfCharacters) {CCoeFep::SimulateKeyEventsL(aArrayOfCharacters);} |
|
244 inline void WriteAttributeDataAndBroadcastL(TUid aAttributeUid) {CCoeFep::WriteAttributeDataAndBroadcastL(aAttributeUid);} |
|
245 inline TBool IsOn() const {return CCoeFep::IsOn();} |
|
246 private: |
|
247 // from CCoeFep |
|
248 virtual void CancelTransaction(); |
|
249 virtual void IsOnHasChangedState(); |
|
250 virtual void OfferKeyEventL(TEventResponse& aEventResponse, const TKeyEvent& aKeyEvent, TEventCode aEventCode); |
|
251 virtual void OfferPointerEventL(TEventResponse& aEventResponse, const TPointerEvent& aPointerEvent, const CCoeControl* aWindowOwningControl); |
|
252 virtual void OfferPointerBufferReadyEventL(TEventResponse& aEventResponse, const CCoeControl* aWindowOwningControl); |
|
253 // from MFepAttributeStorer (via CCoeFep) |
|
254 virtual TInt NumberOfAttributes() const; |
|
255 virtual TUid AttributeAtIndex(TInt aIndex) const; |
|
256 virtual void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const; |
|
257 virtual void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream); |
|
258 // from MCoeForegroundObserver (via CCoeFep) |
|
259 virtual void HandleGainingForeground(); |
|
260 virtual void HandleLosingForeground(); |
|
261 // from MCoeFocusObserver (via CCoeFep) |
|
262 virtual void HandleChangeInFocus(); |
|
263 virtual void HandleDestructionOfFocusedItem(); |
|
264 private: |
|
265 CTstControl* iControl; |
|
266 }; |
|
267 |
|
268 class TTstResourceFileId : public TCleanupItem |
|
269 { |
|
270 public: |
|
271 TTstResourceFileId(CCoeEnv& aConeEnvironment, TInt aResourceFileId); |
|
272 private: |
|
273 static void UnloadResourceFile(TAny* aThis); |
|
274 private: |
|
275 CCoeEnv& iConeEnvironment; |
|
276 TInt iResourceFileId; |
|
277 }; |
|
278 |
|
279 class CTstSettingsDialog : public CEikDialog, private MFepAttributeStorer |
|
280 { |
|
281 public: |
|
282 CTstSettingsDialog(); |
|
283 private: |
|
284 // from CEikDialog |
|
285 virtual TBool OkToExitL(TInt aButtonId); |
|
286 virtual void PreLayoutDynInitL(); |
|
287 // from MFepAttributeStorer |
|
288 virtual TInt NumberOfAttributes() const; |
|
289 virtual TUid AttributeAtIndex(TInt aIndex) const; |
|
290 virtual void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const; |
|
291 virtual void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream); |
|
292 private: |
|
293 TBool iInlineEditingEnabled; |
|
294 TInt iInputMethod; |
|
295 TUid iUid; |
|
296 }; |
|
297 |
|
298 #endif |
|
299 |