|
1 /* |
|
2 * Copyright (c) 2002-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: Implementation for colour selection grid. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknPopupHeadingPane.h> |
|
21 #include <AknIconArray.h> |
|
22 #include <eikenv.h> |
|
23 #include <eikcapc.h> |
|
24 #include <aknlists.h> |
|
25 #include <bitstd.h> |
|
26 #include <gulicon.h> |
|
27 #include <fbs.h> |
|
28 #include <AknsDrawUtils.h> |
|
29 #include <AknsBasicBackgroundControlContext.h> |
|
30 #include <barsread.h> |
|
31 #include <AknLayout.lag> |
|
32 #include <aknenv.h> |
|
33 #include <skinlayout.cdl.h> |
|
34 #include <aknlayoutscalable_avkon.cdl.h> |
|
35 #include <layoutmetadata.cdl.h> |
|
36 #include <AknUtils.h> |
|
37 #include <akntranseffect.h> |
|
38 |
|
39 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
40 #include <uikon/eikenvinterface.h> |
|
41 #include <uikon/eikdefmacros.h> |
|
42 #endif |
|
43 |
|
44 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
45 #include <aknlistloadertfx.h> |
|
46 #include <aknlistboxtfxinternal.h> |
|
47 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
48 |
|
49 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
50 #include <gfxtranseffect/gfxtranseffect.h> |
|
51 #include <akntransitionutils.h> |
|
52 #endif |
|
53 |
|
54 #include <touchfeedback.h> |
|
55 #include "AknColourSelectionGrid.h" |
|
56 #include "akntrace.h" |
|
57 |
|
58 enum TCSelGridFlags |
|
59 { |
|
60 ECSelGridCloseAfterDPageClicked = 0x01 |
|
61 }; |
|
62 |
|
63 |
|
64 // ============================= LOCAL FUNCTIONS =============================== |
|
65 |
|
66 |
|
67 TRect ColourSelectionDialogRect() |
|
68 { |
|
69 TInt colourPopupVariety = 0; |
|
70 if (Layout_Meta_Data::IsLandscapeOrientation()) |
|
71 { |
|
72 switch (AknLayoutUtils::CbaLocation()) |
|
73 { |
|
74 case AknLayoutUtils::EAknCbaLocationBottom: |
|
75 //Bottom softkeyt |
|
76 colourPopupVariety = 1; |
|
77 break; |
|
78 case AknLayoutUtils::EAknCbaLocationRight: |
|
79 //Right softkeyt |
|
80 colourPopupVariety = 2; |
|
81 break; |
|
82 case AknLayoutUtils::EAknCbaLocationLeft: |
|
83 //Left softkeyt |
|
84 colourPopupVariety = 3; |
|
85 break; |
|
86 default: |
|
87 break; |
|
88 } |
|
89 } |
|
90 |
|
91 TRect mainPane; |
|
92 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EPopupParent, mainPane ); |
|
93 |
|
94 TAknLayoutRect colourPopupWindow; |
|
95 colourPopupWindow.LayoutRect(mainPane, AknLayoutScalable_Avkon::popup_large_graphic_colour_window(colourPopupVariety)); |
|
96 return colourPopupWindow.Rect(); |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // DrawGrayLines |
|
101 // Draws gray grid to colour selection grid |
|
102 // ----------------------------------------------------------------------------- |
|
103 void DrawGrayLines( |
|
104 CWindowGc& aGc, |
|
105 const TRect& aRect, |
|
106 const TBool aNoneExist=ETrue) |
|
107 { |
|
108 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
109 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc ); |
|
110 if ( transApi ) |
|
111 { |
|
112 transApi->StartDrawing( MAknListBoxTfxInternal::EListView ); |
|
113 } |
|
114 #endif |
|
115 // get the colour |
|
116 TRgb separatorColor; |
|
117 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), separatorColor, KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG5 ); |
|
118 aGc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
119 aGc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
120 aGc.SetPenColor(separatorColor); |
|
121 |
|
122 TInt paneSeparatorVarietyIndex = aNoneExist; |
|
123 TInt gridVarietyIndex = paneSeparatorVarietyIndex; |
|
124 |
|
125 // list scroll is inside popup pane |
|
126 TAknLayoutRect listScroll; |
|
127 listScroll.LayoutRect(aRect, AknLayoutScalable_Avkon::listscroll_popup_colour_pane()); |
|
128 TRect listScrollRect = listScroll.Rect(); |
|
129 |
|
130 // the grid is inside listscroll |
|
131 TAknLayoutRect grid; |
|
132 grid.LayoutRect(listScrollRect, AknLayoutScalable_Avkon::grid_large_graphic_colour_popup_pane(gridVarietyIndex)); |
|
133 TRect gridRect = grid.Rect(); |
|
134 |
|
135 // get some layout data |
|
136 TAknLayoutScalableParameterLimits limits = AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane_ParamLimits(); |
|
137 |
|
138 // we have to use a hardcoded width for the grid separators, |
|
139 // because we have to make the same assumptions as the grid implementation |
|
140 // about how much gap there is between cells |
|
141 |
|
142 TInt cols = limits.LastColumn() + 1; |
|
143 TInt rows = limits.LastRow() + 1; |
|
144 |
|
145 TAknLayoutRect colourCellSize; |
|
146 if (aNoneExist) |
|
147 { |
|
148 colourCellSize.LayoutRect(gridRect, AknLayoutScalable_Avkon::aid_size_cell_colour_3_pane(1)); |
|
149 } |
|
150 else |
|
151 { |
|
152 colourCellSize.LayoutRect(gridRect, AknLayoutScalable_Avkon::aid_size_cell_colour_1_pane(1)); |
|
153 } |
|
154 |
|
155 TInt cellWidth = colourCellSize.Rect().Width(); |
|
156 TInt cellHeight = colourCellSize.Rect().Height(); |
|
157 |
|
158 TInt left = gridRect.iTl.iX; |
|
159 TInt right = gridRect.iTl.iX + (cols * cellWidth); |
|
160 |
|
161 TInt top = gridRect.iTl.iY; |
|
162 TInt bottom = gridRect.iTl.iY + (rows * cellHeight); |
|
163 |
|
164 // horizontal lines |
|
165 for(TInt row = 0; row < rows; row++) |
|
166 { |
|
167 // but cheat by dividing the grid rect into four rows |
|
168 TInt y = top + ((row + 1) * cellHeight); |
|
169 TPoint start(left, y); // the start of the separator is before the start of the next cell |
|
170 TPoint end(right, y); |
|
171 aGc.DrawLine( start, end ); |
|
172 } |
|
173 |
|
174 // vertical lines |
|
175 for(TInt col = 0; col <cols; col++) |
|
176 { |
|
177 // but cheat by dividing the grid rect into four cols |
|
178 TInt x = left + ((col + 1) * cellWidth); |
|
179 TPoint start(x, top); // the start of the separator is before the start of the next cell |
|
180 TPoint end(x, bottom); |
|
181 aGc.DrawLine( start, end ); |
|
182 } |
|
183 |
|
184 // fix for TSW error EVWG-7MCBBC |
|
185 gridRect.iBr += TPoint( 1, 1 ); |
|
186 |
|
187 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
188 if ( transApi ) |
|
189 { |
|
190 transApi->StopDrawing(); |
|
191 } |
|
192 #endif |
|
193 aGc.DrawRect( gridRect ); |
|
194 }; |
|
195 |
|
196 // CLASS DECLARATION |
|
197 |
|
198 /** |
|
199 * CColorGridView |
|
200 * |
|
201 * |
|
202 * |
|
203 * @lib avkon |
|
204 * @since 2.0 |
|
205 */ |
|
206 |
|
207 NONSHARABLE_CLASS(CColorGridView) : public CAknGridView |
|
208 { |
|
209 public: |
|
210 /** |
|
211 * C++ default constructor. |
|
212 */ |
|
213 CColorGridView(); |
|
214 |
|
215 public: // from CAknGridView |
|
216 /** |
|
217 * draws gray grid |
|
218 * @since 2.0 |
|
219 * @param aClipRect |
|
220 */ |
|
221 void Draw(const TRect* aClipRect = NULL) const; |
|
222 |
|
223 /** |
|
224 * Sets iRect and InoneExist |
|
225 * @since 2.0 |
|
226 * @param aRect |
|
227 * @param aNoneExist |
|
228 */ |
|
229 void SetRect(const TRect& aRect, const TBool& aNoneExist); |
|
230 |
|
231 TPoint ItemPos(TInt aItemIndex) const; |
|
232 |
|
233 private: // data |
|
234 TAknLayoutRect iHorLine[5]; |
|
235 TAknLayoutRect iVerLine[5]; |
|
236 TRect iRect; |
|
237 TBool iNoneExist; |
|
238 CCoeControl *iControl; |
|
239 }; |
|
240 |
|
241 // ---------------------------------------------------------------------------- |
|
242 // CColorGridView::CColorGridView() |
|
243 // |
|
244 // --------------------------------------------------------- |
|
245 // |
|
246 CColorGridView::CColorGridView() |
|
247 { |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------- |
|
251 // CColorGridView::SetRect() |
|
252 // |
|
253 // --------------------------------------------------------- |
|
254 // |
|
255 void CColorGridView::SetRect(const TRect& aRect, const TBool& aNoneExist) |
|
256 { |
|
257 _AKNTRACE( "[%s] The rect of grid are ( %d, %d ) ( %d, %d )", |
|
258 __FUNCTION__, |
|
259 aRect.iTl.iX, aRect.iTl.iY, |
|
260 aRect.iBr.iX, aRect.iBr.iY ); |
|
261 iRect.SetRect(aRect.iTl, aRect.iBr); |
|
262 iNoneExist = aNoneExist; |
|
263 } |
|
264 |
|
265 |
|
266 // --------------------------------------------------------- |
|
267 // CColorGridView::Draw() |
|
268 // |
|
269 // --------------------------------------------------------- |
|
270 // |
|
271 void CColorGridView::Draw(const TRect* aClipRect) const |
|
272 { |
|
273 _AKNTRACE_FUNC_ENTER; |
|
274 _AKNTRACE( "The rect of grid are ( %d, %d ) ( %d, %d )", |
|
275 aClipRect->iTl.iX, aClipRect->iTl.iY, |
|
276 aClipRect->iBr.iX, aClipRect->iBr.iY ); |
|
277 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
278 MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iGc ); |
|
279 if ( transApi ) |
|
280 { |
|
281 TRect drawRect = ViewRect(); |
|
282 transApi->BeginRedraw( MAknListBoxTfxInternal::EListView, drawRect ); |
|
283 } |
|
284 #endif // RD_UI_TRANSITION_EFFECTS_LIST |
|
285 CAknGridView::Draw(aClipRect); |
|
286 DrawGrayLines(*iGc, iRect, iNoneExist); |
|
287 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
288 if ( transApi ) |
|
289 { |
|
290 transApi->EndRedraw( MAknListBoxTfxInternal::EListView ); |
|
291 } |
|
292 #endif |
|
293 _AKNTRACE_FUNC_EXIT; |
|
294 } |
|
295 |
|
296 TPoint CColorGridView::ItemPos( TInt aItemIndex ) const |
|
297 { |
|
298 TPoint p = CAknGridView::ItemPos( aItemIndex ); |
|
299 p += TPoint(1,1); |
|
300 return p; |
|
301 } |
|
302 |
|
303 /** |
|
304 * Color grid |
|
305 * |
|
306 * @lib avkon |
|
307 * @since 2.0 |
|
308 */ |
|
309 |
|
310 NONSHARABLE_CLASS(CColorGrid) : public CAknGrid |
|
311 { |
|
312 public: // from CEikListBox |
|
313 void SizeChanged(); |
|
314 |
|
315 public: // from CAknGrid |
|
316 /** |
|
317 * OfferKeyEventL |
|
318 * @since 2.0 |
|
319 * @param aKeyEvent |
|
320 * @param aType |
|
321 */ |
|
322 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
323 /** |
|
324 * MakeViewClassInstanceL |
|
325 * Overriden from CAknGrid. Create the grid view for thus grid class. |
|
326 * @since 2.0 |
|
327 * @ return grid view |
|
328 */ |
|
329 CListBoxView* MakeViewClassInstanceL(); |
|
330 |
|
331 /** |
|
332 * Set value to tel does none exist |
|
333 * Set value to iNoneExist |
|
334 * @since 2.0 |
|
335 * @param aNoneExist Value to iNoneExist |
|
336 */ |
|
337 void SetNoneExist(const TBool aNoneExist) {iNoneExist = aNoneExist;}; |
|
338 void SetLegacyMode(TBool aLegacyMode); |
|
339 TBool IsLegacyMode(); |
|
340 |
|
341 public: // new functions |
|
342 |
|
343 /** |
|
344 * Draws the pressed down highlight to the currently selected grid item. |
|
345 */ |
|
346 void SetPressedDownState(); |
|
347 |
|
348 /** |
|
349 * Clears the pressed down highlight if currently drawn. |
|
350 */ |
|
351 void CleanPressedDownState(); |
|
352 |
|
353 private: // data |
|
354 |
|
355 TBool iNoneExist; |
|
356 TBool iLegacyMode; |
|
357 TBool iSingleClickEnabled; |
|
358 }; |
|
359 |
|
360 // --------------------------------------------------------- |
|
361 // CColorGrid::SizeChanged() |
|
362 // |
|
363 // --------------------------------------------------------- |
|
364 void CColorGrid::SizeChanged() |
|
365 { |
|
366 _AKNTRACE_FUNC_ENTER; |
|
367 // First call the parent SizeChanged() |
|
368 CAknGrid::SizeChanged(); |
|
369 |
|
370 // Retrieve the itemDrawer |
|
371 CFormattedCellListBoxItemDrawer* itemDrawer = ItemDrawer(); |
|
372 |
|
373 // Start setting up the grid |
|
374 AknListBoxLayouts::SetupStandardGrid(*this); |
|
375 |
|
376 // we have to calculate the size of each cell so that they match the grid lines |
|
377 TRect gridRect = Rect(); |
|
378 |
|
379 // get some layout data |
|
380 TAknLayoutScalableParameterLimits limits = AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane_ParamLimits(); |
|
381 |
|
382 TInt cols = limits.LastColumn() + 1; |
|
383 TInt rows = limits.LastRow() + 1; |
|
384 |
|
385 TAknLayoutRect colourCellSize; |
|
386 if (iNoneExist) |
|
387 { |
|
388 colourCellSize.LayoutRect(gridRect, AknLayoutScalable_Avkon::aid_size_cell_colour_3_pane(1)); |
|
389 } |
|
390 else |
|
391 { |
|
392 colourCellSize.LayoutRect(gridRect, AknLayoutScalable_Avkon::aid_size_cell_colour_1_pane(1)); |
|
393 } |
|
394 |
|
395 TInt cellWidth = colourCellSize.Rect().Width() - 1; |
|
396 TInt cellHeight = colourCellSize.Rect().Height() - 1; |
|
397 |
|
398 // Define the overall size of the cell |
|
399 AknListBoxLayouts::SetupGridPos(*this, 0, 0, 0, 0, cellWidth, cellHeight); |
|
400 |
|
401 TPoint pointLT(0,0); |
|
402 TPoint pointWH(cellWidth, cellHeight); |
|
403 |
|
404 AknListBoxLayouts::SetupGridFormGfxCell( *this, |
|
405 itemDrawer, |
|
406 0/* cell index */, |
|
407 AknLayout::colour( iNoneExist ? 0 : 1 ), |
|
408 pointLT, |
|
409 pointWH ); |
|
410 |
|
411 // Grid skinning starts |
|
412 TAknLayoutRect qsnFrPopupCenter; |
|
413 qsnFrPopupCenter.LayoutRect(gridRect, |
|
414 SkinLayout::Popup_windows_skin_placing__frame_general__Line_1(gridRect)); |
|
415 itemDrawer->FormattedCellData()->SetBackgroundSkinStyle( |
|
416 &KAknsIIDQsnFrPopupCenter, qsnFrPopupCenter.Rect()); |
|
417 |
|
418 DisableScrolling( ETrue ); |
|
419 // Check single click flag |
|
420 iSingleClickEnabled = iAvkonAppUi->IsSingleClickCompatible(); |
|
421 _AKNTRACE_FUNC_EXIT; |
|
422 } |
|
423 |
|
424 // --------------------------------------------------------- |
|
425 // CColorGrid::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
426 // |
|
427 // --------------------------------------------------------- |
|
428 TKeyResponse CColorGrid::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
429 { |
|
430 _AKNTRACE_FUNC_ENTER; |
|
431 TInt code = aKeyEvent.iCode; |
|
432 |
|
433 // With single click first key event enables highlight |
|
434 if ( iSingleClickEnabled |
|
435 && ItemDrawer()->Flags() |
|
436 & CListItemDrawer::ESingleClickDisabledHighlight ) |
|
437 { |
|
438 _AKNTRACE_FUNC_EXIT; |
|
439 return CAknGrid::OfferKeyEventL( aKeyEvent,aType ); |
|
440 } |
|
441 |
|
442 CListBoxView::TSelectionMode selectionMode = CListBoxView::ENoSelection; |
|
443 |
|
444 TBool shiftKeyPressed = (aKeyEvent.iModifiers & EModifierShift); |
|
445 if (iListBoxFlags & EMultipleSelection) |
|
446 { |
|
447 if (shiftKeyPressed && iListBoxFlags & EShiftEnterMarks) |
|
448 { |
|
449 View()->SetAnchor(View()->CurrentItemIndex()); |
|
450 selectionMode = CListBoxView::EDisjointMarkSelection; |
|
451 } |
|
452 else |
|
453 selectionMode = CListBoxView::ENoSelection; |
|
454 } |
|
455 |
|
456 TInt rowIndex = 0; |
|
457 TInt colIndex = 0; |
|
458 CAknGridView *view = (CAknGridView*)iView; |
|
459 switch (code) |
|
460 { |
|
461 case EKeyUpArrow: |
|
462 view->LogicalPosFromDataIndex(view->CurrentDataIndex(), rowIndex, colIndex); |
|
463 |
|
464 if (rowIndex ==0 ) |
|
465 { |
|
466 _AKNTRACE_FUNC_EXIT; |
|
467 return EKeyWasNotConsumed; |
|
468 } |
|
469 iView->MoveCursorL(CListBoxView::ECursorPreviousItem, selectionMode); |
|
470 ClearMatchBuffer(); |
|
471 _AKNTRACE( "[%s] EKeyUpArrow",__FUNCTION__ ); |
|
472 break; |
|
473 case EKeyDownArrow: |
|
474 iView->MoveCursorL(CListBoxView::ECursorNextItem, selectionMode); |
|
475 ClearMatchBuffer(); |
|
476 _AKNTRACE( "[%s] EKeyDownArrow",__FUNCTION__ ); |
|
477 break; |
|
478 |
|
479 case EKeyLeftArrow: |
|
480 iView->MoveCursorL(CListBoxView::ECursorPreviousColumn, selectionMode); |
|
481 ClearMatchBuffer(); |
|
482 _AKNTRACE( "[%s] EKeyLeftArrow",__FUNCTION__ ); |
|
483 break; |
|
484 case EKeyRightArrow: |
|
485 iView->MoveCursorL(CListBoxView::ECursorNextColumn, selectionMode); |
|
486 ClearMatchBuffer(); |
|
487 _AKNTRACE( "[%s] EKeyRightArrow",__FUNCTION__ ); |
|
488 break; |
|
489 |
|
490 #if defined(_DEBUG) // only needed when debuging |
|
491 case EKeyPageUp: |
|
492 iView->MoveCursorL(CListBoxView::ECursorPreviousPage, selectionMode); |
|
493 ClearMatchBuffer(); |
|
494 break; |
|
495 case EKeyPageDown: |
|
496 iView->MoveCursorL(CListBoxView::ECursorNextPage, selectionMode); |
|
497 ClearMatchBuffer(); |
|
498 break; |
|
499 case EKeyHome: |
|
500 iView->MoveCursorL(CListBoxView::ECursorFirstItem, selectionMode); |
|
501 ClearMatchBuffer(); |
|
502 break; |
|
503 case EKeyEnd: |
|
504 iView->MoveCursorL(CListBoxView::ECursorLastItem, selectionMode); |
|
505 ClearMatchBuffer(); |
|
506 break; |
|
507 #endif// end of debug code |
|
508 default: |
|
509 _AKNTRACE_FUNC_EXIT; |
|
510 return CEikListBox::OfferKeyEventL(aKeyEvent,aType); |
|
511 } |
|
512 |
|
513 if (iListBoxFlags & EStateChanged) |
|
514 { |
|
515 ReportEventL(MCoeControlObserver::EEventStateChanged); |
|
516 iListBoxFlags &= (~EStateChanged); |
|
517 } |
|
518 |
|
519 _AKNTRACE_FUNC_EXIT; |
|
520 return EKeyWasConsumed; |
|
521 } |
|
522 |
|
523 CListBoxView* CColorGrid::MakeViewClassInstanceL() |
|
524 { |
|
525 CListBoxView* view = new (ELeave) CColorGridView(); |
|
526 return view; |
|
527 } |
|
528 |
|
529 |
|
530 void CColorGrid::SetLegacyMode(TBool aLegacyMode) |
|
531 { |
|
532 iLegacyMode = aLegacyMode; |
|
533 } |
|
534 |
|
535 TBool CColorGrid::IsLegacyMode() |
|
536 { |
|
537 return iLegacyMode; |
|
538 } |
|
539 // --------------------------------------------------------------------------- |
|
540 // Switches the normal highlight from the highlighted grid item to the |
|
541 // pressed down highlight. |
|
542 // --------------------------------------------------------------------------- |
|
543 // |
|
544 void CColorGrid::SetPressedDownState() |
|
545 { |
|
546 TBool wasPressedDown = |
|
547 GridView()->ItemDrawer()->Flags() & CListItemDrawer::EPressedDownState; |
|
548 if ( !wasPressedDown ) |
|
549 { |
|
550 GridView()->ItemDrawer()->SetFlags( CListItemDrawer::EPressedDownState ); |
|
551 GridView()->DrawItem( CurrentItemIndex() ); |
|
552 } |
|
553 } |
|
554 |
|
555 // --------------------------------------------------------------------------- |
|
556 // Switches the pressed down highlight from the highlighted grid item |
|
557 // to the normal highlight. |
|
558 // --------------------------------------------------------------------------- |
|
559 // |
|
560 void CColorGrid::CleanPressedDownState() |
|
561 { |
|
562 TBool wasPressedDown = |
|
563 GridView()->ItemDrawer()->Flags() & CListItemDrawer::EPressedDownState; |
|
564 if ( wasPressedDown ) |
|
565 { |
|
566 GridView()->ItemDrawer()->ClearFlags( CListItemDrawer::EPressedDownState ); |
|
567 GridView()->DrawItem( CurrentItemIndex() ); |
|
568 } |
|
569 } |
|
570 |
|
571 |
|
572 // CLASS DECLARATION |
|
573 |
|
574 /** |
|
575 * None field |
|
576 * |
|
577 * Control to none field |
|
578 * |
|
579 * @lib avkon |
|
580 * @since 2.0 |
|
581 */ |
|
582 |
|
583 NONSHARABLE_CLASS(CNoneField) : public CCoeControl |
|
584 { |
|
585 public: |
|
586 /** |
|
587 * C++ default constructor. |
|
588 */ |
|
589 CNoneField( TBool aSingleClickEnabled ); |
|
590 |
|
591 /** |
|
592 * destructor. |
|
593 */ |
|
594 ~CNoneField(); |
|
595 |
|
596 public: // New functions |
|
597 |
|
598 /** |
|
599 * Sets the skin context for the control. |
|
600 * |
|
601 * @param aSkinContext Skin context. |
|
602 */ |
|
603 void SetSkinContext( MAknsControlContext* aSkinContext ); |
|
604 |
|
605 void SetLegacyMode(TBool aLegacyMode); |
|
606 TBool IsLegacyMode(); |
|
607 |
|
608 void SetPressDownEffect( TBool aEnable ); |
|
609 public: // from CCoeControl |
|
610 /** |
|
611 * SizeChanged |
|
612 * @since 2.0 |
|
613 */ |
|
614 void SizeChanged(); |
|
615 |
|
616 /** |
|
617 * Draw |
|
618 * @since 2.0 |
|
619 * @param aRect |
|
620 */ |
|
621 void Draw(const TRect& aRect) const; |
|
622 |
|
623 /** |
|
624 * ConstructFromResourceL |
|
625 * @since 2.0 |
|
626 * @param aReader |
|
627 */ |
|
628 void ConstructFromResourceL(TResourceReader& aReader); |
|
629 |
|
630 /** |
|
631 * From CCoeControl |
|
632 * HandlePointerEventL handles pointerevents. |
|
633 * @param aPointerEvent pointerevent to be handled |
|
634 */ |
|
635 void HandlePointerEventL(const TPointerEvent& aPointerEvent ); |
|
636 |
|
637 /** |
|
638 * Sets iNoneObserver to be as observer |
|
639 * @param aObserver pointer to observer |
|
640 */ |
|
641 void SetNoneFieldObserver( MCoeControlObserver* aObserver ); |
|
642 |
|
643 private: //data |
|
644 // TRect iRect; |
|
645 MAknsControlContext *iSkinContext; |
|
646 HBufC *iText; |
|
647 MCoeControlObserver *iNoneObserver; |
|
648 TBool iLegacyMode; |
|
649 TBool iIsEnablePressDownEffect; |
|
650 TBool iSingleClickEnabled; |
|
651 }; |
|
652 CNoneField::CNoneField( TBool aSingleClickEnabled ) |
|
653 : iIsEnablePressDownEffect ( EFalse ), |
|
654 iSingleClickEnabled( aSingleClickEnabled ) |
|
655 { |
|
656 } |
|
657 |
|
658 CNoneField::~CNoneField() |
|
659 { |
|
660 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
661 if ( feedback ) |
|
662 { |
|
663 feedback->RemoveFeedbackForControl( this ); |
|
664 } |
|
665 delete iText; |
|
666 iText = NULL; |
|
667 } |
|
668 |
|
669 |
|
670 // --------------------------------------------------------------------------- |
|
671 // Sets the skin context for the control. |
|
672 // --------------------------------------------------------------------------- |
|
673 // |
|
674 void CNoneField::SetSkinContext( MAknsControlContext* aSkinContext ) |
|
675 { |
|
676 iSkinContext = aSkinContext; |
|
677 } |
|
678 |
|
679 |
|
680 void CNoneField::SetLegacyMode(TBool aLegacyMode) |
|
681 { |
|
682 iLegacyMode = aLegacyMode; |
|
683 } |
|
684 |
|
685 TBool CNoneField::IsLegacyMode() |
|
686 { |
|
687 return iLegacyMode; |
|
688 } |
|
689 |
|
690 void CNoneField::SetPressDownEffect( TBool aEnable ) |
|
691 { |
|
692 if ( !iSingleClickEnabled ) |
|
693 { |
|
694 iIsEnablePressDownEffect = aEnable; |
|
695 } |
|
696 } |
|
697 |
|
698 // --------------------------------------------------------- |
|
699 // CNoneField::SizeChanged() |
|
700 // |
|
701 // --------------------------------------------------------- |
|
702 void CNoneField::SizeChanged() |
|
703 { |
|
704 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
705 if ( feedback ) |
|
706 { |
|
707 feedback->ChangeFeedbackArea( this, 0, Rect() ); |
|
708 } |
|
709 } |
|
710 // --------------------------------------------------------- |
|
711 // CNoneField::ConstructFromResourceL(TResourceReader& aReader) |
|
712 // |
|
713 // --------------------------------------------------------- |
|
714 void CNoneField::ConstructFromResourceL(TResourceReader& aReader) |
|
715 { |
|
716 _AKNTRACE_FUNC_ENTER; |
|
717 if (iLegacyMode) |
|
718 { |
|
719 aReader.ReadInt16(); |
|
720 aReader.ReadInt16(); |
|
721 aReader.ReadInt16(); |
|
722 aReader.ReadInt16(); |
|
723 aReader.ReadInt16(); |
|
724 TPtrC ptr = aReader.ReadTPtrC(); |
|
725 iText = ptr.AllocL(); |
|
726 } |
|
727 else |
|
728 { |
|
729 TPtrC ptr = aReader.ReadTPtrC(); |
|
730 iText = ptr.AllocL(); |
|
731 } |
|
732 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
733 if ( feedback ) |
|
734 { |
|
735 CFeedbackSpec* fbSpec = CFeedbackSpec::New(); |
|
736 if ( fbSpec ) |
|
737 { |
|
738 // on down event list basic feedback + audio |
|
739 fbSpec->AddFeedback( ETouchEventStylusDown, |
|
740 ETouchFeedbackList ); |
|
741 |
|
742 // on up event list basic feedback, no audio |
|
743 fbSpec->AddFeedback( ETouchEventStylusUp, |
|
744 ETouchFeedbackList, |
|
745 ETouchFeedbackVibra ); |
|
746 |
|
747 feedback->SetFeedbackArea( this, |
|
748 0, |
|
749 Rect(), |
|
750 fbSpec ); |
|
751 delete fbSpec; |
|
752 } |
|
753 } |
|
754 _AKNTRACE_FUNC_EXIT; |
|
755 } |
|
756 // --------------------------------------------------------- |
|
757 // CNoneField::Draw(const TRect& aRect) const |
|
758 // |
|
759 // --------------------------------------------------------- |
|
760 void CNoneField::Draw(const TRect& /*aRect*/) const |
|
761 { |
|
762 _AKNTRACE_FUNC_ENTER; |
|
763 |
|
764 TRect rect = Rect(); |
|
765 |
|
766 CWindowGc& gc=SystemGc(); |
|
767 |
|
768 // Set skin |
|
769 MAknsSkinInstance *skin = AknsUtils::SkinInstance(); |
|
770 MAknsControlContext *cc = AknsDrawUtils::ControlContext(this); |
|
771 if (cc) |
|
772 { |
|
773 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
774 AknsDrawUtils::Background( skin, cc, gc, rect ); |
|
775 } |
|
776 |
|
777 // Draw none -text |
|
778 TAknLayoutText noneText; |
|
779 noneText.LayoutText(rect, AknLayoutScalable_Avkon::cell_large_graphic_colour_none_popup_pane_t1()); |
|
780 |
|
781 |
|
782 |
|
783 TAknLayoutId LayoutId; |
|
784 iAvkonEnv->GetCurrentLayoutId( LayoutId ); |
|
785 |
|
786 // Draw focus |
|
787 if (IsFocused()) |
|
788 { |
|
789 TAknLayoutRect gridHighlightPane; |
|
790 gridHighlightPane.LayoutRect( rect, AknLayoutScalable_Avkon::grid_highlight_pane_cp5()); |
|
791 |
|
792 TBool windowFrameDrawn = EFalse; |
|
793 if (cc) |
|
794 { |
|
795 TAknLayoutRect topLeft; |
|
796 topLeft.LayoutRect(gridHighlightPane.Rect(), SkinLayout::Highlight_skin_placing__grid__Line_2()); |
|
797 |
|
798 TAknLayoutRect bottomRight; |
|
799 bottomRight.LayoutRect(gridHighlightPane.Rect(), SkinLayout::Highlight_skin_placing__grid__Line_5()); |
|
800 |
|
801 TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr); |
|
802 TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl); |
|
803 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
804 const TAknsItemID *frameId = iIsEnablePressDownEffect ? &KAknsIIDQsnFrGridPressed : &KAknsIIDQsnFrGrid; |
|
805 windowFrameDrawn = AknsDrawUtils::DrawFrame(skin, gc, outerRect, innerRect, *frameId, KAknsIIDNone); |
|
806 } |
|
807 if( !windowFrameDrawn ) |
|
808 { |
|
809 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
810 gc.SetPenColor(gridHighlightPane.Color()); |
|
811 gridHighlightPane.DrawOutLineRect(gc); |
|
812 } |
|
813 } |
|
814 |
|
815 TRgb color( KRgbBlack ); |
|
816 AknsUtils::GetCachedColor( skin, |
|
817 color, |
|
818 KAknsIIDQsnTextColors, |
|
819 // text #19 popup windows popup windows text |
|
820 EAknsCIQsnTextColorsCG19 ); |
|
821 |
|
822 noneText.DrawText( gc, *iText, ETrue, color ); |
|
823 |
|
824 TRgb separatorColor; |
|
825 AknsUtils::GetCachedColor(AknsUtils::SkinInstance(), separatorColor, KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG5 ); |
|
826 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
827 gc.SetPenColor(separatorColor); |
|
828 TRect out(Rect()); |
|
829 gc.DrawRect( out ); |
|
830 _AKNTRACE_FUNC_EXIT; |
|
831 } |
|
832 |
|
833 |
|
834 // --------------------------------------------------------------------------- |
|
835 // Handles pointer events in none field. If none is already focused, then |
|
836 // this is second click to none field and we can inform observer to |
|
837 // close itself. |
|
838 // --------------------------------------------------------------------------- |
|
839 // |
|
840 void CNoneField::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
841 { |
|
842 _AKNTRACE_FUNC_ENTER; |
|
843 if ( aPointerEvent.iType == TPointerEvent::EButton1Up && |
|
844 Rect().Contains( aPointerEvent.iPosition ) ) |
|
845 { |
|
846 /* Check whether `this' is still valid. */ |
|
847 HBufC **text = &iText; |
|
848 |
|
849 if ( iNoneObserver && IsFocused() ) |
|
850 { |
|
851 iNoneObserver->HandleControlEventL( |
|
852 this, |
|
853 MCoeControlObserver::EEventRequestExit ); |
|
854 } |
|
855 |
|
856 if ( *text ) |
|
857 { |
|
858 SetPressDownEffect( EFalse ); |
|
859 } |
|
860 } |
|
861 _AKNTRACE_FUNC_EXIT; |
|
862 } |
|
863 |
|
864 |
|
865 // ----------------------------------------------------------------------------- |
|
866 // CNoneField::SetNoneFieldObserver |
|
867 // Set iNoneObserver to be observer of nonefield. |
|
868 // ----------------------------------------------------------------------------- |
|
869 // |
|
870 void CNoneField::SetNoneFieldObserver( MCoeControlObserver* aObserver ) |
|
871 { |
|
872 iNoneObserver = aObserver; |
|
873 } |
|
874 |
|
875 // CLASS DECLARATION |
|
876 /** |
|
877 * CAknColorSelectionGridControl |
|
878 * |
|
879 * |
|
880 * |
|
881 * @lib avkon |
|
882 * @since 2.0 |
|
883 */ |
|
884 |
|
885 NONSHARABLE_CLASS(CAknColorSelectionGridControl) : public CCoeControl |
|
886 { |
|
887 public: |
|
888 /** |
|
889 * C++ default constructor. |
|
890 */ |
|
891 CAknColorSelectionGridControl(CColorGrid *aGrid, |
|
892 CNoneField* aNoneField, TBool aSingleClickEnabled ); |
|
893 /** |
|
894 * destructor. |
|
895 */ |
|
896 ~CAknColorSelectionGridControl(); |
|
897 |
|
898 public: // New methods |
|
899 /** |
|
900 * Grid |
|
901 * @since 2.0 |
|
902 */ |
|
903 CColorGrid *Grid() const; |
|
904 |
|
905 /** |
|
906 * Grid |
|
907 * @since 2.0 |
|
908 */ |
|
909 CNoneField *NoneField() const; |
|
910 |
|
911 void SetParentRects(TRect aScreenSize, TRect aColourSelectionDialogRect); |
|
912 |
|
913 public: // from CCoeControl |
|
914 |
|
915 |
|
916 void SizeChanged(); |
|
917 |
|
918 /** |
|
919 * CountComponentControls |
|
920 * @since 2.0 |
|
921 * @return |
|
922 */ |
|
923 TInt CountComponentControls() const; |
|
924 |
|
925 |
|
926 /** |
|
927 * ComponentControl |
|
928 * @since 2.0 |
|
929 * @return |
|
930 */ |
|
931 CCoeControl *ComponentControl(TInt aItem) const; |
|
932 |
|
933 |
|
934 /** |
|
935 * MinimumSize. |
|
936 * @since 2.0 |
|
937 * @return minimum size of this control |
|
938 */ |
|
939 TSize MinimumSize(); |
|
940 |
|
941 |
|
942 /** |
|
943 * ?member_description. |
|
944 * @since 2.0 |
|
945 * @param aDrawNow flag |
|
946 */ |
|
947 void FocusChanged(TDrawNow aDrawNow); |
|
948 |
|
949 /** |
|
950 * Draw |
|
951 * @since 2.0 |
|
952 */ |
|
953 void Draw(const TRect& /*aRect*/) const; |
|
954 |
|
955 /** |
|
956 * OfferKeyEventL |
|
957 * @since 2.0 |
|
958 * @param aKeyEvent |
|
959 * @param aType |
|
960 * @return |
|
961 */ |
|
962 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType); |
|
963 |
|
964 /** |
|
965 * ConstructFromResourceL. |
|
966 * @since 2.0 |
|
967 * @param aRes |
|
968 */ |
|
969 void ConstructFromResourceL(TResourceReader &aRes); |
|
970 |
|
971 /** |
|
972 * HandlePointerEventL |
|
973 * @param aPointerEvent pointer event information |
|
974 * @return |
|
975 */ |
|
976 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
977 |
|
978 private: // Data |
|
979 CColorGrid *iGrid; |
|
980 CNoneField* iNoneField; |
|
981 TRect iScreenSize; |
|
982 TRect iColourSelectionDialogRect; |
|
983 TBool iSingleClickEnabled; |
|
984 }; |
|
985 |
|
986 CAknColorSelectionGridControl::CAknColorSelectionGridControl(CColorGrid *aGrid, |
|
987 CNoneField* aNoneField, TBool aSingleClickEnabled ) |
|
988 : iGrid(aGrid), |
|
989 iNoneField(aNoneField), |
|
990 iSingleClickEnabled( aSingleClickEnabled ) |
|
991 { |
|
992 } |
|
993 |
|
994 CAknColorSelectionGridControl::~CAknColorSelectionGridControl() |
|
995 { |
|
996 delete iGrid; |
|
997 if ( iNoneField && !iNoneField->IsLegacyMode()) |
|
998 { |
|
999 delete iNoneField; |
|
1000 } |
|
1001 } |
|
1002 |
|
1003 void CAknColorSelectionGridControl::ConstructFromResourceL(TResourceReader &aRes) |
|
1004 { |
|
1005 _AKNTRACE_FUNC_ENTER; |
|
1006 if (iNoneField) |
|
1007 { |
|
1008 iNoneField->SetContainerWindowL(*this); |
|
1009 iNoneField->CopyControlContextFrom(this); |
|
1010 if ( !iNoneField->IsLegacyMode() ) |
|
1011 { |
|
1012 iNoneField->ConstructFromResourceL(aRes); |
|
1013 } |
|
1014 } |
|
1015 else |
|
1016 { |
|
1017 if (!iGrid->IsLegacyMode()) |
|
1018 { |
|
1019 aRes.ReadTPtrC(); // none text |
|
1020 } |
|
1021 } |
|
1022 |
|
1023 |
|
1024 iGrid->SetContainerWindowL(*this); |
|
1025 iGrid->CopyControlContextFrom(this); |
|
1026 iGrid->ConstructFromResourceL(aRes); |
|
1027 iGrid->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
1028 CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOff ); |
|
1029 _AKNTRACE_FUNC_EXIT; |
|
1030 } |
|
1031 |
|
1032 |
|
1033 |
|
1034 CColorGrid* CAknColorSelectionGridControl::Grid() const |
|
1035 { |
|
1036 return iGrid; |
|
1037 } |
|
1038 |
|
1039 CNoneField* CAknColorSelectionGridControl::NoneField() const |
|
1040 { |
|
1041 return iNoneField; |
|
1042 } |
|
1043 |
|
1044 void CAknColorSelectionGridControl::SetParentRects(TRect aScreenSize, TRect aColourSelectionDialogRect) |
|
1045 { |
|
1046 iScreenSize = aScreenSize; |
|
1047 iColourSelectionDialogRect = aColourSelectionDialogRect; |
|
1048 } |
|
1049 |
|
1050 void CAknColorSelectionGridControl::SizeChanged() |
|
1051 { |
|
1052 _AKNTRACE_FUNC_ENTER; |
|
1053 TRect applicationRect = iAvkonAppUi->ApplicationRect(); |
|
1054 if (applicationRect != iScreenSize) |
|
1055 { |
|
1056 iColourSelectionDialogRect = ColourSelectionDialogRect(); |
|
1057 iScreenSize = applicationRect; |
|
1058 } |
|
1059 |
|
1060 TRect rect = Rect(); |
|
1061 TRect parent = TRect( 0, 0, rect.Width(), rect.Height() ); |
|
1062 TAknLayoutRect listScrollPopupColourPane; |
|
1063 listScrollPopupColourPane.LayoutRect(parent , AknLayoutScalable_Avkon::listscroll_popup_colour_pane()); |
|
1064 |
|
1065 TInt gridColourPopupPaneVariety = 0; |
|
1066 if (iNoneField) |
|
1067 { |
|
1068 TAknLayoutRect noneFieldPane; |
|
1069 noneFieldPane.LayoutRect(listScrollPopupColourPane.Rect(), AknLayoutScalable_Avkon::cell_large_graphic_colour_none_popup_pane(0)); |
|
1070 iNoneField->SetRect(noneFieldPane.Rect()); |
|
1071 gridColourPopupPaneVariety = 1; |
|
1072 } |
|
1073 TAknLayoutRect gridColourPopupPane; |
|
1074 gridColourPopupPane.LayoutRect(listScrollPopupColourPane.Rect(), AknLayoutScalable_Avkon::grid_large_graphic_colour_popup_pane(gridColourPopupPaneVariety)); |
|
1075 iGrid->SetRect(gridColourPopupPane.Rect()); |
|
1076 |
|
1077 STATIC_CAST(CColorGridView*,iGrid->View())->SetRect(parent, iNoneField != 0); |
|
1078 _AKNTRACE_FUNC_EXIT; |
|
1079 } |
|
1080 |
|
1081 TInt CAknColorSelectionGridControl::CountComponentControls() const |
|
1082 { |
|
1083 if (iNoneField) |
|
1084 { |
|
1085 return 2; |
|
1086 } |
|
1087 else |
|
1088 { |
|
1089 return 1; |
|
1090 } |
|
1091 } |
|
1092 |
|
1093 CCoeControl* CAknColorSelectionGridControl::ComponentControl(TInt aItem) const |
|
1094 { |
|
1095 if (iNoneField && aItem == 0) |
|
1096 { |
|
1097 return iNoneField; |
|
1098 } |
|
1099 else |
|
1100 { |
|
1101 return iGrid; |
|
1102 } |
|
1103 } |
|
1104 |
|
1105 |
|
1106 TSize CAknColorSelectionGridControl::MinimumSize() |
|
1107 { |
|
1108 TRect applicationRect = iAvkonAppUi->ApplicationRect(); |
|
1109 if (applicationRect != iScreenSize) |
|
1110 { |
|
1111 iColourSelectionDialogRect = ColourSelectionDialogRect(); |
|
1112 iScreenSize = applicationRect; |
|
1113 } |
|
1114 |
|
1115 TAknLayoutRect listScrollPopupColourPane; |
|
1116 listScrollPopupColourPane.LayoutRect(iColourSelectionDialogRect , AknLayoutScalable_Avkon::listscroll_popup_colour_pane()); |
|
1117 return listScrollPopupColourPane.Rect().Size(); |
|
1118 } |
|
1119 |
|
1120 void CAknColorSelectionGridControl::FocusChanged(TDrawNow /*aDrawNow*/) |
|
1121 { |
|
1122 if ( AknLayoutUtils::PenEnabled() ) |
|
1123 { |
|
1124 if ( !IsFocused() ) |
|
1125 { |
|
1126 iGrid->ClearSelection(); |
|
1127 } |
|
1128 } |
|
1129 } |
|
1130 |
|
1131 |
|
1132 |
|
1133 |
|
1134 void CAknColorSelectionGridControl::Draw(const TRect& /*aRect*/) const |
|
1135 { |
|
1136 _AKNTRACE_FUNC_ENTER; |
|
1137 // Set skin |
|
1138 CWindowGc& gc=SystemGc(); |
|
1139 |
|
1140 MAknsSkinInstance *skin = AknsUtils::SkinInstance(); |
|
1141 MAknsControlContext *cc = AknsDrawUtils::ControlContext(this); |
|
1142 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
1143 gc.SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1144 TRect rect = Rect(); |
|
1145 |
|
1146 TRect outerRect = TRect(rect.iTl, iColourSelectionDialogRect.Size()); |
|
1147 TRect innerRect = iGrid->Rect(); |
|
1148 AknsDrawUtils::BackgroundBetweenRects( |
|
1149 skin, cc, gc, outerRect, innerRect ); |
|
1150 _AKNTRACE_FUNC_EXIT; |
|
1151 } |
|
1152 |
|
1153 |
|
1154 // --------------------------------------------------------------------------- |
|
1155 // Handles key events in the color selection grid control. |
|
1156 // --------------------------------------------------------------------------- |
|
1157 // |
|
1158 TKeyResponse CAknColorSelectionGridControl::OfferKeyEventL( |
|
1159 const TKeyEvent& aKeyEvent, |
|
1160 TEventCode aType ) |
|
1161 { |
|
1162 _AKNTRACE_FUNC_ENTER; |
|
1163 // With single click first key event enables highlight |
|
1164 if ( iSingleClickEnabled |
|
1165 && iGrid->ItemDrawer()->Flags() |
|
1166 & CListItemDrawer::ESingleClickDisabledHighlight ) |
|
1167 { |
|
1168 // Highlight will be restored to grid control |
|
1169 if ( iNoneField ) |
|
1170 { |
|
1171 iNoneField->SetFocus( EFalse ); |
|
1172 } |
|
1173 iGrid->SetFocus( ETrue ); |
|
1174 _AKNTRACE_FUNC_EXIT; |
|
1175 return iGrid->OfferKeyEventL( aKeyEvent, aType ); |
|
1176 } |
|
1177 if ( iNoneField && iNoneField->IsFocused() ) |
|
1178 { |
|
1179 if ( aKeyEvent.iCode == EKeyDownArrow ) |
|
1180 { |
|
1181 iNoneField->SetFocus( EFalse ); |
|
1182 iGrid->SetFocus( ETrue ); |
|
1183 DrawDeferred(); |
|
1184 } |
|
1185 |
|
1186 _AKNTRACE_FUNC_EXIT; |
|
1187 return EKeyWasConsumed; |
|
1188 } |
|
1189 |
|
1190 TKeyResponse consumed = iGrid->OfferKeyEventL( aKeyEvent, aType ); |
|
1191 if ( iNoneField && |
|
1192 consumed == EKeyWasNotConsumed && |
|
1193 iGrid->IsFocused() && |
|
1194 aKeyEvent.iCode == EKeyUpArrow ) |
|
1195 { |
|
1196 iGrid->SetFocus( EFalse ); |
|
1197 iNoneField->SetFocus( ETrue ); |
|
1198 DrawDeferred(); |
|
1199 |
|
1200 _AKNTRACE_FUNC_EXIT; |
|
1201 return EKeyWasConsumed; |
|
1202 } |
|
1203 |
|
1204 _AKNTRACE_FUNC_EXIT; |
|
1205 return consumed; |
|
1206 } |
|
1207 |
|
1208 |
|
1209 // --------------------------------------------------------------------------- |
|
1210 // Handle the pointer event to the color selection grid control. |
|
1211 // --------------------------------------------------------------------------- |
|
1212 // |
|
1213 void CAknColorSelectionGridControl::HandlePointerEventL( |
|
1214 const TPointerEvent& aPointerEvent ) |
|
1215 { |
|
1216 _AKNTRACE_FUNC_ENTER; |
|
1217 if ( AknLayoutUtils::PenEnabled() ) |
|
1218 { |
|
1219 // Pointer on None-field |
|
1220 if ( iNoneField && |
|
1221 iNoneField->Rect().Contains( aPointerEvent.iPosition ) ) |
|
1222 { |
|
1223 switch ( aPointerEvent.iType ) |
|
1224 { |
|
1225 case TPointerEvent::EButton1Down: |
|
1226 { |
|
1227 _AKNTRACE( "[%s] TPointerEvent::EButton1Down", |
|
1228 __FUNCTION__ ); |
|
1229 // Change focus from color grid to none-field. |
|
1230 if ( iGrid->IsFocused() ) |
|
1231 { |
|
1232 iGrid->SetFocus( EFalse ); |
|
1233 } |
|
1234 iNoneField->SetPressDownEffect( ETrue ); |
|
1235 iNoneField->SetFocus( ETrue ); |
|
1236 DrawDeferred(); |
|
1237 break; |
|
1238 } |
|
1239 |
|
1240 case TPointerEvent::EDrag: |
|
1241 { |
|
1242 _AKNTRACE( "[%s] TPointerEvent::EDrag", |
|
1243 __FUNCTION__ ); |
|
1244 if ( iGrid->IsFocused() ) |
|
1245 { |
|
1246 iGrid->CleanPressedDownState(); |
|
1247 iGrid->SetFocus( EFalse ); |
|
1248 DrawDeferred(); |
|
1249 } |
|
1250 break; |
|
1251 } |
|
1252 |
|
1253 default: |
|
1254 { |
|
1255 break; |
|
1256 } |
|
1257 } |
|
1258 |
|
1259 iNoneField->HandlePointerEventL( aPointerEvent ); |
|
1260 _AKNTRACE_FUNC_EXIT; |
|
1261 return; |
|
1262 } |
|
1263 |
|
1264 // Pointer on grid |
|
1265 CAknGridView *gridView = |
|
1266 static_cast<CAknGridView*>( iGrid->GridView() ); |
|
1267 |
|
1268 TSize itemSize( gridView->ItemSize( 0 ) ); |
|
1269 TRect visibleItemsRect( |
|
1270 gridView->ViewRect().iTl, |
|
1271 TSize( |
|
1272 itemSize.iWidth * gridView->NumberOfColsInView(), |
|
1273 itemSize.iHeight * gridView->NumberOfRowsInView() ) ); |
|
1274 |
|
1275 if ( visibleItemsRect.Contains( aPointerEvent.iPosition ) ) |
|
1276 { |
|
1277 switch ( aPointerEvent.iType ) |
|
1278 { |
|
1279 case TPointerEvent::EButton1Down: |
|
1280 { |
|
1281 _AKNTRACE( "[%s] TPointerEvent::EButton1Down", |
|
1282 __FUNCTION__ ); |
|
1283 if ( iNoneField && iNoneField->IsFocused() ) |
|
1284 { |
|
1285 // Change focus from none-field to color grid. |
|
1286 iNoneField->SetFocus( EFalse ); |
|
1287 iNoneField->SetPressDownEffect( EFalse ); |
|
1288 iNoneField->DrawDeferred(); |
|
1289 } |
|
1290 iGrid->SetFocus( ETrue, EDrawNow ); |
|
1291 break; |
|
1292 } |
|
1293 |
|
1294 case TPointerEvent::EDrag: |
|
1295 { |
|
1296 _AKNTRACE( "[%s] TPointerEvent::EDrag", |
|
1297 __FUNCTION__ ); |
|
1298 if ( iNoneField && iNoneField->IsFocused() ) |
|
1299 { |
|
1300 iNoneField->SetPressDownEffect( EFalse ); |
|
1301 iNoneField->SetFocus( EFalse ); |
|
1302 DrawDeferred(); |
|
1303 } |
|
1304 } |
|
1305 |
|
1306 case TPointerEvent::EButton1Up: |
|
1307 { |
|
1308 _AKNTRACE( "[%s] TPointerEvent::EButton1Up", |
|
1309 __FUNCTION__ ); |
|
1310 if ( !iGrid->IsFocused() ) |
|
1311 { |
|
1312 _AKNTRACE_FUNC_EXIT; |
|
1313 return; // Ignore if move from none field to color grid |
|
1314 } |
|
1315 break; |
|
1316 } |
|
1317 default: |
|
1318 { |
|
1319 break; |
|
1320 } |
|
1321 } |
|
1322 } |
|
1323 else |
|
1324 { |
|
1325 iGrid->CleanPressedDownState(); |
|
1326 |
|
1327 if ( iNoneField ) |
|
1328 { |
|
1329 iNoneField->SetPressDownEffect( EFalse ); |
|
1330 } |
|
1331 |
|
1332 DrawDeferred(); |
|
1333 } |
|
1334 |
|
1335 iGrid->HandlePointerEventL( aPointerEvent ); |
|
1336 } |
|
1337 _AKNTRACE_FUNC_EXIT; |
|
1338 } |
|
1339 |
|
1340 |
|
1341 // CLASS DECLARATION |
|
1342 |
|
1343 /** |
|
1344 * CMainTextArray |
|
1345 * |
|
1346 * |
|
1347 * |
|
1348 * @lib avkon |
|
1349 * @since 2.0 |
|
1350 */ |
|
1351 |
|
1352 NONSHARABLE_CLASS(CMainTextArray) : public MDesCArray, public CBase |
|
1353 { |
|
1354 public: |
|
1355 |
|
1356 /** |
|
1357 * C++ default constructor. |
|
1358 */ |
|
1359 CMainTextArray(TBool &aNoneExist); |
|
1360 /** |
|
1361 * Destructor. |
|
1362 */ |
|
1363 ~CMainTextArray(); |
|
1364 |
|
1365 /** |
|
1366 * MdcaCount |
|
1367 * @since 2.0 |
|
1368 * @return |
|
1369 */ |
|
1370 virtual TInt MdcaCount() const; |
|
1371 |
|
1372 /** |
|
1373 * MdcaPoint |
|
1374 * @since 2.0 |
|
1375 * @param aIndex |
|
1376 * @return |
|
1377 */ |
|
1378 virtual TPtrC MdcaPoint(TInt aIndex) const; |
|
1379 |
|
1380 /** |
|
1381 * ConstructL |
|
1382 * @since 2.0 |
|
1383 * @param aColours Array of colours to be in grid |
|
1384 */ |
|
1385 void ConstructL(CArrayFixFlat<TRgb>* aColours); |
|
1386 |
|
1387 public: // Data |
|
1388 CGulIcon* iIcon[16]; |
|
1389 |
|
1390 private: // Data |
|
1391 mutable TInt iIndex; |
|
1392 TInt iColourNmbr; |
|
1393 TBool iNoneExist; |
|
1394 CArrayFixFlat<TRgb>* iColours; |
|
1395 CFbsBitmap* iBitmap[16]; |
|
1396 CFbsBitmapDevice* iBmpDevice[16]; |
|
1397 HBufC *iString; |
|
1398 |
|
1399 }; |
|
1400 |
|
1401 // --------------------------------------------------------- |
|
1402 // CMainTextArray::CMainTextArray() |
|
1403 // |
|
1404 // --------------------------------------------------------- |
|
1405 // |
|
1406 CMainTextArray::CMainTextArray(TBool &aNoneExist) |
|
1407 : iNoneExist(aNoneExist) |
|
1408 { |
|
1409 } |
|
1410 // --------------------------------------------------------- |
|
1411 // CMainTextArray::~CMainTextArray() |
|
1412 // |
|
1413 // --------------------------------------------------------- |
|
1414 // |
|
1415 CMainTextArray::~CMainTextArray() |
|
1416 { |
|
1417 for (TInt i = 0;i<iColourNmbr;i++) |
|
1418 { |
|
1419 delete iBitmap[i]; |
|
1420 delete iBmpDevice[i]; |
|
1421 } |
|
1422 delete iString; |
|
1423 } |
|
1424 |
|
1425 // --------------------------------------------------------- |
|
1426 // CMainTextArray::ConstructL() |
|
1427 // |
|
1428 // --------------------------------------------------------- |
|
1429 // |
|
1430 void CMainTextArray::ConstructL(CArrayFixFlat<TRgb>* aColours) |
|
1431 { |
|
1432 |
|
1433 this->iColours = aColours; |
|
1434 iColourNmbr = aColours->Count(); |
|
1435 if (iColourNmbr > 16) |
|
1436 { |
|
1437 iColourNmbr = 16; |
|
1438 } |
|
1439 |
|
1440 TAknLayoutRect r; |
|
1441 TAknLayoutRect r_pane; |
|
1442 TInt w, h; |
|
1443 r_pane.LayoutRect(TRect(0,0,0,0), AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane(iNoneExist, 0, 0).LayoutLine()); |
|
1444 r.LayoutRect(r_pane.Rect(), AknLayoutScalable_Avkon::cell_large_graphic_colour_popup_pane_g1().LayoutLine()); |
|
1445 w = r.Rect().Width(); |
|
1446 h = r.Rect().Height(); |
|
1447 TSize bmpsize(w,h); |
|
1448 |
|
1449 for (TInt i = 0;i<iColourNmbr;i++) |
|
1450 { |
|
1451 iBitmap[i] = new (ELeave) CFbsBitmap(); |
|
1452 iBitmap[i]->Create(bmpsize,EColor4K); |
|
1453 iIcon[i] = CGulIcon::NewL(iBitmap[i]); |
|
1454 iIcon[i]->SetBitmapsOwnedExternally(ETrue); |
|
1455 iBmpDevice[i] = CFbsBitmapDevice::NewL(iBitmap[i]); |
|
1456 iBmpDevice[i]->Resize(iBitmap[i]->SizeInPixels()); |
|
1457 } |
|
1458 |
|
1459 iString = HBufC::NewL(10); |
|
1460 } |
|
1461 |
|
1462 |
|
1463 // --------------------------------------------------------- |
|
1464 // CMainTextArray::MdcaCount() |
|
1465 // |
|
1466 // --------------------------------------------------------- |
|
1467 // |
|
1468 TInt CMainTextArray::MdcaCount() const |
|
1469 { |
|
1470 return(iColourNmbr); |
|
1471 } |
|
1472 |
|
1473 // --------------------------------------------------------- |
|
1474 // CMainTextArray::MdcaPoint() |
|
1475 // |
|
1476 // --------------------------------------------------------- |
|
1477 // |
|
1478 TPtrC CMainTextArray::MdcaPoint(TInt aIndex) const |
|
1479 { |
|
1480 TRAP_IGNORE( |
|
1481 { |
|
1482 |
|
1483 CFbsBitGc* fbsBitGc = CFbsBitGc::NewL(); |
|
1484 CleanupStack::PushL( fbsBitGc ); |
|
1485 |
|
1486 fbsBitGc->Activate(iBmpDevice[aIndex]); |
|
1487 |
|
1488 fbsBitGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
1489 if (aIndex < iColourNmbr) |
|
1490 { |
|
1491 fbsBitGc->SetBrushColor(iColours->At(aIndex)); |
|
1492 } |
|
1493 |
|
1494 fbsBitGc->Clear(); |
|
1495 |
|
1496 CleanupStack::PopAndDestroy(); // fbsBitGc |
|
1497 }); |
|
1498 //fix for TSW error AJUA-7MTAXE |
|
1499 iString->Des().Num(aIndex); |
|
1500 |
|
1501 return *iString; |
|
1502 } |
|
1503 |
|
1504 // ============================ MEMBER FUNCTIONS =============================== |
|
1505 |
|
1506 // ---------------------------------------------------------------------------- |
|
1507 // Extension class |
|
1508 // |
|
1509 // ---------------------------------------------------------------------------- |
|
1510 // |
|
1511 NONSHARABLE_CLASS(CAknColourSelectionGridExtension): public CBase |
|
1512 { |
|
1513 public: |
|
1514 CAknColourSelectionGridExtension(); |
|
1515 ~CAknColourSelectionGridExtension(); |
|
1516 |
|
1517 public: |
|
1518 TInt iFlags; |
|
1519 TBool iIsDragged; |
|
1520 }; |
|
1521 |
|
1522 CAknColourSelectionGridExtension::CAknColourSelectionGridExtension() |
|
1523 : iFlags(0), iIsDragged( EFalse ) |
|
1524 { |
|
1525 } |
|
1526 |
|
1527 CAknColourSelectionGridExtension::~CAknColourSelectionGridExtension() |
|
1528 { |
|
1529 } |
|
1530 |
|
1531 // --------------------------------------------------------- |
|
1532 // CAknColourSelectionGrid::CAknColourSelectionGrid() |
|
1533 // |
|
1534 // --------------------------------------------------------- |
|
1535 CAknColourSelectionGrid::CAknColourSelectionGrid() |
|
1536 { |
|
1537 #ifdef RD_UI_TRANSITION_EFFECTS_POPUPS |
|
1538 GfxTransEffect::Register( this, KGfxContextMenuControlUid ); |
|
1539 #endif |
|
1540 iWsBufferRequestID = iAvkonEnv->RequestWsBuffer( 15000 ); |
|
1541 } |
|
1542 |
|
1543 // ----------------------------------------------------------------------------- |
|
1544 // CAknColourSelectionGrid::NewL |
|
1545 // Two-phased constructor. |
|
1546 // ----------------------------------------------------------------------------- |
|
1547 // |
|
1548 EXPORT_C CAknColourSelectionGrid *CAknColourSelectionGrid::NewL( |
|
1549 CArrayFixFlat<TRgb> *aColours, |
|
1550 TBool aNoneExist, |
|
1551 TBool& aNoneChosen, |
|
1552 TRgb& aColourChosen) |
|
1553 { |
|
1554 |
|
1555 |
|
1556 CAknColourSelectionGrid *self = new(ELeave)CAknColourSelectionGrid; |
|
1557 |
|
1558 self->iColours = aColours; |
|
1559 self->iNoneExist = aNoneExist; |
|
1560 self->iNoneChosen = &aNoneChosen; |
|
1561 self->iColourChosen = &aColourChosen; |
|
1562 |
|
1563 return (self); |
|
1564 |
|
1565 } |
|
1566 |
|
1567 |
|
1568 // ----------------------------------------------------------------------------- |
|
1569 // CAknColourSelectionGrid::~CAknColourSelectionGrid |
|
1570 // Destructor |
|
1571 // ----------------------------------------------------------------------------- |
|
1572 // |
|
1573 EXPORT_C CAknColourSelectionGrid::~CAknColourSelectionGrid() |
|
1574 { |
|
1575 iAvkonEnv->CancelWsBufferRequest( iWsBufferRequestID ); |
|
1576 delete iExtension; |
|
1577 } |
|
1578 |
|
1579 |
|
1580 // ----------------------------------------------------------------------------- |
|
1581 // CAknColourSelectionGrid::PreLayoutDynInitL() |
|
1582 // |
|
1583 // ----------------------------------------------------------------------------- |
|
1584 // |
|
1585 void CAknColourSelectionGrid::PreLayoutDynInitL() |
|
1586 { |
|
1587 _AKNTRACE_FUNC_ENTER; |
|
1588 iExtension = new (ELeave) CAknColourSelectionGridExtension; |
|
1589 |
|
1590 CAknIconArray* theIcons = new(ELeave) CAknIconArray(iColours->Count()); |
|
1591 CleanupStack::PushL(theIcons); |
|
1592 |
|
1593 CMainTextArray* iconArrays = new (ELeave) CMainTextArray(iNoneExist); |
|
1594 CleanupStack::PushL(iconArrays); |
|
1595 iconArrays->ConstructL(iColours); |
|
1596 for (TInt i=0;i<iColours->Count();i++) |
|
1597 { |
|
1598 theIcons->AppendL( iconArrays->iIcon[i] ); |
|
1599 } |
|
1600 // Load the icon array into the grid |
|
1601 CCoeControl* gridCtrl = Grid(); |
|
1602 CColorGrid* grid = (CColorGrid*)gridCtrl; |
|
1603 |
|
1604 grid->ItemDrawer()->FormattedCellData()->SetIconArray(theIcons); |
|
1605 grid->Model()->SetItemTextArray(iconArrays); |
|
1606 CleanupStack::Pop(); // iconArrays |
|
1607 CleanupStack::Pop(); // theIcons |
|
1608 |
|
1609 SetLineNonFocusing(EColourGridPopup); |
|
1610 if ( iNoneBox && iNoneBox->IsLegacyMode() ) |
|
1611 { |
|
1612 SetLineNonFocusing(EColourGridPopupNone); |
|
1613 } |
|
1614 |
|
1615 grid->ItemDrawer()->FormattedCellData()->SetSkinEnabledL(ETrue); |
|
1616 |
|
1617 CCoeControl *popupHeadingCtrl = ControlOrNull(EColourGridPopup); |
|
1618 if (popupHeadingCtrl) |
|
1619 { |
|
1620 STATIC_CAST(CAknPopupHeadingPane*, popupHeadingCtrl)->SetLayout(CAknPopupHeadingPane::EColourSelectionGridHeadingPane); |
|
1621 } |
|
1622 _AKNTRACE_FUNC_EXIT; |
|
1623 } |
|
1624 |
|
1625 // ----------------------------------------------------------------------------- |
|
1626 // CAknColourSelectionGrid::SetSizeAndPosition() |
|
1627 // |
|
1628 // ----------------------------------------------------------------------------- |
|
1629 // |
|
1630 void CAknColourSelectionGrid::SetSizeAndPosition( const TSize& aSize ) |
|
1631 { |
|
1632 _AKNTRACE_FUNC_ENTER; |
|
1633 // Set skin id |
|
1634 MAknsControlContext *cc = AknsDrawUtils::ControlContext(this); |
|
1635 if (cc) |
|
1636 { |
|
1637 const TAknsItemID *frameCenterId = &KAknsIIDQsnFrPopupCenter; |
|
1638 |
|
1639 CAknsBasicBackgroundControlContext *bcc = |
|
1640 (CAknsBasicBackgroundControlContext*) cc; |
|
1641 bcc->SetBitmap( *frameCenterId ); |
|
1642 } |
|
1643 |
|
1644 if ( AknLayoutUtils::PenEnabled() ) |
|
1645 { |
|
1646 CAknDialog::SetSizeAndPosition( aSize ); |
|
1647 } |
|
1648 else |
|
1649 { |
|
1650 TRect applicationRect = iAvkonAppUi->ApplicationRect(); |
|
1651 TRect colourSelectionDialogRect(ColourSelectionDialogRect()); |
|
1652 |
|
1653 CCoeControl *gridCtrl = ControlOrNull(ECtrlGridType); |
|
1654 if (gridCtrl) |
|
1655 { |
|
1656 CAknColorSelectionGridControl *ctrl = |
|
1657 (CAknColorSelectionGridControl*)gridCtrl; |
|
1658 ctrl->SetParentRects(applicationRect, colourSelectionDialogRect); |
|
1659 } |
|
1660 SetRect(colourSelectionDialogRect); |
|
1661 } |
|
1662 _AKNTRACE_FUNC_EXIT; |
|
1663 } |
|
1664 |
|
1665 // ---------------------------------------------------------------------------- |
|
1666 // CAknColourSelectionGrid::ExecuteLD() |
|
1667 // |
|
1668 // ---------------------------------------------------------------------------- |
|
1669 // |
|
1670 EXPORT_C TBool CAknColourSelectionGrid::ExecuteLD() |
|
1671 { |
|
1672 return(CAknDialog::ExecuteLD(iNoneExist ? R_COLOUR_SELECTION_GRID_WITH_NONE_FIELD : R_COLOUR_SELECTION_GRID_WITHOUT_NONE_FIELD)); |
|
1673 } |
|
1674 |
|
1675 // ----------------------------------------------------------------------------- |
|
1676 // CAknColourSelectionGrid::OkToExitL() |
|
1677 // |
|
1678 // ----------------------------------------------------------------------------- |
|
1679 // |
|
1680 TBool CAknColourSelectionGrid::OkToExitL(TInt aButton) |
|
1681 { |
|
1682 _AKNTRACE_FUNC_ENTER; |
|
1683 // close the color grid: |
|
1684 // if the NGA effects are off, use “pop-up”. |
|
1685 // If NGA effects are on, use “pop-up closed”. |
|
1686 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1687 |
|
1688 switch (aButton) |
|
1689 { |
|
1690 case EAknSoftkeyInsert: |
|
1691 case EEikBidOk: |
|
1692 { |
|
1693 if ( feedback ) |
|
1694 { |
|
1695 feedback->InstantFeedback( ETouchFeedbackBasic ); |
|
1696 } |
|
1697 TInt index = iGrid->CurrentItemIndex(); |
|
1698 |
|
1699 if (iNoneBox) |
|
1700 { |
|
1701 *iNoneChosen = iNoneBox->IsFocused(); |
|
1702 } |
|
1703 else |
|
1704 { |
|
1705 *iNoneChosen = EFalse; |
|
1706 } |
|
1707 *iColourChosen = iColours->At(index); |
|
1708 break; |
|
1709 } |
|
1710 default: |
|
1711 { |
|
1712 if ( feedback ) |
|
1713 { |
|
1714 if( AknLayoutUtils::PenEnabled() ) |
|
1715 { |
|
1716 if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) ) |
|
1717 { |
|
1718 feedback->InstantFeedback( ETouchFeedbackDecreasingPopUp ); |
|
1719 } |
|
1720 else |
|
1721 { |
|
1722 feedback->InstantFeedback( ETouchFeedbackPopUp ); |
|
1723 } |
|
1724 } |
|
1725 } |
|
1726 break; |
|
1727 } |
|
1728 } |
|
1729 _AKNTRACE_FUNC_EXIT; |
|
1730 return ETrue; |
|
1731 } |
|
1732 |
|
1733 // ----------------------------------------------------------------------------- |
|
1734 // CAknColourSelectionGrid::PostLayoutDynInitL() |
|
1735 // |
|
1736 // ----------------------------------------------------------------------------- |
|
1737 // |
|
1738 void CAknColourSelectionGrid::PostLayoutDynInitL() |
|
1739 { |
|
1740 _AKNTRACE_FUNC_ENTER; |
|
1741 CCoeControl* gridCtrl = Grid(); |
|
1742 if (gridCtrl) |
|
1743 { |
|
1744 CColorGrid* grid = (CColorGrid*)gridCtrl; |
|
1745 grid->ItemDrawer()->FormattedCellData()->SetRespectFocus(ETrue); |
|
1746 if (*iNoneChosen==EFalse) |
|
1747 { |
|
1748 for (TInt i=0;i<iColours->Count();i++) |
|
1749 { |
|
1750 if (iColours->At(i) == *iColourChosen) |
|
1751 { |
|
1752 TBool redrawDisabled = grid->GridView()->RedrawDisabled(); |
|
1753 grid->GridView()->SetDisableRedraw(ETrue); |
|
1754 grid->SetCurrentDataIndex(i); |
|
1755 grid->GridView()->SetDisableRedraw(redrawDisabled); |
|
1756 |
|
1757 break; |
|
1758 } |
|
1759 } |
|
1760 grid->SetFocus(ETrue); |
|
1761 } |
|
1762 else |
|
1763 { |
|
1764 if (iNoneBox) |
|
1765 { |
|
1766 iNoneBox->SetFocus(ETrue); |
|
1767 } |
|
1768 else |
|
1769 { |
|
1770 grid->SetFocus(ETrue); |
|
1771 } |
|
1772 } |
|
1773 } |
|
1774 _AKNTRACE_FUNC_EXIT; |
|
1775 } |
|
1776 |
|
1777 |
|
1778 // ----------------------------------------------------------------------------- |
|
1779 // CAknColourSelectionGrid::CreateCustomControlL() |
|
1780 // |
|
1781 // ----------------------------------------------------------------------------- |
|
1782 // |
|
1783 SEikControlInfo CAknColourSelectionGrid::CreateCustomControlL( |
|
1784 TInt aControlType ) |
|
1785 { |
|
1786 _AKNTRACE_FUNC_ENTER; |
|
1787 // open the color grid: |
|
1788 // if the NGA effects are off, use “pop-up”. |
|
1789 // If NGA effects are on, use “increasing long touch”. |
|
1790 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1791 if ( feedback ) |
|
1792 { |
|
1793 if( AknLayoutUtils::PenEnabled() ) |
|
1794 { |
|
1795 if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) ) |
|
1796 { |
|
1797 feedback->InstantFeedback( ETouchFeedbackIncreasingPopUp ); |
|
1798 } |
|
1799 else |
|
1800 { |
|
1801 feedback->InstantFeedback( ETouchFeedbackPopUp ); |
|
1802 } |
|
1803 } |
|
1804 } |
|
1805 |
|
1806 // Create the grid control. CAknDialog will CreateFromResourceL() it |
|
1807 SEikControlInfo control = {NULL, 0, 0}; |
|
1808 if( iNoneExist && !iNoneBox) |
|
1809 { |
|
1810 iNoneBox = new (ELeave) CNoneField( |
|
1811 iAvkonAppUi->IsSingleClickCompatible() ); |
|
1812 iNoneBox->SetPressDownEffect( EFalse ); |
|
1813 if ( AknLayoutUtils::PenEnabled() ) |
|
1814 { |
|
1815 // Nonefield will inform selecting it with stylus via this observer interface |
|
1816 iNoneBox->SetNoneFieldObserver( this ); |
|
1817 } |
|
1818 |
|
1819 if (aControlType == EAknCtColourSelectionDialogNoneField) |
|
1820 { |
|
1821 // Legacy none field. |
|
1822 iNoneBox->SetLegacyMode(ETrue); |
|
1823 control.iControl = iNoneBox; |
|
1824 control.iTrailerTextId = 0; |
|
1825 control.iFlags = 0; |
|
1826 _AKNTRACE_FUNC_EXIT; |
|
1827 return control; |
|
1828 } |
|
1829 } |
|
1830 CColorGrid* grid = new (ELeave) CColorGrid; |
|
1831 CCoeControl* colorSelectionGridControl; |
|
1832 CleanupStack::PushL(grid); |
|
1833 colorSelectionGridControl = new (ELeave) CAknColorSelectionGridControl( |
|
1834 grid, iNoneBox, iAvkonAppUi->IsSingleClickCompatible() ); |
|
1835 CleanupStack::Pop(); |
|
1836 iGrid = grid; |
|
1837 iGrid->SetNoneExist(iNoneExist); |
|
1838 if (aControlType == EAknCtColourSelectionDialogGrid) |
|
1839 { |
|
1840 grid->SetLegacyMode(ETrue); |
|
1841 } |
|
1842 |
|
1843 if ( AknLayoutUtils::PenEnabled() ) |
|
1844 { |
|
1845 // ListBox informs us selectioning via this observer interface. |
|
1846 iGrid->SetListBoxObserver( this ); |
|
1847 } |
|
1848 |
|
1849 control.iControl = colorSelectionGridControl; |
|
1850 control.iTrailerTextId = 0; |
|
1851 control.iFlags = 0; |
|
1852 _AKNTRACE_FUNC_EXIT; |
|
1853 return control; |
|
1854 } |
|
1855 |
|
1856 |
|
1857 |
|
1858 |
|
1859 |
|
1860 // ----------------------------------------------------------------------------- |
|
1861 // CAknColourSelectionGrid::OfferKeyEventL() |
|
1862 // |
|
1863 // ----------------------------------------------------------------------------- |
|
1864 // |
|
1865 TKeyResponse CAknColourSelectionGrid::OfferKeyEventL( |
|
1866 const TKeyEvent& aKeyEvent, |
|
1867 TEventCode aType) |
|
1868 { |
|
1869 _AKNTRACE_FUNC_ENTER; |
|
1870 if ( IsFocused() || |
|
1871 (aType == EEventKey && aKeyEvent.iCode == EKeyEscape) |
|
1872 ) |
|
1873 { |
|
1874 _AKNTRACE_FUNC_EXIT; |
|
1875 return (CEikDialog::OfferKeyEventL(aKeyEvent, aType)); |
|
1876 } |
|
1877 else |
|
1878 { |
|
1879 _AKNTRACE_FUNC_EXIT; |
|
1880 return EKeyWasNotConsumed; |
|
1881 } |
|
1882 } |
|
1883 |
|
1884 // ----------------------------------------------------------------------------- |
|
1885 // CAknColourSelectionGrid::Grid() |
|
1886 // |
|
1887 // ----------------------------------------------------------------------------- |
|
1888 // |
|
1889 CAknGrid *CAknColourSelectionGrid::Grid() const |
|
1890 { |
|
1891 CCoeControl *gridCtrl = ControlOrNull(ECtrlGridType); |
|
1892 if (!gridCtrl) |
|
1893 { |
|
1894 return NULL; |
|
1895 } |
|
1896 CAknColorSelectionGridControl *ctrl = (CAknColorSelectionGridControl*)gridCtrl; |
|
1897 CAknGrid *grid = ctrl->Grid(); |
|
1898 return grid; |
|
1899 } |
|
1900 |
|
1901 |
|
1902 // --------------------------------------------------------------------------- |
|
1903 // CAknColourSelectionGrid::ActivateL() |
|
1904 // --------------------------------------------------------------------------- |
|
1905 // |
|
1906 void CAknColourSelectionGrid::ActivateL() |
|
1907 { |
|
1908 CCoeControl::ActivateL(); |
|
1909 } |
|
1910 |
|
1911 |
|
1912 // --------------------------------------------------------------------------- |
|
1913 // CAknColourSelectionGrid::HandleListBoxEventL() |
|
1914 // Handles list box events. |
|
1915 // --------------------------------------------------------------------------- |
|
1916 // |
|
1917 void CAknColourSelectionGrid::HandleListBoxEventL( CEikListBox* aListBox, |
|
1918 TListBoxEvent aEventType ) |
|
1919 { |
|
1920 _AKNTRACE_FUNC_ENTER; |
|
1921 if ( !iExtension ) |
|
1922 { |
|
1923 iExtension = new (ELeave) CAknColourSelectionGridExtension; |
|
1924 } |
|
1925 |
|
1926 if ( AknLayoutUtils::PenEnabled() ) |
|
1927 { |
|
1928 switch ( aEventType ) |
|
1929 { |
|
1930 case MEikListBoxObserver::EEventItemClicked: |
|
1931 // This event will be sent when single click is enabled |
|
1932 case MEikListBoxObserver::EEventItemSingleClicked: |
|
1933 { |
|
1934 _AKNTRACE( "[%s] EEventItemClicked or EEventItemSingleClicked", |
|
1935 __FUNCTION__ ); |
|
1936 if ( aListBox == iGrid && !iExtension->iIsDragged ) |
|
1937 { |
|
1938 iExtension->iFlags |= ECSelGridCloseAfterDPageClicked; |
|
1939 } |
|
1940 break; |
|
1941 } |
|
1942 case MEikListBoxObserver::EEventItemDraggingActioned: |
|
1943 { |
|
1944 _AKNTRACE( "[%s] EEventItemDraggingActioned", |
|
1945 __FUNCTION__ ); |
|
1946 iExtension->iIsDragged = ETrue; |
|
1947 iGrid->CleanPressedDownState(); |
|
1948 iExtension->iFlags &= ~ECSelGridCloseAfterDPageClicked; |
|
1949 break; |
|
1950 } |
|
1951 case MEikListBoxObserver::EEventPenDownOnItem: |
|
1952 { |
|
1953 _AKNTRACE( "[%s] EEventPenDownOnItem", |
|
1954 __FUNCTION__ ); |
|
1955 iExtension->iIsDragged = EFalse; |
|
1956 iGrid->SetPressedDownState(); |
|
1957 break; |
|
1958 } |
|
1959 default: |
|
1960 { |
|
1961 break; |
|
1962 } |
|
1963 } |
|
1964 } |
|
1965 _AKNTRACE_FUNC_EXIT; |
|
1966 } |
|
1967 |
|
1968 |
|
1969 // --------------------------------------------------------------------------- |
|
1970 // Handles pointer events |
|
1971 // --------------------------------------------------------------------------- |
|
1972 // |
|
1973 EXPORT_C void CAknColourSelectionGrid::HandlePointerEventL( |
|
1974 const TPointerEvent& aPointerEvent ) |
|
1975 { |
|
1976 _AKNTRACE_FUNC_ENTER; |
|
1977 if ( !iExtension ) |
|
1978 { |
|
1979 iExtension = new (ELeave) CAknColourSelectionGridExtension; |
|
1980 } |
|
1981 |
|
1982 if ( !Rect().Contains( aPointerEvent.iPosition ) ) |
|
1983 { |
|
1984 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
1985 { |
|
1986 TryExitL( EAknSoftkeyCancel ); |
|
1987 _AKNTRACE_FUNC_EXIT; |
|
1988 return; |
|
1989 } |
|
1990 |
|
1991 if ( aPointerEvent.iType == TPointerEvent::EDrag ) |
|
1992 { |
|
1993 iExtension->iIsDragged = ETrue; |
|
1994 } |
|
1995 } |
|
1996 else |
|
1997 { |
|
1998 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
1999 { |
|
2000 iExtension->iIsDragged = EFalse; |
|
2001 } |
|
2002 |
|
2003 CAknDialog::HandlePointerEventL( aPointerEvent ); |
|
2004 } |
|
2005 _AKNTRACE_FUNC_EXIT; |
|
2006 } |
|
2007 |
|
2008 |
|
2009 // --------------------------------------------------------------------------- |
|
2010 // Handles tap event to the CNoneField. |
|
2011 // --------------------------------------------------------------------------- |
|
2012 // |
|
2013 void CAknColourSelectionGrid::HandleControlEventL( CCoeControl* aControl, |
|
2014 TCoeEvent aEventType ) |
|
2015 { |
|
2016 if ( AknLayoutUtils::PenEnabled() ) |
|
2017 { |
|
2018 if ( iExtension && |
|
2019 aControl == iNoneBox && |
|
2020 aEventType == EEventRequestExit && |
|
2021 !iExtension->iIsDragged ) |
|
2022 { |
|
2023 iExtension->iFlags |= ECSelGridCloseAfterDPageClicked; |
|
2024 } |
|
2025 } |
|
2026 } |
|
2027 |
|
2028 |
|
2029 // --------------------------------------------------------------------------- |
|
2030 // Handles closing the colour selection grid dialog after selection |
|
2031 // has been done by tapping. |
|
2032 // --------------------------------------------------------------------------- |
|
2033 // |
|
2034 void CAknColourSelectionGrid::HandleDialogPageEventL( TInt aEventID ) |
|
2035 { |
|
2036 if ( AknLayoutUtils::PenEnabled() ) |
|
2037 { |
|
2038 if ( iExtension && |
|
2039 aEventID == MEikDialogPageObserver::EDialogPageTapped && |
|
2040 iExtension->iFlags & ECSelGridCloseAfterDPageClicked ) |
|
2041 { |
|
2042 iExtension->iFlags = 0; |
|
2043 // Exit requested, exit with ok. |
|
2044 TryExitL( EAknSoftkeyOk ); |
|
2045 } |
|
2046 } |
|
2047 |
|
2048 } |
|
2049 |
|
2050 // End of File |