|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * This file contains the implementation of the view and component |
|
16 * of the picture grid component, as specified in the application LAF. |
|
17 * |
|
18 * |
|
19 */ |
|
20 |
|
21 #include "AknGMSStyleGrid.h" |
|
22 #include <barsread.h> |
|
23 #include <aknlists.h> |
|
24 #include <gulicon.h> // gul icons |
|
25 #include <aknpopuplayout.h> |
|
26 #include <aknPopupHeadingPane.h> |
|
27 |
|
28 #include <applayout.cdl.h> |
|
29 #include <aknlayoutscalable_apps.cdl.h> |
|
30 |
|
31 using namespace AppLayout; |
|
32 |
|
33 |
|
34 // ---------------------------------------------------------------------------- |
|
35 EXPORT_C CAknGMSStyleGridView::CAknGMSStyleGridView() |
|
36 { |
|
37 } |
|
38 |
|
39 // ---------------------------------------------------------------------------- |
|
40 EXPORT_C void CAknGMSStyleGridView::Draw(const TRect* aClipRect/* = NULL*/) const |
|
41 { |
|
42 CAknGridView::Draw(aClipRect); |
|
43 |
|
44 TInt horLines = MaxNumOfHorLines(); |
|
45 TInt verLines = MaxNumOfVerLines(); |
|
46 |
|
47 if ( iModel->NumberOfItems() > 0 ) |
|
48 { |
|
49 for( TInt i1=0 ; i1<horLines ; i1++ ) |
|
50 { |
|
51 iHorLine[i1].DrawRect(*iGc); |
|
52 } |
|
53 for( TInt i2=0 ; i2<verLines ; i2++ ) |
|
54 { |
|
55 iVerLine[i2].DrawRect(*iGc); |
|
56 } |
|
57 } |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 EXPORT_C void CAknGMSStyleGridView::SetupLayout(const TRect& aRect, TBool aIsPopup /*=EFalse */, TInt aNum /*=-1*/) |
|
62 { |
|
63 iRect = &aRect; |
|
64 TInt horLines = MaxNumOfHorLines(); |
|
65 TInt verLines = MaxNumOfVerLines(); |
|
66 |
|
67 if (aIsPopup) |
|
68 { |
|
69 for(TInt i1=0 ; i1<horLines ; i1++) |
|
70 { |
|
71 iHorLine[i1].LayoutRect(aRect, |
|
72 Graphical_message_image_selection_pop_up_window_elements_Line_1(i1)); |
|
73 } |
|
74 |
|
75 // aNum must be 1..4 |
|
76 for(TInt i2=0 ; i2<verLines ; i2++) |
|
77 { |
|
78 iVerLine[i2].LayoutRect(aRect, |
|
79 Graphical_message_image_selection_pop_up_window_elements_Line_2(i2, aNum-1)); |
|
80 } |
|
81 } |
|
82 else |
|
83 { |
|
84 for (TInt i1=0 ; i1<horLines ; i1++) |
|
85 { |
|
86 iHorLine[i1].LayoutRect(aRect, Graphical_message_selection_layout_elements_Line_1(i1)); |
|
87 } |
|
88 for (TInt i2=0 ; i2<verLines ; i2++) |
|
89 { |
|
90 iVerLine[i2].LayoutRect(aRect, Graphical_message_selection_layout_elements_Line_2(i2)); |
|
91 } |
|
92 } |
|
93 } |
|
94 |
|
95 EXPORT_C TAny* CAknGMSStyleGridView::Reserved_1() |
|
96 { |
|
97 return NULL; |
|
98 } |
|
99 |
|
100 TInt CAknGMSStyleGridView::MaxNumOfHorLines() const |
|
101 { |
|
102 //TODO: calculate maximum number of horizontal lines in GMS grid |
|
103 return 5; |
|
104 } |
|
105 |
|
106 TInt CAknGMSStyleGridView::MaxNumOfVerLines() const |
|
107 { |
|
108 //TODO: calculate maximum number of vertical lines in GMS grid |
|
109 return 3; |
|
110 } |
|
111 |
|
112 // ============================================================================ |
|
113 // CAknGMSStyleGrid |
|
114 // ============================================================================ |
|
115 |
|
116 // ---------------------------------------------------------------------------- |
|
117 EXPORT_C CAknGMSStyleGrid::CAknGMSStyleGrid() |
|
118 : AKNGRID(), iIsPopup(EFalse) |
|
119 { |
|
120 |
|
121 } |
|
122 |
|
123 EXPORT_C CAknGMSStyleGrid::CAknGMSStyleGrid(TBool aIsPopup) |
|
124 : AKNGRID(), iIsPopup(aIsPopup) |
|
125 { |
|
126 |
|
127 } |
|
128 |
|
129 |
|
130 |
|
131 EXPORT_C CAknGMSStyleGrid::~CAknGMSStyleGrid() |
|
132 { |
|
133 } |
|
134 |
|
135 TSize CAknGMSStyleGrid::KCELL_SIZE() |
|
136 { |
|
137 //return TSize(72,28); |
|
138 return TSize(0,0); // this is not used anywhere, afaik |
|
139 } |
|
140 |
|
141 // ---------------------------------------------------------------------------- |
|
142 EXPORT_C void CAknGMSStyleGrid::ConstructL(const CCoeControl* aParent, |
|
143 TInt aRows /*=4*/, TInt aCols/*=2*/) |
|
144 { |
|
145 AKNGRID::ConstructL(aParent, EAknListBoxMarkableList); |
|
146 TAknLayoutRect r; |
|
147 r.LayoutRect(Rect(), cell_gms_pane(0,0)); |
|
148 |
|
149 TInt cellWidth = r.Rect().Width(); // was 80 |
|
150 TInt cellHeight = r.Rect().Height(); // was 34 |
|
151 |
|
152 SetLayoutL(EFalse, ETrue, ETrue, aCols, aRows, TSize(cellWidth,cellHeight), 1, 1); |
|
153 SetPrimaryScrollingType(CAknGridView::EScrollFollowsItemsAndLoops); |
|
154 SetSecondaryScrollingType(CAknGridView::EScrollIncrementLineAndLoops); |
|
155 |
|
156 ActivateL(); |
|
157 } |
|
158 |
|
159 // ---------------------------------------------------------------------------- |
|
160 EXPORT_C CAknGMSStyleGrid* CAknGMSStyleGrid::NewL( |
|
161 const CCoeControl* aParent, TBool aIsPopup) |
|
162 { |
|
163 CAknGMSStyleGrid* self = new (ELeave) CAknGMSStyleGrid(aIsPopup); |
|
164 CleanupStack::PushL(self); |
|
165 self->ConstructL(aParent); |
|
166 CleanupStack::Pop(); // self |
|
167 return self; |
|
168 } |
|
169 |
|
170 // ---------------------------------------------------------------------------- |
|
171 void CAknGMSStyleGrid::_LOG(const TDesC& /*aText*/) |
|
172 { |
|
173 } |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 EXPORT_C void CAknGMSStyleGrid::SetupLayout() |
|
177 { |
|
178 STATIC_CAST(CAknGMSStyleGridView*, View())->SetupLayout(Rect()); |
|
179 } |
|
180 |
|
181 EXPORT_C TSize CAknGMSStyleGrid::MinimumSize() |
|
182 { |
|
183 TAknLayoutRect r; |
|
184 if ( iIsPopup ) |
|
185 { |
|
186 r.LayoutRect( Rect(), grid_large_graphic_popup_pane(0) ); |
|
187 } |
|
188 else |
|
189 { |
|
190 r.LayoutRect( Rect(), grid_gms_pane() ); |
|
191 } |
|
192 |
|
193 return TSize( r.Rect().Width(), r.Rect().Height() ); |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 EXPORT_C void CAknGMSStyleGrid::SizeChanged() |
|
198 { |
|
199 // call the super method |
|
200 AKNGRID::SizeChanged(); |
|
201 |
|
202 TAknLayoutRect r; |
|
203 TInt cellWidth; |
|
204 TInt cellHeight; |
|
205 TInt ml(0), mt(0), mW(0)/*, mH(0)*/; // for marked item indication in grid cell |
|
206 |
|
207 if (iIsPopup) |
|
208 { |
|
209 r.LayoutRect( Rect(), cell_large_graphic_popup_pane(0, 0) ); |
|
210 cellWidth = r.Rect().Width(); |
|
211 cellHeight = r.Rect().Height(); |
|
212 TPoint pTl(0,0); |
|
213 TPoint pBr(cellWidth,cellHeight); |
|
214 AknListBoxLayouts::SetupGridFormGfxCell( //place an graphics to cell |
|
215 *this, // whic grid |
|
216 ItemDrawer(), // which itemdrawer is responsible for drawing |
|
217 0, // cell index (also from item string) |
|
218 Cell_pane_elements__popup_large_graphic_gms__Line_1(), |
|
219 pTl, pBr); |
|
220 } |
|
221 else |
|
222 { |
|
223 r.LayoutRect( Rect(), cell_gms_pane(0, 0) ); |
|
224 cellWidth = r.Rect().Width(); |
|
225 cellHeight = r.Rect().Height(); |
|
226 |
|
227 TAknLayoutRect mr; |
|
228 mr.LayoutRect( Rect(), Graphical_message_cell_elements_Line_2() ); |
|
229 ml = mr.Rect().iTl.iX; |
|
230 mt = mr.Rect().iTl.iY; |
|
231 mW = mr.Rect().Width(); |
|
232 // mH = mr.Rect().Height(); |
|
233 |
|
234 TPoint pTl(0,0); |
|
235 TPoint pBr(cellWidth,cellHeight); |
|
236 AknListBoxLayouts::SetupGridFormGfxCell( //place an graphics to cell |
|
237 *this, // which grid |
|
238 ItemDrawer(), // which itemdrawer is responsible for drawing |
|
239 0, // cell index (also from item string) |
|
240 Graphical_message_cell_elements_Line_1(), |
|
241 pTl, pBr); |
|
242 |
|
243 } |
|
244 |
|
245 AknListBoxLayouts::SetupStandardGrid(*this); |
|
246 AknListBoxLayouts::SetupGridPos(*this, 0, 0, -1, -1, cellWidth, cellHeight); |
|
247 |
|
248 if (!iIsPopup) |
|
249 { |
|
250 TRAP_IGNORE( |
|
251 { |
|
252 ItemDrawer()->FormattedCellData()->SetTransparentSubCellL(1, ETrue); |
|
253 ItemDrawer()->FormattedCellData()->SetNotAlwaysDrawnSubCellL(1, ETrue); |
|
254 }); |
|
255 |
|
256 ItemDrawer()->SetItemMarkPosition(1); |
|
257 _LIT(KZero,"0"); |
|
258 ItemDrawer()->SetItemMarkReplacement(KZero); |
|
259 ItemDrawer()->SetItemMarkReverse(ETrue); |
|
260 TPoint pTl(ml,mt); |
|
261 TPoint pBr(ml+mW,mt+mW); |
|
262 AknListBoxLayouts::SetupGridFormGfxCell( |
|
263 *this, |
|
264 ItemDrawer(), |
|
265 1, |
|
266 Graphical_message_cell_elements_Line_2(), |
|
267 pTl, pBr); |
|
268 } |
|
269 |
|
270 } |
|
271 |
|
272 // ---------------------------------------------------------------------------- |
|
273 EXPORT_C void CAknGMSStyleGrid::Draw(const TRect& aRect) const |
|
274 { |
|
275 AKNGRID::Draw(aRect); |
|
276 } |
|
277 |
|
278 // ---------------------------------------------------------------------------- |
|
279 EXPORT_C CListBoxView* CAknGMSStyleGrid::MakeViewClassInstanceL() |
|
280 { |
|
281 CListBoxView* view = new (ELeave) CAknGMSStyleGridView(); |
|
282 return view; |
|
283 } |
|
284 |
|
285 // ---------------------------------------------------------------------------- |
|
286 EXPORT_C void CAknGMSStyleGrid::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
287 { |
|
288 CAknSelectionGridTypedef::HandlePointerEventL(aPointerEvent); |
|
289 } |
|
290 |
|
291 EXPORT_C void* CAknGMSStyleGrid::ExtensionInterface( TUid /*aInterface*/ ) |
|
292 { |
|
293 return NULL; |
|
294 } |
|
295 |
|
296 // ---------------------------------------------------------------------------- |
|
297 EXPORT_C TKeyResponse CAknGMSStyleGrid::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
298 TEventCode aType) |
|
299 { |
|
300 return AKNGRID::OfferKeyEventL(aKeyEvent, aType); |
|
301 } |
|
302 |
|
303 // ---------------------------------------------------------------------------- |
|
304 |
|
305 EXPORT_C void CAknGMSPopupGrid::CalcPopupGridLargeGraphicWindow(TAknPopupWindowLayoutDef &aDef, TRect aRect, TInt num) |
|
306 { |
|
307 // Find window layout variaties based on CBA location |
|
308 TInt variety = 0; |
|
309 AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); |
|
310 if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight) |
|
311 { // Variety numbers for right CBA are 4-7 |
|
312 variety = num-1+4; |
|
313 } |
|
314 else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft) |
|
315 { // Variety numbers for right CBA are 8-11 |
|
316 variety = num-1+8; |
|
317 } |
|
318 else // bottom |
|
319 { |
|
320 variety = num-1; |
|
321 } |
|
322 TAknLayoutRect popup_menu_window; |
|
323 //popup_menu_window.LayoutRect(aRect, 0, ELayoutEmpty,ELayoutEmpty,0,0,176,77+(114-77)*(num-1)); |
|
324 popup_menu_window.LayoutRect(aRect, AknLayoutScalable_Apps::popup_grid_large_graphic_window(variety)); |
|
325 aDef.iWindowRect = popup_menu_window.Rect(); |
|
326 aDef.iPopupMenuWindowOffset=TPoint(0,0); |
|
327 } |
|
328 |
|
329 EXPORT_C void CAknGMSPopupGrid::PopupGridLargeGraphicGraphics(TAknPopupWindowLayoutDef &aDef) |
|
330 { |
|
331 TRect window_rect = AknPopupLayouts::MenuRect(aDef); |
|
332 |
|
333 aDef.iCover.LayoutRect( window_rect, Graphical_message_image_selection_pop_up_window_graphics_Line_1(window_rect)); |
|
334 aDef.iSecond.LayoutRect( window_rect, Graphical_message_image_selection_pop_up_window_graphics_Line_2(window_rect)); |
|
335 aDef.iFirst.LayoutRect( window_rect, Graphical_message_image_selection_pop_up_window_graphics_Line_3(window_rect)); |
|
336 aDef.iOutline.LayoutRect(window_rect, Graphical_message_image_selection_pop_up_window_graphics_Line_4(window_rect)); |
|
337 aDef.iInside.LayoutRect( window_rect, Graphical_message_image_selection_pop_up_window_graphics_Line_5(window_rect)); |
|
338 } |
|
339 |
|
340 EXPORT_C void CAknGMSPopupGrid::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
341 { |
|
342 CAknPopupList::HandlePointerEventL(aPointerEvent); |
|
343 } |
|
344 |
|
345 EXPORT_C void* CAknGMSPopupGrid::ExtensionInterface( TUid /*aInterface*/ ) |
|
346 { |
|
347 return NULL; |
|
348 } |
|
349 |
|
350 EXPORT_C void CAknGMSPopupGrid::SetupPopupGridLargeGraphicWindow(TAknPopupWindowLayoutDef &aDef, |
|
351 TInt aNum, |
|
352 TBool /*aHeading*/) |
|
353 { |
|
354 AknPopupLayouts::SetupDefaults(aDef); |
|
355 TRect window_rect = AknPopupLayouts::MenuRect(aDef); |
|
356 aDef.iListRect.LayoutRect(window_rect, grid_large_graphic_popup_pane(aNum-1)); |
|
357 |
|
358 // combine list heading pane layouts for GMS grid |
|
359 TAknLayoutRect grid; |
|
360 TAknLayoutRect head; |
|
361 |
|
362 grid.LayoutRect(window_rect, Graphical_message_image_selection_pop_up_window_descendants_Line_1()); |
|
363 head.LayoutRect(window_rect, AKN_LAYOUT_WINDOW_Pop_up_window_list_pane_descendants_Line_8); |
|
364 |
|
365 //aDef.iHeadingRect.LayoutRect(window_rect, 0, 3,6, ELayoutEmpty, ELayoutEmpty, 168, 23); |
|
366 aDef.iHeadingRect.LayoutRect( window_rect, |
|
367 0, // can not really set here, so drawing should set color |
|
368 head.Rect().iTl.iX, |
|
369 head.Rect().iTl.iY, ELayoutEmpty, ELayoutEmpty, |
|
370 grid.Rect().Width(), |
|
371 grid.Rect().Height() ); |
|
372 |
|
373 PopupGridLargeGraphicGraphics(aDef); |
|
374 } |
|
375 |
|
376 |
|
377 |
|
378 EXPORT_C void CAknGMSPopupGrid::SetupWindowLayout(AknPopupLayouts::TAknPopupLayouts) |
|
379 { |
|
380 TAknPopupWindowLayoutDef &aDef = Layout(); |
|
381 CAknPopupHeadingPane *aHeading = iTitle; |
|
382 CEikListBox *aListBox = ListBox(); |
|
383 CCoeControl *aWindowOwningControl = this; |
|
384 |
|
385 CAknGMSStyleGrid *grid = (CAknGMSStyleGrid*)aListBox; |
|
386 |
|
387 if ( aHeading ) |
|
388 { |
|
389 aHeading->SetLayout( CAknPopupHeadingPane::EListHeadingPane ); |
|
390 } |
|
391 |
|
392 TInt numOfRows; |
|
393 |
|
394 switch( aListBox->Model()->NumberOfItems() ) |
|
395 { |
|
396 case 1: |
|
397 case 2: |
|
398 numOfRows = 1; |
|
399 break; |
|
400 case 3: |
|
401 case 4: |
|
402 numOfRows = 2; |
|
403 break; |
|
404 case 5: |
|
405 case 6: |
|
406 numOfRows = 3; |
|
407 break; |
|
408 default: |
|
409 numOfRows = 4; |
|
410 break; |
|
411 } |
|
412 |
|
413 TRect mainPane; |
|
414 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
415 |
|
416 // Find window layout variaties based on CBA location |
|
417 TInt variety = 0; |
|
418 AknLayoutUtils::TAknCbaLocation cbaLocation = AknLayoutUtils::CbaLocation(); |
|
419 if (cbaLocation == AknLayoutUtils::EAknCbaLocationRight) |
|
420 { // Variety numbers for right CBA are 4-7 |
|
421 variety = 3+4; |
|
422 } |
|
423 else if (cbaLocation == AknLayoutUtils::EAknCbaLocationLeft) |
|
424 { // Variety numbers for right CBA are 8-11 |
|
425 variety = 3+8; |
|
426 } |
|
427 else // bottom |
|
428 { |
|
429 variety = 3; // why this is 3? |
|
430 } |
|
431 |
|
432 TAknLayoutRect r; |
|
433 r.LayoutRect( mainPane, AknLayoutScalable_Apps::popup_grid_large_graphic_window(variety) ); |
|
434 |
|
435 TRect clientRect = r.Rect(); |
|
436 |
|
437 TInt minRows = 1; |
|
438 TInt maxRows = 3; |
|
439 AknPopupLayouts::CheckRange(numOfRows, minRows,maxRows); |
|
440 CalcPopupGridLargeGraphicWindow(aDef, clientRect, numOfRows); |
|
441 |
|
442 SetupPopupGridLargeGraphicWindow(aDef, numOfRows, aHeading != 0); |
|
443 |
|
444 aWindowOwningControl->SetRect(AknPopupLayouts::WindowRect(aDef)); |
|
445 AknPopupLayouts::HandleSizeAndPositionOfComponents(aDef, aListBox, aHeading); |
|
446 |
|
447 ((CAknGMSStyleGridView*)grid->View())->SetupLayout( |
|
448 AknPopupLayouts::MenuRect( aDef ), ETrue, numOfRows ); |
|
449 } |
|
450 |
|
451 |
|
452 EXPORT_C CAknGMSPopupGrid* CAknGMSPopupGrid::NewL(CEikListBox* aListBox, TInt aCbaResource, AknPopupLayouts::TAknPopupLayouts aType) |
|
453 { |
|
454 CAknGMSPopupGrid* self = new(ELeave)CAknGMSPopupGrid; |
|
455 CleanupStack::PushL(self); |
|
456 self->ConstructL(aListBox, aCbaResource, aType); |
|
457 CleanupStack::Pop(); // self |
|
458 return self; |
|
459 } |
|
460 |
|
461 // END OF FILE |
|
462 |
|
463 |