author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:05:25 +0300 | |
branch | RCL_3 |
changeset 77 | 7cee158cb8cd |
parent 66 | 2455ef1f5bbc |
child 83 | 26b2b12093af |
permissions | -rw-r--r-- |
66 | 1 |
/* |
2 |
* Copyright (c) 2003-2006 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: The CMIDChoiceGroup listbox |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "CMIDChoiceGroupListBox.h" |
|
20 |
// API for iChoiceControl |
|
21 |
#include "CMIDChoiceGroupControl.h" |
|
22 |
#include "CMIDChoiceGroupModel.h" |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
23 |
// API for control item |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
24 |
#include "CMIDControlItem.h" |
66 | 25 |
|
26 |
#include <e32def.h> |
|
27 |
// using for CColumnListBoxData related to colors |
|
28 |
// and in HandleResourceChange function - setting icon array |
|
29 |
#include <eikclbd.h> |
|
30 |
#include <AknsFrameBackgroundControlContext.h> |
|
31 |
#include <AknUtils.h> |
|
32 |
#include <AknsDrawUtils.h> |
|
33 |
#include <skinlayout.cdl.h> |
|
34 |
#include <layoutmetadata.cdl.h> |
|
35 |
||
36 |
// LAF |
|
37 |
// AknLayoutScalable_Avkon::list_single_pane_cp2 |
|
38 |
#include <aknlayoutscalable_avkon.cdl.h> // LAF |
|
39 |
||
40 |
#include <j2me/jdebug.h> |
|
41 |
||
42 |
#undef TRAP_INSTRUMENTATION_LEAVE |
|
43 |
#define TRAP_INSTRUMENTATION_LEAVE(aResult) DEBUG_INT2("In CMIDChoiceGroupListBox.cpp, trapped method was called at line %D and got exception %D", __LINE__, aResult); |
|
44 |
||
45 |
||
46 |
CMIDChoiceGroupListBox::CMIDChoiceGroupListBox(CMIDChoiceGroupControl* aChoiceControl) |
|
47 |
: CAknColumnListBox() |
|
48 |
, iChoiceControl(aChoiceControl) |
|
49 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
50 |
, iHighlight(EFalse) |
|
51 |
, iTopVisibleItemIndex(KErrNotFound) |
|
52 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
53 |
{ |
|
54 |
ASSERT(iChoiceControl); |
|
55 |
} |
|
56 |
||
57 |
CMIDChoiceGroupListBox::~CMIDChoiceGroupListBox() |
|
58 |
{ |
|
59 |
} |
|
60 |
||
61 |
// Constructs the listbox with the model created and owned outside. |
|
62 |
// Makes sure the EKeepModel flag is set, in order to not destroy |
|
63 |
// the model when listbox is destroyed |
|
64 |
void CMIDChoiceGroupListBox::ConstructL( |
|
65 |
const CCoeControl* aParent, |
|
66 |
TInt aFlags, |
|
67 |
CMIDChoiceGroupModel* aModel) |
|
68 |
{ |
|
69 |
// Model is owned outside, set it here, so that when |
|
70 |
// CCAknColumnListBox::ConstructL() calls CreateModelL(), |
|
71 |
// it is already in place. Absolutely make sure that the |
|
72 |
// model owned outside flag is set |
|
73 |
iModel = aModel; |
|
74 |
aFlags |= EKeepModel; |
|
75 |
||
76 |
CAknColumnListBox::ConstructL(aParent, aFlags); |
|
77 |
iListBoxFlags &= ~ELoopScrolling; |
|
78 |
||
79 |
if (iChoiceControl->ChoiceType() == MMIDChoiceGroup::EPopup) |
|
80 |
{ |
|
81 |
TAknLayoutRect layoutRect; |
|
82 |
// layout in respect of the screen as only the height is needed |
|
83 |
layoutRect.LayoutRect(iEikonEnv->ScreenDevice()->SizeInPixels(), AknLayoutScalable_Avkon::list_single_pane_cp2(0).LayoutLine()); |
|
84 |
SetItemHeightL(layoutRect.Rect().Height()); |
|
85 |
} |
|
86 |
#ifndef RD_JAVA_FOR_S60_5_0_w49_2008 |
|
87 |
else |
|
88 |
{ |
|
89 |
// Disable flick/panning functionality |
|
90 |
// Disbled in OMJ DisableScrolling( ETrue ); |
|
91 |
} |
|
92 |
#endif // RD_JAVA_FOR_S60_5_0_w49_2008 |
|
93 |
||
94 |
#ifdef RD_SCALABLE_UI_V2 |
|
95 |
SetAllowStrayPointers(); |
|
96 |
#endif |
|
97 |
||
98 |
#ifdef RD_TACTILE_FEEDBACK |
|
99 |
iFeedback = MTouchFeedback::Instance(); |
|
100 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
101 |
iFeedback->EnableFeedbackForControl(this, FALSE); |
|
102 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
103 |
#endif //RD_TACTILE_FEEDBACK |
|
104 |
||
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
105 |
SetTextColors(); |
66 | 106 |
} |
107 |
||
108 |
// Overridden, because CEikListBox returns EKeyWasConsumed when |
|
109 |
// up is pressed on the first item, or down on last. We need to |
|
110 |
// return not consumed in order to make the form move focus |
|
111 |
// to other items |
|
112 |
// Offers key events to the listbox |
|
113 |
TKeyResponse CMIDChoiceGroupListBox::OfferKeyEventL( |
|
114 |
const TKeyEvent& aKeyEvent, |
|
115 |
TEventCode aType) |
|
116 |
{ |
|
117 |
// First save the currently selected item |
|
118 |
TInt oldCurrent = iView->CurrentItemIndex(); |
|
119 |
||
120 |
TKeyResponse resp = EKeyWasNotConsumed; |
|
121 |
||
122 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
123 |
if (iChoiceControl->ChoiceType() != MMIDChoiceGroup::EPopup) |
|
124 |
{ |
|
125 |
if (aType != EEventKey || iHighlight) |
|
126 |
{ |
|
127 |
// Do not pass the EEventKey to ListBox in case of first |
|
128 |
// HW key action after highlight was disabled. |
|
129 |
resp = CAknColumnListBox::OfferKeyEventL(aKeyEvent, aType); |
|
130 |
} |
|
131 |
else |
|
132 |
{ |
|
133 |
// This is first HW key action after highlight was disabled: |
|
134 |
// highlight should be enabled |
|
135 |
UpdateTopVisibleItemIndex(); |
|
136 |
if (iTopVisibleItemIndex > KErrNotFound) |
|
137 |
{ |
|
138 |
// First top visible element should be highlighted |
|
139 |
iView->SetCurrentItemIndex(iTopVisibleItemIndex); |
|
140 |
||
141 |
// Item drawer must know, that highlight should be enabled |
|
142 |
// from now. |
|
143 |
if (IsHighlightNeeded(oldCurrent,aKeyEvent)) |
|
144 |
{ |
|
145 |
SingleClickDisableHighlightL(EFalse); |
|
146 |
} |
|
147 |
resp = EKeyWasConsumed; |
|
148 |
iTopVisibleItemIndex = KErrNotFound; |
|
149 |
} |
|
150 |
// Enable highlight flag for this ChoiceGroup, even if top visible |
|
151 |
// element wasn't found (ChoiceGroup is now fully invisible). |
|
152 |
iHighlight = ETrue; |
|
153 |
} |
|
154 |
} |
|
155 |
else |
|
156 |
{ |
|
157 |
// For popup ChoiceGroup, handle key events in usual way |
|
158 |
resp = CAknColumnListBox::OfferKeyEventL(aKeyEvent, aType); |
|
159 |
} |
|
160 |
#else |
|
161 |
// Let the ListBox handle the key |
|
162 |
resp = CAknColumnListBox::OfferKeyEventL(aKeyEvent, aType); |
|
163 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
164 |
||
165 |
if (iChoiceControl->ChoiceType() != MMIDChoiceGroup::EPopup) |
|
166 |
{ |
|
167 |
// If the key was up or down, and the current item did not change, |
|
168 |
// we were apparently already on the first or last item. |
|
169 |
// Return EKeyWasNotConsumed so that the form knows to transfer focus |
|
170 |
// BUT ONLY if not used in a popup (otherwise the form will get it and |
|
171 |
// move focus under the popup) |
|
172 |
if (!IsHighlightNeeded(oldCurrent,aKeyEvent)) |
|
173 |
{ |
|
174 |
resp = EKeyWasNotConsumed; |
|
175 |
} |
|
176 |
} |
|
177 |
||
178 |
//For Popup ChoiceGroup in landscape mode we have to redraw listbox |
|
179 |
//to display background properly |
|
180 |
if (iChoiceControl->ChoiceType() == MMIDChoiceGroup::EPopup && |
|
181 |
Layout_Meta_Data::IsLandscapeOrientation() && |
|
182 |
(aKeyEvent.iCode == EKeyUpArrow || |
|
183 |
aKeyEvent.iCode == EKeyDownArrow)) |
|
184 |
{ |
|
185 |
DrawDeferred(); |
|
186 |
} |
|
187 |
||
188 |
return resp; |
|
189 |
} |
|
190 |
||
191 |
||
192 |
// Overridden in order to prevent the listbox from creating its |
|
193 |
// own model. |
|
194 |
void CMIDChoiceGroupListBox::CreateModelL() |
|
195 |
{ |
|
196 |
// Model should've already been given |
|
197 |
ASSERT(iModel); |
|
198 |
if (!iModel) |
|
199 |
{ |
|
200 |
User::Leave(KErrArgument); |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
void CMIDChoiceGroupListBox::SizeChanged() |
|
205 |
{ |
|
206 |
// Because SizeChanged() is the only method called by CAknPopupList during a screen |
|
207 |
// resolution change, we must call these two in here. If we don't, |
|
208 |
// open popup dialogs do not update their content during a screen resolution change |
|
209 |
// @see CMIDChoiceGroupListBox::HandleResolutionChange() and CAknPopupList::HandleResolutionChange(). |
|
210 |
if (iChoiceControl->ChoiceType() == MMIDChoiceGroup::EPopup) |
|
211 |
{ |
|
212 |
TRAP_IGNORE( |
|
213 |
iChoiceControl->SetupColumnsL(ItemDrawer()->ColumnData()); |
|
214 |
TAknLayoutRect layoutRect; |
|
215 |
// layout in respect of the screen as only the height is needed |
|
216 |
layoutRect.LayoutRect(iEikonEnv->ScreenDevice()->SizeInPixels(), AknLayoutScalable_Avkon::list_single_pane_cp2(0).LayoutLine()); |
|
217 |
SetItemHeightL(layoutRect.Rect().Height()); |
|
218 |
); |
|
219 |
} |
|
220 |
||
221 |
CAknColumnListBox::SizeChanged(); |
|
222 |
||
223 |
// Assure that non-popup choicegroup is updated correctly visually |
|
224 |
// after dynamic resolution change. |
|
225 |
TInt lbHeight = Rect().Height(); |
|
226 |
TInt lbItemHeight = iItemHeight; |
|
227 |
||
228 |
// check that listbox's size is already set |
|
229 |
if ((lbHeight > 0) && (lbItemHeight > 0) && (lbHeight >= lbItemHeight) && |
|
230 |
iChoiceControl && |
|
231 |
(iChoiceControl->ChoiceType() != MMIDChoiceGroup::EPopup)) |
|
232 |
{ |
|
233 |
TInt topItemIndex = TopItemIndex(); |
|
234 |
TInt bottomItemIndex = BottomItemIndex(); |
|
235 |
TInt currentItemIndex = CurrentItemIndex(); |
|
236 |
TInt numOfItems = (Model()) ? Model()->NumberOfItems() : 0; |
|
237 |
||
238 |
// check that listbox-view is set correctly |
|
239 |
if ((topItemIndex >= 0) && (bottomItemIndex >= topItemIndex) && |
|
240 |
(bottomItemIndex < numOfItems) && |
|
241 |
(currentItemIndex >= topItemIndex) && |
|
242 |
(currentItemIndex <= bottomItemIndex)) |
|
243 |
{ |
|
244 |
// number of actually/possible visible items |
|
245 |
TInt numOfActuallyVisibleItems = bottomItemIndex - topItemIndex + 1; |
|
246 |
TInt numOfPossiblyVisibleItems = lbHeight / lbItemHeight; |
|
247 |
||
248 |
// detect if it is possible to display more items than it is |
|
249 |
// currently displayed (this indicates that listbox-view is not |
|
250 |
// updated correctly after dynamic resolution change) and |
|
251 |
// eventually update listbox-view's top-item-index |
|
252 |
if ((numOfPossiblyVisibleItems > numOfActuallyVisibleItems) && |
|
253 |
(topItemIndex >= numOfPossiblyVisibleItems - |
|
254 |
numOfActuallyVisibleItems)) |
|
255 |
{ |
|
256 |
topItemIndex -= numOfPossiblyVisibleItems - |
|
257 |
numOfActuallyVisibleItems; |
|
258 |
SetTopItemIndex(topItemIndex); |
|
259 |
} |
|
260 |
} |
|
261 |
} |
|
262 |
} |
|
263 |
||
264 |
void CMIDChoiceGroupListBox::Draw(const TRect& aRect) const |
|
265 |
{ |
|
266 |
//For Popup ChoiceGroup we have to draw its background, |
|
267 |
//because native side doesn't do that properly. |
|
268 |
if (iChoiceControl->ChoiceType() == MMIDChoiceGroup::EPopup) |
|
269 |
{ |
|
270 |
CWindowGc& gc = SystemGc(); |
|
271 |
MAknsControlContext* cc = NULL; |
|
272 |
//create background context: |
|
273 |
//KAknsIIDQsnFrPopupCenter - id of proper background |
|
274 |
//for popup dialog, background is without borders |
|
275 |
TRAP_IGNORE(cc = CAknsBasicBackgroundControlContext::NewL( |
|
276 |
KAknsIIDQsnFrPopupCenter, |
|
277 |
aRect, |
|
278 |
EFalse)); |
|
279 |
if (cc) |
|
280 |
{ |
|
281 |
//draw background |
|
282 |
AknsDrawUtils::DrawBackground( |
|
283 |
AknsUtils::SkinInstance(), |
|
284 |
cc, |
|
285 |
NULL, |
|
286 |
gc, |
|
287 |
Position(), //current listobox position on popup dialog |
|
288 |
aRect, |
|
289 |
KAknsDrawParamDefault); |
|
290 |
} |
|
291 |
} |
|
292 |
||
293 |
CAknColumnListBox::Draw(aRect); |
|
294 |
} |
|
295 |
||
296 |
TTypeUid::Ptr CMIDChoiceGroupListBox::MopSupplyObject(TTypeUid aId) |
|
297 |
{ |
|
298 |
if (iChoiceControl->ChoiceType() != MMIDChoiceGroup::EPopup) |
|
299 |
{ |
|
300 |
return iChoiceControl->MopSupplyObject(aId); |
|
301 |
} |
|
302 |
else // no skinned background in popup list |
|
303 |
{ |
|
304 |
return CAknColumnListBox::MopSupplyObject(aId); |
|
305 |
} |
|
306 |
} |
|
307 |
||
308 |
/** This is currently only used for the open popup choice group items. For the normal |
|
309 |
closed items at the moment form won't pass the notification to them. They are instead |
|
310 |
recreated on a screen resolution change. See CMIChoiceGroupItem::ResolutionChange() and |
|
311 |
CMIChoiceGroupItem::ColorChange(). */ |
|
312 |
void CMIDChoiceGroupListBox::HandleResourceChange(TInt aType) |
|
313 |
{ |
|
314 |
if (aType == KEikColorResourceChange || |
|
315 |
aType == KAknsMessageSkinChange || aType == KUidValueCoeColorSchemeChangeEvent) |
|
316 |
{//skin or color scheme have changed |
|
317 |
TRAP_IGNORE(((CMIDChoiceGroupModel*)Model())->ReConstructSelectionIconsL()); |
|
318 |
ItemDrawer()->ColumnData()->SetIconArray(((CMIDChoiceGroupModel*)Model())->IconArray(ETrue)); |
|
319 |
||
320 |
SetTextColors(); |
|
321 |
} |
|
322 |
else if (aType == KEikDynamicLayoutVariantSwitch) |
|
323 |
{ |
|
324 |
// NOTE for the open popup choicegroup items: |
|
325 |
// CAknPopupList never calls HandleResourceChange() on the list box when aType |
|
326 |
// is KEikDynamicLayoutVariantSwitch so do not put any code here, |
|
327 |
// SizeChanged() will be called instead. |
|
328 |
} |
|
329 |
||
330 |
CAknColumnListBox::HandleResourceChange(aType); |
|
331 |
} |
|
332 |
||
333 |
/** Initialise the listbox text and background colors with values |
|
334 |
from LAF first, and then from the skin if this is supported. */ |
|
335 |
void CMIDChoiceGroupListBox::SetTextColors() |
|
336 |
{ |
|
337 |
CColumnListBoxData::TColors colors; |
|
338 |
||
339 |
colors.iText = AKN_LAF_COLOR_STATIC(215); |
|
340 |
colors.iHighlightedText = AKN_LAF_COLOR_STATIC(0); |
|
341 |
||
342 |
if (AknsUtils::AvkonSkinEnabled()) |
|
343 |
{ |
|
344 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
345 |
TRgb color; |
|
346 |
||
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
347 |
// Chose correct colors for elements |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
348 |
TInt logicalColor = KNonHighlightedItemTextColor; // non-highlighted |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
349 |
|
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
350 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
351 |
if (iChoiceControl |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
352 |
&& iChoiceControl->ChoiceType() != MMIDChoiceGroup::EPopup |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
353 |
&& iChoiceControl->ControlItem() |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
354 |
&& iChoiceControl->ControlItem()->IsHighlighted()) |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
355 |
{ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
356 |
logicalColor = KHighlightedItemTextColor; // highlighted |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
357 |
} |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
358 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
359 |
|
66 | 360 |
TInt error = AknsUtils::GetCachedColor(skin, |
361 |
color, |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
362 |
KAknsIIDQsnTextColors, |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
363 |
logicalColor); |
66 | 364 |
if (!error) |
365 |
{ |
|
366 |
colors.iText = color; |
|
367 |
} |
|
368 |
||
369 |
error = AknsUtils::GetCachedColor(skin, |
|
370 |
color, |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
371 |
KAknsIIDQsnTextColors, |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
372 |
logicalColor); |
66 | 373 |
if (!error) |
374 |
{ |
|
375 |
colors.iHighlightedText = color; |
|
376 |
} |
|
377 |
} |
|
378 |
||
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
379 |
if (View() && View()->ItemDrawer()) |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
380 |
{ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
381 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
382 |
View()->ItemDrawer()->SetFlags( |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
383 |
CListItemDrawer::EUseOverrideSkinTextColor); |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
384 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
385 |
View()->ItemDrawer()->SetTextColor(colors.iText); |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
386 |
View()->ItemDrawer()->SetHighlightedTextColor(colors.iHighlightedText); |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
387 |
} |
66 | 388 |
} |
389 |
||
390 |
||
391 |
void CMIDChoiceGroupListBox::PositionChanged() |
|
392 |
{ |
|
393 |
// Code copied from CEikListBox::SizeChanged() |
|
394 |
TRect clientRect = iBorder.InnerRect(Rect()); |
|
395 |
SetViewRectFromClientRect(clientRect); |
|
396 |
} |
|
397 |
||
398 |
#ifdef RD_SCALABLE_UI_V2 |
|
399 |
void CMIDChoiceGroupListBox::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
400 |
{ |
|
401 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
402 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
403 |
{ |
|
404 |
iUpEventSent = EFalse; |
|
405 |
iHighlight = EFalse; |
|
406 |
UpdateTopVisibleItemIndex(); |
|
407 |
} |
|
408 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
409 |
||
410 |
// In non-popup case, don't forward to base class the drag events |
|
411 |
// that occur outside the listbox |
|
412 |
||
413 |
#ifdef RD_TACTILE_FEEDBACK |
|
414 |
if ((aPointerEvent.iType == TPointerEvent::EButton1Down || |
|
415 |
aPointerEvent.iType == TPointerEvent::EButton1Up) && |
|
416 |
iChoiceControl->ChoiceType() == MMIDChoiceGroup::EPopup) |
|
417 |
{ |
|
418 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
419 |
iFeedback->InstantFeedback(ETouchFeedbackList); |
|
420 |
#else |
|
421 |
iFeedback->InstantFeedback(ETouchFeedbackBasic); |
|
422 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK |
|
423 |
} |
|
424 |
#endif //RD_TACTILE_FEEDBACK |
|
425 |
||
426 |
#ifndef RD_JAVA_S60_RELEASE_9_2 |
|
427 |
if (iChoiceControl->ChoiceType() != MMIDChoiceGroup::EPopup && |
|
428 |
aPointerEvent.iType == TPointerEvent::EDrag) |
|
429 |
{ |
|
430 |
||
431 |
if (!View()->ViewRect().Contains(aPointerEvent.iPosition)) |
|
432 |
{ |
|
433 |
return; |
|
434 |
} |
|
435 |
else |
|
436 |
{ |
|
437 |
||
438 |
// this flag must be set in order that drag events can change |
|
439 |
// the focused listbox item |
|
440 |
iListBoxFlags |= ELeftDownInViewRect; |
|
441 |
} |
|
442 |
} |
|
443 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
444 |
||
445 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
446 |
if (aPointerEvent.iType == TPointerEvent::EDrag && !iUpEventSent && iChoiceControl->Form()->PhysicsScrolling()) |
|
447 |
{ |
|
448 |
TPointerEvent pointerEvent = aPointerEvent; |
|
449 |
pointerEvent.iType = TPointerEvent::EButton1Up; |
|
450 |
CAknColumnListBox::HandlePointerEventL(pointerEvent); |
|
451 |
iUpEventSent = ETrue; |
|
452 |
} |
|
453 |
else if (!iUpEventSent) |
|
454 |
{ |
|
455 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
456 |
CAknColumnListBox::HandlePointerEventL(aPointerEvent); |
|
457 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
458 |
if (aPointerEvent.iType == TPointerEvent::EButton1Up) |
|
459 |
{ |
|
460 |
iUpEventSent = ETrue; |
|
461 |
} |
|
462 |
} |
|
463 |
||
464 |
#endif // RD_JAVA_S60_RELEASE_9_2 |
|
465 |
||
466 |
//For Popup ChoiceGroup in landscape mode we have to redraw listbox |
|
467 |
//to display background properly |
|
468 |
if (iChoiceControl->ChoiceType() == MMIDChoiceGroup::EPopup && |
|
469 |
Layout_Meta_Data::IsLandscapeOrientation()) |
|
470 |
{ |
|
471 |
DrawDeferred(); |
|
472 |
} |
|
473 |
} |
|
474 |
#endif |
|
475 |
||
476 |
/** |
|
477 |
* Checks if highlight is needed |
|
478 |
* Returns EFalse if there should be no highlight |
|
479 |
*/ |
|
480 |
TBool CMIDChoiceGroupListBox::IsHighlightNeeded(TInt aCurrentSelected, |
|
481 |
const TKeyEvent& aKeyEvent) |
|
482 |
{ |
|
483 |
// If the key was up or down, and the current item did not change, |
|
484 |
// we were apparently already on the first or last item. |
|
485 |
// Return EFalse when highlight should be lost |
|
486 |
TBool isHighlightNeeded = ETrue; |
|
487 |
TInt newCurrent = iView->CurrentItemIndex(); |
|
488 |
TBool change = aCurrentSelected != newCurrent; |
|
489 |
TInt lastItemIdx = KErrNotFound; |
|
490 |
||
491 |
if (iModel) |
|
492 |
{ |
|
493 |
lastItemIdx = iModel->NumberOfItems() - 1; |
|
494 |
} |
|
495 |
if ((aKeyEvent.iCode == EKeyUpArrow) && !change && (newCurrent == 0)) |
|
496 |
{ |
|
497 |
isHighlightNeeded = EFalse; |
|
498 |
} |
|
499 |
if ((aKeyEvent.iCode == EKeyDownArrow) && !change && |
|
500 |
(newCurrent == lastItemIdx)) |
|
501 |
{ |
|
502 |
isHighlightNeeded = EFalse; |
|
503 |
} |
|
504 |
return isHighlightNeeded; |
|
505 |
} |
|
506 |
||
507 |
#ifdef RD_JAVA_S60_RELEASE_9_2 |
|
508 |
/** |
|
509 |
* Returns index of ChoiceGroup element, which is the first |
|
510 |
* visible element in ChoiceGroup from top of Form. |
|
511 |
* Used in CMIDChoiceGroupControl, which needs to know |
|
512 |
* current element for possible scrolling |
|
513 |
* (@see CMIDChoiceGroupControl::RequestScrollIfNeededL()). |
|
514 |
*/ |
|
515 |
TInt CMIDChoiceGroupListBox::TopVisibleItemIndex() |
|
516 |
{ |
|
517 |
return iTopVisibleItemIndex; |
|
518 |
} |
|
519 |
||
520 |
/** |
|
521 |
* Fuction calculates index of element, which is the first |
|
522 |
* visible element in ChoiceGroup from top of Form. |
|
523 |
*/ |
|
524 |
void CMIDChoiceGroupListBox::UpdateTopVisibleItemIndex() |
|
525 |
{ |
|
526 |
if (!iHighlight) |
|
527 |
{ |
|
528 |
// There is touch interaction, so we need index for element, |
|
529 |
// which will be highlighted, when user starts using HW keys |
|
530 |
if (iPosition.iY < 0) |
|
531 |
{ |
|
532 |
// ChoiceGroup is now partially visible and its top edge is |
|
533 |
// above the Form top edge. |
|
534 |
||
535 |
// Calculate index of first (partially) visible element |
|
536 |
iTopVisibleItemIndex = Abs(iPosition.iY) / iView->ItemHeight(); |
|
537 |
TRect lbitemRect = TRect( |
|
538 |
iView->ItemPos(iTopVisibleItemIndex), |
|
539 |
iView->ItemSize(iTopVisibleItemIndex)); |
|
540 |
if (lbitemRect.iTl.iY < 0) |
|
541 |
{ |
|
542 |
// Item is really partially visible. |
|
543 |
// Because we don't want index of partially visible item, |
|
544 |
// move index to next item |
|
545 |
iTopVisibleItemIndex++; |
|
546 |
} |
|
547 |
if (iTopVisibleItemIndex >= iModel->NumberOfItems()) |
|
548 |
{ |
|
549 |
// ChoiceGroup is fully invisible (whole rect is above |
|
550 |
// the Form top edge): no element is visible now |
|
551 |
iTopVisibleItemIndex = KErrNotFound; |
|
552 |
} |
|
553 |
} |
|
554 |
else |
|
555 |
{ |
|
556 |
// Top item idge is lower than top edge of Form - is visible |
|
557 |
iTopVisibleItemIndex = 0; |
|
558 |
} |
|
559 |
} |
|
560 |
else |
|
561 |
{ |
|
562 |
// In case of HW keys interaction, there is no highlight, |
|
563 |
// so we don't need highlight any element |
|
564 |
iTopVisibleItemIndex = KErrNotFound; |
|
565 |
} |
|
566 |
} |
|
567 |
/** |
|
568 |
* Fuction sets ESingleClickDisabledHighlight - item drawer flags |
|
569 |
* and reports current highlight element change event |
|
570 |
*/ |
|
571 |
void CMIDChoiceGroupListBox::SingleClickDisableHighlightL(TBool aDisable) |
|
572 |
{ |
|
573 |
// Item drawer must know, that highlight should be enabled/disabled |
|
574 |
// when listbox element taped |
|
575 |
CColumnListBoxItemDrawer* drawer = ItemDrawer(); |
|
576 |
if (drawer) |
|
577 |
{ |
|
578 |
if (aDisable) |
|
579 |
{ |
|
580 |
if (iHighlight) |
|
581 |
{ |
|
582 |
// Set flags in Item drawer so that highlight could be disabled |
|
583 |
drawer->SetFlags(CListItemDrawer::ESingleClickDisabledHighlight); |
|
584 |
iHighlight = EFalse; |
|
585 |
iTopVisibleItemIndex = KErrNotFound; |
|
586 |
} |
|
587 |
} |
|
588 |
else |
|
589 |
{ |
|
590 |
// Set flags in Item drawer so that highlight could be enabled |
|
591 |
drawer->ClearFlags(CListItemDrawer::ESingleClickDisabledHighlight); |
|
592 |
} |
|
593 |
} |
|
594 |
// Report, that current highlighted element changed |
|
595 |
ReportEventL(MCoeControlObserver::EEventStateChanged); |
|
596 |
DrawNow(); |
|
597 |
} |
|
598 |
||
599 |
void CMIDChoiceGroupListBox::SetHighlight(TBool aVisible) |
|
600 |
{ |
|
601 |
iHighlight = aVisible; |
|
602 |
} |
|
603 |
||
604 |
TBool CMIDChoiceGroupListBox::GetHighlight() |
|
605 |
{ |
|
606 |
return iHighlight; |
|
607 |
} |
|
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
608 |
|
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
609 |
void CMIDChoiceGroupListBox::UpdateColors() |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
610 |
{ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
611 |
SetTextColors(); |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
612 |
} |
66 | 613 |
#endif // RD_JAVA_S60_RELEASE_9_2 |