|
1 /* |
|
2 * Copyright (c) 2002-2003 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: The CView class is responsible for displaying the box tree, |
|
15 * handling user input events such as scrolling and navigating links. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef __MVCVIEW_H |
|
21 #define __MVCVIEW_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <eikbctrl.h> |
|
25 #include <eikscrlb.h> |
|
26 |
|
27 #include <cenrepnotifyhandler.h> |
|
28 |
|
29 #include <e32std.h> |
|
30 #include <e32def.h> |
|
31 #include <f32file.h> |
|
32 #include <aknpictographinterface.h> |
|
33 #include <aknpictographdrawerinterface.h> |
|
34 |
|
35 #include <BrCtlDefs.h> |
|
36 #include <BrCtlDialogsProvider.h> |
|
37 #include "BrsrStatusCodes.h" |
|
38 #include "ImageUtils.h" |
|
39 #include "LMgrBoxTreeListener.h" |
|
40 #include "BrsrTypes.h" |
|
41 #include "nw_gdi_types.h" |
|
42 #include "nw_evt_scrollevent.h" |
|
43 #include "CBrowserSettings.h" |
|
44 |
|
45 #include "BrCtl.h" |
|
46 #include "MemoryManager.h" |
|
47 #include "pagescaler.h" |
|
48 |
|
49 |
|
50 #include "wmlcontrol.h" |
|
51 template <class T> class CArrayPtrFlat; |
|
52 |
|
53 // CONSTANTS |
|
54 const TInt KPanicKmViewPanicBase = -9000; |
|
55 const TInt KPanicKmViewTlsNotInitialized = KPanicKmViewPanicBase - 1; |
|
56 const TInt KPanicKmViewSingletonAlreadyCreated = KPanicKmViewPanicBase - 2; |
|
57 const TInt KPanicKmViewTlsViewPointerIsNull = KPanicKmViewPanicBase - 3; |
|
58 |
|
59 |
|
60 // MACROS |
|
61 |
|
62 // DATA TYPES |
|
63 |
|
64 typedef enum |
|
65 { |
|
66 EKmEvAddToPhoneBook, |
|
67 EKmEvMakeCall, |
|
68 EKmEvRemoveFileName, |
|
69 EKmEvOpenToExternalApp, |
|
70 EKmEvDownloadObject |
|
71 } TKimonoEventType; |
|
72 |
|
73 // FUNCTION PROTOTYPES |
|
74 |
|
75 // FORWARD DECLARATIONS |
|
76 class CEikScrollBarFrame; |
|
77 class CAknNavigationDecorator; |
|
78 class CPtrC8Array; |
|
79 class CViewAsyncInit; |
|
80 class MViewListener; |
|
81 class CShell; |
|
82 //class CBrCtl; |
|
83 class TBrCtlImageCarrier; |
|
84 class MViewFocusObserver; |
|
85 |
|
86 // CLASS DECLARATIONS |
|
87 class MBrCtlStateChangeObserver; |
|
88 |
|
89 |
|
90 /** |
|
91 * CView |
|
92 * The CView class is responsible for displaying the box tree, and |
|
93 * handling user input events such as scrolling and navigating links. |
|
94 * |
|
95 * @lib browserengine.dll |
|
96 * @since 2.x |
|
97 */ |
|
98 |
|
99 |
|
100 NONSHARABLE_CLASS(CView) : public CEikBorderedControl, public MCenRepNotifyHandlerCallback, |
|
101 public MAknPictographAnimatorCallBack, public MBoxTreeListener, private MPageScalerCallback |
|
102 { |
|
103 public: |
|
104 static CView* NewL(CCoeControl* aParent, CBrCtl* aBrCtl, TRect& aRect, CWmlControl* aWmlControl ); |
|
105 |
|
106 ~CView(); |
|
107 |
|
108 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
109 |
|
110 TBrCtlDefs::TBrCtlElementType GetFocusedElementType(); |
|
111 |
|
112 NW_Bool InputElementEditComplete(TBool aInputConfirmed); |
|
113 |
|
114 void HandleActivationEvent(); |
|
115 |
|
116 void GenerateAndProcessEvent(const TKimonoEventType& aEvent); |
|
117 |
|
118 /** |
|
119 * SetBrowserSettingL |
|
120 * Set the setting's value. |
|
121 * @since 2.x |
|
122 * @param TUint setting - the number of the setting you wish to set. |
|
123 * This corresponds to a value in the TBrowserSettings enum |
|
124 * @param TUint value - the value you wish to set for the setting |
|
125 * If the value is true/false use 1/0 otherwise the value must correspond |
|
126 * to a value in either one of the following enumerated types: |
|
127 * TBrowserFontSizeLevel or TBrowserFullScreenValue |
|
128 * @return void |
|
129 */ |
|
130 void SetBrowserSettingL(TUint aSetting, TUint aValue); |
|
131 |
|
132 /** |
|
133 * GetBrowserSettingL |
|
134 * Get the setting's value. |
|
135 * @since 2.x |
|
136 * @param TUint setting - the setting whose value you wish to retrieve |
|
137 * @return TUint - value of the setting (as an integer). For true/false |
|
138 * 1/0 will be returned. For other settings, the return value will correspond |
|
139 * with one of the following enumerated types: TBrowserFontSizeLevel or |
|
140 * TBrowserFullScreenValue |
|
141 */ |
|
142 TUint GetBrowserSettingL(TUint aSetting) const; |
|
143 |
|
144 CArrayFixFlat<TBrCtlImageCarrier>* GetPageImagesL(); |
|
145 |
|
146 void SwitchVerticalLayout (); |
|
147 |
|
148 |
|
149 void DrawPictographsInText(CBitmapContext& aGc, const CFont& aFont, const TDesC& aText, const TPoint& aPosition); |
|
150 |
|
151 /** |
|
152 * Check to see if we are in image map view |
|
153 * |
|
154 * @param None |
|
155 * @return TBool ETrue if we are in image map view, EFalse otherwise |
|
156 */ |
|
157 inline TBool IsImageMapView() { return iIsImageMapView; }; |
|
158 |
|
159 /** |
|
160 * This method is called if we are in image map view to create an image list |
|
161 * that just contains the one image shown in the image map view. |
|
162 * |
|
163 * @param None |
|
164 * @return TBool ETrue if we are in image map view, EFalse otherwise |
|
165 */ |
|
166 void GetViewImageList(void* aDynamicVector); |
|
167 |
|
168 // Return the number of active elements in the page |
|
169 TUint GetActiveElements(); |
|
170 |
|
171 /** |
|
172 * |
|
173 * @param box |
|
174 * @return NW_Bool NW_TRUE, if vox is just placeholder (0,0;0x0) |
|
175 * NW_FALSE otherwise; |
|
176 */ |
|
177 NW_Bool |
|
178 IsZeroBox (const NW_LMgr_Box_t* box) const; |
|
179 // Redraw the positioned box on top every time that something was redrawn |
|
180 TBrowserStatusCode DrawPositionedBoxes(); |
|
181 |
|
182 // Any slow browser initialization can happen here |
|
183 void AsyncInit(); |
|
184 |
|
185 TBrowserStatusCode Draw (const NW_Bool); |
|
186 |
|
187 public: // from MBrowserSettingsObserver |
|
188 void BrowserSettingChanged( enum TBrowserSetting aBrowserSetting ); |
|
189 |
|
190 protected: // From CCoeControl |
|
191 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
192 |
|
193 void FocusChanged(TDrawNow aDrawNow); |
|
194 |
|
195 void SizeChanged(); |
|
196 |
|
197 void Draw(const TRect& aRect) const; |
|
198 |
|
199 TInt CountComponentControls() const; |
|
200 |
|
201 CCoeControl* ComponentControl(TInt aIndex) const; |
|
202 |
|
203 protected: |
|
204 void HandleResourceChange(TInt aType); |
|
205 |
|
206 private: // from MSharedDataNotifyHandler |
|
207 |
|
208 void HandleNotifyString(TUint32 aKeyId, const TDesC16& aValue); |
|
209 |
|
210 private: // from MAknPictographDrawerCallBack |
|
211 void DrawPictographArea(); |
|
212 |
|
213 protected: |
|
214 TKeyResponse DoHandleControlKeysL(const TKeyEvent& aKeyEvent); |
|
215 |
|
216 private: // from MPageScalerCallback |
|
217 |
|
218 void DrawDocumentPart( CFbsBitGc& aGc, CFbsBitmap* /*aBitmap*/, const TRect& aDocumentAreaToDraw ); |
|
219 |
|
220 TRect DocumentViewport() ; |
|
221 |
|
222 void ScaledPageChanged( const TRect& aRect, TBool aFullScreen, TBool aScroll ); |
|
223 |
|
224 TSize DocumentSize(); |
|
225 |
|
226 TBool TouchScrolling() { return EFalse; } |
|
227 |
|
228 CCoeControl& PageControlView() { return *(iBrCtl->CCoeControlParent());} |
|
229 |
|
230 |
|
231 private: |
|
232 CView(CBrCtl* aBrCtl); |
|
233 |
|
234 void ConstructL(CCoeControl* aParent, TRect& aRect, CWmlControl* aWmlControl ); |
|
235 |
|
236 TBrowserStatusCode Cancel (); |
|
237 |
|
238 void CreateOffscreenBitmapL( const TRect& aRect ); |
|
239 |
|
240 // Any slow browser initialization can happen here |
|
241 void AsyncInitL(); |
|
242 |
|
243 // Delete entries in a given directory |
|
244 void DeleteDirectoryEntriesL(RFs& aRfs, TPtrC16& aFilePath); |
|
245 |
|
246 NW_Bool DispatchEvent (const NW_Evt_Event_t* event); |
|
247 |
|
248 TBrowserStatusCode FormatPartial (); |
|
249 |
|
250 NW_LMgr_Box_t* GetNextSiblingBox (const NW_LMgr_Box_t* box); |
|
251 |
|
252 TBrowserStatusCode InitializeTree (NW_LMgr_RootBox_t *rootBox, TBool isFormatingBoxTree); |
|
253 |
|
254 // |
|
255 void InitializePageScalerL(); |
|
256 |
|
257 public: // but not exported. For Kimono internal use ("C" side) |
|
258 |
|
259 void SetFormattingPriority( CActive::TPriority aPriority ); |
|
260 |
|
261 TInt AppendFocusObserver(MViewFocusObserver* aViewFocusObserver); |
|
262 |
|
263 TInt AddStateChangeObserver(MBrCtlStateChangeObserver* aBrCtlStateChangeObserver); |
|
264 |
|
265 void BoxTreeDestroyed (); |
|
266 |
|
267 TBool ValidateAddedIndex(NW_LMgr_Box_t* aBox, NW_LMgr_Box_t* aMasterBox); |
|
268 |
|
269 TBrowserStatusCode BoxTreeListenerAppendTabItem (NW_LMgr_Box_t* box); |
|
270 |
|
271 TBrowserStatusCode BoxTreeListenerRelayout (NW_Bool createTabList); |
|
272 |
|
273 TBrowserStatusCode Collapse (NW_LMgr_FlowBox_t* containingFlow, NW_Bool collapseAnonymous); |
|
274 |
|
275 TBrowserStatusCode CreateTabIndexList (); |
|
276 |
|
277 void DoScrollL(const TInt16 aScrollDirection, const TUint32 aScrollDelta); |
|
278 |
|
279 void EnableSuppressDupReformats (NW_Int16 state); |
|
280 |
|
281 void EpocDrawNow (NW_Bool drawNow); |
|
282 |
|
283 NW_Bool EpocProcessEvent (const NW_Evt_Event_t* event); |
|
284 |
|
285 void ExternalLayoutSwitch (); |
|
286 |
|
287 TBrowserStatusCode ForceCurrentBox (NW_LMgr_Box_t* newbox, NW_Bool isNewPage, NW_Bool isRefreshNeeded); |
|
288 |
|
289 TBrowserStatusCode FormatBoxTree (NW_Bool createTabList); |
|
290 |
|
291 void FormattingComplete (); |
|
292 |
|
293 NW_ADT_Vector_Metric_t GetActiveBoxId (); |
|
294 |
|
295 NW_LMgr_Box_t* GetInFocusBox () const; |
|
296 |
|
297 NW_LMgr_Box_t* GetLastVisibleBox () const; |
|
298 |
|
299 NW_LMgr_Box_t* GetNextEventListener (NW_LMgr_BoxVisitor_t* boxVisitor); |
|
300 |
|
301 const NW_GDI_Point2D_t* GetOrigin (); |
|
302 |
|
303 void* GetScroll () const; |
|
304 |
|
305 TBrowserStatusCode GetScrollRange (NW_GDI_Point2D_t* scrollRange); |
|
306 |
|
307 NW_LMgr_Box_t* GetVisibleBox () const; |
|
308 |
|
309 NW_LMgr_Box_t* GetVisibleBoxReverse () const; |
|
310 |
|
311 NW_Bool GetXScrollAmt (const NW_LMgr_Box_t* box, NW_Int32* scrollDelta, NW_Evt_ScrollEvent_Direction_t* scrollDir, NW_Bool scrollMaxAmt) const; |
|
312 |
|
313 NW_Bool GetYScrollAmt (const NW_LMgr_Box_t* box, NW_Int32* scrollDelta, NW_Evt_ScrollEvent_Direction_t* scrollDir, NW_Bool scrollMaxAmt) const; |
|
314 |
|
315 TBrowserStatusCode GotoActiveBox (NW_ADT_Vector_Metric_t activeBoxId); |
|
316 |
|
317 TBrowserStatusCode GotoBox (NW_LMgr_Box_t* box); |
|
318 |
|
319 void HandleError (TBrowserStatusCode status); |
|
320 |
|
321 NW_Bool HandleGNavigation (NW_Uint32 tabIndex); |
|
322 |
|
323 static TBrowserStatusCode InputInvalid(void* aCEpoc32View, TInt aMin); |
|
324 |
|
325 static TBrowserStatusCode InputInvalidL(void* aCEpoc32View, TInt aMin); |
|
326 |
|
327 NW_Bool IsBoxVisible (const NW_LMgr_Box_t* box, NW_GDI_Rectangle_t *bounds) const; |
|
328 |
|
329 TBrowserStatusCode JumpToLink (const NW_LMgr_Box_t* box, NW_Bool scrollMaxAmt); |
|
330 |
|
331 NW_Bool ProcessAccessKey (const NW_Evt_KeyEvent_t* event); |
|
332 |
|
333 NW_Bool ProcessEvent (const NW_Evt_Event_t* event); |
|
334 |
|
335 TBrowserStatusCode RedrawDisplay (NW_Bool drawNow); |
|
336 |
|
337 TBrowserStatusCode ReformatBox (NW_LMgr_Box_t* box); |
|
338 |
|
339 TBrowserStatusCode Refresh (NW_LMgr_Box_t* box); |
|
340 |
|
341 TBrowserStatusCode Relayout (NW_Bool createTabList); |
|
342 |
|
343 void RemoveFocusObserver(MViewFocusObserver* aViewFocusObserver); |
|
344 |
|
345 void RemoveStateChangeObserver(MBrCtlStateChangeObserver* aBrCtlStateChangeObserver); |
|
346 |
|
347 NW_Bool ScrollAfterCurrentBox (const NW_LMgr_Box_t* box, NW_Bool scrollMaxAmt); |
|
348 |
|
349 void SetAppServices(void *appServices); // appservices are of type NW_HED_AppServices |
|
350 |
|
351 TInt SetBoxTree(const NW_LMgr_Box_t* boxTree); // return value is TBrowserStatusCode |
|
352 |
|
353 TBrowserStatusCode SetCurrentMasterBox (); |
|
354 |
|
355 TBrowserStatusCode SetDeviceContext (CGDIDeviceContext* deviceContext); |
|
356 |
|
357 TBrowserStatusCode SetDisplayExtents (NW_GDI_Rectangle_t* displayExtents); |
|
358 |
|
359 void SetShell(CShell* shell); |
|
360 |
|
361 TBrowserStatusCode SetListener (MViewListener* viewListener); |
|
362 |
|
363 TBrowserStatusCode SetOrigin (NW_GDI_Point2D_t* origin); |
|
364 |
|
365 void StartCSSApply (); |
|
366 |
|
367 void DisableAnimation(); |
|
368 |
|
369 void EnableAnimation(); |
|
370 |
|
371 TBrowserStatusCode SwitchFromImageMapView (); |
|
372 |
|
373 TBrowserStatusCode SwitchToImageMapView (); |
|
374 |
|
375 TBrowserStatusCode SwitchVerticalLayout (NW_Bool aFormatBoxTree, NW_Bool aSwitchBox); |
|
376 |
|
377 void UpdateCBAs () const; |
|
378 |
|
379 void UpdateScrollBarsL(CEikScrollBar::TOrientation aOrientation,const TInt aThumbPos ,const TInt aScrollSpan); |
|
380 |
|
381 TBrowserStatusCode UpdateHScrollBar () const; |
|
382 |
|
383 TBrowserStatusCode UpdateVScrollBar () const; |
|
384 |
|
385 inline NW_LMgr_Box_t* GetCurrentBox () { return iCurrentBox; }; |
|
386 |
|
387 inline CGDIDeviceContext* GetDeviceContext () { return iDeviceContext; }; |
|
388 |
|
389 inline void* GetParentWindow () { return this; }; |
|
390 |
|
391 inline NW_GDI_Dimension2D_t GetScrollAmt () {return iScrollAmt;}; |
|
392 |
|
393 inline NW_ADT_DynamicVector_t* GetTabList () {return iTabList;}; |
|
394 |
|
395 inline NW_LMgr_RootBox_t* GetRootBox () { return iRootBox; }; |
|
396 |
|
397 inline NW_GDI_Dimension2D_t GetVisibleAmt () {return iVisibleAmt;} ; |
|
398 |
|
399 inline NW_Bool IsForcedReformatNeeded () { return iForceReformatNeeded; }; |
|
400 |
|
401 inline void ForcedReformatNeeded () { iForceReformatNeeded = NW_TRUE; }; |
|
402 |
|
403 inline void SetCurrentBox (NW_LMgr_Box_t* aCurrentBox) { iCurrentBox = aCurrentBox; }; |
|
404 |
|
405 inline void SetInitialActiveBoxId (NW_ADT_Vector_Metric_t aInitialActiveBoxId) {iInitialActiveBoxId = aInitialActiveBoxId; }; |
|
406 |
|
407 inline void SetInitialDocPosition (NW_GDI_Metric_t aX, NW_GDI_Metric_t aY) { iInitialDocPosition.x = aX; iInitialDocPosition.y = aY; }; |
|
408 |
|
409 inline CPageScaler* PageScaler() { return iPageScaler; } |
|
410 |
|
411 TBrowserStatusCode SetAnchorName (NW_Text_t *anchorName); |
|
412 |
|
413 void ContentSize(TSize& aContentSize) ; |
|
414 NW_Bool FormatPositionedBoxes (); |
|
415 void ScrollTo(TPoint aPoint); |
|
416 |
|
417 public: |
|
418 CBrCtl* BrCtl() {return iBrCtl;} |
|
419 void DrawHistory( CFbsBitGc& aGc, const TRect& aDocumentAreaToDraw ) const; |
|
420 |
|
421 private: |
|
422 TBrowserStatusCode AppendTabItem (NW_LMgr_Box_t* box); |
|
423 |
|
424 void DeleteOptionItems (); |
|
425 |
|
426 NW_GDI_Rectangle_t GetBoxDisplayBounds (NW_LMgr_Box_t* aBox); |
|
427 |
|
428 TBrowserStatusCode GetBoxTabIndex (NW_LMgr_Box_t* box, NW_ADT_Vector_Metric_t* index); |
|
429 |
|
430 TBrowserStatusCode HandleFormattingComplete (); |
|
431 |
|
432 NW_Bool ProcessFontSizeChangeEvent (); |
|
433 |
|
434 NW_Bool ProcessScrollEvent (const NW_Evt_ScrollEvent_t* scrollEvent); |
|
435 |
|
436 NW_Bool ProcessTabEvent (const NW_Evt_TabEvent_t* tabEvent); |
|
437 |
|
438 void SetBoxFormatBounds (NW_LMgr_Box_t* aBox, NW_GDI_Rectangle_t aBoxBounds); |
|
439 |
|
440 TBrowserStatusCode SetupTableFormat (NW_Bool /*relayoutEvent*/); |
|
441 |
|
442 TBrowserStatusCode UpdateScrollBars () const; |
|
443 |
|
444 void GetParentBox(NW_LMgr_Box_t* parentBox, NW_LMgr_Box_t** pReturnedParentBox); |
|
445 private: |
|
446 CBitmapContext* iBitmapContext; |
|
447 CBitmapDevice* iBitmapDevice; |
|
448 TInt iLastRepeats; // To signify long keypresses |
|
449 RPointerArray<MViewListener> iListeners; |
|
450 CFbsBitmap* iOffscreenBitmap; |
|
451 CShell* iShell; |
|
452 CBrCtl* iBrCtl; |
|
453 CAknPictographInterface* iPictographInterface; |
|
454 |
|
455 CPageScaler* iPageScaler; |
|
456 |
|
457 |
|
458 |
|
459 CRepository* iRepository; |
|
460 CCenRepNotifyHandler* iNotifyHandler; |
|
461 |
|
462 RPointerArray <MViewFocusObserver> iViewFocusObserver; |
|
463 RPointerArray <MBrCtlStateChangeObserver> iStateChangeObserver; |
|
464 CViewAsyncInit* iViewAsyncInit; |
|
465 TInt iVScrollPosition; |
|
466 |
|
467 /* The layout manager context */ |
|
468 CArrayPtrFlat<NW_LMgr_RootBox_t>* iRootBoxArray; |
|
469 |
|
470 void* iBoxFormatHandler; |
|
471 NW_Bool iCreateTabList; |
|
472 NW_LMgr_Box_t* iCurrentBox; |
|
473 CGDIDeviceContext* iDeviceContext; |
|
474 NW_Bool iExternalLayoutSwitch; |
|
475 NW_Bool iIsImageMapView; |
|
476 NW_ADT_DynamicVector_t* iOptionItemList; /* for clean up purpose */ |
|
477 NW_ADT_DynamicVector_t* iTabList; |
|
478 NW_LMgr_RootBox_t* iRootBox; |
|
479 |
|
480 /* Scroll data */ |
|
481 void* iScroll; |
|
482 NW_GDI_Dimension2D_t iMaxScrollAmt; |
|
483 NW_GDI_Dimension2D_t iScrollAmt; |
|
484 NW_GDI_Dimension2D_t iVisibleAmt; |
|
485 TPoint iLastPosition; |
|
486 |
|
487 NW_Bool iDrawNow; |
|
488 |
|
489 TBool iDocumentFinished; |
|
490 |
|
491 |
|
492 /*the initial box id and initial docposition , is used after |
|
493 the formatting is complete */ |
|
494 NW_ADT_Vector_Metric_t iInitialActiveBoxId; |
|
495 NW_GDI_Point2D_t iInitialDocPosition; |
|
496 |
|
497 /* |
|
498 ** Used to suppress duplicate reformats when a single image is repeated |
|
499 ** several times within the same page. |
|
500 */ |
|
501 NW_Int16 iSuppressDupReformats; |
|
502 NW_LMgr_Box_t* iPendingReformatBox; |
|
503 NW_Bool iForceReformatNeeded; |
|
504 NW_Text_t *iAnchorName; |
|
505 CActive::TPriority iFormatPriority; |
|
506 CWmlControl* iWmlControl; |
|
507 TBool iShouldActivate; |
|
508 }; |
|
509 |
|
510 #endif // EPOC32VIEW_H |
|
511 |
|
512 // End of File |
|
513 |
|
514 |