|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // system includes |
|
19 #include <peninputlayout.h> |
|
20 #include <AknIconUtils.h> |
|
21 #include <coemain.h> |
|
22 #include <AknsUtils.h> |
|
23 #include <AknsDrawUtils.h> |
|
24 |
|
25 // user includes |
|
26 #include "peninputrepeatbuttonex.h" |
|
27 |
|
28 //default value for long press timer |
|
29 const TInt KLongPressInterval = 600000; |
|
30 |
|
31 //default value for repeat timer |
|
32 const TInt KRepeatInterval = 100000; |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // Constructor |
|
38 // --------------------------------------------------------- |
|
39 // |
|
40 CAknFepCtrlRepeatButtonEx* CAknFepCtrlRepeatButtonEx::NewLC(CFepUiLayout* aUiLayout, |
|
41 TInt aCtrlId, |
|
42 TAknsItemID aNormalID, |
|
43 TAknsItemID aPressedID, |
|
44 TAknsItemID aInactiveID, |
|
45 TInt aEvent, |
|
46 TInt aUnicode) |
|
47 { |
|
48 //PRINTF((_L("CAknFepCtrlRepeatButtonEx::NewLC(), aCtrlId = %d\n"), aCtrlId)); |
|
49 CAknFepCtrlRepeatButtonEx *self = new(ELeave) CAknFepCtrlRepeatButtonEx(aUiLayout, |
|
50 aCtrlId, |
|
51 aNormalID, |
|
52 aPressedID, |
|
53 aInactiveID, |
|
54 aEvent, |
|
55 aUnicode); |
|
56 |
|
57 CleanupStack::PushL(self); |
|
58 self->ConstructL(); |
|
59 |
|
60 return self; |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------- |
|
64 // Constructor |
|
65 // --------------------------------------------------------- |
|
66 // |
|
67 CAknFepCtrlRepeatButtonEx* CAknFepCtrlRepeatButtonEx::NewL(CFepUiLayout* aUiLayout, |
|
68 TInt aCtrlId, |
|
69 TAknsItemID aNormalID, |
|
70 TAknsItemID aPressedID, |
|
71 TAknsItemID aInactiveID, |
|
72 TInt aEvent, |
|
73 TInt aUnicode) |
|
74 { |
|
75 //PRINTF((_L("CAknFepCtrlRepeatButtonEx::NewL(), aCtrlId = %d\n"), aCtrlId)); |
|
76 CAknFepCtrlRepeatButtonEx *self = NewLC(aUiLayout, |
|
77 aCtrlId, |
|
78 aNormalID, |
|
79 aPressedID, |
|
80 aInactiveID, |
|
81 aEvent, |
|
82 aUnicode); |
|
83 CleanupStack::Pop(self); |
|
84 |
|
85 return self; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------- |
|
89 // Destructor |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 CAknFepCtrlRepeatButtonEx::~CAknFepCtrlRepeatButtonEx() |
|
93 { |
|
94 //PRINTF((_L("CAknFepCtrlRepeatButtonEx::~CAknFepCtrlRepeatButtonEx()\n"))); |
|
95 CancelRepeat(); |
|
96 |
|
97 delete iLongPressTimer; |
|
98 delete iRepeatTimer; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------- |
|
102 // Constructor |
|
103 // --------------------------------------------------------- |
|
104 // |
|
105 CAknFepCtrlRepeatButtonEx::CAknFepCtrlRepeatButtonEx(CFepUiLayout* aUiLayout, |
|
106 TInt aCtrlId, |
|
107 TAknsItemID aNormalID, |
|
108 TAknsItemID aPressedID, |
|
109 TAknsItemID aInactiveID, |
|
110 TInt aEvent, |
|
111 TInt aUnicode) |
|
112 :CAknFepCtrlCommonButton(aUiLayout, aCtrlId, aNormalID, aPressedID, aInactiveID), |
|
113 iEvent( aEvent ), iUnicode( aUnicode ) |
|
114 { |
|
115 iLongPressInterval = KLongPressInterval; |
|
116 iRepeatInterval = KRepeatInterval; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------- |
|
120 // Constructor |
|
121 // --------------------------------------------------------- |
|
122 // |
|
123 void CAknFepCtrlRepeatButtonEx::ConstructL() |
|
124 { |
|
125 //PRINTF((_L("CAknFepCtrlRepeatButtonEx::ConstructL()\n"))); |
|
126 BaseConstructL(); |
|
127 |
|
128 iLongPressTimer = CAknFepTimer::NewL(this); |
|
129 iRepeatTimer = CAknFepTimer::NewL(this); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------- |
|
133 // Time out event handler of both long press timer & repeat timer |
|
134 // --------------------------------------------------------- |
|
135 // |
|
136 void CAknFepCtrlRepeatButtonEx::HandleTimerOut(const CAknFepTimer* aTimer) |
|
137 { |
|
138 //PRINTF((_L("CAknFepCtrlRepeatButtonEx::HandleTimerOut()--"))); |
|
139 if (aTimer == iLongPressTimer) |
|
140 { |
|
141 //PRINTF((_L("long press timer timeout\n"))); |
|
142 iRepeatTimer->SetTimer(iRepeatInterval); |
|
143 } |
|
144 else |
|
145 { |
|
146 if (aTimer == iRepeatTimer) |
|
147 { |
|
148 //PRINTF((_L("repeat timer timeout: EEventButtonUp reported\n"))); |
|
149 if ( Unicode() ) |
|
150 { |
|
151 TInt unicode = Unicode(); |
|
152 TPtrC ptr = (TUint16*)(&unicode ) ; |
|
153 ReportEvent(Event(),ptr); |
|
154 } |
|
155 else |
|
156 { |
|
157 ReportEvent(EEventButtonUp); |
|
158 } |
|
159 |
|
160 #ifdef RD_TACTILE_FEEDBACK |
|
161 if (UiLayout()->SupportTactileFeedback()) |
|
162 { |
|
163 UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput); |
|
164 } |
|
165 #endif //RD_TACTILE_FEEDBACK |
|
166 iRepeatTimer->SetTimer(iRepeatInterval); |
|
167 } |
|
168 } |
|
169 } |
|
170 |
|
171 // --------------------------------------------------------- |
|
172 // Handle button down start long press timer |
|
173 // --------------------------------------------------------- |
|
174 // |
|
175 CFepUiBaseCtrl* CAknFepCtrlRepeatButtonEx::HandlePointerDownEventL(const TPoint& aPt) |
|
176 { |
|
177 //PRINTF((_L("CAknFepCtrlRepeatButtonEx::HandleButtonDown()\n"))); |
|
178 |
|
179 //PRINTF((_L("Set long press Timer\n"))); |
|
180 iLongPressTimer->SetTimer(iLongPressInterval); |
|
181 |
|
182 return CAknFepCtrlCommonButton::HandlePointerDownEventL(aPt); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------- |
|
186 // Handle button up cancel timers |
|
187 // --------------------------------------------------------- |
|
188 // |
|
189 CFepUiBaseCtrl* CAknFepCtrlRepeatButtonEx::HandlePointerUpEventL(const TPoint& aPt) |
|
190 { |
|
191 //PRINTF((_L("CAknFepCtrlRepeatButtonEx::HandleButtonUp()\n"))); |
|
192 |
|
193 CancelRepeat(); |
|
194 |
|
195 return CAknFepCtrlCommonButton::HandlePointerUpEventL(aPt); |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------- |
|
199 // Handle pointer levae event cancel timers |
|
200 // --------------------------------------------------------- |
|
201 // |
|
202 void CAknFepCtrlRepeatButtonEx::HandlePointerLeave(const TPoint& aPoint) |
|
203 { |
|
204 CAknFepCtrlCommonButton::HandlePointerLeave(aPoint); |
|
205 |
|
206 CancelRepeat(); |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------- |
|
210 // Set the repeat interval of repeat timer |
|
211 // --------------------------------------------------------- |
|
212 // |
|
213 void CAknFepCtrlRepeatButtonEx::SetRepeatInterval(const TTimeIntervalMicroSeconds32& aTime) |
|
214 { |
|
215 iRepeatInterval = aTime; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // Cancel timers |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 void CAknFepCtrlRepeatButtonEx::CancelRepeat() |
|
223 { |
|
224 //PRINTF((_L("CAknFepCtrlRepeatButton::CancelRepeat()\n"))); |
|
225 iLongPressTimer->Cancel(); |
|
226 iRepeatTimer->Cancel(); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------- |
|
230 // Unicode |
|
231 // --------------------------------------------------------- |
|
232 // |
|
233 TInt CAknFepCtrlRepeatButtonEx::Unicode() |
|
234 { |
|
235 return iUnicode; |
|
236 } |
|
237 |
|
238 // --------------------------------------------------------- |
|
239 // Event |
|
240 // --------------------------------------------------------- |
|
241 // |
|
242 TInt CAknFepCtrlRepeatButtonEx::Event() |
|
243 { |
|
244 return iEvent; |
|
245 } |
|
246 |
|
247 // End Of File |