javauis/lcdui_akn/lcdui/src/CMIDForm.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 19 Aug 2010 09:48:13 +0300
branchRCL_3
changeset 24 6c158198356e
parent 23 e5618cc85d74
permissions -rw-r--r--
Revision: v2.2.9 Kit: 201033
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     1
/*
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies).
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     8
*
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    11
*
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    12
* Contributors:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    13
*
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    14
* Description:  Implements the Form LCDUI component.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    15
*
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    16
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    17
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    18
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    19
//RD_SCALABLE_UI definition
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    20
#include <bldvariant.hrh>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    21
// using CEikScrollBarFrame API for iSBFrame
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    22
#include <eiksbfrm.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    23
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    24
// API used for retrieving layout for initial alignment (in ConstructL)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    25
#include <centralrepository.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    26
// constants used in retrieving layout for initial alignment (in ConstructL)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    27
#include <AvkonInternalCRKeys.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    28
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    29
// control context that provides a layout background
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    30
#include <AknsListBoxBackgroundControlContext.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    31
// highlight background
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    32
#include <AknsFrameBackgroundControlContext.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    33
// API for text formatting used in DrawNoDataStringL function
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    34
#include <AknBidiTextUtils.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    35
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    36
#include "CMIDForm.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    37
#include "CMIDFormRow.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    38
// API for iDisplayable
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    39
#include "CMIDDisplayable.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    40
#include "CMIDItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    41
#include "CMIDControlItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    42
#include "CMIDGaugeItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    43
#include "CMIDImageItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    44
#include "CMIDStringItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    45
// CMIDLabelContainerItem API used to obtain CMIDStringItem item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    46
#include "CMIDLabelContainerItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    47
#include "CMIDTextFieldItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    48
#include "CMIDChoiceGroupItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    49
#include "CMIDSpacer.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    50
#include "CMIDCustomItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    51
#include "CMIDDateFieldItem.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    52
#include "CMIDComponentFactory.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    53
#include "CMIDUtils.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    54
#include "CMIDItemLabel.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    55
#include "CMIDTicker.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    56
#include "CMIDFont.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    57
#include "CMIDPopupNoteController.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    58
// Kinetic scrolling
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    59
#include "CMIDFormPhysics.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    60
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    61
#include <applayout.cdl.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    62
// LAF
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    63
#include <aknlayoutscalable_avkon.cdl.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    64
// LAF
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    65
#include <layoutmetadata.cdl.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    66
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    67
// Api for skin layout
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    68
#include <skinlayout.cdl.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    69
using namespace SkinLayout;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    70
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    71
#include <j2me/jdebug.h>
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    72
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    73
#undef  TRAP_INSTRUMENTATION_LEAVE
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    74
#define TRAP_INSTRUMENTATION_LEAVE(aResult) DEBUG_INT2("In CMIDForm.cpp, trapped method was called at line %D and got exception %D", __LINE__, aResult);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    75
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    76
#ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    77
/** Dividers used when the the scroll amount is calculated*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    78
const TInt KScrollAmountDivider = 4;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    79
const TInt KScrollAmountDividerForThumbDrag = 10;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    80
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    81
/** Interval for scrolling when stylus is dragged outside the form and held down */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    82
const TInt KScrollInterval = 100000; // 0,1 sec
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    83
#endif //RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    84
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    85
/** The minimum amount to scroll */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    86
const TInt KMinScrollAmount = 40;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    87
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    88
/** The timeout in microseconds for visual updates. When items are added or removed
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    89
or modified, the form is not redrawn immediately but only after this timeout. This way
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    90
if more items are being added or removed or changed we reduce the number of redraws.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    91
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    92
const TInt KLayoutTimeout = 60000; //60 msecs
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    93
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    94
/** If layout has been requested for a period longer than the cap then perform layout
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    95
even if the midlet is still performing form insert/delete operations. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    96
const TInt KLayoutCap = 1000000; // 1 sec
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    97
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    98
///////////////////////////////////////////////////////////////////////////////////////////////////
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
    99
// MMIDForm interface
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   100
///////////////////////////////////////////////////////////////////////////////////////////////////
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   101
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   102
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   103
 * Add items list. Note: this is no longer called by framework!!
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   104
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   105
void CMIDForm::SetAllItemsL(const RArray<MMIDItem*>& aItems)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   106
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   107
    DEBUG("CMIDForm::SetAllItemsL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   108
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   109
    ASSERT(iItems.Count() == 0);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   110
    //
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   111
    TInt count = aItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   112
    for (TInt i=0; i<count; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   113
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   114
        User::LeaveIfError(iItems.Append(aItems[i]));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   115
        CMIDControlItem& ci = ControlItem(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   116
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   117
        AddItemToFormL(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   118
        ci.MakeVisible(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   119
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   120
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   121
    RequestLayoutL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   122
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   123
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   124
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   125
 * Replaces an item. Keeps the same item focused which had focus before,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   126
 * and if that's the one that this is replacing, then this will be focused
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   127
 * if possible.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   128
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   129
void CMIDForm::SetItemL(MMIDItem& aItem,TInt aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   130
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   131
    DEBUG("CMIDForm::SetItemL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   132
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   133
    CMIDControlItem& oldCi = ControlItem(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   134
    RemoveItemFromForm(oldCi);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   135
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   136
    iItems[aIndex] = &aItem;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   137
    CMIDControlItem& ci = ControlItem(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   138
    AddItemToFormL(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   139
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   140
    ci.MakeVisible(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   141
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   142
    if (iFocused == aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   143
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   144
        iDisplayable.MenuHandler()->HideMenuIfVisible();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   145
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   146
        if (ci.IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   147
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   148
            SetFocusedItem(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   149
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   150
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   151
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   152
            SetFocusedItem(KErrNotFound);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   153
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   154
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   155
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   156
    RequestLayoutL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   157
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   158
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   159
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   160
 * Inserts a new Item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   161
 */
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   162
void CMIDForm::InsertItemL(MMIDItem& aItem, TInt aIndex)
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   163
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   164
    DEBUG("CMIDForm::InsertItemL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   165
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   166
    User::LeaveIfError(iItems.Insert(&aItem,aIndex));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   167
    CMIDControlItem& ci = ControlItem(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   168
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   169
    AddItemToFormL(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   170
    ci.MakeVisible(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   171
    // if insert item then index of pointed control is increase
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   172
    if (aIndex <= iIndexPointedControl)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   173
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   174
        iIndexPointedControl++;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   175
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   176
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   177
    // If there isn't any focused item yet, we have to set focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   178
    // to first item which is focusable. Once the item has focus,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   179
    // we can skip this step.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   180
    if (iFocused == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   181
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   182
        SetFocusedItem(ci.IsSelectable() ? aIndex : KErrNotFound);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   183
    }
23
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   184
    else if (aIndex <= iFocused)
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   185
    {
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   186
        // If new item is inserted to Form above the current item,
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   187
        // index must increase
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   188
        iFocused++;
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
   189
    }
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   190
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   191
    RequestLayoutL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   192
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   193
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   194
void CMIDForm::DeleteItemL(TInt aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   195
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   196
    DEBUG("CMIDForm::DeleteItemL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   197
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   198
    TBool updateFocused = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   199
    // if delete item then index of pointed control is decrease
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   200
    if (iIndexPointedControl > aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   201
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   202
        iIndexPointedControl--;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   203
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   204
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   205
        // if delete item is same as index of pointed control then index is set to not active
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   206
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   207
        if (iIndexPointedControl == aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   208
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   209
            iIndexPointedControl = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   210
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   211
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   212
    if (iFocused > aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   213
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   214
        iFocused--;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   215
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   216
    else if (iFocused == aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   217
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   218
        iDisplayable.MenuHandler()->HideMenuIfVisible();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   219
        ReplaceFocusedItem();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   220
        updateFocused = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   221
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   222
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   223
    CMIDControlItem& ci = ControlItem(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   224
    RemoveItemFromForm(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   225
    if (&ci == iPointedControl)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   226
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   227
        iPointedControl = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   228
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   229
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   230
    iItems.Remove(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   231
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   232
    if (iFocused != KErrNotFound && updateFocused)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   233
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   234
        iFocused--;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   235
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   236
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   237
    RequestLayoutL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   238
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   239
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   240
void CMIDForm::DeleteAllItemsL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   241
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   242
    DEBUG("CMIDForm::DeleteAllItemsL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   243
    iDisplayable.MenuHandler()->HideMenuIfVisible();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   244
    SetFocusedItem(KErrNotFound);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   245
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   246
    TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   247
    for (TInt i=0; i < itemCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   248
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   249
        CMIDControlItem& ci = ControlItem(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   250
        RemoveItemFromForm(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   251
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   252
    iItems.Reset();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   253
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   254
    iScroll = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   255
    // if delete all then index of pointed control is set to not active
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   256
    iIndexPointedControl = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   257
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   258
    iPointedControl = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   259
    RequestLayoutL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   260
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   261
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   262
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   263
 * Called when the item has changed its appearance in some way.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   264
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   265
void CMIDForm::RefreshItemL(TInt aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   266
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   267
    DEBUG("CMIDForm::RefreshItemL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   268
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   269
    if (aIndex != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   270
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   271
        RequestLayoutL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   272
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   273
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   274
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   275
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   276
 * Returns whether the item is actually visible to the user. Must therefore take into
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   277
 * account the visibility of the entire form, and whether the specific item is scrolled
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   278
 * in/out of the viewable area.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   279
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   280
TBool CMIDForm::IsItemVisible(TInt aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   281
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   282
    DEBUG("CMIDForm::IsItemVisible");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   283
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   284
    CMIDControlItem& control = ControlItem(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   285
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   286
    if ((control.Position().iY > Height()) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   287
            ((control.Position().iY + control.Size().iHeight) < 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   288
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   289
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   290
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   291
    return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   292
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   293
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   294
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   295
 * Called prior to the Form itself being made the current Displayable.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   296
 * It provides an opportunity to prepare the form such that this item will
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   297
 * be visible and focused when the form is eventually made current
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   298
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   299
void CMIDForm::SetCurrentItemL(TInt aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   300
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   301
    DEBUG("CMIDForm::SetCurrentItemL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   302
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   303
    // If it is pending request for layout, than layout now.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   304
    if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   305
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   306
        LayoutAndDrawL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   307
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   308
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   309
    // Set focus of item to aIndex and scroll to it.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   310
    SetFocusedItem(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   311
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   312
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   313
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   314
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   315
//
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   316
// End of MMIDForm interface
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   317
//
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   318
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   319
TInt CMIDForm::CountComponentControls() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   320
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   321
    return iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   322
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   323
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   324
CCoeControl* CMIDForm::ComponentControl(TInt aIndex) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   325
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   326
    return iRows[aIndex];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   327
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   328
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   329
TKeyResponse CMIDForm::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   330
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   331
    DEBUG("< CMIDForm::OfferKeyEventL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   332
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   333
    TBool isArrowKey = (aKeyEvent.iCode == EKeyDownArrow || aKeyEvent.iCode == EKeyUpArrow ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   334
                        aKeyEvent.iCode == EKeyLeftArrow || aKeyEvent.iCode == EKeyRightArrow);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   335
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   336
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   337
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   338
        CMIDControlItem& controlItem = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   339
        TRect controlRect = GetControlRect(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   340
        TBool visible = RectPartiallyVisible(controlRect);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   341
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   342
#ifdef RD_JAVA_S60_RELEASE_9_2
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   343
        TInt numItemCommands = controlItem.CommandList()->Count();
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   344
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   345
        // If focused form item does not have any commands,
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   346
        // and select key was pressed try to show screen\help option menu.
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   347
        // ChoiceGroup and DateField handles this case separately.
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   348
        // Gauge enter key is also handled here,
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   349
        // so it would behave the same way as selection key.
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   350
        if (numItemCommands == 0 && aType == EEventKey &&
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   351
                controlItem.Type() != MMIDComponent::EChoiceGroup &&
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   352
                controlItem.Type() != MMIDComponent::EDateField &&
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   353
                (aKeyEvent.iScanCode == EStdKeyDevice3 ||
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   354
                 (aKeyEvent.iScanCode == EStdKeyEnter &&
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   355
                  controlItem.Type() == MMIDComponent::EGauge)))
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   356
        {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   357
            iDisplayable.ShowScreenOrHelpOptionsMenuL();
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   358
        }
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   359
#endif // RD_JAVA_S60_RELEASE_9_2
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
   360
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   361
        // arrow key events are not sent to the hidden focused item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   362
        if ((visible || !isArrowKey) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   363
                controlItem.OfferKeyEventL(aKeyEvent,aType) == EKeyWasConsumed)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   364
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   365
            DEBUG("CMIDForm::OfferKeyEventL - out after item consumed key");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   366
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   367
#ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   368
            // If focused TextField or DateField item is at least partly out of
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   369
            // Form viewport, then key event (excluding arrow keys and soft keys)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   370
            // scrolls the item completely visible. This situation
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   371
            // is possible when scrolling has been done with scrollbar.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   372
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   373
            // Soft keys and arrow keys are ignored. Filtering must be done comparing
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   374
            // scan codes because the aEventType.iCode is not available for all key presses.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   375
            TBool ignoreKey = (aKeyEvent.iScanCode == EStdKeyRightArrow ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   376
                               aKeyEvent.iScanCode == EStdKeyUpArrow ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   377
                               aKeyEvent.iScanCode == EStdKeyDownArrow ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   378
                               aKeyEvent.iScanCode == EStdKeyLeftArrow ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   379
                               aKeyEvent.iScanCode == EStdKeyDevice0 ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   380
                               aKeyEvent.iScanCode == EStdKeyDevice1 ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   381
                               aKeyEvent.iScanCode == EStdKeyDevice3);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   382
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   383
            if ((controlItem.Type() == MMIDComponent::ETextField ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   384
                    controlItem.Type() == MMIDComponent::EDateField) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   385
                    !RectFullyVisible(controlRect) && !ignoreKey)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   386
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   387
                // Scroll up if controlItem is above the Form viewport.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   388
                // Otherwise scroll down.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   389
                if (controlRect.iTl.iY < 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   390
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   391
                    ScrollToFocused(EUp, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   392
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   393
                else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   394
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   395
                    ScrollToFocused(EDown, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   396
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   397
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   398
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   399
#endif // RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   400
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   401
            return EKeyWasConsumed;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   402
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   403
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   404
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   405
    DEBUG("CMIDForm::OfferKeyEventL - got chance to scroll");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   406
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   407
    if ((aType == EEventKey) && isArrowKey && (iItems.Count() > 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   408
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   409
        DEBUG("CMIDForm::OfferKeyEventL - about to call Traverse");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   410
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   411
        Traverse(ConvertKeyToDirection(aKeyEvent.iCode));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   412
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   413
        DEBUG("CMIDForm::OfferKeyEventL - out after Traverse");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   414
        return EKeyWasConsumed;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   415
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   416
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   417
    // msk: this is needed if MSK is not enabled
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   418
    if ((aType == EEventKey) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   419
            ((aKeyEvent.iScanCode == EStdKeyDevice3) || (aKeyEvent.iCode == EKeyEnter))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   420
       )
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   421
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   422
        if (!DoDefaultCommand())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   423
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   424
            iDisplayable.ShowOkOptionsMenuL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   425
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   426
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   427
        DEBUG("CMIDForm::OfferKeyEventL - out after default command or ok menu");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   428
        return EKeyWasConsumed;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   429
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   430
    // end msk
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   431
    DEBUG("> CMIDForm::OfferKeyEventL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   432
    return EKeyWasNotConsumed;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   433
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   434
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   435
/**  Handle a focus change. Make sure there is no layout pending and if there is
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   436
one then do it, see TrappedLayoutAndDraw(). This is because when there is a layout
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   437
pending we are in a temporary inconsistent phase with no rows and the rows are the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   438
intermediary to the items via the CountComponentControl() and ComponentControl() calls.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   439
Then pass on focus to our children according to the value stored in iFocused. Finally
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   440
update the scroll bars if gaining focus and draw. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   441
void CMIDForm::FocusChanged(TDrawNow /*aDrawNow*/)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   442
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   443
    DEBUG("CMIDForm::FocusChanged");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   444
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   445
    TrappedLayoutAndDraw(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   446
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   447
    TInt i = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   448
    TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   449
    while (++i < itemCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   450
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   451
        if (i == iFocused)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   452
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   453
            ControlItem(iFocused).SetFocus(IsFocused());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   454
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   455
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   456
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   457
            ControlItem(i).SetFocus(EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   458
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   459
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   460
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   461
    // make sure scrollbar is up to date when we get focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   462
    if (IsFocused())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   463
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   464
        UpdateScrollBar();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   465
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   466
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   467
    DrawNow();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   468
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   469
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   470
void CMIDForm::SizeChanged()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   471
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   472
    DEBUG("CMIDForm::SizeChanged");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   473
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   474
    iBackgroundControlContext->SetParentPos(PositionRelativeToScreen()) ;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   475
    iBackgroundControlContext->SetRect(Rect()) ;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   476
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   477
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   478
/** Before calling CCoeControl::InputCapabilities(), make sure there is
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   479
no outstanding layout. This is because if there is one outstanding, we have
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   480
no rows and hence ComponentControls() returns zero. This means that, for example
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   481
if there are any editors in the items, CCoeControl::InputCapabilities() will not
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   482
reach them and the FEP will not be initialised. @see TrappedLayoutAndDraw(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   483
CCoeControl::InputCapabilities(), CAknFepManager::HandleChangeInFocusL() and
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   484
CCoeAppUi::InputCapabilities() */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   485
TCoeInputCapabilities CMIDForm::InputCapabilities() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   486
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   487
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   488
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   489
        return ControlItem(iFocused).InputCapabilities();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   490
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   491
    return     CCoeControl::InputCapabilities(); //TCoeInputCapabilities::ENone
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   492
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   493
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   494
TTypeUid::Ptr CMIDForm::MopSupplyObject(TTypeUid aId)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   495
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   496
    if (aId.iUid == MAknsControlContext::ETypeId && iBackgroundControlContext)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   497
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   498
        return MAknsControlContext::SupplyMopObject(aId, iBackgroundControlContext);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   499
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   500
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   501
    CMIDMenuHandler* menuHandler = iDisplayable.MenuHandler();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   502
    return SupplyMopObject(aId, menuHandler->Cba(), menuHandler->MenuBar());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   503
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   504
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   505
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   506
#ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   507
void CMIDForm::HandlePointerEventL(const TPointerEvent& aPointerEvent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   508
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   509
    if (!AknLayoutUtils::PenEnabled())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   510
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   511
        return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   512
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   513
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   514
    if (iPhysics)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   515
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   516
        HandlePhysicsPointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   517
        return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   518
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   519
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   520
    switch (aPointerEvent.iType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   521
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   522
    case TPointerEvent::EButton1Down:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   523
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   524
        DEBUG_INT3("CMIDForm::HandlePointerEventL(): event=%D, x,y=%D,%D",
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   525
                   aPointerEvent.iType, aPointerEvent.iPosition.iX, aPointerEvent.iPosition.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   526
        iLastValidPointerEvent = aPointerEvent;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   527
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   528
        CMIDControlItem* ci = ControlItemAtPoint(aPointerEvent.iPosition);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   529
        // stored on ButtonDown value
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   530
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   531
        if (ci && ci->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   532
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   533
            TInt itemIndex = ItemIndex(*ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   534
            iIndexPointedControl = itemIndex;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   535
            iLastValidPointedItemPosition = ci->Position();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   536
            TBool changeFocus = (itemIndex != iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   537
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   538
            if (changeFocus)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   539
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   540
                // changing the focused item by dragging must start from unfocused item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   541
                iCanDragFocus = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   542
                iFocusChangingWithPen = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   543
                // give basic tactile feedback on button down when move focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   544
#ifdef RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   545
                DoFeedbackOnFocusChange(*ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   546
#endif // RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   547
                SetFocusedItem(itemIndex, ENone, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   548
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   549
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   550
            TInt scroll = ScrollDistanceToTappedItem(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   551
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   552
            iScrollOnPointerDown = (scroll != 0);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   553
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   554
            CCoeControl::HandlePointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   555
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   556
            if (iScrollOnPointerDown)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   557
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   558
                ScrollRelative(scroll);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   559
                ControlItem(iFocused).NotifyScrollingCompleted();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   560
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   561
            else if (changeFocus)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   562
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   563
                HandleItemVisibilityChange();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   564
                DrawNow();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   565
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   566
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   567
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   568
                iCanDragFocus = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   569
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   570
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   571
        else // pointer down did not happen on any control item, allow starting drag
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   572
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   573
            iCanDragFocus = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   574
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   575
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   576
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   577
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   578
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   579
    case TPointerEvent::EButton1Up:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   580
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   581
        if (iIndexPointedControl>-1 && &ControlItem(iIndexPointedControl) == ControlItemAtPoint(aPointerEvent.iPosition))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   582
            // When this is item where TPointerEvent::EButton1Down was happened,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   583
            // then event is forwarded to item. It is its responsibility check that
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   584
            // up event occured if it have some actions on up event.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   585
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   586
            DEBUG_INT3("CMIDForm::HandlePointerEventL(): event=%D, x,y=%D,%D",
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   587
                       aPointerEvent.iType, aPointerEvent.iPosition.iX, aPointerEvent.iPosition.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   588
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   589
            HandleDragEventL(aPointerEvent, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   590
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   591
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   592
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   593
            // When this is not item where TPointerEvent::EButton1Down was happened,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   594
            // then e`vent is forwarded to item where originally. It is its responsibility
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   595
            // check that up event occured if it have some actions on up event.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   596
            // Setting default values of related variables.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   597
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   598
            if (iIndexPointedControl>-1 && &ControlItem(iIndexPointedControl))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   599
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   600
                TBool bbutton = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   601
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   602
                if (IsStringItem(ControlItem(iIndexPointedControl)))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   603
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   604
                    // get appearance from StringItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   605
                    CMIDStringItem *strItem = static_cast< CMIDStringItem* >(&ControlItem(iIndexPointedControl));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   606
                    MMIDItem::TAppearance appearance = strItem->Appearance();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   607
                    bbutton = (appearance == MMIDItem::EButton || appearance == MMIDItem::EHyperLink);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   608
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   609
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   610
                if (ControlItem(iIndexPointedControl).Type() != MMIDComponent::EChoiceGroup && !bbutton)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   611
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   612
                    TPointerEvent pointerevent;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   613
                    pointerevent.iType = TPointerEvent::EButton1Up;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   614
                    pointerevent.iModifiers = aPointerEvent.iModifiers;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   615
                    pointerevent.iPosition = iLastValidPointerEvent.iPosition +
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   616
                                             ControlItem(iIndexPointedControl).Position() - iLastValidPointedItemPosition;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   617
                    pointerevent.iParentPosition = iLastValidPointerEvent.iParentPosition;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   618
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   619
                    ControlItem(iIndexPointedControl).HandlePointerEventL(pointerevent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   620
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   621
                    DEBUG_INT3("CMIDForm::HandlePointerEventL(): event=%D, x,y=%D,%D",
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   622
                               pointerevent.iType, pointerevent.iPosition.iX, pointerevent.iPosition.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   623
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   624
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   625
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   626
                // forward event for aPointerEvent
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   627
                CCoeControl::HandlePointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   628
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   629
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   630
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   631
        // If it is pending request for layout, than layout form now and refresh.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   632
        if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   633
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   634
            LayoutFormL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   635
            DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   636
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   637
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   638
        iCanDragFocus = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   639
        iFocusChangingWithPen = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   640
        iScrollOnPointerDown = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   641
        iIndexPointedControl = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   642
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   643
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   644
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   645
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   646
    case TPointerEvent::EDrag:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   647
        // for dragging
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   648
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   649
        if (iIndexPointedControl>-1 && &ControlItem(iIndexPointedControl) == ControlItemAtPoint(aPointerEvent.iPosition))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   650
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   651
            // When this is item where TPointerEvent::EButton1Down was happened,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   652
            // then it is updated iLastValidPointerEvent.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   653
            iLastValidPointerEvent = aPointerEvent;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   654
            // If it is pending request for layout, than layout Form now and refresh
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   655
            // elsewhere call HandleDragEventL and forward EDrag events to event.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   656
            if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   657
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   658
                LayoutFormL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   659
                DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   660
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   661
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   662
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   663
                HandleDragEventL(aPointerEvent, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   664
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   665
            DEBUG_INT3("CMIDForm::HandlePointerEventL(): event=%D, x,y=%D,%D",
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   666
                       aPointerEvent.iType, aPointerEvent.iPosition.iX,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   667
                       aPointerEvent.iPosition.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   668
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   669
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   670
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   671
            // When this is not item where TPointerEvent::EButton1Down was happened,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   672
            // then we do only dragging. There it is not send event to item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   673
            HandleDragEventL(aPointerEvent, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   674
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   675
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   676
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   677
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   678
    case TPointerEvent::EButtonRepeat:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   679
        // For button repeating
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   680
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   681
        DEBUG_INT3("CMIDForm::HandlePointerEventL(): event=%D, x,y=%D,%D",
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   682
                   aPointerEvent.iType, aPointerEvent.iPosition.iX,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   683
                   aPointerEvent.iPosition.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   684
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   685
        RequestPointerRepeat(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   686
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   687
        if (iCanDragFocus)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   688
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   689
            if (aPointerEvent.iPosition.iY < 0  && CanScrollUp())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   690
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   691
                TimedScroll(EUp);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   692
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   693
            else if (aPointerEvent.iPosition.iY > Height() && CanScrollDown())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   694
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   695
                TimedScroll(EDown);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   696
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   697
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   698
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   699
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   700
            CCoeControl::HandlePointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   701
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   702
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   703
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   704
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   705
    default:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   706
        // By defalt only implementation of base class.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   707
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   708
        CCoeControl::HandlePointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   709
        DEBUG_INT3("CMIDForm::HandlePointerEventL(): event=%D, x,y=%D,%D",
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   710
                   aPointerEvent.iType, aPointerEvent.iPosition.iX,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   711
                   aPointerEvent.iPosition.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   712
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   713
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   714
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   715
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   716
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   717
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   718
void CMIDForm::HandleDragEventL(const TPointerEvent& aPointerEvent, TBool aForItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   719
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   720
    RequestPointerRepeat(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   721
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   722
    if (iCanDragFocus)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   723
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   724
        // formRect covers the whole vertical form area, but excludes
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   725
        // the left and right margins and the scroll bar area
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   726
        TRect formRect(TPoint(iFormRect.Rect().iTl.iX, 0),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   727
                       TPoint(iFormRect.Rect().iBr.iX, Height()));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   728
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   729
        // Try to find the new focused item, if needed
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   730
        if (formRect.Contains(aPointerEvent.iPosition) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   731
                !FocusedItemContainsPoint(aPointerEvent.iPosition))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   732
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   733
            CMIDControlItem* ci = ControlItemAtPoint(aPointerEvent.iPosition);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   734
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   735
            if (ci && ci->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   736
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   737
                TInt itemIndex = ItemIndex(*ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   738
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   739
                // Find the direction to which the focus is dragged
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   740
                TDirection direction = ENone;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   741
                if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   742
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   743
                    TRect rect = ControlItem(iFocused).Rect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   744
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   745
                    if (aPointerEvent.iPosition.iY < rect.iTl.iY)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   746
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   747
                        direction = EUp;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   748
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   749
                    else if (aPointerEvent.iPosition.iY >= rect.iBr.iY)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   750
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   751
                        direction = EDown;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   752
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   753
                    else // focus is moved horizontally
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   754
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   755
                        direction = (itemIndex < iFocused) ? ELeft : ERight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   756
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   757
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   758
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   759
#ifdef RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   760
                if (iFocused != itemIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   761
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   762
                    iFeedback->InstantFeedback(ETouchFeedbackSensitive);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   763
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   764
#endif
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   765
                SetFocusedItem(itemIndex, direction, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   766
                HandleItemVisibilityChange();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   767
                DrawNow();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   768
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   769
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   770
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   771
        if (FocusedItemContainsPoint(aPointerEvent.iPosition))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   772
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   773
            // forward EDrag events to the focused so that the focus can
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   774
            // move inside the item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   775
            // (only when this is item where TPointerEvent::EButton1Down was occured)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   776
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   777
            CMIDControlItem* focusedControl = ControlItemAtPoint(aPointerEvent.iPosition);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   778
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   779
            if (aForItem || (iIndexPointedControl > -1 && &ControlItem(iIndexPointedControl) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   780
                             (IsChoiceGroup(ControlItem(iIndexPointedControl)) || IsCustomItem(ControlItem(iIndexPointedControl)))) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   781
                    focusedControl && IsChoiceGroup(*focusedControl) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   782
                    focusedControl && IsCustomItem(*focusedControl))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   783
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   784
                ControlItem(iFocused).HandlePointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   785
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   786
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   787
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   788
                if (iIndexPointedControl > -1 && &ControlItem(iIndexPointedControl))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   789
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   790
                    TBool bbutton = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   791
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   792
                    if (IsStringItem(ControlItem(iIndexPointedControl)))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   793
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   794
                        CMIDStringItem *strItem = static_cast< CMIDStringItem* >(&ControlItem(iIndexPointedControl));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   795
                        MMIDItem::TAppearance appearance = strItem->Appearance();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   796
                        bbutton = (appearance == MMIDItem::EButton || appearance == MMIDItem::EHyperLink);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   797
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   798
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   799
                    //forward event (only for changing focus) for Button & Hyperlink
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   800
                    if (bbutton && &ControlItem(iIndexPointedControl))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   801
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   802
                        ControlItem(iIndexPointedControl).HandlePointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   803
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   804
                    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   805
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   806
                        iDisplayable.TryDetectLongTapL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   807
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   808
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   809
                else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   810
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   811
                    iDisplayable.TryDetectLongTapL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   812
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   813
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   814
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   815
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   816
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   817
            // make sure that long tap animation is canceled in this case
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   818
            iDisplayable.TryDetectLongTapL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   819
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   820
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   821
    else // cannot drag focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   822
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   823
        CCoeControl::HandlePointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   824
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   825
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   826
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   827
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   828
void CMIDForm::RequestPointerRepeat(const TPointerEvent& aPointerEvent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   829
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   830
    if (aPointerEvent.iPosition.iY < 0 ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   831
            aPointerEvent.iPosition.iY > Height())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   832
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   833
        TRect screen;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   834
        AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screen);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   835
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   836
        TRect repeatRect = screen;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   837
        if (aPointerEvent.iPosition.iY < 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   838
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   839
            repeatRect.iBr.iY = iMidpFormRect.Rect().iTl.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   840
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   841
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   842
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   843
            repeatRect.iTl.iY = iMidpFormRect.Rect().iBr.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   844
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   845
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   846
        // repeatRect must be given in propotion to form's window, move it up
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   847
        repeatRect.Move(0, -iMidpFormRect.Rect().iTl.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   848
        Window().RequestPointerRepeatEvent(KScrollInterval, repeatRect);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   849
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   850
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   851
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   852
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   853
void CMIDForm::TimedScroll(TDirection aDirection)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   854
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   855
    ASSERT(aDirection == EDown || aDirection == EUp);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   856
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   857
    // First find the row that is the first or last row (depending on
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   858
    // the scroll direction) that is at least partailly visible on the form.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   859
    // Search direction is opposite to aDirection.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   860
    TDirection searchDirection = (aDirection == EUp) ? EDown : EUp;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   861
    TInt idx = FirstRowOnScreen(searchDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   862
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   863
    if (idx == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   864
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   865
        return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   866
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   867
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   868
    TInt scroll = Height() / KScrollAmountDividerForThumbDrag;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   869
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   870
    // Find the row that will be visible (at least partially) after
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   871
    // after the scrolling.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   872
    if (aDirection == EUp)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   873
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   874
        while (idx > 0 && (iRows[idx]->Rect().iTl.iY + scroll > 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   875
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   876
            --idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   877
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   878
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   879
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   880
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   881
        while ((idx < iRows.Count() - 1) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   882
                (iRows[idx]->Rect().iBr.iY - scroll < Height()))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   883
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   884
            ++idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   885
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   886
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   887
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   888
    TBool rowFocused = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   889
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   890
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   891
        rowFocused = GetControlRect(iFocused).Intersects(iRows[idx]->Rect());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   892
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   893
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   894
    // If the focus is not yet on the row, try to set one of its items focused
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   895
    if (!rowFocused)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   896
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   897
        for (TInt i = 0; i < iRows[idx]->NumItems(); ++i)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   898
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   899
            CMIDControlItem* item = iRows[idx]->Item(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   900
            if (item->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   901
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   902
                SetFocusedItem(ItemIndex(*item), aDirection, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   903
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   904
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   905
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   906
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   907
#ifdef RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   908
    iFeedback->InstantFeedback(ETouchFeedbackSensitive);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   909
#endif
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   910
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   911
    ScrollRelative((aDirection == EUp) ? scroll : -scroll);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   912
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   913
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   914
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   915
TBool CMIDForm::CanScrollUp() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   916
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   917
    return (iScroll < 0);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   918
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   919
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   920
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   921
TBool CMIDForm::CanScrollDown() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   922
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   923
    return ((iFormHeight - iScroll) < iTotalFormHeight);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   924
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   925
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   926
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   927
TBool CMIDForm::FocusedItemContainsPoint(const TPoint& aPoint) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   928
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   929
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   930
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   931
        if (ItemIsUnconstrained(iFocused))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   932
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   933
            return StringItemContainsPoint(
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   934
                       static_cast<CMIDStringItem*>(&ControlItem(iFocused)), aPoint);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   935
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   936
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   937
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   938
            return ControlItem(iFocused).Rect().Contains(aPoint);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   939
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   940
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   941
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   942
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   943
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   944
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   945
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   946
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   947
CMIDControlItem* CMIDForm::ControlItemAtPoint(const TPoint& aPoint) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   948
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   949
    TInt idx = RowAtPoint(aPoint);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   950
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   951
    if (idx != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   952
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   953
        for (TInt i = 0; i < iRows[idx]->NumItems(); ++i)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   954
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   955
            CMIDControlItem* ci = iRows[idx]->Item(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   956
            if (ci && ci->Rect().Contains(aPoint))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   957
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   958
                return ci;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   959
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   960
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   961
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   962
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   963
    return NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   964
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   965
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   966
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   967
TInt CMIDForm::RowAtPoint(const TPoint& aPoint) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   968
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   969
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   970
    // loop until the first row fully below the visible form area
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   971
    for (TInt i = 0; i < rowCount && (iRows[i]->Position().iY < iFormHeight); ++i)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   972
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   973
        if (iRows[i]->Rect().Contains(aPoint))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   974
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   975
            return i;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   976
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   977
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   978
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   979
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   980
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   981
#endif // #ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   982
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   983
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   984
void CMIDForm::SetFocusedItemIfNone(CMIDItem* aItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   985
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   986
    if (iFocused == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   987
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   988
        ASSERT(aItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   989
        TInt index = Index(aItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   990
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   991
        if (index >= 0 && index < iItems.Count())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   992
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   993
            CMIDControlItem& ci = ControlItem(iItems[index]);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   994
            if (ci.IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   995
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   996
                SetFocusedItem(index);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   997
                ScrollToFocused();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   998
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
   999
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1000
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1001
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1002
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1003
/** This method is called when an item loses focusability,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1004
for example because it loses all its commands. If this item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1005
is focused, call ReplaceFocusedItem() to find another focusable
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1006
item. @see CMIDItem::RemoveCommand() and  ReplaceFocusedItem*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1007
void CMIDForm::RemoveFocusIfFocused(CMIDItem* aItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1008
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1009
    ASSERT(aItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1010
    TInt index = Index(aItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1011
    if (iFocused == index)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1012
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1013
        // Hide menu because item has lost all item commands and
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1014
        // another item may have become focused behind the menu.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1015
        iDisplayable.MenuHandler()->HideMenuIfVisible();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1016
        ReplaceFocusedItem();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1017
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1018
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1019
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1020
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1021
 * Traverse is a method to go thorough the form; it includes moving focus from
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1022
 * item to another possibly scrolling the form. Note that sometimes traversal
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1023
 * does not move focus, because an item is larger that the screen and thus form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1024
 * is scrolled little by little so that the user can see the whole content. On
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1025
 * other cases, traversing means only moving focus from item to another as both
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1026
 * items are visible on the screen.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1027
 *
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1028
 * @param  aDirection defines the direction of the traversing (up, down, left, right).
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1029
 **/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1030
void CMIDForm::Traverse(TDirection aDirection)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1031
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1032
    DEBUG("< CMIDForm::Traverse");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1033
    DEBUG_INT("< CMIDForm::Traverse Direction is %D", aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1034
    TBool horizontalScroll = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1035
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1036
    if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1037
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1038
        DEBUG("CMIDForm::Traverse - calling layout");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1039
        // lets do the layout now so we can always assume that we are layed out before doing this stuff
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1040
        TrappedLayoutAndDraw();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1041
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1042
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1043
#ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1044
    TBool focusHidden = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1045
    // If the focused item is currently fully outside the visible form area,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1046
    // it means that form has been scrolled by moving the scrollbar with pen. In this case
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1047
    // set iFocused (temporarily) to KErrNone in order that scrolling with arrow keys works ok.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1048
    if (iFocused != KErrNotFound && !RectPartiallyVisible(GetControlRect(iFocused)))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1049
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1050
        focusHidden = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1051
        SetFocusedItem(KErrNotFound, ENone, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1052
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1053
#endif
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1054
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1055
    if (aDirection == ELeft || aDirection == ERight)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1056
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1057
        DEBUG("CMIDForm::Traverse - move focus horizontally");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1058
        if (!TryMovingFocusHorizontally(aDirection))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1059
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1060
            if (iInitialAlignment == MMIDItem::ERight)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1061
            {//RIGHT TO LEFT
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1062
                TryMovingFocusVertically(aDirection == ELeft ? EDown : EUp, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1063
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1064
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1065
            {//LEFT TO RIGHT
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1066
                TryMovingFocusVertically(aDirection == ELeft ? EUp : EDown, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1067
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1068
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1069
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1070
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1071
            horizontalScroll = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1072
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1073
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1074
    else if (aDirection == EUp || aDirection == EDown)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1075
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1076
        DEBUG("CMIDForm::Traverse - move focus vertically");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1077
        TryMovingFocusVertically(aDirection, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1078
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1079
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1080
    // if there is still a focused item, make sure it is still on the screen.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1081
    // if it isn't remove focus as we've already tried out best to have a
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1082
    // focussed item on screen
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1083
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1084
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1085
        TRect rect = GetControlRect(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1086
        if (!RectPartiallyVisible(rect))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1087
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1088
            SetFocusedItem(KErrNotFound, ENone);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1089
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1090
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1091
#ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1092
    else if (focusHidden)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1093
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1094
        // Try to bring the focus back to visible area by setting the last focusable
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1095
        // item in the scroll direction focused.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1096
        TDirection searchDirection = (aDirection == EDown || aDirection == ERight) ?
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1097
                                     EUp : EDown;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1098
        TInt newFocusIndex  = IndexOfFirstFocusableItemOnScreen(searchDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1099
        if (newFocusIndex != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1100
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1101
            // Pass searchDirection also to SetFocusedItem(). This is needed at least
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1102
            // for choice group and custom item cases, so that they can set there
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1103
            // internal focus to the last element in the actual scroll direction.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1104
            SetFocusedItem(newFocusIndex, searchDirection, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1105
            DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1106
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1107
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1108
#endif
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1109
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1110
    RawScrollFinalize(horizontalScroll);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1111
    DEBUG("> CMIDForm::Traverse");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1112
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1113
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1114
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1115
// -----------------------------------------------------------------------------
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1116
// Form scrolling methods
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1117
// -----------------------------------------------------------------------------
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1118
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1119
 * Scroll to the focused control if there is one and update form visibility (draw) and scroll bar.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1120
 * @see ScrollToRect() and SetRowExtentsWithRespectToScrolledLocation().
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1121
 **/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1122
void CMIDForm::ScrollToFocused(TDirection aDirection /*=EDown*/, TBool aReset /*= ETrue*/)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1123
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1124
    DEBUG("< CMIDForm::ScrollToFocused");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1125
    if (!LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1126
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1127
        if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1128
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1129
            TRect rect = GetControlRect(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1130
            DEBUG_INT4("CMIDForm::ScrollToFocused - rect is %D %D %D %D",
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1131
                       rect.iTl.iX, rect.iTl.iY, rect.iBr.iX, rect.iBr.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1132
            RawScrollToRect(rect, aDirection, aReset);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1133
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1134
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1135
        RawScrollFinalize(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1136
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1137
        if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1138
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1139
            ControlItem(iFocused).NotifyScrollingCompleted();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1140
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1141
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1142
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1143
    UpdatePhysics();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1144
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1145
    DEBUG("> CMIDForm::ScrollToFocused");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1146
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1147
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1148
TInt CMIDForm::ScrollDistanceToTappedItem(CMIDControlItem* aPointedControl)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1149
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1150
    TRect focusedRect = aPointedControl->Rect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1151
    TInt scroll = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1152
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1153
    // Calculate how much we need to scroll to make the tapped item fully/more visible
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1154
    if (!RectFullyVisible(focusedRect))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1155
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1156
        TInt topMargin = iFormRect.Rect().iTl.iY - iMidpFormRect.Rect().iTl.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1157
        TInt bottomMargin = iMidpFormRect.Rect().iBr.iY - iFormRect.Rect().iBr.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1158
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1159
        if (focusedRect.Height() <= Height())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1160
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1161
            scroll = (focusedRect.iBr.iY > Height()) ?
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1162
                     Height() - focusedRect.iBr.iY : -focusedRect.iTl.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1163
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1164
        // Scroll long item so that it fills the whole form height.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1165
        // No scroll in case item already fills the whole screen or if there would
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1166
        // be just few pixels (~margins) to scroll.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1167
        else if ((focusedRect.iTl.iY > 0 && focusedRect.iTl.iY > topMargin) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1168
                 (focusedRect.iBr.iY < Height() &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1169
                  Height() - focusedRect.iBr.iY > bottomMargin))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1170
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1171
            scroll = (focusedRect.iTl.iY > 0) ?
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1172
                     -focusedRect.iTl.iY : -(focusedRect.iBr.iY - Height());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1173
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1174
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1175
    return scroll;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1176
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1177
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1178
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1179
 * Scrolls to the rect corresponding to the row specified by aIdx using
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1180
 * the direction indicated by aDirection. @see ScrollToRect()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1181
 **/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1182
void CMIDForm::RawScrollToRow(TInt aIdx, TDirection aDirection)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1183
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1184
    DEBUG("< CMIDForm::RawScrollToRow");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1185
    if (aIdx >= 0 && aIdx < iRows.Count())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1186
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1187
        TRect rect = iRows[aIdx]->Rect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1188
        DEBUG("CMIDForm::RawScrollToRow - scroll to rect");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1189
        RawScrollToRect(rect, aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1190
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1191
    DEBUG("> CMIDForm::RawScrollToRow");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1192
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1193
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1194
/** */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1195
void CMIDForm::RawScrollToRect(const TRect& aRect, TDirection aDirection, TBool aReset)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1196
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1197
    DEBUG("< CMIDForm::RawScrollToRect");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1198
    DEBUG_INT4("CMIDForm::RawScrollToRect - rect is %D %D %D %D", aRect.iTl.iX, aRect.iTl.iY,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1199
               aRect.iBr.iX, aRect.iBr.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1200
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1201
    if (RectFullyVisible(aRect))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1202
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1203
        DEBUG("CMIDForm::RawScrollToRect - return rect fully visible");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1204
        TInt maxScrollValue = Height() - HeightOfAllItems();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1205
        // Avoid scrolling out of the form (i.e. after the view port has lower height)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1206
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1207
        if (iScroll < maxScrollValue)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1208
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1209
            RawScroll(maxScrollValue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1210
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1211
        return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1212
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1213
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1214
    TInt scrollOffset = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1215
    if (aRect.Size().iHeight > Height())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1216
    {//rect higher than screen height
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1217
        if (RectPartiallyVisible(aRect) && !aReset)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1218
        {//if already visible, scroll only of KMinScrollAmount (panning)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1219
            scrollOffset = (aDirection == EDown) ? -KMinScrollAmount : KMinScrollAmount;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1220
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1221
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1222
        {//if not visible and scrolling down scroll to top - KMinScrollAmount
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1223
            // or to bottom + KMinScrollAmount if scrolling up
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1224
            scrollOffset = (aDirection == EDown) ? (Height() - (aRect.iTl.iY + KMinScrollAmount))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1225
                           : -(aRect.iBr.iY - KMinScrollAmount);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1226
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1227
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1228
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1229
    {//if it fits on screen make sure its BR is at the bottom if scrolling down
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1230
        //or its TL is at the top if scrolling up
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1231
        scrollOffset = (aDirection == EDown) ? (Height() - aRect.iBr.iY) : (-aRect.iTl.iY);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1232
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1233
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1234
    RawScroll(iScroll + scrollOffset);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1235
    DEBUG("> CMIDForm::RawScrollToRect");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1236
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1237
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1238
void CMIDForm::ScrollRelative(TInt aScroll)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1239
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1240
    DEBUG("CMIDForm::ScrollRelative");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1241
    RawScrollRelative(aScroll);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1242
    RawScrollFinalize(EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1243
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1244
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1245
void CMIDForm::RawScrollRelative(TInt aScroll)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1246
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1247
    TInt scroll = iScroll + aScroll;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1248
    RawScroll(scroll);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1249
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1250
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1251
void CMIDForm::RawScroll(TInt aScroll)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1252
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1253
    TInt contentHeight  = HeightOfAllItems();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1254
    TInt viewPortHeight = Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1255
    if (aScroll > 0 || contentHeight <= viewPortHeight)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1256
    { // make sure that top does not slide down
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1257
        aScroll = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1258
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1259
    if (contentHeight > viewPortHeight && ((-aScroll) + viewPortHeight) > contentHeight)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1260
    { // scroll only as long as there is content
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1261
        aScroll = -(contentHeight - viewPortHeight);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1262
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1263
    iHasScrolled = iScroll != aScroll;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1264
    iScrollDelta = aScroll - iScroll;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1265
    iScroll = aScroll;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1266
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1267
    SetRowPositionsWithRespectToScrolledLocation();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1268
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1269
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1270
void CMIDForm::SetRowExtentsWithRespectToScrolledLocation()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1271
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1272
    iTotalFormHeight = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1273
    TInt xMargin = iFormRect.Rect().iTl.iX;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1274
    TInt yTopMargin = iFormRect.Rect().iTl.iY - iMidpFormRect.Rect().iTl.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1275
    TInt yBottomMargin = iMidpFormRect.Rect().iBr.iY - iFormRect.Rect().iBr.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1276
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1277
    iTotalFormHeight = yTopMargin;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1278
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1279
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1280
    for (TInt i=0; i < rowCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1281
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1282
        // Form left margin is added in the beginning of each row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1283
        iRows[i]->SetExtent(TPoint(xMargin, iScroll + iTotalFormHeight),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1284
                            TSize(Width(), iRows[i]->Size().iHeight));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1285
        iTotalFormHeight += iRows[i]->Size().iHeight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1286
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1287
    // Form bottom margin is added
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1288
    iTotalFormHeight += yBottomMargin;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1289
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1290
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1291
void CMIDForm::SetRowPositionsWithRespectToScrolledLocation()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1292
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1293
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1294
    for (TInt i=0; i < rowCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1295
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1296
        // Form left margin is added in the beginning of each row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1297
        TPoint pos = iRows[i]->Position();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1298
        pos.iY += ScrollDelta();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1299
        iRows[i]->SetPosition(pos);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1300
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1301
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1302
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1303
// Finalizes scrolling after any RawScrollXxxx method call, e.g. causes repaint.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1304
// Draw can be prevented e.g. because of the performance reasons.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1305
void CMIDForm::RawScrollFinalize(TBool forseAction, TBool aDraw /*= ETrue*/)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1306
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1307
    if (iHasScrolled || forseAction)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1308
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1309
        UpdateHighlightBackgroundPosition();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1310
        HandleItemVisibilityChange();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1311
        UpdateScrollBar();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1312
        if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1313
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1314
            CMIDControlItem& ci = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1315
            if (IsTextFieldItem(ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1316
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1317
                if (RectPartiallyVisible(ci.Rect()))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1318
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1319
                    ((CMIDTextFieldItem&) ci).SetCursorVisibility(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1320
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1321
                else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1322
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1323
                    ((CMIDTextFieldItem&) ci).SetCursorVisibility(EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1324
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1325
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1326
            if (IsDateField(ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1327
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1328
                // Update right cursor position on Datefiled
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1329
                ((CMIDDateFieldItem&) ci).CursorUpdate();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1330
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1331
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1332
        if (aDraw)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1333
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1334
            DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1335
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1336
        iHasScrolled = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1337
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1338
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1339
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1340
/** Returns the client area */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1341
TRect CMIDForm::GetClientArea()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1342
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1343
    TRect scrolledClientArea = TRect(Position(), TSize(Width(), Height()));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1344
    return scrolledClientArea;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1345
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1346
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1347
// returns ETrue if it moved the focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1348
// returns EFalse otherwise
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1349
TBool CMIDForm::TryMovingFocusHorizontally(TDirection aDirection)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1350
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1351
    ASSERT(aDirection == ELeft || aDirection == ERight);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1352
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1353
    TInt idx = NextFocusableHorizontalIdx(aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1354
    if (idx != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1355
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1356
        SetFocusedItem(idx, aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1357
        return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1358
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1359
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1360
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1361
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1362
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1363
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1364
  Moves the focus vertically.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1365
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1366
  We check if there is a focussable item,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1367
  which is on a row totally or partially visible and if there is such
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1368
  an item we then select that row. This is done by calling
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1369
  NextPartiallyVisibleRowWithFocusableItem(). If no such item was found we pick
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1370
  the top or bottom (depending on scrolling direction) row that is partially
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1371
  visible or the first not visible if the last one is completely shown.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1372
  This is done by FirstRowWithBottomBelowScreen() and LastRowWithTopAboveScreen().
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1373
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1374
  At this point if we have a row,  we select a focussable item on it and
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1375
  scroll to it if aScroll is true. Calling scroll methods doesn't mean there is going to be
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1376
  scrolling of the form,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1377
  if the item is already visible no scrolling is done. We select the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1378
  next focussable item according to the value of the parameter aSelectClosest.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1379
  If this paramerter is true we call SelectClosestFocussableItem() otherwise
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1380
  we either select the first or the last selectable item on the row depending
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1381
  on the direction.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1382
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1383
  If we find a control we scroll to it by calling ScrollToFocused() (if aScroll is true) and move
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1384
  the focus to it by calling SetFocusedItem(). Otherwise we
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1385
  scroll to the row by calling ScrollToRow() if aScroll is true.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1386
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1387
  If we could not find any row with a focusable item on it, we scroll the form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1388
  of a fixed quantity, KMinScrollAmount, if aScroll is true.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1389
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1390
  We return ETrue if the focus was moved, EFalse otherwise. Note: Currently the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1391
  return value of this method is ignored.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1392
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1393
  @see  NextPartiallyVisibleRowWithFocusableItem(), FirstRowWithBottomBelowScreen(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1394
              LastRowWithTopAboveScreen(), SelectClosestFocussableItem()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1395
                   ScrollToRow(), SetFocusedItem() and DoScrollRelative().
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1396
           Also see ReplaceFocusedItem(), called when the focused item is removed or
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1397
           loses focusability - in this case no scrolling will occur.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1398
  */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1399
TBool CMIDForm::TryMovingFocusVertically(TDirection aDirection, TBool aSelectClosest,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1400
        TBool aScroll /*=ETrue*/)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1401
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1402
    DEBUG("> CMIDForm::TryMovingFocusVertically");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1403
    ASSERT(aDirection == EUp || aDirection == EDown);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1404
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1405
    // is VKB opened
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1406
    if (iDisplayable.IsVKBOnScreen())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1407
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1408
        return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1409
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1410
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1411
    TInt rowIdx = NextPartiallyVisibleRowWithFocusableItem(aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1412
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1413
    if (rowIdx == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1414
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1415
        DEBUG("CMIDForm::TryMovingFocusVertically - no partially visible focusable control found");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1416
        rowIdx = aDirection == EDown ? FirstRowWithBottomBelowScreen() : LastRowWithTopAboveScreen();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1417
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1418
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1419
    if (rowIdx != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1420
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1421
        CMIDControlItem* ci = aSelectClosest ? SelectClosestFocussableItem(rowIdx) :
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1422
                              (aDirection == EDown ? iRows[rowIdx]->FirstFocusableItem() :
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1423
                               iRows[rowIdx]->LastFocusableItem());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1424
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1425
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1426
        if (ci)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1427
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1428
            DEBUG("CMIDForm::TryMovingFocusVertically - got control");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1429
            TInt index = Index(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1430
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1431
            if (index == KErrNotFound && IsLabelContainerItem(*ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1432
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1433
                CMIDLabelContainerItem* ucsi = static_cast<CMIDLabelContainerItem*>(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1434
                CMIDStringItem& si = ucsi->StringItem();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1435
                index = Index(&si);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1436
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1437
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1438
            if (index != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1439
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1440
                TRect rect = GetControlRect(index);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1441
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1442
                if (aScroll)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1443
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1444
                    SetFocusedItem(index, aDirection, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1445
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1446
                else if (RectPartiallyVisible(rect))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1447
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1448
                    SetFocusedItem(index, aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1449
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1450
                else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1451
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1452
                    SetFocusedItem(KErrNotFound);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1453
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1454
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1455
                DEBUG("CMIDForm::TryMovingFocusVertically - out after scroll to control");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1456
                return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1457
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1458
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1459
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1460
        DEBUG("CMIDForm::TryMovingFocusVertically - scrolling to row");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1461
        if (aScroll)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1462
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1463
            RawScrollToRow(rowIdx, aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1464
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1465
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1466
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1467
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1468
        DEBUG("CMIDForm::TryMovingFocusVertically - small default scrolling");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1469
        if (aScroll)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1470
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1471
            RawScrollRelative((aDirection == EDown) ? -KMinScrollAmount : KMinScrollAmount);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1472
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1473
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1474
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1475
    DEBUG("< CMIDForm::TryMovingFocusVertically");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1476
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1477
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1478
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1479
/** Given a row index, selects on this row the focusable control whose center on
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1480
the x axis is closes to the center of the currently focused item, if there is one.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1481
If no control is found, returns the first selectable item on the row. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1482
CMIDControlItem* CMIDForm::SelectClosestFocussableItem(TInt aRowIndex) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1483
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1484
    ASSERT(aRowIndex >= 0 && aRowIndex < iRows.Count());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1485
    TInt selectedIndex = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1486
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1487
    if (iFocused != -1)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1488
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1489
        TRect rect = GetControlRect(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1490
        TInt focusedCenter = rect.iTl.iX + rect.Width()/2;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1491
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1492
        TInt diff = iInnerWidth;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1493
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1494
        TInt numItemsOnRow = iRows[aRowIndex]->NumItems();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1495
        for (TInt i = 0; i < numItemsOnRow; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1496
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1497
            CMIDControlItem* item = iRows[aRowIndex]->Item(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1498
            if (item->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1499
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1500
                TInt center = item->Position().iX + (item->Size().iWidth / 2);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1501
                TInt itemDiff = focusedCenter > center ? (focusedCenter - center) : (center - focusedCenter);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1502
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1503
                if (itemDiff < diff)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1504
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1505
                    selectedIndex = i;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1506
                    diff = itemDiff;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1507
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1508
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1509
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1510
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1511
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1512
    return selectedIndex == -1 ? iRows[aRowIndex]->FirstFocusableItem() :
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1513
           iRows[aRowIndex]->Item(selectedIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1514
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1515
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1516
TInt CMIDForm::IndexOfFirstFocusableItemOnScreen(TDirection aDirection)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1517
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1518
    ASSERT(aDirection == EUp || aDirection == EDown);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1519
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1520
    TInt startIdx = FirstRowOnScreen(aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1521
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1522
    if (startIdx == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1523
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1524
        return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1525
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1526
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1527
    CMIDControlItem* ci = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1528
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1529
    if (aDirection == EDown)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1530
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1531
        TInt idx = startIdx - 1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1532
        TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1533
        while (++idx < rowCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1534
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1535
            CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1536
            if (row->Position().iY > Height())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1537
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1538
                break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1539
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1540
            ci = row->FirstFocusableItemOnScreen();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1541
            if (ci)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1542
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1543
                break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1544
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1545
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1546
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1547
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1548
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1549
        TInt idx = startIdx + 1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1550
        while (--idx >= 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1551
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1552
            CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1553
            if ((row->Position().iY + row->Size().iHeight) < 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1554
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1555
                break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1556
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1557
            ci = row->FirstFocusableItemOnScreen();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1558
            if (ci)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1559
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1560
                break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1561
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1562
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1563
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1564
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1565
    if (!ci)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1566
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1567
        return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1568
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1569
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1570
    TInt index = Index(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1571
    if (index == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1572
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1573
        if (IsLabelContainerItem(*ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1574
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1575
            CMIDLabelContainerItem* ucsi = static_cast<CMIDLabelContainerItem*>(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1576
            CMIDStringItem& si = ucsi->StringItem();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1577
            index = Index(&si);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1578
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1579
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1580
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1581
    return index;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1582
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1583
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1584
/** Return the rect for a control, taking into account if the control is an
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1585
unconstrained string item which has been split over more than one label container
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1586
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1587
TRect CMIDForm::GetControlRect(TInt aIdx) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1588
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1589
    CMIDControlItem& ci = ControlItem(aIdx);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1590
    TRect rect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1591
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1592
    if (ItemIsUnconstrained(aIdx))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1593
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1594
        rect = GetUnconstrainedStringItemRect(static_cast<CMIDStringItem*>(&ci));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1595
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1596
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1597
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1598
        rect = ci.Rect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1599
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1600
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1601
    return rect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1602
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1603
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1604
/** Collate rects for unconstrained string items that have been split across more
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1605
than one lable container */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1606
TRect CMIDForm::GetUnconstrainedStringItemRect(CMIDStringItem* aStringItem) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1607
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1608
    TRect rect(0,0,0,0);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1609
    TBool found = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1610
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1611
    TInt rowIdx = FirstRowOfUnconstrainedStringItem(*aStringItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1612
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1613
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1614
    // if the first row of unconstrained string item cannot be found
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1615
    // it means that string item is placed as default item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1616
    // so simply return item's rect
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1617
    if (rowIdx == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1618
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1619
        return aStringItem->Rect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1620
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1621
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1622
    while (rowIdx != KErrNotFound && rowIdx < rowCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1623
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1624
        CMIDFormRow* row = iRows[rowIdx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1625
        for (TInt idxOnRow = 0; idxOnRow < row->NumItems(); idxOnRow++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1626
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1627
            CMIDControlItem* ci = row->Item(idxOnRow);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1628
            if (ci && IsLabelContainerItem(*ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1629
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1630
                CMIDLabelContainerItem* usil = static_cast<CMIDLabelContainerItem*>(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1631
                CMIDStringItem* si = &(usil->StringItem());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1632
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1633
                if (si == aStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1634
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1635
                    if (!found)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1636
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1637
                        rect.iTl = usil->Rect().iTl;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1638
                        found = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1639
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1640
                    rect.iBr = usil->Rect().iBr;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1641
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1642
                else if (found)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1643
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1644
                    return rect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1645
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1646
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1647
            else if (found)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1648
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1649
                return rect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1650
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1651
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1652
        rowIdx++;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1653
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1654
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1655
    return rect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1656
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1657
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1658
TBool CMIDForm::RectPartiallyVisible(const TRect& aRect)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1659
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1660
    return ((aRect.iTl.iY >= 0) && (aRect.iTl.iY < Height())) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1661
           ((aRect.iBr.iY >= 0) && (aRect.iBr.iY < Height())) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1662
           ((aRect.iTl.iY < 0) && (aRect.iBr.iY >= Height()));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1663
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1664
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1665
TBool CMIDForm::RectFullyVisible(const TRect& aRect)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1666
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1667
    return (aRect.iTl.iY >= 0) && (aRect.iBr.iY <= Height());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1668
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1669
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1670
TInt CMIDForm::FirstRowWithBottomBelowScreen()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1671
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1672
    TInt idx = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1673
    TInt rowWithFocus = iFocused == KErrNotFound ? -1 : Row(ControlItem(iFocused));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1674
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1675
    while (++idx < rowCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1676
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1677
        CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1678
        TInt height = row->Size().iHeight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1679
        TInt yPos = row->Position().iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1680
        if ((height + yPos) > Height() && row->HasNonSpacerItems() && idx != rowWithFocus)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1681
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1682
            return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1683
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1684
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1685
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1686
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1687
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1688
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1689
TInt CMIDForm::LastRowWithTopAboveScreen()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1690
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1691
    TInt idx = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1692
    TInt rowWithFocus = iFocused == KErrNotFound ? -1 : Row(ControlItem(iFocused));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1693
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1694
    while (--idx >= 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1695
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1696
        CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1697
        TInt yPos = row->Position().iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1698
        if (yPos < 0 && row->HasNonSpacerItems() && idx != rowWithFocus)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1699
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1700
            return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1701
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1702
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1703
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1704
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1705
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1706
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1707
// note: inspite of the name of this method, we only consider rows with
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1708
// a focusable item that has not already been scrolled off the screen.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1709
// For Example:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1710
//
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1711
//  ----
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1712
// | A  | This is a
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1713
// |    | string item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1714
//  ----  that is placed
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1715
//----------------------- <- top of form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1716
//        next to item A.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1717
//        This
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1718
//        string
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1719
//        item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1720
//        is
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1721
//        quite
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1722
//        tall
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1723
//        and
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1724
//----------------------- <- botom of form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1725
//        fills
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1726
//        the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1727
//        screen
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1728
//
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1729
// Assuming that A is focusable, and we are scrolling down, and also assuming
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1730
// that the string item is not focusable, we do not consider A when looking
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1731
// for focusable items, because we are scrolling down and A is already above
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1732
// the screen.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1733
TInt CMIDForm::NextPartiallyVisibleRowWithFocusableItem(TDirection aDirection)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1734
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1735
    ASSERT(aDirection == EUp || aDirection == EDown);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1736
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1737
    TInt startIdx = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1738
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1739
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1740
        //If there is layout request pending, the array of rows is probably
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1741
        //empty. So we need to do layout of form, which fills the array of rows.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1742
        //Then row, where current focused item is, will be found.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1743
        if (iRows.Count() == 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1744
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1745
            TrappedLayoutAndDraw(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1746
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1747
        TInt row = Row(ControlItem(iFocused));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1748
        if (row == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1749
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1750
            CMIDControlItem& ci = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1751
            if (IsStringItem(ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1752
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1753
                // find the first row either above or below (depends on direction)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1754
                // this unconstrained stringItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1755
                CMIDStringItem& stringItem =
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1756
                    *(static_cast<CMIDStringItem*>(&ci));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1757
                if (aDirection == EDown)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1758
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1759
                    startIdx = FirstRowBelowUnconstrainedStringItem(stringItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1760
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1761
                else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1762
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1763
                    startIdx = FirstRowAboveUnconstrainedStringItem(stringItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1764
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1765
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1766
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1767
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1768
                // shouldn't get here
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1769
                ASSERT(EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1770
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1771
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1772
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1773
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1774
            startIdx = row + ((aDirection == EDown) ? 1 : -1);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1775
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1776
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1777
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1778
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1779
        // There is no focused item on Form (iFocused value is KErrNotFound).
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1780
        // So we need to try to find another Item which could gain focus.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1781
        startIdx = FirstRowOnScreen(aDirection);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1782
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1783
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1784
    if (startIdx == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1785
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1786
        return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1787
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1788
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1789
    if (aDirection == EDown)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1790
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1791
        TInt idx = startIdx - 1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1792
        TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1793
        while (++idx < rowCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1794
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1795
            CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1796
            if (row->Position().iY > Height())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1797
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1798
                break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1799
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1800
            if (row->HasFocusableItemOnOrBelowScreen())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1801
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1802
                return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1803
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1804
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1805
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1806
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1807
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1808
        TInt idx = startIdx + 1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1809
        while (--idx >= 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1810
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1811
            CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1812
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1813
            if (row->HasFocusableItemOnOrAboveScreen())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1814
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1815
                return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1816
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1817
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1818
            if ((row->Position().iY + row->Size().iHeight) < 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1819
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1820
                break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1821
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1822
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1823
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1824
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1825
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1826
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1827
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1828
// if aFromTop is false we look from the bottom up
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1829
TInt CMIDForm::FirstRowOnScreen(TDirection aDirection)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1830
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1831
    ASSERT(aDirection == EUp || aDirection == EDown);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1832
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1833
    TInt idx = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1834
    if (aDirection == EDown)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1835
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1836
        idx = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1837
        TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1838
        while (++idx < rowCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1839
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1840
            CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1841
            TInt bottom = row->Position().iY + row->Size().iHeight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1842
            if (bottom > 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1843
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1844
                return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1845
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1846
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1847
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1848
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1849
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1850
        idx = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1851
        while (--idx >= 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1852
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1853
            CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1854
            TInt top = row->Position().iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1855
            if (top < Height())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1856
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1857
                return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1858
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1859
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1860
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1861
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1862
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1863
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1864
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1865
// Returns the item index of the next focusable item in the given direction.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1866
// Note: this may return an object that is not on the current row if there is
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1867
//       an unconstrained string item on the current row.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1868
//
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1869
//       --------
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1870
//       |      |
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1871
//       |  A   |
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1872
//       |      | --------
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1873
//       -------- --------
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1874
//       -----------------
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1875
//       __________ ------
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1876
//                  |    |
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1877
//                  | B  |
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1878
//                  |    |
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1879
//                  ------
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1880
// In the above diagram we see a selectable item A, an unconstrained stringItem,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1881
// and another selectable item B. If A has focus and the stringItem is not focusable
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1882
// then calling NextFocusableHorizontalIdx( ERight ) should return the index of B.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1883
// If the string item is selectable then its index would get returned and a further
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1884
// call to NextFocusableHorizontalIdx( ERight ) would return the index of B.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1885
// If B has focus calling NextFocusableHorizontalIdx( ELeft ) would simply return the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1886
// index of the stringItem if it is selectable or A if not.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1887
TInt CMIDForm::NextFocusableHorizontalIdx(TDirection aDirection)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1888
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1889
    ASSERT(aDirection == ELeft || aDirection == ERight);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1890
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1891
    TInt idx = KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1892
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1893
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1894
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1895
        CMIDFormRow* rowPtr = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1896
        CMIDControlItem& controlItem = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1897
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1898
        TInt rowIdx = Row(controlItem, rowPtr);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1899
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1900
        if (rowIdx != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1901
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1902
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1903
            idx = rowPtr->Find(&controlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1904
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1905
            if (aDirection == ELeft)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1906
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1907
                while (--idx >= 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1908
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1909
                    if (rowPtr->Item(idx)->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1910
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1911
                        return ItemIndex(*(rowPtr->Item(idx)));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1912
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1913
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1914
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1915
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1916
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1917
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1918
                // direction is ERight
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1919
                while (++idx < rowPtr->NumItems())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1920
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1921
                    if (rowPtr->Item(idx)->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1922
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1923
                        return ItemIndex(*(rowPtr->Item(idx)));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1924
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1925
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1926
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1927
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1928
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1929
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1930
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1931
            // there is something focused but we failed to find a row index for it,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1932
            // so it is probably an unconstrained stringItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1933
            if (aDirection == ELeft)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1934
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1935
                if (IsStringItem(controlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1936
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1937
                    CMIDStringItem* si = static_cast<CMIDStringItem*>(&controlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1938
                    idx = FirstFocusableItemBeforeStartOfUnconstrainedStringItemIdx(*si);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1939
                    return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1940
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1941
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1942
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1943
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1944
                // direction ie ERight
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1945
                if (IsStringItem(controlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1946
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1947
                    CMIDStringItem* si = static_cast<CMIDStringItem*>(&controlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1948
                    idx = FirstFocusableItemOnLastLineOfUnconstrainedStringItemIdx(*si);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1949
                    return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1950
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1951
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1952
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1953
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1954
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1955
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1956
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1957
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1958
/** Replaces the currently focused item. This is called when the focused item is removed
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1959
or it loses focusability, for example a string item that loses all its commands. So this
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1960
is always triggered by a java call, never by the user. We call the same methods that are
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1961
used by Scroll(), ie TryMovingFocusHorizontally() and TryMovingFocusVertically(). However
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1962
in this case we don't want the form to scroll if the focused item is not on screen. So
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1963
these two methods will move the focus if a focusable item is either completely or partially
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1964
visible on screen following the good direction (right-down for left to right devices and
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1965
vice-versa for right to left devices). TryMovingFocusVertically() will set the focused item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1966
to KErrNotFound if no focusable item is currently visible. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1967
void CMIDForm::ReplaceFocusedItem()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1968
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1969
    if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1970
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1971
        DEBUG("CMIDForm::ReplaceFocusedItem - calling layout");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1972
        TRAP_IGNORE(LayoutFormL());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1973
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1974
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1975
    CMIDForm::TDirection direction = (iInitialAlignment == MMIDItem::ERight) ? ELeft : ERight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1976
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1977
    if (!TryMovingFocusHorizontally(direction))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1978
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1979
        if (iInitialAlignment == MMIDItem::ERight)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1980
        {//RIGHT TO LEFT
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1981
            if (!TryMovingFocusVertically(direction == ELeft ? EDown : EUp, EFalse, EFalse))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1982
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1983
                SetFocusedItem(KErrNotFound);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1984
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1985
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1986
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1987
        {//LEFT TO RIGHT
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1988
            if (!TryMovingFocusVertically(direction == ELeft ? EUp : EDown, EFalse, EFalse))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1989
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1990
                SetFocusedItem(KErrNotFound);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1991
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1992
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1993
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1994
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1995
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1996
void CMIDForm::SetFocusedItem(TInt aFocusIdx, TDirection aDirection /*= ENone*/,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1997
                              TBool aDoScroll /*= ETrue*/)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1998
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  1999
    TInt oldFocused = iFocused;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2000
    TInt focusIndexDelta = aFocusIdx - iFocused;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2001
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2002
    { // actions for the item loosing focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2003
        CMIDControlItem& control = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2004
        control.PostFocusTransferEvent(EFalse, aDirection);
23
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  2005
        // setting highlight must be called before setting focus
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  2006
        control.SetHighlight(EFalse);
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2007
        control.SetFocus(EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2008
        UpdateItemCommands(NULL, NULL);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2009
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2010
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2011
    iFocused = aFocusIdx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2012
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2013
    //If there is traverse from visible to invisible TextField, Form has to scroll first
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2014
    //before actions for the item which gaining focus are done. Form scrolling provides
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2015
    //position settings to all visible items in form.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2016
    //When TextField gains focus, cursor values are calculated. Because this step was done before
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2017
    //scrolling, position of edwin in TextField was not set (@see CMIDFormRow::SizeChanged())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2018
    //and cursor was drawn to wrong position.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2019
    //So Form has to scroll first -> this action provides proper position settings
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2020
    //to item and items which are part of it (e.g. edwin in TextField) and after that
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2021
    //changing focus makes proper cursor drawing.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2022
    if (focusIndexDelta != 0 && aDoScroll)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2023
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2024
        if (oldFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2025
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2026
            aDirection = (focusIndexDelta > 0) ? EDown : EUp;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2027
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2028
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2029
        ScrollToFocused(aDirection, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2030
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2031
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2032
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2033
    { // actions for the item gaining focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2034
        CMIDControlItem& control = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2035
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2036
        SetHighlightBackgroundRects();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2037
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2038
        control.PostFocusTransferEvent(ETrue, aDirection);
23
e5618cc85d74 Revision: v2.1.32
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 18
diff changeset
  2039
        control.SetHighlight(ETrue);
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2040
        control.SetFocus(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2041
        // msk: deliver also the possible MSK command to displayable
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2042
        UpdateItemCommands(control.CommandList(), control.GetMSKCommand());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2043
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2044
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2045
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2046
/** Updates the model of the scrollbar and moves the thumb. Scroll bar must have
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2047
already been layouted.*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2048
void CMIDForm::UpdateScrollBar()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2049
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2050
    ASSERT(iSBFrame);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2051
    DEBUG_INT("CMIDForm::UpdateScrollBar - iScroll is %D", iScroll);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2052
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2053
    TInt heightOfAllItems = HeightOfAllItems();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2054
    TInt height = heightOfAllItems > Height() ? heightOfAllItems : Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2055
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2056
    TEikScrollBarModel vSbarModel(height, Height(), -iScroll);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2057
    iSBFrame->Tile(&vSbarModel);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2058
    iSBFrame->MoveVertThumbTo(-iScroll);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2059
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2060
    iPopupController->HidePopup(); // hide info popup window if visible
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2061
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2062
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2063
CMIDForm* CMIDForm::NewL(MMIDEnv& aEnv,MMIDDisplayable& aDisplayable)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2064
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2065
    CMIDForm* form = new(ELeave) CMIDForm(aEnv, static_cast<CMIDDisplayable&>(aDisplayable));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2066
    CleanupStack::PushL(form);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2067
    form->ConstructL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2068
    CleanupStack::Pop(form);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2069
    return form;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2070
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2071
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2072
CMIDForm::CMIDForm(MMIDEnv& aEnv, CMIDDisplayable& aDisplayable)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2073
        : iDisplayable(aDisplayable), iEnv(&aEnv), iFocused(KErrNotFound),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2074
        iInitialAlignment(MMIDItem::ELeft), iHasScrolled(EFalse),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2075
        iLastFadeMessage(0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2076
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2077
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2078
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2079
CMIDForm::~CMIDForm()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2080
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2081
    TRAP_IGNORE(DeleteAllItemsL());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2082
    DeleteRows();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2083
    iCurrentRow = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2084
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2085
    delete iSBFrame;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2086
    SetItemsFormPointersToVal(NULL);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2087
    iItems.Close();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2088
    iRows.Close();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2089
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2090
    delete iLayoutTimer;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2091
    delete iNoDataText;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2092
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2093
    if (iBackgroundControlContext)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2094
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2095
        delete iBackgroundControlContext;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2096
        iBackgroundControlContext = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2097
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2098
    if (iHighlightedBackgroundCc)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2099
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2100
        delete iHighlightedBackgroundCc;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2101
        iHighlightedBackgroundCc = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2102
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2103
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2104
    // Displayable is notified about content control deletion
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2105
    iDisplayable.NotifyContentDestroyed();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2106
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2107
    delete iPopupController;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2108
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2109
    if (iHighlightTimer)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2110
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2111
        iHighlightTimer->Cancel();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2112
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2113
    delete iHighlightTimer;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2114
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2115
    delete iPhysics;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2116
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2117
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2118
#include "javaoslayer.h"
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2119
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2120
void CMIDForm::Draw(const TRect& aRect) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2121
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2122
    if (!iStartUpTraceDone)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2123
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2124
        java::util::JavaOsLayer::startUpTrace("MIDP: CMIDForm::Draw starts", -1, -1);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2125
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2126
    if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2127
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2128
        return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2129
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2130
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2131
    CWindowGc& gc = SystemGc();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2132
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2133
    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2134
    AknsDrawUtils::Background(skin, iBackgroundControlContext, this, gc, aRect);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2135
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2136
    // Draw focus highlight
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2137
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2138
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2139
        TRect focusedRect = ControlItem(iFocused).Rect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2140
        if (focusedRect.Intersects(aRect))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2141
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2142
            AknsDrawUtils::Background(AknsUtils::SkinInstance(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2143
                                      iHighlightedBackgroundCc, this,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2144
                                      SystemGc(), focusedRect);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2145
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2146
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2147
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2148
    // If there is no items, "No data" string is printed to the middle of the screen
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2149
    if (iItems.Count() == 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2150
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2151
        TRAP_IGNORE(DrawNoDataStringL());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2152
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2153
    if (!iStartUpTraceDone)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2154
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2155
        java::util::JavaOsLayer::startUpTrace("MIDP: CMIDForm::Draw done", -1, -1);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2156
        iStartUpTraceDone = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2157
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2158
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2159
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2160
void CMIDForm::DrawNoDataStringL() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2161
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2162
    CWindowGc& gc = SystemGc();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2163
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2164
    // Actual skin instance
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2165
    MAknsSkinInstance* skin = AknsUtils::SkinInstance();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2166
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2167
    // If there is not the color fot the particular skin and id found, default (black) is used
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2168
    TRgb color;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2169
    // Try to receive the color by skin and color Id, if not successful, black is used
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2170
    TInt err = AknsUtils::GetCachedColor(skin, color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG6);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2171
    if (err != KErrNone)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2172
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2173
        color = AKN_LAF_COLOR(AknLayout::Title_pane_texts_Line_1(0, 0).iC);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2174
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2175
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2176
    const CFont* font = CMIDFont::DefaultFont(CMIDFont::EDefaultTextId);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2177
    TInt textWidth = font->TextWidthInPixels(iNoDataText->Des());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2178
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2179
    // Rectangle for computing the center
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2180
    TRect screenRect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2181
    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screenRect);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2182
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2183
    // Centers the string to the middle of the screen
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2184
    TInt x = (screenRect.Width() - textWidth) / 2;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2185
    TInt y = (iInnerHeight - font->HeightInPixels()) / 2;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2186
    TPoint point(x, y);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2187
    //Reserve extra space for biditext formatting
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2188
    HBufC* bidiTextBuffer = HBufC::NewLC(iNoDataText->Size() + KAknBidiExtraSpacePerLine);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2189
    TPtr bidiText = bidiTextBuffer->Des();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2190
    TPtr caption = iNoDataText->Des();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2191
    bidiText = caption;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2192
    // Handle (bidi)text formatting for all languages
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2193
    AknBidiTextUtils::ConvertToVisualAndClipL(bidiText, *font, textWidth, textWidth);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2194
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2195
    gc.SetPenColor(color);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2196
    gc.UseFont(font);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2197
    gc.DrawText(bidiText, point);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2198
    CleanupStack::PopAndDestroy(bidiTextBuffer);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2199
    gc.DiscardFont();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2200
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2201
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2202
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2203
/** Request a layout operaiton. We must delete the rows if postponing layout
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2204
in case java side some of the controls have been deleted. Otherwise because those
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2205
controls may be on existing rows we would get a panic in a draw request outside
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2206
our control. By deleting the rows in the worse scenario we'll get a blank form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2207
drawn temporarily until the next layout operation. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2208
void CMIDForm::RequestLayoutL(TBool aImmediately /*= EFalse*/)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2209
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2210
    if (aImmediately)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2211
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2212
        iLayoutTimer->Cancel();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2213
        LayoutAndDrawL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2214
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2215
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2216
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2217
        if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2218
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2219
            TTime now;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2220
            now.HomeTime();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2221
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2222
            if (now.MicroSecondsFrom(iLayoutRequestTime) > KLayoutCap)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2223
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2224
                LayoutAndDrawL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2225
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2226
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2227
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2228
                iLayoutTimer->Cancel();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2229
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2230
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2231
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2232
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2233
            iLayoutRequestTime.HomeTime();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2234
            DeleteRows();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2235
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2236
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2237
        if (iLayoutRequestTime != -1)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2238
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2239
            iLayoutTimer->After(KLayoutTimeout);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2240
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2241
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2242
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2243
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2244
/** Return true if a layout request has been made. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2245
TBool CMIDForm::LayoutPending() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2246
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2247
    return (iLayoutRequestTime != -1) && (iLayoutTimer->IsActive());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2248
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2249
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2250
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2251
Layout the form, do scrolling and draw. Reset any previous layout request.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2252
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2253
@see RequestLayout(), LayoutPending(), LayoutFormL() and DoScroll()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2254
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2255
void CMIDForm::LayoutAndDrawL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2256
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2257
    DEBUG("CMIDForm::LayoutAndDrawL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2258
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2259
    LayoutFormL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2260
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2261
    HandleItemVisibilityChange();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2262
    UpdateScrollBar();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2263
    SetHighlightBackgroundRects();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2264
    DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2265
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2266
    UpdatePhysics();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2267
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2268
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2269
/** Call LayoutAndDrawL() inside a trap harness and log an error message if it
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2270
levaes.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2271
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2272
    @param aOnlyIfPending Call LayoutAndDrawL() only if there is one pending,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2273
           @see LayoutPending(). By default this parameter is EFalse, i.e. always do layout
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2274
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2275
    @return The leave code returned by LayoutAndDrawL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2276
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2277
TInt CMIDForm::TrappedLayoutAndDraw(TBool aOnlyIfPending /* = EFalse */)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2278
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2279
    if (aOnlyIfPending  && !LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2280
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2281
        return KErrNone;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2282
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2283
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2284
    TRAPD(err, LayoutAndDrawL());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2285
    return err;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2286
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2287
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2288
/* Called when the form becomes current and after the focus was set
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2289
 * @see CMIDDisplayable::HandleCurrentL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2290
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2291
void CMIDForm::HandleCurrentL(TBool aCurrent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2292
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2293
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2294
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2295
        CMIDControlItem& control = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2296
        control.HandleCurrentL(aCurrent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2297
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2298
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2299
    if (!aCurrent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2300
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2301
        iPopupController->HidePopup();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2302
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2303
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2304
#ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2305
    iCanDragFocus = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2306
#endif
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2307
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2308
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2309
void CMIDForm::ConstructL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2310
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2311
    UpdateMemberVariables();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2312
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2313
    SetContainerWindowL(iDisplayable);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2314
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2315
    iPopupController = CMIDPopupNoteController::NewL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2316
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2317
    // Scroll initialisations
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2318
#ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2319
    iSBFrame = new(ELeave) CEikScrollBarFrame(this, this, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2320
    Window().SetPointerGrab(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2321
#else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2322
    iSBFrame = new(ELeave) CEikScrollBarFrame(this, NULL, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2323
#endif //RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2324
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2325
    iSBFrame->SetScrollBarVisibilityL(
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2326
        CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2327
    iSBFrame->CreateDoubleSpanScrollBarsL(ETrue, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2328
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2329
    // Background initialisation
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2330
    iBackgroundControlContext = CAknsListBoxBackgroundControlContext::NewL(
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2331
                                    KAknsIIDQsnBgAreaMainListGene, Rect(), ETrue,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2332
                                    KAknsIIDQsnBgColumnAB, Rect())  ;  // Rect parameters are only place-holders
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2333
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2334
    // Background for highlighted item, frame rects are set later
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2335
    iHighlightedBackgroundCc = CAknsFrameBackgroundControlContext::NewL(
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2336
                                   KAknsIIDQsnFrInput,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2337
                                   TRect(), TRect(), ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2338
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2339
    iDisplayable.SetComponentL(*this);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2340
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2341
    // get the layout from shared data so we can tell what our
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2342
    // initial alignment should be
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2343
    TInt layoutId = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2344
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2345
    CRepository* repository = CRepository::NewL(KCRUidAvkon);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2346
    repository->Get(KAknLayoutId, layoutId);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2347
    delete repository;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2348
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2349
    if (layoutId == EAknLayoutIdABRW)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2350
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2351
        iInitialAlignment = MMIDItem::ERight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2352
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2353
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2354
    iLayoutTimer = CTimeOutTimer::NewL(CActive::EPriorityIdle, *this);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2355
    iNoDataText =  iEikonEnv->AllocReadResourceL(R_AVKON_NO_DATA);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2356
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2357
#ifdef RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2358
    iFeedback = MTouchFeedback::Instance();
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  2359
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  2360
    UpdateTactileFeedbackDensity();
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  2361
#endif // RD_JAVA_ADVANCED_TACTILE_FEEDBACK
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  2362
#endif // RD_TACTILE_FEEDBACK
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  2363
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2364
    //index of pointed control is set to not active
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2365
    iIndexPointedControl=-1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2366
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2367
    if (CMIDFormPhysics::FeatureEnabled())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2368
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2369
        iPhysics = CMIDFormPhysics::NewL(*this);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2370
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2371
        // Destroy iPhysics immediately if physics is not allowed.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2372
        // This should happen in error situation only, when implementation
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2373
        // dll couldn't be loaded although the feature was enabled.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2374
        if (iPhysics && !iPhysics->PhysicsAllowed())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2375
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2376
            delete iPhysics;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2377
            iPhysics = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2378
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2379
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2380
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2381
            iHighlightTimer = CPeriodic::NewL(CActive::EPriorityStandard);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2382
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2383
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2384
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2385
    LayoutAndDrawL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2386
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2387
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2388
void CMIDForm::UpdateMemberVariables()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2389
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2390
    TAknLayoutRect mainMidpPane;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2391
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2392
#ifdef RD_JAVA_S60_RELEASE_9_2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2393
    TRect mainPaneRect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2394
    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2395
    mainMidpPane.LayoutRect(mainPaneRect,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2396
                            AknLayoutScalable_Avkon::main_midp_pane().LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2397
#else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2398
    mainMidpPane.LayoutRect(iEikonEnv->ScreenDevice()->SizeInPixels(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2399
                            AknLayoutScalable_Avkon::main_midp_pane().LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2400
#endif // RD_JAVA_S60_RELEASE_9_2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2401
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2402
    TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2403
    iMidpFormRect.LayoutRect(mainMidpPane.Rect(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2404
                             AknLayoutScalable_Avkon::midp_form_pane(variety).LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2405
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2406
    TAknLayoutRect listForm2MidpPane;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2407
    listForm2MidpPane.LayoutRect(iMidpFormRect.Rect(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2408
                                 AknLayoutScalable_Avkon::list_form2_midp_pane().LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2409
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2410
    iFormRect.LayoutRect(listForm2MidpPane.Rect(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2411
                         AknLayoutScalable_Avkon::form2_midp_field_pane().LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2412
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2413
    iInnerWidth = iFormRect.Rect().Width();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2414
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2415
    iInnerHeight = iFormRect.Rect().Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2416
    iFormHeight = iMidpFormRect.Rect().Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2417
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2418
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2419
MMIDItem* CMIDForm::CurrentItem() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2420
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2421
    return iFocused == KErrNotFound ? NULL : iItems[iFocused];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2422
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2423
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2424
CMIDItem& CMIDForm::Item(TInt aIndex) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2425
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2426
    MMIDItem* item = iItems[aIndex];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2427
    return ControlItem(item->Type());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2428
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2429
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2430
CMIDControlItem& CMIDForm::ControlItem(TInt aIndex) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2431
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2432
    return ControlItem(iItems[aIndex]);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2433
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2434
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2435
CMIDControlItem& CMIDForm::ControlItem(MMIDItem* aMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2436
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2437
    CMIDControlItem* base = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2438
    TInt type  = (TInt) aMMidItem->Type();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2439
    switch (type)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2440
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2441
    case MMIDComponent::EImageItem:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2442
        base = static_cast<CMIDImageItem*>(aMMidItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2443
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2444
    case MMIDComponent::EStringItem:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2445
        base = static_cast<CMIDStringItem*>(aMMidItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2446
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2447
    case MMIDComponent::ESpacer:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2448
        base = static_cast<CMIDSpacer*>(aMMidItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2449
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2450
    case MMIDComponent::EGauge:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2451
        base = static_cast<CMIDGaugeItem*>(aMMidItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2452
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2453
    case MMIDComponent::ETextField:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2454
        base = static_cast<CMIDTextFieldItem*>(aMMidItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2455
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2456
    case MMIDComponent::EChoiceGroup:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2457
        base = static_cast<CMIDChoiceGroupItem*>(aMMidItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2458
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2459
    case MMIDComponent::EDateField:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2460
        base = static_cast<CMIDDateFieldItem*>(aMMidItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2461
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2462
    case MMIDComponent::ECustomItem:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2463
        base = static_cast<CMIDCustomItem*>(aMMidItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2464
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2465
    default:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2466
        ASSERT(EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2467
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2468
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2469
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2470
    return *base;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2471
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2472
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2473
TInt CMIDForm::Index(CCoeControl* aControl) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2474
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2475
    TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2476
    for (TInt i=0; i < itemCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2477
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2478
        CCoeControl* control = static_cast<CCoeControl*>(&(ControlItem(i)));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2479
        if (control == aControl)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2480
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2481
            return i;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2482
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2483
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2484
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2485
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2486
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2487
TInt CMIDForm::FormWidth()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2488
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2489
    return CMIDForm::StaticFormRect().Width();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2490
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2491
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2492
/*static*/ TRect CMIDForm::StaticFormRect()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2493
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2494
    TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2495
    TRect mainPaneRect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2496
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2497
#ifdef RD_JAVA_S60_RELEASE_9_2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2498
    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2499
#else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2500
    mainPaneRect = iAvkonAppUi->ApplicationRect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2501
#endif // RD_JAVA_S60_RELEASE_9_2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2502
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2503
    TAknLayoutRect mainMidpPane;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2504
    mainMidpPane.LayoutRect(mainPaneRect,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2505
                            AknLayoutScalable_Avkon::main_midp_pane().LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2506
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2507
    TAknLayoutRect midpFormRect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2508
    midpFormRect.LayoutRect(mainMidpPane.Rect(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2509
                            AknLayoutScalable_Avkon::midp_form_pane(variety).LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2510
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2511
    TAknLayoutRect listForm2MidpPane;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2512
    listForm2MidpPane.LayoutRect(midpFormRect.Rect(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2513
                                 AknLayoutScalable_Avkon::list_form2_midp_pane().LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2514
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2515
    TAknLayoutRect formRect;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2516
    formRect.LayoutRect(listForm2MidpPane.Rect(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2517
                        AknLayoutScalable_Avkon::form2_midp_field_pane().LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2518
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2519
    return formRect.Rect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2520
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2521
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2522
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2523
TBool CMIDForm::IsCurrentItem(CMIDItem* aItem) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2524
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2525
    return (iFocused != KErrNotFound) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2526
           (iFocused == Index(static_cast<CCoeControl*>(aItem)));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2527
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2528
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2529
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2530
void CMIDForm::HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2531
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2532
    switch (aEventType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2533
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2534
    case MCoeControlObserver::EEventStateChanged:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2535
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2536
        TInt index = KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2537
        User::LeaveIfError(index = Index(aControl));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2538
        MMIDComponent::TType type = iItems[index]->Type();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2539
        if (type == EStringItem || type == EImageItem || type == ECustomItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2540
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2541
            // These don't change state in the MIDP sense, so it must be a button
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2542
            // press so we need to post a default command event, if there is one
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2543
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2544
            // msk: this is needed if msk is not enabled
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2545
            PostDefaultItemCommandEvent(index);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2546
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2547
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2548
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2549
            iEnv->PostJavaEvent(*this,EDisplayable,index);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2550
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2551
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2552
    break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2553
    case MCoeControlObserver::EEventRequestFocus:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2554
        if (!aControl->IsNonFocusing())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2555
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2556
            SetFocusedItem(Index(aControl));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2557
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2558
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2559
    default:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2560
        break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2561
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2562
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2563
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2564
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2565
/*
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2566
 * Pointer events from different Items are are routed via this function to private HandleControlEventL.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2567
 * Focus is not accepted if Item is not focusable.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2568
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2569
void CMIDForm::HandleTouchControlEventL(CCoeControl* aControl,TCoeEvent aEventType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2570
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2571
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2572
    CMIDControlItem& ci = ControlItem(Index(aControl));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2573
    if (ci.IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2574
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2575
        HandleControlEventL(aControl, aEventType);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2576
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2577
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2578
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2579
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2580
void CMIDForm::TimerExpired()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2581
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2582
    TrappedLayoutAndDraw();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2583
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2584
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2585
/*
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2586
 * Called whenever something's happened which could change the visibility of an item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2587
 * controls. e.g. when made current, when update Items, when scroll.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2588
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2589
void CMIDForm::HandleItemVisibilityChange()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2590
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2591
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2592
    // CUSTOM ITEM ONLY
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2593
    TInt count = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2594
    for (TInt i=0; i<count; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2595
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2596
        if (iItems[i]->Type() == MMIDComponent::ECustomItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2597
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2598
            // this will get the CustomItem's FocusChanged method called which will cause
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2599
            // some visibility events to be sent
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2600
            CMIDControlItem& ci = ControlItem(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2601
            ((CMIDCustomItem&) ci).HandleVisibilityChange();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2602
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2603
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2604
    // END CUSTOM ITEM
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2605
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2606
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2607
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2608
/** Handles an item size change event. This is called by within the plugin, not by java
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2609
side unlike RefreshItemL(TInt).
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2610
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2611
First of all we check if there is a layout pending operation.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2612
If there is one we don't do anything. This is because this method is called during
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2613
control creation when items are inserted in the form. However, it is also called later
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2614
on when the control is already displaying and its size changes. During control creation
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2615
we should do a delayed layout (for performance reasons) wheras if we delay layout in the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2616
second case we get an unpleasant redraw effect because the item control usually draws
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2617
immediately. So we should try and layout+draw immediately in the second case.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2618
We distinguish between the two cases by checking if there is a layout
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2619
operation (which is requested by InsertItemL()). Also, in the second case, instead of
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2620
doing a full LayoutAndDrawL() we only resize elements already assigned to rows and
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2621
update the scroll bars. And then we draw. This is a bit more efficient than recreating
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2622
the rows. Because this method is only called by items that fill an entire row anyway,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2623
we shouln't need to re-create rows.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2624
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2625
void CMIDForm::RefreshItemL(MMIDItem* aItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2626
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2627
    TInt index = iItems.Find(aItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2628
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2629
    if (!LayoutPending() && index != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2630
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2631
        SizeItemsInFormRowsL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2632
        SetRowExtentsWithRespectToScrolledLocation();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2633
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2634
        if ((aItem->Type() == MMIDComponent::ETextField) && (index == iFocused))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2635
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2636
            CMIDTextFieldItem* tf = static_cast<CMIDTextFieldItem*>(aItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2637
            TPoint p;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2638
            TBool success = tf->GetCursorPosL(p);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2639
            if (success)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2640
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2641
                if (p.iY < 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2642
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2643
                    RawScrollRelative(p.iY + 10);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2644
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2645
                else if (p.iY > Height())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2646
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2647
                    RawScrollRelative(Height() - (p.iY + 10));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2648
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2649
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2650
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2651
        RawScrollFinalize(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2652
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2653
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2654
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2655
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2656
 * If the item at aIndex has a default command set for it, then this will be invoked and True
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2657
 * will be returned. False if a command has not been posted
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2658
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2659
// msk: this method is needed if msk is not enabled
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2660
TBool CMIDForm::PostDefaultItemCommandEvent(TInt aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2661
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2662
    if (aIndex != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2663
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2664
        CMIDCommand* defaultCommand = ControlItem(iItems[aIndex]).DefaultCommand();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2665
        if (defaultCommand)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2666
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2667
            iEnv->PostJavaEvent(*iItems[aIndex],EItem,ECommand,defaultCommand->Id());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2668
            return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2669
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2670
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2671
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2672
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2673
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2674
void CMIDForm::AddItemToFormL(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2675
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2676
    aControlItem.SetForm(this);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2677
    aControlItem.SetContainerWindowL(*this);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2678
    aControlItem.ItemAddedToFormL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2679
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2680
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2681
void CMIDForm::RemoveItemFromForm(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2682
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2683
    aControlItem.MakeVisible(EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2684
    aControlItem.SetPosition(TPoint(-Width(), 0));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2685
    // Item is not allowed to access container window from now.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2686
    aControlItem.ItemRemovedFromForm();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2687
    aControlItem.SetForm(NULL);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2688
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2689
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2690
void CMIDForm::UpdateItemCommands(CMIDCommandList* aCommandList, CMIDCommand* aMSKCommand)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2691
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2692
    iDisplayable.SetItemCommandList(aCommandList, aMSKCommand);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2693
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2694
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2695
// msk: this method is needed if msk is not enabled
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2696
TBool CMIDForm::DoDefaultCommand()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2697
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2698
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2699
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2700
        CMIDControlItem& ci = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2701
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2702
        CMIDCommand* defaultCommand = ci.DefaultCommand();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2703
        if (defaultCommand)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2704
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2705
            iEnv->PostJavaEvent(*(iItems[iFocused]), EItem, ECommand, defaultCommand->Id());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2706
            return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2707
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2708
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2709
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2710
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2711
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2712
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2713
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2714
TInt CMIDForm::Row(const CMIDControlItem& aItem) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2715
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2716
    CMIDFormRow* rowPtr = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2717
    return Row(aItem, rowPtr);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2718
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2719
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2720
TInt CMIDForm::Row(const CMIDControlItem& aItem, CMIDFormRow*& aRowPtr) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2721
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2722
    aRowPtr = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2723
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2724
    for (TInt i=0; i < rowCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2725
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2726
        TInt idx = iRows[i]->Find(&aItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2727
        if (idx != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2728
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2729
            aRowPtr = iRows[i];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2730
            return i;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2731
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2732
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2733
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2734
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2735
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2736
CMIDForm::TDirection CMIDForm::ConvertKeyToDirection(TUint aCode)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2737
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2738
    switch (aCode)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2739
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2740
    case EKeyDownArrow:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2741
        return EDown;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2742
    case EKeyUpArrow:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2743
        return EUp;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2744
    case EKeyLeftArrow:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2745
        return ELeft;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2746
    case EKeyRightArrow:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2747
        return ERight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2748
    default:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2749
        return ENone;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2750
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2751
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2752
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2753
// returns the index of a CMIDControlItem in the iItems array. If the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2754
// CMIDControlItem is a CMIDLabelContainerItem, then the index
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2755
// of the stringItem associated with it is returned.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2756
TInt CMIDForm::ItemIndex(CMIDControlItem& aItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2757
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2758
    MMIDItem* item = aItem.iMMidItem;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2759
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2760
    TInt idx = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2761
    TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2762
    while (idx < itemCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2763
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2764
        if (iItems[idx] == item)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2765
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2766
            return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2767
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2768
        idx++;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2769
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2770
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2771
    // OK, so we didn't find it. Maybe it is a CMIDLabelContainerItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2772
    if (IsLabelContainerItem(aItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2773
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2774
        CMIDLabelContainerItem* usil = static_cast<CMIDLabelContainerItem*>(&aItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2775
        return ItemIndex(usil->StringItem());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2776
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2777
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2778
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2779
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2780
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2781
// this method will return the index of the row ABOVE the indicated unconstrained string item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2782
// if the string item was on the top row then KErrNotFound is returned, also if the string item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2783
// could not be found or was not an unconstrained string item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2784
TInt CMIDForm::FirstRowAboveUnconstrainedStringItem(CMIDStringItem& aStringItem) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2785
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2786
    TInt idx = FirstRowOfUnconstrainedStringItem(aStringItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2787
    return (idx == KErrNotFound) ? KErrNotFound : idx - 1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2788
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2789
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2790
// returns the index of the first row of an unconstrained string item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2791
// Returns KErrNotFound if the string item could not be found (or if it was not
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2792
// an unconstrained string item).
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2793
TInt CMIDForm::FirstRowOfUnconstrainedStringItem(CMIDStringItem& aStringItem) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2794
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2795
    TInt idx = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2796
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2797
    while (++idx < rowCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2798
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2799
        CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2800
        TInt innerIdx = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2801
        while (++innerIdx < row->NumItems())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2802
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2803
            CMIDControlItem* ci = row->Item(innerIdx);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2804
            if (IsLabelContainerItem(*ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2805
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2806
                CMIDLabelContainerItem* ucsi = static_cast<CMIDLabelContainerItem*>(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2807
                if (&(ucsi->StringItem()) == &aStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2808
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2809
                    return idx;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2810
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2811
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2812
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2813
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2814
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2815
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2816
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2817
TInt CMIDForm::FirstRowBelowUnconstrainedStringItem(CMIDStringItem& aStringItem) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2818
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2819
    TInt idx = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2820
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2821
    while (--idx < rowCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2822
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2823
        CMIDFormRow* row = iRows[idx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2824
        TInt innerIdx = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2825
        while (++innerIdx < row->NumItems())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2826
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2827
            CMIDControlItem* ci = row->Item(innerIdx);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2828
            if (IsLabelContainerItem(*ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2829
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2830
                CMIDLabelContainerItem* ucsi = static_cast<CMIDLabelContainerItem*>(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2831
                if (&(ucsi->StringItem()) == &aStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2832
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2833
                    return ((idx + 1) >= rowCount) ? KErrNotFound : idx + 1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2834
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2835
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2836
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2837
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2838
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2839
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2840
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2841
TInt CMIDForm::FirstFocusableItemBeforeStartOfUnconstrainedStringItemIdx(CMIDStringItem& aStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2842
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2843
    TInt rowIdx = FirstRowOfUnconstrainedStringItem(aStringItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2844
    if (rowIdx != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2845
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2846
        CMIDFormRow* row = iRows[rowIdx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2847
        TInt idxOnRow = row->NumItems();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2848
        while (--idxOnRow >= 0)  // search backward along the row for the unconstrained string item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2849
            // we probably could assume it is the last element
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2850
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2851
            CMIDControlItem* ci = row->Item(idxOnRow);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2852
            if (IsLabelContainerItem(*ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2853
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2854
                CMIDLabelContainerItem* usil = static_cast<CMIDLabelContainerItem*>(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2855
                CMIDStringItem* si = &(usil->StringItem());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2856
                if (si == &aStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2857
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2858
                    break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2859
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2860
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2861
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2862
        if (idxOnRow > 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2863
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2864
            // there are some items on the row before the start of the unconstrained string item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2865
            while (--idxOnRow >= 0)  // search backward along the row for the first focusable item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2866
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2867
                CMIDControlItem* ci = row->Item(idxOnRow);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2868
                if (ci->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2869
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2870
                    return ItemIndex(*ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2871
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2872
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2873
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2874
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2875
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2876
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2877
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2878
TInt CMIDForm::FirstFocusableItemOnLastLineOfUnconstrainedStringItemIdx(CMIDStringItem& aStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2879
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2880
    TInt rowIdx = FirstRowBelowUnconstrainedStringItem(aStringItem) - 1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2881
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2882
    if (rowIdx == -2)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2883
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2884
        rowIdx = iRows.Count() -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2885
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2886
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2887
    if (rowIdx > KErrNotFound)  // if FirstRowBelowUnconstrainedStringItem returned KErrNotFound then we have -2 so check with '>'
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2888
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2889
        CMIDFormRow* row = iRows[rowIdx];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2890
        TInt idxOnRow = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2891
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2892
        TBool found = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2893
        while (++idxOnRow < row->NumItems())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2894
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2895
            CMIDControlItem* ci = row->Item(idxOnRow);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2896
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2897
            if (ControlBelongsToSameUnconstrainedItem(ci,aStringItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2898
            {//ok we found our item, if the next one is selectable we return
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2899
                found = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2900
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2901
            else if (found && ci->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2902
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2903
                return ItemIndex(*ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2904
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2905
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2906
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2907
    return KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2908
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2909
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2910
/** Return true if aCi belongs to the same unconstrained string item (aStringItem) */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2911
TBool CMIDForm::ControlBelongsToSameUnconstrainedItem(CMIDControlItem* aCi, CMIDStringItem& aStringItem) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2912
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2913
    if (IsLabelContainerItem(*aCi))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2914
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2915
        CMIDLabelContainerItem* usil = static_cast<CMIDLabelContainerItem*>(aCi);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2916
        if (&(usil->StringItem()) == &aStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2917
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2918
            return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2919
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2920
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2921
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2922
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2923
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2924
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2925
/** */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2926
void CMIDForm::RemoveDeletedItem(CMIDControlItem& aItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2927
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2928
    iFocused = KErrNotFound;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2929
    TInt i=-1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2930
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2931
    while (++i < rowCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2932
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2933
        CMIDFormRow* row = iRows[i];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2934
        if (row->RemoveItemIfExists(aItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2935
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2936
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2937
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2938
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2939
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2940
    i = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2941
    TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2942
    while (++i < itemCount)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2943
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2944
        if (aItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2945
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2946
            if (aItem.iMMidItem == iItems[i])
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2947
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2948
                iItems.Remove(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2949
                break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2950
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2951
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2952
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2953
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2954
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2955
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2956
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2957
/////////////////////////////////////////////////////////////////////////////////////////
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2958
// new layout methods
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2959
/////////////////////////////////////////////////////////////////////////////////////////
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2960
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2961
// does the layout for the entire form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2962
void CMIDForm::LayoutFormL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2963
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2964
    DEBUG("CMIDForm::LayoutFormL");
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2965
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2966
    if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2967
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2968
        iLayoutRequestTime = -1;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2969
        iLayoutTimer->Cancel();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2970
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2971
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2972
    TReal prevHeight = HeightOfAllItems() - Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2973
    TInt prevFocusedYPos = 0; // by default it is on top of screen
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2974
    TInt focusedItem = iFocused;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2975
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2976
    if (focusedItem != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2977
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2978
        TRect rect = GetControlRect(focusedItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2979
        prevFocusedYPos    = rect.iTl.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2980
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2981
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2982
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2983
    // scroll bar layouting
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2984
    AknLayoutUtils::LayoutVerticalScrollBar(iSBFrame, Rect(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2985
                                            AknLayoutScalable_Avkon::scroll_pane_cp51().LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2986
    ResetItemsPreferredSizes();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2987
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2988
    // this prevents items from calling layout recursively
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2989
    SetItemsFormPointersToVal(NULL);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2990
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2991
    AssignItemsToRowsL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2992
    SizeItemsInFormRowsL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2993
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2994
    SetItemsFormPointersToVal(this);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2995
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2996
    SetRowExtentsWithRespectToScrolledLocation();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2997
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2998
    TReal newHeight = HeightOfAllItems() - Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  2999
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3000
    if (newHeight != prevHeight)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3001
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3002
        // layout has changed significantly, but we need to keep focused component scrolled so that
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3003
        // user sees it at the same level in viewport
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3004
        TInt newFocusedYPos = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3005
        if (focusedItem != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3006
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3007
            TRect rect = GetControlRect(focusedItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3008
            newFocusedYPos    = rect.iTl.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3009
            TInt delta = prevFocusedYPos - newFocusedYPos;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3010
            if (iScroll != 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3011
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3012
                // correct only if not on top of window
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3013
                ScrollRelative(delta);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3014
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3015
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3016
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3017
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3018
            if (newHeight < prevHeight)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3019
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3020
                // no focused item, just try to keep same component visible
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3021
                iScroll  = newHeight > 0 ? ((TReal) iScroll * (newHeight / prevHeight)) : 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3022
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3023
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3024
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3025
        SetRowExtentsWithRespectToScrolledLocation();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3026
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3027
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3028
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3029
void CMIDForm::ResetItemsPreferredSizes()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3030
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3031
    TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3032
    for (TInt i=0; i < itemCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3033
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3034
        CMIDControlItem& ci = ControlItem(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3035
        ci.ResetPreferredSize();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3036
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3037
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3038
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3039
void CMIDForm::SetItemsFormPointersToVal(CMIDForm* aVal)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3040
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3041
    TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3042
    for (TInt i=0; i < itemCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3043
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3044
        CMIDControlItem& ci = ControlItem(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3045
        ci.SetForm(aVal);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3046
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3047
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3048
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3049
/** If an items preferred size is zero
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3050
we shouldn't add it to the form row and so we skip it */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3051
TBool CMIDForm::SkipNullItem(TInt aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3052
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3053
    CMIDControlItem& ci = ControlItem(iItems[aIndex]);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3054
    if (ci.PreferredSize() == TSize(0, 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3055
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3056
        if (iFocused == aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3057
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3058
            SetFocusedItem(KErrNotFound);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3059
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3060
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3061
        return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3062
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3063
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3064
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3065
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3066
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3067
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3068
    If the current row index is the same as the row count,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3069
    create and append to iRows a new row and store it into
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3070
    iCurrentRow. Increment the current row index. Also reset
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3071
    the current alignment.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3072
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3073
void CMIDForm::CreateNewRowAndSetAsCurrentL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3074
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3075
    CMIDFormRow* row = CMIDFormRow::NewL(*this);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3076
    CleanupStack::PushL(row);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3077
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3078
    User::LeaveIfError(iRows.Append(row));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3079
    CleanupStack::Pop(row);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3080
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3081
    iCurrentRow = row;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3082
    iCurrentRow->SetAlignment(iCurrentAlignment);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3083
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3084
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3085
/** Verify the current alignment and change it if the current row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3086
is empty. If the row is not empty and the item alignement is different
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3087
and the item requires a row break, then add a new row. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3088
void CMIDForm::VerifyRowAlignmentL(TInt aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3089
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3090
    TInt leftRightMask = MMIDItem::ELeft | MMIDItem::ERight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3091
    CMIDControlItem& ci = ControlItem(iItems[aIndex]);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3092
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3093
    if (iCurrentRow->NumItems() == 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3094
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3095
        // this is the first item in the row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3096
        if (!LayoutDefault(ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3097
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3098
            // we take the items alignment for the row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3099
            iCurrentAlignment = MMIDItem::TLayout(ci.Layout() & leftRightMask);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3100
            iCurrentRow->SetAlignment(iCurrentAlignment);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3101
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3102
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3103
    else if (!LayoutMatchesCurrentAlignment(ci, iCurrentAlignment))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3104
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3105
        // the new layout doesn't match the current so go to the next row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3106
        CreateNewRowAndSetAsCurrentL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3107
        iCurrentAlignment = MMIDItem::TLayout(ci.Layout() & leftRightMask);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3108
        iCurrentRow->SetAlignment(iCurrentAlignment);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3109
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3110
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3111
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3112
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3113
     Inserts the specified number of new rows (aNumNewLines). If there is a control
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3114
    item passed as a parameter it means the lines to be inserted are empty lines
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3115
    preceeding the control and therefore should have their empty size set to the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3116
    size of the control.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3117
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3118
     @param aControlItem The control item used to set the size of empty rows.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3119
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3120
    @param aNumNewLines    The number of rows to be added, if equal to zero this method does
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3121
                        nothing
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3122
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3123
void CMIDForm::InsertNewlinesL(TInt aNumNewlines, CMIDControlItem* aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3124
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3125
    for (TInt idx = 0; idx < aNumNewlines; idx++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3126
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3127
        if (aControlItem && aControlItem->LabelControl() && iCurrentRow && iCurrentRow->NumItems() == 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3128
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3129
            iCurrentRow->SetEmptyRowSize(TSize(iInnerWidth,aControlItem->OneLineLabelHeight()));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3130
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3131
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3132
        CreateNewRowAndSetAsCurrentL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3133
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3134
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3135
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3136
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3137
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3138
 * Creates a new string item, using special type CMIDLabelContainerItem.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3139
 * This is a special string item which has no label and is added to wrap
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3140
 * content of a previous string item across several rows.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3141
 *
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3142
 *  @see CMIDLabelContainerItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3143
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3144
void CMIDForm::CreateAndAddLabelContainerItemL(CMIDStringItem& aStringItem,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3145
        CEikLabel& aLabel, TBool aIsStringItemContent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3146
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3147
    // Label container items items have an horizontal margin only
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3148
    // when at the beginning of the row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3149
    TBool hasHMargin = (iCurrentRow->NumItems() == 0);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3150
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3151
    CMIDLabelContainerItem* usil =
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3152
        CMIDLabelContainerItem::NewL(aStringItem, aLabel, hasHMargin);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3153
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3154
    CleanupStack::PushL(usil);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3155
    usil->SetContainerWindowL(*this);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3156
    // sets flag for detecting if label container item is created
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3157
    // from string item label or content
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3158
    usil->SetIsStringItemContent(aIsStringItemContent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3159
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3160
    iCurrentRow->AppendL(usil);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3161
    CleanupStack::Pop(usil);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3162
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3163
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3164
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3165
 *  Inserts a CMIDLabelContainerItem for each line in aTextControl.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3166
 *
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3167
 *  @see CreateAndAddLabelContainerItemL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3168
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3169
void CMIDForm::InsertContainerItemsL(CMIDStringItem& aStringItem,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3170
                                     CMIDItemLabel& aTextControl, TBool aIsStringItemContent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3171
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3172
    TInt numLines = aTextControl.NumLines();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3173
    for (TInt j = 0; j < numLines; j++)
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3174
    {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3175
        CEikLabel* label = aTextControl.LabelAtIdx(j);
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3176
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3177
        if (label)
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3178
        {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3179
            CGraphicsContext::TTextAlign align = aTextControl.LabelAtIdx(j)->iAlignment.TextAlign();
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3180
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3181
            // If aLabel aligment is incorrect relayout aLabel
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3182
            if ((align != CGraphicsContext::ERight &&
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3183
                    iInitialAlignment == MMIDItem::ERight) ||
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3184
                    (align != CGraphicsContext::ELeft &&
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3185
                     iInitialAlignment == MMIDItem::ELeft) ||
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3186
                    (align != CGraphicsContext::ECenter &&
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3187
                     iInitialAlignment == MMIDItem::ECenter))
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3188
            {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3189
                aTextControl.LayoutItemLabel();
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3190
            }
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3191
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3192
            // insert every line as a CMIDLabelContainerItem
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3193
            CreateAndAddLabelContainerItemL(
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3194
                aStringItem, *(label), aIsStringItemContent);
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3195
        }
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3196
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3197
        if (j != (numLines-1))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3198
        { // insert a row break except for the last line
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3199
            CreateNewRowAndSetAsCurrentL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3200
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3201
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3202
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3203
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3204
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3205
    Adds an unconstrained string item to one or more rows. If the item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3206
    has a label always insert a line break (new row) before and if it
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3207
    is followed by constrained item also after the label. Crop the label
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3208
    to the full line width and insert is as a CMIDLabelContainerItem.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3209
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3210
    If the item has no label we can start anywhere in the current row.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3211
    Split its content across the remaining width for the first line
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3212
    and then across the full line width. Insert a CMIDLabelContainerItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3213
    for each line and insert a row break after each CMIDLabelContainerItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3214
    except the last one.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3215
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3216
    Item with label can be inserted as default item when one of this
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3217
    situation occurs:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3218
    - it is the last item in form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3219
    - following item is constrained
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3220
    - following item is unconstrained but has a label
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3221
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3222
    Item without label can be inserted as default item when:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3223
    - it is the only item in form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3224
    - it is the first item in form and following item is
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3225
    unconstrained but has a label (it starts in a new row)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3226
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3227
    @see CMILabelContainerItem, InsertContainerItemsL(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3228
         CreateNewRowAndSetAsCurrentL(), InsertNewlinesL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3229
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3230
void CMIDForm::AddUnconstrainedStringItemL(TInt& aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3231
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3232
    CMIDStringItem* si = (CMIDStringItem*)iItems[aIndex];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3233
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3234
    TInt widthForText = Width();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3235
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3236
    // check if next item is unconstrained and has label
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3237
    TBool nextUnconstrainedHasLabel(EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3238
    if (aIndex < iItems.Count()-1 && ItemIsUnconstrained(aIndex + 1))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3239
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3240
        CMIDStringItem* nextItem = (CMIDStringItem*)iItems[aIndex+1];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3241
        if (nextItem->LabelControl() &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3242
                (nextItem->LabelControl()->Text()->Length() > 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3243
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3244
            nextUnconstrainedHasLabel = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3245
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3246
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3247
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3248
    if (si->LabelControl() && (si->LabelControl()->Text()->Length() > 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3249
    {//item has a label - it should be placed in a new row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3250
        if (iCurrentRow->NumItems() > 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3251
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3252
            CreateNewRowAndSetAsCurrentL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3253
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3254
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3255
        // If the item is last or next item is constrained or next item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3256
        // is unconstrained but has a label (it will be placed in a new row)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3257
        // this item is placed as default item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3258
        if ((aIndex == iItems.Count()-1) || !ItemIsUnconstrained(aIndex + 1)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3259
                || nextUnconstrainedHasLabel)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3260
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3261
            AddDefaultItemL(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3262
            return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3263
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3264
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3265
        // otherwise place the label in one row and then insert the text
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3266
        si->LabelControl()->SetWidthL(widthForText);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3267
        // label of string item is inserted as label container item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3268
        // EFalse identifies that label container item is created from string item label
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3269
        InsertContainerItemsL(*si, *(si->LabelControl()), EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3270
        // string items is divided to label container items due to concatenation of contents
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3271
        // contained in adjacent string items
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3272
        si->SetIsDivided(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3273
        CreateNewRowAndSetAsCurrentL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3274
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3275
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3276
    { // item has no label
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3277
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3278
        // If the item is the only item in form or it is the first item in form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3279
        // and the next item is unconstrained with label (it starts at a new row)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3280
        // this item is placed as default item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3281
        if ((iItems.Count() == 1) || (aIndex == 0 && nextUnconstrainedHasLabel))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3282
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3283
            AddDefaultItemL(aIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3284
            return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3285
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3286
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3287
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3288
    // this is either the remaining width on the current row or the full
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3289
    // line width if we are on a new row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3290
    TInt remainingLineWidth = widthForText - iCurrentRow->CurrentWidth();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3291
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3292
    if ((remainingLineWidth < si->StringContentControl()->FirstWordWidth())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3293
            && (iCurrentRow->NumItems() != 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3294
    { // if not even one word fits then go to the next line unless
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3295
        // we are already on a new line
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3296
        CreateNewRowAndSetAsCurrentL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3297
        remainingLineWidth = widthForText;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3298
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3299
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3300
    // wrap the content to the remaining width for the first line and to
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3301
    // the full width for any other line
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3302
    si->StringContentControl()->SetVariableWidthL(remainingLineWidth, widthForText);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3303
    // content of string item is inserted as label container item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3304
    // ETrue identifies that label container item is created from string item content
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3305
    InsertContainerItemsL(*si, *(si->StringContentControl()), ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3306
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3307
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3308
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3309
 * Adds a standard case item to the current row. It verifies if a new
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3310
 * row should be added and adds one if so. Then it appends the item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3311
 * to the current row.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3312
 *
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3313
 * @see CMIDControlItem, OkToMoveToNextRow()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3314
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3315
void CMIDForm::AddDefaultItemL(TInt& aIndex)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3316
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3317
    CMIDControlItem& ci = ControlItem(iItems[aIndex]);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3318
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3319
    TSize itemSize = LayoutShrink(ci) ? ci.MinimumSize() : ci.PreferredSize();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3320
    ci.SetSizeQuiet(itemSize);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3321
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3322
    if (OkToMoveToNextRow(itemSize))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3323
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3324
        CreateNewRowAndSetAsCurrentL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3325
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3326
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3327
    iCurrentRow->AppendL(&ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3328
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3329
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3330
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3331
    Return true if the given size does not fit into the current
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3332
    row and the row is not empty and the size is not bigger than
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3333
    an empty row.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3334
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3335
TBool CMIDForm::OkToMoveToNextRow(const TSize& aItemSize) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3336
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3337
    return ((iCurrentRow->CurrentWidth() + aItemSize.iWidth) > iInnerWidth) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3338
           !((aItemSize.iWidth > iInnerWidth) && (iCurrentRow->NumItems() == 0));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3339
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3340
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3341
/**
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3342
    Assigns the items to the rows, which are re-created.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3343
*/
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3344
void CMIDForm::AssignItemsToRowsL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3345
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3346
    DeleteRows();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3347
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3348
    //reset current alignment
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3349
    iCurrentAlignment = InitialAlignment();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3350
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3351
    //Create a row, the form must have at least an empty row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3352
    CreateNewRowAndSetAsCurrentL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3353
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3354
    for (TInt i = 0;  i < iItems.Count(); i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3355
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3356
        if (SkipNullItem(i))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3357
        { //zero size items are ignored
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3358
            continue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3359
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3360
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3361
        // if the current alignment changes we may need to change row
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3362
        VerifyRowAlignmentL(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3363
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3364
        CMIDControlItem& ci = ControlItem(iItems[i]);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3365
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3366
        // add any extra rows before the current item if needed
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3367
        InsertNewlinesL(NumNewLinesBefore(ci), &ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3368
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3369
        if (ItemIsUnconstrained(i))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3370
        { // unconstrained string items are processed specially
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3371
            AddUnconstrainedStringItemL(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3372
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3373
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3374
        { // any other item is processed in here
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3375
            AddDefaultItemL(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3376
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3377
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3378
        // add any additional row breaks if needed
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3379
        InsertNewlinesL(NumNewLinesAfter(ci), &ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3380
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3381
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3382
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3383
/** Return true if the item is an unconstrained string item, false otherwise */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3384
TBool CMIDForm::ItemIsUnconstrained(TInt aIndex) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3385
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3386
    if (aIndex >= 0 && aIndex < iItems.Count())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3387
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3388
        CMIDControlItem& ci = ControlItem(iItems[aIndex]);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3389
        return (IsStringItem(ci) && ((CMIDStringItem*)&ci)->IsUnconstrainedStringItem());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3390
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3391
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3392
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3393
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3394
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3395
TBool CMIDForm::LayoutMatchesCurrentAlignment(CMIDControlItem& aControlItem,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3396
        MMIDItem::TLayout aCurrentAlignment)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3397
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3398
    TInt leftRightMask = MMIDItem::ELeft | MMIDItem::ERight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3399
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3400
    return ((aControlItem.Layout() & leftRightMask) == MMIDItem::EDefault) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3401
           ((aControlItem.Layout() & leftRightMask) == aCurrentAlignment);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3402
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3403
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3404
TBool CMIDForm::LayoutDefault(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3405
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3406
    TInt leftRightMask = MMIDItem::ELeft | MMIDItem::ERight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3407
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3408
    return ((aControlItem.Layout() & leftRightMask) == MMIDItem::EDefault);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3409
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3410
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3411
TBool CMIDForm::LayoutNewLineBefore(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3412
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3413
    return (aControlItem.Layout() & MMIDItem::ENewLineBefore);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3414
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3415
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3416
TBool CMIDForm::LayoutNewLineAfter(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3417
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3418
    return (aControlItem.Layout() & MMIDItem::ENewLineAfter);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3419
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3420
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3421
/** Return true if the LAYOUT_SHRINK directive has been set. For
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3422
string items which have one or both dimensions of the preferred
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3423
size set the layout shrink directive is ignored. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3424
TBool CMIDForm::LayoutShrink(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3425
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3426
    if (IsStringItem(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3427
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3428
        CMIDStringItem* si = (CMIDStringItem*)(&aControlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3429
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3430
        if (si->WidthOrHeightSpecified())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3431
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3432
            return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3433
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3434
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3435
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3436
    return (aControlItem.Layout() & MMIDItem::EShrink);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3437
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3438
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3439
/** Return true if the LAYOUT_EXPAND directive has been set. For
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3440
string items which have one or both dimensions of the preferred
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3441
size set the layout expand directive is ignored. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3442
TBool CMIDForm::LayoutExpand(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3443
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3444
    if (IsStringItem(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3445
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3446
        CMIDStringItem* si = (CMIDStringItem*)(&aControlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3447
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3448
        if (si->WidthOrHeightSpecified())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3449
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3450
            return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3451
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3452
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3453
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3454
    return (aControlItem.Layout() & MMIDItem::EExpand);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3455
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3456
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3457
/** Return true if the LAYOUT_VSHIRNK directive has been set. For
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3458
string items which have one or both dimensions of the preferred
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3459
size set the layout vertical shrink directive is ignored. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3460
TBool CMIDForm::LayoutVerticalShrink(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3461
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3462
    if (IsStringItem(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3463
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3464
        CMIDStringItem* si = (CMIDStringItem*)(&aControlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3465
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3466
        if (si->WidthOrHeightSpecified())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3467
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3468
            return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3469
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3470
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3471
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3472
    return (aControlItem.Layout() & MMIDItem::EVerticalShrink);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3473
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3474
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3475
/** Return true if the LAYOUT_VEXPAND directive has been set. For
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3476
string items which have one or both dimensions of the preferred
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3477
size set the layout vertical expand directive is ignored. */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3478
TBool CMIDForm::LayoutVerticalExpand(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3479
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3480
    if (IsStringItem(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3481
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3482
        CMIDStringItem* si = (CMIDStringItem*)(&aControlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3483
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3484
        if (si->WidthOrHeightSpecified())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3485
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3486
            return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3487
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3488
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3489
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3490
    return (aControlItem.Layout() & MMIDItem::EVerticalExpand);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3491
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3492
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3493
TBool CMIDForm::LayoutVerticalCenter(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3494
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3495
    TInt layout = aControlItem.Layout();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3496
    layout &= MMIDItem::EVerticalCenter;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3497
    return (layout == MMIDItem::EVerticalCenter);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3498
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3499
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3500
TBool CMIDForm::LayoutBottom(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3501
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3502
    TInt layout = aControlItem.Layout();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3503
    layout &= MMIDItem::EVerticalCenter;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3504
    return (layout == MMIDItem::EBottom) || (layout == 0);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3505
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3506
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3507
TBool CMIDForm::IsStringItem(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3508
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3509
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3510
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3511
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3512
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3513
    return (aControlItem.iMMidItem->Type() == MMIDComponent::EStringItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3514
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3515
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3516
TBool CMIDForm::IsStringItemHyperlink(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3517
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3518
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3519
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3520
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3521
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3522
    if (aControlItem.iMMidItem->Type() == MMIDComponent::EStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3523
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3524
        return (((CMIDStringItem&) aControlItem).Appearance() == MMIDItem::EHyperLink);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3525
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3526
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3527
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3528
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3529
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3530
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3531
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3532
TBool CMIDForm::IsStringItemButton(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3533
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3534
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3535
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3536
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3537
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3538
    if (aControlItem.iMMidItem->Type() == MMIDComponent::EStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3539
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3540
        return (((CMIDStringItem&) aControlItem).Appearance() == MMIDItem::EButton);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3541
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3542
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3543
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3544
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3545
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3546
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3547
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3548
TBool CMIDForm::IsCustomItem(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3549
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3550
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3551
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3552
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3553
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3554
    return (aControlItem.iMMidItem->Type() == MMIDComponent::ECustomItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3555
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3556
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3557
TBool CMIDForm::IsGaugeItem(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3558
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3559
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3560
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3561
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3562
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3563
    return (aControlItem.iMMidItem->Type() == MMIDComponent::EGauge);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3564
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3565
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3566
TBool CMIDForm::IsTextFieldItem(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3567
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3568
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3569
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3570
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3571
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3572
    return (aControlItem.iMMidItem->Type() == MMIDComponent::ETextField);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3573
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3574
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3575
TBool CMIDForm::IsChoiceGroup(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3576
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3577
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3578
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3579
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3580
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3581
    return (aControlItem.iMMidItem->Type() == MMIDComponent::EChoiceGroup);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3582
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3583
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3584
TBool CMIDForm::IsPopupChoiceGroup(CMIDControlItem& aControlItem)
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3585
{
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3586
    if (aControlItem.iMMidItem
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3587
            && aControlItem.iMMidItem->Type() == MMIDComponent::EChoiceGroup)
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3588
    {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3589
        CMIDChoiceGroupItem& cgItem = static_cast<CMIDChoiceGroupItem&>(aControlItem);
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3590
        CMIDChoiceGroupControl* cgControl =
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3591
            static_cast<CMIDChoiceGroupControl*>(cgItem.ComponentControl(1));
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3592
        if (cgControl && cgControl->ChoiceType() == MMIDChoiceGroup::EPopup)
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3593
        {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3594
            return ETrue;
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3595
        }
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3596
    }
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3597
    return EFalse;
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3598
}
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3599
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3600
TBool CMIDForm::IsDateField(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3601
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3602
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3603
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3604
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3605
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3606
    return (aControlItem.iMMidItem->Type() == MMIDComponent::EDateField);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3607
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3608
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3609
TBool CMIDForm::IsLabelContainerItem(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3610
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3611
    return (aControlItem.Type() == KLabelContainerItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3612
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3613
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3614
TBool CMIDForm::IsSpacerUsedForFormatting(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3615
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3616
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3617
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3618
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3619
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3620
    if (aControlItem.iMMidItem->Type() == MMIDComponent::ESpacer)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3621
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3622
        CMIDSpacer* spacer = static_cast<CMIDSpacer*>(&aControlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3623
        return spacer->UsedForStringFormatting();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3624
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3625
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3626
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3627
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3628
TBool CMIDForm::IsImageItem(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3629
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3630
    if (!aControlItem.iMMidItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3631
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3632
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3633
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3634
    return (aControlItem.iMMidItem->Type() == MMIDItem::EImageItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3635
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3636
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3637
#ifdef RD_JAVA_S60_RELEASE_9_2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3638
void CMIDForm::PostPendingUpEventL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3639
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3640
    MMIDItem* curItem = CurrentItem();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3641
    if (curItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3642
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3643
        CMIDControlItem& item = ControlItem(curItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3644
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3645
        if (IsChoiceGroup(item))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3646
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3647
            CMIDChoiceGroupItem* cgItem = static_cast<CMIDChoiceGroupItem*>(&item);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3648
            cgItem->PostPendingUpEventL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3649
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3650
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3651
}
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3652
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3653
TInt CMIDForm::FormRowIndex(CMIDFormRow* aRow)
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3654
{
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3655
    return iRows.Find(aRow);
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3656
}
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3657
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3658
CMIDFormRow* CMIDForm::FormRow(TInt aIndex)
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3659
{
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3660
    if (iRows.Count() > aIndex)
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3661
    {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3662
        return iRows[aIndex];
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3663
    }
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3664
    return NULL;
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  3665
}
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3666
#endif // RD_JAVA_S60_RELEASE_9_2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3667
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3668
// returns: The number of new lines before an item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3669
//          This only takes into account new lines that come from
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3670
//          preceeding a string item with new line characters.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3671
TInt CMIDForm::NumNewLinesBefore(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3672
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3673
    if (IsStringItem(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3674
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3675
        CMIDStringItem* si = (CMIDStringItem*)(&aControlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3676
        TInt nLinesBefore = si->NumNewlinesBefore();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3677
        if (nLinesBefore > 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3678
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3679
            return nLinesBefore;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3680
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3681
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3682
    if (iCurrentRow && iCurrentRow->NumItems() == 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3683
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3684
        return 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3685
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3686
    return LayoutNewLineBefore(aControlItem) ? 1 : 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3687
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3688
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3689
// returns: The number of new lines that should appear after an item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3690
//          This takes into account the new lines that can occour from
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3691
//          newlines at the end of a string item, and if there are none
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3692
//          of these, then it returns 1 if the Layout NewLineAfter
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3693
//          directive has been used and 0 otherwise.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3694
TInt CMIDForm::NumNewLinesAfter(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3695
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3696
    if (IsStringItem(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3697
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3698
        CMIDStringItem* si = (CMIDStringItem*)(&aControlItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3699
        if (si->NumNewlinesAfter() > 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3700
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3701
            TInt nLinesAfter = si->NumNewlinesAfter();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3702
            if (nLinesAfter > 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3703
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3704
                return nLinesAfter;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3705
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3706
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3707
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3708
    return LayoutNewLineAfter(aControlItem) ? 1 : 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3709
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3710
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3711
// effects:  Sizes the items within the rows based on their layout characteristics
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3712
// modifies: CMIDFormRow
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3713
void CMIDForm::SizeItemsInFormRowsL()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3714
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3715
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3716
    for (TInt i=0; i < rowCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3717
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3718
        iRows[i]->SizeItemsL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3719
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3720
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3721
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3722
// effects:  Deletes all rows in the Form. It doesn't affect the items that have
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3723
//           been added to the form.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3724
// modifies: CMIDForm, CMIDFormRow
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3725
void CMIDForm::DeleteRows()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3726
{
18
9ac0a0a7da70 Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  3727
    // By deleting rows we are losing pointers to original items.
9ac0a0a7da70 Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  3728
    // To avoid any problems with using iPointedControl, which
9ac0a0a7da70 Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  3729
    // could points to invalid object (e.g. used in
9ac0a0a7da70 Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  3730
    // CMIDForm::HandleHighlightTimer or
9ac0a0a7da70 Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  3731
    // in CMIDForm::HandlePhysicsPointerEventL),
9ac0a0a7da70 Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  3732
    // iPointedControl must be set to NULL.
9ac0a0a7da70 Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  3733
    iPointedControl = NULL;
9ac0a0a7da70 Revision: v2.1.26
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 17
diff changeset
  3734
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3735
    for (TInt i=0; i < iRows.Count(); i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3736
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3737
        delete iRows[i];
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3738
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3739
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3740
    iRows.Reset();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3741
    iCurrentRow = NULL;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3742
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3743
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3744
TInt CMIDForm::HeightOfAllItems()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3745
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3746
    return iTotalFormHeight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3747
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3748
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3749
void CMIDForm::UpdateHeightOfAllItems()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3750
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3751
    TInt yTopMargin = iFormRect.Rect().iTl.iY - iMidpFormRect.Rect().iTl.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3752
    TInt yBottomMargin = iMidpFormRect.Rect().iBr.iY - iFormRect.Rect().iBr.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3753
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3754
    iTotalFormHeight = yTopMargin;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3755
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3756
    TInt rowCount = iRows.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3757
    for (TInt i=0; i < rowCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3758
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3759
        iTotalFormHeight += iRows[i]->Size().iHeight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3760
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3761
    // Form bottom margin is added
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3762
    iTotalFormHeight += yBottomMargin;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3763
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3764
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3765
/* HandleResourceChange
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3766
 *
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3767
 * This method is called after a resource change event, for example after
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3768
 * screen dynamic resolution change.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3769
 *
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3770
 * In the case of a screen dynamic resolution change we notify all items and
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3771
 * repeat the entire form layout.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3772
 *
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3773
 * We calculate the % of form that has been scrolled so far and we
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3774
 * modify iScroll so that we have scrolled the same % of form after resolution
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3775
 * change. Note that the max extent of iScroll is HeightOfAllItems() - Height()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3776
 * and not simply HeightOfAllItems() as one may think, see
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3777
 * SetRowExtentsWithRespectToScrolledLocation(). Also note that applying a %
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3778
 * scrolling does not necessarily mean the same items will be on screen after a
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3779
 * resolution change.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3780
 * Especially when changing from portrait to landscape or vice-versa the
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3781
 * number of items on a row vary greatly and as a consequence the number of
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3782
 * rows may vary. Therefore, if there is a focused item on screen before
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3783
 * resolution change (iFocused not KErrNotFound) we make sure this item is
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3784
 * visible and focused after res change by scrolling to it, see SetFocusedItem()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3785
 * and ScrollToFocused().
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3786
 */
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3787
void CMIDForm::HandleResourceChange(TInt aType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3788
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3789
    TInt maxScrollExtentOld = HeightOfAllItems() - Height(); //max extent of iScroll
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3790
    CCoeControl::HandleResourceChange(aType);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3791
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3792
    if (aType == KEikDynamicLayoutVariantSwitch)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3793
    { // dynamic resolution change
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3794
        TInt focusedItem = iFocused;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3795
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3796
        UpdateMemberVariables();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3797
        UpdateHeightOfAllItems();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3798
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3799
        TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3800
        for (TInt i=0; i < itemCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3801
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3802
            CMIDControlItem& controlItem = ControlItem(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3803
            controlItem.ResolutionChange(aType);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3804
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3805
            if (controlItem.LabelControl())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3806
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3807
                controlItem.LabelControl()->ResolutionChange();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3808
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3809
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3810
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3811
        TInt maxScrollExtentNew = HeightOfAllItems() - Height(); //max extent of iScroll
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3812
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3813
        TRAPD(err,LayoutFormL());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3814
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3815
        if (err == KErrNone)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3816
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3817
            if ((maxScrollExtentNew <= 0) && (maxScrollExtentOld > 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3818
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3819
                // scroll on top
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3820
                RawScroll(0);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3821
                if (focusedItem != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3822
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3823
                    // restore the form item focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3824
                    CMIDControlItem& control = ControlItem(focusedItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3825
                    control.RestoreInnerFocus();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3826
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3827
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3828
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3829
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3830
                if ((maxScrollExtentNew > 0) || (maxScrollExtentOld > 0))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3831
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3832
                    // if there is something focused
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3833
                    if (focusedItem != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3834
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3835
                        // restore the form item focus
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3836
                        CMIDControlItem& control = ControlItem(focusedItem);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3837
                        ScrollToFocused();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3838
                        control.RestoreInnerFocus();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3839
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3840
                    // if scroll out of maxScrollExtent
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3841
                    if (maxScrollExtentNew+iScroll < 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3842
                    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3843
                        // scroll to bottom
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3844
                        RawScroll(-maxScrollExtentNew);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3845
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3846
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3847
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3848
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3849
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3850
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3851
        SetHighlightBackgroundRects();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3852
        HandleItemVisibilityChange();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3853
        UpdateScrollBar();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3854
        DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3855
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3856
    else if (aType == KEikColorResourceChange || aType == KAknsMessageSkinChange ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3857
             aType == KUidValueCoeColorSchemeChangeEvent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3858
    {//skin or color scheme change
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3859
        TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3860
        for (TInt i=0; i < itemCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3861
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3862
            CMIDControlItem& controlItem = ControlItem(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3863
            controlItem.ColorChange(aType);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3864
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3865
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3866
        // send this event also to form scrollbar
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3867
        CEikScrollBar* sb = iSBFrame->GetScrollBarHandle(CEikScrollBar::EVertical);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3868
        if (sb)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3869
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3870
            sb->HandleResourceChange(aType);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3871
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3872
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3873
    else if ((aType == KEikMessageUnfadeWindows) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3874
             (aType == KEikMessageFadeAllWindows))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3875
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3876
        iLastFadeMessage = aType;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3877
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3878
    else if ((aType == KEikMessageWindowsFadeChange) &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3879
             ((iLastFadeMessage == KEikMessageUnfadeWindows) ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3880
              (iLastFadeMessage == KEikMessageFadeAllWindows)))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3881
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3882
        TInt itemCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3883
        for (TInt i=0; i < itemCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3884
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3885
            CMIDControlItem& controlItem = ControlItem(i);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3886
            controlItem.HandleWindowFade(iLastFadeMessage == KEikMessageFadeAllWindows);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3887
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3888
        iLastFadeMessage = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3889
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3890
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3891
    UpdatePhysics();
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  3892
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  3893
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  3894
    UpdateTactileFeedbackDensity();
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  3895
#endif // RD_JAVA_ADVANCED_TACTILE_FEEDBACK
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3896
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3897
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3898
TBool CMIDForm::TryDetectLongTapL(const TPointerEvent &aPointerEvent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3899
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3900
    return iDisplayable.TryDetectLongTapL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3901
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3902
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3903
#ifdef RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3904
void CMIDForm::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3905
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3906
    if (AknLayoutUtils::PenEnabled())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3907
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3908
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3909
        if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3910
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3911
            LayoutFormL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3912
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3913
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3914
        TInt pixelIndex;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3915
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3916
        switch (aEventType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3917
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3918
        case EEikScrollUp:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3919
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3920
            pixelIndex = iScroll + (Height() / KScrollAmountDivider);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3921
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3922
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3923
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3924
        case EEikScrollDown:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3925
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3926
            pixelIndex = iScroll - (Height() / KScrollAmountDivider);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3927
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3928
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3929
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3930
        case EEikScrollPageUp:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3931
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3932
            pixelIndex = iScroll + Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3933
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3934
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3935
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3936
        case EEikScrollPageDown:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3937
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3938
            pixelIndex = iScroll - Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3939
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3940
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3941
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3942
        default://thumb drag
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3943
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3944
            //scroll form if thumb position has moved more than 1/10 of the screen height either up or down
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3945
            //or thumb position is at top or at bottom of the scrollbar.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3946
            if (-aScrollBar->ThumbPosition() < (iScroll - (Height() / KScrollAmountDividerForThumbDrag))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3947
                    || -aScrollBar->ThumbPosition() > (iScroll + (Height() / KScrollAmountDividerForThumbDrag))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3948
                    || aScrollBar->ThumbPosition() == 0
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3949
                    || aScrollBar->ThumbPosition() == aScrollBar->Model()->MaxThumbPos())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3950
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3951
                aScrollBar->DrawNow();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3952
                pixelIndex = - aScrollBar->ThumbPosition();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3953
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3954
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3955
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3956
                return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3957
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3958
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3959
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3960
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3961
        RawScroll(pixelIndex);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3962
        RawScrollFinalize(ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3963
        UpdatePhysics();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3964
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3965
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3966
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3967
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3968
TBool CMIDForm::StringItemContainsPoint(CMIDStringItem* aStringItem, const TPoint& aPoint) const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3969
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3970
    CMIDControlItem* ci = ControlItemAtPoint(aPoint);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3971
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3972
    if (ci)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3973
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3974
        if (IsLabelContainerItem(*ci))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3975
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3976
            CMIDLabelContainerItem *lci = static_cast<CMIDLabelContainerItem*>(ci);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3977
            CMIDStringItem& si = lci->StringItem();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3978
            if (&si == aStringItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3979
            { // LabelContainer item is (part of) StringItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3980
                if (si.IsDivided())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3981
                { // StringItem was divided due to concatenation of contents
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3982
                    if (lci->IsStringItemContent())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3983
                    { // return ETrue if is pointed to StringItem content
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3984
                        return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3985
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3986
                    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3987
                    { // return EFasle if is pointed to StringItem label
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3988
                        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3989
                    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3990
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3991
                else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3992
                { // StringItem was not divided, pointed directly to unconstrained StringItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3993
                    return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3994
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3995
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3996
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3997
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3998
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  3999
            return (ci == aStringItem && aStringItem->TappingActionRect().Contains(aPoint));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4000
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4001
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4002
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4003
    return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4004
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4005
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4006
TBool CMIDForm::IsFocusChangingWithPen() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4007
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4008
    return iFocusChangingWithPen;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4009
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4010
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4011
#endif //RD_SCALABLE_UI_V2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4012
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4013
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4014
void CMIDForm::HandleForegroundL(TBool aForeground)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4015
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4016
    // send HandleForegroundL notification to gauge items
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4017
    TInt itemsCount = iItems.Count();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4018
    for (TInt i=0; i < itemsCount; i++)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4019
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4020
        if (iItems[i]->Type() == MMIDComponent::EGauge)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4021
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4022
            CMIDGaugeItem* gauge = static_cast<CMIDGaugeItem*>(iItems[i]);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4023
            ASSERT(gauge);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4024
            gauge->HandleForegroundL(aForeground);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4025
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4026
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4027
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4028
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4029
CMIDPopupNoteController* CMIDForm::GetPopupNoteController() const
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4030
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4031
    return  iPopupController;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4032
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4033
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4034
TInt CMIDForm::GetMidpNaviPos()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4035
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4036
    TAknLayoutRect mainMidpPane;
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4037
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4038
    // get main pane size from Avkon (size in pixels)
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4039
#ifdef RD_JAVA_S60_RELEASE_9_2
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4040
    TRect mainPane;
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4041
    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPane);
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4042
    mainMidpPane.LayoutRect(mainPane,
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4043
                            AknLayoutScalable_Avkon::main_midp_pane().LayoutLine());
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4044
#else
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4045
    mainMidpPane.LayoutRect(iEikonEnv->ScreenDevice()->SizeInPixels(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4046
                            AknLayoutScalable_Avkon::main_midp_pane().LayoutLine());
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4047
#endif // RD_JAVA_S60_RELEASE_9_2
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4048
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4049
    // getting form size depends on screen orientation
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4050
    TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4051
    iMidpFormRect.LayoutRect(mainMidpPane.Rect(),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4052
                             AknLayoutScalable_Avkon::midp_form_pane(variety).LayoutLine());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4053
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4054
    // different between screen size and form size
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4055
    TInt xFormDiff = mainMidpPane.Rect().iBr.iX - iMidpFormRect.Rect().iBr.iX;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4056
    // width of navi bar position only for ( iAlignment == MMIDItem::ERight )
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4057
    TInt xNaviPos  = iMidpFormRect.Rect().iTl.iX - xFormDiff;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4058
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4059
    return xNaviPos;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4060
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4061
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4062
void CMIDForm::UpdatePhysics()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4063
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4064
    if (iPhysics)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4065
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4066
        TSize worldSize(Width(), HeightOfAllItems());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4067
        TSize viewSize(Width(), Height());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4068
        TPoint viewCenter(Width() / 2, -iScroll + Height() / 2);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4069
        TRAP_IGNORE(iPhysics->InitPhysicsL(worldSize, viewSize, viewCenter));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4070
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4071
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4072
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4073
TInt CMIDForm::HighlightTimerCallback(TAny* aPtr)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4074
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4075
    CMIDForm* me = static_cast<CMIDForm*>(aPtr);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4076
    me->HandleHighlightTimer();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4077
    return 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4078
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4079
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4080
void CMIDForm::HandleHighlightTimer()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4081
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4082
    iHighlightTimer->Cancel();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4083
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4084
    if (iPointedControl && iPointedControl->IsSelectable())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4085
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4086
        // If tactile feedback has not been given already
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4087
        // give basic tactile feedback when focus changes.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4088
        // Don't give tactile feedback for button because it is handled
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4089
        // by button implementation.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4090
#ifdef RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4091
        if (!iFeedbackExecutedInPointerDown)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4092
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4093
            DoFeedbackOnFocusChange(*iPointedControl);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4094
            iFeedbackExecutedInPointerDown = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4095
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4096
#endif // RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4097
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4098
        TInt itemIndex = ItemIndex(*iPointedControl);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4099
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4100
        if (itemIndex != iFocused)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4101
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4102
            SetFocusedItem(itemIndex, ENone, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4103
            DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4104
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4105
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4106
        if (!PhysicsScrolling() && !iUpEventSent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4107
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4108
            TRAP_IGNORE(ForwardPointerEventToItemL(iLastPointerDownEvent));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4109
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4110
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4111
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4112
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4113
void CMIDForm::SetHighlightBackgroundRects()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4114
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4115
    if (iFocused == KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4116
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4117
        return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4118
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4119
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4120
    CMIDControlItem& ci = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4121
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4122
    // Limit rect size to screen size. If Rect() is way larger
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4123
    // than screen, the svg engine will not cope handling that.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4124
    TRect r(ci.Size());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4125
    TRect s;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4126
    AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, s);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4127
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4128
    if (r.Intersects(s))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4129
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4130
        s.Intersection(r);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4131
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4132
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4133
    TRect rect(s);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4134
    rect.Normalize(); // ensure positive w & h, just in case
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4135
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4136
    TAknLayoutRect topLeft ;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4137
    topLeft.LayoutRect(rect, SkinLayout::Input_field_skin_placing__general__Line_2());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4138
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4139
    TAknLayoutRect bottomRight;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4140
    bottomRight.LayoutRect(rect, SkinLayout::Input_field_skin_placing__general__Line_5());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4141
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4142
    TRect outerRect = TRect(topLeft.Rect().iTl, bottomRight.Rect().iBr);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4143
    TRect innerRect = TRect(topLeft.Rect().iBr, bottomRight.Rect().iTl);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4144
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4145
    iHighlightedBackgroundCc->SetParentContext(iDisplayable.BackGroundControlContext());
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4146
    iHighlightedBackgroundCc->SetFrameRects(outerRect, innerRect);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4147
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4148
    UpdateHighlightBackgroundPosition();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4149
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4150
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4151
void CMIDForm::UpdateHighlightBackgroundPosition()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4152
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4153
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4154
    if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4155
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4156
        CMIDControlItem& ci = ControlItem(iFocused);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4157
        TPoint highlightPosition = ci.PositionRelativeToScreen();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4158
        TRect focusedRect = ci.Rect();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4159
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4160
        // Max size of the higlight background is limited to screen size,
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4161
        // see SetHighlightBackgroundRects().
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4162
        // Need to adjust the highlight position if focused item is partially visible
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4163
        // on top of the form and it is larger than screen.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4164
        if (focusedRect.iTl.iY < 0 && focusedRect.iBr.iY > 0)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4165
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4166
            TRect screen;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4167
            AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screen);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4168
            if (focusedRect.Height() > screen.Height())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4169
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4170
                if (focusedRect.iBr.iY > iSize.iHeight)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4171
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4172
                    // Focused item fills the visible form area fully
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4173
                    highlightPosition.iY = 0;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4174
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4175
                else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4176
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4177
                    // Bottom of focused item is in the visible form area
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4178
                    highlightPosition.iY += focusedRect.Height() - screen.Height();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4179
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4180
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4181
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4182
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4183
        iHighlightedBackgroundCc->SetParentPos(highlightPosition);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4184
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4185
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4186
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4187
void CMIDForm::HandlePhysicsPointerEventL(const TPointerEvent& aPointerEvent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4188
{
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4189
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4190
    iLastPointerEventType = aPointerEvent.iType;
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4191
#endif
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4192
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4193
    if (iPhysics && iPhysics->CanBeStopped())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4194
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4195
        switch (aPointerEvent.iType)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4196
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4197
        case TPointerEvent::EButton1Down:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4198
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4199
            iPreventPhysicsScrolling = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4200
            iFlickStoppedOnDownEvent = iFlickOngoing;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4201
            iFeedbackExecutedInPointerDown = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4202
            iPhysics->Stop();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4203
            CMIDControlItem* ci = ControlItemAtPoint(aPointerEvent.iPosition);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4204
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4205
            // Physics scrolling was not ongoing and tap hit already selected item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4206
            // Then forward pointer event to the item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4207
            if (ci && IsCurrentItem((CMIDItem*)ci) && !iFlickStoppedOnDownEvent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4208
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4209
                iPointedControl = ci;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4210
                ForwardPointerEventToItemL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4211
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4212
            else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4213
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4214
                // Tactile fedback is executed when kinetic scrolling is stopped on down event.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4215
                if (iFlickStoppedOnDownEvent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4216
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4217
#ifdef RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4218
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4219
                    iFeedback->InstantFeedback(ETouchFeedbackList);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4220
#else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4221
                    iFeedback->InstantFeedback(ETouchFeedbackBasic);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4222
#endif // RD_JAVA_ADVANCED_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4223
                    iFeedbackExecutedInPointerDown = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4224
#endif // RD_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4225
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4226
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4227
                // Pointed control changes.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4228
                if (ci && ci->IsSelectable() && (MMIDItem*)ci != CurrentItem())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4229
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4230
                    iFocusChangingWithPen = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4231
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4232
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4233
                // Start highlight timer
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4234
                iPointedControl = ci;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4235
                iHighlightTimer->Cancel();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4236
                // Start highlight timer if some any control is tapped.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4237
                if (iPointedControl)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4238
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4239
                    TInt highlightTimeout = iPhysics->HighlightDelay() * 1000;
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4240
                    if (IsPopupChoiceGroup(*iPointedControl))
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4241
                    {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4242
                        highlightTimeout /= 2;
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4243
                    }
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4244
                    iHighlightTimer->Start(TTimeIntervalMicroSeconds32(highlightTimeout),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4245
                                           TTimeIntervalMicroSeconds32(highlightTimeout),
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4246
                                           TCallBack(HighlightTimerCallback, this));
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4247
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4248
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4249
            // Setup members
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4250
            iStartPosition = aPointerEvent.iPosition;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4251
            iLastPointerDownEvent = aPointerEvent;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4252
            iUpEventSent = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4253
            iStartTime.HomeTime();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4254
            iLastDragPosition = aPointerEvent.iPosition;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4255
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4256
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4257
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4258
        // EDrag
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4259
        case TPointerEvent::EDrag:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4260
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4261
            TInt dragY = iStartPosition.iY - aPointerEvent.iPosition.iY;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4262
            TInt dragX = iStartPosition.iX - aPointerEvent.iPosition.iX;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4263
            iDisplayable.TryDetectLongTapL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4264
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4265
            // Override triggering of physicsScrolling in case of doing text painting in TextField-item
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4266
            // or moving slider in Gauge-item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4267
            if (!iPreventPhysicsScrolling && iPointedControl && iPointedControl->iMMidItem &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4268
                    iPointedControl->iMMidItem->Type() == MMIDComponent::ETextField)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4269
            {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4270
                // If physics scrolling is not ongoing (abs(dragY) < DragTreshold)
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4271
                // then stop flicking and forward event to the item (iPreventPhysicsScrolling = ETrue).
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4272
                if ((Abs(dragX) > iPhysics->DragThreshold()) && (Abs(dragY) < iPhysics->DragThreshold()
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4273
                        && !iPanningOngoing))
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4274
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4275
                    iPreventPhysicsScrolling = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4276
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4277
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4278
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4279
            // Check whether DragTreshold for panning is exceeded. If yes, then cancel timer and longtap.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4280
            if (!iPanningOngoing && Abs(dragY) > iPhysics->DragThreshold() && !iPreventPhysicsScrolling)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4281
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4282
                iPanningOngoing = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4283
                iHighlightTimer->Cancel();
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4284
                // Start panning from aPointerEvent.iPosition with iPhysics->DragThreshold() margin
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4285
                iLastDragPosition = aPointerEvent.iPosition;
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4286
                iPhysics->SetPanningPosition(iLastDragPosition - aPointerEvent.iPosition);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4287
                //Forward one drag event to the focused textField or Gauge when panning is triggered
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4288
                if ((iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4289
                        && IsTextFieldItem(ControlItem(iFocused)))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4290
                {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4291
                    ControlItem(iFocused).HandlePointerEventL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4292
                }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4293
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4294
            // If panning is already ongoing. Update panning position. Also we redraw entire Form
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4295
            // to prevent unexpected behavior(artifacts on the screen) during flick scrolling and
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4296
            // to make scrolling smoother.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4297
            else if (iPanningOngoing)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4298
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4299
                iPhysics->SetPanningPosition(iLastDragPosition - aPointerEvent.iPosition);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4300
                iLastDragPosition = aPointerEvent.iPosition;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4301
                DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4302
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4303
            // If dragged outside of StringItem area or panning starts, then up event is sent to the item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4304
            if (!iUpEventSent && iPointedControl && IsStringItem(*iPointedControl)  && (iPanningOngoing ||
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4305
                    (iPointedControl && !iPointedControl->Rect().Contains(aPointerEvent.iPosition)))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4306
               )
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4307
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4308
                TPointerEvent pointerEvent = aPointerEvent;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4309
                pointerEvent.iType = TPointerEvent::EButton1Up;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4310
                ForwardPointerEventToItemL(pointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4311
                iPointedControl = ControlItemAtPoint(aPointerEvent.iPosition);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4312
                iUpEventSent = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4313
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4314
            // If physics scrolling is not ongoing forward event to the item.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4315
            else if (!iHighlightTimer->IsActive() && !PhysicsScrolling() &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4316
                     (iPointedControl && iPointedControl->Rect().Contains(aPointerEvent.iPosition)))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4317
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4318
                ForwardPointerEventToItemL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4319
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4320
#ifdef RD_JAVA_S60_RELEASE_9_2
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4321
            // ChoiceGroup gets drag events while physics scrolling.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4322
            // Enables internal highlight disappearing when panning begins.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4323
            // We have control if there is any Item on Form.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4324
            else if (!iHighlightTimer->IsActive()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4325
                     && (iFocused > KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4326
                     && IsChoiceGroup(ControlItem(iFocused))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4327
                     && PhysicsScrolling())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4328
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4329
                ForwardPointerEventToItemL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4330
            }
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4331
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4332
#endif // RD_JAVA_S60_RELEASE_9_2             
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4333
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4334
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4335
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4336
        // EButton1Up
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4337
        case TPointerEvent::EButton1Up:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4338
        {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4339
            // If physics scrolling is ongoing then start flicking
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4340
            // and forward event to the item.
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4341
            if (iPanningOngoing && !iPreventPhysicsScrolling)
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4342
            {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4343
                TPoint distance = iStartPosition - aPointerEvent.iPosition;
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4344
                iFlickOngoing = iPhysics->StartFlick(distance, iStartTime);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4345
            }
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4346
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4347
            // If physics scrolling is not ongoing then only
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4348
            // forward event to the item.
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4349
            if (!iUpEventSent)
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4350
            {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4351
                ForwardPointerEventToItemL(aPointerEvent);
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4352
                iUpEventSent = ETrue;
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4353
            }
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4354
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4355
            iPanningOngoing = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4356
            iCanDragFocus = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4357
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4358
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4359
        default:
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4360
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4361
            ForwardPointerEventToItemL(aPointerEvent);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4362
            break;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4363
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4364
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4365
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4366
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4367
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4368
        IgnoreEventsUntilNextPointerUp();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4369
        return;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4370
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4371
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4372
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4373
void CMIDForm::ForwardPointerEventToItemL(const TPointerEvent& aPointerEvent)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4374
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4375
    if (iPointedControl)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4376
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4377
        // Drag events are not forwarded to CustomItem
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4378
        if (!iFlickStoppedOnDownEvent &&
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4379
                !(IsCustomItem(*iPointedControl) && aPointerEvent.iType == TPointerEvent::EDrag))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4380
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4381
            if (iFocused != KErrNotFound)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4382
            {
24
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4383
                if (IsPopupChoiceGroup(*iPointedControl))
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4384
                {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4385
                    iPointedControl->HandlePointerEventL(aPointerEvent);
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4386
                }
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4387
                else
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4388
                {
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4389
                    ControlItem(iFocused).HandlePointerEventL(aPointerEvent);
6c158198356e Revision: v2.2.9
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 23
diff changeset
  4390
                }
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4391
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4392
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4393
            if (LayoutPending())
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4394
            {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4395
                LayoutFormL();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4396
                DrawDeferred();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4397
            }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4398
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4399
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4400
        if (aPointerEvent.iType == TPointerEvent::EButton1Up)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4401
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4402
            iFocusChangingWithPen = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4403
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4404
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4405
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4406
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4407
void CMIDForm::HandlePhysicsScroll(TInt aScroll, TBool aDrawNow, TUint /*aFlags*/)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4408
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4409
    iScroll = iScroll + aScroll;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4410
    if (aScroll)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4411
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4412
        iHasScrolled = ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4413
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4414
    iScrollDelta = aScroll;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4415
    SetRowPositionsWithRespectToScrolledLocation();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4416
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4417
    if (aDrawNow)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4418
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4419
        RawScrollFinalize(ETrue, ETrue);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4420
        DrawNow();
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4421
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4422
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4423
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4424
        RawScrollFinalize(ETrue, EFalse);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4425
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4426
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4427
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4428
    //Tactile feedback on dragging/flicking.
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4429
    DoScrollingFeedback();
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4430
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4431
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4432
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4433
void CMIDForm::PhysicsScrollingEnd()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4434
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4435
    iFlickOngoing = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4436
    iPanningOngoing = EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4437
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4438
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4439
TBool CMIDForm::PhysicsEnabled()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4440
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4441
    if (iPhysics)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4442
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4443
        return ETrue;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4444
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4445
    else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4446
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4447
        return EFalse;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4448
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4449
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4450
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4451
TBool CMIDForm::PhysicsScrolling()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4452
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4453
    return iFlickOngoing | iPanningOngoing;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4454
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4455
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4456
TInt CMIDForm::ScrollDelta()
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4457
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4458
    return iScrollDelta;
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4459
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4460
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4461
void CMIDForm::DoFeedbackOnFocusChange(CMIDControlItem& aControlItem)
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4462
{
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4463
    //Tapping on StringItem BUTTON should not do feedback, here.
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4464
    //Native class CAknButton does it by itself
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4465
    if (!IsStringItemButton(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4466
    {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4467
        //Other items should do some feedback
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4468
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4469
        if (IsStringItemHyperlink(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4470
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4471
            //if StringItem is HYPERLIK it should give sensitive button feedback
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4472
            iFeedback->InstantFeedback(ETouchFeedbackSensitiveButton);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4473
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4474
        else if (IsImageItem(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4475
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4476
            //if pointed control is ImageItem, its focusable, it has to be either
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4477
            //HYPERLIK ot BUTTON, so it should give sensitive button feedback
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4478
            iFeedback->InstantFeedback(ETouchFeedbackSensitiveButton);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4479
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4480
        else if (IsChoiceGroup(aControlItem))
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4481
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4482
            //tapping on unfocused ChoiceGroup makes also activation, so it should
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4483
            //give basic list feedback
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4484
            iFeedback->InstantFeedback(ETouchFeedbackList);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4485
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4486
        else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4487
        {
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4488
            //changing focus to other items should give sensitive list feedback
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4489
            iFeedback->InstantFeedback(ETouchFeedbackSensitiveList);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4490
        }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4491
#else
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4492
        iFeedback->InstantFeedback(ETouchFeedbackBasic);
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4493
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK                
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4494
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4495
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4496
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4497
#ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4498
void CMIDForm::UpdateTactileFeedbackDensity()
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4499
{
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4500
    TAknLayoutRect layoutRect;
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4501
    layoutRect.LayoutRect(TRect(), AknLayoutScalable_Avkon::
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4502
                          list_single_heading_pane(0).LayoutLine());
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4503
    iTactileFeedbackDensity = layoutRect.Rect().Height();
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4504
}
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4505
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4506
void CMIDForm::DoScrollingFeedback()
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4507
{
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4508
    TRect formRect(Rect());
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4509
    TInt topEdgePos = iScroll;
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4510
    TInt bottomEdgePos = iScroll + HeightOfAllItems();
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4511
    // Calculate distance between current Form content position
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4512
    // and previous position, where last feedback happened.
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4513
    TInt lastFeedbackDistanceY = Abs(iLastTactileFeedbackPos - iScroll);
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4514
    TTouchLogicalFeedback feedbackType(ETouchFeedbackNone);
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4515
    if (lastFeedbackDistanceY >= iTactileFeedbackDensity)
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4516
    {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4517
        if ((topEdgePos < formRect.iTl.iY)
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4518
                && (bottomEdgePos > formRect.iBr.iY))
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4519
        {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4520
            // If top (or bottom) edge of the content is outside
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4521
            // of visible area of Form, do feedback every time.
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4522
            feedbackType = ETouchFeedbackSensitiveList;
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4523
        }
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4524
        else if (iLastPointerEventType != TPointerEvent::EButton1Up)
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4525
        {
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4526
            // Begining or end of the content reached (i.e. top or bottom
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4527
            // egde of the contont is now visible): feedback is given
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4528
            // only if user do panning. No feedback, if touch release
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4529
            // happened.
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4530
            feedbackType = ETouchFeedbackSensitiveList;
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4531
        }
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4532
        // Store the position of the content.
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4533
        iLastTactileFeedbackPos = iScroll;
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4534
    }
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4535
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4536
    if (iFeedback && feedbackType != ETouchFeedbackNone)
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4537
    {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4538
        if (iLastPointerEventType != TPointerEvent::EButton1Up)
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4539
        {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4540
            iFeedback->EnableFeedbackForControl(this, ETrue, ETrue);
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4541
        }
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4542
        else
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4543
        {
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4544
            // Disable audion feedback on flicking (i.e. user don't pan by
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4545
            // touch input).
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4546
            iFeedback->EnableFeedbackForControl(this, ETrue, EFalse);
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4547
        }
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4548
        // Do the feedback if needed.
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4549
        iFeedback->InstantFeedback(this, feedbackType);
14
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4550
    }
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4551
}
04becd199f91 Revision: v2.1.22
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
diff changeset
  4552
#endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
17
0fd27995241b Revision: v2.1.24
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 14
diff changeset
  4553