|
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(__TFEP2_H__) |
|
17 #define __TFEP2_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(__GDI_H__) |
|
28 #include <gdi.h> |
|
29 #endif |
|
30 |
|
31 #if !defined(__W32STD_H__) |
|
32 #include <w32std.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(__EIKDIALG_H__) |
|
48 #include <techview/eikdialg.h> |
|
49 #endif |
|
50 |
|
51 class CTstFep; |
|
52 |
|
53 class CTstScribbleWindow : public CCoeControl // this needs to be a separate control as it needs to be a window with "pointer-buffers" enabled |
|
54 { |
|
55 public: |
|
56 static CTstScribbleWindow* NewL(CTstFep& aFep, RWindowTreeNode& aParent); |
|
57 virtual ~CTstScribbleWindow(); |
|
58 void SetPointerBufferEnabled(TBool aPointerBufferEnabled); |
|
59 void HandleTimeOutL(); |
|
60 void CancelTransactionAndDrawNow(); |
|
61 void CancelTransaction(TBool& aChangeWasMade); |
|
62 // from CCoeControl |
|
63 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
64 virtual void HandlePointerBufferReadyL(); |
|
65 private: |
|
66 typedef CArrayFix<TPoint> CPolyLine; |
|
67 enum {ENumberOfPointsInBuffer=32}; |
|
68 enum |
|
69 { |
|
70 EFlagPointerIsDown =0x00000001, |
|
71 EFlagPointerBufferActuallyEnabled =0x00000002 |
|
72 }; |
|
73 class CTimeOutTimer : public CTimer |
|
74 { |
|
75 public: |
|
76 static CTimeOutTimer* NewL(CTstScribbleWindow& aScribbleWindow); |
|
77 virtual ~CTimeOutTimer(); |
|
78 private: |
|
79 CTimeOutTimer(CTstScribbleWindow& aScribbleWindow); |
|
80 virtual void RunL(); |
|
81 private: |
|
82 CTstScribbleWindow& iScribbleWindow; |
|
83 }; |
|
84 private: |
|
85 CTstScribbleWindow(CTstFep& aFep); |
|
86 void ConstructL(RWindowTreeNode& aParent); |
|
87 // from CCoeControl |
|
88 virtual void Draw(const TRect& aRect) const; |
|
89 private: |
|
90 CTstFep& iFep; |
|
91 TUint iFlags; |
|
92 RPointerArray<CPolyLine> iArrayOfPolyLines; |
|
93 CTimeOutTimer* iTimeOutTimer; |
|
94 }; |
|
95 |
|
96 struct STstBitmapHandles; |
|
97 class CFbsBitmap; |
|
98 |
|
99 class CTstWholeScreenScribbleArea : public CBase |
|
100 { |
|
101 public: |
|
102 static CTstWholeScreenScribbleArea* NewL(RWsSession& aWindowServerSession, RWindowGroup& aWindowGroup, const TSize& aScreenSize, TDisplayMode aDisplayMode, const TDesC& aDllName); |
|
103 ~CTstWholeScreenScribbleArea(); |
|
104 inline void RequestNotificationOfStartOfTransaction(TRequestStatus& aRequestStatus) {iHandWritingRecognizer.RequestNotificationOfStartOfTransaction(aRequestStatus);} |
|
105 inline void CancelRequestForNotificationOfStartOfTransaction() {iHandWritingRecognizer.CancelRequestForNotificationOfStartOfTransaction();} |
|
106 inline void RequestCharacters(TRequestStatus& aRequestStatus, TDes8& aCharacterBuffer, TBool aUpperCase) {iHandWritingRecognizer.RequestCharacters(aRequestStatus, aCharacterBuffer, aUpperCase);} |
|
107 inline void CancelRequestForCharacters() {iHandWritingRecognizer.CancelRequestForCharacters();} |
|
108 inline void SetUpperCase(TBool aUpperCase) {iHandWritingRecognizer.SetUpperCase(aUpperCase);} |
|
109 private: |
|
110 enum |
|
111 { |
|
112 EFlagMutexIsConstructed=0x00000001 |
|
113 }; |
|
114 class RHandWritingRecognizer : public RAnim |
|
115 { |
|
116 public: |
|
117 inline RHandWritingRecognizer() {} |
|
118 inline RHandWritingRecognizer(RAnimDll& aAnimDll) :RAnim(aAnimDll) {} |
|
119 void ConstructL(const RWsSprite& aSprite, STstBitmapHandles& aBitmapHandles); |
|
120 void FinishConstructionL(); |
|
121 void RequestNotificationOfStartOfTransaction(TRequestStatus& aRequestStatus); |
|
122 void CancelRequestForNotificationOfStartOfTransaction(); |
|
123 void RequestCharacters(TRequestStatus& aRequestStatus, TDes8& aCharacterBuffer, TBool aUpperCase); |
|
124 void CancelRequestForCharacters(); |
|
125 void SetUpperCase(TBool aUpperCase); |
|
126 }; |
|
127 private: |
|
128 CTstWholeScreenScribbleArea(RWsSession& aWindowServerSession); |
|
129 void ConstructL(RWindowGroup& aWindowGroup, const TSize& aScreenSize, TDisplayMode aDisplayMode, const TDesC& aDllName); |
|
130 static CFbsBitmap* CreateBitmapL(TInt aHandleOfBitmapToUse, const TSize& aScreenSize, TDisplayMode aDisplayMode); |
|
131 static void SignalMutex(TAny* aMutex); |
|
132 private: |
|
133 TUint iFlags; |
|
134 RMutex iMutex; |
|
135 TSpriteMember iSpriteMember; |
|
136 RAnimDll iDll; |
|
137 RWsSprite iSprite; |
|
138 RHandWritingRecognizer iHandWritingRecognizer; |
|
139 }; |
|
140 |
|
141 class CFont; |
|
142 |
|
143 class CTstControl : public CCoeControl |
|
144 { |
|
145 public: |
|
146 static CTstControl* NewL(CTstFep& aFep); |
|
147 virtual ~CTstControl(); |
|
148 void CancelTransaction(); |
|
149 void IsOnHasChangedState(); |
|
150 void OfferPointerEventL(CCoeFep::TEventResponse& aEventResponse, const TPointerEvent& aPointerEvent, const CCoeControl* aWindowOwningControl); |
|
151 void OfferPointerBufferReadyEventL(CCoeFep::TEventResponse& aEventResponse, const CCoeControl* aWindowOwningControl); |
|
152 inline TBool UpperCase() const {return (iFlags&EFlagUpperCase);} |
|
153 static TInt NumberOfAttributes(); |
|
154 static TUid AttributeAtIndex(TInt aIndex); |
|
155 void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const; |
|
156 void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream); |
|
157 static void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream, TBool aUpperCase, TBool aWholeScreen, TBool aPointerBufferEnabled); |
|
158 static void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream, TBool& aUpperCase, TBool& aWholeScreen, TBool& aPointerBufferEnabled); |
|
159 void HandleGainingForeground(); |
|
160 void HandleLosingForeground(); |
|
161 void HandleChangeInFocus(); |
|
162 void HandleDestructionOfFocusedItem(); |
|
163 private: |
|
164 typedef void (*FChangeFunction)(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
165 enum {EArrowHeadSize=4}; |
|
166 enum {EMaximumLengthOfDisplayOfContextInformation=15}; |
|
167 enum |
|
168 { |
|
169 ETstUpperCaseUid=0x10003eab, |
|
170 ETstWholeScreenUid=0x1000550c, |
|
171 ETstPointerBufferEnabledUid=0x10004d18 |
|
172 }; |
|
173 enum |
|
174 { |
|
175 EFlagForeground =0x00000001, |
|
176 EFlagWindowIsBeingDragged =0x00000002, |
|
177 EFlagUpperCase =0x00000004, |
|
178 EFlagWholeScreen =0x00000008, |
|
179 EFlagPointerBufferEnabled =0x00000010, |
|
180 EFlagActuallyWholeScreen =0x00000020 |
|
181 }; |
|
182 enum |
|
183 { |
|
184 EHeightOfScribbleWindow =60, |
|
185 EGapLeftOfEachLine =1, |
|
186 EGapAboveTopLine =1, |
|
187 EGapBetweenEachLine =1, |
|
188 EGapBelowBottomLine =1 |
|
189 }; |
|
190 class CHandlerForStartOfTransaction : public CActive |
|
191 { |
|
192 public: |
|
193 static CHandlerForStartOfTransaction* NewL(CTstWholeScreenScribbleArea& aWholeScreenScribbleArea, CCoeEnv& aConeEnvironment); |
|
194 virtual ~CHandlerForStartOfTransaction(); |
|
195 private: |
|
196 CHandlerForStartOfTransaction(CTstWholeScreenScribbleArea& aWholeScreenScribbleArea, CCoeEnv& aConeEnvironment); |
|
197 void RequestNotificationOfStartOfTransaction(); |
|
198 virtual void DoCancel(); |
|
199 virtual void RunL(); |
|
200 private: |
|
201 CTstWholeScreenScribbleArea& iWholeScreenScribbleArea; |
|
202 CCoeEnv& iConeEnvironment; |
|
203 }; |
|
204 class CHandlerForCharacters : public CActive |
|
205 { |
|
206 public: |
|
207 static CHandlerForCharacters* NewL(CTstWholeScreenScribbleArea& aWholeScreenScribbleArea, CTstFep& aFep, TBool aForeground); |
|
208 virtual ~CHandlerForCharacters(); |
|
209 inline void SetWholeScreen(TBool aWholeScreen) {SetFlagAffectingWhetherActive(EFlagWholeScreen, aWholeScreen);} |
|
210 inline void SetIsOn(TBool aIsOn) {SetFlagAffectingWhetherActive(EFlagIsOn, aIsOn);} |
|
211 inline void SetForeground(TBool aForeground) {SetFlagAffectingWhetherActive(EFlagForeground, aForeground);} |
|
212 void SetUpperCase(TBool aUpperCase); |
|
213 private: |
|
214 enum {EMaximumLengthOfCharacterBuffer=4*sizeof(TUint)}; |
|
215 enum |
|
216 { |
|
217 EFlagWholeScreen =0x00000001, |
|
218 EFlagIsOn =0x00000002, |
|
219 EFlagForeground =0x00000004, |
|
220 EFlagUpperCase =0x00000008 |
|
221 }; |
|
222 private: |
|
223 CHandlerForCharacters(CTstWholeScreenScribbleArea& aWholeScreenScribbleArea, CTstFep& aFep, TBool aForeground); |
|
224 void SetFlagAffectingWhetherActive(TUint aFlagAffectingWhetherActive, TBool aSetting); // aFlag may be passed EFlagWholeScreen, EFlagIsOn or EFlagForeground |
|
225 void RequestCharacters(); |
|
226 static TInt NumberOfCharactersInBuffer(const CBase* aCharacterBuffer); // aCharacterBuffer is really a TDesC8 |
|
227 static const TAny* CharacterInBuffer(const CBase* aCharacterBuffer, TInt aIndex); // aCharacterBuffer is really a TDesC8 |
|
228 virtual void DoCancel(); |
|
229 virtual void RunL(); |
|
230 private: |
|
231 CTstWholeScreenScribbleArea& iWholeScreenScribbleArea; |
|
232 CTstFep& iFep; |
|
233 TUint iFlags; |
|
234 TBuf8<EMaximumLengthOfCharacterBuffer> iCharacterBuffer; |
|
235 }; |
|
236 private: |
|
237 CTstControl(CTstFep& aFep); |
|
238 void ConstructL(); |
|
239 static void SetForeground(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
240 static void SetFocus(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
241 static void SetUpperCase(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
242 static void SetWholeScreen(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
243 static void SetPointerBufferEnabled(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
244 static void SetInputCapabilities(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter); |
|
245 static void SetFlag(CTstControl& aControl, TBool& aChangeWasMade, TInt aParameter, TUint aFlag); |
|
246 void DoSetWholeScreen(TBool aWholeScreen); |
|
247 void ChangeSetupAndDrawNow(FChangeFunction aChangeFunction, TInt aParameter=0); |
|
248 public: |
|
249 // from CCoeControl |
|
250 virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aEventCode); |
|
251 private: |
|
252 // from CCoeControl |
|
253 virtual void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
254 virtual TInt CountComponentControls() const; |
|
255 virtual CCoeControl* ComponentControl(TInt aIndex) const; |
|
256 virtual void Draw(const TRect& aRect) const; |
|
257 private: |
|
258 CTstFep& iFep; |
|
259 TUint iFlags; |
|
260 TCoeInputCapabilities iInputCapabilities; |
|
261 CTstScribbleWindow* iScribbleWindow; |
|
262 CTstWholeScreenScribbleArea* iWholeScreenScribbleArea; |
|
263 CHandlerForStartOfTransaction* iHandlerForStartOfTransaction; |
|
264 CHandlerForCharacters* iHandlerForCharacters; |
|
265 CFont* iStatusFont; |
|
266 TPoint iPositionOnWindowBeingDragged; |
|
267 }; |
|
268 |
|
269 class CTstFep : public CCoeFep |
|
270 { |
|
271 public: |
|
272 CTstFep(CCoeEnv& aConeEnvironment); |
|
273 void ConstructL(const CCoeFepParameters& aFepParameters); |
|
274 virtual ~CTstFep(); |
|
275 inline void SimulateKeyEventsL(const TArray<TUint>& aArrayOfCharacters) {CCoeFep::SimulateKeyEventsL(aArrayOfCharacters);} |
|
276 inline void WriteAttributeDataAndBroadcastL(TUid aAttributeUid) {CCoeFep::WriteAttributeDataAndBroadcastL(aAttributeUid);} |
|
277 inline TBool IsOn() const {return CCoeFep::IsOn();} |
|
278 inline TBool UpperCase() const {return iControl->UpperCase();} |
|
279 private: |
|
280 // from CCoeFep |
|
281 virtual void CancelTransaction(); |
|
282 virtual void IsOnHasChangedState(); |
|
283 virtual void OfferKeyEventL(TEventResponse& aEventResponse, const TKeyEvent& aKeyEvent, TEventCode aEventCode); |
|
284 virtual void OfferPointerEventL(TEventResponse& aEventResponse, const TPointerEvent& aPointerEvent, const CCoeControl* aWindowOwningControl); |
|
285 virtual void OfferPointerBufferReadyEventL(TEventResponse& aEventResponse, const CCoeControl* aWindowOwningControl); |
|
286 // from MFepAttributeStorer (via CCoeFep) |
|
287 virtual TInt NumberOfAttributes() const; |
|
288 virtual TUid AttributeAtIndex(TInt aIndex) const; |
|
289 virtual void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const; |
|
290 virtual void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream); |
|
291 // from MCoeForegroundObserver (via CCoeFep) |
|
292 virtual void HandleGainingForeground(); |
|
293 virtual void HandleLosingForeground(); |
|
294 // from MCoeFocusObserver (via CCoeFep) |
|
295 virtual void HandleChangeInFocus(); |
|
296 virtual void HandleDestructionOfFocusedItem(); |
|
297 private: |
|
298 CTstControl* iControl; |
|
299 }; |
|
300 |
|
301 class TTstResourceFileId : public TCleanupItem |
|
302 { |
|
303 public: |
|
304 TTstResourceFileId(CCoeEnv& aConeEnvironment, TInt aResourceFileId); |
|
305 private: |
|
306 static void UnloadResourceFile(TAny* aThis); |
|
307 private: |
|
308 CCoeEnv& iConeEnvironment; |
|
309 TInt iResourceFileId; |
|
310 }; |
|
311 |
|
312 class CTstSettingsDialog : public CEikDialog, private MFepAttributeStorer |
|
313 { |
|
314 public: |
|
315 CTstSettingsDialog(); |
|
316 private: |
|
317 TUint CheckBoxStateAsFlag(TInt aControlId, TUint aFlag) const; |
|
318 void SetCheckBoxState(TInt aControlId, TUint aFlag); |
|
319 // from CEikDialog |
|
320 virtual TBool OkToExitL(TInt aButtonId); |
|
321 virtual void PreLayoutDynInitL(); |
|
322 // from MFepAttributeStorer |
|
323 virtual TInt NumberOfAttributes() const; |
|
324 virtual TUid AttributeAtIndex(TInt aIndex) const; |
|
325 virtual void WriteAttributeDataToStreamL(TUid aAttributeUid, RWriteStream& aStream) const; |
|
326 virtual void ReadAttributeDataFromStreamL(TUid aAttributeUid, RReadStream& aStream); |
|
327 private: |
|
328 enum |
|
329 { |
|
330 EFlagUpperCase =0x00000001, |
|
331 EFlagWholeScreen =0x00000002, |
|
332 EFlagPointerBufferEnabled =0x00000004 |
|
333 }; |
|
334 private: |
|
335 TUint iFlags; |
|
336 TUid iUid; |
|
337 }; |
|
338 |
|
339 #endif |
|
340 |