|
1 /* |
|
2 * Copyright (c) 2006-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 the License "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 "WidgetUi.hrh" |
|
19 #include "WidgetUiWindowContainer.h" |
|
20 #include "WidgetUiWindowManager.h" |
|
21 #include "WidgetUiWindowView.h" |
|
22 #include "WidgetUiWindow.h" |
|
23 |
|
24 #include <WidgetUi.rsg> |
|
25 |
|
26 #include <WidgetRegistryConstants.h> |
|
27 |
|
28 #include <BrCtlInterface.h> |
|
29 #include <ApUtils.h> |
|
30 #include <InternetConnectionManager.h> |
|
31 #include <ActiveApDb.h> |
|
32 #include <avkon.hrh> |
|
33 #include <aknsdrawutils.h> |
|
34 #include <AknsBasicBackgroundControlContext.h> |
|
35 |
|
36 // CAknMessageQueryDialog |
|
37 #include <AknMessageQueryDialog.h> |
|
38 #include <aknnotewrappers.h> |
|
39 #include <AknNoteDialog.h> |
|
40 #include <BrowserDialogsProvider.h> |
|
41 |
|
42 // EXTERNAL DATA STRUCTURES |
|
43 |
|
44 // EXTERNAL FUNCTION PROTOTYPES |
|
45 |
|
46 // CONSTANTS |
|
47 |
|
48 // MACROS |
|
49 |
|
50 // LOCAL CONSTANTS AND MACROS |
|
51 |
|
52 // MODULE DATA STRUCTURES |
|
53 |
|
54 // LOCAL FUNCTION PROTOTYPES |
|
55 |
|
56 // FORWARD DECLARATIONS |
|
57 |
|
58 // ============================= LOCAL FUNCTIONS =============================== |
|
59 |
|
60 |
|
61 // ============================ MEMBER FUNCTIONS =============================== |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CWidgetUiWindowContainer::NewL |
|
65 // two-phase constructor |
|
66 // |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CWidgetUiWindowContainer* |
|
70 CWidgetUiWindowContainer::NewL( |
|
71 const TRect& aRect, CWidgetUiWindowManager& aWindowManager ) |
|
72 { |
|
73 CWidgetUiWindowContainer* container = |
|
74 new ( ELeave ) CWidgetUiWindowContainer( aWindowManager ); |
|
75 CleanupStack::PushL( container ); |
|
76 container->ConstructL( aRect ); |
|
77 CleanupStack::Pop(); // container |
|
78 |
|
79 return container; |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // CWidgetUiWindowContainer::ConstructL |
|
84 // EPOC two phased constructor |
|
85 // |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CWidgetUiWindowContainer::ConstructL( |
|
89 const TRect& aRect) |
|
90 { |
|
91 #ifdef _DEBUG |
|
92 _LIT(KDir, "WidgetUi"); |
|
93 _LIT(KFile, "WidgetUi.log"); |
|
94 #endif |
|
95 |
|
96 #ifdef _DEBUG |
|
97 TInt err = iFileLogger.Connect(); |
|
98 if (err == KErrNone) |
|
99 { |
|
100 iFileLogger.CreateLog( KDir(), KFile(), EFileLoggingModeOverwrite ); |
|
101 iCanLog = ETrue; |
|
102 } |
|
103 #endif |
|
104 |
|
105 |
|
106 iCommandBase = TBrCtlDefs::ECommandIdBase; |
|
107 |
|
108 CreateWindowL(); |
|
109 |
|
110 SetRect( aRect ); |
|
111 iSkinContext = CAknsBasicBackgroundControlContext::NewL( |
|
112 KAknsIIDQsnBgScreen , aRect, EFalse); |
|
113 |
|
114 ActivateL(); |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CWidgetUiWindowContainer::CWidgetUiWindowContainer |
|
119 // C++ default constructor |
|
120 // |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 CWidgetUiWindowContainer::CWidgetUiWindowContainer(CWidgetUiWindowManager& aWindowManager) |
|
124 :iWindowManager( aWindowManager ) |
|
125 { |
|
126 |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CWidgetUiWindowContainer::~CWidgetUiWindowContainer |
|
131 // Destructor |
|
132 // |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 CWidgetUiWindowContainer::~CWidgetUiWindowContainer() |
|
136 { |
|
137 delete iSkinContext; |
|
138 |
|
139 #ifdef _DEBUG |
|
140 if (iCanLog) |
|
141 { |
|
142 iFileLogger.CloseLog(); |
|
143 iFileLogger.Close(); |
|
144 } |
|
145 #endif |
|
146 |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // CWidgetUiWindowContainer::SizeChanged |
|
151 // Called by framework when the view size is changed |
|
152 // |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CWidgetUiWindowContainer::SizeChanged() |
|
156 { |
|
157 TInt offset( 0 ); |
|
158 |
|
159 if( Engine() && (Engine()->Rect() != Rect()) ) |
|
160 { |
|
161 TRect rect( Rect() ); |
|
162 //rect.iBr.iY-=offset; |
|
163 Engine()->SetRect( rect ); |
|
164 } |
|
165 |
|
166 if(iSkinContext) |
|
167 iSkinContext->SetRect(Rect()); |
|
168 |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CWidgetUiWindowContainer::CountComponentControls |
|
173 // return the number of controls contained |
|
174 // |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CWidgetUiWindowContainer::CountComponentControls() const |
|
178 { |
|
179 TInt count( 0 ); |
|
180 if( Engine() ) |
|
181 { |
|
182 count++; |
|
183 } |
|
184 return count; |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CWidgetUiWindowContainer::ComponentControl |
|
189 // return the component control identified by the given index |
|
190 // |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 CCoeControl* CWidgetUiWindowContainer::ComponentControl( TInt aIndex ) const |
|
194 { |
|
195 switch( aIndex ) |
|
196 { |
|
197 case 0: |
|
198 { |
|
199 return Engine(); |
|
200 } |
|
201 default: |
|
202 { |
|
203 return NULL; |
|
204 } |
|
205 } |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CWidgetUiWindowContainer::Draw |
|
210 // Draws the control |
|
211 // |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CWidgetUiWindowContainer::Draw(const TRect& aRect) const |
|
215 { |
|
216 CWindowGc& gc = SystemGc(); |
|
217 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
218 if (iSkinContext && !AknsDrawUtils::Background(skin, iSkinContext, this, gc, aRect)) |
|
219 { |
|
220 // default draw if no skin |
|
221 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
222 gc.SetBrushColor( KRgbWhite ); |
|
223 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
224 gc.DrawRect( aRect ); |
|
225 } |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CWidgetUiWindowContainer::HandleKeyEventL |
|
230 // Handles key events |
|
231 // |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 TKeyResponse CWidgetUiWindowContainer::HandleKeyEventL( |
|
235 const TKeyEvent& /*aKeyEvent*/, |
|
236 TEventCode /*aType*/ ) |
|
237 { |
|
238 return EKeyWasNotConsumed; |
|
239 } |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // CWidgetUiWindowContainer::HandleCommandL |
|
243 // Handles user commands |
|
244 // |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 void CWidgetUiWindowContainer::HandleCommandL( TInt aCommand ) |
|
248 { |
|
249 switch( aCommand ) |
|
250 { |
|
251 case ECmdReload: |
|
252 break; |
|
253 // MSK pressed in content view so notify BrCtl to activate item under cursor |
|
254 case ECmdMsk: |
|
255 { |
|
256 Engine()->HandleCommandL( |
|
257 (TInt)TBrCtlDefs::ECommandOpen + |
|
258 (TInt)TBrCtlDefs::ECommandIdBase ); |
|
259 break; |
|
260 } |
|
261 default: |
|
262 { |
|
263 Engine()->HandleCommandL( aCommand ); |
|
264 DrawDeferred();// re-draw widget after option menu goes away |
|
265 break; |
|
266 } |
|
267 } |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // CWidgetUiWindowContainer::OfferKeyEventL |
|
272 // Handles key events |
|
273 // |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 TKeyResponse CWidgetUiWindowContainer::OfferKeyEventL( |
|
277 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
278 { |
|
279 // Handle RED End Key (EKeyNo) |
|
280 if (aKeyEvent.iCode == EKeyNo) |
|
281 { |
|
282 // Close the current active widget |
|
283 iWindowManager.CloseWindowsAsync(EFalse); |
|
284 return EKeyWasConsumed; |
|
285 } |
|
286 |
|
287 TKeyResponse resp(EKeyWasNotConsumed); |
|
288 TBool editing(EFalse); |
|
289 //Reset the iIsOptionsMenuActivated if enabled |
|
290 iWindowManager.View()->DeActivateOptionsMenu(); |
|
291 |
|
292 if (Engine()) |
|
293 { |
|
294 TBool showStausPane(EFalse); |
|
295 TBrCtlDefs::TBrCtlElementType eType = Engine()->FocusedElementType(); |
|
296 switch(eType) |
|
297 { |
|
298 case TBrCtlDefs::EElementInputBox: |
|
299 case TBrCtlDefs::EElementActivatedInputBox: |
|
300 case TBrCtlDefs::EElementTextAreaBox: |
|
301 // status pane is needed for editing |
|
302 showStausPane = ETrue; |
|
303 // fall through |
|
304 case TBrCtlDefs::EElementObjectBox: |
|
305 case TBrCtlDefs::EElementActivatedObjectBox: |
|
306 { |
|
307 // Status pane must be shown before input is activated because resizing de-activates |
|
308 // the input box. |
|
309 // Rules for input activation: |
|
310 // Copied from WebKit BrowserView |
|
311 // CKeyEventHandler::HandleOfferKeyEventL case EEventKeyUp |
|
312 // (aKeyEvent.iScanCode > EStdKeyScrollLock && aKeyEvent.iScanCode < EStdKeyF1) |
|
313 if (aKeyEvent.iCode == EKeyEnter || aKeyEvent.iCode == EKeyOK || |
|
314 (aKeyEvent.iScanCode > EStdKeyScrollLock && aKeyEvent.iScanCode < EStdKeyF1)) |
|
315 { |
|
316 iWindowManager.View()->ShowActivatedObject(ETrue, showStausPane); |
|
317 editing = ETrue; |
|
318 } |
|
319 break; |
|
320 } |
|
321 default: |
|
322 break; |
|
323 } |
|
324 |
|
325 resp = Engine()->OfferKeyEventL( aKeyEvent, aType ); |
|
326 |
|
327 // special case for readonly input box - if not activated then remove status pane and cba |
|
328 if( editing && aType == EEventKeyUp && |
|
329 (Engine()->FocusedElementType() != TBrCtlDefs::EElementActivatedInputBox && |
|
330 Engine()->FocusedElementType() != TBrCtlDefs::EElementActivatedObjectBox )) |
|
331 { |
|
332 iWindowManager.View()->ShowActivatedObject(EFalse); |
|
333 } |
|
334 |
|
335 } |
|
336 |
|
337 return resp; |
|
338 } |
|
339 |
|
340 void CWidgetUiWindowContainer::FocusChanged(TDrawNow aDrawNow) |
|
341 { |
|
342 |
|
343 if (Engine()) |
|
344 Engine()->SetFocus(IsFocused()); |
|
345 |
|
346 CCoeControl::FocusChanged( aDrawNow ); |
|
347 } |
|
348 // ----------------------------------------------------------------------------- |
|
349 // CWidgetUiWindowContainer::CancelLoad() |
|
350 // |
|
351 // ----------------------------------------------------------------------------- |
|
352 // |
|
353 void CWidgetUiWindowContainer::CancelLoad() |
|
354 { |
|
355 } |
|
356 |
|
357 // ----------------------------------------------------------------------------- |
|
358 // CWidgetUiWindowContainer::Engine() |
|
359 // return CBrCtlInterface* |
|
360 // |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 CBrCtlInterface* CWidgetUiWindowContainer::Engine() const |
|
364 { |
|
365 CBrCtlInterface* engine = NULL; |
|
366 // Active window can be null at startup |
|
367 if( iWindowManager.ActiveWindow() ) |
|
368 { |
|
369 engine = iWindowManager.ActiveWindow()->Engine(); |
|
370 } |
|
371 |
|
372 return engine; |
|
373 } |
|
374 |
|
375 |
|
376 |
|
377 // ----------------------------------------------------------------------------- |
|
378 // CWidgetUiWindowContainer::ErrorNote() |
|
379 // |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 void CWidgetUiWindowContainer::ErrorNoteL( const TDesC& aPrompt ) |
|
383 { |
|
384 CAknErrorNote* note = new ( ELeave ) CAknErrorNote(); |
|
385 note->ExecuteLD( aPrompt ); |
|
386 } |
|
387 |
|
388 // ---------------------------------------------------------------------------- |
|
389 // CWidgetUiWindowContainer::InfoNoteL |
|
390 // |
|
391 // ---------------------------------------------------------------------------- |
|
392 // |
|
393 void CWidgetUiWindowContainer::InfoNoteL( const TDesC& aPrompt ) |
|
394 { |
|
395 CAknConfirmationNote* note = new (ELeave) CAknConfirmationNote( ETrue ); |
|
396 note->ExecuteLD( aPrompt ); |
|
397 } |
|
398 |
|
399 |
|
400 |
|
401 // End of File |