|
1 /* |
|
2 * Copyright (c) 2002-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: EIKON control group implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikctgrp.h> |
|
20 #include <eikpanic.h> |
|
21 #include <coedef.h> |
|
22 #include <coeccntx.h> |
|
23 #include <layoutmetadata.cdl.h> |
|
24 #include <AknUtils.h> // LayoutUtils |
|
25 #include <AknStatuspaneUtils.h> |
|
26 #include <avkon.rsg> |
|
27 |
|
28 const TInt KControlArrayGranularity = 5; |
|
29 const TInt KStartCornerMask = 0x00f; |
|
30 const TInt KOrientationMask = 0x030; |
|
31 |
|
32 EXPORT_C CEikControlGroup::CEikControlGroup() |
|
33 : iLines(1) |
|
34 { |
|
35 __DECLARE_NAME(_S("CEikControlGroup")); |
|
36 } |
|
37 |
|
38 EXPORT_C CEikControlGroup::~CEikControlGroup() |
|
39 { |
|
40 DeleteAllComponents(); |
|
41 delete iControlArray; |
|
42 } |
|
43 |
|
44 EXPORT_C void CEikControlGroup::ConstructL(TStartCorner aStart,TOrientation aOrientation) |
|
45 { |
|
46 iControlArray=new(ELeave) CArrayFixFlat<TEikGroupControl> (KControlArrayGranularity); |
|
47 iLayout|=aStart|aOrientation; |
|
48 } |
|
49 |
|
50 EXPORT_C void CEikControlGroup::AddControlL(CCoeControl* aControl,TInt aId) |
|
51 { |
|
52 TEikGroupControl ctrl; |
|
53 ctrl.iControl=aControl; |
|
54 ctrl.iId=aId; |
|
55 AddControlL(ctrl); |
|
56 } |
|
57 |
|
58 EXPORT_C void CEikControlGroup::AddControlL(TEikGroupControl& aGroupControl) |
|
59 { |
|
60 __ASSERT_DEBUG(aGroupControl.iControl,Panic(EEikPanicNullPointer)); |
|
61 aGroupControl.iControl->SetContainerWindowL(*this); |
|
62 iControlArray->AppendL(aGroupControl); |
|
63 } |
|
64 |
|
65 EXPORT_C void CEikControlGroup::InsertControlL(TEikGroupControl& aGroupControl,TInt aIndex) |
|
66 { |
|
67 __ASSERT_DEBUG(aGroupControl.iControl,Panic(EEikPanicNullPointer)); |
|
68 aGroupControl.iControl->SetContainerWindowL(*this); |
|
69 iControlArray->InsertL(aIndex,aGroupControl); // takes ownership at this point |
|
70 } |
|
71 |
|
72 EXPORT_C void CEikControlGroup::DeleteControl(TInt aIndex,TInt aCount) |
|
73 { |
|
74 for (TInt ii=aIndex+aCount-1;ii>=aIndex;ii--) |
|
75 { |
|
76 delete (*iControlArray)[ii].iControl; |
|
77 iControlArray->Delete(ii); |
|
78 } |
|
79 } |
|
80 |
|
81 EXPORT_C void CEikControlGroup::Reset() |
|
82 { |
|
83 DeleteAllComponents(); |
|
84 iControlArray->Reset(); |
|
85 } |
|
86 |
|
87 EXPORT_C void CEikControlGroup::DeleteAllComponents() |
|
88 { |
|
89 if (iControlArray) |
|
90 { |
|
91 const TInt count=iControlArray->Count(); |
|
92 for (TInt ii=0;ii<count;ii++) |
|
93 delete ((*iControlArray)[ii].iControl); |
|
94 } |
|
95 } |
|
96 |
|
97 EXPORT_C TInt CEikControlGroup::IndexById(TInt aId) const |
|
98 { |
|
99 const TInt count=iControlArray->Count(); |
|
100 for (TInt ii=0;ii<count;ii++) |
|
101 { |
|
102 if ((*iControlArray)[ii].iId==aId) |
|
103 return ii; |
|
104 } |
|
105 return KErrNotFound; |
|
106 } |
|
107 |
|
108 EXPORT_C CCoeControl* CEikControlGroup::ControlById(TInt aId) const |
|
109 { |
|
110 const TInt index=IndexById(aId); |
|
111 if (index==KErrNotFound) |
|
112 return NULL; |
|
113 return (*iControlArray)[index].iControl; |
|
114 } |
|
115 |
|
116 EXPORT_C TInt CEikControlGroup::ControlId(CCoeControl* aControl) const |
|
117 { |
|
118 const TInt count=iControlArray->Count(); |
|
119 for (TInt ii=0;ii<count;ii++) |
|
120 { |
|
121 TEikGroupControl ctrl=(*iControlArray)[ii]; |
|
122 if (ctrl.iControl==aControl) |
|
123 return ctrl.iId; |
|
124 } |
|
125 return KErrNotFound; |
|
126 } |
|
127 |
|
128 EXPORT_C CCoeControl* CEikControlGroup::Control(TInt aIndex) const |
|
129 { |
|
130 return (*iControlArray)[aIndex].iControl; |
|
131 } |
|
132 |
|
133 EXPORT_C CArrayFix<TEikGroupControl>* CEikControlGroup::ControlArray() const |
|
134 { |
|
135 return iControlArray; |
|
136 } |
|
137 |
|
138 EXPORT_C void CEikControlGroup::SetControlsAllSameSize() |
|
139 { |
|
140 iLayout|=EAllSameSize; |
|
141 } |
|
142 |
|
143 EXPORT_C void CEikControlGroup::Draw(const TRect& /*aRect*/) const |
|
144 { |
|
145 const TRect rect(Rect()); |
|
146 CWindowGc& gc=SystemGc(); |
|
147 iBorder.Draw(gc,rect); |
|
148 if (iContext) |
|
149 { |
|
150 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
151 iContext->PrepareContext(gc); |
|
152 gc.DrawRect(iBorder.InnerRect(rect)); |
|
153 } |
|
154 } |
|
155 |
|
156 EXPORT_C void CEikControlGroup::SetLengthInPixels(TInt aLength) |
|
157 { |
|
158 __ASSERT_DEBUG(aLength>=1,Panic(EEikPanicCtGroupInvalidDimension)); |
|
159 iLength=aLength; |
|
160 if (Orientation()==ELayHorizontally) |
|
161 iSize.iWidth=aLength; |
|
162 else |
|
163 iSize.iHeight=aLength; |
|
164 } |
|
165 |
|
166 EXPORT_C void CEikControlGroup::SetBreadthInPixels(TInt aBreadth) |
|
167 { |
|
168 __ASSERT_DEBUG(aBreadth>=1,Panic(EEikPanicCtGroupInvalidDimension)); |
|
169 iBreadth=aBreadth; |
|
170 if (Orientation()==ELayHorizontally) |
|
171 iSize.iHeight=aBreadth; |
|
172 else |
|
173 iSize.iWidth=aBreadth; |
|
174 } |
|
175 |
|
176 EXPORT_C void CEikControlGroup::SetNumberOfLines(TInt aNumLines,TBool aDistributeEvenly) |
|
177 { |
|
178 __ASSERT_DEBUG(aNumLines>=1,Panic(EEikPanicCtGroupInvalidNumberOfLines)); |
|
179 iLines=aNumLines; |
|
180 if (aDistributeEvenly) |
|
181 iLayout|=EDistributeEvenly; |
|
182 else |
|
183 iLayout&=~EDistributeEvenly; |
|
184 } |
|
185 |
|
186 EXPORT_C TSize CEikControlGroup::MinimumSize() |
|
187 { |
|
188 const TBool horiz=(Orientation()==ELayHorizontally); |
|
189 TSize size=(horiz? TSize(iLength,iBreadth) : TSize(iBreadth,iLength)); |
|
190 if ((horiz && size.iWidth==0) || (!horiz && size.iHeight==0)) |
|
191 { |
|
192 if (iLines==1) |
|
193 { |
|
194 const TInt count=iControlArray->Count(); |
|
195 TInt length=0; |
|
196 if (AllSameSize()) |
|
197 length=count*(horiz? iLargestControl.iWidth : iLargestControl.iHeight); |
|
198 else |
|
199 { |
|
200 for (TInt ii=0;ii<count;ii++) |
|
201 { |
|
202 const TSize ctrlSize=ControlMinimumSize(ii); |
|
203 length+=(horiz? ctrlSize.iWidth : ctrlSize.iHeight); |
|
204 } |
|
205 } |
|
206 if (horiz) |
|
207 size.iWidth=length+(count-1)*iHSpacing; |
|
208 else |
|
209 size.iHeight=length+(count-1)*iVSpacing; |
|
210 } |
|
211 else if (iLines>1 && iLayout&EDistributeEvenly) |
|
212 { |
|
213 const TInt count=iControlArray->Count(); |
|
214 const TInt maxLineCount=(count+iLines-1)/iLines; |
|
215 TInt length=0; |
|
216 if (AllSameSize()) |
|
217 length=maxLineCount*(horiz? iLargestControl.iWidth : iLargestControl.iHeight); |
|
218 else |
|
219 { |
|
220 TInt ii=-1; |
|
221 while (++ii<count) |
|
222 { |
|
223 if ((ii+1)%iLines && ii!=count-1) |
|
224 { |
|
225 const TSize ctrlSize=ControlMinimumSize(ii); |
|
226 length+=(horiz? ctrlSize.iWidth : ctrlSize.iHeight); |
|
227 } |
|
228 else |
|
229 { |
|
230 length=Max((horiz? size.iWidth : size.iHeight),length); |
|
231 length=0; |
|
232 } |
|
233 } |
|
234 } |
|
235 if (horiz) |
|
236 { |
|
237 size.iWidth=length; |
|
238 size.iWidth+=(maxLineCount-1)*iHSpacing; |
|
239 } |
|
240 else |
|
241 { |
|
242 size.iHeight=length; |
|
243 size.iHeight+=(maxLineCount-1)*iVSpacing; |
|
244 } |
|
245 } |
|
246 else |
|
247 Panic(EEikPanicCtGroupInsufficientInitialisation); |
|
248 if (horiz) |
|
249 size.iWidth+=iBorder.SizeDelta().iWidth; |
|
250 else |
|
251 size.iHeight+=iBorder.SizeDelta().iHeight; |
|
252 } |
|
253 if ((horiz && size.iHeight==0) || (!horiz && size.iWidth==0)) |
|
254 { |
|
255 TInt breadth=0; |
|
256 if (AllSameSize()) |
|
257 breadth=(horiz? iLargestControl.iHeight : iLargestControl.iWidth); |
|
258 else |
|
259 { |
|
260 const TInt count=iControlArray->Count(); |
|
261 for (TInt ii=0;ii<count;ii++) |
|
262 { |
|
263 const TSize ctrlSize=ControlMinimumSize(ii); |
|
264 breadth=Max(breadth,(horiz? ctrlSize.iHeight : ctrlSize.iWidth)); |
|
265 } |
|
266 } |
|
267 breadth*=iLines; |
|
268 if (horiz) |
|
269 size.iHeight=breadth+(iLines-1)*iVSpacing+iBorder.SizeDelta().iHeight; |
|
270 else |
|
271 size.iWidth=breadth+(iLines-1)*iHSpacing+iBorder.SizeDelta().iWidth; |
|
272 } |
|
273 return size; |
|
274 } |
|
275 |
|
276 EXPORT_C TSize CEikControlGroup::ControlMinimumSize(TInt aIndex) const |
|
277 { |
|
278 TSize size; |
|
279 TEikGroupControl ctrl=(*iControlArray)[aIndex]; |
|
280 if (Orientation()==ELayHorizontally) |
|
281 { |
|
282 TSize ctrlSize; |
|
283 if (ctrl.IsLengthSet()) |
|
284 size.iWidth=ctrl.Length(); |
|
285 else |
|
286 { |
|
287 ctrlSize=ctrl.iControl->MinimumSize(); |
|
288 size.iWidth=ctrlSize.iWidth; |
|
289 } |
|
290 if (iBreadth==0) |
|
291 size.iHeight=(ctrlSize.iHeight>0? ctrlSize.iHeight : ctrl.iControl->MinimumSize().iHeight); |
|
292 else |
|
293 { |
|
294 size.iHeight=iBreadth; |
|
295 size.iHeight-=iBorder.SizeDelta().iHeight; |
|
296 size.iHeight/=iLines; |
|
297 } |
|
298 } |
|
299 else |
|
300 { |
|
301 TSize ctrlSize; |
|
302 if (ctrl.IsLengthSet()) |
|
303 size.iHeight=ctrl.Length(); |
|
304 else |
|
305 { |
|
306 ctrlSize=ctrl.iControl->MinimumSize(); |
|
307 size.iHeight=ctrlSize.iHeight; |
|
308 } |
|
309 if (iBreadth==0) |
|
310 size.iWidth=(ctrlSize.iWidth>0? ctrlSize.iWidth : ctrl.iControl->MinimumSize().iWidth); |
|
311 else |
|
312 { |
|
313 size.iWidth=iBreadth; |
|
314 size.iWidth-=iBorder.SizeDelta().iWidth; |
|
315 size.iWidth/=iLines; |
|
316 } |
|
317 } |
|
318 return size; |
|
319 } |
|
320 |
|
321 EXPORT_C TInt CEikControlGroup::ControlMinimumLength(TInt aIndex) |
|
322 { |
|
323 TEikGroupControl ctrl=(*iControlArray)[aIndex]; |
|
324 if (AllSameSize()) |
|
325 return (Orientation()==ELayHorizontally? iLargestControl.iWidth : iLargestControl.iHeight); |
|
326 if (ctrl.IsLengthSet()) |
|
327 return ctrl.Length(); |
|
328 if (Orientation()==ELayHorizontally) |
|
329 return ctrl.iControl->MinimumSize().iWidth; |
|
330 return ctrl.iControl->MinimumSize().iHeight; |
|
331 } |
|
332 |
|
333 EXPORT_C TSize CEikControlGroup::LargestControlSize() const |
|
334 { |
|
335 TSize size; |
|
336 const TInt count=iControlArray->Count(); |
|
337 for (TInt ii=0;ii<count;ii++) |
|
338 { |
|
339 const TSize ctrlSize=ControlMinimumSize(ii); |
|
340 size.iWidth=Max(size.iWidth,ctrlSize.iWidth); |
|
341 size.iHeight=Max(size.iHeight,ctrlSize.iHeight); |
|
342 } |
|
343 return size; |
|
344 } |
|
345 |
|
346 |
|
347 EXPORT_C TInt CEikControlGroup::CountComponentControls() const |
|
348 { |
|
349 TInt count = iControlArray->Count(); |
|
350 |
|
351 // This prevents MSK from drawing in landscape layouts. |
|
352 // Also MSK doesn't even need to be activated in landscape modes. |
|
353 if ( count == 4 ) |
|
354 { |
|
355 // Exception is made for idle flat status pane layouts, |
|
356 // in which the MSK is used also in landscape. |
|
357 TBool mskSupportedLscLayoutActive( |
|
358 AVKONENV->StatusPaneResIdForCurrentLayout( |
|
359 AknStatuspaneUtils::CurrentStatusPaneLayoutResId() ) == |
|
360 R_AVKON_WIDESCREEN_PANE_LAYOUT_IDLE_FLAT_NO_SOFTKEYS ); |
|
361 |
|
362 if ( iLayout & EDisableMSKDrawing || |
|
363 ( Layout_Meta_Data::IsLandscapeOrientation() && |
|
364 !mskSupportedLscLayoutActive ) ) |
|
365 { |
|
366 count--; |
|
367 } |
|
368 } |
|
369 |
|
370 return count; |
|
371 } |
|
372 |
|
373 EXPORT_C CCoeControl* CEikControlGroup::ComponentControl(TInt aIndex) const |
|
374 { |
|
375 return (*iControlArray)[aIndex].iControl; |
|
376 } |
|
377 |
|
378 void CEikControlGroup::SetMSKVisibility(TBool aEnable) |
|
379 { |
|
380 if (!aEnable) |
|
381 { |
|
382 iLayout|=EDisableMSKDrawing; |
|
383 } |
|
384 else |
|
385 { |
|
386 iLayout&=~EDisableMSKDrawing; |
|
387 } |
|
388 } |
|
389 |
|
390 EXPORT_C void CEikControlGroup::ControlSpacing(TInt& aHSpacing,TInt& aVSpacing) const |
|
391 { |
|
392 aHSpacing=iHSpacing; |
|
393 aVSpacing=iVSpacing; |
|
394 } |
|
395 |
|
396 EXPORT_C void CEikControlGroup::SetControlSpacing(TInt aHSpacing,TInt aVSpacing) |
|
397 { |
|
398 iHSpacing=aHSpacing; |
|
399 iVSpacing=aVSpacing; |
|
400 } |
|
401 |
|
402 EXPORT_C void CEikControlGroup::SetControlLayout(TStartCorner aStart,TOrientation aOrientation) |
|
403 { |
|
404 iLayout&=~KStartCornerMask; |
|
405 iLayout&=~KOrientationMask; |
|
406 iLayout|=aStart|aOrientation; |
|
407 } |
|
408 |
|
409 EXPORT_C void CEikControlGroup::SizeChanged() |
|
410 { |
|
411 LayoutControls(); |
|
412 } |
|
413 |
|
414 EXPORT_C void CEikControlGroup::LayoutControls() |
|
415 { |
|
416 const TBool horiz=Orientation()==ELayHorizontally; |
|
417 const TRect inner=iBorder.InnerRect(Rect()); |
|
418 TInt lineBreadth=0; |
|
419 if (horiz) |
|
420 lineBreadth=(inner.Height()-(iLines-1)*iVSpacing)/iLines; |
|
421 else |
|
422 lineBreadth=(inner.Width()-(iLines-1)*iHSpacing)/iLines; |
|
423 const TInt count=iControlArray->Count(); |
|
424 TInt ctrlsInLine=(DistributeEvenly()? (count+iLines-1)/iLines : 0); |
|
425 TInt index=0; |
|
426 TPoint ctrlPos=inner.iTl; |
|
427 TStartCorner startCorner=StartCorner(); |
|
428 for (TInt ii=0;ii<iLines && index<count;ii++) |
|
429 { |
|
430 TInt excess=0; |
|
431 TInt length=(iLength? iLength-(horiz? iBorder.SizeDelta().iWidth : iBorder.SizeDelta().iHeight) : |
|
432 (horiz? inner.Width() : inner.Height())); |
|
433 if (DistributeEvenly()) |
|
434 { |
|
435 if (ii==iLines-1) |
|
436 ctrlsInLine=count-(ctrlsInLine*ii); |
|
437 else |
|
438 ctrlsInLine=Min(ctrlsInLine,count-index); |
|
439 TInt ctrlsLength=0; |
|
440 for (TInt jj=0;jj<ctrlsInLine && index+jj<=count;jj++) |
|
441 { |
|
442 if (index+jj==count) |
|
443 { |
|
444 ctrlsInLine=jj; |
|
445 break; |
|
446 } |
|
447 ctrlsLength+=ControlMinimumLength(index+jj); |
|
448 } |
|
449 ctrlsLength+=(ctrlsInLine-1)*(horiz? iHSpacing : iVSpacing); |
|
450 excess=length-ctrlsLength; |
|
451 } |
|
452 else |
|
453 { |
|
454 ctrlsInLine=0; |
|
455 TInt jj=index; |
|
456 TInt ctrlsLength=0; |
|
457 const TInt spacing=(horiz? iHSpacing : iVSpacing); |
|
458 if (index<count) |
|
459 { |
|
460 FOREVER |
|
461 { |
|
462 const TInt ctrlLength=ControlMinimumLength(jj++)+(ctrlsInLine? spacing : 0); |
|
463 if (ctrlLength+ctrlsLength<=length) |
|
464 { |
|
465 ctrlsLength+=ctrlLength; |
|
466 ++ctrlsInLine; |
|
467 if (jj==count) |
|
468 break; |
|
469 } |
|
470 else |
|
471 break; |
|
472 } |
|
473 excess=length-ctrlsLength; |
|
474 } |
|
475 } |
|
476 TInt stretchable=0; |
|
477 for (TInt jj=0;jj<ctrlsInLine;jj++) |
|
478 { |
|
479 if ((*iControlArray)[index+jj].IsStretchable()) |
|
480 ++stretchable; |
|
481 } |
|
482 switch (startCorner) |
|
483 { |
|
484 case EFromTopLeft: |
|
485 ctrlPos=inner.iTl; |
|
486 if (horiz) |
|
487 ctrlPos.iY+=ii*(lineBreadth+iVSpacing); |
|
488 else |
|
489 ctrlPos.iX+=ii*(lineBreadth+iHSpacing); |
|
490 break; |
|
491 case EFromTopRight: |
|
492 ctrlPos.iX=inner.iBr.iX; |
|
493 ctrlPos.iY=inner.iTl.iY; |
|
494 if (horiz) |
|
495 { |
|
496 ctrlPos.iX-=ControlMinimumLength(index); |
|
497 ctrlPos.iY+=ii*(lineBreadth+iVSpacing); |
|
498 } |
|
499 else |
|
500 ctrlPos.iX-=lineBreadth+(ii*(lineBreadth+iHSpacing)); |
|
501 break; |
|
502 case EFromBottomLeft: |
|
503 ctrlPos.iX=inner.iTl.iX; |
|
504 ctrlPos.iY=inner.iBr.iY; |
|
505 if (horiz) |
|
506 ctrlPos.iY-=(lineBreadth+(ii*(lineBreadth+iVSpacing))); |
|
507 else |
|
508 { |
|
509 ctrlPos.iX+=ii*(lineBreadth+iHSpacing); |
|
510 ctrlPos.iY-=ControlMinimumLength(index); |
|
511 } |
|
512 break; |
|
513 case EFromBottomRight: |
|
514 ctrlPos=inner.iBr; |
|
515 if (horiz) |
|
516 { |
|
517 ctrlPos.iX-=ControlMinimumLength(index); |
|
518 ctrlPos.iY-=(lineBreadth+(ii*(lineBreadth+iVSpacing))); |
|
519 } |
|
520 else |
|
521 { |
|
522 ctrlPos.iX-=lineBreadth+(ii*(lineBreadth+iHSpacing)); |
|
523 ctrlPos.iY-=ControlMinimumLength(index); |
|
524 } |
|
525 break; |
|
526 } |
|
527 TInt stretched=0; |
|
528 for (TInt kk=index;kk<ctrlsInLine+index;kk++) |
|
529 { |
|
530 TSize ctrlSize; |
|
531 TSize delta=TSize(0,0); |
|
532 TSize deltaPos=TSize(0,0); |
|
533 if (AllSameSize()) |
|
534 ctrlSize=iLargestControl; |
|
535 else |
|
536 { |
|
537 ctrlSize=ControlMinimumSize(kk); |
|
538 if(kk<ctrlsInLine+index-1) |
|
539 delta=ControlMinimumSize(kk+1)-ctrlSize; |
|
540 } |
|
541 if (horiz) |
|
542 ctrlSize.iHeight=lineBreadth; |
|
543 else |
|
544 ctrlSize.iWidth=lineBreadth; |
|
545 if ((*iControlArray)[kk].IsStretchable()) |
|
546 { |
|
547 TInt extra=excess/stretchable; |
|
548 if (excess%stretchable>stretched) |
|
549 ++extra; |
|
550 ++stretched; |
|
551 if (horiz) |
|
552 { |
|
553 ctrlSize.iWidth+=extra; |
|
554 if (startCorner==EFromTopRight || startCorner==EFromBottomRight) |
|
555 deltaPos.iWidth-=extra; |
|
556 } |
|
557 else |
|
558 { |
|
559 ctrlSize.iHeight+=extra; |
|
560 if (startCorner==EFromBottomLeft || startCorner==EFromBottomRight) |
|
561 deltaPos.iHeight-=extra; |
|
562 } |
|
563 } |
|
564 CCoeControl* ctrl=(*iControlArray)[kk].iControl; |
|
565 TInt adjacent=0; |
|
566 if (horiz) |
|
567 adjacent=Adjacent(ii+1,kk-index+1,kk,iLines,ctrlsInLine); |
|
568 else |
|
569 adjacent=Adjacent(kk-index+1,ii+1,kk,ctrlsInLine,iLines); |
|
570 ctrl->SetAdjacent(adjacent); |
|
571 ctrl->SetExtent(ctrlPos+deltaPos,ctrlSize); |
|
572 if (kk<ctrlsInLine+index-1) |
|
573 { |
|
574 if (horiz) |
|
575 { |
|
576 if (startCorner==EFromTopLeft || startCorner==EFromBottomLeft) |
|
577 ctrlPos.iX+=ctrlSize.iWidth+iHSpacing; |
|
578 else |
|
579 ctrlPos.iX-=((ctrlSize+delta).iWidth+iHSpacing); |
|
580 } |
|
581 else |
|
582 { |
|
583 if (startCorner==EFromTopLeft || startCorner==EFromTopRight) |
|
584 ctrlPos.iY+=ctrlSize.iHeight+iVSpacing; |
|
585 else |
|
586 ctrlPos.iY-=((ctrlSize+delta).iHeight+iVSpacing); |
|
587 } |
|
588 } |
|
589 } |
|
590 index+=ctrlsInLine; |
|
591 } |
|
592 } |
|
593 |
|
594 EXPORT_C TInt CEikControlGroup::Adjacent(TInt aRow,TInt aColumn,TInt aCtrlIndex,TInt aTotalRows,TInt aTotalColumns) const |
|
595 { |
|
596 if (!(iLines==1 || iLayout&EAllSameSize)) |
|
597 return 0; |
|
598 const TBool ctrlBordered=(*iControlArray)[aCtrlIndex].iControl->HasBorder(); |
|
599 TInt adjacent=EGulAdjNone; |
|
600 if (ctrlBordered) |
|
601 { |
|
602 TStartCorner startCorner=StartCorner(); |
|
603 const TInt startHoriz=((startCorner==EFromTopLeft || startCorner==EFromBottomLeft)? |
|
604 EGulAdjLeft : EGulAdjRight); |
|
605 const TInt endHoriz=((startCorner==EFromTopLeft || startCorner==EFromBottomLeft)? |
|
606 EGulAdjRight : EGulAdjLeft); |
|
607 const TInt startVert=((startCorner==EFromTopLeft || startCorner==EFromTopRight)? |
|
608 EGulAdjTop : EGulAdjBottom); |
|
609 const TInt endVert=((startCorner==EFromTopLeft || startCorner==EFromTopRight)? |
|
610 EGulAdjBottom : EGulAdjTop); |
|
611 const TInt internalHoriz=startHoriz; |
|
612 const TInt internalVert=startVert; |
|
613 const TBool bordered=HasBorder(); |
|
614 if (bordered) |
|
615 { |
|
616 if (aRow==1) |
|
617 adjacent|=startVert; |
|
618 if (aRow==aTotalRows) |
|
619 adjacent|=endVert; |
|
620 if (aColumn==1) |
|
621 adjacent|=startHoriz; |
|
622 if (aColumn==aTotalColumns) |
|
623 adjacent|=endHoriz; |
|
624 } |
|
625 if (iHSpacing==0 && aColumn!=1) |
|
626 { |
|
627 const TInt index=(Orientation()==ELayHorizontally? aCtrlIndex-1 : aCtrlIndex-aTotalRows); |
|
628 if ((*iControlArray)[index].iControl->HasBorder()) |
|
629 adjacent|=internalHoriz; |
|
630 } |
|
631 if (iVSpacing==0 && aRow!=1) |
|
632 { |
|
633 const TInt index=(Orientation()==ELayHorizontally? aCtrlIndex-aTotalColumns : aCtrlIndex-1); |
|
634 if ((*iControlArray)[index].iControl->HasBorder()) |
|
635 adjacent|=internalVert; |
|
636 } |
|
637 } |
|
638 return adjacent; |
|
639 } |
|
640 |
|
641 EXPORT_C CEikControlGroup::TStartCorner CEikControlGroup::StartCorner() const |
|
642 { |
|
643 return ((TStartCorner)(iLayout&KStartCornerMask)); |
|
644 } |
|
645 |
|
646 EXPORT_C CEikControlGroup::TOrientation CEikControlGroup::Orientation() const |
|
647 { |
|
648 return ((TOrientation)(iLayout&KOrientationMask)); |
|
649 } |
|
650 |
|
651 EXPORT_C TBool CEikControlGroup::DistributeEvenly() const |
|
652 { |
|
653 return iLayout&EDistributeEvenly; |
|
654 } |
|
655 |
|
656 EXPORT_C TBool CEikControlGroup::AllSameSize() |
|
657 { |
|
658 const TBool sameSize=iLayout&EAllSameSize; |
|
659 if (sameSize && !(iLargestControl.iWidth && iLargestControl.iHeight)) |
|
660 iLargestControl=LargestControlSize(); |
|
661 return sameSize; |
|
662 } |
|
663 |
|
664 /** |
|
665 * Gets the list of logical colors employed in the drawing of the control, |
|
666 * paired with an explanation of how they are used. Appends the list to aColorUseList. |
|
667 * |
|
668 * @since ER5U |
|
669 */ |
|
670 EXPORT_C void CEikControlGroup::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const |
|
671 { |
|
672 CEikBorderedControl::GetColorUseListL(aColorUseList); |
|
673 } |
|
674 |
|
675 /** |
|
676 * Handles a change to the control's resources of type aType |
|
677 * which are shared across the environment, e.g. colors or fonts. |
|
678 * |
|
679 * @since ER5U |
|
680 */ |
|
681 EXPORT_C void CEikControlGroup::HandleResourceChange(TInt aType) |
|
682 { |
|
683 CEikBorderedControl::HandleResourceChange(aType); |
|
684 } |
|
685 |
|
686 /** |
|
687 * Writes the internal state of the control and its components to aStream. |
|
688 * Does nothing in release mode. |
|
689 * Designed to be overidden and base called by subclasses. |
|
690 * |
|
691 * @internal |
|
692 * @since App-Framework_6.1 |
|
693 */ |
|
694 #ifndef _DEBUG |
|
695 EXPORT_C void CEikControlGroup::WriteInternalStateL(RWriteStream&) const |
|
696 {} |
|
697 #else |
|
698 EXPORT_C void CEikControlGroup::WriteInternalStateL(RWriteStream& aWriteStream) const |
|
699 { |
|
700 _LIT(KEikLitCtGrpCtlStart,"<CEikControlGroup>"); |
|
701 _LIT(KEikLitCtGrpCtlEnd,"<\\CEikControlGroup>"); |
|
702 _LIT(KEikLitCtGrpLay,"<iLayout>"); |
|
703 _LIT(KEikLitCtGrpLayEnd,"<\\iLayout>"); |
|
704 _LIT(KEikLitCtGrpLines,"<iLines>"); |
|
705 _LIT(KEikLitCtGrpLinesEnd,"<\\iLines>"); |
|
706 _LIT(KEikLitCtGrpHSp,"<iHSpacing>"); |
|
707 _LIT(KEikLitCtGrpHSpEnd,"<\\iHSpacing>"); |
|
708 _LIT(KEikLitCtGrpVSp,"<iVSpacing>"); |
|
709 _LIT(KEikLitCtGrpVSpEnd,"<\\iVSpacing>"); |
|
710 _LIT(KEikLitCtGrpBrd,"<iBreadth>"); |
|
711 _LIT(KEikLitCtGrpBrdEnd,"<\\iBreadth>"); |
|
712 _LIT(KEikLitCtGrpLen,"<iLength>"); |
|
713 _LIT(KEikLitCtGrpLenEnd,"<\\iLength>"); |
|
714 _LIT(KEikLitCtGrpLrgstCtl,"<iLargestControl>"); |
|
715 _LIT(KEikLitCtGrpLrgstCtlEnd,"<\\iLargestControl>"); |
|
716 |
|
717 aWriteStream << KEikLitCtGrpCtlStart; |
|
718 aWriteStream << KEikLitCtGrpLay; |
|
719 aWriteStream.WriteInt32L(iLayout); |
|
720 aWriteStream << KEikLitCtGrpLayEnd; |
|
721 aWriteStream << KEikLitCtGrpLines; |
|
722 aWriteStream.WriteInt32L(iLines); |
|
723 aWriteStream << KEikLitCtGrpLinesEnd; |
|
724 aWriteStream << KEikLitCtGrpHSp; |
|
725 aWriteStream.WriteInt32L(iHSpacing); |
|
726 aWriteStream << KEikLitCtGrpHSpEnd; |
|
727 aWriteStream << KEikLitCtGrpVSp; |
|
728 aWriteStream.WriteInt32L(iVSpacing); |
|
729 aWriteStream << KEikLitCtGrpVSpEnd; |
|
730 aWriteStream << KEikLitCtGrpBrd; |
|
731 aWriteStream.WriteInt32L(iBreadth); |
|
732 aWriteStream << KEikLitCtGrpBrdEnd; |
|
733 aWriteStream << KEikLitCtGrpLen; |
|
734 aWriteStream.WriteInt32L(iLength); |
|
735 aWriteStream << KEikLitCtGrpLenEnd; |
|
736 aWriteStream << KEikLitCtGrpLrgstCtl; |
|
737 aWriteStream << iLargestControl; |
|
738 aWriteStream << KEikLitCtGrpLrgstCtlEnd; |
|
739 CEikBorderedControl::WriteInternalStateL(aWriteStream); |
|
740 aWriteStream << KEikLitCtGrpCtlEnd; |
|
741 } |
|
742 #endif |
|
743 |
|
744 EXPORT_C void CEikControlGroup::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
745 { |
|
746 CEikBorderedControl::HandlePointerEventL(aPointerEvent); |
|
747 } |
|
748 |
|
749 EXPORT_C void* CEikControlGroup::ExtensionInterface( TUid /*aInterface*/ ) |
|
750 { |
|
751 return NULL; |
|
752 } |
|
753 |
|
754 EXPORT_C void CEikControlGroup::Reserved_2() |
|
755 {} |