|
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 <ganes/HgVgItem.h> |
|
20 #include <gulicon.h> |
|
21 |
|
22 #include "HgVgHelper.h" |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CHgVgItem::NewL() |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 EXPORT_C CHgVgItem* CHgVgItem::NewL( |
|
29 TInt aFlags, |
|
30 CGulIcon* aIcon, |
|
31 const TDesC& aTitle, |
|
32 const TDesC& aText ) |
|
33 { |
|
34 CHgVgItem* self = CHgVgItem::NewLC( aFlags, aIcon, aTitle, aText ); |
|
35 CleanupStack::Pop( self ); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // CHgVgItem::NewL() |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CHgVgItem* CHgVgItem::NewLC( |
|
44 TInt aFlags, |
|
45 CGulIcon* aIcon, |
|
46 const TDesC& aTitle, |
|
47 const TDesC& aText ) |
|
48 { |
|
49 CHgVgItem* self = new (ELeave) CHgVgItem( aFlags, aIcon ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL( aTitle, aText ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CHgVgItem::~CHgVgItem() |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CHgVgItem::~CHgVgItem() |
|
60 { |
|
61 FreeOpenVgImage(); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CHgVgItem::SetIcon() |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C void CHgVgItem::SetIcon( CGulIcon* aIcon, TInt aFlags ) |
|
69 { |
|
70 CHgItem::SetIcon(aIcon, aFlags); |
|
71 ReloadOpenVgImage(); |
|
72 } |
|
73 |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CHgVgItem::CHgVgItem() |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 CHgVgItem::CHgVgItem( TInt aFlags, CGulIcon* aIcon ) : CHgItem(aFlags, aIcon), |
|
80 iVgImage( VG_INVALID_HANDLE ) |
|
81 { |
|
82 ReloadOpenVgImage(); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // CHgVgItem::ConstructL() |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CHgVgItem::ConstructL( const TDesC& aTitle, const TDesC& aText ) |
|
90 { |
|
91 CHgItem::ConstructL(aTitle, aText); |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CHgVgItem::VgImage() |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 VGImage CHgVgItem::VgImage() const |
|
99 { |
|
100 return iVgImage; |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // CHgVgItem::ReloadOpenVgImage() |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CHgVgItem::ReloadOpenVgImage() |
|
108 { |
|
109 FreeOpenVgImage(); |
|
110 if( iIcon ) |
|
111 { |
|
112 TRAP_IGNORE( iVgImage = HgVgHelper::CreateVgImageFromIconL(*iIcon); ) |
|
113 } |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // CHgVgItem::FreeOpenVgImage() |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 void CHgVgItem::FreeOpenVgImage() |
|
121 { |
|
122 if (iVgImage != VG_INVALID_HANDLE) |
|
123 { |
|
124 vgDestroyImage(iVgImage); |
|
125 iVgImage = VG_INVALID_HANDLE; |
|
126 } |
|
127 } |
|
128 |
|
129 // End of File |