|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "PreviewControlBase.h" |
|
22 |
|
23 //============================================================================= |
|
24 EXPORT_C CPreviewControlBase * CPreviewControlBase::NewL ( |
|
25 const TRect & aRect, |
|
26 CCoeControl * aParent |
|
27 ) |
|
28 { |
|
29 CPreviewControlBase * self = new (ELeave) CPreviewControlBase; |
|
30 CleanupStack::PushL (self); |
|
31 self->ConstructL (aRect, aParent); |
|
32 CleanupStack::Pop(); // self |
|
33 return self; |
|
34 } |
|
35 |
|
36 //============================================================================= |
|
37 EXPORT_C void CPreviewControlBase::ConstructL ( |
|
38 const TRect & aRect, |
|
39 CCoeControl * aParent |
|
40 ) |
|
41 { |
|
42 // Set container |
|
43 SetContainerWindowL (*aParent); |
|
44 |
|
45 // Set extent |
|
46 SetRect (aRect); |
|
47 |
|
48 // Activate |
|
49 ActivateL(); |
|
50 } |
|
51 |
|
52 //============================================================================= |
|
53 EXPORT_C CPreviewControlBase::~CPreviewControlBase() |
|
54 { |
|
55 iPreview = NULL; |
|
56 } |
|
57 |
|
58 //============================================================================= |
|
59 EXPORT_C void CPreviewControlBase::SetImageL (CFbsBitmap * aBitmap) |
|
60 { |
|
61 iPreview = aBitmap; |
|
62 } |
|
63 |
|
64 //============================================================================= |
|
65 EXPORT_C void CPreviewControlBase::SetImageL (const CFbsBitmap * aBitmap) |
|
66 { |
|
67 iPreview = aBitmap; |
|
68 } |
|
69 |
|
70 //============================================================================= |
|
71 EXPORT_C void CPreviewControlBase::DrawPreviewImage (const TRect & aRect) const |
|
72 { |
|
73 // Get graphics context |
|
74 CWindowGc & gc = SystemGc(); |
|
75 |
|
76 // Set graphics context parameters |
|
77 gc.SetPenStyle (CGraphicsContext::ESolidPen); |
|
78 gc.SetPenColor (KRgbBlack); |
|
79 gc.SetBrushStyle (CGraphicsContext::ESolidBrush); |
|
80 gc.SetBrushColor (KRgbBlack); |
|
81 |
|
82 // Draw preview image if found |
|
83 if ( iPreview && iPreview->Handle() ) |
|
84 { |
|
85 gc.BitBlt (TPoint(0,0), iPreview); |
|
86 } |
|
87 else |
|
88 { |
|
89 gc.DrawRect (aRect); |
|
90 } |
|
91 } |
|
92 |
|
93 //============================================================================= |
|
94 EXPORT_C void CPreviewControlBase::Draw (const TRect & aRect) const |
|
95 { |
|
96 DrawPreviewImage(aRect); |
|
97 } |
|
98 |
|
99 // End of File |