|
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: Layout calculation and UI rendering mechanism implementations. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _CXNUIENGINEIMPL_H |
|
20 #define _CXNUIENGINEIMPL_H |
|
21 |
|
22 // System includes |
|
23 |
|
24 // User includes |
|
25 #include "xnuistatelistener.h" |
|
26 #include "xnviewmanager.h" |
|
27 #include "xnmenu.h" |
|
28 |
|
29 // Forward declarations |
|
30 class CCoeControl; |
|
31 class CXnControlAdapter; |
|
32 class CXnNode; |
|
33 class CXnPointerArray; |
|
34 class CXnODT; |
|
35 class CGraphicsDevice; |
|
36 class CXnUiEngine; |
|
37 class CXnKeyEventDispatcher; |
|
38 class CXnEditor; |
|
39 class CXnResource; |
|
40 class CXnEditMode; |
|
41 class CXnHitTest; |
|
42 class CXnViewManager; |
|
43 class CXnViewData; |
|
44 class CXnPluginData; |
|
45 |
|
46 // Constants |
|
47 namespace XnLayoutPhase |
|
48 { |
|
49 const TInt ENone = 0x00; |
|
50 const TInt ELayout = 0x01; |
|
51 const TInt EMeasure = 0x02; |
|
52 } |
|
53 |
|
54 namespace XnLayoutControl |
|
55 { |
|
56 const TInt ELayoutUI = 0x01; |
|
57 const TInt ERenderUI = 0x02; |
|
58 const TInt ERefreshMenu = 0x04; |
|
59 const TInt EIgnoreState = 0x08; |
|
60 const TInt EViewDirty = 0x10; |
|
61 const TInt EEffectStarted = 0x20; |
|
62 const TInt EFirstPassDraw = 0x40; |
|
63 } |
|
64 |
|
65 NONSHARABLE_STRUCT( TXnDirtyRegion ) |
|
66 { |
|
67 RRegion iRegion; |
|
68 CCoeControl* iControl; // Not own. |
|
69 |
|
70 ~TXnDirtyRegion() |
|
71 { |
|
72 iRegion.Close(); |
|
73 } |
|
74 }; |
|
75 |
|
76 |
|
77 // Class declaration |
|
78 |
|
79 /** |
|
80 * Layout calculation and UI rendering mechanism |
|
81 * implementations. |
|
82 * |
|
83 * @ingroup group_xnlayoutengine |
|
84 * @lib xn3layoutengine.lib |
|
85 * @since Series 60 3.1 |
|
86 */ |
|
87 NONSHARABLE_CLASS( CXnUiEngineImpl ) : public CBase, |
|
88 public MXnViewObserver, |
|
89 public MXnUiResourceChangeObserver, |
|
90 public XnMenuInterface::MXnMenuObserver |
|
91 { |
|
92 |
|
93 public: |
|
94 // Constructors and destructor |
|
95 |
|
96 /** |
|
97 * Two-phased constructor. |
|
98 * |
|
99 * @param aUiEngine Ui engine |
|
100 * @param aViewManager View manager |
|
101 */ |
|
102 static CXnUiEngineImpl* NewL( CXnUiEngine& aUiEngine, |
|
103 CXnAppUiAdapter& aAdapter ); |
|
104 |
|
105 /** |
|
106 * 2nd phase constructor |
|
107 */ |
|
108 void ConstructL(); |
|
109 |
|
110 /** |
|
111 * Destructor. |
|
112 */ |
|
113 virtual ~CXnUiEngineImpl(); |
|
114 |
|
115 public: |
|
116 // New functions |
|
117 |
|
118 /** |
|
119 * Gets AppUi |
|
120 * |
|
121 * @since S60 5.0 |
|
122 * @return AppUi |
|
123 */ |
|
124 CXnAppUiAdapter& AppUiAdapter() const; |
|
125 |
|
126 /** |
|
127 * Lays out the UI |
|
128 * |
|
129 * @since Series 60 3.1 |
|
130 * @param aNode Starting point of the layout |
|
131 */ |
|
132 void LayoutUIL( CXnNode* aNode = NULL ); |
|
133 |
|
134 /** |
|
135 * Creates UI implementations for the UI, adjusts control coordinates |
|
136 * according to the layout |
|
137 * |
|
138 * @since Series 60 3.1 |
|
139 * @param aNode Starting point |
|
140 */ |
|
141 void RenderUIL( CXnNode* aNode = NULL ); |
|
142 |
|
143 /** |
|
144 * Gets the root node of the UI |
|
145 * |
|
146 * @since Series 60 3.1 |
|
147 * @return Root node |
|
148 */ |
|
149 CXnNode* RootNode(); |
|
150 |
|
151 /** |
|
152 * Gets the ODT |
|
153 * |
|
154 * @since Series 60 3.1 |
|
155 * @return ODT |
|
156 */ |
|
157 CXnODT* ODT(); |
|
158 |
|
159 /** |
|
160 * Finds a node by id |
|
161 * |
|
162 * @since Series 60 3.1 |
|
163 * @param aNode Node id |
|
164 * @param aNamespace Namespace |
|
165 * @return Node with given id |
|
166 */ |
|
167 CXnNode* FindNodeByIdL( const TDesC& aNodeId, |
|
168 const TDesC& aNamespace = KNullDesC ); |
|
169 /** |
|
170 * Finds a node by id, b-bit version |
|
171 * |
|
172 * @since Series 60 3.1 |
|
173 * @param aNode Node id |
|
174 * @param aNamespace Namespace |
|
175 * @return Node with given id |
|
176 */ |
|
177 CXnNode* FindNodeByIdL( const TDesC8& aNodeId, |
|
178 const TDesC8& aNamespace = KNullDesC8 ); |
|
179 /** |
|
180 * Finds nodes by class |
|
181 * |
|
182 * @since Series 60 3.1 |
|
183 * @param aClassId Class id |
|
184 * @return Nodes with given class id |
|
185 */ |
|
186 CXnPointerArray* FindNodeByClassL( const TDesC& aClassId, |
|
187 const TDesC& aNamespace = KNullDesC ); |
|
188 |
|
189 /** |
|
190 * Finds nodes by class |
|
191 * |
|
192 * @since Series 60 3.1 |
|
193 * @param aClassId Class id |
|
194 * @return Nodes with given class id |
|
195 */ |
|
196 CXnPointerArray* FindNodeByClassL( const TDesC8& aClassId, |
|
197 const TDesC8& aNamespace = KNullDesC8 ); |
|
198 |
|
199 /** |
|
200 * Gets resources of the UI |
|
201 * |
|
202 * @since Series 60 3.1 |
|
203 * @return List of resources |
|
204 */ |
|
205 CArrayPtrSeg< CXnResource >& Resources(); |
|
206 |
|
207 /** |
|
208 * Sets currently focused node |
|
209 * |
|
210 * @since Series 60 3.1 |
|
211 * @param aFocusedNode Currently focused node |
|
212 * @param aSource A source of event that triggered focus change. |
|
213 */ |
|
214 void SetFocusedNodeL( CXnNode* aFocusedNode, TInt aSource = 0 ); |
|
215 |
|
216 /** |
|
217 * Get currently focused node |
|
218 * |
|
219 * @since Series 60 3.1 |
|
220 * @return Focused node. |
|
221 */ |
|
222 CXnNode* FocusedNode(); |
|
223 |
|
224 /** |
|
225 * Checks if the UI is in Edit mode. |
|
226 * |
|
227 * @since Series 60 5.0 |
|
228 * @return ETrue if the current mode is edit, otherwise EFalse. |
|
229 */ |
|
230 TBool IsEditMode(); |
|
231 |
|
232 /** |
|
233 * Get a numeric value of a property in vertical pixels |
|
234 * |
|
235 * @since Series 60 3.1 |
|
236 * @param aValue Property |
|
237 * @param aReferenceValue Value used for percentage calculation |
|
238 * @return Value in vertical pixels |
|
239 */ |
|
240 TInt VerticalPixelValueL( CXnProperty* aValue, TInt aReferenceValue ); |
|
241 |
|
242 /** |
|
243 * Get a numeric value of a property in horizontal pixels |
|
244 * |
|
245 * @since Series 60 3.1 |
|
246 * @param aValue Property |
|
247 * @param aReferenceValue Value used for percentage calculation |
|
248 * @return Value in horizontal pixels |
|
249 */ |
|
250 TInt HorizontalPixelValueL( CXnProperty* aValue, TInt aReferenceValue ); |
|
251 |
|
252 /** |
|
253 * Get a numeric value of a property in vertical twips |
|
254 * |
|
255 * @since Series 60 3.1 |
|
256 * @param aValue Property |
|
257 * @param aReferenceValue Value used for percentage calculation |
|
258 * @return Value in vertical twips |
|
259 */ |
|
260 TInt VerticalTwipValueL( CXnProperty* aValue, TInt aReferenceValue ); |
|
261 |
|
262 /** |
|
263 * Get a numeric value of a property in horizontal twips |
|
264 * |
|
265 * @since Series 60 3.1 |
|
266 * @param aValue Property |
|
267 * @param aReferenceValue Value used for percentage calculation |
|
268 * @return Value in horizontal pixels |
|
269 */ |
|
270 TInt HorizontalTwipValueL( CXnProperty* aValue, TInt aReferenceValue ); |
|
271 |
|
272 /** |
|
273 * Refresh current menu |
|
274 * |
|
275 * @since Series 60 3.1 |
|
276 */ |
|
277 void RefreshMenuL(); |
|
278 |
|
279 /** |
|
280 * Returns view manager |
|
281 * |
|
282 * @since S60 5.0 |
|
283 * @return view manager |
|
284 */ |
|
285 CXnViewManager* ViewManager(); |
|
286 |
|
287 /** |
|
288 * Returns the active view |
|
289 |
|
290 * @since Series 60 3.1 |
|
291 * @return Active view node |
|
292 */ |
|
293 CXnNode* ActiveView(); |
|
294 |
|
295 /** |
|
296 * Add a dirty node. LayoutUiL and RenderUiL will only perform operations |
|
297 * on the set of dirty nodes. |
|
298 * |
|
299 * @since Series 60 3.1 |
|
300 * @param aNode Dirty node. |
|
301 * @param aLayoutPhaseHint, a hint where to start next layout phase |
|
302 */ |
|
303 void AddDirtyNodeL( CXnNode* aNode, TInt aLevel ); |
|
304 |
|
305 /** |
|
306 * Get the size of the current screen device |
|
307 * |
|
308 * @since Series 60 3.1 |
|
309 * @return Size of the current screen device |
|
310 */ |
|
311 TSize ScreenDeviceSize() const; |
|
312 |
|
313 /** |
|
314 * Checks whether the dialog is displaying. |
|
315 * |
|
316 * @since Series 60 3.1 |
|
317 * @return ETrue if dialog is displaying. |
|
318 */ |
|
319 TBool IsDialogDisplaying(); |
|
320 |
|
321 /** |
|
322 * Handles a change to the control's resources of type aType |
|
323 * |
|
324 * @since Series 60 3.1 |
|
325 * @param aType Changed resource type |
|
326 */ |
|
327 void HandleResourceChangeL( TInt aType ); |
|
328 |
|
329 /** |
|
330 * Checks whether the menu is displaying. |
|
331 * |
|
332 * @since Series 60 3.1 |
|
333 * @return ETrue if menu is displaying. |
|
334 */ |
|
335 TBool IsMenuDisplaying(); |
|
336 |
|
337 /** |
|
338 * Returns menubar node |
|
339 * |
|
340 * @since Series 60 3.2 |
|
341 * @return Menubar node |
|
342 */ |
|
343 CXnNode* MenuBarNode() const; |
|
344 |
|
345 /** |
|
346 * Returns stylus popup node |
|
347 * |
|
348 * @since S60 60 5.0 |
|
349 * @return stylus popup node |
|
350 */ |
|
351 CXnNode* StylusPopupNode() const; |
|
352 |
|
353 /** |
|
354 * Set node as passive, and add it to the passive focused node array. |
|
355 * |
|
356 * @since Series 60 3.2 |
|
357 * @param aNode Node to use. |
|
358 */ |
|
359 void AddPassiveFocusedNodeL( CXnNode* aNode ); |
|
360 |
|
361 /** |
|
362 * Unset the passive focus from the node, and remove it from the passive |
|
363 * focused node array. |
|
364 * |
|
365 * @since Series 60 3.2 |
|
366 * @param aNode Node to use. |
|
367 */ |
|
368 void RemovePassiveFocusedNodeL( CXnNode* aNode ); |
|
369 |
|
370 /** |
|
371 * Clear the passive focused node array, and unset the passive focus |
|
372 * states. |
|
373 * |
|
374 * @since Series 60 3.2 |
|
375 */ |
|
376 void ClearPassiveFocusedNodesL(); |
|
377 |
|
378 /** |
|
379 * Sets node's dropped state |
|
380 * |
|
381 * @since Series 60 3.2 |
|
382 * @param aNode Node |
|
383 * @param aDropped Dropped |
|
384 */ |
|
385 void SetNodeDroppedL( CXnNode& aNode, TInt aDropped ) const; |
|
386 |
|
387 /** |
|
388 * Checks if node is adaptive, but doesn't have any content |
|
389 * |
|
390 * @since Series 60 3.2 |
|
391 * @param aNode node |
|
392 * @param aAvailableSize size to be checked |
|
393 */ |
|
394 void CheckAdaptiveContentL( CXnNode& aNode, TSize aAvailableSize ) const; |
|
395 |
|
396 /** |
|
397 * Adds a node which can be focused |
|
398 * |
|
399 * @since Series 60 3.2 |
|
400 * @param aNode Node |
|
401 */ |
|
402 void AddFocusCandidateL( CXnNode* aNode ); |
|
403 |
|
404 /** |
|
405 * Sets client rect |
|
406 * |
|
407 * @since Series 60 3.2 |
|
408 * @param aRect area to be set |
|
409 * @param aDrawNow Call rendering routines if ETrue |
|
410 */ |
|
411 void SetClientRectL( TRect aRect, TBool aDrawNow = ETrue ); |
|
412 |
|
413 /** |
|
414 * Fetch editor to operate on AI3 widgets. |
|
415 * |
|
416 * @since Series 60 5.0 |
|
417 * @return Pointer to Editor |
|
418 */ |
|
419 CXnEditor* Editor() const; |
|
420 |
|
421 /** |
|
422 * Gets client rect |
|
423 * |
|
424 * @since Series 60 3.2 |
|
425 * @return client rect |
|
426 */ |
|
427 TRect ClientRect() const; |
|
428 |
|
429 /** |
|
430 * Gets pointer to edit mode storage. |
|
431 * |
|
432 * @since Series 60 5.0 |
|
433 * @return edit mode storage |
|
434 */ |
|
435 CXnEditMode* EditMode(); |
|
436 |
|
437 /** |
|
438 * Get current view plugins nodes. |
|
439 * |
|
440 * @since Series 60 5.0 |
|
441 * @return Pointer to plugin node array |
|
442 */ |
|
443 RPointerArray< CXnNode >* Plugins(); |
|
444 |
|
445 /** |
|
446 * Gets hit test |
|
447 * |
|
448 * @since S60 5.1 |
|
449 * @return the hittest |
|
450 */ |
|
451 CXnHitTest& HitTest() const; |
|
452 |
|
453 /** |
|
454 * Positions stylus popup according given position |
|
455 * |
|
456 * @since S60 5.1 |
|
457 * @param aNode stylus popup node |
|
458 * @param aReference a reference node where popup should fit |
|
459 * @param aPosition stylus popup position to set. |
|
460 */ |
|
461 void PositionStylusPopupL( CXnNode& aNode, CXnNode& aReference, |
|
462 const TPoint& aPosition ); |
|
463 |
|
464 /** |
|
465 * Gets theme resource file |
|
466 * |
|
467 * @since S60 5.1 |
|
468 * @param aPath path from which file is found |
|
469 * @param aFile file to which resource is set |
|
470 * @return errorcode |
|
471 */ |
|
472 TInt GetThemeResource( const TDesC& aPath, RFile& aFile ); |
|
473 |
|
474 /** |
|
475 * Analyse added widget |
|
476 * |
|
477 * @since S60 5.1 |
|
478 * @param aNode Widget to be analyzed |
|
479 * @return ETrue if fits, EFalse otherwise |
|
480 */ |
|
481 TBool AnalyseAddedWidgetL( CXnNode& aNode ); |
|
482 |
|
483 /** |
|
484 * Disables layoyt and redraw, places cleanup item to cleanup stack |
|
485 * for enabling layot and redraw |
|
486 * |
|
487 * @since Series 60 5.0 |
|
488 */ |
|
489 void DisableRenderUiLC(); |
|
490 |
|
491 /** |
|
492 * Set event dispatcher |
|
493 * |
|
494 * @since Series 60 5.0 |
|
495 * @param aDispather Event dispatcher |
|
496 */ |
|
497 void SetEventDispatcher( CXnKeyEventDispatcher* aDispatcher ); |
|
498 |
|
499 private: |
|
500 |
|
501 IMPORT_C static void EnableRenderUi( TAny* aAny ); |
|
502 |
|
503 private: |
|
504 // constructors |
|
505 |
|
506 /** |
|
507 * C++ default constructor. |
|
508 */ |
|
509 CXnUiEngineImpl( CXnUiEngine& aUiEngine, CXnAppUiAdapter& aAdapter ); |
|
510 |
|
511 private: |
|
512 // new functions |
|
513 |
|
514 /** |
|
515 * Prepares to the layout algorithm run |
|
516 * |
|
517 * @since Series 60 3.2 |
|
518 */ |
|
519 void PrepareRunLayoutL(); |
|
520 |
|
521 /** |
|
522 * Runs the layout algorithm |
|
523 * |
|
524 * @since Series 60 3.2 |
|
525 */ |
|
526 TInt RunLayoutL( CXnNode* aNode ); |
|
527 |
|
528 /** |
|
529 * Checks if layout is currently disabled |
|
530 * |
|
531 * @since Series 60 3.2 |
|
532 */ |
|
533 TBool IsLayoutDisabled(); |
|
534 |
|
535 void AddToRedrawListL( CXnNode* aNode, TRect aRect = |
|
536 TRect::EUninitialized ); |
|
537 |
|
538 void AddToDirtyListL( CXnNode* aNode ); |
|
539 |
|
540 /** |
|
541 * Finds a node where to start layout |
|
542 * |
|
543 * @since Series 60 5.0 |
|
544 */ |
|
545 CXnNode* StartLayoutFromL(); |
|
546 |
|
547 void ForceRenderUIL( TBool aLayoutOnly = EFalse ); |
|
548 |
|
549 CCoeControl* WindowOwningControl( CXnNode& aNode ); |
|
550 |
|
551 TXnDirtyRegion* FindDirtyRegionL( CXnNode& aNode ); |
|
552 |
|
553 void AddRedrawRectL( TRect aRect, CXnNode& aNode ); |
|
554 |
|
555 void ReportScreenDeviceChangeL(); |
|
556 |
|
557 private: |
|
558 //Derived functions |
|
559 |
|
560 /** |
|
561 * from MXnViewObserver |
|
562 */ |
|
563 void NotifyViewActivatedL( const CXnViewData& aViewData ); |
|
564 |
|
565 /** |
|
566 * from MXnViewObserver |
|
567 */ |
|
568 void NotifyViewDeactivatedL( const CXnViewData& /*aViewData*/ ); |
|
569 |
|
570 /** |
|
571 * from MXnViewObserver |
|
572 */ |
|
573 void NotifyConfigureWidgetL( const CHsContentInfo& /*aContentInfo*/, |
|
574 CXnPluginData& /*aPluginData*/ ); |
|
575 |
|
576 /** |
|
577 * from MXnViewObserver |
|
578 */ |
|
579 void NotifyWidgetAdditionL( const CXnPluginData& aPluginData ); |
|
580 |
|
581 /** |
|
582 * from MXnViewObserver |
|
583 */ |
|
584 void NotifyWidgetRemovalL( const CXnPluginData& /*aPluginData*/ ); |
|
585 |
|
586 /** |
|
587 * from MXnViewObserver |
|
588 */ |
|
589 void NotifyViewAdditionL( const CXnPluginData& /*aPluginData*/ ){}; |
|
590 |
|
591 /** |
|
592 * from MXnViewObserver |
|
593 */ |
|
594 void NotifyViewRemovalL( const CXnPluginData& /*aPluginData*/ ){}; |
|
595 |
|
596 private: |
|
597 // from MXnMenuObserver |
|
598 |
|
599 TBool DynInitMenuItemL( CXnNodeAppIf& aMenuItem, CXnNodeAppIf* aPlugin = NULL ); |
|
600 |
|
601 private: |
|
602 // from MXnPropertyChangeObserver |
|
603 |
|
604 /** |
|
605 * Property changed |
|
606 * |
|
607 * @since S60 5.1 |
|
608 * @param aKey key value |
|
609 * @param aValue property value |
|
610 */ |
|
611 void PropertyChangedL( const TUint32 aKey, const TInt aValue ); |
|
612 |
|
613 private: |
|
614 // from MXnUiResourceChangeObserver |
|
615 |
|
616 /** |
|
617 * @see MXnUiResourceChangeObserver |
|
618 */ |
|
619 void NotifyStatusPaneSizeChanged(); |
|
620 |
|
621 /** |
|
622 * @see MXnUiResourceChangeObserver |
|
623 */ |
|
624 void NotifyResourceChanged( TInt aType ); |
|
625 |
|
626 private: |
|
627 // Data |
|
628 |
|
629 /** Current screen device, Owned */ |
|
630 CGraphicsDevice* iCurrentGraphicsDevice; |
|
631 /** UI engine - received from constructor's input parameters, Not owned */ |
|
632 CXnUiEngine* iUiEngine; |
|
633 /** AppUi, Not owned */ |
|
634 CXnAppUiAdapter& iAppUiAdapter; |
|
635 /** Not owned. View manager */ |
|
636 CXnViewManager& iViewManager; |
|
637 /** Key event dispatcher, Not owned */ |
|
638 CXnKeyEventDispatcher* iKeyEventDispatcher; |
|
639 /** ControlAdapters, not owned */ |
|
640 const RPointerArray< CXnControlAdapter >* iControlAdapterList; |
|
641 /** Region pending redraw */ |
|
642 RPointerArray<TXnDirtyRegion> iRedrawRegions; |
|
643 /** List of currently dirty nodes */ |
|
644 RPointerArray< CXnNode > iDirtyList; |
|
645 /** Array of nodes which can be focused */ |
|
646 RPointerArray< CXnNode > iFocusCandidateList; |
|
647 /** current view */ |
|
648 CXnNode* iCurrentView; |
|
649 /** current view control adapter, not owned */ |
|
650 CXnControlAdapter* iCurrentViewControlAdapter; |
|
651 /** Controls layouting */ |
|
652 TInt iLayoutControl; |
|
653 /** Layout algo phase */ |
|
654 TInt iLayoutPhase; |
|
655 /** Unit in pixels (width). */ |
|
656 TReal iHorizontalUnitInPixels; |
|
657 /** Unit in pixels (height). */ |
|
658 TReal iVerticalUnitInPixels; |
|
659 /** Cached menu node */ |
|
660 CXnNode* iMenuNode; |
|
661 /** Cached styluspopup node */ |
|
662 CXnNode* iStylusPopupNode; |
|
663 /** Drawing area */ |
|
664 TRect iClientRect; |
|
665 /** Owned. Edit mode storage; */ |
|
666 CXnEditMode* iEditMode; |
|
667 /** Owned. hittest */ |
|
668 CXnHitTest* iHitTest; |
|
669 /** Disable count */ |
|
670 TInt iDisableCount; |
|
671 }; |
|
672 |
|
673 #endif // _CXNUIENGINEIMPL_H |