|
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 #include "MemSpyViewFBServBitmaps.h" |
|
19 |
|
20 // System includes |
|
21 #include <memspyui.rsg> |
|
22 |
|
23 // Engine includes |
|
24 #include <memspy/engine/memspyengine.h> |
|
25 #include <memspy/engine/memspyengineobjectprocess.h> |
|
26 #include <memspy/engine/memspyengineobjectthread.h> |
|
27 #include <memspy/engine/memspyengineobjectcontainer.h> |
|
28 #include <memspy/engine/memspyengineobjectthreadinfoobjects.h> |
|
29 #include <memspy/engine/memspyengineobjectthreadinfocontainer.h> |
|
30 #include <memspy/engine/memspyenginehelperprocess.h> |
|
31 #include <memspy/engine/memspyenginehelperheap.h> |
|
32 |
|
33 // User includes |
|
34 #include "MemSpyUiUtils.h" |
|
35 #include "MemSpyViewMainMenu.h" |
|
36 #include "MemSpyViewThreads.h" |
|
37 #include "MemSpyContainerObserver.h" |
|
38 #include "MemSpyExportBitmapsToMemoryCardDialog.h" |
|
39 |
|
40 // Constants |
|
41 const TInt KMemSpyIdleResetListboxTimerPeriod = 500000; |
|
42 const TInt KMemSpyImageSlideshowPeriod = 1000000; |
|
43 |
|
44 |
|
45 |
|
46 CMemSpyViewFBServBase::CMemSpyViewFBServBase( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps ) |
|
47 : CMemSpyViewBase( aEngine, aObserver ), iBitmaps( aBitmaps ) |
|
48 { |
|
49 } |
|
50 |
|
51 |
|
52 CMemSpyViewFBServBase::~CMemSpyViewFBServBase() |
|
53 { |
|
54 #ifdef _DEBUG |
|
55 RDebug::Printf("CMemSpyViewFBServBase::~CMemSpyViewFBServBase() - deleting bitmaps: 0x%08x", iBitmaps ); |
|
56 #endif |
|
57 delete iBitmaps; |
|
58 } |
|
59 |
|
60 |
|
61 TBool CMemSpyViewFBServBase::HandleCommandL( TInt aCommand ) |
|
62 { |
|
63 TBool handled = ETrue; |
|
64 // |
|
65 switch ( aCommand ) |
|
66 { |
|
67 case EMemSpyCmdImagesSlideshow: |
|
68 OnCmdSlideShowL(); |
|
69 break; |
|
70 #ifndef __WINS__ |
|
71 case EMemSpyCmdImagesSaveAllToMemoryCard: |
|
72 OnCmdExportToMemoryCardL(); |
|
73 break; |
|
74 #endif |
|
75 case EMemSpyCmdImagesListing: |
|
76 OnCmdImageListingL(); |
|
77 break; |
|
78 |
|
79 default: |
|
80 handled = CMemSpyViewBase::HandleCommandL( aCommand ); |
|
81 break; |
|
82 } |
|
83 // |
|
84 return handled; |
|
85 } |
|
86 |
|
87 |
|
88 void CMemSpyViewFBServBase::OnCmdSlideShowL() |
|
89 { |
|
90 TInt index = 0; |
|
91 CMemSpyViewFBServSlideshow::NewLD( *iBitmaps, index ); |
|
92 |
|
93 // Select the item that was last displayed |
|
94 const TInt count = iBitmaps->Count(); |
|
95 if ( iListBox && index >= 0 && index < count ) |
|
96 { |
|
97 iListBox->SetCurrentItemIndex( index ); |
|
98 HandleListBoxItemSelectedL( index ); |
|
99 DrawDeferred(); |
|
100 } |
|
101 } |
|
102 |
|
103 |
|
104 void CMemSpyViewFBServBase::OnCmdExportToMemoryCardL() |
|
105 { |
|
106 // Deletes itself |
|
107 CMemSpyExportBitmapsToMemoryCardDialog::NewL( iCoeEnv->FsSession(), *iBitmaps ); |
|
108 } |
|
109 |
|
110 |
|
111 void CMemSpyViewFBServBase::OnCmdImageListingL() |
|
112 { |
|
113 // Begin a new data stream |
|
114 _LIT( KMemSpyContext, "Bitmap List - " ); |
|
115 _LIT( KMemSpyFolder, "Bitmaps" ); |
|
116 iEngine.Sink().DataStreamBeginL( KMemSpyContext, KMemSpyFolder ); |
|
117 |
|
118 // Set prefix for overall listing |
|
119 _LIT(KOverallPrefix, "Bitmap List - "); |
|
120 iEngine.Sink().OutputPrefixSetLC( KOverallPrefix ); |
|
121 |
|
122 // Create header |
|
123 CMemSpyEngineFbServBitmap::OutputDataColumnsL( iEngine ); |
|
124 |
|
125 // List items |
|
126 const TInt count = iBitmaps->Count(); |
|
127 for(TInt i=0; i<count; i++) |
|
128 { |
|
129 const CMemSpyEngineFbServBitmap& bitmap = iBitmaps->At( i ); |
|
130 // |
|
131 bitmap.OutputDataL( iEngine ); |
|
132 } |
|
133 |
|
134 // Tidy up |
|
135 CleanupStack::PopAndDestroy(); // prefix |
|
136 |
|
137 // End data stream |
|
138 iEngine.Sink().DataStreamEndL(); |
|
139 } |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 |
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 |
|
170 CMemSpyViewFBServBitmaps::CMemSpyViewFBServBitmaps( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver ) |
|
171 : CMemSpyViewFBServBase( aEngine, aObserver, NULL ) |
|
172 { |
|
173 #ifdef _DEBUG |
|
174 RDebug::Printf("CMemSpyViewFBServBitmaps::CMemSpyViewFBServBitmaps(1) - iBitmaps is: 0x%08x", iBitmaps ); |
|
175 #endif |
|
176 } |
|
177 |
|
178 |
|
179 CMemSpyViewFBServBitmaps::CMemSpyViewFBServBitmaps( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps ) |
|
180 : CMemSpyViewFBServBase( aEngine, aObserver, aBitmaps ) |
|
181 { |
|
182 #ifdef _DEBUG |
|
183 RDebug::Printf("CMemSpyViewFBServBitmaps::CMemSpyViewFBServBitmaps(2) - iBitmaps is: 0x%08x", iBitmaps ); |
|
184 #endif |
|
185 } |
|
186 |
|
187 |
|
188 CMemSpyViewFBServBitmaps::~CMemSpyViewFBServBitmaps() |
|
189 { |
|
190 delete iIdleResetListboxTimer; |
|
191 iBitmapHandles.Close(); |
|
192 } |
|
193 |
|
194 |
|
195 void CMemSpyViewFBServBitmaps::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
196 { |
|
197 _LIT( KTitle, "Font & Bitmap Server" ); |
|
198 SetTitleL( KTitle ); |
|
199 |
|
200 if ( iBitmaps == NULL ) |
|
201 { |
|
202 // Prepare bitmap handles |
|
203 iEngine.HelperFbServ().GetArrayOfBitmapHandlesL( iBitmapHandles ); |
|
204 |
|
205 // Create bitmap array - construction occurs asynchronously |
|
206 iBitmaps = CMemSpyEngineFbServBitmapArray::NewL( CActive::EPriorityIdle, iBitmapHandles, *this ); |
|
207 } |
|
208 |
|
209 // Finish construction |
|
210 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
211 |
|
212 // Create idle listbox refresh timer |
|
213 if ( iBitmaps->Count() == 0 ) |
|
214 { |
|
215 iIdleResetListboxTimer = CPeriodic::NewL( CActive::EPriorityLow ); |
|
216 } |
|
217 else |
|
218 { |
|
219 if ( aSelectionRune != NULL ) |
|
220 { |
|
221 iCurrentBitmap = reinterpret_cast< CMemSpyEngineFbServBitmap* >( aSelectionRune ); |
|
222 const TInt index = iBitmaps->BitmapIndexByHandle( iCurrentBitmap->Handle() ); |
|
223 iListBox->SetCurrentItemIndex( index ); |
|
224 HandleListBoxItemSelectedL( index ); |
|
225 } |
|
226 |
|
227 iListBox->DrawDeferred(); |
|
228 } |
|
229 } |
|
230 |
|
231 |
|
232 void CMemSpyViewFBServBitmaps::RefreshL() |
|
233 { |
|
234 #ifdef _DEBUG |
|
235 RDebug::Printf("CMemSpyViewFBServBitmaps::RefreshL() - iBitmaps->Count(): %d", iBitmaps->Count()); |
|
236 #endif |
|
237 |
|
238 SetListBoxModelL(); |
|
239 CMemSpyViewBase::RefreshL(); |
|
240 } |
|
241 |
|
242 |
|
243 TMemSpyViewType CMemSpyViewFBServBitmaps::ViewType() const |
|
244 { |
|
245 return EMemSpyViewTypeFBServBitmaps; |
|
246 } |
|
247 |
|
248 |
|
249 CMemSpyViewBase* CMemSpyViewFBServBitmaps::PrepareParentViewL() |
|
250 { |
|
251 CMemSpyViewMainMenu* parent = new(ELeave) CMemSpyViewMainMenu( iEngine, iObserver ); |
|
252 CleanupStack::PushL( parent ); |
|
253 parent->ConstructL( Rect(), *Parent(), (TAny*) ViewType() ); |
|
254 CleanupStack::Pop( parent ); |
|
255 return parent; |
|
256 } |
|
257 |
|
258 |
|
259 CMemSpyViewBase* CMemSpyViewFBServBitmaps::PrepareChildViewL() |
|
260 { |
|
261 CMemSpyViewBase* child = new(ELeave) CMemSpyViewFBServBitmapInfo( iEngine, iObserver, iBitmaps, *iCurrentBitmap ); |
|
262 |
|
263 // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now. |
|
264 // This object is about to die in any case. |
|
265 iBitmaps = NULL; |
|
266 |
|
267 CleanupStack::PushL( child ); |
|
268 child->ConstructL( Rect(), *Parent() ); |
|
269 CleanupStack::Pop( child ); |
|
270 return child; |
|
271 } |
|
272 |
|
273 |
|
274 void CMemSpyViewFBServBitmaps::HandleFbServBitmapArrayEventL( TEvent aEvent ) |
|
275 { |
|
276 if ( aEvent == EBitmapItemsCreated ) |
|
277 { |
|
278 } |
|
279 else if ( aEvent == EBitmapArrayConstructionComplete ) |
|
280 { |
|
281 } |
|
282 // |
|
283 iIdleResetListboxTimer->Cancel(); |
|
284 iIdleResetListboxTimer->Start( KMemSpyIdleResetListboxTimerPeriod/2, KMemSpyIdleResetListboxTimerPeriod, TCallBack( IdleUpdateListBoxModel, this ) ); |
|
285 } |
|
286 |
|
287 |
|
288 void CMemSpyViewFBServBitmaps::SetListBoxModelL() |
|
289 { |
|
290 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
291 listbox->Model()->SetItemTextArray( iBitmaps ); |
|
292 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
293 } |
|
294 |
|
295 |
|
296 void CMemSpyViewFBServBitmaps::HandleListBoxItemActionedL( TInt aIndex ) |
|
297 { |
|
298 const TInt count = iBitmaps->Count(); |
|
299 if ( aIndex >= 0 && aIndex < count ) |
|
300 { |
|
301 CMemSpyEngineFbServBitmap& bitmap = iBitmaps->At( aIndex ); |
|
302 iCurrentBitmap = &bitmap; |
|
303 } |
|
304 else |
|
305 { |
|
306 iCurrentBitmap = NULL; |
|
307 } |
|
308 |
|
309 // Notify observer about item selection |
|
310 ReportEventL( MMemSpyViewObserver::EEventItemActioned ); |
|
311 } |
|
312 |
|
313 |
|
314 void CMemSpyViewFBServBitmaps::HandleListBoxItemSelectedL( TInt aIndex ) |
|
315 { |
|
316 const TInt count = iBitmaps->Count(); |
|
317 if ( aIndex >= 0 && aIndex < count ) |
|
318 { |
|
319 CMemSpyEngineFbServBitmap& bitmap = iBitmaps->At( aIndex ); |
|
320 iCurrentBitmap = &bitmap; |
|
321 } |
|
322 else |
|
323 { |
|
324 iCurrentBitmap = NULL; |
|
325 } |
|
326 |
|
327 // Notify observer about item selection |
|
328 ReportEventL( MMemSpyViewObserver::EEventItemSelected ); |
|
329 } |
|
330 |
|
331 |
|
332 TInt CMemSpyViewFBServBitmaps::IdleUpdateListBoxModel( TAny* aSelf ) |
|
333 { |
|
334 CMemSpyViewFBServBitmaps* self = reinterpret_cast< CMemSpyViewFBServBitmaps* >( aSelf ); |
|
335 TRAP_IGNORE( self->DoIdleUpdateListBoxModelL() ); |
|
336 return EFalse; |
|
337 } |
|
338 |
|
339 |
|
340 void CMemSpyViewFBServBitmaps::DoIdleUpdateListBoxModelL() |
|
341 { |
|
342 // Try to maintain current item selection if at all possible. |
|
343 TInt handle = 0; |
|
344 if ( iCurrentBitmap ) |
|
345 { |
|
346 handle = iCurrentBitmap->Handle(); |
|
347 iCurrentBitmap = NULL; |
|
348 } |
|
349 |
|
350 // Update list box & model |
|
351 iListBox->HandleItemAdditionL(); |
|
352 iListBox->DrawDeferred(); |
|
353 |
|
354 // Try to select previous item if it is still available |
|
355 const TInt index = iBitmaps->BitmapIndexByHandle( handle ); |
|
356 if ( index >= 0 && index < iBitmaps->Count() ) |
|
357 { |
|
358 iListBox->SetCurrentItemIndex( index ); |
|
359 HandleListBoxItemSelectedL( index ); |
|
360 } |
|
361 |
|
362 iIdleResetListboxTimer->Cancel(); |
|
363 } |
|
364 |
|
365 |
|
366 |
|
367 |
|
368 |
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 |
|
394 |
|
395 |
|
396 |
|
397 CMemSpyViewFBServBitmapInfo::CMemSpyViewFBServBitmapInfo( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps, CMemSpyEngineFbServBitmap& aSelectedBitmap ) |
|
398 : CMemSpyViewFBServBase( aEngine, aObserver, aBitmaps ), iBitmapObject( aSelectedBitmap ) |
|
399 { |
|
400 #ifdef _DEBUG |
|
401 RDebug::Printf("CMemSpyViewFBServBitmapInfo::CMemSpyViewFBServBitmapInfo() - iBitmaps is: 0x%08x", iBitmaps ); |
|
402 #endif |
|
403 } |
|
404 |
|
405 |
|
406 void CMemSpyViewFBServBitmapInfo::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
407 { |
|
408 _LIT( KTitle, "Bitmap Details" ); |
|
409 SetTitleL( KTitle ); |
|
410 |
|
411 // Finish construction |
|
412 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
413 |
|
414 if ( iBitmaps->Count() ) |
|
415 { |
|
416 iListBox->SetCurrentItemIndex( 0 ); |
|
417 HandleListBoxItemSelectedL( 0 ); |
|
418 } |
|
419 } |
|
420 |
|
421 |
|
422 void CMemSpyViewFBServBitmapInfo::RefreshL() |
|
423 { |
|
424 SetListBoxModelL(); |
|
425 CMemSpyViewBase::RefreshL(); |
|
426 } |
|
427 |
|
428 |
|
429 TMemSpyViewType CMemSpyViewFBServBitmapInfo::ViewType() const |
|
430 { |
|
431 return EMemSpyViewTypeFBServBitmapInfo; |
|
432 } |
|
433 |
|
434 |
|
435 CMemSpyViewBase* CMemSpyViewFBServBitmapInfo::PrepareParentViewL() |
|
436 { |
|
437 CMemSpyViewFBServBitmaps* parent = new(ELeave) CMemSpyViewFBServBitmaps( iEngine, iObserver, iBitmaps ); |
|
438 |
|
439 // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now. |
|
440 // This object is about to die in any case. |
|
441 iBitmaps = NULL; |
|
442 |
|
443 CleanupStack::PushL( parent ); |
|
444 parent->ConstructL( Rect(), *Parent(), &iBitmapObject ); |
|
445 CleanupStack::Pop( parent ); |
|
446 return parent; |
|
447 } |
|
448 |
|
449 |
|
450 CMemSpyViewBase* CMemSpyViewFBServBitmapInfo::PrepareChildViewL() |
|
451 { |
|
452 CMemSpyViewFBServBitmapViewer* child = new(ELeave) CMemSpyViewFBServBitmapViewer( iEngine, iObserver, iBitmaps, iBitmapObject ); |
|
453 |
|
454 // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now. |
|
455 // This object is about to die in any case. |
|
456 iBitmaps = NULL; |
|
457 |
|
458 CleanupStack::PushL( child ); |
|
459 CEikAppUi* appUi = static_cast< CEikAppUi* >( iEikonEnv->AppUi() ); |
|
460 const TRect rect( TPoint( 0, 0 ), appUi->ClientRect().Size() ); |
|
461 child->ConstructL( rect, *Parent() ); |
|
462 CleanupStack::Pop( child ); |
|
463 return child; |
|
464 } |
|
465 |
|
466 |
|
467 void CMemSpyViewFBServBitmapInfo::SetListBoxModelL() |
|
468 { |
|
469 CAknSettingStyleListBox* listbox = static_cast< CAknSettingStyleListBox* >( iListBox ); |
|
470 listbox->Model()->SetItemTextArray( &iBitmapObject ); |
|
471 listbox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
472 } |
|
473 |
|
474 |
|
475 void CMemSpyViewFBServBitmapInfo::HandleListBoxItemActionedL( TInt aIndex ) |
|
476 { |
|
477 // Only report the event if its the first item that was actioned |
|
478 if ( aIndex == 0 ) |
|
479 { |
|
480 ReportEventL( MMemSpyViewObserver::EEventItemActioned ); |
|
481 } |
|
482 } |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 |
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 |
|
511 |
|
512 |
|
513 CMemSpyViewFBServBitmapViewer::CMemSpyViewFBServBitmapViewer( CMemSpyEngine& aEngine, MMemSpyViewObserver& aObserver, CMemSpyEngineFbServBitmapArray* aBitmaps, CMemSpyEngineFbServBitmap& aSelectedBitmap ) |
|
514 : CMemSpyViewFBServBase( aEngine, aObserver, aBitmaps ), iBitmapObject( aSelectedBitmap ) |
|
515 { |
|
516 #ifdef _DEBUG |
|
517 RDebug::Printf("CMemSpyViewFBServBitmapViewer::CMemSpyViewFBServBitmapViewer() - iBitmaps is: 0x%08x", iBitmaps ); |
|
518 #endif |
|
519 } |
|
520 |
|
521 |
|
522 CMemSpyViewFBServBitmapViewer::~CMemSpyViewFBServBitmapViewer() |
|
523 { |
|
524 delete iImage; |
|
525 } |
|
526 |
|
527 |
|
528 void CMemSpyViewFBServBitmapViewer::ConstructL( const TRect& aRect, CCoeControl& aContainer, TAny* aSelectionRune ) |
|
529 { |
|
530 _LIT( KTitle, "Bitmap Preview" ); |
|
531 SetTitleL( KTitle ); |
|
532 |
|
533 // Finish construction |
|
534 CMemSpyViewBase::ConstructL( aRect, aContainer, aSelectionRune ); |
|
535 |
|
536 // Prepare image |
|
537 iImage = new(ELeave) CEikImage(); |
|
538 iImage->SetContainerWindowL( *this ); |
|
539 iImage->SetPicture( &iBitmapObject.Bitmap(), NULL ); |
|
540 iImage->SetPictureOwnedExternally( ETrue ); |
|
541 SizeChanged(); |
|
542 } |
|
543 |
|
544 |
|
545 void CMemSpyViewFBServBitmapViewer::RefreshL() |
|
546 { |
|
547 CMemSpyViewBase::RefreshL(); |
|
548 } |
|
549 |
|
550 |
|
551 TMemSpyViewType CMemSpyViewFBServBitmapViewer::ViewType() const |
|
552 { |
|
553 return EMemSpyViewTypeFBServBitmapViewer; |
|
554 } |
|
555 |
|
556 |
|
557 CMemSpyViewBase* CMemSpyViewFBServBitmapViewer::PrepareParentViewL() |
|
558 { |
|
559 CMemSpyViewFBServBitmapInfo* parent = new(ELeave) CMemSpyViewFBServBitmapInfo( iEngine, iObserver, iBitmaps, iBitmapObject ); |
|
560 |
|
561 // Ownership is transferred to child. Cleanupstack guarantees it will be destroyed now. |
|
562 // This object is about to die in any case. |
|
563 iBitmaps = NULL; |
|
564 |
|
565 CleanupStack::PushL( parent ); |
|
566 CEikAppUi* appUi = static_cast< CEikAppUi* >( iEikonEnv->AppUi() ); |
|
567 const TRect rect( TPoint( 0, 0 ), appUi->ClientRect().Size() ); |
|
568 parent->ConstructL( rect, *Parent() ); |
|
569 CleanupStack::Pop( parent ); |
|
570 return parent; |
|
571 } |
|
572 |
|
573 |
|
574 void CMemSpyViewFBServBitmapViewer::SetListBoxModelL() |
|
575 { |
|
576 } |
|
577 |
|
578 |
|
579 CEikListBox* CMemSpyViewFBServBitmapViewer::ConstructListBoxL() |
|
580 { |
|
581 return NULL; |
|
582 } |
|
583 |
|
584 |
|
585 void CMemSpyViewFBServBitmapViewer::Draw( const TRect& /*aRect*/ ) const |
|
586 { |
|
587 CWindowGc& gc = SystemGc(); |
|
588 // |
|
589 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
590 gc.SetBrushColor( KRgbWhite ); |
|
591 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
592 gc.DrawRect( Rect() ); |
|
593 // |
|
594 gc.SetBrushColor( KRgbBlack ); |
|
595 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
596 gc.DrawRect( iBorderRect ); |
|
597 } |
|
598 |
|
599 |
|
600 void CMemSpyViewFBServBitmapViewer::SizeChanged() |
|
601 { |
|
602 TRect rect( Rect() ); |
|
603 TSize size( rect.Size() ); |
|
604 // |
|
605 TSize bitmapSize( iBitmapObject.Bitmap().SizeInPixels() ); |
|
606 |
|
607 // Try to center image, if possible. |
|
608 if ( bitmapSize.iWidth < size.iWidth ) |
|
609 { |
|
610 const TInt offset = ( size.iWidth - bitmapSize.iWidth) / 2; |
|
611 rect.Move( offset, 0 ); |
|
612 size.iWidth = bitmapSize.iWidth; |
|
613 } |
|
614 if ( bitmapSize.iHeight < size.iHeight ) |
|
615 { |
|
616 const TInt offset = ( size.iHeight - bitmapSize.iHeight) / 2; |
|
617 rect.Move( 0, offset ); |
|
618 size.iHeight = bitmapSize.iHeight; |
|
619 } |
|
620 // |
|
621 rect.SetSize( size ); |
|
622 if ( iImage ) |
|
623 { |
|
624 iImage->SetRect( rect ); |
|
625 } |
|
626 iBorderRect = rect; |
|
627 iBorderRect.Grow( 2, 2 ); |
|
628 } |
|
629 |
|
630 |
|
631 TInt CMemSpyViewFBServBitmapViewer::CountComponentControls() const |
|
632 { |
|
633 TInt count = 0; |
|
634 // |
|
635 if ( iImage ) |
|
636 { |
|
637 ++count; |
|
638 } |
|
639 // |
|
640 return count; |
|
641 } |
|
642 |
|
643 |
|
644 CCoeControl* CMemSpyViewFBServBitmapViewer::ComponentControl( TInt /*aIndex*/ ) const |
|
645 { |
|
646 return iImage; |
|
647 } |
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 CMemSpyViewFBServSlideshow::CMemSpyViewFBServSlideshow( CMemSpyEngineFbServBitmapArray& aBitmaps, TInt& aIndex ) |
|
666 : iBitmaps( aBitmaps ), iIndex( aIndex ) |
|
667 { |
|
668 } |
|
669 |
|
670 |
|
671 CMemSpyViewFBServSlideshow::~CMemSpyViewFBServSlideshow() |
|
672 { |
|
673 delete iTimer; |
|
674 } |
|
675 |
|
676 |
|
677 void CMemSpyViewFBServSlideshow::ConstructL() |
|
678 { |
|
679 iTimer = CPeriodic::NewL( CActive::EPriorityLow ); |
|
680 iTimer->Start( KMemSpyImageSlideshowPeriod, KMemSpyImageSlideshowPeriod, TCallBack( IdleUpdate, this ) ); |
|
681 } |
|
682 |
|
683 |
|
684 void CMemSpyViewFBServSlideshow::NewLD( CMemSpyEngineFbServBitmapArray& aBitmaps, TInt& aIndex ) |
|
685 { |
|
686 CMemSpyViewFBServSlideshow* self = new(ELeave) CMemSpyViewFBServSlideshow( aBitmaps, aIndex ); |
|
687 CleanupStack::PushL( self ); |
|
688 self->ConstructL(); |
|
689 CleanupStack::Pop( self ); |
|
690 // |
|
691 self->ExecuteLD( R_MEMSPY_IMAGE_SLIDESHOW ); |
|
692 } |
|
693 |
|
694 |
|
695 void CMemSpyViewFBServSlideshow::PreLayoutDynInitL() |
|
696 { |
|
697 ShowNextImageL(); |
|
698 } |
|
699 |
|
700 |
|
701 TBool CMemSpyViewFBServSlideshow::OkToExitL( TInt /*aButtonId*/ ) |
|
702 { |
|
703 return ETrue; |
|
704 } |
|
705 |
|
706 |
|
707 TInt CMemSpyViewFBServSlideshow::IdleUpdate( TAny* aSelf ) |
|
708 { |
|
709 CMemSpyViewFBServSlideshow* self = reinterpret_cast< CMemSpyViewFBServSlideshow* >( aSelf ); |
|
710 TRAP_IGNORE( self->ShowNextImageL() ); |
|
711 return EFalse; |
|
712 } |
|
713 |
|
714 |
|
715 void CMemSpyViewFBServSlideshow::ShowNextImageL() |
|
716 { |
|
717 CEikImage* imageControl = static_cast< CEikImage* >( Control(EMemSpyCtrlIdSlideShowImage) ); |
|
718 |
|
719 // Get the right image |
|
720 const TInt imageCount = iBitmaps.Count(); |
|
721 if ( iIndex < imageCount ) |
|
722 { |
|
723 CMemSpyEngineFbServBitmap& bitmap = iBitmaps.At( iIndex ); |
|
724 imageControl->SetPicture( &bitmap.Bitmap(), NULL ); |
|
725 imageControl->SetPictureOwnedExternally( ETrue ); |
|
726 |
|
727 // Prepare title |
|
728 const TSize size( bitmap.Bitmap().SizeInPixels() ); |
|
729 _LIT(KTitleFormat, "%3d x %3d"); |
|
730 TBuf<128> title; |
|
731 title.Format( KTitleFormat, size.iWidth, size.iHeight ); |
|
732 SetTitleL( title ); |
|
733 // |
|
734 User::ResetInactivityTime(); |
|
735 // |
|
736 Layout(); |
|
737 // |
|
738 ++iIndex; |
|
739 } |
|
740 else |
|
741 { |
|
742 // Dismiss myself. |
|
743 delete this; |
|
744 } |
|
745 } |
|
746 |