|
1 /* |
|
2 * Copyright (c) 2003-2004 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 class handles formatting of the boxes , refreshes the boxe on the postformatting, |
|
15 adds the active boxes to the tab list |
|
16 * |
|
17 */ |
|
18 |
|
19 #ifndef BOX_FORMAT_HANDLER_H |
|
20 #define BOX_FORMAT_HANDLER_H |
|
21 |
|
22 #include "e32base.h" |
|
23 #include "CStack.h" |
|
24 #include "nw_gdi_utils.h" |
|
25 #include "BoxFormat.h" |
|
26 |
|
27 // INCLUDES |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // DATA TYPES |
|
34 |
|
35 // FUNCTION PROTOTYPES |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 |
|
39 // CLASS DECLARATION |
|
40 |
|
41 |
|
42 /** |
|
43 * The class handles formatting of the boxes , refreshes the boxe on the postformatting, |
|
44 * adds the active boxes to the tab list |
|
45 * |
|
46 * @lib lmgr.lib |
|
47 */ |
|
48 class CLMgr_BoxFormatHandler: public CActive |
|
49 { |
|
50 public: |
|
51 /** |
|
52 * A two phase constructor that constructs and initializes CLMgr_BoxFormatHandler class |
|
53 * leaves KErrNoMemory if out of memory |
|
54 * @param aRootBox - flowBox to be formatted |
|
55 * @param aSelectiveFormatting is ETrue if only a flowBox and its children needs to be formatted |
|
56 * @return CLMgr_BoxFormatHandler* - pointer to the instance of class CLMgr_BoxFormatHandler |
|
57 */ |
|
58 static CLMgr_BoxFormatHandler* NewL(NW_LMgr_Box_t* aRootBox, |
|
59 TBool aSelectiveFormatting); |
|
60 /** |
|
61 * the method is called from view to format box tree |
|
62 */ |
|
63 void PartialFormatL( CActive::TPriority aPriority ); |
|
64 |
|
65 /** |
|
66 * the method is called from view after the partialFormat is called |
|
67 * for the last chunk |
|
68 */ |
|
69 void PageLoadCompleted(); |
|
70 |
|
71 TBrowserStatusCode Collapse( NW_LMgr_FlowBox_t* aContainingFlow, NW_Bool aCollapseAnonymous ); |
|
72 /** |
|
73 * the method clears the formatting context . |
|
74 * The formatting context includes the formatting stack and the current format box |
|
75 */ |
|
76 void ClearFormattingContext(); |
|
77 |
|
78 /** |
|
79 * initializes the flowbox and its children |
|
80 * @param - flowbox and its children to be initialized |
|
81 * @return - returns KBrsrSuccess if no error |
|
82 */ |
|
83 TBrowserStatusCode InitializeBox(NW_LMgr_BidiFlowBox_t *flow); |
|
84 |
|
85 /** |
|
86 * initializes the flowbox and its children in small screen mode |
|
87 * @param - flowbox and its children to be initialized |
|
88 * @return - returns KBrsrSuccess if no error |
|
89 */ |
|
90 TBrowserStatusCode InitializeBoxSSL(NW_LMgr_BidiFlowBox_t *flow); |
|
91 |
|
92 /** |
|
93 * set the background format flag to true which means that |
|
94 * the next format is a background format |
|
95 */ |
|
96 inline void SetBackgroundFormat() { iBackgroundFormat = ETrue; } |
|
97 |
|
98 /** |
|
99 * This function returns true if the current format is a background format |
|
100 */ |
|
101 inline TBool BackgroundFormat() { return iBackgroundFormat; } |
|
102 |
|
103 /** |
|
104 * Destructor- deletes format stack and |
|
105 * removes the instance from CActiveScheduler |
|
106 */ |
|
107 ~CLMgr_BoxFormatHandler(); |
|
108 |
|
109 /** |
|
110 * |
|
111 * adds the box to the tab list |
|
112 * @param box - the box to be added to the tab list |
|
113 * @return - returns KBrsrOutOfMemory if OOM |
|
114 */ |
|
115 TBrowserStatusCode AddTabItem(NW_LMgr_Box_t *box); |
|
116 |
|
117 /** |
|
118 * |
|
119 * returns last formatted box |
|
120 * @return - last formatted box of the box tree |
|
121 */ |
|
122 NW_LMgr_Box_t* GetLastFormattedBox() |
|
123 { |
|
124 return iFormatBox; |
|
125 } |
|
126 /** |
|
127 * |
|
128 * sets the last box to be formatted from the boxtee |
|
129 * @param aLastBoxToFormat - the last box to be formatted from the boxtee |
|
130 */ |
|
131 void SetLastBoxToFormatL(NW_LMgr_Box_t *aLastBoxToFormat) |
|
132 { |
|
133 iLastBoxToFormat = aLastBoxToFormat; |
|
134 } |
|
135 |
|
136 /** |
|
137 * |
|
138 * overriddes Active virtual function . The method formats a flowbox ( including its children) |
|
139 * or a leaf box |
|
140 * leaves if OOM |
|
141 */ |
|
142 void RunL(); |
|
143 |
|
144 /** |
|
145 * overriddes Active virtual function |
|
146 * Clears the formatting context, if the formatting is cancelled |
|
147 */ |
|
148 void DoCancel(); |
|
149 |
|
150 /** |
|
151 * overriddes Active virtual function |
|
152 * Clears the formatting context, incase if any error |
|
153 */ |
|
154 TInt RunError(TInt aError); |
|
155 |
|
156 /** |
|
157 * sets the root box on the format handler (generally used if the |
|
158 * root box changes, but the format handler is the same) |
|
159 */ |
|
160 void SetRootBox(NW_LMgr_Box_t* aRootBox); |
|
161 TBool GetFormattingComplete(){return iFormattingCompleted;}; |
|
162 |
|
163 private: |
|
164 // auxiallary class to contain ,enable copying and deleting of FormatContexts |
|
165 |
|
166 class CFormatStackContext: public CBase |
|
167 { |
|
168 public: |
|
169 CFormatStackContext(CLMgr_BoxFormatHandler* aBoxFormatHandler); |
|
170 static void CleanupStackContext(TAny* aFormatStackContext); |
|
171 |
|
172 CFormatStackContext(const CFormatStackContext& aFormatStackContext); |
|
173 ~CFormatStackContext(); |
|
174 // formatbox - box to be formatted |
|
175 NW_LMgr_Box_t *iBox; |
|
176 // parent box of iBox |
|
177 NW_LMgr_Box_t *iParentFormatBox; |
|
178 // context to format iBox |
|
179 NW_LMgr_FormatContext_t* iParentContext; |
|
180 // used to calculate rootBox temp height after formatting part of box tree |
|
181 NW_GDI_Dimension2D_t iTempDimensions ; |
|
182 // is ETrue if page load is completed |
|
183 TBool iPageLoadCompleted; |
|
184 // reference to the containing class |
|
185 CLMgr_BoxFormatHandler* iBoxFormatHandler;// has |
|
186 }; |
|
187 private: |
|
188 /** |
|
189 * Constructor |
|
190 **/ |
|
191 CLMgr_BoxFormatHandler(); |
|
192 /** |
|
193 * Initializes CLMgr_BoxFormatHandler , creates stack to handle formatting |
|
194 * and adds the CLMgr_BoxFormatHandler instance to ActiveScheduler |
|
195 * @param aRootBox - flowbox to be formatted |
|
196 * @param aSelectiveFormatting- is ETrue if only aRootBox and its children need |
|
197 to be formatted |
|
198 **/ |
|
199 void ConstructL(NW_LMgr_Box_t* aRootBox, |
|
200 TBool aSelectiveFormatting); |
|
201 |
|
202 /** |
|
203 * Formats iFormatBox (the current box to be formatted ) and all the boxes to |
|
204 * the left subtree iFormatBox |
|
205 * Leaves with KErrNoMemory if OOM |
|
206 **/ |
|
207 void HandlePartialFormatL(); |
|
208 /** |
|
209 * Finds the format context of the next box of aFormatBox to be formatted |
|
210 * If the aFormatBox is NULL , then a new FormatContext is created on rootbox and |
|
211 * the child of the rootbox becomes the next box to be formattec |
|
212 * Leaves with KErrNoMemory if OOM |
|
213 **/ |
|
214 void FindFormatContextL(NW_LMgr_Box_t* aFormatBox); |
|
215 /** |
|
216 * The method is called after the formatting all the chunks and no more |
|
217 * chunks are available for the page. The method does post formatting of all |
|
218 * the boxes on the stack and calls the formatting completed on IBoxTreeListener |
|
219 **/ |
|
220 void HandlePageLoadCompletedL(); |
|
221 /** |
|
222 * The method handles post formatting on a box |
|
223 * @param CFormatStackContext- Formatting context instance to be post formatted |
|
224 **/ |
|
225 void PostFormatL(CFormatStackContext& ); |
|
226 /** |
|
227 * The method clears all the items on the format stack and sets the current box to |
|
228 * formatted to NULL |
|
229 **/ |
|
230 void ClearFormatStack(); |
|
231 /** |
|
232 * The method returns the BoxFormatter instance based on the box type |
|
233 * @param aBox the box to find the formatter . |
|
234 * @return TLMgr_BoxFormatter instance that can handle formatting of aBox |
|
235 **/ |
|
236 TLMgr_BoxFormatter& GetBoxFormatter(NW_LMgr_Box_t* aBox); |
|
237 |
|
238 /** |
|
239 * The method returns the last box of the boxtree |
|
240 * @return the last box of the boxtree |
|
241 **/ |
|
242 |
|
243 NW_LMgr_Box_t* GetLastBox(); |
|
244 |
|
245 /** |
|
246 * The method returns dimensions of aBox by the aBox childrens height and width |
|
247 * @return NW_GDI_Dimension2D_t - dimensions of the aBox |
|
248 **/ |
|
249 NW_GDI_Dimension2D_t CalculateBoxTempBounds(NW_LMgr_Box_t* aBox ); |
|
250 |
|
251 /** |
|
252 * The method normalizes the box on the box tree |
|
253 * @param box - box to be normalized |
|
254 * @return void |
|
255 **/ |
|
256 void InitBoxL(NW_LMgr_Box_t *aBox); |
|
257 |
|
258 /** |
|
259 * The method refreshes the box after the box is post formatted |
|
260 * @return void |
|
261 * @param box - box to be refresed |
|
262 **/ |
|
263 void RefreshBoxL(NW_LMgr_Box_t *aBox ); |
|
264 |
|
265 /** |
|
266 * This method adds the children boxes which are instances of active boxes |
|
267 * to the tab list |
|
268 * @param box - box to be added |
|
269 **/ |
|
270 void AddTabItemL( NW_LMgr_Box_t *aBox ); |
|
271 |
|
272 /** |
|
273 * This method is called from AddTabItemL to add tabitems |
|
274 * containeed in container box subtree |
|
275 **/ |
|
276 void AddSubTreeTabItemsL(NW_LMgr_Box_t *aBox); |
|
277 |
|
278 /** |
|
279 * This method is called from PartialFormatL to initialize the rootbox |
|
280 * It sets the body box and initializes the display bounds |
|
281 **/ |
|
282 void InitRootBox(); |
|
283 |
|
284 /** |
|
285 * This method appends the NW_LMgr_FormatContext_t* object to the array of pointers |
|
286 * iFormatContextRef. |
|
287 **/ |
|
288 void AppendFormatContextL(NW_LMgr_FormatContext_t* aLMgr_FormatContext_t); |
|
289 |
|
290 /** |
|
291 * This method updates the display bounds on a formatted subtree |
|
292 **/ |
|
293 void UpdateDisplayBounds( NW_LMgr_Box_t* aBox ); |
|
294 |
|
295 private: |
|
296 // friends |
|
297 friend class CFormatStackContext; |
|
298 |
|
299 private: |
|
300 // members |
|
301 // formatted flowboxes are added to the stack(iFormatStack) to be postformatted after |
|
302 // formatting the flowboxes children |
|
303 CStack<CFormatStackContext, ETrue>* iFormatStack; |
|
304 // default box formatter |
|
305 TLMgr_BoxFormatter iTLMgr_BoxFormatter; |
|
306 // marquee box formatter |
|
307 TLMgr_Marquee_Box_Formatter iTLMgr_Marquee_Box_Formatter; |
|
308 // Table cell or table row box formatter |
|
309 TLMgr_StaticCell_Box_Formatter iTLMgr_StaticCell_Box_Formatter; |
|
310 |
|
311 // Last box to be formatted from the boxtree |
|
312 NW_LMgr_Box_t *iLastBoxToFormat ; |
|
313 // RootBox reference |
|
314 NW_LMgr_Box_t *iRootBox; |
|
315 |
|
316 // The current flowbox used to format iFormatBox |
|
317 NW_LMgr_Box_t* iCurrentFlowBox ; |
|
318 // The current format context used to format iFormatBox |
|
319 NW_LMgr_FormatContext_t* iCurrentFormatContext; |
|
320 // The box to be formatted |
|
321 NW_LMgr_Box_t* iFormatBox; |
|
322 // is ETrue if the box that is formatted is split |
|
323 TBool iContainerSplit; |
|
324 // is ETrue if part of the tree is to be formatted |
|
325 TBool iSelectiveFormatting; |
|
326 // is ETrue if PartialFormatL method is called for the last chunk |
|
327 TBool iPageLoadCompleted; |
|
328 TBool iFormattingCompleted; |
|
329 CArrayPtrFlat<NW_LMgr_FormatContext_t>* iFormatContextRef; |
|
330 // the following 2 members are used to normalize the boxtree |
|
331 TBool iFirstBr; |
|
332 TBool iSecondBr; |
|
333 TBool iBackgroundFormat; |
|
334 CActive::TPriority iFormattingPriority; |
|
335 }; |
|
336 |
|
337 #endif |