1 /* |
|
2 * Copyright (c) 2005 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: Screensaver GifAnimation plug-in implementation source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include <e32std.h> |
|
23 #include <eikenv.h> |
|
24 #include <barsread.h> |
|
25 #include <fbs.h> |
|
26 #include <gdi.h> |
|
27 #include <f32file.h> |
|
28 #include <cecombrowserplugininterface.h> |
|
29 |
|
30 #include "GifAnimationPlugin.h" |
|
31 #include "GifAnimationUtils.h" |
|
32 |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // Instance factory. |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CGifAnimationPlugin* CGifAnimationPlugin::NewL( NPP anInstance ) |
|
41 { |
|
42 DBG_TRACE_FN_BEGIN; |
|
43 CGifAnimationPlugin *self = new (ELeave) CGifAnimationPlugin; |
|
44 CleanupStack::PushL( self ); |
|
45 self->Construct( anInstance ); |
|
46 |
|
47 CleanupStack::Pop(); |
|
48 DBG_TRACE_FN_END; |
|
49 return self; |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // Destructor |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 CGifAnimationPlugin::~CGifAnimationPlugin() |
|
57 { |
|
58 DBG_TRACE_FN_BEGIN; |
|
59 if ( iControl ) |
|
60 { |
|
61 delete iControl; |
|
62 iControl=NULL; |
|
63 } |
|
64 DBG_TRACE_FN_END; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // Notifies host that plug-in has finished. |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CGifAnimationPlugin::PrepareToExitL() |
|
72 { |
|
73 DBG_TRACE_FN_BEGIN; |
|
74 |
|
75 if ( iPluginAdapter ) |
|
76 { |
|
77 CCoeControl* aParentControl = iPluginAdapter->GetParentControl(); |
|
78 if ( iControl != NULL ) |
|
79 { |
|
80 // will free resources, if file was loaded but was not stopped |
|
81 iControl->StopAnimation(); |
|
82 } |
|
83 iPluginAdapter->PluginFinishedL(); |
|
84 } |
|
85 DBG_TRACE_FN_END; |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // 2nd phase constructor. |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 void CGifAnimationPlugin::Construct( NPP anInstance ) |
|
93 { |
|
94 DBG_TRACE_FN_BEGIN; |
|
95 iInstance=anInstance; |
|
96 DBG_TRACE_FN_END; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Sets the parent window to plug-in. If already set, only updates size. |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CGifAnimationPlugin::SetWindowL( const NPWindow *aWindow, |
|
104 const TRect& aRect ) |
|
105 { |
|
106 DBG_TRACE_FN_BEGIN; |
|
107 iPluginAdapter = static_cast<MPluginAdapter*>( aWindow->window ); |
|
108 CCoeControl* aParentControl = iPluginAdapter->GetParentControl(); |
|
109 if ( iControl == NULL ) |
|
110 { |
|
111 iControl = CGifAnimationPluginControl::NewL( aParentControl, |
|
112 iPluginAdapter ); |
|
113 iPluginAdapter->PluginConstructedL( iControl ); |
|
114 } |
|
115 |
|
116 if ( iControl != NULL ) |
|
117 { |
|
118 iControl->SetRect( aRect ); |
|
119 } |
|
120 DBG_TRACE_FN_END; |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // Returns pointer on instance of CGifAnimationPluginControl |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 CGifAnimationPluginControl* CGifAnimationPlugin::Control() |
|
128 { |
|
129 DBG_TRACE_FN_BEGIN; |
|
130 ASSERT( iControl ); |
|
131 DBG_TRACE_FN_END; |
|
132 return iControl; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Returns pointer on NPP instance |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 NPP CGifAnimationPlugin::Instance() |
|
140 { |
|
141 DBG_TRACE_FN_BEGIN; |
|
142 ASSERT( iInstance ); |
|
143 DBG_TRACE_FN_END; |
|
144 return iInstance; |
|
145 } |
|