|
1 /* |
|
2 * Copyright (c) 2007 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: Viewport visual. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_HUIVIEWPORTLAYOUT_H |
|
21 #define C_HUIVIEWPORTLAYOUT_H |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <uiacceltk/HuiLayout.h> |
|
25 |
|
26 /* Forward declarations */ |
|
27 class CHuiEnv; |
|
28 |
|
29 |
|
30 /** |
|
31 * A CHuiViewportLayout is similar to a CHuiDeckLayout, but it can contain |
|
32 * visuals larger than itself. The larger visuals can be scrolled around. |
|
33 * |
|
34 * The viewport visual can be thought of as providing a "window" onto a larger visual. |
|
35 * Different parts of the visual can be viewed by moving the viewport. By default, the |
|
36 * clipping region is enabled. |
|
37 * |
|
38 * To use the viewport visual, you first need to call SetVirtualSize() to define the |
|
39 * coordinate system for the visual. You pass in the work area of the visual, in whatever |
|
40 * units you choose. For example, if you set the virtual work area size to (1.0, 1.0), it |
|
41 * will use a normalised (u, v) coordinate mapping system. |
|
42 * |
|
43 * Next, you can set the dimensions and position of the viewport (or "window") using SetViewportSize() |
|
44 * and SetViewportPos(). This viewport can be moved around the virtual work area. The contents of the |
|
45 * viewport will be fitted to the ViewportVisual. |
|
46 * |
|
47 * Possible uses for CHuiViewportVisual are for text marquee scrolling effects and photo zooming. |
|
48 * |
|
49 * @todo - insert diagram here. |
|
50 * @see CHuiDeckLayout |
|
51 * |
|
52 */ |
|
53 |
|
54 NONSHARABLE_CLASS(CHuiViewportLayout) : public CHuiLayout |
|
55 { |
|
56 public: |
|
57 |
|
58 /** @beginAPI */ |
|
59 |
|
60 // Bitfield of binary flags. |
|
61 enum TFlags |
|
62 { |
|
63 /** Wrap contents of visual horizontally. */ |
|
64 EWrapHorizontal = 0x0001, |
|
65 |
|
66 /** Wrap contents of visual vertically. */ |
|
67 EWrapVertical = 0x0002 |
|
68 }; |
|
69 |
|
70 /* Constructors and destructor. */ |
|
71 |
|
72 /** |
|
73 * Construct a new viewport layout and give its ownership to a control. |
|
74 * |
|
75 * @param aOwnerControl Owner control. |
|
76 * @param aParentLayout Parent layout for the new deck layout. |
|
77 */ |
|
78 IMPORT_C static CHuiViewportLayout* AddNewL(CHuiControl& aOwnerControl, |
|
79 CHuiLayout* aParentLayout = 0); |
|
80 |
|
81 /** @endAPI */ |
|
82 |
|
83 public: |
|
84 |
|
85 /** |
|
86 * Constructor. |
|
87 * |
|
88 * @param aOwner Owner control. |
|
89 */ |
|
90 CHuiViewportLayout(MHuiVisualOwner& aOwner); // Made public for unit tests. |
|
91 |
|
92 void ConstructL(); // Made public for unit tests. |
|
93 |
|
94 ~CHuiViewportLayout(); // Made public for unit tests. |
|
95 |
|
96 public: |
|
97 |
|
98 /** @beginAPI */ |
|
99 |
|
100 /* Methods. */ |
|
101 |
|
102 /** |
|
103 * Set virtual size of the viewable area. |
|
104 * |
|
105 * This is different from the physical size of the viewport - |
|
106 * it defines the coordinate space that is used for scrolling. |
|
107 * To use a normalised (u, v) coordinate mapping system, set aSize to (,1.0, 1.0). |
|
108 * |
|
109 * @param aSize The bottom-right corner of the child visual, in the units you wish to use for positioning the viewport. |
|
110 * @param aTransitionTime The time it will take to complete the resizing of the virtual size. |
|
111 */ |
|
112 IMPORT_C void SetVirtualSize(const THuiRealSize& aSize, TInt aTransitionTime=0); |
|
113 |
|
114 /** |
|
115 * Set size of the viewport area. |
|
116 * |
|
117 * This is the size of the "window" we are using to look at the visual. |
|
118 * |
|
119 * @param aSize The size of the viewport in the units defined by SetVirtualSize(). |
|
120 * @param aTransitionTime The time it will take to complete the resizing of the viewport area. |
|
121 * @see SetVirtualSize, SetViewportPos |
|
122 */ |
|
123 IMPORT_C void SetViewportSize(const THuiRealSize& aSize, TInt aTransitionTime=0); |
|
124 |
|
125 /** |
|
126 * Set position of the viewport area. |
|
127 * |
|
128 * This is the offset of the "window" we are using to look at the visual. |
|
129 * |
|
130 * @param aSize The size of the viewport in the units defined by SetVirtualSize(). |
|
131 * @param aTransitionTime The time it will take to complete moving the viewport area. |
|
132 * @see SetVirtualSize, SetViewportSize |
|
133 */ |
|
134 IMPORT_C void SetViewportPos(const THuiRealPoint& aSize, TInt aTransitionTime=0); |
|
135 |
|
136 /** @endAPI */ |
|
137 |
|
138 /** |
|
139 * Overridden version of size changing updates the layout of child visuals. |
|
140 * |
|
141 * @param aSize New size for the layout. |
|
142 * @param aTransitionTime Time for the transition to new size to take |
|
143 * place. |
|
144 */ |
|
145 void SetSize(const THuiRealSize& aSize, TInt aTransitionTime=0); |
|
146 |
|
147 TBool ChildSize(TInt aOrdinal, TSize& aSize); |
|
148 |
|
149 TBool ChildPos(TInt aOrdinal, TPoint& aPos); |
|
150 |
|
151 TInt ChildRect(TInt aOrdinal, THuiRealRect& aRect); |
|
152 |
|
153 void GetClassName(TDes& aName) const |
|
154 { |
|
155 aName = _L("CViewportLayout"); |
|
156 } |
|
157 |
|
158 private: |
|
159 |
|
160 /** The bottom-right corner of the child visual, in the units defined by SetVirtualSize. */ |
|
161 THuiRealSize iVirtualSize; |
|
162 |
|
163 /** The top-left corner of the viewport window, relative to te position defined by iVirtualSize. */ |
|
164 THuiRealPoint iViewportPos; |
|
165 |
|
166 /** The size of the viewport window, relative to te position defined by iVirtualSize. */ |
|
167 THuiRealSize iViewportSize; |
|
168 |
|
169 /** Bitfield of flags to change the way the vieport is rendered. */ |
|
170 TInt iWrappingFlags; |
|
171 |
|
172 }; |
|
173 |
|
174 #endif // C_HUIVIEWPORTLAYOUT_H |