|
1 /* |
|
2 * Copyright (c) 2007-2009 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 manager for MRGUI usage. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "nmrlayoutmanager.h" |
|
19 |
|
20 #include <aknutils.h> |
|
21 #include <aknlayoutscalable_apps.cdl.h> |
|
22 #include <aknlayoutscalable_avkon.cdl.h> |
|
23 |
|
24 |
|
25 using namespace NMRLayoutManager; |
|
26 |
|
27 |
|
28 // Unnamed namespace for local definitions |
|
29 namespace { // codescanner::unnamednamespace |
|
30 |
|
31 // Numerals for layout data usage. |
|
32 const TInt KLayoutValueZero = 0; |
|
33 const TInt KLayoutValueOne = 1; |
|
34 const TInt KLayoutValueTwo = 2; |
|
35 const TInt KLayoutValueThree = 3; |
|
36 const TInt KLayoutValueFour = 4; |
|
37 const TInt KLayoutValueFive = 5; |
|
38 const TInt KLayoutValueSeven = 7; |
|
39 |
|
40 #ifdef _DEBUG |
|
41 _LIT( KNMRLayoutManagerPanicText, "NMRLayoutManager" ); |
|
42 enum TNMRLayoutManagerPanic |
|
43 { |
|
44 ENMRLayoutManagerUnhandledCase = 1, |
|
45 }; |
|
46 void Panic( TNMRLayoutManagerPanic aPanic ) |
|
47 { |
|
48 User::Panic( KNMRLayoutManagerPanicText, aPanic ); |
|
49 } |
|
50 #endif |
|
51 |
|
52 } // Unnamed namespace |
|
53 |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // NMRLayoutManager::GetWindowComponentLayout |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C TAknWindowComponentLayout NMRLayoutManager::GetWindowComponentLayout( TMRLayout aLayout ) |
|
60 { |
|
61 TAknWindowComponentLayout layout; |
|
62 switch ( aLayout ) |
|
63 { |
|
64 case EMRLayoutDialog: |
|
65 { |
|
66 layout = AknLayoutScalable_Apps::main_sp_fs_calendar_pane( KLayoutValueZero ); |
|
67 break; |
|
68 } |
|
69 case EMRLayoutDialogBg: |
|
70 { |
|
71 layout = AknLayoutScalable_Apps::bg_main_sp_fs_cale_pane( KLayoutValueOne ); |
|
72 break; |
|
73 } |
|
74 case EMRLayoutDialogBgGraphics: |
|
75 { |
|
76 layout = AknLayoutScalable_Apps::bgmain_sp_fs_calendar_pane_g1( KLayoutValueZero ); |
|
77 break; |
|
78 } |
|
79 case EMRLayoutCtrlBar: |
|
80 { |
|
81 layout = AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_cp01( KLayoutValueOne ); |
|
82 break; |
|
83 } |
|
84 case EMRLayoutCtrlBarGraphics: |
|
85 { |
|
86 layout = AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_g1( KLayoutValueOne ); |
|
87 break; |
|
88 } |
|
89 case EMRLayoutContentArea: |
|
90 { |
|
91 layout = AknLayoutScalable_Apps::listscroll_cale_mrui_pane( KLayoutValueOne ); |
|
92 break; |
|
93 } |
|
94 case EMRLayoutListArea: |
|
95 { |
|
96 layout = AknLayoutScalable_Apps::list_cale_mrui_pane( KLayoutValueZero ); |
|
97 break; |
|
98 } |
|
99 case EMRLayoutScrollBar: |
|
100 { |
|
101 layout = AknLayoutScalable_Apps::sp_fs_scroll_pane_cp07( KLayoutValueOne ); |
|
102 break; |
|
103 } |
|
104 |
|
105 case EMRLayoutStripe: |
|
106 { |
|
107 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g3( KLayoutValueZero ); |
|
108 break; |
|
109 } |
|
110 case EMRLayoutMRNaviArrowLeft: |
|
111 { |
|
112 layout = AknLayoutScalable_Apps::main_sp_fs_email_pane_g1( KLayoutValueOne ); |
|
113 break; |
|
114 } |
|
115 case EMRLayoutMRNaviArrowRight: |
|
116 { |
|
117 layout = AknLayoutScalable_Apps::main_sp_fs_email_pane_g2( KLayoutValueOne ); |
|
118 break; |
|
119 } |
|
120 case EMRLayoutTextEditorIcon: |
|
121 { |
|
122 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueOne ); |
|
123 break; |
|
124 } |
|
125 case EMRLayoutTextEditorBg: |
|
126 { |
|
127 layout = AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg_cp01( KLayoutValueOne ); |
|
128 break; |
|
129 } |
|
130 case EMRLayoutTimeEditorIcon: |
|
131 { |
|
132 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueTwo ); |
|
133 break; |
|
134 } |
|
135 case EMRLayoutTimeEditorStartBg: |
|
136 { |
|
137 layout = AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg_cp01( KLayoutValueTwo ); |
|
138 break; |
|
139 } |
|
140 case EMRLayoutTimeEditorEndBg: |
|
141 { |
|
142 layout = AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg_cp02( KLayoutValueTwo ); |
|
143 break; |
|
144 } |
|
145 case EMRLayoutDateEditorIcon: |
|
146 { |
|
147 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueThree ); |
|
148 break; |
|
149 } |
|
150 case EMRLayoutDateEditorBg: |
|
151 { |
|
152 layout = AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg_cp01( KLayoutValueThree ); |
|
153 break; |
|
154 } |
|
155 case EMRLayoutCheckboxIcon: |
|
156 { |
|
157 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueFive ); |
|
158 break; |
|
159 } |
|
160 |
|
161 case EMRLayoutSingleRowAColumnGraphic: |
|
162 { |
|
163 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueSeven ); |
|
164 break; |
|
165 } |
|
166 case EMRLayoutSingleRowDColumnGraphic: |
|
167 { |
|
168 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g2( KLayoutValueZero ); |
|
169 break; |
|
170 } |
|
171 case EMRLayoutAttachmentSelectionGrid: |
|
172 { |
|
173 layout = AknLayoutScalable_Avkon::grid_tb_ext_pane( KLayoutValueZero ); |
|
174 break; |
|
175 } |
|
176 case EMRLayoutAttachmentSelectionGridCell: |
|
177 { |
|
178 layout = AknLayoutScalable_Avkon::cell_tb_ext_pane( KLayoutValueZero, 0, 0 ); |
|
179 break; |
|
180 } |
|
181 case EMRLayoutAttachmentSelectionGridCellGraphic: |
|
182 { |
|
183 layout = AknLayoutScalable_Avkon::cell_tb_ext_pane_g1( KLayoutValueTwo ); |
|
184 break; |
|
185 } |
|
186 default: |
|
187 { |
|
188 __ASSERT_DEBUG( EFalse, Panic( ENMRLayoutManagerUnhandledCase ) ); |
|
189 break; |
|
190 } |
|
191 } |
|
192 return layout; |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // NMRLayoutManager::GetTextComponentLayout |
|
197 // --------------------------------------------------------------------------- |
|
198 // |
|
199 EXPORT_C TAknTextComponentLayout NMRLayoutManager::GetTextComponentLayout( TMRTextLayout aLayout ) |
|
200 { |
|
201 TAknTextComponentLayout layout; |
|
202 switch ( aLayout ) |
|
203 { |
|
204 case EMRTextLayoutText: |
|
205 { |
|
206 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t1( KLayoutValueZero ); |
|
207 break; |
|
208 } |
|
209 case EMRTextLayoutTextEditor: |
|
210 { |
|
211 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueOne ); |
|
212 break; |
|
213 } |
|
214 case EMRTextLayoutTimeEditorStart: |
|
215 { |
|
216 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueTwo ); |
|
217 break; |
|
218 } |
|
219 case EMRTextLayoutTimeEditorSeparator: |
|
220 { |
|
221 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t3( KLayoutValueTwo ); |
|
222 break; |
|
223 } |
|
224 case EMRTextLayoutTimeEditorEnd: |
|
225 { |
|
226 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t4( KLayoutValueTwo ); |
|
227 break; |
|
228 } |
|
229 case EMRTextLayoutDateEditor: |
|
230 { |
|
231 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueThree ); |
|
232 break; |
|
233 } |
|
234 case EMRTextLayoutMultiRowTextEditor: |
|
235 { |
|
236 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueFour ); |
|
237 break; |
|
238 } |
|
239 case EMRTextLayoutCheckboxEditor: |
|
240 { |
|
241 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueFive ); |
|
242 break; |
|
243 } |
|
244 case EMRLayoutCtrlBarTitle: |
|
245 { |
|
246 layout = AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_t1( KLayoutValueOne ); |
|
247 break; |
|
248 } |
|
249 |
|
250 case EMRTextLayoutSingleRowEditorText: |
|
251 { |
|
252 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueSeven ); |
|
253 break; |
|
254 } |
|
255 case EMRTextLayoutAttachmentSelectionGridCellText: |
|
256 { |
|
257 layout = AknLayoutScalable_Avkon::cell_tb_ext_pane_t1( KLayoutValueOne ); |
|
258 break; |
|
259 } |
|
260 |
|
261 default: |
|
262 { |
|
263 __ASSERT_DEBUG( EFalse, Panic( ENMRLayoutManagerUnhandledCase ) ); |
|
264 break; |
|
265 } |
|
266 } |
|
267 return layout; |
|
268 } |
|
269 |
|
270 // --------------------------------------------------------------------------- |
|
271 // NMRLayoutManager::GetLayoutRect |
|
272 // --------------------------------------------------------------------------- |
|
273 // |
|
274 EXPORT_C TAknLayoutRect NMRLayoutManager::GetLayoutRect( const TRect& aParentRect, TMRLayout aLayout ) |
|
275 { |
|
276 TAknLayoutRect layoutRect; |
|
277 TAknWindowComponentLayout layout = GetWindowComponentLayout( aLayout ); |
|
278 layoutRect.LayoutRect( aParentRect, layout ); |
|
279 return layoutRect; |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // NMRLayoutManager::GetFieldLayoutRect |
|
284 // --------------------------------------------------------------------------- |
|
285 // |
|
286 EXPORT_C TAknLayoutRect NMRLayoutManager::GetFieldLayoutRect( const TRect& aParentRect, TInt aRows ) |
|
287 { |
|
288 TAknWindowComponentLayout fieldLayout; |
|
289 |
|
290 TAknLayoutScalableParameterLimits limits = |
|
291 AknLayoutScalable_Apps::list_single_cale_mrui_pane_ParamLimits( 0 ); |
|
292 |
|
293 // Map aRows to lower variety limit |
|
294 TInt variety = limits.FirstVariety() + ( aRows - 1 ); |
|
295 // Make sure min <= variety <= max |
|
296 variety = Min( limits.LastVariety(), Max( limits.FirstVariety(), variety ) ); |
|
297 |
|
298 fieldLayout = AknLayoutScalable_Apps::list_single_cale_mrui_pane( variety ); |
|
299 TAknLayoutRect layoutRect; |
|
300 layoutRect.LayoutRect( aParentRect, fieldLayout ); |
|
301 return layoutRect; |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // NMRLayoutManager::GetFieldRowLayoutRect |
|
306 // --------------------------------------------------------------------------- |
|
307 // |
|
308 EXPORT_C TAknLayoutRect NMRLayoutManager::GetFieldRowLayoutRect( const TRect& aParentRect, TInt aRow ) |
|
309 { |
|
310 TAknWindowComponentLayout rowLayout; |
|
311 |
|
312 TAknLayoutScalableParameterLimits limits = |
|
313 AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_ParamLimits( 0 ); |
|
314 |
|
315 // Map aRows to lower variety limit |
|
316 TInt variety = limits.FirstVariety() + ( aRow - 1 ); |
|
317 // Make sure min <= variety <= max |
|
318 variety = Min( limits.LastVariety(), Max( limits.FirstVariety(), variety ) ); |
|
319 |
|
320 rowLayout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane( variety ); |
|
321 TAknLayoutRect layoutRect; |
|
322 layoutRect.LayoutRect( aParentRect, rowLayout ); |
|
323 return layoutRect; |
|
324 } |
|
325 |
|
326 // --------------------------------------------------------------------------- |
|
327 // NMRLayoutManager::GetLayoutText |
|
328 // --------------------------------------------------------------------------- |
|
329 // |
|
330 EXPORT_C TAknLayoutText NMRLayoutManager::GetLayoutText( const TRect& aParentRect, TMRTextLayout aLayout ) |
|
331 { |
|
332 TAknLayoutText layoutText; |
|
333 TAknTextComponentLayout layout = GetTextComponentLayout( aLayout ); |
|
334 layoutText.LayoutText( aParentRect, layout ); |
|
335 return layoutText; |
|
336 } |
|
337 |
|
338 // EOF |