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