20
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "HgScrollbar.h"
|
|
20 |
#include <ganes/HgScrollbarObserverIface.h>
|
|
21 |
#include "HgConstants.h"
|
|
22 |
|
|
23 |
#include <AknsUtils.h>
|
|
24 |
#include <AknUtils.h>
|
|
25 |
#include <AknsDrawUtils.h>
|
|
26 |
|
|
27 |
#include <layoutmetadata.cdl.h>
|
|
28 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
29 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
30 |
|
|
31 |
#include <bitstd.h>
|
|
32 |
#include <gulicon.h>
|
|
33 |
|
|
34 |
#include <AknIconUtils.h>
|
|
35 |
#include <AknsUtils.h>
|
|
36 |
#include <AknsConstants.h>
|
|
37 |
#include <w32std.h>
|
|
38 |
|
|
39 |
// -----------------------------------------------------------------------------
|
|
40 |
// CHgScrollbar::NewL()
|
|
41 |
// -----------------------------------------------------------------------------
|
|
42 |
//
|
|
43 |
CHgScrollbar* CHgScrollbar::NewL( MHgScrollbarObserver& aObserver )
|
|
44 |
{
|
|
45 |
CHgScrollbar* self = new (ELeave) CHgScrollbar( aObserver );
|
|
46 |
CleanupStack::PushL( self );
|
|
47 |
self->ConstructL();
|
|
48 |
CleanupStack::Pop( self );
|
|
49 |
return self;
|
|
50 |
}
|
|
51 |
|
|
52 |
// -----------------------------------------------------------------------------
|
|
53 |
// CHgScrollbar::~CHgScrollbar()
|
|
54 |
// -----------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CHgScrollbar::~CHgScrollbar()
|
|
57 |
{
|
|
58 |
delete iScrollbarBg;
|
|
59 |
delete iScrollbarHandle;
|
|
60 |
delete iScrollbarHandleBg;
|
|
61 |
delete iScrollbarBgSelected;
|
|
62 |
delete iScrollbarHandleSelected;
|
|
63 |
}
|
|
64 |
|
|
65 |
// -----------------------------------------------------------------------------
|
|
66 |
// CHgScrollbar::CHgScrollbar()
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
//
|
|
69 |
CHgScrollbar::CHgScrollbar( MHgScrollbarObserver& aObserver )
|
|
70 |
: iObserver( aObserver ),
|
|
71 |
iStatic( ETrue )
|
|
72 |
{
|
|
73 |
|
|
74 |
}
|
|
75 |
|
|
76 |
// -----------------------------------------------------------------------------
|
|
77 |
// CHgScrollbar::ConstructL()
|
|
78 |
// -----------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
void CHgScrollbar::ConstructL()
|
|
81 |
{
|
|
82 |
}
|
|
83 |
|
|
84 |
// -----------------------------------------------------------------------------
|
|
85 |
// CHgScrollbar::SetScrollbarL()
|
|
86 |
// -----------------------------------------------------------------------------
|
|
87 |
//
|
|
88 |
void CHgScrollbar::InitScrollBarL(
|
|
89 |
TRect aRect,
|
|
90 |
TSize aTotalSize,
|
|
91 |
TSize aViewSize,
|
|
92 |
TBool aLandscapeScrolling )
|
|
93 |
{
|
|
94 |
if( iTotalSize == aTotalSize
|
|
95 |
&& iViewSize == aViewSize
|
|
96 |
&& iLandscapeScrolling == aLandscapeScrolling )
|
|
97 |
{
|
|
98 |
return;
|
|
99 |
}
|
|
100 |
|
|
101 |
TInt variety = aLandscapeScrolling ? 1 : 0;
|
|
102 |
|
|
103 |
TAknLayoutRect layout;
|
|
104 |
layout.LayoutRect(aRect, AknLayoutScalable_Avkon::scroll_pane( variety ));
|
|
105 |
iScrollbarRect = layout.Rect();
|
|
106 |
|
|
107 |
TBool prevStatic = iStatic;
|
|
108 |
|
|
109 |
if((aTotalSize.iHeight <= aViewSize.iHeight && !aLandscapeScrolling)
|
|
110 |
|| (aTotalSize.iWidth <= aViewSize.iWidth && aLandscapeScrolling) )
|
|
111 |
{
|
|
112 |
iTotalSize = aViewSize;
|
|
113 |
iStatic = ETrue;
|
|
114 |
}
|
|
115 |
else
|
|
116 |
{
|
|
117 |
iTotalSize = aTotalSize;
|
|
118 |
iStatic = EFalse;
|
|
119 |
}
|
|
120 |
|
|
121 |
// Do we need to init the bg graphics
|
|
122 |
TBool initBg = (iViewSize != aViewSize) // view size has been changed
|
|
123 |
|| (prevStatic != iStatic) // static value changed
|
|
124 |
|| (iLandscapeScrolling != aLandscapeScrolling); // different scrolling direction
|
|
125 |
|
|
126 |
iViewSize = aViewSize;
|
|
127 |
iLandscapeScrolling = aLandscapeScrolling;
|
|
128 |
iHandlePosition.SetXY(0,0);
|
|
129 |
|
|
130 |
if(iLandscapeScrolling)
|
|
131 |
{
|
|
132 |
iTotalLength = iTotalSize.iWidth - iViewSize.iWidth;
|
|
133 |
}
|
|
134 |
else
|
|
135 |
{
|
|
136 |
iTotalLength = iTotalSize.iHeight - iViewSize.iHeight;
|
|
137 |
}
|
|
138 |
|
|
139 |
// Don't init icons in static mode since they are not drawn
|
|
140 |
if(!iStatic)
|
|
141 |
InitIconsL( initBg );
|
|
142 |
}
|
|
143 |
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
// CHgScrollbar::SetViewPosition()
|
|
146 |
// -----------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
void CHgScrollbar::SetViewPosition( TPoint aPosition )
|
|
149 |
{
|
|
150 |
if(!iStatic)
|
|
151 |
{
|
|
152 |
if(iLandscapeScrolling)
|
|
153 |
{
|
|
154 |
if (AknLayoutUtils::LayoutMirrored())
|
|
155 |
{
|
|
156 |
iHandlePosition.iX = (iScrollLength) * (1.0 - aPosition.iX / TReal(iTotalLength));
|
|
157 |
}
|
|
158 |
else
|
|
159 |
{
|
|
160 |
iHandlePosition.iX = (iScrollLength) * (aPosition.iX / TReal(iTotalLength));
|
|
161 |
}
|
|
162 |
}
|
|
163 |
else
|
|
164 |
{
|
|
165 |
iHandlePosition.iY = (iScrollLength) * (aPosition.iY / TReal(iTotalLength));
|
|
166 |
}
|
|
167 |
CheckHandlePosition( EFalse );
|
|
168 |
}
|
|
169 |
}
|
|
170 |
|
|
171 |
// -----------------------------------------------------------------------------
|
|
172 |
// CHgScrollbar::HandlePointerEventL()
|
|
173 |
// -----------------------------------------------------------------------------
|
|
174 |
//
|
|
175 |
TBool CHgScrollbar::HandlePointerEventL( const TPointerEvent& aEvent )
|
|
176 |
{
|
|
177 |
return HandleScrollBarPointerEvent( aEvent );
|
|
178 |
}
|
|
179 |
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
// CHgScrollbar::HandleScrollBarPointerEvent()
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
//
|
|
184 |
TBool CHgScrollbar::HandleScrollBarPointerEvent( const TPointerEvent& aEvent )
|
|
185 |
{
|
|
186 |
TBool ret = EFalse;
|
|
187 |
// Quick and dirty hack, remove when logic for fetching the correct drag rect is available
|
|
188 |
TRect dragArea( iScrollbarRect );
|
|
189 |
dragArea.iBr.iX += KScrollAreaOffset;
|
|
190 |
dragArea.iTl.iX -= KScrollAreaOffset;
|
|
191 |
|
|
192 |
// Start drag
|
|
193 |
if( aEvent.iType == TPointerEvent::EButton1Down && dragArea.Contains(aEvent.iPosition))
|
|
194 |
{
|
|
195 |
TSize size(iHandleSize);
|
|
196 |
size.iWidth += KScrollAreaOffset*2;
|
|
197 |
TRect handleRect( dragArea.iTl + iHandlePosition, size );
|
|
198 |
iDragging = handleRect.Contains( aEvent.iPosition );
|
|
199 |
iPrevDrag = aEvent.iPosition;
|
|
200 |
iHandler = ret = ETrue;
|
|
201 |
CheckHandlePosition( !iStatic );
|
|
202 |
}
|
|
203 |
|
|
204 |
// Drag
|
|
205 |
if( aEvent.iType == TPointerEvent::EDrag && iHandler)
|
|
206 |
{
|
|
207 |
if( iDragging )
|
|
208 |
{
|
|
209 |
if(iLandscapeScrolling)
|
|
210 |
{
|
|
211 |
iHandlePosition.iX -= iPrevDrag.iX - aEvent.iPosition.iX;
|
|
212 |
}
|
|
213 |
else
|
|
214 |
{
|
|
215 |
iHandlePosition.iY -= iPrevDrag.iY - aEvent.iPosition.iY;
|
|
216 |
}
|
|
217 |
CheckHandlePosition( !iStatic );
|
|
218 |
|
|
219 |
iPrevDrag = aEvent.iPosition;
|
|
220 |
}
|
|
221 |
ret = ETrue;
|
|
222 |
}
|
|
223 |
|
|
224 |
// End drag
|
|
225 |
if( aEvent.iType == TPointerEvent::EButton1Up && iHandler)
|
|
226 |
{
|
|
227 |
if(!iDragging)
|
|
228 |
{
|
|
229 |
TBool below = iLandscapeScrolling ?
|
|
230 |
aEvent.iPosition.iX > iHandlePosition.iX
|
|
231 |
: aEvent.iPosition.iY > iHandlePosition.iY;
|
|
232 |
iHandlePosition += below ? iHandleSize.AsPoint() : -iHandleSize.AsPoint();
|
|
233 |
}
|
|
234 |
CheckHandlePosition( !iStatic );
|
|
235 |
iHandler = iDragging = EFalse;
|
|
236 |
ret = ETrue;
|
|
237 |
}
|
|
238 |
|
|
239 |
return ret;
|
|
240 |
}
|
|
241 |
|
|
242 |
|
|
243 |
// -----------------------------------------------------------------------------
|
|
244 |
// CHgScrollbar::Draw()
|
|
245 |
// -----------------------------------------------------------------------------
|
|
246 |
//
|
|
247 |
void CHgScrollbar::Draw( CWindowGc& aGc )
|
|
248 |
{
|
|
249 |
if(!iStatic)
|
|
250 |
DrawScrollbar( aGc );
|
|
251 |
}
|
|
252 |
|
|
253 |
// -----------------------------------------------------------------------------
|
|
254 |
// CHgScrollbar::DrawScrollbar()
|
|
255 |
// -----------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CHgScrollbar::DrawScrollbar( CWindowGc& aGc )
|
|
258 |
{
|
|
259 |
if(iScrollbarBg && iScrollbarHandle && iScrollbarHandleBg)
|
|
260 |
{
|
|
261 |
if(iHandler)
|
|
262 |
{
|
|
263 |
aGc.BitBltMasked(iScrollbarRect.iTl,
|
|
264 |
iScrollbarHandleBg->Bitmap(),
|
|
265 |
iScrollbarHandleBg->Bitmap()->SizeInPixels(),
|
|
266 |
iScrollbarHandleBg->Mask(),
|
|
267 |
EFalse);
|
|
268 |
|
|
269 |
aGc.BitBltMasked(iScrollbarRect.iTl + iHandlePosition,
|
|
270 |
iScrollbarHandleSelected->Bitmap(),
|
|
271 |
iScrollbarHandleSelected->Bitmap()->SizeInPixels(),
|
|
272 |
iScrollbarHandleSelected->Mask(),
|
|
273 |
EFalse);
|
|
274 |
}
|
|
275 |
else
|
|
276 |
{
|
|
277 |
aGc.BitBltMasked(iScrollbarRect.iTl,
|
|
278 |
iScrollbarBg->Bitmap(),
|
|
279 |
iScrollbarBg->Bitmap()->SizeInPixels(),
|
|
280 |
iScrollbarBg->Mask(),
|
|
281 |
EFalse);
|
|
282 |
|
|
283 |
aGc.BitBltMasked(iScrollbarRect.iTl + iHandlePosition,
|
|
284 |
iScrollbarHandle->Bitmap(),
|
|
285 |
iScrollbarHandle->Bitmap()->SizeInPixels(),
|
|
286 |
iScrollbarHandle->Mask(),
|
|
287 |
EFalse);
|
|
288 |
}
|
|
289 |
}
|
|
290 |
}
|
|
291 |
|
|
292 |
// -----------------------------------------------------------------------------
|
|
293 |
// CHgScrollbar::CheckHandlePosition()
|
|
294 |
// -----------------------------------------------------------------------------
|
|
295 |
//
|
|
296 |
void CHgScrollbar::CheckHandlePosition( TBool aReportChange )
|
|
297 |
{
|
|
298 |
|
|
299 |
if(iLandscapeScrolling)
|
|
300 |
{
|
|
301 |
iHandlePosition.iY = 0;
|
|
302 |
if(iHandlePosition.iX < 0 )
|
|
303 |
iHandlePosition.iX = 0;
|
|
304 |
if(iHandlePosition.iX > iScrollLength)
|
|
305 |
iHandlePosition.iX = iScrollLength;
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
iHandlePosition.iX = 0;
|
|
310 |
if(iHandlePosition.iY < 0 )
|
|
311 |
iHandlePosition.iY = 0;
|
|
312 |
if(iHandlePosition.iY > iScrollLength)
|
|
313 |
iHandlePosition.iY = iScrollLength;
|
|
314 |
}
|
|
315 |
if( aReportChange )
|
|
316 |
{
|
|
317 |
TPoint pos (iViewSize.iWidth/2, iViewSize.iHeight/2);
|
|
318 |
if(iLandscapeScrolling)
|
|
319 |
{
|
|
320 |
if (AknLayoutUtils::LayoutMirrored())
|
|
321 |
{
|
|
322 |
pos.iX += (1.0 - iHandlePosition.iX / TReal(iScrollLength)) * (iTotalLength);
|
|
323 |
}
|
|
324 |
else
|
|
325 |
{
|
|
326 |
pos.iX += (iHandlePosition.iX / TReal(iScrollLength)) * (iTotalLength);
|
|
327 |
}
|
|
328 |
}
|
|
329 |
else
|
|
330 |
{
|
|
331 |
pos.iY += (iHandlePosition.iY / TReal(iScrollLength)) * (iTotalLength);
|
|
332 |
}
|
|
333 |
|
|
334 |
iObserver.ScrollBarPositionChanged( pos );
|
|
335 |
}
|
|
336 |
}
|
|
337 |
|
|
338 |
// -----------------------------------------------------------------------------
|
|
339 |
// CHgScrollbar::InitIconsL()
|
|
340 |
// -----------------------------------------------------------------------------
|
|
341 |
//
|
|
342 |
void CHgScrollbar::InitIconsL( TBool aInitBgIcons )
|
|
343 |
{
|
|
344 |
if(aInitBgIcons)
|
|
345 |
{
|
|
346 |
delete iScrollbarBg; iScrollbarBg = NULL;
|
|
347 |
delete iScrollbarBgSelected; iScrollbarBgSelected = NULL;
|
|
348 |
delete iScrollbarHandleBg; iScrollbarHandleBg = NULL;
|
|
349 |
|
|
350 |
CreateIconL(iScrollbarBg, iScrollbarRect.Size());
|
|
351 |
CreateIconL(iScrollbarBgSelected, iScrollbarRect.Size());
|
|
352 |
CreateIconL(iScrollbarHandleBg, iScrollbarRect.Size());
|
|
353 |
}
|
|
354 |
|
|
355 |
TReal xFactor = iScrollbarRect.Width()/TReal(iTotalSize.iWidth);
|
|
356 |
TReal yFactor = iScrollbarRect.Height()/TReal(iTotalSize.iHeight);
|
|
357 |
|
|
358 |
iHandleSize = TSize ( iViewSize.iWidth * xFactor, iViewSize.iHeight * yFactor );
|
|
359 |
|
|
360 |
if(iLandscapeScrolling)
|
|
361 |
{
|
|
362 |
TInt min = 2*iHandleSize.iHeight;
|
|
363 |
if( iHandleSize.iWidth < min )
|
|
364 |
{
|
|
365 |
iHandleSize.iWidth = min;
|
|
366 |
}
|
|
367 |
iScrollLength = iScrollbarRect.Width() - iHandleSize.iWidth;
|
|
368 |
}
|
|
369 |
else
|
|
370 |
{
|
|
371 |
TInt min = 2*iHandleSize.iWidth;
|
|
372 |
if( iHandleSize.iHeight < min )
|
|
373 |
{
|
|
374 |
iHandleSize.iHeight = min;
|
|
375 |
}
|
|
376 |
iScrollLength = iScrollbarRect.Height() - iHandleSize.iHeight;
|
|
377 |
}
|
|
378 |
|
|
379 |
delete iScrollbarHandle; iScrollbarHandle = NULL;
|
|
380 |
delete iScrollbarHandleSelected; iScrollbarHandleSelected = NULL;
|
|
381 |
|
|
382 |
CreateIconL(iScrollbarHandle, iHandleSize );
|
|
383 |
CreateIconL(iScrollbarHandleSelected, iHandleSize );
|
|
384 |
|
|
385 |
if( iLandscapeScrolling )
|
|
386 |
{
|
|
387 |
if( aInitBgIcons )
|
|
388 |
{
|
|
389 |
DrawIconL( *iScrollbarBg,
|
|
390 |
KAknsIIDQsnCpScrollHorizontalBgTop,
|
|
391 |
KAknsIIDQsnCpScrollHorizontalBgMiddle,
|
|
392 |
KAknsIIDQsnCpScrollHorizontalBgBottom );
|
|
393 |
|
|
394 |
// TODO, check if this is needed.
|
|
395 |
// DrawIconL( *iScrollbarHandleBg,
|
|
396 |
// KAknsIIDQsnCpScrollHorizontalHandleBgTop,
|
|
397 |
// KAknsIIDQsnCpScrollHorizontalHandleBgMiddle,
|
|
398 |
// KAknsIIDQsnCpScrollHorizontalHandleBgBottom );
|
|
399 |
|
|
400 |
DrawIconL( *iScrollbarBgSelected,
|
|
401 |
KAknsIIDQsnCpScrollHorizontalBgTopPressed,
|
|
402 |
KAknsIIDQsnCpScrollHorizontalBgMiddlePressed,
|
|
403 |
KAknsIIDQsnCpScrollHorizontalBgBottomPressed );
|
|
404 |
}
|
|
405 |
|
|
406 |
DrawIconL( *iScrollbarHandle,
|
|
407 |
KAknsIIDQsnCpScrollHorizontalHandleTop,
|
|
408 |
KAknsIIDQsnCpScrollHorizontalHandleMiddle,
|
|
409 |
KAknsIIDQsnCpScrollHorizontalHandleBottom);
|
|
410 |
|
|
411 |
DrawIconL( *iScrollbarHandleSelected,
|
|
412 |
KAknsIIDQsnCpScrollHorizontalHandleTopPressed,
|
|
413 |
KAknsIIDQsnCpScrollHorizontalHandleMiddlePressed,
|
|
414 |
KAknsIIDQsnCpScrollHorizontalHandleBottomPressed );
|
|
415 |
}
|
|
416 |
else
|
|
417 |
{
|
|
418 |
if(aInitBgIcons)
|
|
419 |
{
|
|
420 |
DrawIconL( *iScrollbarBg,
|
|
421 |
KAknsIIDQsnCpScrollBgTop,
|
|
422 |
KAknsIIDQsnCpScrollBgMiddle,
|
|
423 |
KAknsIIDQsnCpScrollBgBottom );
|
|
424 |
|
|
425 |
DrawIconL( *iScrollbarHandleBg,
|
|
426 |
KAknsIIDQsnCpScrollHandleBgTop,
|
|
427 |
KAknsIIDQsnCpScrollHandleBgMiddle,
|
|
428 |
KAknsIIDQsnCpScrollHandleBgBottom );
|
|
429 |
|
|
430 |
DrawIconL( *iScrollbarBgSelected,
|
|
431 |
KAknsIIDQsnCpScrollBgTopPressed,
|
|
432 |
KAknsIIDQsnCpScrollBgMiddlePressed,
|
|
433 |
KAknsIIDQsnCpScrollBgBottomPressed );
|
|
434 |
}
|
|
435 |
|
|
436 |
DrawIconL( *iScrollbarHandle,
|
|
437 |
KAknsIIDQsnCpScrollHandleTop,
|
|
438 |
KAknsIIDQsnCpScrollHandleMiddle,
|
|
439 |
KAknsIIDQsnCpScrollHandleBottom);
|
|
440 |
|
|
441 |
DrawIconL( *iScrollbarHandleSelected,
|
|
442 |
KAknsIIDQsnCpScrollHandleTopPressed,
|
|
443 |
KAknsIIDQsnCpScrollHandleMiddlePressed,
|
|
444 |
KAknsIIDQsnCpScrollHandleBottomPressed );
|
|
445 |
}
|
|
446 |
}
|
|
447 |
|
|
448 |
// -----------------------------------------------------------------------------
|
|
449 |
// CHgScrollbar::CreateIconL()
|
|
450 |
// -----------------------------------------------------------------------------
|
|
451 |
//
|
|
452 |
void CHgScrollbar::CreateIconL( CGulIcon*& aIcon, TSize aSize)
|
|
453 |
{
|
|
454 |
CFbsBitmap* bmap = new (ELeave) CFbsBitmap;
|
|
455 |
CleanupStack::PushL( bmap );
|
|
456 |
User::LeaveIfError( bmap->Create( aSize , EColor64K));
|
|
457 |
|
|
458 |
CFbsBitmap* mask = new (ELeave) CFbsBitmap;
|
|
459 |
CleanupStack::PushL( mask );
|
|
460 |
User::LeaveIfError( mask->Create( aSize , EGray256));
|
|
461 |
|
|
462 |
aIcon = CGulIcon::NewL( bmap, mask );
|
|
463 |
|
|
464 |
CleanupStack::Pop(2, bmap);
|
|
465 |
}
|
|
466 |
|
|
467 |
// -----------------------------------------------------------------------------
|
|
468 |
// CHgScrollbar::DrawIconL()
|
|
469 |
// -----------------------------------------------------------------------------
|
|
470 |
//
|
|
471 |
void CHgScrollbar::DrawIconL( CGulIcon& aIcon,
|
|
472 |
const TAknsItemID& aTop,
|
|
473 |
const TAknsItemID& aMiddle,
|
|
474 |
const TAknsItemID& aBottom )
|
|
475 |
{
|
|
476 |
TRect rect;
|
|
477 |
TSize iconSize(aIcon.Bitmap()->SizeInPixels());
|
|
478 |
TSize tSize;
|
|
479 |
TPoint point(0,0);
|
|
480 |
if(iLandscapeScrolling)
|
|
481 |
{
|
|
482 |
tSize.SetSize(iconSize.iHeight, iconSize.iHeight);
|
|
483 |
}
|
|
484 |
else
|
|
485 |
{
|
|
486 |
tSize.SetSize(iconSize.iWidth, iconSize.iWidth);
|
|
487 |
}
|
|
488 |
|
|
489 |
// TOP
|
|
490 |
rect.SetRect(point, tSize);
|
|
491 |
DrawBitmapL( aIcon, aTop, rect );
|
|
492 |
|
|
493 |
// MIDDLE
|
|
494 |
TSize middlesize(iconSize);
|
|
495 |
if(iLandscapeScrolling)
|
|
496 |
{
|
|
497 |
point.iX = tSize.iWidth;
|
|
498 |
middlesize.iWidth -= 2*tSize.iWidth;
|
|
499 |
}
|
|
500 |
else
|
|
501 |
{
|
|
502 |
point.iY = tSize.iHeight;
|
|
503 |
middlesize.iHeight -= 2*tSize.iHeight;
|
|
504 |
}
|
|
505 |
rect.SetRect(point, middlesize);
|
|
506 |
DrawBitmapL( aIcon, aMiddle, rect);
|
|
507 |
|
|
508 |
// BOTTOM
|
|
509 |
point = iconSize.AsPoint()-tSize;
|
|
510 |
rect.SetRect(point, tSize);
|
|
511 |
DrawBitmapL( aIcon, aBottom, rect );
|
|
512 |
}
|
|
513 |
|
|
514 |
// -----------------------------------------------------------------------------
|
|
515 |
// CHgScrollbar::DrawBitmapL()
|
|
516 |
// -----------------------------------------------------------------------------
|
|
517 |
//
|
|
518 |
void CHgScrollbar::DrawBitmapL( CGulIcon& aIcon,
|
|
519 |
const TAknsItemID& aItem,
|
|
520 |
const TRect& aDestRect )
|
|
521 |
{
|
|
522 |
CFbsBitmap* bitmap = NULL;
|
|
523 |
CFbsBitmap* mask = NULL;
|
|
524 |
TRAP_IGNORE( AknsUtils::CreateIconL(AknsUtils::SkinInstance(), aItem, bitmap, mask, KNullDesC, -1, -1); )
|
|
525 |
|
|
526 |
if(!bitmap)
|
|
527 |
{
|
|
528 |
AknsUtils::CreateIconL(AknsUtils::SkinInstance(), aItem, bitmap, KNullDesC, -1);
|
|
529 |
}
|
|
530 |
|
|
531 |
AknIconUtils::SetSize(bitmap, aDestRect.Size(), EAspectRatioNotPreserved);
|
|
532 |
ScaleBitmapL(aDestRect, aIcon.Bitmap(), bitmap);
|
|
533 |
|
|
534 |
if(mask)
|
|
535 |
{
|
|
536 |
AknIconUtils::SetSize(mask, aDestRect.Size(), EAspectRatioNotPreserved);
|
|
537 |
ScaleBitmapL(aDestRect, aIcon.Mask(), mask);
|
|
538 |
}
|
|
539 |
|
|
540 |
delete bitmap; bitmap = NULL;
|
|
541 |
delete mask; mask = NULL;
|
|
542 |
}
|
|
543 |
|
|
544 |
|
|
545 |
// -----------------------------------------------------------------------------
|
|
546 |
// CHgScrollbar::ScaleBitmapL()
|
|
547 |
// -----------------------------------------------------------------------------
|
|
548 |
//
|
|
549 |
void CHgScrollbar::ScaleBitmapL( const TRect& aDestRect,
|
|
550 |
CFbsBitmap* aDest,
|
|
551 |
const CFbsBitmap* aSrc)
|
|
552 |
{
|
|
553 |
CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(aDest);
|
|
554 |
CleanupStack::PushL(device);
|
|
555 |
|
|
556 |
CFbsBitGc* gc = NULL;
|
|
557 |
User::LeaveIfError(device->CreateContext(gc));
|
|
558 |
CleanupStack::PushL(gc);
|
|
559 |
|
|
560 |
gc->DrawBitmap(aDestRect, aSrc);
|
|
561 |
|
|
562 |
CleanupStack::PopAndDestroy(2, device);
|
|
563 |
}
|
|
564 |
|
|
565 |
// -----------------------------------------------------------------------------
|
|
566 |
// CHgScrollbar::ScrollbarBg()
|
|
567 |
// -----------------------------------------------------------------------------
|
|
568 |
//
|
|
569 |
const CGulIcon* CHgScrollbar::ScrollbarBg() const
|
|
570 |
{
|
|
571 |
return iScrollbarBg;
|
|
572 |
}
|
|
573 |
|
|
574 |
|
|
575 |
const CGulIcon* CHgScrollbar::ScrollbarHandleBg() const
|
|
576 |
{
|
|
577 |
return iScrollbarHandleBg;
|
|
578 |
}
|
|
579 |
|
|
580 |
const CGulIcon* CHgScrollbar::ScrollbarHandle() const
|
|
581 |
{
|
|
582 |
return iScrollbarHandle;
|
|
583 |
}
|
|
584 |
|
|
585 |
const CGulIcon* CHgScrollbar::ScrollbarBgSelected() const
|
|
586 |
{
|
|
587 |
return iScrollbarBgSelected;
|
|
588 |
}
|
|
589 |
|
|
590 |
const CGulIcon* CHgScrollbar::ScrollbarHandleSelected() const
|
|
591 |
{
|
|
592 |
return iScrollbarHandleSelected;
|
|
593 |
}
|
|
594 |
|
|
595 |
const TRect& CHgScrollbar::ScrollbarRect() const
|
|
596 |
{
|
|
597 |
return iScrollbarRect;
|
|
598 |
}
|
|
599 |
|
|
600 |
const TPoint& CHgScrollbar::HandlePosition() const
|
|
601 |
{
|
|
602 |
return iHandlePosition;
|
|
603 |
}
|
|
604 |
|
|
605 |
TBool CHgScrollbar::IsStatic() const
|
|
606 |
{
|
|
607 |
return iStatic;
|
|
608 |
}
|
|
609 |
|
|
610 |
TBool CHgScrollbar::IsDragging() const
|
|
611 |
{
|
|
612 |
return iDragging;
|
|
613 |
}
|
|
614 |
|
|
615 |
TBool CHgScrollbar::Handler() const
|
|
616 |
{
|
|
617 |
return iHandler;
|
|
618 |
}
|
|
619 |
|
|
620 |
void CHgScrollbar::Reset()
|
|
621 |
{
|
|
622 |
iHandler = iDragging = EFalse;
|
|
623 |
}
|
|
624 |
|
|
625 |
// End of file
|