66
|
1 |
/*
|
|
2 |
* Copyright (c) 2003-2007 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: Implements the Form LCDUI component.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// For LyaoutMirrored() method.
|
|
20 |
#include <AknUtils.h>
|
|
21 |
|
|
22 |
#include "CMIDFormRow.h"
|
|
23 |
// CMIDForm API for iForm
|
|
24 |
#include "CMIDForm.h"
|
|
25 |
// API for items on rows
|
|
26 |
#include "CMIDControlItem.h"
|
|
27 |
#include "CMIDItemLabel.h"
|
|
28 |
|
|
29 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
30 |
#include "CMIDLabelContainerItem.h"
|
|
31 |
|
|
32 |
#include <AknsUtils.h>
|
|
33 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
34 |
|
|
35 |
// CONSTANTS
|
|
36 |
// Default for Form separator line color's alpha value, used if not
|
|
37 |
// found from skin.
|
|
38 |
const TInt KDefaultSeparatorAlpha = 32;
|
|
39 |
const TInt KDefaultSeparatorColor = 0;
|
|
40 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
41 |
|
|
42 |
CMIDFormRow* CMIDFormRow::NewL(CMIDForm& aForm)
|
|
43 |
{
|
|
44 |
CMIDFormRow* self = new(ELeave) CMIDFormRow(aForm);
|
|
45 |
CleanupStack::PushL(self);
|
|
46 |
self->ActivateL();
|
|
47 |
CleanupStack::Pop(self);
|
|
48 |
return self;
|
|
49 |
}
|
|
50 |
|
|
51 |
CMIDFormRow::~CMIDFormRow()
|
|
52 |
{
|
|
53 |
TInt i;
|
|
54 |
for (i=0; i < iItems.Count(); i++)
|
|
55 |
{
|
|
56 |
if (CMIDForm::IsLabelContainerItem(*(iItems[i])))
|
|
57 |
{
|
|
58 |
delete iItems[i];
|
|
59 |
}
|
|
60 |
else if (CMIDForm::IsSpacerUsedForFormatting(*(iItems[i])))
|
|
61 |
{
|
|
62 |
delete iItems[i];
|
|
63 |
}
|
|
64 |
}
|
|
65 |
iItems.Reset();
|
|
66 |
iItems.Close();
|
|
67 |
}
|
|
68 |
|
|
69 |
TInt CMIDFormRow::CountComponentControls() const
|
|
70 |
{
|
|
71 |
return iItems.Count();
|
|
72 |
}
|
|
73 |
|
|
74 |
CCoeControl* CMIDFormRow::ComponentControl(TInt aIndex) const
|
|
75 |
{
|
|
76 |
return iItems[aIndex];
|
|
77 |
}
|
|
78 |
|
|
79 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
80 |
void CMIDFormRow::Draw(const TRect& /*aRect*/) const
|
|
81 |
{
|
|
82 |
if (iSeparator)
|
|
83 |
{
|
|
84 |
CWindowGc& gc = SystemGc();
|
|
85 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
86 |
gc.SetBrushStyle(CGraphicsContext::ENullBrush);
|
|
87 |
gc.SetPenStyle(CGraphicsContext::ESolidPen);
|
|
88 |
|
|
89 |
TRgb color;
|
|
90 |
TInt err = AknsUtils::GetCachedColor(skin,
|
|
91 |
color,
|
|
92 |
KAknsIIDQsnTextColors,
|
|
93 |
EAknsCIQsnTextColorsCG6);
|
|
94 |
if (err != KErrNone)
|
|
95 |
{
|
|
96 |
color = KDefaultSeparatorColor;
|
|
97 |
}
|
|
98 |
|
|
99 |
TRgb colorFromSkin;
|
|
100 |
// Get alpha value from skin, if not successful, default is used.
|
|
101 |
err = AknsUtils::GetCachedColor(skin ? skin : AknsUtils::SkinInstance(),
|
|
102 |
colorFromSkin,
|
|
103 |
KAknsIIDQsnLineColors,
|
|
104 |
EAknsCIQsnLineColorsCG15);
|
|
105 |
|
|
106 |
color.SetAlpha(!err ? colorFromSkin.Red() : KDefaultSeparatorAlpha);
|
|
107 |
gc.SetDrawMode(CGraphicsContext::EDrawModePEN);
|
|
108 |
gc.SetPenColor(color);
|
|
109 |
|
|
110 |
// Draw line to upper part of the form row.
|
|
111 |
TRect lineRect(Rect());
|
|
112 |
// Using same margin value with avkon list box separator lines.
|
|
113 |
TInt gap = AknLayoutScalable_Avkon::listscroll_gen_pane(0).LayoutLine().it;
|
|
114 |
lineRect.Shrink(gap, 0);
|
|
115 |
lineRect.Move(0, 1);
|
|
116 |
gc.DrawLine(TPoint(lineRect.iTl.iX, lineRect.iTl.iY),
|
|
117 |
TPoint(lineRect.iBr.iX, lineRect.iTl.iY));
|
|
118 |
}
|
|
119 |
}
|
|
120 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
121 |
|
|
122 |
void CMIDFormRow::SizeChanged()
|
|
123 |
{
|
|
124 |
TInt xOff = 0;
|
|
125 |
|
|
126 |
TSize size(0,0);
|
|
127 |
|
|
128 |
TInt i;
|
|
129 |
for (i=0; i < iItems.Count(); i++)
|
|
130 |
{
|
|
131 |
CMIDControlItem& ci = *(iItems[i]);
|
|
132 |
size.iWidth += ci.Size().iWidth;
|
|
133 |
if (ci.Size().iHeight > size.iHeight)
|
|
134 |
{
|
|
135 |
size.iHeight = ci.Size().iHeight;
|
|
136 |
}
|
|
137 |
}
|
|
138 |
|
|
139 |
if (iAlignment == MMIDItem::ERight)
|
|
140 |
{
|
|
141 |
xOff = iForm.Width() - size.iWidth;
|
|
142 |
// If it is mirrored layout, we need translate a row.
|
|
143 |
if (AknLayoutUtils::LayoutMirrored())
|
|
144 |
{
|
|
145 |
xOff -= iForm.GetMidpNaviPos();
|
|
146 |
}
|
|
147 |
}
|
|
148 |
|
|
149 |
if (iAlignment == MMIDItem::ECenter)
|
|
150 |
{
|
|
151 |
xOff = (iForm.Width() - size.iWidth) / 2;
|
|
152 |
}
|
|
153 |
|
|
154 |
for (i=0; i < iItems.Count(); i++)
|
|
155 |
{
|
|
156 |
CMIDControlItem& ci = *(iItems[i]);
|
|
157 |
TInt yOff = 0;
|
|
158 |
if (CMIDForm::LayoutBottom(ci))
|
|
159 |
{
|
|
160 |
yOff = size.iHeight - ci.Size().iHeight;
|
|
161 |
}
|
|
162 |
if (CMIDForm::LayoutVerticalCenter(ci))
|
|
163 |
{
|
|
164 |
yOff = (size.iHeight - ci.Size().iHeight) / 2;
|
|
165 |
}
|
|
166 |
|
|
167 |
// Form left margin is added in the beginning of each row
|
|
168 |
TPoint newPosition = Position() + TPoint(xOff, yOff);
|
|
169 |
TSize itemSize = ci.Size();
|
|
170 |
TRect itemRect = TRect(newPosition, itemSize);
|
|
171 |
ci.SetRect(itemRect);
|
|
172 |
xOff += ci.Size().iWidth;
|
|
173 |
}
|
|
174 |
}
|
|
175 |
|
|
176 |
TSize CMIDFormRow::MinimumSize()
|
|
177 |
{
|
|
178 |
if (iItems.Count() == 0)
|
|
179 |
{
|
|
180 |
return iEmptyRowSize;
|
|
181 |
}
|
|
182 |
|
|
183 |
TInt width = 0;
|
|
184 |
TInt height = 0;
|
|
185 |
|
|
186 |
for (TInt i=0; i < iItems.Count(); i++)
|
|
187 |
{
|
|
188 |
CMIDControlItem& ci = *(iItems[i]);
|
|
189 |
|
|
190 |
width += CMIDForm::LayoutShrink(ci) ? ci.MinimumSize().iWidth : ci.PreferredSize().iWidth;
|
|
191 |
|
|
192 |
if (CMIDForm::LayoutVerticalShrink(ci))
|
|
193 |
{
|
|
194 |
if (height < ci.MinimumSize().iHeight)
|
|
195 |
{
|
|
196 |
height = ci.MinimumSize().iHeight;
|
|
197 |
}
|
|
198 |
}
|
|
199 |
else
|
|
200 |
{
|
|
201 |
if (height < ci.PreferredSize().iHeight)
|
|
202 |
{
|
|
203 |
height = ci.PreferredSize().iHeight;
|
|
204 |
}
|
|
205 |
}
|
|
206 |
}
|
|
207 |
return TSize(width, height);
|
|
208 |
}
|
|
209 |
|
|
210 |
void CMIDFormRow::AppendL(CMIDControlItem* aItem)
|
|
211 |
{
|
|
212 |
if (iForm.InitialAlignment() == MMIDItem::ELeft)
|
|
213 |
{
|
|
214 |
User::LeaveIfError(iItems.Append(aItem));
|
|
215 |
}
|
|
216 |
else
|
|
217 |
{
|
|
218 |
User::LeaveIfError(iItems.Insert(aItem, 0));
|
|
219 |
}
|
|
220 |
iCurrentWidth += aItem->Size().iWidth;
|
|
221 |
|
|
222 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
223 |
SetSeparator();
|
|
224 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
225 |
}
|
|
226 |
|
|
227 |
void CMIDFormRow::SetAlignment(MMIDItem::TLayout aAlignment)
|
|
228 |
{
|
|
229 |
ASSERT((aAlignment == MMIDItem::ELeft) || (aAlignment == MMIDItem::ERight) || (aAlignment == MMIDItem::ECenter));
|
|
230 |
iAlignment = aAlignment;
|
|
231 |
}
|
|
232 |
|
|
233 |
/** */
|
|
234 |
void CMIDFormRow::SizeItemsL()
|
|
235 |
{
|
|
236 |
TSize minSize = MinimumSize();
|
|
237 |
|
|
238 |
// size the widths first
|
|
239 |
TInt availableWidth = iForm.Width() - minSize.iWidth;
|
|
240 |
// equation is also allowed - resizing when extra space is same as allowed
|
|
241 |
if (availableWidth >= 0)
|
|
242 |
{
|
|
243 |
TInt totalExtraWidth = 0;
|
|
244 |
for (TInt j=0; j < iItems.Count(); j++)
|
|
245 |
{
|
|
246 |
CMIDControlItem& ci = *(iItems[j]);
|
|
247 |
if (CMIDForm::LayoutShrink(ci))
|
|
248 |
{
|
|
249 |
totalExtraWidth += ci.PreferredSize().iWidth - ci.MinimumSize().iWidth;
|
|
250 |
}
|
|
251 |
}
|
|
252 |
|
|
253 |
if (availableWidth > totalExtraWidth)
|
|
254 |
{
|
|
255 |
// just give all items what they want
|
|
256 |
for (TInt j=0; j < iItems.Count(); j++)
|
|
257 |
{
|
|
258 |
CMIDControlItem& ci = *(iItems[j]);
|
|
259 |
ci.SetSizeQuiet(ci.PreferredSize());
|
|
260 |
}
|
|
261 |
|
|
262 |
availableWidth -= totalExtraWidth;
|
|
263 |
}
|
|
264 |
else
|
|
265 |
{
|
|
266 |
// distribute the size
|
|
267 |
TReal scaleFactor;
|
|
268 |
if (availableWidth == totalExtraWidth)
|
|
269 |
{
|
|
270 |
scaleFactor = 1;
|
|
271 |
}
|
|
272 |
else
|
|
273 |
{
|
|
274 |
if (totalExtraWidth != 0)
|
|
275 |
{
|
|
276 |
scaleFactor = TReal(availableWidth) / TReal(totalExtraWidth);
|
|
277 |
}
|
|
278 |
else
|
|
279 |
{
|
|
280 |
scaleFactor = 1;
|
|
281 |
}
|
|
282 |
}
|
|
283 |
|
|
284 |
for (TInt j=0; j < iItems.Count(); j++)
|
|
285 |
{
|
|
286 |
CMIDControlItem& ci = *(iItems[j]);
|
|
287 |
|
|
288 |
if (CMIDForm::LayoutShrink(ci))
|
|
289 |
{
|
|
290 |
TInt minAndPreferredDif = ci.PreferredSize().iWidth - ci.MinimumSize().iWidth;
|
|
291 |
TInt newMinAndPreferredDif = TInt(scaleFactor * TReal(minAndPreferredDif));
|
|
292 |
TInt newWidth = ci.MinimumSize().iWidth + Min(newMinAndPreferredDif, minAndPreferredDif);
|
|
293 |
availableWidth -= Min(newMinAndPreferredDif, minAndPreferredDif);
|
|
294 |
ci.SetSizeQuiet(TSize(newWidth, ci.Size().iHeight));
|
|
295 |
}
|
|
296 |
else
|
|
297 |
{
|
|
298 |
ci.SetSizeQuiet(TSize(ci.PreferredSize().iWidth, ci.Size().iHeight));
|
|
299 |
}
|
|
300 |
}
|
|
301 |
}
|
|
302 |
// note: should probably do another pass through to make sure the above step
|
|
303 |
// went ok and didn't suffer from rounding errors (ie that the Shrink items didn't
|
|
304 |
// end up smaller than their preferred size (if we have size left over)
|
|
305 |
|
|
306 |
// loop through and expand the items with Expand layout
|
|
307 |
if (availableWidth > 0)
|
|
308 |
{
|
|
309 |
TInt numExpand = 0;
|
|
310 |
// count the items with Expand layout
|
|
311 |
for (TInt j=0; j < iItems.Count(); j++)
|
|
312 |
{
|
|
313 |
CMIDControlItem& ci = *(iItems[j]);
|
|
314 |
|
|
315 |
if (CMIDForm::LayoutExpand(ci))
|
|
316 |
{
|
|
317 |
numExpand++;
|
|
318 |
}
|
|
319 |
}
|
|
320 |
if (numExpand > 0)
|
|
321 |
{
|
|
322 |
TInt addedSize = availableWidth / numExpand;
|
|
323 |
TInt expandIdx = -1;
|
|
324 |
|
|
325 |
for (TInt j=0; j < iItems.Count(); j++)
|
|
326 |
{
|
|
327 |
CMIDControlItem& ci = *(iItems[j]);
|
|
328 |
|
|
329 |
if (CMIDForm::LayoutExpand(ci))
|
|
330 |
{
|
|
331 |
ci.SetSizeQuiet(ci.Size() + TSize(addedSize, 0));
|
|
332 |
availableWidth -= addedSize;
|
|
333 |
expandIdx = j;
|
|
334 |
// at the end of the loop this will hold the last expanded
|
|
335 |
// item. At that time we can check if we still have extra
|
|
336 |
// space remaining and give it to the item at this index
|
|
337 |
}
|
|
338 |
}
|
|
339 |
if (availableWidth > 0)
|
|
340 |
{
|
|
341 |
// if we still have extra width due to rounding error just give it to the last item
|
|
342 |
iItems[expandIdx]->SetSizeQuiet(iItems[expandIdx]->Size() + TSize(availableWidth, 0));
|
|
343 |
}
|
|
344 |
}
|
|
345 |
}
|
|
346 |
}
|
|
347 |
|
|
348 |
|
|
349 |
// the widths have been calculated. This could have changed the height
|
|
350 |
// due to for example label wrapping so ask the control to check
|
|
351 |
// the new width.
|
|
352 |
TInt j;
|
|
353 |
for (j=0; j < iItems.Count(); j++)
|
|
354 |
{
|
|
355 |
CMIDControlItem& ci = *(iItems[j]);
|
|
356 |
ci.AdjustToNewWidthL(ci.Size().iWidth);
|
|
357 |
}
|
|
358 |
|
|
359 |
// now size the heights
|
|
360 |
|
|
361 |
// first find the row height
|
|
362 |
TInt rowHeight = 0;
|
|
363 |
for (j=0; j < iItems.Count(); j++)
|
|
364 |
{
|
|
365 |
CMIDControlItem& ci = *(iItems[j]);
|
|
366 |
|
|
367 |
TInt height = ci.PreferredSize().iHeight;
|
|
368 |
if (CMIDForm::LayoutVerticalShrink(ci))
|
|
369 |
{
|
|
370 |
height = ci.MinimumSize().iHeight;
|
|
371 |
}
|
|
372 |
if (height > rowHeight)
|
|
373 |
{
|
|
374 |
rowHeight = height;
|
|
375 |
}
|
|
376 |
}
|
|
377 |
|
|
378 |
if (iItems.Count() == 0)
|
|
379 |
{//if not items use empty row height
|
|
380 |
rowHeight = iEmptyRowSize.iHeight;
|
|
381 |
}
|
|
382 |
|
|
383 |
// now set the row heights
|
|
384 |
for (j=0; j < iItems.Count(); j++)
|
|
385 |
{
|
|
386 |
CMIDControlItem& ci = *(iItems[j]);
|
|
387 |
|
|
388 |
// first set the size normally, then change it based on shrink and expand directives
|
|
389 |
ci.SetSizeQuiet(TSize(ci.Size().iWidth, ci.PreferredSize().iHeight));
|
|
390 |
if (CMIDForm::LayoutVerticalShrink(ci))
|
|
391 |
{
|
|
392 |
TInt height = Min(ci.PreferredSize().iHeight, rowHeight);
|
|
393 |
ci.SetSizeQuiet(TSize(ci.Size().iWidth, height));
|
|
394 |
}
|
|
395 |
if (CMIDForm::LayoutVerticalExpand(ci))
|
|
396 |
{
|
|
397 |
ci.SetSizeQuiet(TSize(ci.Size().iWidth, rowHeight));
|
|
398 |
}
|
|
399 |
|
|
400 |
ci.AdjustToSizeL(ci.Size());
|
|
401 |
}
|
|
402 |
|
|
403 |
// set the size of the row
|
|
404 |
SetSize(TSize(iForm.Width(), rowHeight));
|
|
405 |
}
|
|
406 |
|
|
407 |
TInt CMIDFormRow::NumItems()
|
|
408 |
{
|
|
409 |
return iItems.Count();
|
|
410 |
}
|
|
411 |
|
|
412 |
TInt CMIDFormRow::Find(const CMIDControlItem* aItem) const
|
|
413 |
{
|
|
414 |
for (TInt i=0; i < iItems.Count(); i++)
|
|
415 |
{
|
|
416 |
if (aItem == iItems[i])
|
|
417 |
{
|
|
418 |
return i;
|
|
419 |
}
|
|
420 |
}
|
|
421 |
|
|
422 |
return KErrNotFound;
|
|
423 |
}
|
|
424 |
|
|
425 |
CMIDControlItem* CMIDFormRow::Item(TInt aIndex)
|
|
426 |
{
|
|
427 |
ASSERT(aIndex >= 0 && aIndex < iItems.Count());
|
|
428 |
return iItems[aIndex];
|
|
429 |
}
|
|
430 |
|
|
431 |
TBool CMIDFormRow::HasFocusableItemOnOrAboveScreen()
|
|
432 |
{
|
|
433 |
for (TInt i=0; i < iItems.Count(); i++)
|
|
434 |
{
|
|
435 |
if (iItems[i]->IsSelectable())
|
|
436 |
{
|
|
437 |
TRect rect = iItems[i]->Rect();
|
|
438 |
if (rect.iTl.iY < iForm.Height())
|
|
439 |
{
|
|
440 |
return ETrue;
|
|
441 |
}
|
|
442 |
}
|
|
443 |
}
|
|
444 |
return EFalse;
|
|
445 |
}
|
|
446 |
|
|
447 |
TBool CMIDFormRow::HasFocusableItemOnOrBelowScreen()
|
|
448 |
{
|
|
449 |
for (TInt i=0; i < iItems.Count(); i++)
|
|
450 |
{
|
|
451 |
if (iItems[i]->IsSelectable())
|
|
452 |
{
|
|
453 |
TRect rect = iItems[i]->Rect();
|
|
454 |
if (rect.iBr.iY >= 0)
|
|
455 |
{
|
|
456 |
return ETrue;
|
|
457 |
}
|
|
458 |
}
|
|
459 |
}
|
|
460 |
return EFalse;
|
|
461 |
}
|
|
462 |
|
|
463 |
CMIDControlItem* CMIDFormRow::FirstFocusableItemOnScreen()
|
|
464 |
{
|
|
465 |
TInt idx = -1;
|
|
466 |
while (++idx < iItems.Count())
|
|
467 |
{
|
|
468 |
if (iItems[idx]->IsSelectable())
|
|
469 |
{
|
|
470 |
TRect rect = iItems[idx]->Rect();
|
|
471 |
if (iForm.RectPartiallyVisible(rect))
|
|
472 |
{
|
|
473 |
return iItems[idx];
|
|
474 |
}
|
|
475 |
}
|
|
476 |
}
|
|
477 |
return NULL;
|
|
478 |
}
|
|
479 |
|
|
480 |
CMIDControlItem* CMIDFormRow::FirstFocusableItem()
|
|
481 |
{
|
|
482 |
TInt idx = -1;
|
|
483 |
while (++idx < iItems.Count())
|
|
484 |
{
|
|
485 |
if (iItems[idx]->IsSelectable())
|
|
486 |
{
|
|
487 |
return iItems[idx];
|
|
488 |
}
|
|
489 |
}
|
|
490 |
return NULL;
|
|
491 |
}
|
|
492 |
|
|
493 |
CMIDControlItem* CMIDFormRow::LastFocusableItem()
|
|
494 |
{
|
|
495 |
TInt idx = iItems.Count();
|
|
496 |
while (--idx >= 0)
|
|
497 |
{
|
|
498 |
if (iItems[idx]->IsSelectable())
|
|
499 |
{
|
|
500 |
return iItems[idx];
|
|
501 |
}
|
|
502 |
}
|
|
503 |
return NULL;
|
|
504 |
}
|
|
505 |
|
|
506 |
// typically just used when cleaning up. This won't cause a layout.
|
|
507 |
TBool CMIDFormRow::RemoveItemIfExists(CMIDControlItem& aItem)
|
|
508 |
{
|
|
509 |
TInt i = -1;
|
|
510 |
while (++i < iItems.Count())
|
|
511 |
{
|
|
512 |
if (&aItem == iItems[i])
|
|
513 |
{
|
|
514 |
iItems.Remove(i);
|
|
515 |
return ETrue;
|
|
516 |
}
|
|
517 |
}
|
|
518 |
|
|
519 |
return EFalse;
|
|
520 |
}
|
|
521 |
|
|
522 |
TInt CMIDFormRow::CurrentWidth()
|
|
523 |
{
|
|
524 |
return iCurrentWidth;
|
|
525 |
}
|
|
526 |
|
|
527 |
CMIDFormRow::CMIDFormRow(CMIDForm& aForm)
|
|
528 |
:iForm(aForm)
|
|
529 |
{
|
|
530 |
#ifdef RD_SCALABLE_UI_V2
|
|
531 |
SetAllowStrayPointers();
|
|
532 |
#endif // RD_SCALABLE_UI_V2
|
|
533 |
}
|
|
534 |
|
|
535 |
void CMIDFormRow::ConstructL()
|
|
536 |
{
|
|
537 |
}
|
|
538 |
|
|
539 |
/**
|
|
540 |
* Returns true if this row has at least an item which is not a spacer
|
|
541 |
*/
|
|
542 |
TBool CMIDFormRow::HasNonSpacerItems() const
|
|
543 |
{
|
|
544 |
TBool ret = EFalse;
|
|
545 |
|
|
546 |
TInt i = -1;
|
|
547 |
while (++i < iItems.Count())
|
|
548 |
{
|
|
549 |
if (iItems[i]->Type() != MMIDComponent::ESpacer)
|
|
550 |
{
|
|
551 |
ret = ETrue;
|
|
552 |
break;
|
|
553 |
}
|
|
554 |
}
|
|
555 |
|
|
556 |
return ret;
|
|
557 |
}
|
|
558 |
|
|
559 |
#ifdef RD_JAVA_S60_RELEASE_9_2
|
|
560 |
void CMIDFormRow::SetSeparator()
|
|
561 |
{
|
|
562 |
// Separator is not drawn above the first row.
|
|
563 |
if (iForm.FormRowIndex(this) <= 0)
|
|
564 |
{
|
|
565 |
iSeparator = EFalse;
|
|
566 |
return;
|
|
567 |
}
|
|
568 |
else
|
|
569 |
{
|
|
570 |
iSeparator = ETrue;
|
|
571 |
}
|
|
572 |
|
|
573 |
// Separator is not drawn if the rows includes only spacers
|
|
574 |
if (!HasNonSpacerItems())
|
|
575 |
{
|
|
576 |
iSeparator = EFalse;
|
|
577 |
return;
|
|
578 |
}
|
|
579 |
|
|
580 |
if (Item(0)->HasLabel())
|
|
581 |
{
|
|
582 |
iSeparator = ETrue;
|
|
583 |
return;
|
|
584 |
}
|
|
585 |
else
|
|
586 |
{
|
|
587 |
// If the first item is other than StringItem then draw separator.
|
|
588 |
if (!CMIDForm::IsLabelContainerItem(*Item(0)))
|
|
589 |
{
|
|
590 |
iSeparator = ETrue;
|
|
591 |
return;
|
|
592 |
}
|
|
593 |
else
|
|
594 |
{
|
|
595 |
// If Button type StringItem then separator is drawn.
|
|
596 |
if (CMIDForm::IsStringItemButton(*Item(0)))
|
|
597 |
{
|
|
598 |
iSeparator = ETrue;
|
|
599 |
return;
|
|
600 |
}
|
|
601 |
|
|
602 |
CMIDLabelContainerItem* ucsi = static_cast<CMIDLabelContainerItem*>(Item(0));
|
|
603 |
// If the first item is label, then draw separator.
|
|
604 |
if (ucsi && !ucsi->IsStringItemContent())
|
|
605 |
{
|
|
606 |
iSeparator = ETrue;
|
|
607 |
return;
|
|
608 |
}
|
|
609 |
else
|
|
610 |
{
|
|
611 |
// If the last item in the previous row is StringItem,
|
|
612 |
// then do not draw separator.
|
|
613 |
TInt prevRowIndex = iForm.FormRowIndex(this) - 1;
|
|
614 |
if (prevRowIndex >= 0)
|
|
615 |
{
|
|
616 |
CMIDFormRow* prevRow = iForm.FormRow(prevRowIndex);
|
|
617 |
TInt index = 0;
|
|
618 |
if (prevRow)
|
|
619 |
{
|
|
620 |
index = prevRow->NumItems();
|
|
621 |
|
|
622 |
// If there are items in previous row check if row is StrinItem
|
|
623 |
if (index >= 1)
|
|
624 |
{
|
|
625 |
CMIDControlItem* lastPrevItem = prevRow->Item(index - 1);
|
|
626 |
|
|
627 |
if (lastPrevItem && CMIDForm::IsLabelContainerItem(*lastPrevItem))
|
|
628 |
{
|
|
629 |
iSeparator = EFalse;
|
|
630 |
return;
|
|
631 |
}
|
|
632 |
else
|
|
633 |
{
|
|
634 |
iSeparator = ETrue;
|
|
635 |
return;
|
|
636 |
}
|
|
637 |
}
|
|
638 |
else
|
|
639 |
{
|
|
640 |
iSeparator = ETrue;
|
|
641 |
return;
|
|
642 |
}
|
|
643 |
}
|
|
644 |
}
|
|
645 |
}
|
|
646 |
}
|
|
647 |
}
|
|
648 |
}
|
|
649 |
#endif // RD_JAVA_S60_RELEASE_9_2
|
|
650 |
// End of File
|