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