|
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 const TInt KVarietyZero = 0; |
|
32 |
|
33 // Numerals for layout data usage. |
|
34 const TInt KLayoutValueZero = 0; |
|
35 const TInt KLayoutValueOne = 1; |
|
36 const TInt KLayoutValueTwo = 2; |
|
37 const TInt KLayoutValueThree = 3; |
|
38 const TInt KLayoutValueFour = 4; |
|
39 const TInt KLayoutValueFive = 5; |
|
40 |
|
41 #ifdef _DEBUG |
|
42 _LIT( KNMRLayoutManagerPanicText, "NMRLayoutManager" ); |
|
43 enum TNMRLayoutManagerPanic |
|
44 { |
|
45 ENMRLayoutManagerUnhandledCase = 1, |
|
46 }; |
|
47 void Panic( TNMRLayoutManagerPanic aPanic ) |
|
48 { |
|
49 User::Panic( KNMRLayoutManagerPanicText, aPanic ); |
|
50 } |
|
51 #endif |
|
52 |
|
53 } // Unnamed namespace |
|
54 |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // NMRLayoutManager::GetWindowComponentLayout |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 EXPORT_C TAknWindowComponentLayout NMRLayoutManager::GetWindowComponentLayout( TMRLayout aLayout ) |
|
61 { |
|
62 TAknWindowComponentLayout layout; |
|
63 switch ( aLayout ) |
|
64 { |
|
65 case EMRLayoutDialog: |
|
66 { |
|
67 layout = AknLayoutScalable_Apps::main_sp_fs_calendar_pane( KLayoutValueZero ); |
|
68 break; |
|
69 } |
|
70 case EMRLayoutDialogBg: |
|
71 { |
|
72 layout = AknLayoutScalable_Apps::bg_main_sp_fs_cale_pane( KLayoutValueOne ); |
|
73 break; |
|
74 } |
|
75 case EMRLayoutDialogBgGraphics: |
|
76 { |
|
77 layout = AknLayoutScalable_Apps::bgmain_sp_fs_calendar_pane_g1( KLayoutValueZero ); |
|
78 break; |
|
79 } |
|
80 case EMRLayoutCtrlBar: |
|
81 { |
|
82 layout = AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_cp01( KLayoutValueOne ); |
|
83 break; |
|
84 } |
|
85 case EMRLayoutCtrlBarGraphics: |
|
86 { |
|
87 layout = AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_g1( KLayoutValueOne ); |
|
88 break; |
|
89 } |
|
90 case EMRLayoutContentArea: |
|
91 { |
|
92 layout = AknLayoutScalable_Apps::listscroll_cale_mrui_pane( KLayoutValueOne ); |
|
93 break; |
|
94 } |
|
95 case EMRLayoutListArea: |
|
96 { |
|
97 layout = AknLayoutScalable_Avkon::list_gen_pane( KVarietyZero ).LayoutLine(); |
|
98 break; |
|
99 } |
|
100 case EMRLayoutScrollBar: |
|
101 { |
|
102 layout = AknLayoutScalable_Avkon::scroll_pane( KVarietyZero ).LayoutLine(); |
|
103 break; |
|
104 } |
|
105 case EMRLayoutTextEditorIcon: |
|
106 { |
|
107 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueOne ); |
|
108 break; |
|
109 } |
|
110 case EMRLayoutTextEditorBg: |
|
111 { |
|
112 layout = AknLayoutScalable_Apps::bg_main_sp_fs_cale_pane( KLayoutValueOne ); |
|
113 //layout = AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg_cp01( KLayoutValueOne ); |
|
114 break; |
|
115 } |
|
116 case EMRLayoutTimeEditorIcon: |
|
117 { |
|
118 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueTwo ); |
|
119 break; |
|
120 } |
|
121 case EMRLayoutTimeEditorStartBg: |
|
122 { |
|
123 layout = AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg_cp01( KLayoutValueTwo ); |
|
124 break; |
|
125 } |
|
126 case EMRLayoutTimeEditorEndBg: |
|
127 { |
|
128 layout = AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg_cp02( KLayoutValueTwo ); |
|
129 break; |
|
130 } |
|
131 case EMRLayoutDateEditorIcon: |
|
132 { |
|
133 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueThree ); |
|
134 break; |
|
135 } |
|
136 case EMRLayoutDateEditorBg: |
|
137 { |
|
138 layout = AknLayoutScalable_Apps::list_single_cmail_header_editor_pane_bg_cp01( KLayoutValueThree ); |
|
139 break; |
|
140 } |
|
141 case EMRLayoutCheckboxIcon: |
|
142 { |
|
143 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_g1( KLayoutValueFive ); |
|
144 break; |
|
145 } |
|
146 default: |
|
147 { |
|
148 __ASSERT_DEBUG( EFalse, Panic( ENMRLayoutManagerUnhandledCase ) ); |
|
149 break; |
|
150 } |
|
151 } |
|
152 return layout; |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // NMRLayoutManager::GetTextComponentLayout |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 EXPORT_C TAknTextComponentLayout NMRLayoutManager::GetTextComponentLayout( TMRTextLayout aLayout ) |
|
160 { |
|
161 TAknTextComponentLayout layout; |
|
162 switch ( aLayout ) |
|
163 { |
|
164 case EMRTextLayoutText: |
|
165 { |
|
166 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t1( KLayoutValueZero ); |
|
167 break; |
|
168 } |
|
169 case EMRTextLayoutTextEditor: |
|
170 { |
|
171 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueOne ); |
|
172 break; |
|
173 } |
|
174 case EMRTextLayoutTimeEditorStart: |
|
175 { |
|
176 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueTwo ); |
|
177 break; |
|
178 } |
|
179 case EMRTextLayoutTimeEditorSeparator: |
|
180 { |
|
181 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t3( KLayoutValueTwo ); |
|
182 break; |
|
183 } |
|
184 case EMRTextLayoutTimeEditorEnd: |
|
185 { |
|
186 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t4( KLayoutValueTwo ); |
|
187 break; |
|
188 } |
|
189 case EMRTextLayoutDateEditor: |
|
190 { |
|
191 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueThree ); |
|
192 break; |
|
193 } |
|
194 case EMRTextLayoutMultiRowTextEditor: |
|
195 { |
|
196 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueFour ); |
|
197 break; |
|
198 } |
|
199 case EMRTextLayoutCheckboxEditor: |
|
200 { |
|
201 layout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_t2( KLayoutValueFive ); |
|
202 break; |
|
203 } |
|
204 case EMRLayoutCtrlBarTitle: |
|
205 { |
|
206 layout = AknLayoutScalable_Apps::main_sp_fs_ctrlbar_pane_t1( KLayoutValueZero ); |
|
207 break; |
|
208 } |
|
209 default: |
|
210 { |
|
211 __ASSERT_DEBUG( EFalse, Panic( ENMRLayoutManagerUnhandledCase ) ); |
|
212 break; |
|
213 } |
|
214 } |
|
215 return layout; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // NMRLayoutManager::GetLayoutRect |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 EXPORT_C TAknLayoutRect NMRLayoutManager::GetLayoutRect( const TRect& aParentRect, TMRLayout aLayout ) |
|
223 { |
|
224 TAknLayoutRect layoutRect; |
|
225 TAknWindowComponentLayout layout = GetWindowComponentLayout( aLayout ); |
|
226 layoutRect.LayoutRect( aParentRect, layout ); |
|
227 return layoutRect; |
|
228 } |
|
229 |
|
230 // --------------------------------------------------------------------------- |
|
231 // NMRLayoutManager::GetFieldLayoutRect |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 EXPORT_C TAknLayoutRect NMRLayoutManager::GetFieldLayoutRect( const TRect& aParentRect, TInt aRows ) |
|
235 { |
|
236 TAknWindowComponentLayout fieldLayout; |
|
237 |
|
238 TAknLayoutScalableParameterLimits limits = |
|
239 AknLayoutScalable_Apps::list_single_cale_mrui_pane_ParamLimits( 0 ); |
|
240 |
|
241 // Map aRows to lower variety limit |
|
242 TInt variety = limits.FirstVariety() + ( aRows - 1 ); |
|
243 // Make sure min <= variety <= max |
|
244 variety = Min( limits.LastVariety(), Max( limits.FirstVariety(), variety ) ); |
|
245 |
|
246 fieldLayout = AknLayoutScalable_Apps::list_single_cale_mrui_pane( variety ); |
|
247 TAknLayoutRect layoutRect; |
|
248 layoutRect.LayoutRect( aParentRect, fieldLayout ); |
|
249 return layoutRect; |
|
250 } |
|
251 |
|
252 // --------------------------------------------------------------------------- |
|
253 // NMRLayoutManager::GetFieldRowLayoutRect |
|
254 // --------------------------------------------------------------------------- |
|
255 // |
|
256 EXPORT_C TAknLayoutRect NMRLayoutManager::GetFieldRowLayoutRect( const TRect& aParentRect, TInt aRow ) |
|
257 { |
|
258 TAknWindowComponentLayout rowLayout; |
|
259 |
|
260 TAknLayoutScalableParameterLimits limits = |
|
261 AknLayoutScalable_Apps::list_single_cale_mrui_row_pane_ParamLimits( 0 ); |
|
262 |
|
263 // Map aRows to lower variety limit |
|
264 TInt variety = limits.FirstVariety() + ( aRow - 1 ); |
|
265 // Make sure min <= variety <= max |
|
266 variety = Min( limits.LastVariety(), Max( limits.FirstVariety(), variety ) ); |
|
267 |
|
268 rowLayout = AknLayoutScalable_Apps::list_single_cale_mrui_row_pane( variety ); |
|
269 TAknLayoutRect layoutRect; |
|
270 layoutRect.LayoutRect( aParentRect, rowLayout ); |
|
271 return layoutRect; |
|
272 } |
|
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // NMRLayoutManager::GetLayoutText |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 EXPORT_C TAknLayoutText NMRLayoutManager::GetLayoutText( const TRect& aParentRect, TMRTextLayout aLayout ) |
|
279 { |
|
280 TAknLayoutText layoutText; |
|
281 TAknTextComponentLayout layout = GetTextComponentLayout( aLayout ); |
|
282 layoutText.LayoutText( aParentRect, layout ); |
|
283 return layoutText; |
|
284 } |
|
285 |
|
286 // EOF |