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