66
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2007 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: CMIDChoiceGroupItem implements the MID Form ChoiceGroup item
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include <avkon.mbg>
|
|
20 |
#include <j2me/jdebug.h>
|
|
21 |
|
|
22 |
#include "CMIDChoiceGroupItem.h"
|
|
23 |
#include "CMIDChoiceGroupControl.h"
|
|
24 |
// API for iLabelControl
|
|
25 |
#include "CMIDItemLabel.h"
|
|
26 |
#include "CMIDCommandList.h"
|
|
27 |
#include "CMIDCommand.h"
|
|
28 |
#include "CMIDPopupNoteController.h"
|
|
29 |
// needed API for CMIDDisplayable and CMIDCommandList in UpdateCommands function
|
|
30 |
#include "CMIDDisplayable.h"
|
|
31 |
|
|
32 |
/** This macro is executed each time a trapped call returns an error code different than KErrNone */
|
|
33 |
#undef TRAP_INSTRUMENTATION_LEAVE
|
|
34 |
#define TRAP_INSTRUMENTATION_LEAVE(aResult) DEBUG_INT2("In CMIDChoiceGroupItem.cpp, trapped method was called at line %D and got exception %D", __LINE__, aResult);
|
|
35 |
|
|
36 |
|
|
37 |
// class CMIDChoiceGroupItem
|
|
38 |
|
|
39 |
CMIDChoiceGroupItem* CMIDChoiceGroupItem::NewL(
|
|
40 |
MMIDEnv& aMIDEnv, const TDesC& aLabel, TInt aType,
|
|
41 |
RArray<TPtrC>& aStringArray, RArray<MMIDImage*>& aImageArray, CMIDUIManager* aUIManager)
|
|
42 |
{
|
|
43 |
CMIDChoiceGroupItem* self = new(ELeave) CMIDChoiceGroupItem(
|
|
44 |
aMIDEnv, aType, aStringArray, aImageArray, aUIManager);
|
|
45 |
CleanupStack::PushL(self);
|
|
46 |
self->ConstructL(aLabel);
|
|
47 |
CleanupStack::Pop(self);
|
|
48 |
return self;
|
|
49 |
}
|
|
50 |
|
|
51 |
|
|
52 |
CMIDChoiceGroupItem::CMIDChoiceGroupItem(
|
|
53 |
MMIDEnv& aMIDEnv,
|
|
54 |
TInt aType,
|
|
55 |
RArray<TPtrC>& aStringArray,
|
|
56 |
RArray<MMIDImage*>& aImageArray,
|
|
57 |
CMIDUIManager* aUIManager)
|
|
58 |
: CMIDControlItem(MMIDItem::EDefault, aUIManager),
|
|
59 |
iChoiceType((MMIDChoiceGroup::TChoiceType) aType),
|
|
60 |
iFitPolicy(EWrapDefault),
|
|
61 |
iMIDEnv(aMIDEnv),
|
|
62 |
iStringArray(aStringArray),
|
|
63 |
iImageArray(aImageArray)
|
|
64 |
{
|
|
65 |
// Set this to be a MMIDItem interface implementor
|
|
66 |
iMMidItem = this;
|
|
67 |
|
|
68 |
// This is a focusing item
|
|
69 |
SetFocusing(ETrue);
|
|
70 |
}
|
|
71 |
|
|
72 |
CMIDChoiceGroupItem::~CMIDChoiceGroupItem()
|
|
73 |
{
|
|
74 |
delete iChoiceGroupControl;
|
|
75 |
if (iSelectCommand)
|
|
76 |
{
|
|
77 |
iSelectCommand->SetObserver(NULL);
|
|
78 |
iSelectCommand->Dispose();
|
|
79 |
iSelectCommand = NULL;
|
|
80 |
}
|
|
81 |
if (iMarkCommand)
|
|
82 |
{
|
|
83 |
iMarkCommand->SetObserver(NULL);
|
|
84 |
iMarkCommand->Dispose();
|
|
85 |
iMarkCommand = NULL;
|
|
86 |
}
|
|
87 |
if (iUnmarkCommand)
|
|
88 |
{
|
|
89 |
iUnmarkCommand->SetObserver(NULL);
|
|
90 |
iUnmarkCommand->Dispose();
|
|
91 |
iUnmarkCommand = NULL;
|
|
92 |
}
|
|
93 |
}
|
|
94 |
|
|
95 |
void CMIDChoiceGroupItem::ConstructL(const TDesC& aLabel)
|
|
96 |
{
|
|
97 |
// Allow parent to construct parts that are common
|
|
98 |
CMIDControlItem::ConstructL();
|
|
99 |
|
|
100 |
// Create built-in commands to makes selections in the list
|
|
101 |
HBufC* label = NULL;
|
|
102 |
if (iChoiceType == EPopup)
|
|
103 |
{
|
|
104 |
label = iEikonEnv->AllocReadResourceL(R_QTN_MSK_CHANGE);
|
|
105 |
}
|
|
106 |
else
|
|
107 |
{
|
|
108 |
label = iEikonEnv->AllocReadResourceL(R_QTN_MSK_SELECT);
|
|
109 |
}
|
|
110 |
CleanupStack::PushL(label);
|
|
111 |
iSelectCommand = CMIDCommand::NewBuiltInCommandL(label->Des(),
|
|
112 |
CMIDCommand::EItem, CMIDCommand::EChoiceGroupSelectCommandId);
|
|
113 |
CleanupStack::PopAndDestroy(label); // command creates a copy of the string
|
|
114 |
label = iEikonEnv->AllocReadResourceL(R_QTN_MSK_MARK);
|
|
115 |
CleanupStack::PushL(label);
|
|
116 |
iMarkCommand = CMIDCommand::NewBuiltInCommandL(label->Des(),
|
|
117 |
CMIDCommand::EItem, CMIDCommand::EChoiceGroupMarkCommandId);
|
|
118 |
CleanupStack::PopAndDestroy(label); // command creates a copy of the string
|
|
119 |
label = iEikonEnv->AllocReadResourceL(R_QTN_MSK_UNMARK);
|
|
120 |
CleanupStack::PushL(label);
|
|
121 |
iUnmarkCommand = CMIDCommand::NewBuiltInCommandL(label->Des(),
|
|
122 |
CMIDCommand::EItem, CMIDCommand::EChoiceGroupUnmarkCommandId);
|
|
123 |
CleanupStack::PopAndDestroy(label); // command creates a copy of the string
|
|
124 |
iSelectCommand->SetObserver(this);
|
|
125 |
iMarkCommand->SetObserver(this);
|
|
126 |
iUnmarkCommand->SetObserver(this);
|
|
127 |
if (iChoiceType == EPopup)
|
|
128 |
{ // in popup the command is always available
|
|
129 |
SetBuiltInMSKCommand(iSelectCommand);
|
|
130 |
}
|
|
131 |
|
|
132 |
// Parent created label control, set label in it
|
|
133 |
SetLabelL(aLabel);
|
|
134 |
iLabelControl->SetWidthL(FormClientAreaWidth());
|
|
135 |
|
|
136 |
// Create the choicegroup control to hold the items
|
|
137 |
// passed in. The actual control is created when the
|
|
138 |
// choicegroup item is added to a form, otherwise it won't
|
|
139 |
// have a parent window, and the listbox doesn't like that
|
|
140 |
iChoiceGroupControl = new(ELeave) CMIDChoiceGroupControl(iChoiceType, this);
|
|
141 |
iChoiceGroupControl->ConstructL(iStringArray, iImageArray);
|
|
142 |
|
|
143 |
// Spy on control
|
|
144 |
iChoiceGroupControl->SetObserver(this);
|
|
145 |
|
|
146 |
#ifdef RD_SCALABLE_UI_V2
|
|
147 |
SetAllowStrayPointers();
|
|
148 |
#endif
|
|
149 |
|
|
150 |
// This control is ready
|
|
151 |
ActivateL();
|
|
152 |
}
|
|
153 |
|
|
154 |
void CMIDChoiceGroupItem::UpdateCommands()
|
|
155 |
{
|
|
156 |
// MSK
|
|
157 |
// This method must be called when ever the current list item or list selection changes.
|
|
158 |
// It sets the command such that it tells the user what can be done next. E.g. in exlusive
|
|
159 |
// list if current item is selected, then we enable context sensitive menu by setting
|
|
160 |
// MSK command to NULL. In multiple lists, the command label changes depending on the
|
|
161 |
// selected state of the current list item.
|
|
162 |
CMIDCommand* cmd = iSelectCommand;
|
|
163 |
if (iChoiceType == EExclusive)
|
|
164 |
{
|
|
165 |
TInt numberOfOkMenuCmds(0);
|
|
166 |
if (iForm)
|
|
167 |
{ // check for number of context menu commands
|
|
168 |
CMIDDisplayable& displayable = iForm->CurrentDisplayable();
|
|
169 |
numberOfOkMenuCmds = displayable.NumCommandsForOkOptionsMenu();
|
|
170 |
}
|
|
171 |
// If item is selected and there are commands for context menu
|
|
172 |
// then context menu should be displayed - set MSK command to NULL.
|
|
173 |
// Since number of context menu commands queried from CMIDDisplayable
|
|
174 |
// may not be synchronized with iCommandList at this stage, we also
|
|
175 |
// check the number of commands in iCommandList.
|
|
176 |
if (iChoiceGroupControl->IsCurrentItemSelected() &&
|
|
177 |
(DefaultCommand() || numberOfOkMenuCmds > 0 ||
|
|
178 |
iCommandList->Count() > 0))
|
|
179 |
{
|
|
180 |
cmd = NULL;
|
|
181 |
}
|
|
182 |
}
|
|
183 |
else if (iChoiceType == EMultiple)
|
|
184 |
{
|
|
185 |
cmd = iChoiceGroupControl->IsCurrentItemSelected() ? iUnmarkCommand : iMarkCommand;
|
|
186 |
}
|
|
187 |
|
|
188 |
// If choice group is empty, MSK command is set to null,
|
|
189 |
// except in popup case "change" command is always shown.
|
|
190 |
if (iChoiceType != EPopup && iChoiceGroupControl->NumberOfElements() == 0)
|
|
191 |
{
|
|
192 |
cmd = NULL;
|
|
193 |
}
|
|
194 |
|
|
195 |
SetBuiltInMSKCommand(cmd);
|
|
196 |
#ifndef RD_JAVA_S60_RELEASE_9_2
|
|
197 |
iChoiceGroupControl->ShowInfoPopup();
|
|
198 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
199 |
}
|
|
200 |
|
|
201 |
// msk
|
|
202 |
TBool CMIDChoiceGroupItem::ProcessCommandL(CMIDCommand* /*aCommand*/)
|
|
203 |
{
|
|
204 |
if (iChoiceType == EPopup)
|
|
205 |
{
|
|
206 |
iChoiceGroupControl->DoPopupL();
|
|
207 |
}
|
|
208 |
else // for multiple and exclusive
|
|
209 |
{
|
|
210 |
// toggle selection
|
|
211 |
iChoiceGroupControl->ToggleCurrentItemSelectionL();
|
|
212 |
}
|
|
213 |
return ETrue;
|
|
214 |
}
|
|
215 |
|
|
216 |
|
|
217 |
// Updates the commands when the form that the item is on becomes the current.
|
|
218 |
// After LAF changes: If the form is not the current displayable anymore, closes the popup
|
|
219 |
void CMIDChoiceGroupItem::HandleCurrentL(TBool aCurrent)
|
|
220 |
{
|
|
221 |
if (!aCurrent && iChoiceGroupControl && iChoiceType == MMIDChoiceGroup::EPopup)
|
|
222 |
{
|
|
223 |
iChoiceGroupControl->ClosePopup();
|
|
224 |
}
|
|
225 |
if (aCurrent)
|
|
226 |
{
|
|
227 |
UpdateCommands();
|
|
228 |
}
|
|
229 |
}
|
|
230 |
|
|
231 |
|
|
232 |
// Inserts a new element in the choice
|
|
233 |
void CMIDChoiceGroupItem::InsertElementL(TInt aIndex, const TDesC& aText, MMIDImage* aImage)
|
|
234 |
{
|
|
235 |
ASSERT(iChoiceGroupControl);
|
|
236 |
iChoiceGroupControl->InsertElementL(aIndex, aText, aImage);
|
|
237 |
UpdateCommands();
|
|
238 |
}
|
|
239 |
|
|
240 |
// Deletes an element from the choice
|
|
241 |
void CMIDChoiceGroupItem::DeleteElementL(TInt aIndex)
|
|
242 |
{
|
|
243 |
ASSERT(iChoiceGroupControl);
|
|
244 |
iChoiceGroupControl->DeleteElementL(aIndex);
|
|
245 |
UpdateCommands();
|
|
246 |
}
|
|
247 |
|
|
248 |
// Deletes all elements
|
|
249 |
void CMIDChoiceGroupItem::DeleteAllL()
|
|
250 |
{
|
|
251 |
ASSERT(iChoiceGroupControl);
|
|
252 |
iChoiceGroupControl->DeleteAllL();
|
|
253 |
UpdateCommands();
|
|
254 |
}
|
|
255 |
|
|
256 |
// Sets properties of element at <aIndex>
|
|
257 |
void CMIDChoiceGroupItem::SetElementL(TInt aIndex, const TDesC& aText, MMIDImage* aImage)
|
|
258 |
{
|
|
259 |
ASSERT(iChoiceGroupControl);
|
|
260 |
iChoiceGroupControl->SetElementL(aIndex, aText, aImage);
|
|
261 |
}
|
|
262 |
|
|
263 |
// Sets selection state of element at <aIndex>
|
|
264 |
void CMIDChoiceGroupItem::SelectElementL(TInt aIndex, TBool aSelected)
|
|
265 |
{
|
|
266 |
ASSERT(iChoiceGroupControl);
|
|
267 |
iChoiceGroupControl->SelectElementL(aIndex, aSelected);
|
|
268 |
}
|
|
269 |
|
|
270 |
// Returns selection state of element at <aIndex>
|
|
271 |
TBool CMIDChoiceGroupItem::IsSelected(TInt aIndex)
|
|
272 |
{
|
|
273 |
ASSERT(iChoiceGroupControl);
|
|
274 |
return iChoiceGroupControl->IsSelected(aIndex);
|
|
275 |
}
|
|
276 |
|
|
277 |
// Sets element text font
|
|
278 |
void CMIDChoiceGroupItem::SetFontL(TInt aIndex, MMIDFont* aFont)
|
|
279 |
{
|
|
280 |
ASSERT(iChoiceGroupControl);
|
|
281 |
iChoiceGroupControl->SetFontL(aIndex, aFont);
|
|
282 |
}
|
|
283 |
|
|
284 |
// Sets element text fit policy
|
|
285 |
void CMIDChoiceGroupItem::SetFitPolicyL(TInt aFitPolicy)
|
|
286 |
{
|
|
287 |
ASSERT(iChoiceGroupControl);
|
|
288 |
iChoiceGroupControl->SetFitPolicyL(aFitPolicy);
|
|
289 |
}
|
|
290 |
|
|
291 |
// --- from MMIDItem ---
|
|
292 |
|
|
293 |
|
|
294 |
// --- from CCoeControl ---
|
|
295 |
|
|
296 |
// Set the containing window
|
|
297 |
void CMIDChoiceGroupItem::SetContainerWindowL(const CCoeControl& aContainer)
|
|
298 |
{
|
|
299 |
// Set this controls parent
|
|
300 |
CMIDControlItem::SetContainerWindowL(aContainer);
|
|
301 |
SetObserver(iForm);
|
|
302 |
}
|
|
303 |
|
|
304 |
|
|
305 |
// Count component controls in this compound control
|
|
306 |
TInt CMIDChoiceGroupItem::CountComponentControls() const
|
|
307 |
{
|
|
308 |
TInt count = 0;
|
|
309 |
CCoeControl* controls[] = { iLabelControl, iChoiceGroupControl };
|
|
310 |
for (TUint ii = 0; ii < sizeof(controls) / sizeof(CCoeControl*); ii++)
|
|
311 |
{
|
|
312 |
if (controls[ii])
|
|
313 |
{
|
|
314 |
count++;
|
|
315 |
}
|
|
316 |
}
|
|
317 |
return count;
|
|
318 |
}
|
|
319 |
|
|
320 |
|
|
321 |
// Return requested component control
|
|
322 |
CCoeControl* CMIDChoiceGroupItem::ComponentControl(TInt aIndex) const
|
|
323 |
{
|
|
324 |
CCoeControl* controls[] = { iLabelControl, iChoiceGroupControl};
|
|
325 |
|
|
326 |
for (TUint ii=0; ii < sizeof(controls) / sizeof(CCoeControl*); ii++)
|
|
327 |
{
|
|
328 |
// Index is decremented only if control is not NULL
|
|
329 |
if ((controls[ii]) && (aIndex-- == 0))
|
|
330 |
{
|
|
331 |
return controls[ii];
|
|
332 |
}
|
|
333 |
}
|
|
334 |
return NULL;
|
|
335 |
}
|
|
336 |
|
|
337 |
|
|
338 |
// Calculate size and layout
|
|
339 |
void CMIDChoiceGroupItem::SizeChanged()
|
|
340 |
{
|
|
341 |
TRect labelRect;
|
|
342 |
TRect choiceRect;
|
|
343 |
|
|
344 |
CalcChildSizes(Rect(), labelRect, choiceRect);
|
|
345 |
|
|
346 |
if (iLabelControl)
|
|
347 |
{
|
|
348 |
iLabelControl->SetRect(labelRect);
|
|
349 |
}
|
|
350 |
|
|
351 |
if (iChoiceGroupControl)
|
|
352 |
{
|
|
353 |
iChoiceGroupControl->SetRect(choiceRect);
|
|
354 |
}
|
|
355 |
|
|
356 |
CMIDControlItem::SizeChanged();
|
|
357 |
}
|
|
358 |
|
|
359 |
|
|
360 |
// Calculates and returns the minimum size of this item
|
|
361 |
TSize CMIDChoiceGroupItem::MinimumSize()
|
|
362 |
{
|
|
363 |
ASSERT(iChoiceGroupControl);
|
|
364 |
|
|
365 |
TInt height = LabelHeight();
|
|
366 |
|
|
367 |
if (height == 0 && iChoiceGroupControl->NumberOfElements() == 0)
|
|
368 |
{
|
|
369 |
return TSize(0, 0);
|
|
370 |
}
|
|
371 |
else
|
|
372 |
{
|
|
373 |
height += iChoiceGroupControl->MinimumSize().iHeight;
|
|
374 |
return TSize(FormClientAreaWidth(), height);
|
|
375 |
}
|
|
376 |
}
|
|
377 |
|
|
378 |
|
|
379 |
// Offers key events to the choicegroup control.
|
|
380 |
TKeyResponse CMIDChoiceGroupItem::OfferKeyEventL(
|
|
381 |
const TKeyEvent& aKeyEvent,
|
|
382 |
TEventCode aType)
|
|
383 |
{
|
|
384 |
// For now, just offer key events to choice control
|
|
385 |
TKeyResponse resp = EKeyWasNotConsumed;
|
|
386 |
|
|
387 |
if (iChoiceGroupControl)
|
|
388 |
{
|
|
389 |
resp = iChoiceGroupControl->OfferKeyEventL(aKeyEvent, aType);
|
|
390 |
}
|
|
391 |
|
|
392 |
return resp;
|
|
393 |
}
|
|
394 |
|
|
395 |
// Responds to focus change.
|
|
396 |
// From CCoeControl.
|
|
397 |
void CMIDChoiceGroupItem::FocusChanged(TDrawNow aDrawNow)
|
|
398 |
{
|
|
399 |
CMIDControlItem::FocusChanged(aDrawNow);
|
|
400 |
|
|
401 |
// update focus state of choice group control regarding to current focus state
|
|
402 |
if (iChoiceGroupControl)
|
|
403 |
{
|
|
404 |
iChoiceGroupControl->SetFocus(IsFocused(), aDrawNow);
|
|
405 |
}
|
|
406 |
}
|
|
407 |
|
|
408 |
|
|
409 |
#ifdef RD_SCALABLE_UI_V2
|
|
410 |
void CMIDChoiceGroupItem::HandlePointerEventL(const TPointerEvent& aPointerEvent)
|
|
411 |
{
|
|
412 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
413 |
if (!AknLayoutUtils::PenEnabled())
|
|
414 |
{
|
|
415 |
return;
|
|
416 |
}
|
|
417 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down)
|
|
418 |
{
|
|
419 |
iLongTapDetected = EFalse;
|
|
420 |
}
|
|
421 |
iLongTapDetected = iForm->TryDetectLongTapL(aPointerEvent);
|
|
422 |
#else
|
|
423 |
if (!AknLayoutUtils::PenEnabled() || iForm->TryDetectLongTapL(aPointerEvent))
|
|
424 |
{
|
|
425 |
return;
|
|
426 |
}
|
|
427 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
428 |
|
|
429 |
switch (aPointerEvent.iType)
|
|
430 |
{
|
|
431 |
case TPointerEvent::EDrag:
|
|
432 |
{
|
|
433 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
434 |
if (iLongTapDetected)
|
|
435 |
{
|
|
436 |
return;
|
|
437 |
}
|
|
438 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
439 |
|
|
440 |
if (aPointerEvent.iPosition.iY >= 0 &&
|
|
441 |
aPointerEvent.iPosition.iY < FormRect().Height() &&
|
|
442 |
iChoiceGroupControl->Rect().Contains(aPointerEvent.iPosition))
|
|
443 |
{
|
|
444 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
445 |
// Drag events inside ChoiceGroup area are forwarded to the control.
|
|
446 |
iChoiceGroupControl->HandlePointerEventL(aPointerEvent);
|
|
447 |
#else
|
|
448 |
if (iForm->PhysicsEnabled())
|
|
449 |
{
|
|
450 |
}
|
|
451 |
else
|
|
452 |
{
|
|
453 |
// Forward drag events directly to the control (i.e. to listbox). This enables
|
|
454 |
// the moving of the highlight inside list box when foucused item is changed
|
|
455 |
// by dragging on the form. Calling CCoeControl::HandlePointerEventL() forwards the
|
|
456 |
// drag events to grabbing component only and setting the grabbing component properly
|
|
457 |
// is not always possible. See CCoeControl implementation.
|
|
458 |
iChoiceGroupControl->HandlePointerEventL(aPointerEvent);
|
|
459 |
|
|
460 |
}
|
|
461 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
462 |
|
|
463 |
}
|
|
464 |
break;
|
|
465 |
}
|
|
466 |
|
|
467 |
case TPointerEvent::EButton1Up:
|
|
468 |
{
|
|
469 |
if (iChoiceType == MMIDChoiceGroup::EPopup &&
|
|
470 |
!iForm->IsScrolledOnPointerDown() &&
|
|
471 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
472 |
!iLongTapDetected &&
|
|
473 |
#else
|
|
474 |
// In non-single click UI style, item must be focused
|
|
475 |
// before opening pop-up choicegroup.
|
|
476 |
!iForm->IsFocusChangingWithPen() &&
|
|
477 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
478 |
!iForm->PhysicsScrolling())
|
|
479 |
{
|
|
480 |
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
|
|
481 |
MTouchFeedback* feedback = MTouchFeedback::Instance();
|
|
482 |
if (feedback)
|
|
483 |
{
|
|
484 |
feedback->InstantFeedback(ETouchFeedbackList);
|
|
485 |
}
|
|
486 |
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
|
|
487 |
iChoiceGroupControl->DoPopupL();
|
|
488 |
}
|
|
489 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
490 |
// Forward pointer event except if long tap has been detected,
|
|
491 |
// because we want to keep highlight visible.
|
|
492 |
if (iLongTapDetected)
|
|
493 |
{
|
|
494 |
iPendingUpEvent = aPointerEvent;
|
|
495 |
}
|
|
496 |
else
|
|
497 |
{
|
|
498 |
CMIDControlItem::HandlePointerEventL(aPointerEvent);
|
|
499 |
}
|
|
500 |
#else
|
|
501 |
if (iForm->PhysicsEnabled())
|
|
502 |
{
|
|
503 |
if (!iForm->PhysicsScrolling())
|
|
504 |
{
|
|
505 |
CMIDControlItem::HandlePointerEventL(aPointerEvent);
|
|
506 |
}
|
|
507 |
}
|
|
508 |
else
|
|
509 |
{
|
|
510 |
CMIDControlItem::HandlePointerEventL(aPointerEvent);
|
|
511 |
}
|
|
512 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
513 |
break;
|
|
514 |
}
|
|
515 |
|
|
516 |
default:
|
|
517 |
CMIDControlItem::HandlePointerEventL(aPointerEvent);
|
|
518 |
break;
|
|
519 |
}
|
|
520 |
|
|
521 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
522 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down)
|
|
523 |
{
|
|
524 |
// highlight should be disabled when choicegroup taped
|
|
525 |
iChoiceGroupControl->SingleClickDisableHighlightL(ETrue);
|
|
526 |
}
|
|
527 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
528 |
}
|
|
529 |
#endif //RD_SCALABLE_UI_V2
|
|
530 |
|
|
531 |
// --- from CMIDControlItem
|
|
532 |
|
|
533 |
// Returns a rect that should be partially visible for an Item to have focus
|
|
534 |
// (ie the choicegroup control area)
|
|
535 |
TRect CMIDChoiceGroupItem::FocusableRect()
|
|
536 |
{
|
|
537 |
if (iChoiceGroupControl)
|
|
538 |
{
|
|
539 |
return iChoiceGroupControl->Rect();
|
|
540 |
}
|
|
541 |
else
|
|
542 |
{
|
|
543 |
// Just return the items rect.
|
|
544 |
return Rect();
|
|
545 |
}
|
|
546 |
}
|
|
547 |
|
|
548 |
void CMIDChoiceGroupItem::RestoreInnerFocus()
|
|
549 |
{
|
|
550 |
if (iChoiceGroupControl)
|
|
551 |
iChoiceGroupControl->RestoreFocus();
|
|
552 |
}
|
|
553 |
|
|
554 |
// --- from MMIDChoiceGroupControlObserver
|
|
555 |
|
|
556 |
// Called when the model has changed. Based on the change, will cause
|
|
557 |
// just a redraw of the control, or size recalculation
|
|
558 |
void CMIDChoiceGroupItem::HandleChoiceGroupControlEventL(
|
|
559 |
CMIDChoiceGroupControl* aControl,
|
|
560 |
TChoiceGroupControlEvent aEvent,
|
|
561 |
TAny* aParam)
|
|
562 |
{
|
|
563 |
ASSERT(iChoiceGroupControl);
|
|
564 |
|
|
565 |
// If not from our control, ignore
|
|
566 |
if (aControl != iChoiceGroupControl)
|
|
567 |
{
|
|
568 |
return;
|
|
569 |
}
|
|
570 |
|
|
571 |
switch (aEvent)
|
|
572 |
{
|
|
573 |
case ESizeChanged:
|
|
574 |
break;
|
|
575 |
|
|
576 |
case EScrollRequest:
|
|
577 |
// Make form scroll the requested amount and redraw
|
|
578 |
if (iForm)
|
|
579 |
{
|
|
580 |
iForm->ScrollRelative((TInt) aParam);
|
|
581 |
iForm->UpdatePhysics();
|
|
582 |
}
|
|
583 |
break;
|
|
584 |
|
|
585 |
default:
|
|
586 |
break;
|
|
587 |
}
|
|
588 |
}
|
|
589 |
|
|
590 |
|
|
591 |
// Need to construct the choice listbox when adding to a form
|
|
592 |
// (the listbox very much likes to have a parent window when created)
|
|
593 |
void CMIDChoiceGroupItem::ItemAddedToFormL()
|
|
594 |
{
|
|
595 |
// Form must've been set before
|
|
596 |
ASSERT(iForm);
|
|
597 |
|
|
598 |
// NOTE: The form calls SetContainerWindow() only after
|
|
599 |
// calling SetForm(). That's why the form and not this is
|
|
600 |
// passed as parent.
|
|
601 |
|
|
602 |
// Create a choice group control here, so that we can
|
|
603 |
// give a parent window to the listbox
|
|
604 |
CreateChoiceGroupControlL(iForm);
|
|
605 |
|
|
606 |
iChoiceGroupControl->EnableListHighlight(EFalse);
|
|
607 |
}
|
|
608 |
|
|
609 |
|
|
610 |
// Discard the listbox control when removed from a form
|
|
611 |
void CMIDChoiceGroupItem::ItemRemovedFromForm()
|
|
612 |
{
|
|
613 |
// Get rid of the actual control, but keep the
|
|
614 |
// choicegroup control around, as it holds the model with
|
|
615 |
// all the added elements and can be reattached to a form
|
|
616 |
if (iChoiceGroupControl)
|
|
617 |
{
|
|
618 |
iChoiceGroupControl->DeleteControl();
|
|
619 |
}
|
|
620 |
}
|
|
621 |
|
|
622 |
void CMIDChoiceGroupItem::NotifyScrollingCompleted()
|
|
623 |
{
|
|
624 |
// When this cg becomes focused, show info popup after the form scrolling is completed
|
|
625 |
// and new position has been set to this item. If the note was shown before the new position
|
|
626 |
// is set, the note might be in wrong position (or might be hidden by form, see
|
|
627 |
// CMIDForm::UpdateScrollBar and CMICForm::RawScrollFinalize).
|
|
628 |
if (IsFocused())
|
|
629 |
{
|
|
630 |
iChoiceGroupControl->ShowInfoPopup();
|
|
631 |
}
|
|
632 |
}
|
|
633 |
|
|
634 |
void CMIDChoiceGroupItem::PostItemStateChangedEventL()
|
|
635 |
{
|
|
636 |
ReportEventL(MCoeControlObserver::EEventStateChanged);
|
|
637 |
}
|
|
638 |
|
|
639 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
640 |
void CMIDChoiceGroupItem::PostPendingUpEventL()
|
|
641 |
{
|
|
642 |
if (iLongTapDetected)
|
|
643 |
{
|
|
644 |
iChoiceGroupControl->HandlePointerEventL(iPendingUpEvent);
|
|
645 |
iLongTapDetected = EFalse;
|
|
646 |
}
|
|
647 |
}
|
|
648 |
|
|
649 |
TBool CMIDChoiceGroupItem::LongTapDetected()
|
|
650 |
{
|
|
651 |
return iLongTapDetected;
|
|
652 |
}
|
|
653 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
654 |
|
|
655 |
void CMIDChoiceGroupItem::PostFocusTransferEvent(TBool aFocus, CMIDForm::TDirection aDirection)
|
|
656 |
{
|
|
657 |
if (aFocus)
|
|
658 |
{
|
|
659 |
if (aDirection == CMIDForm::EDown || aDirection == CMIDForm::ERight ||
|
|
660 |
aDirection == CMIDForm::ENone)
|
|
661 |
{
|
|
662 |
iChoiceGroupControl->HiliteFirstElement(ETrue);
|
|
663 |
}
|
|
664 |
else
|
|
665 |
{
|
|
666 |
iChoiceGroupControl->HiliteLastElement(ETrue);
|
|
667 |
}
|
|
668 |
UpdateCommands();
|
|
669 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
670 |
if (aDirection != CMIDForm::ENone)
|
|
671 |
{
|
|
672 |
iChoiceGroupControl->ShowInfoPopup();
|
|
673 |
}
|
|
674 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
675 |
}
|
|
676 |
else
|
|
677 |
{
|
|
678 |
iChoiceGroupControl->EnableListHighlight(EFalse);
|
|
679 |
}
|
|
680 |
}
|
|
681 |
|
|
682 |
|
|
683 |
// Return the items preferred height without the label part
|
|
684 |
// (the "payload" size)
|
|
685 |
TInt CMIDChoiceGroupItem::ItemPreferredHeightWithoutLabel()
|
|
686 |
{
|
|
687 |
return iChoiceGroupControl ? iChoiceGroupControl->MinimumSize().iHeight : 0;
|
|
688 |
}
|
|
689 |
|
|
690 |
|
|
691 |
void CMIDChoiceGroupItem::CreateChoiceGroupControlL(CCoeControl* aParent)
|
|
692 |
{
|
|
693 |
// Create an actual choice control
|
|
694 |
if (iChoiceGroupControl)
|
|
695 |
{
|
|
696 |
// Create one
|
|
697 |
TRect labelRect;
|
|
698 |
TRect choiceRect;
|
|
699 |
CalcChildSizes(Rect(), labelRect, choiceRect);
|
|
700 |
|
|
701 |
iChoiceGroupControl->CreateControlL(aParent, choiceRect);
|
|
702 |
}
|
|
703 |
}
|
|
704 |
|
|
705 |
|
|
706 |
// Calculates child control sizes
|
|
707 |
void CMIDChoiceGroupItem::CalcChildSizes(
|
|
708 |
const TRect& aItemRect,
|
|
709 |
TRect& aLabelRect,
|
|
710 |
TRect& aChoiceRect)
|
|
711 |
{
|
|
712 |
aLabelRect.SetRect(aItemRect.iTl, TSize(aItemRect.Width(), LabelHeight()));
|
|
713 |
|
|
714 |
aChoiceRect = aItemRect;
|
|
715 |
aChoiceRect.iTl.iY += aLabelRect.Height();
|
|
716 |
}
|
|
717 |
|
|
718 |
/** */
|
|
719 |
void CMIDChoiceGroupItem::ResolutionChange(TInt aType)
|
|
720 |
{
|
|
721 |
if (aType == KEikDynamicLayoutVariantSwitch && iForm)
|
|
722 |
{ // dynamic resolution change
|
|
723 |
TRAP_IGNORE(CreateChoiceGroupControlL(iForm));
|
|
724 |
// After the listbox is recreated it shows the focus indication by default.
|
|
725 |
// Clear it if this item is not the one having focus on the form.
|
|
726 |
if (iForm->CurrentItem() != this)
|
|
727 |
{
|
|
728 |
iChoiceGroupControl->EnableListHighlight(EFalse);
|
|
729 |
}
|
|
730 |
}
|
|
731 |
|
|
732 |
// warn choice group control of layout change
|
|
733 |
if (aType == KEikDynamicLayoutVariantSwitch && iChoiceGroupControl)
|
|
734 |
{
|
|
735 |
iChoiceGroupControl->HandleResourceChange(aType);
|
|
736 |
}
|
|
737 |
}
|
|
738 |
|
|
739 |
void CMIDChoiceGroupItem::ColorChange(TInt /*aType*/)
|
|
740 |
{
|
|
741 |
if (iForm)
|
|
742 |
{
|
|
743 |
TRAP_IGNORE(CreateChoiceGroupControlL(iForm));
|
|
744 |
// After the listbox is recreated it shows the focus indication by default.
|
|
745 |
// Clear it if this item is not the one having focus on the form.
|
|
746 |
if (iForm->CurrentItem() != this)
|
|
747 |
{
|
|
748 |
iChoiceGroupControl->EnableListHighlight(EFalse);
|
|
749 |
}
|
|
750 |
}
|
|
751 |
}
|
|
752 |
|
|
753 |
void CMIDChoiceGroupItem::SetLabelL(const TDesC& aLabel)
|
|
754 |
{
|
|
755 |
CMIDControlItem::SetLabelL(aLabel);
|
|
756 |
}
|
|
757 |
|
|
758 |
void CMIDChoiceGroupItem::SetLayoutL(TLayout aLayout)
|
|
759 |
{
|
|
760 |
CMIDControlItem::SetLayoutL(aLayout);
|
|
761 |
}
|
|
762 |
|
|
763 |
void CMIDChoiceGroupItem::Dispose()
|
|
764 |
{
|
|
765 |
delete this;
|
|
766 |
}
|
|
767 |
|
|
768 |
void CMIDChoiceGroupItem::AddCommandL(MMIDCommand* aCommand)
|
|
769 |
{
|
|
770 |
// Add command to item, don't notify form twice
|
|
771 |
CMIDControlItem::AddCommandL(aCommand, EFalse);
|
|
772 |
// UpdateCommands() calls form notification
|
|
773 |
UpdateCommands();
|
|
774 |
}
|
|
775 |
|
|
776 |
void CMIDChoiceGroupItem::RemoveCommand(MMIDCommand* aCommand)
|
|
777 |
{
|
|
778 |
// Remove command to item, don't notify form twice
|
|
779 |
CMIDControlItem::RemoveCommand(aCommand, EFalse);
|
|
780 |
// UpdateCommands() calls form notification
|
|
781 |
UpdateCommands();
|
|
782 |
}
|
|
783 |
|
|
784 |
void CMIDChoiceGroupItem::SetDefaultCommand(MMIDCommand* aCommand)
|
|
785 |
{
|
|
786 |
CMIDControlItem::SetDefaultCommand(aCommand);
|
|
787 |
}
|
|
788 |
|
|
789 |
void CMIDChoiceGroupItem::SetPreferredSizeL(const TSize& aSize)
|
|
790 |
{
|
|
791 |
CMIDControlItem::SetPreferredSize(aSize, MinimumSize());
|
|
792 |
}
|
|
793 |
|
|
794 |
TSize CMIDChoiceGroupItem::PreferredSize() const
|
|
795 |
{
|
|
796 |
return ResetPreferredSize();
|
|
797 |
}
|
|
798 |
|
|
799 |
TSize CMIDChoiceGroupItem::MinimumSize() const
|
|
800 |
{
|
|
801 |
// Const cast to make this call the CCoeControl overridden MinimumSize()
|
|
802 |
CCoeControl* control = const_cast<CMIDChoiceGroupItem *>(this);
|
|
803 |
return control->MinimumSize();
|
|
804 |
}
|
|
805 |
|
|
806 |
void CMIDChoiceGroupItem::SafeDrawNow()
|
|
807 |
{
|
|
808 |
if (DrawableWindow())
|
|
809 |
{
|
|
810 |
DrawNow();
|
|
811 |
}
|
|
812 |
}
|
|
813 |
|
|
814 |
TRect CMIDChoiceGroupItem::FormRect()
|
|
815 |
{
|
|
816 |
if (iForm)
|
|
817 |
{
|
|
818 |
return iForm->Rect();
|
|
819 |
}
|
|
820 |
else
|
|
821 |
{
|
|
822 |
return (TRect(0, 0, 0, 0));
|
|
823 |
}
|
|
824 |
}
|
|
825 |
|
|
826 |
// End of File
|