|
1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Grid for smile icons |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "cimcvappsmileicongrid.h" |
|
21 #include "imcvappsmileutility.hrh" |
|
22 #include <AknUtils.h> |
|
23 #include <AknIconUtils.h> |
|
24 #include <AknLayout.lag> |
|
25 #include <gulicon.h> |
|
26 #include <eikdialg.h> |
|
27 #include <AknsDrawUtils.h> |
|
28 #include <aknappui.h> |
|
29 #include <aknlayoutscalable_avkon.cdl.h> |
|
30 #include <AknDef.h> |
|
31 #include "imcvlogger.h" |
|
32 #include "imcvuiapputils.h" |
|
33 |
|
34 #include "mimcvtapeventobserver.h" |
|
35 |
|
36 // CONSTANTS |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CIMCVAppSmileIconGrid::NewL |
|
41 // (other items were commented in a header). |
|
42 // ----------------------------------------------------------------------------- |
|
43 // Two-phased constructor. |
|
44 CIMCVAppSmileIconGrid* CIMCVAppSmileIconGrid::NewL( CEikDialog* aParent, |
|
45 const RPointerArray<CGulIcon>& aIconArray ) |
|
46 { |
|
47 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::NewL() start") ); |
|
48 CIMCVAppSmileIconGrid* self = new (ELeave) CIMCVAppSmileIconGrid( aParent, |
|
49 aIconArray ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop( self ); |
|
53 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::NewL() end") ); |
|
54 return self; |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CIMCVAppSmileIconGrid::~CIMCVAppSmileIconGrid |
|
59 // ----------------------------------------------------------------------------- |
|
60 CIMCVAppSmileIconGrid::~CIMCVAppSmileIconGrid() |
|
61 { |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CIMCVAppSmileIconGrid::CIMCVAppSmileIconGrid |
|
66 // (other items were commented in a header). |
|
67 // ----------------------------------------------------------------------------- |
|
68 // C++ constructor can NOT contain any code, that |
|
69 // might leave. |
|
70 // |
|
71 CIMCVAppSmileIconGrid::CIMCVAppSmileIconGrid( CEikDialog* aParent, |
|
72 const RPointerArray<CGulIcon>& aIconArray ) |
|
73 :iParent( aParent ), iIconArray( aIconArray ) |
|
74 { |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CIMCVAppSmileIconGrid::ConstructL |
|
79 // (other items were commented in a header). |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 // default constructor can leave. |
|
83 void CIMCVAppSmileIconGrid::ConstructL() |
|
84 { |
|
85 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::ConstructL() start") ); |
|
86 iIconCount = iIconArray.Count(); |
|
87 |
|
88 iIsMirrored = ETrue ; |
|
89 SetContainerWindowL( *iParent ); |
|
90 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::ConstructL() end") ); |
|
91 } |
|
92 |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CIMCVAppSmileIconGrid::MoveCursor |
|
96 // Move cursor and redraw highlight. |
|
97 // Called when arrow-key is pressed. |
|
98 // (other items were commented in a header). |
|
99 // --------------------------------------------------------- |
|
100 // |
|
101 void CIMCVAppSmileIconGrid::MoveCursor( TInt aKeyCode ) |
|
102 { |
|
103 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::MoveCursor() start") ); |
|
104 iPrevCursorPos = iCursorPos; |
|
105 |
|
106 switch( aKeyCode ) |
|
107 { |
|
108 case EKeyLeftArrow: |
|
109 { |
|
110 if( AknLayoutUtils::LayoutMirrored() ) |
|
111 { |
|
112 iCursorPos++; |
|
113 if( iCursorPos >= iIconCount ) |
|
114 { |
|
115 iCursorPos = 0; |
|
116 } |
|
117 } |
|
118 else |
|
119 { |
|
120 iCursorPos--; |
|
121 if( iCursorPos < 0 ) |
|
122 { |
|
123 iCursorPos = iIconCount - 1; |
|
124 } |
|
125 } |
|
126 break; |
|
127 } |
|
128 case EKeyRightArrow: |
|
129 { |
|
130 if( AknLayoutUtils::LayoutMirrored() ) |
|
131 { |
|
132 iCursorPos--; |
|
133 if( iCursorPos < 0 ) |
|
134 { |
|
135 iCursorPos = iIconCount - 1; |
|
136 } |
|
137 } |
|
138 else |
|
139 { |
|
140 iCursorPos++; |
|
141 if( iCursorPos >= iIconCount ) |
|
142 { |
|
143 iCursorPos = 0; |
|
144 } |
|
145 } |
|
146 break; |
|
147 } |
|
148 case EKeyUpArrow: |
|
149 { |
|
150 if( iCursorPos < iMaxColumns ) |
|
151 { |
|
152 iCursorPos += ( iRowCount * iMaxColumns ) - 1; |
|
153 |
|
154 if( iCursorPos >= iIconCount ) |
|
155 { |
|
156 iCursorPos -= iMaxColumns; |
|
157 } |
|
158 |
|
159 if( iCursorPos < 0 ) |
|
160 { |
|
161 iCursorPos = iIconCount - 1; |
|
162 } |
|
163 } |
|
164 else |
|
165 { |
|
166 iCursorPos -= iMaxColumns; |
|
167 } |
|
168 break; |
|
169 } |
|
170 case EKeyDownArrow: |
|
171 { |
|
172 if( iCursorPos < ( iIconCount - iMaxColumns ) ) |
|
173 { |
|
174 iCursorPos += iMaxColumns; |
|
175 } |
|
176 else |
|
177 { |
|
178 iCursorPos %= iMaxColumns; |
|
179 iCursorPos++; |
|
180 if( iCursorPos >= iMaxColumns || |
|
181 iCursorPos >= iIconCount ) |
|
182 { |
|
183 iCursorPos = 0; |
|
184 } |
|
185 } |
|
186 break; |
|
187 } |
|
188 default: |
|
189 { |
|
190 return; |
|
191 } |
|
192 } |
|
193 |
|
194 DrawDeferred(); |
|
195 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::MoveCursor() end") ); |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------- |
|
199 // CIMCVAppSmileIconGrid::SelectedBitmapId |
|
200 // Called when OK-key or Select-softkey is pressed. |
|
201 // (other items were commented in a header). |
|
202 // --------------------------------------------------------- |
|
203 // |
|
204 TInt CIMCVAppSmileIconGrid::SelectedBitmapId() |
|
205 { |
|
206 return iCursorPos; |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------- |
|
210 // CIMCVAppSmileIconGrid::HeightInRows |
|
211 // Return row count of grid. |
|
212 // (other items were commented in a header). |
|
213 // --------------------------------------------------------- |
|
214 // |
|
215 TInt CIMCVAppSmileIconGrid::HeightInRows() |
|
216 { |
|
217 return iRowCount; |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------- |
|
221 // CIMCVAppSmileIconGrid::SetLayout |
|
222 // Set layout of identifier grid. |
|
223 // (other items were commented in a header). |
|
224 // --------------------------------------------------------- |
|
225 // |
|
226 void CIMCVAppSmileIconGrid::SetLayout() |
|
227 { |
|
228 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::SetLayout() start") ); |
|
229 iIsMirrored = AknLayoutUtils::LayoutMirrored() ; |
|
230 |
|
231 // popup_grid_graphic_window (Parent) |
|
232 TRect parentRect( iParent->Rect() ); |
|
233 |
|
234 // listscroll_popup_graphic_pane (this compoment) |
|
235 TAknLayoutRect listLayoutRect; |
|
236 listLayoutRect.LayoutRect( |
|
237 parentRect, |
|
238 AknLayoutScalable_Avkon::listscroll_popup_graphic_pane() ); |
|
239 |
|
240 // grid_graphic_popup_pane |
|
241 TAknLayoutRect gridLayoutRect; |
|
242 gridLayoutRect.LayoutRect( |
|
243 listLayoutRect.Rect(), |
|
244 AknLayoutScalable_Avkon::grid_graphic_popup_pane( 0 ) ); |
|
245 |
|
246 // cell_graphic_popup_pane (upper left cell) |
|
247 TAknLayoutRect oneCellRect; |
|
248 oneCellRect.LayoutRect( |
|
249 gridLayoutRect.Rect(), |
|
250 AknLayoutScalable_Avkon::cell_graphic_popup_pane( 0, 0, 0 ) ); |
|
251 |
|
252 iFirstCell = oneCellRect.Rect(); |
|
253 iCellWidth = iFirstCell.Width(); |
|
254 iCellHeight = iFirstCell.Height(); |
|
255 |
|
256 // cell_graphic_popup_pane_g1 (icon size) |
|
257 TAknLayoutRect myIconRect; |
|
258 myIconRect.LayoutRect( |
|
259 iFirstCell, |
|
260 AknLayoutScalable_Avkon::cell_graphic2_pane_g5(0) ); |
|
261 |
|
262 iIconSize = myIconRect.Rect().Size(); |
|
263 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::SetLayout() end") ); |
|
264 } |
|
265 |
|
266 // --------------------------------------------------------- |
|
267 // CIMCVAppSmileIconGrid::MinimumSize |
|
268 // Return minimum size to use the control. |
|
269 // (other items were commented in a header). |
|
270 // --------------------------------------------------------- |
|
271 // |
|
272 TSize CIMCVAppSmileIconGrid::MinimumSize() |
|
273 { |
|
274 TAknLayoutRect gridRect; |
|
275 gridRect.LayoutRect( |
|
276 iParent->Rect(), |
|
277 AknLayoutScalable_Avkon::listscroll_popup_graphic_pane() ); |
|
278 return gridRect.Rect().Size(); |
|
279 } |
|
280 |
|
281 // --------------------------------------------------------- |
|
282 // CIMCVAppSmileIconGrid::SizeChanged |
|
283 // Control rectangle is set. |
|
284 // (other items were commented in a header). |
|
285 // --------------------------------------------------------- |
|
286 // |
|
287 void CIMCVAppSmileIconGrid::SizeChanged() |
|
288 { |
|
289 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::SizeChanged() start") ); |
|
290 SetLayout(); |
|
291 |
|
292 TInt iconCount( iIconArray.Count() ); |
|
293 for ( TInt i = 0; i < iconCount; i++ ) |
|
294 { |
|
295 AknIconUtils::SetSize( iIconArray[i]->Bitmap(), |
|
296 iIconSize ); |
|
297 } |
|
298 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::SizeChanged() end") ); |
|
299 } |
|
300 |
|
301 // --------------------------------------------------------- |
|
302 // CIMCVAppSmileIconGrid::HandleResourceChange |
|
303 // Notifier for changing layout |
|
304 // (other items were commented in a header). |
|
305 // --------------------------------------------------------- |
|
306 // |
|
307 |
|
308 void CIMCVAppSmileIconGrid::HandleResourceChange( TInt aType ) |
|
309 { |
|
310 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::HandleResourceChange() start") ); |
|
311 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
312 { |
|
313 SetLayout(); |
|
314 } |
|
315 else |
|
316 { |
|
317 CCoeControl::HandleResourceChange( aType ); |
|
318 } |
|
319 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::HandleResourceChange() end") ); |
|
320 } |
|
321 |
|
322 |
|
323 // --------------------------------------------------------- |
|
324 // CIMCVAppSmileIconGrid::Draw |
|
325 // Drawing control. |
|
326 // (other items were commented in a header). |
|
327 // --------------------------------------------------------- |
|
328 // |
|
329 void CIMCVAppSmileIconGrid::Draw( const TRect& /* aRect */ ) const |
|
330 { |
|
331 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::Draw() start") ); |
|
332 CWindowGc& gc = SystemGc(); |
|
333 |
|
334 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
335 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
336 |
|
337 if( !iDragEvent ) |
|
338 { |
|
339 //draw the grid |
|
340 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
341 gc.SetBrushStyle(CGraphicsContext::ENullBrush); |
|
342 gc.SetPenSize(TSize(1,1)); |
|
343 gc.SetPenColor(AKN_LAF_COLOR(215)); |
|
344 |
|
345 // For some reason the dialog does not draw it's background |
|
346 // completely, so we'll have to do it here. |
|
347 // This should work with bgRect = Rect(), but it doesn't. |
|
348 // Change this if you know how it should be done. |
|
349 TRect bgRect = iParent->Rect(); |
|
350 bgRect.iTl.iY = Rect().iTl.iY; |
|
351 // --- |
|
352 |
|
353 TBool skins = AknsDrawUtils::Background( skin, cc, this, gc, bgRect ); |
|
354 |
|
355 if ( !skins ) |
|
356 { |
|
357 TRgb color = AKN_LAF_COLOR( 0 ); |
|
358 AknsUtils::GetCachedColor(skin,color,KAknsIIDQsnIconColors,EAknsCIQsnIconColorsCG1); |
|
359 gc.SetBrushColor(color); |
|
360 gc.Clear( bgRect ); |
|
361 } |
|
362 |
|
363 TInt lastRowIconsCount = iIconCount % iMaxColumns; |
|
364 if( lastRowIconsCount == 0 && iIconCount > 0 ) |
|
365 { |
|
366 // last row is full |
|
367 lastRowIconsCount = iMaxColumns; |
|
368 } |
|
369 |
|
370 TInt i( 0 ); |
|
371 |
|
372 if(!iIsMirrored) |
|
373 { |
|
374 //draw horizontal lines |
|
375 for( i = 0; i <= iRowCount; ++i ) |
|
376 { |
|
377 TPoint startPoint( iFirstCell.iTl ); |
|
378 TPoint endPoint( iFirstCell.iTl ); |
|
379 startPoint.iY += i * iCellHeight; |
|
380 endPoint.iY += i * iCellHeight; |
|
381 endPoint.iX += ( ( i == iRowCount ) || ( i == 0 && iRowCount == 1 ) |
|
382 ? ( lastRowIconsCount ) |
|
383 * iCellWidth : iMaxColumns * iCellWidth ); |
|
384 // add 1 pixel to remove the gap from bottom right corners |
|
385 ++endPoint.iX; |
|
386 gc.DrawLine( startPoint, endPoint ); |
|
387 } |
|
388 |
|
389 //draw vertical lines |
|
390 for( i = 0; i <= iMaxColumns; ++i ) |
|
391 { |
|
392 TPoint startPoint( iFirstCell.iTl ); |
|
393 TPoint endPoint( iFirstCell.iTl ); |
|
394 startPoint.iX += i * iCellWidth; |
|
395 endPoint.iX += i * iCellWidth; |
|
396 endPoint.iY += ( i <= lastRowIconsCount ? |
|
397 iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1 ) ); |
|
398 gc.DrawLine( startPoint, endPoint ); |
|
399 } |
|
400 } |
|
401 else |
|
402 { |
|
403 //draw horizontal lines |
|
404 for( i = 0; i <= iRowCount; ++i ) |
|
405 { |
|
406 TPoint startPoint( iFirstCell.iBr.iX, iFirstCell.iTl.iY); |
|
407 TPoint endPoint( iFirstCell.iBr.iX, iFirstCell.iTl.iY ); |
|
408 startPoint.iY += i * iCellHeight; |
|
409 endPoint.iY += i * iCellHeight; |
|
410 endPoint.iX -= ( ( i == iRowCount ) || ( i == 0 && iRowCount == 1 ) |
|
411 ? ( lastRowIconsCount ) |
|
412 * iCellWidth : iMaxColumns * iCellWidth ); |
|
413 // sub 1 pixel to remove the gap from bottom left corners |
|
414 --endPoint.iX; |
|
415 gc.DrawLine( startPoint, endPoint ); |
|
416 } |
|
417 |
|
418 //draw vertical lines |
|
419 for( i = 0; i <= iMaxColumns; ++i ) |
|
420 { |
|
421 TPoint startPoint( iFirstCell.iBr.iX, iFirstCell.iTl.iY ); |
|
422 TPoint endPoint( iFirstCell.iBr.iX, iFirstCell.iTl.iY); |
|
423 startPoint.iX -= i * iCellWidth; |
|
424 endPoint.iX -= i * iCellWidth; |
|
425 endPoint.iY += ( i <= lastRowIconsCount ? |
|
426 iCellHeight * iRowCount : iCellHeight * ( iRowCount - 1 ) ); |
|
427 gc.DrawLine( startPoint, endPoint ); |
|
428 } |
|
429 |
|
430 } |
|
431 |
|
432 //draw icons |
|
433 for( i = 0; i < iIconCount; ++i ) |
|
434 { |
|
435 DrawItem( gc, skins, skin, cc, i, i == iCursorPos ); |
|
436 } |
|
437 } |
|
438 else |
|
439 { |
|
440 // only selection changed, highlight new pos |
|
441 DrawItem( gc, cc != NULL, skin, cc, iCursorPos, ETrue ); |
|
442 // and clear old |
|
443 DrawItem( gc, cc != NULL, skin, cc, iPrevCursorPos, EFalse ); |
|
444 } |
|
445 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::Draw() end") ); |
|
446 } |
|
447 |
|
448 // --------------------------------------------------------- |
|
449 // CIMCVAppSmileIconGrid::DrawItem |
|
450 // (other items were commented in a header). |
|
451 // --------------------------------------------------------- |
|
452 void CIMCVAppSmileIconGrid::DrawItem( CWindowGc& aGc, |
|
453 TBool aSkinEnabled, |
|
454 MAknsSkinInstance* aSkin, |
|
455 MAknsControlContext* aSkinCc, |
|
456 TInt aIndex, TBool aSelected ) const |
|
457 { |
|
458 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::DrawItem() start") ); |
|
459 //lets count currect cell |
|
460 TRect myRect = iFirstCell; |
|
461 TPoint offset; |
|
462 |
|
463 if(!iIsMirrored) |
|
464 { |
|
465 offset.iX = ( aIndex % iMaxColumns ) * iCellWidth; |
|
466 } |
|
467 else |
|
468 { |
|
469 offset.iX = -(( aIndex % iMaxColumns ) * iCellWidth); |
|
470 } |
|
471 |
|
472 offset.iY = aIndex / iMaxColumns * iCellHeight; |
|
473 |
|
474 myRect.Move( offset ); |
|
475 |
|
476 // don't draw bg/highlight over borderlines |
|
477 TRect myHighLightRect = myRect; |
|
478 myHighLightRect.iTl.iX++; |
|
479 myHighLightRect.iTl.iY++; |
|
480 |
|
481 if( aSelected ) |
|
482 { |
|
483 // HIGHLIGHT |
|
484 if( !aSkinEnabled ) |
|
485 { |
|
486 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
487 } |
|
488 |
|
489 TRgb color = AKN_LAF_COLOR(210); |
|
490 AknsUtils::GetCachedColor( aSkin, color, KAknsIIDQsnIconColors, |
|
491 EAknsCIQsnComponentColorsCG17 ); |
|
492 aGc.SetBrushColor( color ); |
|
493 aGc.Clear( myHighLightRect ); |
|
494 } |
|
495 else |
|
496 { |
|
497 TRgb color = AKN_LAF_COLOR( 0 ); |
|
498 AknsUtils::GetCachedColor( aSkin, color, KAknsIIDQsnIconColors, |
|
499 EAknsCIQsnIconColorsCG1 ); |
|
500 aGc.SetBrushColor( color ); |
|
501 if ( aSkinEnabled ) |
|
502 { |
|
503 AknsDrawUtils::Background( aSkin, aSkinCc, aGc, myHighLightRect ); |
|
504 } |
|
505 else |
|
506 { |
|
507 aGc.DrawRect( myHighLightRect ); |
|
508 } |
|
509 } |
|
510 |
|
511 TAknWindowLineLayout myIconLayout( AknLayoutScalable_Avkon::cell_graphic2_pane_g5(0) ); |
|
512 |
|
513 TAknLayoutRect myIconRect; |
|
514 myIconRect.LayoutRect( myRect, myIconLayout ); |
|
515 |
|
516 if( aIndex < iIconArray.Count() ) |
|
517 { |
|
518 myIconRect.DrawImage( aGc, |
|
519 iIconArray[ aIndex ]->Bitmap(), |
|
520 iIconArray[ aIndex ]->Mask() ); |
|
521 } |
|
522 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::DrawItem() end") ); |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------- |
|
526 // CIMCVAppSmileIconGrid::HandlePointerEventL |
|
527 // (other items were commented in a header). |
|
528 // --------------------------------------------------------- |
|
529 // |
|
530 void CIMCVAppSmileIconGrid::HandlePointerEventL( |
|
531 const TPointerEvent& aPointerEvent ) |
|
532 { |
|
533 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::HandlePointerEventL() start") ); |
|
534 if( !IMCVUiAppUtils::PenEnabled() ) |
|
535 { |
|
536 // Ignore event |
|
537 //return; |
|
538 } |
|
539 |
|
540 TInt oldSelection = iCursorPos; |
|
541 TPoint hitPos = aPointerEvent.iPosition; |
|
542 |
|
543 // Convert XY position to linear cursor position |
|
544 hitPos -= iFirstCell.iTl; |
|
545 TInt xPos = hitPos.iX / iCellWidth; |
|
546 TInt yPos = hitPos.iY / iCellHeight; |
|
547 TInt newSelection = yPos * iMaxColumns + xPos; |
|
548 |
|
549 // Check that the selection is inside the grid |
|
550 TBool validItem = xPos <= iMaxColumns - 1 && |
|
551 Rng( 0, newSelection, iIconCount - 1 ) && |
|
552 hitPos.iX >= 0 && |
|
553 hitPos.iY >= 0; |
|
554 if( !validItem ) |
|
555 { |
|
556 // not valid point --> ignore event |
|
557 return; |
|
558 } |
|
559 |
|
560 // Only update if something new was selected |
|
561 if( newSelection != oldSelection ) |
|
562 { |
|
563 // New valid item |
|
564 iPrevCursorPos = iCursorPos; |
|
565 iCursorPos = newSelection; |
|
566 iDragEvent = ETrue; |
|
567 DrawDeferred(); |
|
568 iDragEvent = EFalse; |
|
569 } |
|
570 |
|
571 // Notify observer |
|
572 if( iTapObserver && |
|
573 aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
574 { |
|
575 // Smiley was tapped |
|
576 iTapObserver->HandleTapEventL( MIMCVTapEventObserver::ESingleTap, |
|
577 iTapControlId ); |
|
578 } |
|
579 |
|
580 if( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
581 { |
|
582 // enable dragging when button1 is down |
|
583 EnableDragEvents(); |
|
584 // single tap has to insert the smiley. |
|
585 // this code is not required |
|
586 // Window().SetPointerGrab( ETrue ); |
|
587 |
|
588 // and make sure that we get the dragging events |
|
589 // ClaimPointerGrab( ETrue ); |
|
590 } |
|
591 |
|
592 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
593 IM_CV_LOGS(TXT("CIMCVAppSmileIconGrid::HandlePointerEventL() end") ); |
|
594 } |
|
595 |
|
596 // ----------------------------------------------------------------------------- |
|
597 // CIMCVAppSmileIconGrid::SetTapObserver |
|
598 // (other items were commented in a header). |
|
599 // ----------------------------------------------------------------------------- |
|
600 // |
|
601 void CIMCVAppSmileIconGrid::SetTapObserver( MIMCVTapEventObserver* aObserver, |
|
602 TUint aId ) |
|
603 { |
|
604 iTapObserver = aObserver; |
|
605 iTapControlId = aId; |
|
606 } |
|
607 |
|
608 // ----------------------------------------------------------------------------- |
|
609 // CIMCVAppSmileIconGrid::SetViewableWindowWidth |
|
610 // (other items were commented in a header). |
|
611 // ----------------------------------------------------------------------------- |
|
612 // |
|
613 void CIMCVAppSmileIconGrid::SetViewableWindowWidth(TInt aViewableWidth) |
|
614 { |
|
615 TRect parentRect( iParent->Rect() ); |
|
616 |
|
617 // listscroll_popup_graphic_pane (this compoment) |
|
618 TAknLayoutRect listLayoutRect; |
|
619 listLayoutRect.LayoutRect( |
|
620 parentRect, |
|
621 AknLayoutScalable_Avkon::listscroll_popup_graphic_pane() ); |
|
622 |
|
623 // grid_graphic_popup_pane |
|
624 TAknLayoutRect gridLayoutRect; |
|
625 gridLayoutRect.LayoutRect( |
|
626 listLayoutRect.Rect(), |
|
627 AknLayoutScalable_Avkon::grid_graphic_popup_pane( 0 ) ); |
|
628 |
|
629 // cell_graphic_popup_pane (upper left cell) |
|
630 TAknLayoutRect oneCellRect; |
|
631 oneCellRect.LayoutRect( |
|
632 gridLayoutRect.Rect(), |
|
633 AknLayoutScalable_Avkon::cell_graphic_popup_pane( 0, 0, 0 ) ); |
|
634 |
|
635 TInt cellWidth = oneCellRect.Rect().Width(); |
|
636 |
|
637 iMaxColumns = aViewableWidth/cellWidth; |
|
638 |
|
639 iRowCount = iIconCount / iMaxColumns; |
|
640 |
|
641 if (iIconCount % iMaxColumns) |
|
642 { |
|
643 iRowCount++; |
|
644 } |
|
645 |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CIMCVAppSmileIconGrid::GetFirstCellRect |
|
650 // (other items were commented in a header). |
|
651 // ----------------------------------------------------------------------------- |
|
652 // |
|
653 TRect CIMCVAppSmileIconGrid::GetFirstCellRect() |
|
654 { |
|
655 // popup_grid_graphic_window (Parent) |
|
656 TRect parentRect( iParent->Rect() ); |
|
657 |
|
658 // listscroll_popup_graphic_pane (this compoment) |
|
659 TAknLayoutRect listLayoutRect; |
|
660 listLayoutRect.LayoutRect( |
|
661 parentRect, |
|
662 AknLayoutScalable_Avkon::listscroll_popup_graphic_pane() ); |
|
663 |
|
664 // grid_graphic_popup_pane |
|
665 TAknLayoutRect gridLayoutRect; |
|
666 gridLayoutRect.LayoutRect( |
|
667 listLayoutRect.Rect(), |
|
668 AknLayoutScalable_Avkon::grid_graphic_popup_pane( 0 ) ); |
|
669 |
|
670 // cell_graphic_popup_pane (upper left cell) |
|
671 TAknLayoutRect oneCellRect; |
|
672 oneCellRect.LayoutRect( |
|
673 gridLayoutRect.Rect(), |
|
674 AknLayoutScalable_Avkon::cell_graphic_popup_pane( 0, 0, 0 ) ); |
|
675 |
|
676 return oneCellRect.Rect(); |
|
677 //return iFirstCell; |
|
678 |
|
679 } |
|
680 // End of File |