66
|
1 |
/*
|
|
2 |
* Copyright (c) 2003 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: ?Description
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef CMIDUTILS_H
|
|
20 |
#define CMIDUTILS_H
|
|
21 |
|
|
22 |
#include <coecntrl.h>
|
|
23 |
#include <gulcolor.h>
|
|
24 |
// MMIDUtils interface
|
|
25 |
#include <lcdui.h>
|
|
26 |
|
|
27 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
28 |
#ifdef RD_JAVA_S60_RELEASE_5_0_IAD
|
|
29 |
#include "javaptivariation.h"
|
|
30 |
#endif //RD_JAVA_S60_RELEASE_5_0_IAD
|
|
31 |
#endif // RD_INTELLIGENT_TEXT_INPUT
|
|
32 |
// FORWARD DECLARATIONS
|
|
33 |
class CHWRMLight;
|
|
34 |
class CHWRMVibra;
|
|
35 |
class CMIDUIManager;
|
|
36 |
class CMIDKeyDecoder;
|
|
37 |
class CMIDMenuHandler;
|
|
38 |
|
|
39 |
//#include <dsyenums.h> // contains enums needed by DosSvrServices
|
|
40 |
|
|
41 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
42 |
class CPtiEngine;
|
|
43 |
class CRepository;
|
|
44 |
#endif // RD_INTELLIGENT_TEXT_INPUT
|
|
45 |
|
|
46 |
NONSHARABLE_CLASS(CMIDUtils) : public CBase, public MMIDUtils
|
|
47 |
{
|
|
48 |
/**
|
|
49 |
* Enumeration defines values for every keyboard type.
|
|
50 |
* Values come from repository:
|
|
51 |
* 0 No Keyboard
|
|
52 |
* 1 Keyboard with 12 key
|
|
53 |
* 2 QWERTY 4x12 layout
|
|
54 |
* 3 QWERTY 4x10 layout
|
|
55 |
* 4 QWERTY 3 x 11 layout
|
|
56 |
* 5 Half QWERTY
|
|
57 |
* 6 Custom QWERTY
|
|
58 |
*/
|
|
59 |
enum TKeyboardTypes
|
|
60 |
{
|
|
61 |
ENoKeyboard,
|
|
62 |
EKeyboardWith12Key,
|
|
63 |
EQWERTY4x12Layout,
|
|
64 |
EQWERTY4x10Layout,
|
|
65 |
EQWERTY3x11Layout,
|
|
66 |
EHalfQWERTY,
|
|
67 |
ECustomQWERTY
|
|
68 |
};
|
|
69 |
|
|
70 |
enum TStickyKeyStatus
|
|
71 |
{
|
|
72 |
EKeyNotPressed,
|
|
73 |
EKeyWasPressed,
|
|
74 |
EKeyWasReleased,
|
|
75 |
};
|
|
76 |
|
|
77 |
enum TLockableKeyStatus
|
|
78 |
{
|
|
79 |
EKeyNotActive,
|
|
80 |
EKeyActive,
|
|
81 |
EKeyNotActiveNext,
|
|
82 |
EKeyLocked,
|
|
83 |
};
|
|
84 |
|
|
85 |
// This class is storage for data needed for scaling.
|
|
86 |
class TScalingData
|
|
87 |
{
|
|
88 |
public:
|
|
89 |
inline TScalingData();
|
|
90 |
|
|
91 |
TSize iOriginalSize;
|
|
92 |
TSize iTargetSize;
|
|
93 |
TSize iScreenSize;
|
|
94 |
TSize iCanvasSize;
|
|
95 |
TReal iRatioX;
|
|
96 |
TReal iRatioY;
|
|
97 |
};
|
|
98 |
|
|
99 |
public:
|
|
100 |
enum TDirections
|
|
101 |
{
|
|
102 |
EHorizontal,
|
|
103 |
EVertical
|
|
104 |
};
|
|
105 |
|
|
106 |
private:
|
|
107 |
class TStickyKeysHandler
|
|
108 |
{
|
|
109 |
public:
|
|
110 |
TStickyKeysHandler();
|
|
111 |
void Reset();
|
|
112 |
TBool HandleKey(const TKeyEvent& aKeyEvent, TEventCode aType);
|
|
113 |
TInt Modifiers() const;
|
|
114 |
|
|
115 |
private:
|
|
116 |
void ResetState();
|
|
117 |
TUint ModifierFromScanCode(TInt aScanCode);
|
|
118 |
TBool IsSticky(const TKeyEvent& aKeyEvent);
|
|
119 |
void HandleLockableKeys(TUint aModifiers);
|
|
120 |
void HandleFnKey();
|
|
121 |
void HandleShiftKey();
|
|
122 |
void AddShiftToStickyModifiers();
|
|
123 |
void AddFnToStickyModifiers();
|
|
124 |
inline TBool IsFnModifierOn(const TUint aModifiers) const;
|
|
125 |
inline TBool IsShiftModifierOn(const TUint aModifiers) const;
|
|
126 |
|
|
127 |
private:
|
|
128 |
TStickyKeyStatus iStickyKeyState;
|
|
129 |
TLockableKeyStatus iFnKeyState;
|
|
130 |
TLockableKeyStatus iShiftKeyState;
|
|
131 |
TInt iLastStickyScanCode;
|
|
132 |
TUint iStickyModifier;
|
|
133 |
TUint iLastKeyModifier;
|
|
134 |
TUint iActualFnModifierValue;
|
|
135 |
TUint iActualShiftModifierValue;
|
|
136 |
};
|
|
137 |
|
|
138 |
public:
|
|
139 |
/**
|
|
140 |
* Static method to create MMIDUtils instance
|
|
141 |
* @param aEnv Environment
|
|
142 |
* @param aUIManager Manager
|
|
143 |
* @return MMIDUtils instance
|
|
144 |
*
|
|
145 |
* @since s60
|
|
146 |
*/
|
|
147 |
static MMIDUtils* NewL(MMIDEnv& aEnv, CMIDUIManager* aUIManager);
|
|
148 |
|
|
149 |
//
|
|
150 |
// Utility methods used within lcdui plugin
|
|
151 |
//
|
|
152 |
static void MapJavaToETextChars(HBufC* aText,TBool aSupportLineBreaks=ETrue);
|
|
153 |
static void MapETextToJavaChars(HBufC* aText);
|
|
154 |
static TInt GameAction(TInt aKeyCode);
|
|
155 |
static TBool IsStronglyRightToLeft(HBufC* aText);
|
|
156 |
static void Reverse(HBufC* aText);
|
|
157 |
static TBool IgnoreKeyEvent(TUint aKeyEvent);
|
|
158 |
static CFbsBitmap* CopyBitmapL(CFbsBitmap* aSource);
|
|
159 |
|
|
160 |
/**
|
|
161 |
* Scaling of one integer (as height).
|
|
162 |
*
|
|
163 |
* @param aNonScaled A non-scaled value.
|
|
164 |
* @param aDirection A direction of value. Values are in TDirections.
|
|
165 |
* @return A scaled value.
|
|
166 |
*
|
|
167 |
* @since S60 5.0
|
|
168 |
*/
|
|
169 |
TInt DoScaling(TInt aNonScaled, TInt aDirection);
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Scaling of TPoint value.
|
|
173 |
*
|
|
174 |
* @param aNonScaled A non-scaled value.
|
|
175 |
* @return A scaled value.
|
|
176 |
*
|
|
177 |
* @since S60 5.0
|
|
178 |
*/
|
|
179 |
TPoint DoScaling(TPoint aNonScaled);
|
|
180 |
|
|
181 |
/**
|
|
182 |
* Scaling and positioning of TPoint value.
|
|
183 |
*
|
|
184 |
* @param aNonScaled A non-scaled value.
|
|
185 |
* @return A scaled value.
|
|
186 |
*
|
|
187 |
* @since S60 5.0
|
|
188 |
*/
|
|
189 |
TPoint DoScalingAndPositioning(TPoint aNonScaled);
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Scaling of TRect value.
|
|
193 |
*
|
|
194 |
* @param aNonScaled A non-scaled value.
|
|
195 |
* @return A scaled value.
|
|
196 |
*
|
|
197 |
* @since S60 5.0
|
|
198 |
*/
|
|
199 |
TRect DoScaling(TRect aNonScaled);
|
|
200 |
|
|
201 |
/**
|
|
202 |
* Scaling and positioning of TRect value.
|
|
203 |
*
|
|
204 |
* @param aNonScaled A non-scaled value.
|
|
205 |
* @return A scaled value.
|
|
206 |
*
|
|
207 |
* @since S60 5.0
|
|
208 |
*/
|
|
209 |
TRect DoScalingAndPositioning(TRect aNonScaled);
|
|
210 |
|
|
211 |
/**
|
|
212 |
* Scaling of TSize value.
|
|
213 |
*
|
|
214 |
* @param aNonScaled A non-scaled value.
|
|
215 |
* @return A scaled value.
|
|
216 |
*
|
|
217 |
* @since S60 5.0
|
|
218 |
*/
|
|
219 |
TSize DoScaling(TSize aNonScaled);
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Descaling of one integer (as height).
|
|
223 |
*
|
|
224 |
* @param aNonScaled A scaled value.
|
|
225 |
* @param aDirection A direction of value. Values are in TDirections.
|
|
226 |
* @return A original non-scaled value.
|
|
227 |
*
|
|
228 |
* @since S60 5.0
|
|
229 |
*/
|
|
230 |
TInt DoDescaling(TInt aNonScaled, TInt aDirection);
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Descaling of TPoint value.
|
|
234 |
*
|
|
235 |
* @param aNonScaled A scaled value.
|
|
236 |
* @return A original non-scaled value.
|
|
237 |
*
|
|
238 |
* @since S60 5.0
|
|
239 |
*/
|
|
240 |
TPoint DoDescaling(TPoint aNonScaled);
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Descaling and position to originalposition of TPoint value.
|
|
244 |
*
|
|
245 |
* @param aNonScaled A scaled value.
|
|
246 |
* @return A original non-scaled value.
|
|
247 |
*
|
|
248 |
* @since S60 5.0
|
|
249 |
*/
|
|
250 |
TPoint DoDescalingAndPositioning(TPoint aNonScaled);
|
|
251 |
|
|
252 |
/**
|
|
253 |
* Descaling of TRect value.
|
|
254 |
*
|
|
255 |
* @param aNonScaled A scaled value.
|
|
256 |
* @return A original non-scaled value.
|
|
257 |
*
|
|
258 |
* @since S60 5.0
|
|
259 |
*/
|
|
260 |
TRect DoDescaling(TRect aNonScaled);
|
|
261 |
|
|
262 |
/**
|
|
263 |
* Descaling and position to originalposition of TRect value.
|
|
264 |
*
|
|
265 |
* @param aNonScaled A scaled value.
|
|
266 |
* @return A original non-scaled value.
|
|
267 |
*
|
|
268 |
* @since S60 5.0
|
|
269 |
*/
|
|
270 |
TRect DoDescalingAndPositioning(TRect aNonScaled);
|
|
271 |
|
|
272 |
/**
|
|
273 |
* Descaling of TSize value.
|
|
274 |
*
|
|
275 |
* @param aNonScaled A scaled value.
|
|
276 |
* @return A original non-scaled value.
|
|
277 |
*
|
|
278 |
* @since S60 5.0
|
|
279 |
*/
|
|
280 |
TSize DoDescaling(TSize aNonScaled);
|
|
281 |
|
|
282 |
|
|
283 |
/**
|
|
284 |
* Get information about scaling settings.
|
|
285 |
*
|
|
286 |
* @return ETrue if Nokia-MIDlet-Original-Display-Size is set.
|
|
287 |
* EFalse otherwise.
|
|
288 |
*
|
|
289 |
* @since S60 5.0
|
|
290 |
*/
|
|
291 |
TBool IsScalingEnabled();
|
|
292 |
|
|
293 |
|
|
294 |
/**
|
|
295 |
* Gets current size of fullscreen canvas.
|
|
296 |
*
|
|
297 |
* @return current size of fullscreen canvas
|
|
298 |
*
|
|
299 |
* @since S60 5.0
|
|
300 |
*/
|
|
301 |
TRect GetOnScreenCanvasRect();
|
|
302 |
|
|
303 |
/**
|
|
304 |
* @return ETrue if aChar is one of the following characters: 0x0a, 0x0d, 0x2028
|
|
305 |
*/
|
|
306 |
static TBool IsLineSeparator(const TText aChar);
|
|
307 |
|
|
308 |
//
|
|
309 |
// From MMIDUtils
|
|
310 |
//
|
|
311 |
TBool PlaySound(TInt aType);
|
|
312 |
//
|
|
313 |
// key utils
|
|
314 |
TBool IsJavaKey(TInt aScanCode);
|
|
315 |
TInt MapNonUnicodeKey(TUint aScanCode);
|
|
316 |
void GetKeyName(TDes& aText,TInt aKeyCode);
|
|
317 |
TInt GetKeyCode(TInt aGameAction);
|
|
318 |
TInt GetGameAction(TInt aKeyCode);
|
|
319 |
TBool HasPointerEvents();
|
|
320 |
TBool HasPointerMotionEvents();
|
|
321 |
TBool HasRepeatEvents();
|
|
322 |
void GetKeyboardTypeName(TDes* aText);
|
|
323 |
TInt GetKeyScanCode();
|
|
324 |
void SetLastKeyEvent(const TKeyEvent& aEvent);
|
|
325 |
TInt GetKeyModifier();
|
|
326 |
void MappingDataForKey(TKeyEvent& aEvent, TEventCode aType);
|
|
327 |
void HandleResourceChangedL();
|
|
328 |
void HandleForegroundL(TBool aForeground);
|
|
329 |
//
|
|
330 |
// Display utils
|
|
331 |
TBool FlashBacklightL(const TTimeIntervalMicroSeconds32& aDuration);
|
|
332 |
TBool Vibrate(const TTimeIntervalMicroSeconds32& aDuration);
|
|
333 |
TInt Color(TColorType aColorSpecifier);
|
|
334 |
TGraphicsType BorderStyle(TBool aHighlighted);
|
|
335 |
TSize BestImageSize(TImageType aImageType) const;
|
|
336 |
//
|
|
337 |
// Font utils
|
|
338 |
SFontSpec FontSpecifierSpecs(MMIDFont::TFontSpecifier aSpecifier);
|
|
339 |
//
|
|
340 |
// Destruction
|
|
341 |
inline void Dispose();
|
|
342 |
//
|
|
343 |
|
|
344 |
private:
|
|
345 |
/**
|
|
346 |
* Ctor
|
|
347 |
* @param aEnv Environment
|
|
348 |
* @param aUIManager Manager
|
|
349 |
*
|
|
350 |
* @since s60
|
|
351 |
*/
|
|
352 |
CMIDUtils(MMIDEnv& aEnv, CMIDUIManager* aUIManager);
|
|
353 |
|
|
354 |
~CMIDUtils();
|
|
355 |
void ConstructL();
|
|
356 |
|
|
357 |
//
|
|
358 |
TBool HasPen();
|
|
359 |
TBool HasMouse();
|
|
360 |
|
|
361 |
/**
|
|
362 |
* Gets a sizes neeeded for futher function of scaling functions.
|
|
363 |
*
|
|
364 |
* @return Initialized instance of TScalingData with actual content.
|
|
365 |
*
|
|
366 |
* @since S60 5.0
|
|
367 |
*/
|
|
368 |
CMIDUtils::TScalingData GetScalingData();
|
|
369 |
|
|
370 |
void UpdateScalingData();
|
|
371 |
|
|
372 |
void UpdateStickyKeyFlags(const TKeyEvent& aKeyEvent);
|
|
373 |
void UpdatePTIEngineStatusL();
|
|
374 |
|
|
375 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
376 |
|
|
377 |
#ifdef RD_JAVA_S60_RELEASE_5_0_IAD
|
|
378 |
void CallToJavaPtiVariationL(TInt aType);
|
|
379 |
#endif //RD_JAVA_S60_RELEASE_5_0_IAD
|
|
380 |
|
|
381 |
/**
|
|
382 |
* Function sets keyboard type/layout for Pti engine
|
|
383 |
*/
|
|
384 |
void SetPtiKeyboardL();
|
|
385 |
#endif //RD_INTELLIGENT_TEXT_INPUT
|
|
386 |
|
|
387 |
private:
|
|
388 |
MMIDEnv* iEnv;
|
|
389 |
|
|
390 |
// Light Client API, owned
|
|
391 |
CHWRMLight* iLight;
|
|
392 |
|
|
393 |
// Vibra API, owned
|
|
394 |
CHWRMVibra* iVibra;
|
|
395 |
CMIDUIManager* iUIManager;
|
|
396 |
CMIDKeyDecoder* iKeyDecoder;
|
|
397 |
|
|
398 |
TScalingData iScalingData;
|
|
399 |
|
|
400 |
|
|
401 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
402 |
/**
|
|
403 |
* Predictive text input engine for canvas low level key events.
|
|
404 |
* Own.
|
|
405 |
*/
|
|
406 |
CPtiEngine* iPtiEngine;
|
|
407 |
|
|
408 |
/**
|
|
409 |
* Acces to a repository ( Fep input txt lang )
|
|
410 |
* Own.
|
|
411 |
*/
|
|
412 |
CRepository* iRepository;
|
|
413 |
|
|
414 |
#ifdef RD_JAVA_S60_RELEASE_5_0_IAD
|
|
415 |
RLibrary iPtiSupportLib;
|
|
416 |
#endif //RD_JAVA_S60_RELEASE_5_0_IAD
|
|
417 |
|
|
418 |
// Storing current pti keyboard type/layout
|
|
419 |
TInt iPtiKeyboardType;
|
|
420 |
#endif // RD_INTELLIGENT_TEXT_INPUT
|
|
421 |
|
|
422 |
TInt iQwertyMode;
|
|
423 |
|
|
424 |
TInt iStickyKey;
|
|
425 |
|
|
426 |
// Stores value of the scan code of the latest key event.
|
|
427 |
// Value is used for com.nokia.key.scancode system property.
|
|
428 |
TInt iLastScanCode;
|
|
429 |
|
|
430 |
TInt iModifier;
|
|
431 |
|
|
432 |
TStickyKeysHandler iStickyHandler;
|
|
433 |
|
|
434 |
// Instace of menu handler. Needed for scaling. Not owned.
|
|
435 |
CMIDMenuHandler* iMenuHandler;
|
|
436 |
|
|
437 |
// Flag if scaling data was initialized.
|
|
438 |
TBool iScalingDataInitialized;
|
|
439 |
};
|
|
440 |
|
|
441 |
inline void CMIDUtils::Dispose()
|
|
442 |
{
|
|
443 |
delete this;
|
|
444 |
}
|
|
445 |
|
|
446 |
inline CMIDUtils::TScalingData::TScalingData(): iOriginalSize(),
|
|
447 |
iTargetSize(),
|
|
448 |
iScreenSize(),
|
|
449 |
iCanvasSize(),
|
|
450 |
iRatioX(1.0f),
|
|
451 |
iRatioY(1.0f)
|
|
452 |
{}
|
|
453 |
|
|
454 |
#endif // CMIDUTILS_H
|