|
1 /* |
|
2 * Copyright (c) 2006-2008 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: Implementation of MTactileFeedbackInterface of LCDUI midlets. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifdef RD_TACTILE_FEEDBACK |
|
20 |
|
21 #include "CMIDToolkit.h" |
|
22 #include <touchfeedback.h> |
|
23 #include "CTactileFeedbackInterfaceLCDUI.h" |
|
24 #include "TactileFeedbackImpl.h" |
|
25 |
|
26 //#include "CMIDTactileFeedbackExtension.h" |
|
27 |
|
28 CTactileFeedbackInterfaceLCDUI::CTactileFeedbackInterfaceLCDUI(CMIDToolkit* aToolkit) |
|
29 { |
|
30 iLcduiToolkit = aToolkit; |
|
31 aToolkit->ExecuteTrap(&_CreateMTouchFeedback, &iFeedback); |
|
32 }; |
|
33 |
|
34 |
|
35 void CTactileFeedbackInterfaceLCDUI::DirectFeedback(TTouchLogicalFeedback aStyle) |
|
36 { |
|
37 iLcduiToolkit->ExecuteTrap(&_DoDirectFeedback, iFeedback, aStyle); |
|
38 }; |
|
39 |
|
40 |
|
41 void CTactileFeedbackInterfaceLCDUI::RegisterFeedbackArea(void* aControl, TInt aControlType, TInt aAreaIndex, TInt aX, TInt aY, TInt aWidth, TInt aHeight, TTouchLogicalFeedback aStyle) |
|
42 { |
|
43 TRect feedbackRect(aX, aY, aX + aWidth, aY + aHeight); |
|
44 |
|
45 MMIDTactileFeedbackComponent* tactileComponent = NULL; |
|
46 |
|
47 if (aControlType == 1) // Canvas |
|
48 { |
|
49 MMIDCanvas* control = MIDUnhand<MMIDCanvas>((TInt)aControl); |
|
50 tactileComponent = control->TactileFeedbackComponent(); |
|
51 } |
|
52 else if (aControlType == 2) //CustomItem |
|
53 { |
|
54 MMIDCustomItem* control = MIDUnhand<MMIDCustomItem>((TInt)aControl); |
|
55 tactileComponent = control->TactileFeedbackComponent(); |
|
56 } |
|
57 |
|
58 iLcduiToolkit->ExecuteTrap(&_RegisterFeedbackAreaForComponent, tactileComponent, aAreaIndex, feedbackRect, aStyle); |
|
59 }; |
|
60 |
|
61 |
|
62 void CTactileFeedbackInterfaceLCDUI::UnregisterFeedbackArea(void* aControl, TInt aControlType, TInt aAreaIndex) |
|
63 { |
|
64 MMIDTactileFeedbackComponent* tactileComponent = NULL; |
|
65 |
|
66 if (aControlType == 1) // Canvas |
|
67 { |
|
68 MMIDCanvas* control = MIDUnhand<MMIDCanvas>((TInt)aControl); |
|
69 tactileComponent = control->TactileFeedbackComponent(); |
|
70 } |
|
71 else if (aControlType == 2) //CustomItem |
|
72 { |
|
73 MMIDCustomItem* control = MIDUnhand<MMIDCustomItem>((TInt)aControl); |
|
74 tactileComponent = control->TactileFeedbackComponent(); |
|
75 } |
|
76 |
|
77 |
|
78 iLcduiToolkit->ExecuteTrap(&_UnregisterFeedbackAreaForComponent, tactileComponent, aAreaIndex); |
|
79 } |
|
80 |
|
81 void CTactileFeedbackInterfaceLCDUI::UnregisterFeedbackForControl(void* aControl, TInt aControlType) |
|
82 { |
|
83 MMIDTactileFeedbackComponent* tactileComponent = NULL; |
|
84 |
|
85 if (aControlType == 1) // Canvas |
|
86 { |
|
87 MMIDCanvas* control = MIDUnhand<MMIDCanvas>((TInt)aControl); |
|
88 tactileComponent = control->TactileFeedbackComponent(); |
|
89 } |
|
90 else if (aControlType == 2) //CustomItem |
|
91 { |
|
92 MMIDCustomItem* control = MIDUnhand<MMIDCustomItem>((TInt)aControl); |
|
93 tactileComponent = control->TactileFeedbackComponent(); |
|
94 } |
|
95 |
|
96 |
|
97 iLcduiToolkit->ExecuteTrap(&_UnregisterFeedbackForControlForComponent, tactileComponent); |
|
98 } |
|
99 |
|
100 void CTactileFeedbackInterfaceLCDUI::MoveAreaToFirstPriority(void* aControl, TInt aControlType, TInt aAreaIndex) |
|
101 { |
|
102 MMIDTactileFeedbackComponent* tactileComponent = NULL; |
|
103 |
|
104 if (aControlType == 1) // Canvas |
|
105 { |
|
106 MMIDCanvas* control = MIDUnhand<MMIDCanvas>((TInt)aControl); |
|
107 tactileComponent = control->TactileFeedbackComponent(); |
|
108 } |
|
109 else if (aControlType == 2) //CustomItem |
|
110 { |
|
111 MMIDCustomItem* control = MIDUnhand<MMIDCustomItem>((TInt)aControl); |
|
112 tactileComponent = control->TactileFeedbackComponent(); |
|
113 } |
|
114 |
|
115 iLcduiToolkit->ExecuteTrap(&_MoveAreaToFirstPriorityForComponent, tactileComponent, aAreaIndex); |
|
116 } |
|
117 |
|
118 TBool CTactileFeedbackInterfaceLCDUI::IsTouchFeedbackSupported() |
|
119 { |
|
120 return iLcduiToolkit->Execute(&_IsTouchFeedbackSupported, iFeedback); |
|
121 } |
|
122 |
|
123 #endif |