|
1 /* |
|
2 * Copyright (c) 2008 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: Background appearance drawer |
|
15 * |
|
16 */ |
|
17 |
|
18 // System includes |
|
19 #include <aknappui.h> |
|
20 #include <AknUtils.h> |
|
21 #include <AknsUtils.h> |
|
22 #include <AknsDrawUtils.h> |
|
23 #include <AknsLayeredBackgroundControlContext.h> |
|
24 #include <gdi.h> |
|
25 |
|
26 // User includes |
|
27 #include "xnappuiadapter.h" |
|
28 #include "xnuiengine.h" |
|
29 #include "xneditmode.h" |
|
30 #include "xnviewadapter.h" |
|
31 #include "xnfocuscontrol.h" |
|
32 |
|
33 #include "xnbgcontrol.h" |
|
34 |
|
35 // Constants |
|
36 |
|
37 // ============================ LOCAL FUNCTIONS ================================ |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CXnBgControl::NewL() |
|
42 // Two-phased constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CXnBgControl* CXnBgControl::NewL() |
|
46 { |
|
47 CXnBgControl* self = CXnBgControl::NewLC(); |
|
48 CleanupStack::Pop( self ); |
|
49 return self; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CXnBgControl::NewLC() |
|
54 // Two-phased constructor. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CXnBgControl* CXnBgControl::NewLC() |
|
58 { |
|
59 CXnBgControl* self = new ( ELeave ) CXnBgControl(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CXnBgControl::~CXnBgControl() |
|
67 // C++ default destructor. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 CXnBgControl::~CXnBgControl() |
|
71 { |
|
72 delete iBgContext; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CXnBgControl::CXnBgControl() |
|
77 // C++ default constructor. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 CXnBgControl::CXnBgControl() |
|
81 { |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // CXnBgControl::ConstructL() |
|
86 // 2nd phase constructor |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CXnBgControl::ConstructL() |
|
90 { |
|
91 CreateWindowL(); |
|
92 |
|
93 EnableDragEvents(); |
|
94 |
|
95 Window().SetPointerGrab( ETrue ); |
|
96 |
|
97 iBgContext = CAknsLayeredBackgroundControlContext::NewL( |
|
98 KAknsIIDWallpaper, TRect(), ETrue, 1 ); |
|
99 |
|
100 ActivateL(); |
|
101 |
|
102 MakeVisible( ETrue ); |
|
103 |
|
104 SetComponentsToInheritVisibility( ETrue ); |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CXnBgControl::CountComponentControls() |
|
109 // |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 TInt CXnBgControl::CountComponentControls() const |
|
113 { |
|
114 if ( iControl ) |
|
115 { |
|
116 return 1; |
|
117 } |
|
118 |
|
119 return 0; |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CXnBgControl::ComponentControl() |
|
124 // |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 CCoeControl* CXnBgControl::ComponentControl( TInt aIndex ) const |
|
128 { |
|
129 if ( aIndex == 0 ) |
|
130 { |
|
131 return iControl; |
|
132 } |
|
133 |
|
134 return NULL; |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CXnBgControl::SizeChanged() |
|
139 // |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CXnBgControl::SizeChanged() |
|
143 { |
|
144 TRect rect; |
|
145 |
|
146 #ifdef RD_FULLSCREEN_WALLPAPER |
|
147 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, rect ); |
|
148 #else |
|
149 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, rect ); |
|
150 #endif |
|
151 |
|
152 iBgContext->SetRect( rect ); |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CXnBgControl::Draw() |
|
157 // |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CXnBgControl::Draw( const TRect& aRect ) const |
|
161 { |
|
162 CXnAppUiAdapter* appui( |
|
163 static_cast< CXnAppUiAdapter* >( iAvkonAppUi ) ); |
|
164 |
|
165 TInt state( appui->UiEngine().EditMode()->EditState() ); |
|
166 |
|
167 CWindowGc& gc( SystemGc() ); |
|
168 |
|
169 if ( state == CXnEditMode::EShootContent ) |
|
170 { |
|
171 // No background needed for dragging widget screenshot |
|
172 } |
|
173 else |
|
174 { |
|
175 MAknsSkinInstance* skin( AknsUtils::SkinInstance() ); |
|
176 |
|
177 AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect ); |
|
178 } |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CXnBgControl::SetCompoundControl() |
|
183 // |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CXnBgControl::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
187 { |
|
188 CXnAppUiAdapter* appui( static_cast< CXnAppUiAdapter* >( iAvkonAppUi ) ); |
|
189 |
|
190 appui->UiEngine().DisableRenderUiLC(); |
|
191 |
|
192 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
193 |
|
194 appui->UiEngine().RenderUIL(); |
|
195 |
|
196 CleanupStack::PopAndDestroy(); |
|
197 } |
|
198 |
|
199 // ----------------------------------------------------------------------------- |
|
200 // CXnBgControl::SetCompoundControl() |
|
201 // |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CXnBgControl::SetCompoundControl( CCoeControl* aControl ) |
|
205 { |
|
206 if ( iControl == aControl ) |
|
207 { |
|
208 return; |
|
209 } |
|
210 |
|
211 if ( iControl ) |
|
212 { |
|
213 // Remove parents |
|
214 iControl->SetParent( NULL ); |
|
215 iControl->SetMopParent( NULL ); |
|
216 |
|
217 iControl->MakeVisible( EFalse ); |
|
218 } |
|
219 |
|
220 if ( aControl ) |
|
221 { |
|
222 // Set self as parent |
|
223 aControl->SetParent( this ); |
|
224 aControl->SetMopParent( this ); |
|
225 |
|
226 aControl->MakeVisible( ETrue ); |
|
227 } |
|
228 |
|
229 iControl = aControl; |
|
230 } |
|
231 |
|
232 // End of file |
|
233 |