textrendering/textformatting/tbox/LAYEMU.CPP
author Pat Downey <patd@symbian.org>
Fri, 04 Jun 2010 10:37:54 +0100
changeset 32 8b9155204a54
child 44 601ab138ba0b
permissions -rw-r--r--
Revert last code drop.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
32
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description: 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
* CTextLayout implementation using the TAGMA text formatting system.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
#include <txtlaydc.h>
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include "FRMTLAY.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include "FRMCONST.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include "FORMUTIL.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include "FRMCONST_INTERNAL.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#include "FRMCONST_PARTNER.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
#include "TAGMA_INTERNAL.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
#include "FRMTLAY_INTERNAL.H"
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
#endif
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
const TInt KMaxExtraLines = 10; // maximum number of lines to format after the current and following lines
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
								// before using background formatting
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
// during page down/up, the number of lines that should remain visible after
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
// the scroll, counting from the first line that is not completely visible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
// i.e. setting this to 0 means always scroll KMaxProportionOfScreenToScroll.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
// setting it to 1 means make sure that no lines are ever both partially off the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
// top/bottom before the scroll and partially visible off the bottom/top after
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
// the scroll.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
// setting it to any number higher means keep that number -1 lines completely
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
// visible before and after the scroll.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
const TInt KNumberOfLinesToKeepVisibleDuringScroll = 2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
/** maximum scroll proportions in thousandths. This overrides
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
 the KNumberOfLinesToKeepVisibleDuringScroll constant.*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
const TInt KMaxProportionOfScreenToScroll = 1000;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
/** minimum scroll proportions in thousandths. This overrides
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
 the KNumberOfLinesToKeepVisibleDuringScroll constant.*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
const TInt KMinProportionOfScreenToScroll = 600;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
Constructs an iterator over the text referenced by aSource.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
@param aSource The source of the text to be iterated over.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
CTextLayout::TUtf32SourceCache::TUtf32SourceCache(const MTmSource& aSource)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
	: iSource(&aSource), iCurrentViewIndex(-1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
Constructs an iterator over the text formatted by aLayout.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
@param aLayout The formatter of the text to be iterated over.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
CTextLayout::TUtf32SourceCache::TUtf32SourceCache(const CTextLayout& aLayout)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
	: iSource(aLayout.iSource), iCurrentViewIndex(-1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
Gets the specified character without uniting surrogate pairs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
@param aIndex The document position to retrieve.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
@pre 0 <= aIndex && aIndex < {document length}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
TText CTextLayout::TUtf32SourceCache::GetUtf16(TInt aIndex)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
	TTmCharFormat dummy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
	if (aIndex < iCurrentViewIndex)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
		iCurrentViewIndex = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
		iSource->GetText(iCurrentViewIndex, iCurrentView, dummy);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
	TInt currentViewEnd = iCurrentViewIndex + iCurrentView.Length();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
	while (currentViewEnd <= aIndex)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
		TInt difference = aIndex - iCurrentViewIndex;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
		TInt newIndex = aIndex - (difference >> 1);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
		iCurrentViewIndex = newIndex < currentViewEnd?
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
			currentViewEnd : newIndex;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
		iSource->GetText(iCurrentViewIndex, iCurrentView, dummy);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
		currentViewEnd = iCurrentViewIndex + iCurrentView.Length();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
	return iCurrentView[aIndex - iCurrentViewIndex];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
Gets the specified character, uniting surrogate pairs if appropriate.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
@param aIndex
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
	The document position to retrive.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
@return
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
	The character at position aIndex. If aIndex is at the first code of a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
	surrogate pair, the full character is returned. If it is the second of a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
	valid surrogate pair or an unpaired surrogate, the surrogate is returned.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
TChar CTextLayout::TUtf32SourceCache::GetUtf32(TInt aIndex)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
	TText code = GetUtf16(aIndex);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
	if (TChar::IsHighSurrogate(code) && iSource->DocumentLength() < aIndex + 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
		TText code2 = GetUtf16(aIndex + 1);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
		if (TChar::IsLowSurrogate(code2))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
			return TChar::JoinSurrogate(code, code2);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
	return code;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
/** Allocates and constructs a CTextLayout object. By default, the formatting
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
is set to the entire document (EFFormatAllText).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
@param aDoc Pointer to the MLayDoc implementation that is the source of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
text and formatting information. Must not be NULL or a panic occurs.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
@param aWrapWidth The wrapping width in pixels.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
@return Pointer to the new CTextLayout object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
EXPORT_C CTextLayout *CTextLayout::NewL(MLayDoc *aLayDoc,TInt aWrapWidth)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
	CTextLayout* t = new(ELeave) CTextLayout;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
	CleanupStack::PushL(t);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
	t->ConstructL(aLayDoc,aWrapWidth);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
	CleanupStack::Pop();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
	return t;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
EXPORT_C CTextLayout::CTextLayout():
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
	iText(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
	iExcessHeightRequired(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
	iWnd(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
	iBeginRedrawCount(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
	iRedrawRect(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
	iTextViewCursorPos(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
	iIsWndInExternalRedraw(EFalse),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
	iUnformattedStart(KMaxTInt),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
	iHighlightExtensions(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
	iSource(NULL)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
/** Constructs an object with a text source of aLayDoc and a wrap width of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
aWrapWidth, with wrapping turned on.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
EXPORT_C void CTextLayout::ConstructL(MLayDoc *aLayDoc,TInt aWrapWidth)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
	iHighlightExtensions = new(ELeave) TTmHighlightExtensions;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
	CleanupStack::PushL(iHighlightExtensions);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
	iHighlightExtensions->SetAll(0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   157
	iText = new(ELeave) CTmTextLayout;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
	CleanupStack::PushL(iHighlightExtensions);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
	iSource = new(ELeave) TLayDocTextSource;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
	iSource->iLayDoc = aLayDoc;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
	SetWrapWidth(aWrapWidth);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
	SetAmountToFormat(EFFormatAllText);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
	CleanupStack::Pop(2);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
EXPORT_C CTextLayout::~CTextLayout()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
	delete iHighlightExtensions;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
	iHighlightExtensions = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
	delete iText;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
	iText = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
	delete iSource;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
	iSource = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
void CTextLayout::SetWindow(RWindow* aWnd)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
	iWnd = aWnd;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
void CTextLayout::SetReadyToRedraw()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
	iReadyToRedraw = ETrue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
void CTextLayout::BeginRedraw(const TRect& aRect)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
	if(!iReadyToRedraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
	if (0 == iBeginRedrawCount++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
		iRedrawRect = aRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
		if (NULL != iWnd)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
			if (iWnd->GetDrawRect() == TRect::EUninitialized)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
				iWnd->Invalidate(aRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
				iWnd->BeginRedraw(aRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
				else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
					iIsWndInExternalRedraw = ETrue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   209
void CTextLayout::EndRedraw()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
	if(!iReadyToRedraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
	__ASSERT_ALWAYS(iBeginRedrawCount > 0, Panic(EInvalidRedraw));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
	if (0 == --iBeginRedrawCount)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
		if (NULL != iWnd)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
			if (!iIsWndInExternalRedraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
				iWnd->EndRedraw();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
				iRedrawRect = TRect();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
				else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
					iIsWndInExternalRedraw = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
void CTextLayout::SetExternalDraw(const TRect& aRect)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
	__ASSERT_ALWAYS(0 == iBeginRedrawCount, Panic(EInvalidRedraw));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
	iBeginRedrawCount++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
	iRedrawRect = aRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
void CTextLayout::ResetExternalDraw()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
	__ASSERT_ALWAYS(1 == iBeginRedrawCount, Panic(EInvalidRedraw));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
	iBeginRedrawCount--;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
	iRedrawRect = TRect();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
TBool CTextLayout::BeginRedrawCalled() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
	return iBeginRedrawCount > 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
/** Discards all formatting information. This function is used by the CTextView
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
and the printing classes, but should be called by higher-level classes that
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
need to clean up after any CTextLayout function has caused an out-of-memory
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
exception. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
EXPORT_C void CTextLayout::DiscardFormat()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
	iText->Clear();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
	iBandTop = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
TInt CTextLayout::SetBandTop()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
	TInt originalBandTop = iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
	if (iScrollFlags & EFScrollOnlyToTopsOfLines)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
		TTmLineInfo line;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   268
		if (iText->YPosToLine(iBandTop, line))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
			iBandTop = line.iOuterRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
	return originalBandTop - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
/** Sets the layout object's source text to aDoc.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
@param aDoc Pointer to the MLayDoc implementation that is the source of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
text and formatting information. Must not be NULL or a panic occurs. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
EXPORT_C void CTextLayout::SetLayDoc(MLayDoc *aLayDoc)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
	iSource->iLayDoc = aLayDoc;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
/** Sets the wrap width. If the current format mode is screen mode
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
(CLayoutData::EFScreenMode) aWrapWidth is in pixels, otherwise it is in twips.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   288
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   289
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   290
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
A valid wrap width (>0) must be supplied or the expected amount of formatting will 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
not take place. This could lead to panics when trying to retrieve formatting 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
information that does not exist.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
@param aWrapWidth The wrap width in pixels or twips. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
EXPORT_C void CTextLayout::SetWrapWidth(TInt aWrapWidth)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
	if (iSource->iFormatMode == CLayoutData::EFScreenMode)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
		iSource->iWidth = aWrapWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
		iSource->iWidth = iSource->iFormatDevice->HorizontalTwipsToPixels(aWrapWidth);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
/** Sets the height of the band in pixels or twips. This is the height of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
visible text, or the view window, and it is also the page height for the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
purposes of scrolling up and down by page. If the current mode is screen mode 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
(CLayoutData::EFScreenMode) or what-you-see-is-what-you-get mode 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   309
(CLayoutData::EFWysiwygMode), aHeight is in pixels, otherwise it is in twips.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   310
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   311
The text needs to be reformatted after a call to this function. 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   312
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   313
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   314
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   315
A valid band height (>0) must be supplied or the expected amount of formatting will 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   316
not take place. This could lead to panics when trying to retrieve formatting 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   317
information that does not exist.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   318
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   319
@param aHeight The band height in pixels or twips. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   320
EXPORT_C void CTextLayout::SetBandHeight(TInt aHeight)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   321
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   322
	iVisibleHeight = aHeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   323
	if (iBandHeight != CLayoutData::EFHeightForFormattingAllText || aHeight < 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   324
		iBandHeight = aHeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   325
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   326
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   327
/** Gets the height of the band in pixels or twips.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   328
@return The height of the band in pixels or twips. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   329
EXPORT_C TInt CTextLayout::BandHeight() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   330
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   331
	return VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   332
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   333
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   334
/** Sets the device map used for drawing and formatting. This device map is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   335
also used for formatting and drawing paragraph labels unless a separate label
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   336
device map has been set (see SetLabelsDeviceMap()).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   337
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   338
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   339
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   340
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   341
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   342
Although the name of the function suggests that only the image device is set,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   343
the formatting device is also set.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   344
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   345
@param aGd The device map used for drawing and formatting. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   346
EXPORT_C void CTextLayout::SetImageDeviceMap(MGraphicsDeviceMap *aDeviceMap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   347
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   348
	iSource->iImageDevice = aDeviceMap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   349
	iSource->iFormatDevice = aDeviceMap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   350
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   351
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   352
/** Sets the device map used for formatting and drawing paragraph labels. If
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   353
not set, the device map used for labels will be the same as that used for the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   354
text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   355
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   356
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   357
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   358
@param aDeviceMap The device map used for formatting and drawing paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   359
labels. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   360
EXPORT_C void CTextLayout::SetLabelsDeviceMap(MGraphicsDeviceMap *aDeviceMap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   361
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   362
	iSource->iLabelsDevice = aDeviceMap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   363
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   364
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   365
/** Sets whether to format all the text (if aAmountOfFormat is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   366
EFFormatAllText), or just the visible band (if aAmountOfFormat is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   367
EFFormatBand). If band formatting is selected, enough text is formatted to fill
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   368
the visible height.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   369
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   370
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   371
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   372
@param aAmountOfFormat CTextLayout::EFFormatBand (the default) to format the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   373
visible text only. CTextLayout::EFFormatAllText to format all the text in the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   374
document. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   375
EXPORT_C void CTextLayout::SetAmountToFormat(TAmountFormatted aAmountOfFormat)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   376
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   377
	if (aAmountOfFormat == EFFormatBand)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   378
		iBandHeight = iVisibleHeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   379
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   380
		iBandHeight = CLayoutData::EFHeightForFormattingAllText;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   381
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   382
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   383
/** Tests whether band formatting is on, as set by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   384
CTextLayout::SetAmountToFormat().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   385
@return ETrue if band formatting is on, EFalse if not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   386
EXPORT_C TBool CTextLayout::IsFormattingBand() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   387
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   388
	return iBandHeight != CLayoutData::EFHeightForFormattingAllText;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   389
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   390
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   391
/** Sets the format mode and wrap width and (for certain format modes only)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   392
sets the formatting device.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   393
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   394
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   395
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   396
Notes:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   397
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   398
If aFormatMode is CLayoutData::EFWysiwygMode or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   399
CLayoutData::EFPrintPreviewMode, the format device is set to aFormatDevice,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   400
which must not be NULL.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   401
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   402
If aFormatMode is CLayoutData::EFScreenMode or CLayoutData::EFPrintMode,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   403
aFormatDevice is ignored and should be NULL; the format device is set to the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   404
image device.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   405
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   406
The wrap width is set in either twips or pixels using the same rule as for
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   407
SetWrapWidth().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   408
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   409
@param aFormatMode The format mode.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   410
@param aWrapWidth The wrap width in pixels or twips.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   411
@param aFormatDevice The formatting device or NULL, depending on the format
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   412
mode. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   413
EXPORT_C void CTextLayout::SetFormatMode(CLayoutData::TFormatMode aFormatMode,TInt aWrapWidth,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   414
										 MGraphicsDeviceMap* aFormatDevice)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   415
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   416
	if (aFormatMode == CLayoutData::EFWysiwygMode || aFormatMode == CLayoutData::EFPrintPreviewMode)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   417
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   418
		__ASSERT_ALWAYS(aFormatDevice != NULL,Panic(EFormatDeviceNotSet));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   419
		iSource->iFormatDevice = aFormatDevice;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   420
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   421
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   422
		iSource->iFormatDevice = iSource->iImageDevice;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   423
	iSource->iFormatMode = aFormatMode;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   424
	SetWrapWidth(aWrapWidth);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   425
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   426
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   427
/** Turns wrapping on (if aNoWrapping is EFParagraphsWrappedByDefault) or off
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   428
(if aNoWrapping is EFAllParagraphsNotWrapped). Overrides the paragraph format
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   429
when wrapping is turned off -paragraphs are not broken into lines even if the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   430
iWrap member of CParaFormat is ETrue. If wrapping is turned on,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   431
CParaFormat::iWrap is honoured.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   432
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   433
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   434
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   435
@param aNoWrapping EFAllParagraphsNotWrapped (the default) to turn wrapping
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   436
off, EFParagraphsWrappedByDefault to turn wrapping on. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   437
EXPORT_C void CTextLayout::ForceNoWrapping(TBool aNoWrapping)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   438
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   439
	if (aNoWrapping)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   440
		iSource->iFlags &= ~TLayDocTextSource::EWrap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   441
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   442
		iSource->iFlags |= TLayDocTextSource::EWrap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   443
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   444
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   445
/** Tests whether wrapping is on or off.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   446
@return ETrue if wrapping is on, EFalse if off. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   447
EXPORT_C TBool CTextLayout::IsWrapping() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   448
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   449
	return (iSource->iFlags & TLayDocTextSource::EWrap) != 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   450
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   451
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   452
/** Sets the truncation mode. If truncation is on, lines that exceed the wrap
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   453
width, either because they have no legal line break, or because wrapping is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   454
off, are truncated, and an ellipsis is inserted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   455
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   456
@param aOn If ETrue, lines which extend beyond the wrap width are truncated
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   457
with an ellipsis character. If EFalse, no ellipsis is used. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   458
EXPORT_C void CTextLayout::SetTruncating(TBool aOn)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   459
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   460
	if (aOn)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   461
		iSource->iFlags |= TLayDocTextSource::ETruncateWithEllipsis;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   462
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   463
		iSource->iFlags &= ~TLayDocTextSource::ETruncateWithEllipsis;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   464
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   465
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   466
/** Tests whether truncation is on (as set by SetTruncating()).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   467
@return ETrue if truncation is on, EFalse if not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   468
EXPORT_C TBool CTextLayout::Truncating() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   469
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   470
	return (iSource->iFlags & TLayDocTextSource::ETruncateWithEllipsis) != 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   471
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   472
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   473
/** Sets the ellipsis character to be used if truncation is on. Specify the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   474
value 0xFFFF (the illegal Unicode character) if no ellipsis character should
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   475
be used. By default, the ellipsis character is 0x2026, the ordinary horizontal
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   476
ellipsis.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   477
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   478
@param aEllipsis The Unicode value of the truncating ellipsis character. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   479
EXPORT_C void CTextLayout::SetTruncatingEllipsis(TChar aEllipsis)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   480
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   481
	iSource->iEllipsis = aEllipsis;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   482
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   483
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   484
/** Returns the ellipsis character used when truncation is on. The value 0xFFFF
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   485
(the illegal Unicode character) means that no ellipsis character is appended to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   486
truncated text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   487
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   488
@return The Unicode value of the truncating ellipsis character. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   489
EXPORT_C TChar CTextLayout::TruncatingEllipsis() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   490
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   491
	return iSource->iEllipsis;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   492
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   493
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   494
/** Sets the width in pixels of the margin in which labels are drawn.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   495
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   496
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   497
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   498
@param aWidth The width in pixels of the labels margin. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   499
EXPORT_C void CTextLayout::SetLabelsMarginWidth(TInt aWidth)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   500
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   501
	iSource->iLabelsWidth = aWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   502
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   503
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   504
/** Specifies which non-printing characters (e.g. space, paragraph break, etc.)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   505
are to be drawn using symbols.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   506
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   507
The text needs to be reformatted after a call to this function.(because
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   508
non-printing characters may differ in width from their visible
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   509
representations).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   510
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   511
@param aVisibility Indicates which non-printing characters are drawn using
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   512
symbols. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   513
EXPORT_C void CTextLayout::SetNonPrintingCharsVisibility(TNonPrintingCharVisibility aVisibility)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   514
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   515
	iSource->iNonPrintingCharVisibility = aVisibility;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   516
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   517
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   518
/** Returns which non-printing characters are drawn using symbols.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   519
@return Indicates which non-printing characters are drawn using symbols. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   520
EXPORT_C TNonPrintingCharVisibility CTextLayout::NonPrintingCharsVisibility() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   521
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   522
	return iSource->iNonPrintingCharVisibility;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   523
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   524
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   525
/** Tests whether background formatting is currently taking place. Background
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   526
formatting is managed by CTextView, using an active object, when the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   527
CTextLayout object is owned by a CTextView object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   528
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   529
Not generally useful.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   530
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   531
@return ETrue if background formatting is currently taking place. EFalse if not.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   532
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   533
EXPORT_C TBool CTextLayout::IsBackgroundFormatting() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   534
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   535
	return iUnformattedStart < KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   536
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   537
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   538
/** CTextView calls this function when background formatting has ended. It
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   539
allows the CTextLayout object to discard information used only during
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   540
background formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   541
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   542
Not generally useful. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   543
EXPORT_C void CTextLayout::NotifyTerminateBackgroundFormatting()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   544
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   545
	iUnformattedStart = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   546
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   547
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   548
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   549
/** Specifies whether partially displayed lines (at the top and bottom of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   550
the view) are to be prevented from being drawn, and whether the top of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   551
the display is to be aligned to the nearest line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   552
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   553
This function takes effect only when the text is next formatted or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   554
scrolled.Note:This function was designed for non-editable text in the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   555
Agenda application, and there is an important restriction:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   556
CTextView functions that reformat the text after editing must not be used
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   557
while partial lines are excluded; these functions are 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   558
CTextView::HandleCharEditL(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   559
CTextView::HandleInsertDeleteL() and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   560
CTextView::HandleRangeFormatChangeL().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   561
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   562
@param aExcludePartialLines ETrue (the default) to exclude partially
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   563
displayed lines from the view. EFalse to include them.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   564
@deprecated 7.0 */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   565
//It did not work, and it was not what the customer wanted. A more comprehensive
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   566
//solution is being considered.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   567
EXPORT_C void CTextLayout::SetExcludePartialLines(TBool) {}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   568
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   569
/** Tests whether partial lines at the top and bottom of the view are
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   570
currently excluded.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   571
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   572
@return ETrue if partial lines are excluded, EFalse if they are displayed.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   573
@deprecated 7.0 */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   574
EXPORT_C TBool CTextLayout::ExcludingPartialLines() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   575
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   576
	return EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   577
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   578
 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   579
/** Sets the percentage by which font heights are increased in order to provide
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   580
automatic extra spacing (leading) between lines. This amount is set to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   581
CLayoutData::EFFontHeightIncreaseFactor, which is 7, when a CTextLayout object
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   582
is created.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   583
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   584
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   585
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   586
@param aPercentage Factor by which to increase font heights. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   587
EXPORT_C void CTextLayout::SetFontHeightIncreaseFactor(TInt aPercentage)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   588
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   589
	iSource->iFontHeightIncreaseFactor = aPercentage;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   590
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   591
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   592
/** Returns the font height increase factor as a percentage (i.e. a return
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   593
value of 7 means that font heights are increased by 7% to provide automatic
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   594
extra spacing between lines).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   595
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   596
@return Factor by which font heights are increased. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   597
EXPORT_C TInt CTextLayout::FontHeightIncreaseFactor() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   598
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   599
	return iSource->iFontHeightIncreaseFactor;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   600
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   601
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   602
/** Sets the minimum line descent in pixels. This amount is set to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   603
CLayoutData::EFMinimumLineDescent, which is 3, when a CTextLayout object is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   604
created.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   605
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   606
The text needs to be reformatted after a call to this function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   607
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   608
@param aPixels The minimum line descent in pixels. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   609
EXPORT_C void CTextLayout::SetMinimumLineDescent(TInt aPixels)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   610
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   611
	iSource->iMinimumLineDescent = aPixels;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   612
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   613
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   614
/** Returns the minimum line descent in pixels.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   615
@return The minimum line descent in pixels. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   616
EXPORT_C TInt CTextLayout::MinimumLineDescent() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   617
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   618
	return iSource->iMinimumLineDescent;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   619
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   620
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   621
/** Returns the document length in characters, including all the text, not just
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   622
the formatted portion, but not including the final paragraph delimiter (the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   623
"end-of-text character") if any. Thus the length of an empty document is zero.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   624
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   625
@return The number of characters in the document */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   626
EXPORT_C TInt CTextLayout::DocumentLength() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   627
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   628
	return iSource->DocumentLength();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   629
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   630
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   631
/** Sets aDocPos to the paragraph start and returns the amount by which aDocPos
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   632
has changed, as a non-negative number.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   633
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   634
@param aDocPos A document position. On return, contains the document position
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   635
of the first character in the paragraph.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   636
@return The number of characters skipped in moving to the new document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   637
position. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   638
EXPORT_C TInt CTextLayout::ToParagraphStart(TInt& aDocPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   639
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   640
	TInt old_pos = aDocPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   641
	aDocPos = iSource->ParagraphStart(aDocPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   642
	return old_pos - aDocPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   643
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   644
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   645
/** Returns the height in pixels of any formatted text above the visible
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   646
region.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   647
@return The height in pixels of any formatted text above the visible region. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   648
EXPORT_C TInt CTextLayout::PixelsAboveBand() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   649
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   650
	return iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   651
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   652
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   653
/** Returns the y coordinate of the bottom of the last formatted line, relative
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   654
to the top of the visible region.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   655
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   656
@return The y coordinate of the bottom of the last formatted line. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   657
EXPORT_C TInt CTextLayout::YBottomLastFormattedLine() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   658
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   659
    return Max(0, iText->LayoutHeight() - iBandTop );
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   660
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   661
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   662
/** Returns the height in pixels of the formatted text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   663
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   664
@return The height in pixels of all the formatted text. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   665
EXPORT_C TInt CTextLayout::FormattedHeightInPixels() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   666
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   667
	return iText->LayoutHeight();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   668
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   669
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   670
/** Returns the number of fully or partially visible characters in the visible
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   671
band.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   672
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   673
@param aDocPos On return, contains the document position of the first fully or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   674
partially visible character in the band.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   675
@return The total number of characters in the band. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   676
EXPORT_C TInt CTextLayout::PosRangeInBand(TInt& aDocPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   677
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   678
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   679
	if (!iText->YPosToLine(iBandTop,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   680
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   681
		aDocPos = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   682
		return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   683
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   684
	aDocPos = info.iStart;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   685
	int end = iSource->DocumentLength();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   686
	//INC085809 - less 1 pixel. Rect edge is actually outside bounds
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   687
	if (iText->YPosToLine(iBandTop + VisibleHeightInPixels() - 1,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   688
		end = info.iEnd;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   689
	return end - aDocPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   690
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   691
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   692
/** Tests whether the document position aDocPos is fully or partially visible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   693
If it is, puts the y coordinate of the left-hand end of the baseline of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   694
line containing aDocPos into aXyPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   695
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   696
@param aDocPos The document position of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   697
@param aXyPos On return, contains the y coordinate of the left-hand end of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   698
baseline of the line containing aDocPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   699
@return ETrue if the position is visible. EFalse if the position is not visible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   700
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   701
EXPORT_C TBool CTextLayout::PosInBand(TInt aDocPos,TPoint& aXyPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   702
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   703
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   704
	TTmDocPos pos(aDocPos, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   705
	TBool result = PosInBand(pos,&info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   706
	aXyPos.iX = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   707
	aXyPos.iY = info.iBaseline;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   708
	return result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   709
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   710
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   711
/** Tests whether the document position aDocPos is fully or partially visible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   712
If it is, puts the y coordinate of the left-hand end of the baseline of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   713
line containing aDocPos into aXyPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   714
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   715
@param aDocPos The document position of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   716
@param aXyPos On return, contains the y coordinate of the left-hand end of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   717
baseline of the line containing aDocPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   718
@return ETrue if the position is visible. EFalse if the position is not visible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   719
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   720
EXPORT_C TBool CTextLayout::PosInBand(TTmDocPos aDocPos,TPoint& aXyPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   721
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   722
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   723
	TBool result = PosInBand(aDocPos,&info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   724
	aXyPos.iX = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   725
	aXyPos.iY = info.iBaseline;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   726
	return result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   727
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   728
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   729
/** Tests whether the document position aDocPos is fully or partially visible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   730
If it is, puts the baseline of the line containing aDocPos into aLineInfo.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   731
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   732
@param aDocPos The document position of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   733
@param aLineInfo On return, contains the baseline of the line containing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   734
aDocPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   735
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   736
@return ETrue if the document position aDocPos is fully or partially visible. If
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   737
so, and if aLineInfo is non-NULL, puts information about the line in aLineInfo.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   738
Otherwise, EFalse */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   739
EXPORT_C TBool CTextLayout::PosInBand(const TTmDocPos& aDocPos,TTmLineInfo* aLineInfo) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   740
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   741
	TTmLineInfo dummy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   742
	TTmLineInfo* info_ptr = aLineInfo ? aLineInfo : &dummy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   743
	TTagmaForwarder forwarder(*this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   744
	if (!forwarder.DocPosToLine(aDocPos,*info_ptr))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   745
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   746
	return info_ptr->iOuterRect.iBr.iY > 0 && info_ptr->iOuterRect.iTl.iY < VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   747
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   748
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   749
/** Tests whether the character aDocPos is formatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   750
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   751
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   752
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   753
If a section of text contains characters p to q, it contains document positions
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   754
p to q + 1; but this function returns ETrue for positions p to q only, so it
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   755
refers to characters, not positions. However, it will return ETrue for q if q is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   756
the end of the document.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   757
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   758
@param aDocPos The document position of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   759
@return ETrue if the character at the document position specified is formatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   760
EFalse if not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   761
EXPORT_C TBool CTextLayout::PosIsFormatted(TInt aDocPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   762
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   763
	if (aDocPos < iText->StartChar())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   764
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   765
	if (aDocPos >= iText->StartChar() + FormattedLength())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   766
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   767
	return TRUE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   768
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   769
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   770
/** Gets the document position of the first character in the specified line,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   771
counting the first line as line one (not zero) in the band. If the line is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   772
after the band, returns the last character position of the band. If there is no
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   773
formatted text, returns CTextLayout::EFNoCurrentFormat.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   774
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   775
@param aLineNo Line number in formatted text, counting the first line as line
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   776
one.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   777
@return The document position of the first character on the line. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   778
EXPORT_C TInt CTextLayout::FirstCharOnLine(TInt aLineNo) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   779
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   780
	__ASSERT_DEBUG(aLineNo > 0,Panic(EInvalidLineNumber));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   781
	if (iText->StartChar() == iText->EndChar())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   782
		return EFNoCurrentFormat;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   783
	aLineNo--;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   784
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   785
	if (!iText->LineNumberToLine(aLineNo,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   786
		return Min(iText->EndChar(),iSource->DocumentLength());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   787
	return info.iStart;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   788
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   789
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   790
/** Returns the number of formatted characters. This will be one more than
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   791
expected if the formatted text runs to the end of the document, because it will
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   792
include the end-of-text character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   793
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   794
@return The number of formatted characters in the document. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   795
EXPORT_C TInt CTextLayout::FormattedLength() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   796
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   797
	return iText->EndChar() - iText->StartChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   798
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   799
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   800
/** Returns the document position of the first formatted character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   801
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   802
@return The document position of the first formatted character. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   803
EXPORT_C TInt CTextLayout::FirstFormattedPos() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   804
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   805
	return iText->StartChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   806
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   807
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   808
/** Gets the number of formatted lines.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   809
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   810
@return The number of formatted lines in the document. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   811
EXPORT_C TInt CTextLayout::NumFormattedLines() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   812
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   813
	return iText->Lines();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   814
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   815
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   816
/** Returns the line number, counting from 0, of the first fully visible line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   817
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   818
@return The line number of the first fully visible line. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   819
EXPORT_C TInt CTextLayout::FirstLineInBand() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   820
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   821
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   822
	if (!iText->YPosToLine(iBandTop,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   823
		return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   824
	int line = info.iLineNumber;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   825
	if (info.iOuterRect.iTl.iY < iBandTop)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   826
		line++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   827
	return line;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   828
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   829
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   830
/** Gets the rectangle enclosing the formatted line that contains or is closest
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   831
to y coordinate aYPos. If aYPos is above the first formatted line, the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   832
rectangle returned is that of the first formatted line. If aYPos is below the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   833
last formatted line the rectangle returned is that of the last formatted line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   834
If there is no formatted text, returns CTextLayout::EFNoCurrentFormat.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   835
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   836
@param aYPos The y coordinate of the line of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   837
@param aLine On return, contains the rectangle which encloses the line at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   838
aYPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   839
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   840
@return The line width in pixels. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   841
EXPORT_C TInt CTextLayout::GetLineRect(TInt aYPos,TRect& aRect) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   842
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   843
	int y = iBandTop + aYPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   844
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   845
	// Snap to formatted area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   846
	if (y >= iText->LayoutHeight())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   847
		y = iText->LayoutHeight() - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   848
	if (y < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   849
		y = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   850
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   851
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   852
	TBool found = iText->YPosToLine(y,info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   853
	if (!found)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   854
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   855
		aRect.SetSize(TSize(0,0));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   856
		return EFNoCurrentFormat;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   857
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   858
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   859
	aRect = info.iOuterRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   860
	aRect.iTl.iX = info.iInnerRect.iTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   861
	aRect.iBr.iX = info.iInnerRect.iBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   862
	aRect.Move(0,-iBandTop);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   863
	return aRect.Width();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   864
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   865
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   866
/** Returns the height of the paragraph containing aDocPos. If the paragraph is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   867
not formatted, returns zero. If the paragraph is partially formatted, returns
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   868
the height of the formatted part.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   869
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   870
@param aDocPos A document position within the paragraph of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   871
@return The height in pixels of the paragraph. Zero if the paragraph is not
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   872
formatted. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   873
EXPORT_C TInt CTextLayout::ParagraphHeight(TInt aDocPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   874
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   875
	TRect r;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   876
	GetParagraphRect(TTmDocPos(aDocPos, ETrue), r);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   877
	return r.Height();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   878
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   879
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   880
/** Returns the rectangle enclosing the paragraph containing aDocPos. If the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   881
paragraph is not formatted, returns an empty rectangle. If the paragraph is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   882
partially formatted, returns the rectangle enclosing the formatted part.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   883
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   884
@param aDocPos A document position within the paragraph.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   885
@return The rectangle which encloses the paragraph containing aDocPos. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   886
EXPORT_C TRect CTextLayout::ParagraphRectL(TInt aDocPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   887
	{	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   888
	TRect r;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   889
	GetParagraphRect(TTmDocPos(aDocPos, ETrue), r);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   890
	return r;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   891
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   892
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   893
/** Returns the left and right extremes, in layout coordinates, of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   894
formatted text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   895
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   896
@param aLeftX On return, contains the x coordinate of the leftmost point of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   897
formatted text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   898
@param aRightX On return, contains the x coordinate of the rightmost point of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   899
the formatted text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   900
@param aOnlyVisibleLines If ETrue, only scans partially or fully visible lines.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   901
If EFalse, scans all the formatted text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   902
@param aIgnoreWrapCharacters If ETrue, does not include wrap characters in the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   903
measurement (paragraph delimiters, forced line breaks, etc.). If EFalse,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   904
includes them.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   905
@return EFalse if there is no formatted text, otherwise ETrue. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   906
EXPORT_C TBool CTextLayout::CalculateHorizontalExtremesL(TInt& aLeftX,TInt& aRightX,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   907
														 TBool aOnlyVisibleLines,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   908
														 TBool /*aIgnoreWrapCharacters*/) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   909
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   910
	return CalculateHorizontalExtremes(aLeftX,aRightX,aOnlyVisibleLines);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   911
	//+ implement aIgnoreWrapCharacters? not until clearly specified
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   912
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   913
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   914
TBool CTextLayout::CalculateHorizontalExtremes(TInt& aLeftX,TInt& aRightX,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   915
											   TBool aOnlyVisibleLines) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   916
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   917
	int top = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   918
	int bottom = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   919
	if (aOnlyVisibleLines)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   920
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   921
		top = iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   922
		bottom = iBandTop + VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   923
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   924
	iText->HorizontalExtremes(aLeftX, aRightX, top, bottom);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   925
	if (0 < aLeftX)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   926
		aLeftX = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   927
	if (aRightX < iSource->iWidth)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   928
		aRightX = iSource->iWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   929
	return iText->StartChar() < iText->EndChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   930
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   931
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   932
TInt CTextLayout::WrapWidth() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   933
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   934
	return iSource->iWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   935
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   936
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   937
TBool CTextLayout::GetCursor(const TTmDocPos& aDocPos,TTmCursorPlacement aPlacement,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   938
							 TRect& aLineRect,TPoint& aOrigin,TInt& aWidth,TInt& aAscent,TInt& aDescent) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   939
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   940
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   941
	TBool result = iText->GetCursor(aDocPos,aPlacement,info,aOrigin,aWidth,aAscent,aDescent);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   942
	if (result)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   943
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   944
		aOrigin.iY -= iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   945
		aLineRect = info.iOuterRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   946
		aLineRect.iTl.iX = info.iInnerRect.iTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   947
		aLineRect.iBr.iX = info.iInnerRect.iBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   948
		aLineRect.Move(0,-iBandTop);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   949
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   950
	return result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   951
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   952
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   953
/** Gets the height (ascent + descent) and ascent of the font of the character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   954
at aDocPos, as created using the graphics device map used for drawing (the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   955
"image device") and returns them in aHeight and aAscent, after increasing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   956
aHeight by the font height increase factor (see SetFontHeightIncreaseFactor()).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   957
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   958
@param aDocPos A document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   959
@param aHeight On return contains the height in pixels of the character at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   960
aDocPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   961
@param aAscent On return, contains the ascent in pixels of the character at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   962
aDocPos. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   963
EXPORT_C void CTextLayout::GetCharacterHeightAndAscentL(TInt aDocPos,TInt& aHeight,TInt& aAscent) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   964
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   965
	TPtrC text;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   966
	TTmCharFormat format;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   967
	iSource->GetText(aDocPos,text,format);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   968
	TFontSpec fs;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   969
	format.iFontSpec.GetTFontSpec(fs);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   970
	GetFontHeightAndAscentL(fs,aHeight,aAscent);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   971
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   972
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   973
/** Gets the height (ascent + descent) and ascent of the font specified by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   974
aFontSpec, as created using the graphics device map used for drawing (the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   975
"image device") and puts them into aHeight and aAscent, after increasing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   976
aHeight by the font height increase factor (see SetFontHeightIncreaseFactor()).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   977
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   978
@param aFontSpec Font specification.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   979
@param aHeight On return, contains the height in pixels of the font.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   980
@param aAscent On return, contains the ascent in pixels of the font. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   981
EXPORT_C void CTextLayout::GetFontHeightAndAscentL(const TFontSpec& aFontSpec,TInt& aHeight,TInt& aAscent) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   982
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   983
	CFont* font;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   984
	MGraphicsDeviceMap& device = iSource->InterpretDevice();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   985
	User::LeaveIfError(device.GetNearestFontInTwips(font,aFontSpec));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   986
	aHeight = font->HeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   987
	int increase = (iSource->iFontHeightIncreaseFactor * aHeight) / 100;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   988
	aHeight += increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   989
	aAscent = font->AscentInPixels() + increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   990
	device.ReleaseFont(font);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   991
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   992
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   993
/** Returns the index of the nearest character in the document to the window 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   994
coordinates specified. Sets aPos to the actual position of the intersection 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   995
of the line's baseline with the character's edge. If aPos is before the start
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   996
of the formatted area, returns the first formatted character; if it is after 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   997
the end of the formatted area, returns the position after the last formatted 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   998
character, or the end of the document, whichever is less.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   999
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1000
This function is deprecated in v7.0s. Use the more powerful FindXYPos() instead.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1001
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1002
@param aPos Contains coordinates to convert to a document position. On return,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1003
contains the exact coordinates of the intersection of the line's baseline with
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1004
the character edge at the document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1005
@param aFlags Three possible values: 0 is the default, and performs the task at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1006
full accuracy (the function returns the document position of the character edge
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1007
nearest to the coordinates). CLayoutData::EFWholeLinesOnly examines lines only
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1008
and returns the position at the right end of the line if aPos.iX > 0, otherwise
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1009
the position at the left end.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1010
@return The document position of the nearest character to the coordinates, or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1011
of the start or end of the line, depending on the value of aFlags. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1012
EXPORT_C TInt CTextLayout::XyPosToDocPosL(TPoint &aXyPos,TUint) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1013
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1014
	if (aXyPos.iY < -iBandTop)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1015
		return iText->StartChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1016
	else if (aXyPos.iY >= iText->LayoutHeight() - iBandTop)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1017
		return Min(iText->EndChar(),iSource->DocumentLength());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1018
	TTmPosInfo2 pos_info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1019
	TTmLineInfo lineInfo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1020
	FindXyPos(aXyPos,pos_info, &lineInfo);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1021
	aXyPos = pos_info.iEdge;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1022
	TInt r = pos_info.iDocPos.iPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1023
	if (!pos_info.iDocPos.iLeadingEdge && lineInfo.iStart != r)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1024
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1025
		r -= 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1026
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1027
		//	surrogate support
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1028
		if ( r > 0 )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1029
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1030
			TPtrC text;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1031
			TTmCharFormat format;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1032
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1033
			iSource->GetText( r - 1, text, format );
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1034
			if ( text.Length() > 1 )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1035
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1036
				TUint highSurrogate = text[0];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1037
				TUint lowSurrogate = text[1];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1038
				if ( TChar::IsHighSurrogate( highSurrogate ) &&
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1039
				        TChar::IsLowSurrogate( lowSurrogate ) )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1040
					--r;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1041
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1042
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1043
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1044
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1045
	return r;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1046
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1047
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1048
/** Finds the document position nearest to aXyPos. If aXyPos is in the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1049
formatted text returns ETrue, otherwise returns EFalse. If ETrue is returned,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1050
places information about the document position in aPosInfo and information
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1051
about the line containing the document position in aLineInfo if it is non-NULL.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1052
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1053
@param aXyPos Contains coordinates to convert to a document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1054
@param aPosInfo Buffer to store information about the document position if the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1055
specified coordinates are located in the formatted text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1056
@param aLineInfo Buffer to store information about the line if the specified
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1057
coordinates are located in the formatted text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1058
@return ETrue if aXyPos is a formatted position, otherwise EFalse. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1059
EXPORT_C TBool CTextLayout::FindXyPos(const TPoint& aXyPos,TTmPosInfo2& aPosInfo,TTmLineInfo* aLineInfo) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1060
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1061
	TTagmaForwarder forwarder(*this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1062
	TTmLineInfo line_info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1063
	TBool result = forwarder.FindXyPos(aXyPos,aPosInfo,line_info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1064
	if (aLineInfo && result)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1065
		*aLineInfo = line_info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1066
	return result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1067
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1068
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1069
/** Returns the x-y coordinates of the document position aDocPos in aPos. The
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1070
return value is ETrue if the position is formatted, or EFalse if it is not, in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1071
which case aPos is undefined.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1072
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1073
Deprecated - use the more powerful FindDocPos() instead
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1074
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1075
@param aDocPos The document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1076
@param aPos On return, contains the x-y coordinates of aDocPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1077
@param aFlags Two possible values: 0 is the default, and performs the task at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1078
full accuracy, and CLayoutData::EFWholeLinesOnly, which examines lines only and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1079
sets aXyPos.iY only, and cannot leave.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1080
@return ETrue if the document position is formatted, EFalse if not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1081
EXPORT_C TBool CTextLayout::DocPosToXyPosL(TInt aDocPos,TPoint& aXyPos,TUint /*aFlags*/) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1082
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1083
	TTmDocPos doc_pos(aDocPos, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1084
	TTmPosInfo2 pos_info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1085
	TBool result = FindDocPos(doc_pos,pos_info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1086
	aXyPos = pos_info.iEdge;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1087
	return result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1088
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1089
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1090
/** Finds the x-y position of the document position aDocPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1091
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1092
If ETrue is returned, places information about the document position in aPosInfo
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1093
and information about the line containing the document position in aLineInfo if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1094
it is non-NULL.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1095
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1096
@param aDocPos Contains the document position to check.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1097
@param aPosInfo On return, stores information about the document position if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1098
the position is formatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1099
@param aLineInfo Buffer to store the line information if the document position
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1100
is formatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1101
@return ETrue if aDocPos is in the formatted text, otherwise EFalse. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1102
EXPORT_C TBool CTextLayout::FindDocPos(const TTmDocPosSpec& aDocPos,TTmPosInfo2& aPosInfo,TTmLineInfo* aLineInfo) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1103
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1104
	TTagmaForwarder forwarder(*this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1105
	TTmLineInfo line_info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1106
	TBool result = forwarder.FindDocPos(aDocPos,aPosInfo,line_info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1107
	if (aLineInfo && result)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1108
		*aLineInfo = line_info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1109
	return result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1110
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1111
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1112
/** Finds the next cursor position to aDocPos in the visually ordered line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1113
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1114
@param aDocPos Contains the document position to check.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1115
@param aPosInfo On return, stores information about the document position of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1116
the next cursor position, if ETrue is returned.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1117
@param aToLeft ETrue if the position to the left is to be found, or EFalse if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1118
the position to the right is to be found.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1119
@return EFalse if there is no formatting, or the position is at the end of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1120
line already. ETrue otherwise. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1121
EXPORT_C TBool CTextLayout::GetNextVisualCursorPos(
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1122
	const TTmDocPosSpec& aDocPos, TTmPosInfo2& aPosInfo, TBool aToLeft) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1123
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1124
	TTagmaForwarder forwarder(*this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1125
	return forwarder.GetNextVisualCursorPos(aDocPos, aPosInfo, aToLeft);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1126
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1127
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1128
/** Gets a rectangle enclosing two formatted document positions on the same
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1129
line. If the second position is less than the first, or on a different line, it
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1130
is taken to indicate the end of the line. This function panics if either
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1131
position is unformatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1132
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1133
Note:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1134
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1135
CTextLayout must have been set with a valid wrap width and band height before
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1136
calling this function, otherwise no formatting will take place and the function 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1137
will panic.  Wrap width and band height values must be > 0 to be valid.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1138
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1139
@param aDocPos1 The first document position on the line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1140
@param aDocPos2 The second document position on the line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1141
@return The minimal rectangle, which bounds both positions.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1142
@see SetBandHeight
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1143
@see SetWrapWidth */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1144
EXPORT_C TRect CTextLayout::GetLineRectL(TInt aDocPos1,TInt aDocPos2) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1145
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1146
	TRect rect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1147
	TPoint point;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1148
	TInt xCoords[4];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1149
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1150
	if (iText->LayoutHeight() == 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1151
		return TRect(0,0,0,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1152
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1153
	__ASSERT_ALWAYS(PosIsFormatted(aDocPos1),Panic(ECharacterNotFormatted));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1154
	__ASSERT_DEBUG(PosIsFormatted(aDocPos2),Panic(ECharacterNotFormatted));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1155
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1156
	TTmDocPosSpec docSpec(aDocPos1, TTmDocPosSpec::ELeading);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1157
	TTmPosInfo2 pos_info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1158
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1159
	// Finding the leading edge of aDocPos1
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1160
	FindDocPos(docSpec,pos_info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1161
	point = pos_info.iEdge;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1162
	xCoords[0] = point.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1163
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1164
	// Getthe Line rectangle
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1165
	GetLineRect(point.iY,rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1166
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1167
	__ASSERT_DEBUG(rect.iTl.iY <= point.iY && rect.iBr.iY >= point.iY,Panic(EPixelNotInFormattedLine));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1168
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1169
	//	Finding the leading edge of aDocPos2
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1170
	docSpec.iPos = aDocPos2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1171
	TBool isformatted = FindDocPos(docSpec, pos_info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1172
	point = pos_info.iEdge;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1173
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1174
	// Checks if the aDocPos2 is contained in the same line of the aDocPos1
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1175
	// Can't use TRect::Contains() here, because TRect::Contains() considers a point located on the right  
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1176
	// hand side or bottom as outside the rectangle, which will has problem when work with RTL text that 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1177
	// is at the right hand end of a line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1178
	TBool isContained = (point.iX>=rect.iTl.iX && point.iX<=rect.iBr.iX 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1179
				&& point.iY>=rect.iTl.iY && point.iY<=rect.iBr.iY);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1180
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1181
	RTmParFormat parFormat;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1182
	iSource->GetParagraphFormatL(aDocPos1, parFormat);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1183
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1184
	//	The special cases (as indicated in the description):
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1185
	//	When the aDocPos2 is less than the aDocPos1, or not formatted, or on a different line from which the  
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1186
	//	aDocPos1 is in, then the function will return the rectangle starting from docPos1's leading edge and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1187
	//	ending at the end of the line (which is determined by paragraph directionality).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1188
	if (aDocPos2 < aDocPos1 || !isformatted || !isContained)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1189
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1190
		if (parFormat.RightToLeft())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1191
			rect.iBr.iX = xCoords[0];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1192
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1193
			rect.iTl.iX = xCoords[0];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1194
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1195
		parFormat.Close();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1196
		return rect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1197
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1198
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1199
	xCoords[1] = point.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1200
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1201
	//	Finding the Trailing edge of (aDocPos1 + 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1202
	docSpec.iType = TTmDocPosSpec::ETrailing;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1203
	docSpec.iPos = aDocPos1 + 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1204
	FindDocPos(docSpec, pos_info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1205
	xCoords[2] = pos_info.iEdge.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1206
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1207
	//	Finding the Trailing edge of (aDocPos2 + 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1208
	docSpec.iPos = aDocPos2 + 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1209
	FindDocPos(docSpec, pos_info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1210
	xCoords[3] = pos_info.iEdge.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1211
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1212
	rect.iBr.iX = xCoords[0];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1213
	rect.iTl.iX = xCoords[0];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1214
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1215
	// The returned rectangle is generated by (when is not a special case)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1216
	// 1) Find the Line rectangle
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1217
	// 2) Find the:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1218
	//		- leading edge of docPos1 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1219
    //		- leading edge of docPos2 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1220
    //		- trailing edge of docPos1+1 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1221
    //		- trailing edge of docPos2+1
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1222
	// 3) Cut the line rectangle at the smallest edge and the largest edge among 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1223
	//	  the four edges found in step 2.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1224
	for (TInt i = 1; i<4; i++ )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1225
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1226
		if (rect.iBr.iX < xCoords[i])
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1227
			rect.iBr.iX = xCoords[i];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1228
		if (rect.iTl.iX > xCoords[i])
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1229
			rect.iTl.iX = xCoords[i];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1230
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1231
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1232
	parFormat.Close();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1233
	return rect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1234
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1235
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1236
/** Gets the bounding rectangle of the picture, if any, located at the document
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1237
position or coordinates specified, and returns it in aPictureRect.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1238
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1239
If aCanScaleOrCrop is non-null, sets aCanScaleOrCrop to indicate 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1240
whether the picture can be scaled or cropped. 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1241
Returns ETrue if the operation was successful. Returns EFalse otherwise;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1242
that is, if there is no picture at the position, or if the position is unformatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1243
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1244
@param aDocPos The document position of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1245
@param aXyPos The layout coordinates of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1246
@param aPictureRect On return, contains the rectangle which encloses the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1247
picture located at the position specified.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1248
@param aCanScaleOrCrop If non-NULL and the function returns ETrue, on return,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1249
indicates whether the picture can be scaled or cropped. By default, NULL.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1250
@return ETrue if the operation was successful, (i.e. there is a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1251
picture character at the position, it has been loaded into
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1252
memory, and the position is formatted). EFalse if any of these
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1253
conditions are not met. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1254
EXPORT_C TBool CTextLayout::PictureRectangleL(TInt aDocPos,TRect& aPictureRect,TBool* aCanScaleOrCrop) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1255
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1256
	if (aDocPos < iText->StartChar() || aDocPos >= iText->EndChar() - 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1257
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1258
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1259
	aPictureRect.SetRect(0,0,0,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1260
	TSize size;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1261
	if (iSource->GetPictureSizeInTwipsL(aDocPos,size) != KErrNone)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1262
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1263
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1264
	TRect rect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1265
	TTmDocPos pos(aDocPos, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1266
	TTmPosInfo2 pos_info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1267
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1268
	TInt subscript;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1269
	if (!iText->FindDocPos(pos,pos_info,info,subscript))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1270
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1271
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1272
	MGraphicsDeviceMap& device = iSource->InterpretDevice();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1273
	size.iWidth = device.HorizontalTwipsToPixels(size.iWidth);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1274
	size.iHeight = device.VerticalTwipsToPixels(size.iHeight);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1275
	rect.iBr.iY = pos_info.iEdge.iY - iBandTop + subscript;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1276
	rect.iTl.iY = rect.iBr.iY - size.iHeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1277
	if (pos_info.iRightToLeft)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1278
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1279
		rect.iBr.iX = pos_info.iEdge.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1280
		rect.iTl.iX = rect.iBr.iX - size.iWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1281
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1282
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1283
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1284
		rect.iTl.iX = pos_info.iEdge.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1285
		rect.iBr.iX = rect.iTl.iX + size.iWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1286
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1287
/*	rect.iTl = pos_info.iEdge;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1288
	rect.Move(0,-iBandTop);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1289
	rect.iTl.iY -= size.iHeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1290
	rect.iBr = rect.iTl + size;*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1291
	CPicture* picture = iSource->PictureL(aDocPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1292
	if (!picture)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1293
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1294
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1295
	if (aCanScaleOrCrop)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1296
		*aCanScaleOrCrop = picture->Capability().iScalingType != TPictureCapability::ENotScaleable ||
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1297
						   picture->Capability().iIsCroppable;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1298
	aPictureRect = rect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1299
	return TRUE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1300
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1301
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1302
/** Finds if there is a picture at the position under the point aXyPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1303
If there is, returns the document position of it, sets the rectangle
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1304
occupied in aPictureRect, and whether the picture allows scaling
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1305
in aCanScaleOrCrop, if non-null. Note that aXyPos may be outside
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1306
the picture found.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1307
@return  The document position of the picture found, or KErrNotFound if there 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1308
is none. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1309
TInt CTextLayout::PictureRectangleAndPosL(const TPoint& aXyPos, TRect& aPictureRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1310
	TBool* aCanScaleOrCrop) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1311
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1312
	TTmPosInfo2 posInfo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1313
	if (!FindXyPos(aXyPos, posInfo))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1314
		return KErrNotFound;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1315
	TInt doc_pos = posInfo.iDocPos.iPos - (posInfo.iDocPos.iLeadingEdge? 0 : 1);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1316
	if (PictureRectangleL(doc_pos, aPictureRect, aCanScaleOrCrop))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1317
		return doc_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1318
	return KErrNotFound;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1319
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1320
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1321
/** Gets the bounding rectangle of the picture (if any) at aXyPos and puts it
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1322
in aPictureRect. If aCanScaleOrCrop is non-null sets *aCanScaleOrCrop to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1323
indicate whether the picture can be scaled or cropped. Note that aXyPos
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1324
may be outside aPictureRect on a successful return, if the picture does
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1325
not occupy the whole of the section of the line it is in.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1326
@return ETrue if the position is formatted and there is a picture there. */	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1327
EXPORT_C TBool CTextLayout::PictureRectangleL(const TPoint& aXyPos,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1328
	TRect& aPictureRect, TBool* aCanScaleOrCrop) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1329
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1330
	return 0 <= PictureRectangleAndPosL(aXyPos, aPictureRect, aCanScaleOrCrop)?
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1331
		ETrue : EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1332
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1333
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1334
/** Gets the first document position in a line that starts at or below the top
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1335
of the visible area. If there is no such line, returns the position after the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1336
last formatted character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1337
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1338
@return The document position of the first character in a line within the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1339
visible area. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1340
EXPORT_C TInt CTextLayout::FirstDocPosFullyInBand() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1341
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1342
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1343
	if (!iText->YPosToLine(iBandTop,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1344
		return iText->EndChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1345
	if (info.iOuterRect.iTl.iY < iBandTop)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1346
		return info.iEnd;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1347
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1348
		return info.iStart;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1349
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1350
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1351
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1352
 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1353
 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1354
/** This interface is deprecated, and is made available in version 7.0s solely
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1355
to provide binary compatibility with Symbian OS v6.1. Developers are strongly
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1356
advised not to make use of this API in new applications. In particular, use the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1357
other overload of this function if you need to distinguish between leading and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1358
trailing edge positions.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1359
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1360
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1361
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1362
@param aDocPos A valid document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1363
@param aYPos The y coordinate at which to display the character at aDocPos. On
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1364
return, contains the actual vertical position of the specified part of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1365
line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1366
@param aYPosQualifier Controls which part of the line is set to appear at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1367
aYPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1368
@param aDiscardFormat If ETrue (EFViewDiscardAllFormat), the text is reformatted
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1369
to include aDocPos, otherwise text is formatted only as necessary when bringing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1370
new lines into the visible area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1371
@return The number of pixels the text was scrolled, may be positive or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1372
negative. A value of CTextLayout::EFScrollRedrawWholeScreen indicates that the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1373
entire visible area, at least, was scrolled, and so there is no point in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1374
blitting text; a full redraw is needed. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1375
EXPORT_C TInt CTextLayout::SetViewL(TInt aDocPos,TInt& aYPos,TViewYPosQualifier aYPosQualifier,TDiscard aDiscardFormat)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1376
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1377
	TTmDocPos pos(aDocPos, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1378
	return SetViewL(pos,aYPos,aYPosQualifier,aDiscardFormat);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1379
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1380
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1381
/** Changes the top of the visible area so that the line containing aDocPos is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1382
vertically positioned at aYPos. Which part of the line is set to appear at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1383
aYPos (top, baseline, or bottom) is controlled by the TViewYPosQualifier
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1384
argument, which also specifies whether the visible area is to be filled and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1385
whether the line should be made fully visible if possible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1386
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1387
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1388
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1389
@param aDocPos A valid document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1390
@param aYPos The y coordinate at which to display the character at aDocPos. On
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1391
return, contains the actual vertical position of the specified part of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1392
line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1393
@param aYPosQualifier Controls which part of the line is set to appear at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1394
aYPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1395
@param aDiscardFormat If ETrue (EFViewDiscardAllFormat), the text is reformatted
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1396
to include aDocPos, otherwise text is formatted only as necessary when bringing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1397
new lines into the visible area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1398
@return The number of pixels the text was scrolled, may be positive or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1399
negative. A value of CTextLayout::EFScrollRedrawWholeScreen indicates that the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1400
entire visible area, at least, was scrolled, and so there is no point in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1401
blitting text; a full redraw is needed. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1402
EXPORT_C TInt CTextLayout::SetViewL(const TTmDocPos& aDocPos, TInt& aYPos,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1403
	TViewYPosQualifier aYPosQualifier, TDiscard aDiscardFormat)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1404
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1405
	if (aDocPos.iPos < 0 || aDocPos.iPos > iSource->DocumentLength())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1406
		Panic(EInvalidDocPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1407
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1408
	/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1409
	If the format is to be discarded, or no text has yet been formatted, or if the document position
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1410
	to be viewed is not formatted, format the band.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1411
	*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1412
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1413
	TBool all_formatted = FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1414
	TBool pos_is_formatted = iText->DocPosToLine(aDocPos,info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1415
	if (!pos_is_formatted ||
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1416
		aDiscardFormat == EFViewDiscardAllFormat ||
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1417
		(iText->StartChar() == iText->EndChar() && iSource->DocumentLength() > 0))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1418
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1419
		FormatBandL(aDocPos.iPos,aDocPos.iPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1420
		all_formatted = TRUE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1421
		pos_is_formatted = iText->DocPosToLine(aDocPos,info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1422
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1423
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1424
	// Find out where the top of the line is.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1425
	if (!pos_is_formatted)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1426
		return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1427
	int line_top_y = info.iOuterRect.iTl.iY - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1428
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1429
	// Determine the desired position of the top of the line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1430
	int offset = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1431
	if (aYPosQualifier.iHotSpot == TViewYPosQualifier::EFViewBaseLine)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1432
		offset = info.iBaseline - info.iOuterRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1433
	else if (aYPosQualifier.iHotSpot == TViewYPosQualifier::EFViewBottomOfLine)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1434
		offset = info.iOuterRect.iBr.iY - info.iOuterRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1435
	int desired_line_top_y = aYPos - offset;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1436
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1437
	// Adjust aYPos so that the line is fully visible if desired.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1438
	if (aYPosQualifier.iFullyVisible == TViewYPosQualifier::EFViewForceLineFullyVisible)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1439
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1440
		TInt screenHeight = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1441
		TInt lineHeight = info.iOuterRect.Height();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1442
		TInt lineAscent = info.iBaseline - info.iOuterRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1443
		// If the top of the line is off the top of the screen, and the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1444
		// baseline and the top can both fit, make the top of the line flush
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1445
		// with the top of the screen.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1446
		if (lineAscent <= screenHeight
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1447
			&& desired_line_top_y < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1448
			desired_line_top_y = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1449
		// If the whole line can fit and the bottom if off the bottom of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1450
		// screen, make the bottom flush with the bottom of the screen.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1451
		if (lineHeight <= screenHeight
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1452
			&& screenHeight < desired_line_top_y + lineHeight)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1453
			desired_line_top_y = screenHeight - lineHeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1454
		// If the ascent will not fit, or the baseline is off the bottom of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1455
		// the screen, move the baseline flush with the bottom of the screen
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1456
		if (screenHeight < lineAscent
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1457
			|| screenHeight < desired_line_top_y + lineAscent)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1458
			desired_line_top_y = screenHeight - lineAscent;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1459
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1460
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1461
	// Scroll the document position to the desired vertical coordinate and update aYPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1462
	TInt dy = desired_line_top_y - line_top_y;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1463
	if (dy)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1464
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1465
		dy = ScrollL(dy,aYPosQualifier.iFillScreen ? EFDisallowScrollingBlankSpace : EFAllowScrollingBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1466
		line_top_y += dy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1467
		aYPos = line_top_y + offset;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1468
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1469
		// Ensure that aYPos is in the line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1470
		if (aYPosQualifier.iHotSpot == TViewYPosQualifier::EFViewBottomOfLine)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1471
			aYPos--;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1472
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1473
	return all_formatted ? EFScrollRedrawWholeScreen : dy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1474
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1475
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1476
/** Formats enough text to fill the visible band.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1477
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1478
Note: Do not use if a CTextView object owns this CTextLayout object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1479
EXPORT_C void CTextLayout::FormatBandL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1480
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1481
	FormatBandL(0,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1482
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1483
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1484
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1485
Format enough text to fill the visible band and include both aStartDocPos and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1486
aEndDocPos. Start at the start of the document if formatting everything, or at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1487
the start of the paragraph containing aStartDocPos if formatting the visible
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1488
band only.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1489
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1490
void CTextLayout::FormatBandL(TInt aStartDocPos,TInt aEndDocPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1491
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1492
	TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1493
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1494
	if (iBandHeight != CLayoutData::EFHeightForFormattingAllText)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1495
		param.iStartChar = iSource->ParagraphStart(aStartDocPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1496
	if (param.iWrapWidth < 1 || param.iMaxHeight < 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1497
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1498
		// Do just a little formatting if the values are illegal.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1499
		// This is to prevent the AddParL running with no
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1500
		// height limit, taking up huge amounts of time, and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1501
		// having to return with 0 lines formatted, which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1502
		// confuses CEikEdwin.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1503
		param.iMaxHeight = 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1504
		param.iWrapWidth = 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1505
		iText->SetTextL(*iSource,param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1506
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1507
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1508
	iText->SetTextL(*iSource,param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1509
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1510
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1511
	if(IsFormattingBand() && (iText->EndChar() <= aEndDocPos && iText->EndChar() < iSource->DocumentLength()))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1512
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1513
		param.iEndChar = aEndDocPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1514
		iText->ExtendFormattingDownwardsL(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1515
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1516
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1517
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1518
		while (iText->EndChar() <= aEndDocPos && iText->EndChar() < iSource->DocumentLength())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1519
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1520
			int h,p;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1521
			AddFormattingAtEndL(param, h, p);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1522
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1523
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1524
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1525
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1526
	if (iBandHeight != CLayoutData::EFHeightForFormattingAllText)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1527
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1528
		int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1529
		while (iText->LayoutHeight() < visible_height)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1530
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1531
			int h,p;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1532
			if (!iText->AddParL(param,TRUE,h,p))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1533
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1534
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1535
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1536
	iBandTop = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1537
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1538
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1539
/** Makes sure the line that aYPos is in (if it exists) is covered by the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1540
formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1541
@param aYPos Y pixel position in window-relative co-ordinates.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1542
@internalComponent
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1543
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1544
EXPORT_C void CTextLayout::ExtendFormattingToCoverYL(TInt aYPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1545
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1546
	TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1547
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1548
	param.iStartChar = iText->StartChar() - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1549
	param.iEndChar = iText->EndChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1550
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1551
	TInt heightIncrease;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1552
	TInt p;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1553
	while (iBandTop < -aYPos && iText->AddParL(param, ETrue, heightIncrease, p))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1554
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1555
		iBandTop += heightIncrease;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1556
		param.iStartChar = iText->StartChar() - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1557
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1558
	TInt heightRemaining = iBandTop + aYPos - iText->LayoutHeight() + 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1559
	if(heightRemaining > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1560
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1561
		param.iStartChar = iText->EndChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1562
		param.iEndChar = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1563
		param.iMaxHeight = heightRemaining;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1564
		iText->ExtendFormattingDownwardsL(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1565
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1566
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1567
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1568
/** Allows you to increase the formatted text range by specifying a point in the text you
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1569
want to increase the range to. Makes sure the line that aDocPos is in (if it exists) is covered by the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1570
formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1571
@param aDocPos Position in the text you wish to extend the formatting to. e.g. passing in 0 will
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1572
increase the formatting range to the very first character entered in the document.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1573
@pre aDocPos is in the range 0...DocumentLength
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1574
@post aDocPos has been formatted
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1575
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1576
EXPORT_C void CTextLayout::ExtendFormattingToCoverPosL(TInt aDocPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1577
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1578
	__ASSERT_DEBUG(0 <= aDocPos && aDocPos <= DocumentLength(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1579
			Panic(EInvalidDocPos));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1580
	TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1581
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1582
	param.iStartChar = iText->StartChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1583
	param.iEndChar = iText->EndChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1584
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1585
	TInt heightIncrease;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1586
	TInt p;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1587
	TInt pos = aDocPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1588
	if(pos > 0)     // Avoid going into infinite loop.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1589
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1590
		pos -= 1;	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1591
		}						
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1592
	while ((pos < param.iStartChar) && (iText->AddParL(param, ETrue, heightIncrease, p)))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1593
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1594
		iBandTop += heightIncrease;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1595
		param.iStartChar = iText->StartChar();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1596
		}	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1597
	param.iEndChar = aDocPos + 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1598
	if(iText->EndChar() < param.iEndChar)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1599
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1600
		iText->ExtendFormattingDownwardsL(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1601
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1602
	__ASSERT_DEBUG((aDocPos >= iText->StartChar()) && (aDocPos <= iText->EndChar()),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1603
			Panic(ECharacterNotFormatted));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1604
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1605
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1606
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1607
/** Sets the formatted text to begin at the start of the paragraph including
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1608
aStartPos and end at aEndPos. Moves the line containing aStartDocPos to the top
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1609
of the visible area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1610
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1611
Notes:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1612
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1613
This function is not generally useful; it exists for the convenience of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1614
printing system.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1615
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1616
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1617
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1618
@param aStartDocPos A document position within the paragraph from which to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1619
begin formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1620
@param aEndDocPos Document position at which to end formatting. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1621
EXPORT_C void CTextLayout::FormatCharRangeL(TInt aStartDocPos,TInt aEndDocPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1622
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1623
	FormatCharRangeL(aStartDocPos,aEndDocPos,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1624
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1625
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1626
void CTextLayout::FormatCharRangeL(TInt aStartDocPos,TInt aEndDocPos,TInt aPixelOffset)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1627
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1628
	__ASSERT_DEBUG(aStartDocPos >= 0 && aStartDocPos <= DocumentLength(),Panic(EInvalidDocPos));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1629
	__ASSERT_DEBUG(aEndDocPos >= 0 && aEndDocPos <= DocumentLength(),Panic(EInvalidDocPos));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1630
	__ASSERT_DEBUG(aStartDocPos <= aEndDocPos,Panic(ENoCharRangeToFormat));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1631
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1632
	TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1633
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1634
	param.iStartChar = iSource->ParagraphStart(aStartDocPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1635
	param.iEndChar = aEndDocPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1636
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1637
	iText->SetTextL(*iSource,param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1638
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1639
	TTmDocPos pos(aStartDocPos, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1640
	if (iText->DocPosToLine(pos,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1641
		iBandTop = info.iOuterRect.iTl.iY - aPixelOffset;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1642
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1643
		iBandTop = 0; //+ raise an exception?
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1644
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1645
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1646
/** A special function to support background formatting by the higher level
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1647
CTextView class. It formats the next pending line. The return value is ETrue if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1648
there is more formatting to do. On entry, aBotPixel contains the y coordinate
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1649
of the bottom of the formatted text; this is updated by the function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1650
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1651
Notes:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1652
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1653
Not generally useful.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1654
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1655
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1656
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1657
@param aBotPixel On entry, contains the y coordinate of the bottom of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1658
formatted text; this is updated by the function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1659
@return ETrue if there is more formatting to do. EFalse if not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1660
EXPORT_C TBool CTextLayout::FormatNextLineL(TInt& aBottomPixel)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1661
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1662
	if (iUnformattedStart < KMaxTInt)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1663
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1664
		TTmFormatParamBase param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1665
		InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1666
		param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1667
		TTmReformatParam reformat_param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1668
		reformat_param.iStartChar = iUnformattedStart;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1669
		reformat_param.iMaxExtraLines = KMaxExtraLines;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1670
		reformat_param.iParInvalid = iParInvalid;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1671
		TTmReformatResult result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1672
		iText->FormatL(param,reformat_param,result);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1673
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1674
		// If there is no formatting to do, indicate that formatting is complete to the end of the paragraph
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1675
		if (result.iUnformattedStart == KMaxTInt)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1676
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1677
			TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1678
			TTmDocPos pos(iUnformattedStart, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1679
			TBool isFormatted = iText->DocPosToLine(pos,info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1680
			__ASSERT_DEBUG(isFormatted, Panic(EPosNotFormatted));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1681
			isFormatted = iText->ParNumberToLine(info.iParNumber,KMaxTInt,info);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1682
			__ASSERT_DEBUG(isFormatted, Panic(EPosNotFormatted));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1683
			aBottomPixel = info.iOuterRect.iBr.iY - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1684
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1685
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1686
		// Indicate that formatting is complete up to the lower edge of the current line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1687
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1688
			aBottomPixel = result.iRedrawRect.iBr.iY - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1689
		iUnformattedStart = result.iUnformattedStart;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1690
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1691
	return iUnformattedStart < KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1692
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1693
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1694
/** Controls the height of a single line, for use by the pagination system
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1695
only. Using the format supplied in aParaFormat, determines the height of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1696
line containing aDocPos and returns it in aHeight. Changes aDocPos to the end
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1697
of the line and returns ETrue if that position is not the end of the paragraph.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1698
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1699
Notes:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1700
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1701
Not generally useful; it exists for use by the pagination system only.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1702
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1703
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1704
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1705
@param aParaFormat Contains paragraph formatting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1706
@param aDocPos A document position. On return, contains the document position
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1707
of the end of the line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1708
@param aHeight On return, contains the height of the formatted line containing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1709
aDocPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1710
@param aPageBreak On return, ETrue if the last character on the line is a page
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1711
break. EFalse if not.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1712
@return ETrue if the line is not the last line in the paragraph. EFalse if it is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1713
the last line. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1714
EXPORT_C TBool CTextLayout::FormatLineL(CParaFormat* /*aParaFormat*/,TInt& aDocPos,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1715
										TInt& aHeight,TBool& aPageBreak)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1716
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1717
	// If the line is not formatted, replace the formatted text with the single paragraph containing the line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1718
	if (aDocPos < iText->StartChar() || aDocPos >= iText->EndChar())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1719
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1720
		TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1721
		InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1722
		param.iStartChar = iSource->ParagraphStart(aDocPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1723
		param.iEndChar = iSource->ParagraphEnd(aDocPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1724
		param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1725
		iText->SetTextL(*iSource,param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1726
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1727
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1728
	TTmDocPos pos(aDocPos, ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1729
	if (!iText->DocPosToLine(pos,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1730
		User::Leave(KErrGeneral);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1731
	aHeight = info.iOuterRect.Height();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1732
	aDocPos = info.iEnd;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1733
	TPtrC text;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1734
	TTmCharFormat format;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1735
	iSource->GetText(info.iEnd - 1,text,format);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1736
	aPageBreak = text[0] == CEditableText::EPageBreak;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1737
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1738
	return !(info.iFlags & TTmLineInfo::EParEnd);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1739
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1740
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1741
/** Scrolls the text up or down by aNumParas paragraphs, disallowing blank
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1742
space at the bottom of the visible area if aScrollBlankSpace is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1743
CTextLayout::EFDisallowScrollingBlankSpace.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1744
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1745
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1746
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1747
@param aNumParas The number of paragraphs to scroll; may be a positive or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1748
negative value. On return, contains the number of paragraphs not scrolled; that
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1749
is the difference between the requested number and the number of paragraphs
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1750
actually scrolled.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1751
@param aScrollBlankSpace Only relevant when scrolling downwards.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1752
CTextLayout::EFAllowScrollingBlankSpace allows blank space to scroll into the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1753
visible area. CTextLayout::EFDisallowScrollingBlankSpace prevents blank space
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1754
from scrolling into the visible area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1755
@pre aPars must not scroll the display beyond the formatted range. If aPars
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1756
scrolls beyond the formatted range, this method will leave with the error code
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1757
CTextLayout::EPosNotFormatted
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1758
@return The number of pixels actually scrolled. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1759
EXPORT_C TInt CTextLayout::ScrollParagraphsL(TInt& aPars,TAllowDisallow aScrollBlankSpace)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1760
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1761
	TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1762
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1763
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1764
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1765
	int height_increase = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1766
	int paragraphs_increase = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1767
	int cur_par = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1768
	int desired_par = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1769
	int pixels_to_scroll = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1770
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1771
	if (aPars > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1772
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1773
		if (iText->YPosToLine(iBandTop,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1774
			cur_par = info.iParNumber;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1775
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1776
			User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1777
		if (info.iParTop < iBandTop)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1778
			aPars--;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1779
		desired_par = cur_par - aPars;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1780
		while (desired_par < 0 && iText->AddParL(param,TRUE,height_increase,paragraphs_increase))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1781
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1782
			iBandTop += height_increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1783
			desired_par += paragraphs_increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1784
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1785
		aPars = -desired_par;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1786
		if (desired_par < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1787
			desired_par = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1788
		if (!iText->ParNumberToLine(desired_par,0,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1789
			User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1790
		pixels_to_scroll = iBandTop - info.iOuterRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1791
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1792
	else if (aPars < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1793
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1794
		int band_bottom = iBandTop + VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1795
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1796
		// Extend formatting until the visible height is filled.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1797
		param.iEndChar = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1798
		param.iMaxHeight = band_bottom - iText->LayoutHeight();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1799
		if(param.iMaxHeight > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1800
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1801
			iText->ExtendFormattingDownwardsL(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1802
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1803
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1804
		if (iText->YPosToLine(band_bottom - 1,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1805
			cur_par = info.iParNumber;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1806
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1807
			User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1808
		if (!((info.iFlags & TTmLineInfo::EParEnd) && info.iOuterRect.iBr.iY == band_bottom))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1809
			aPars++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1810
		desired_par = cur_par - aPars;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1811
		int last_par = iText->Paragraphs() - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1812
		while (desired_par > last_par && iText->AddParL(param, EFalse, height_increase,paragraphs_increase))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1813
			last_par += paragraphs_increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1814
		aPars = last_par - desired_par;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1815
		if (desired_par > last_par)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1816
			desired_par = last_par;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1817
		if (!iText->ParNumberToLine(desired_par,KMaxTInt,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1818
			iText->AddParL(param, EFalse, height_increase, paragraphs_increase);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1819
		if (!iText->ParNumberToLine(desired_par,KMaxTInt,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1820
			User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1821
		pixels_to_scroll = band_bottom - info.iOuterRect.iBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1822
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1823
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1824
	return ScrollL(pixels_to_scroll,aScrollBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1825
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1826
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1827
/** Scrolls the text up or down by aNumLines lines, disallowing blank space at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1828
the bottom of the visible area if aScrollBlankSpace is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1829
CTextLayout::EFDisallowScrollingBlankSpace.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1830
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1831
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1832
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1833
@param aNumLines The number of lines to scroll; may be a positive or negative
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1834
value. On return, contains the number of lines not scrolled; that is, the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1835
requested number, minus the number actually scrolled.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1836
@param aScrollBlankSpace Only relevant when scrolling downwards.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1837
CTextLayout::EFAllowScrollingBlankSpace allows blank space to scroll into the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1838
visible area. CTextLayout::EFDisallowScrollingBlankSpace prevents blank space
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1839
from scrolling into the visible area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1840
@pre aLines must not scroll the display beyond the formatted range. If aLines
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1841
scrolls beyond the formatted range, this method will leave with the error code
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1842
CTextLayout::EPosNotFormatted
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1843
@return The number of pixels actually scrolled. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1844
EXPORT_C TInt CTextLayout::ScrollLinesL(TInt& aLines,TAllowDisallow aScrollBlankSpace)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1845
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1846
	TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1847
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1848
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1849
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1850
	int height_increase = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1851
	int paragraphs_increase = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1852
	int lines_scrolled = aLines;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1853
	int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1854
	if (aLines > 0)			// bring aLines lines into view at the top of the display
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1855
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1856
		int desired_top_line_number = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1857
		for (;;)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1858
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1859
			// Find the line number of the first visible line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1860
			TBool partial_line = FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1861
			int top_line_number = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1862
			if (iBandTop >= iText->LayoutHeight())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1863
				top_line_number = iText->Lines();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1864
			else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1865
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1866
				if (iText->YPosToLine(iBandTop,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1867
					top_line_number = info.iLineNumber;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1868
				else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1869
					User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1870
				partial_line = iBandTop > info.iOuterRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1871
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1872
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1873
			// Find the line number of the desired first visible line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1874
			// Defect fix for INC015850. Changed IF so that if the currently
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1875
			// visible top line is as tall or taller (due to a large font or picture)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1876
			// than the visible height of the view our desired top line remains
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1877
			// the next one above so that a scroll takes place.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1878
			desired_top_line_number = top_line_number - aLines;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1879
			if (partial_line && (info.iOuterRect.iBr.iY-info.iOuterRect.iTl.iY < visible_height))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1880
				desired_top_line_number++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1881
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1882
			// If the desired first visible line number is negative, more lines need to be formatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1883
			if (desired_top_line_number >= 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1884
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1885
			if (!iText->AddParL(param,TRUE,height_increase,paragraphs_increase))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1886
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1887
			iBandTop += height_increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1888
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1889
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1890
		if (desired_top_line_number < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1891
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1892
			lines_scrolled += desired_top_line_number;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1893
			desired_top_line_number = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1894
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1895
		aLines -= lines_scrolled;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1896
		if (lines_scrolled)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1897
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1898
			if (!iText->LineNumberToLine(desired_top_line_number,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1899
				User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1900
			// if the line to be scrolled to is taller than the screen, we want
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1901
			// to make sure that the baseline is not scrolled off the screen.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1902
			if (visible_height < info.iBaseline - info.iOuterRect.iTl.iY)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1903
				return ScrollL(iBandTop + visible_height - info.iBaseline, aScrollBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1904
			return ScrollL(iBandTop - info.iOuterRect.iTl.iY,aScrollBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1905
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1906
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1907
			return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1908
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1909
	else if (aLines < 0)	// bring aLines lines into view at the bottom of the display
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1910
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1911
		if (iScrollFlags & EFScrollOnlyToTopsOfLines)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1912
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1913
			// If we are restricting scroll to the tops of lines, then lines at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1914
			// bottom are irrelevant, so all we do is lose the top line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1915
			if (!iText->YPosToLine(iBandTop, info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1916
				User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1917
			return ScrollL(-info.iOuterRect.Height(), aScrollBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1918
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1919
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1920
		int desired_bottom_line_number = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1921
		int band_bottom = iBandTop + visible_height;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1922
		int last_formatted_line = iText->Lines() - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1923
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1924
		// Extend formatting until the visible height is filled.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1925
		param.iEndChar = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1926
		param.iMaxHeight = band_bottom - iText->LayoutHeight();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1927
		if(param.iMaxHeight > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1928
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1929
			iText->ExtendFormattingDownwardsL(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1930
			}	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1931
		for (;;)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1932
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1933
			// Find the line number of the last visible line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1934
			TBool partial_line = FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1935
			int bottom_line_number = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1936
			if (iText->YPosToLine(band_bottom - 1,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1937
				bottom_line_number = info.iLineNumber;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1938
			else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1939
				User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1940
			partial_line = band_bottom < info.iOuterRect.iBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1941
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1942
			// Find the line number of the desired last visible line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1943
			desired_bottom_line_number = bottom_line_number - aLines;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1944
			if (partial_line)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1945
				desired_bottom_line_number--;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1946
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1947
			// If the desired last visible line number is greater than the last line, more lines need to be formatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1948
			if (desired_bottom_line_number <= last_formatted_line)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1949
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1950
			if (!AddFormattingAtEndL(param, height_increase,paragraphs_increase))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1951
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1952
			last_formatted_line = iText->Lines() - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1953
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1954
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1955
		int shortfall = desired_bottom_line_number - last_formatted_line;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1956
		if (shortfall > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1957
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1958
			lines_scrolled += shortfall;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1959
			desired_bottom_line_number = last_formatted_line;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1960
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1961
		aLines -= lines_scrolled;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1962
		if (lines_scrolled)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1963
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1964
			if (!iText->LineNumberToLine(desired_bottom_line_number,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1965
				User::Leave(EPosNotFormatted);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1966
			return ScrollL(band_bottom - info.iOuterRect.iBr.iY,aScrollBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1967
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1968
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1969
			return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1970
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1971
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1972
		return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1973
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1974
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1975
/** Scrolls the text up or down by aPixels pixels, disallowing blank space at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1976
the bottom of the visible area if aScrollBlankSpace is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1977
CTextLayout::EFDisallowScrollingBlankSpace.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1978
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1979
The return value (not aPixels, as you would expect from ScrollParagraphsL() and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1980
ScrollLinesL()) contains the number of pixels not successfully scrolled, that
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1981
is, the original value of aPixels, minus the number of pixels actually
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1982
scrolled. On return, aPixels is set to the number of pixels actually scrolled.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1983
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1984
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1985
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1986
@param aPixels The number of pixels to scroll; may be a positive or negative
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1987
value. On return, contains the number of pixels actually scrolled.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1988
@param aScrollBlankSpace Only relevant when scrolling downwards.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1989
CTextLayout::EFAllowScrollingBlankSpace allows blank space to scroll into the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1990
visible area. CTextLayout::EFDisallowScrollingBlankSpace prevents blank space
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1991
from scrolling into the visible area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1992
@return The difference between the requested number of pixels to scroll and the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1993
number of pixels actually scrolled. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1994
EXPORT_C TInt CTextLayout::ChangeBandTopL(TInt& aPixels,TAllowDisallow aScrollBlankSpace)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1995
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1996
	int desired_pixels = aPixels;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1997
	aPixels = ScrollL(aPixels,aScrollBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1998
	return desired_pixels - aPixels;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  1999
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2000
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2001
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2002
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2003
/** Scrolls the text up or down by aPixels pixels, allowing blank space at
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2004
top and bottom of the visible area, which means the scrolling can go beyond the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2005
top or bottom border.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2006
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2007
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2008
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2009
@param aPixels The number of pixels to scroll; may be a positive or negative
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2010
value. The actual scrolled pixel number is always identical to aPixels*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2011
EXPORT_C void CTextLayout::ChangeBandTopNoLimitBorderL(TInt aPixels)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2012
    {
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2013
    ScrollL(aPixels,EFAllowScrollingBlankSpace,ETrue,ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2014
    }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2015
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2016
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2017
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2018
 * Finds a position (in pixels, from the top of the window) where the cursor
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2019
 * can be such that its line will be fully visible. If this is not possible,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2020
 * then return one with its baseline visible. If this is not possible, we don't
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2021
 * care what the answer is.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2022
 */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2023
TInt CTextLayout::SuggestCursorPos(TInt aCurrentCursorPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2024
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2025
	int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2026
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2027
	if (iText->YPosToLine(iBandTop + aCurrentCursorPos, info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2028
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2029
		TBool currentLineHasBaselineVisible =
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2030
			(TBool)(iBandTop <= info.iBaseline
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2031
			&& info.iBaseline < iBandTop + visible_height);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2032
		TInt tryThisLine = -1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2033
		// find a good line to put the cursor on.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2034
		if (info.iOuterRect.iTl.iY < iBandTop)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2035
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2036
			// try next line
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2037
			tryThisLine = info.iLineNumber + 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2038
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2039
		else if (iBandTop + visible_height < info.iOuterRect.iBr.iY)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2040
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2041
			tryThisLine = info.iLineNumber - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2042
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2043
		if (0 <= tryThisLine && iText->LineNumberToLine(tryThisLine, info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2044
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2045
			if (iBandTop <= info.iOuterRect.iTl.iY
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2046
				&& info.iOuterRect.iBr.iY < iBandTop + visible_height)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2047
				// this line fully visible
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2048
				aCurrentCursorPos = info.iBaseline - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2049
			else if (!currentLineHasBaselineVisible
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2050
				&& iBandTop <= info.iBaseline
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2051
				&& info.iBaseline < iBandTop + visible_height)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2052
				// not fully visible, but its baseline is, and the original
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2053
				// line's baseline was not
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2054
				aCurrentCursorPos = info.iBaseline - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2055
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2056
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2057
	return aCurrentCursorPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2058
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2059
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2060
/** Scrolls up by a page (that is the band height as set by SetBandHeight(), or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2061
half that amount if scrolling over lines taller than this), moving the text
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2062
downwards. The current desired vertical cursor position is passed in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2063
aYCursorPos and updated to a new suggested position as near as possible to it,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2064
but within the visible text and on a baseline.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2065
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2066
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2067
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2068
@param aYCursorPos The current desired vertical cursor position. On return,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2069
updated to a new suggested position as near as possible to it.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2070
@param aPixelsScrolled On return, contains the number of pixels scrolled. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2071
EXPORT_C void CTextLayout::PageUpL(TInt& aYCursorPos,TInt& aPixelsScrolled)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2072
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2073
	// Move the cursor into the visible area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2074
	int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2075
	if (aYCursorPos < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2076
		aYCursorPos = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2077
	else if (aYCursorPos > visible_height)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2078
		aYCursorPos = visible_height - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2079
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2080
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2081
	// position the top of the screen must be at least as low as
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2082
	TInt longestScrollTo = iBandTop + visible_height
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2083
		- visible_height * KMaxProportionOfScreenToScroll/1000;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2084
	// position the top of the screen must be at least as high as
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2085
	TInt shortestScrollTo = iBandTop + visible_height
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2086
		- visible_height * KMinProportionOfScreenToScroll/1000;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2087
	TInt desiredScrollTo = shortestScrollTo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2088
	// find the line at the top of the screen
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2089
	// (we cannot find the one that includes the first pixel off the screen
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2090
	// because it might not have been formatted yet)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2091
	if  (iText->YPosToLine(iBandTop, info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2092
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2093
		// subtract one from the line number if this was on the screen
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2094
		TInt line = info.iLineNumber
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2095
			- (info.iOuterRect.iTl.iY < iBandTop? 0 : 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2096
			+ KNumberOfLinesToKeepVisibleDuringScroll;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2097
		if (iText->LineNumberToLine(Max(0, line), info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2098
			desiredScrollTo = info.iOuterRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2099
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2100
	if (shortestScrollTo < desiredScrollTo)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2101
		desiredScrollTo = shortestScrollTo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2102
	else if (desiredScrollTo < longestScrollTo)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2103
		desiredScrollTo = longestScrollTo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2104
	aPixelsScrolled = ScrollL(iBandTop + visible_height - desiredScrollTo,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2105
		EFDisallowScrollingBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2106
	aYCursorPos = aPixelsScrolled == 0?
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2107
		0
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2108
		: SuggestCursorPos(aYCursorPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2109
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2110
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2111
/** Scrolls down by a page (that is the band height as set by SetBandHeight(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2112
or half that amount if scrolling over lines taller than this), moving the text
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2113
upwards. The current desired vertical cursor position is passed in aYCursorPos
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2114
and updated to a new suggested position as near as possible to it, but within
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2115
the visible text and on a baseline.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2116
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2117
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2118
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2119
@param aYCursorPos The current desired vertical cursor position. On return,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2120
updated to a new suggested position as near as possible to it.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2121
@param aPixelsScrolled On return, contains the number of pixels scrolled - a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2122
negative value. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2123
EXPORT_C void CTextLayout::PageDownL(TInt& aYCursorPos,TInt& aPixelsScrolled)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2124
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2125
	// Move the cursor into the visible area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2126
	int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2127
	if (aYCursorPos < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2128
		aYCursorPos = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2129
	else if (aYCursorPos > visible_height)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2130
		aYCursorPos = visible_height - 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2131
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2132
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2133
	// position the bottom of the screen must be at least as high as
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2134
	TInt longestScrollTo = iBandTop +
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2135
		visible_height * KMaxProportionOfScreenToScroll/1000;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2136
	// position the bottom of the screen must be at least as low as
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2137
	TInt shortestScrollTo = iBandTop + visible_height * KMinProportionOfScreenToScroll/1000;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2138
	TInt desiredScrollTo = shortestScrollTo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2139
	// find the line at the bottom of the screen
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2140
	// (we cannot find the one that includes the first pixel off the screen
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2141
	// because it might not have been formatted yet)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2142
	if  (iText->YPosToLine(iBandTop + visible_height - 1, info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2143
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2144
		// add one to the line number if this was on the screen
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2145
		TInt line = info.iLineNumber
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2146
			+ (iBandTop + visible_height < info.iBaseline? 0 : 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2147
			- KNumberOfLinesToKeepVisibleDuringScroll;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2148
		if (iText->LineNumberToLine(Max(0, line), info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2149
			desiredScrollTo = info.iOuterRect.iBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2150
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2151
	if (desiredScrollTo < shortestScrollTo)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2152
		desiredScrollTo = shortestScrollTo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2153
	else if (longestScrollTo < desiredScrollTo)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2154
		desiredScrollTo = longestScrollTo;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2155
	aPixelsScrolled = ScrollL(iBandTop - desiredScrollTo,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2156
		EFDisallowScrollingBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2157
	aYCursorPos = aPixelsScrolled == 0?
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2158
		visible_height - 1
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2159
		: SuggestCursorPos(aYCursorPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2160
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2161
	__ASSERT_DEBUG(-visible_height <= aPixelsScrolled,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2162
		Panic(EPageScrollError));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2163
	__ASSERT_DEBUG(0 <= aYCursorPos && aYCursorPos <= visible_height,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2164
		Panic(EPageScrollError));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2165
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2166
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2167
/** Reformats to reflect a single character edit.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2168
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2169
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2170
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2171
@param aType Indicates the type of edit which has taken place.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2172
CTextLayout::EFCharacterInsert (the default) for a character insertion,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2173
CTextLayout::EFParagraphDelimiter for a paragraph delimiter insertion,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2174
CTextLayout::EFLeftDelete or CTextLayout::EFRightDelete for a character or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2175
paragraph delimiter deletion to the left or right of the document position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2176
@param aCursorPos The document position at which the edit took place, before
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2177
the edit. If this position is not formatted, a panic occurs; it is modified in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2178
accordance with the edit.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2179
@param aGood On return, the y coordinate of the top of the paragraph following
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2180
the paragraph which has been edited, before the edit.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2181
@param aFormattedUpTo On return, the y coordinate of the bottom of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2182
reformatted line or lines, after the edit.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2183
@param aFormattedFrom On return, the vertical layout coordinate of the top of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2184
the reformatted line or lines, after the edit.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2185
@param aScroll The number of pixels by which the text had to be scrolled
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2186
(positive means text moved down).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2187
@param aFormatChanged ETrue if text is to be reformatted from the start of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2188
paragraph the cursor was on before the edit, EFalse if from the start of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2189
line the cursor was on before the edit.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2190
@return EFalse if no more lines need to be reformatted. ETrue if some more lines
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2191
need to be reformatted. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2192
EXPORT_C TBool CTextLayout::HandleCharEditL(TUint aType,TInt& aCursorPos,TInt& aGood,TInt& aFormatBottom,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2193
											TInt& aFormatTop,TInt& aScroll,TBool aFormatFromStartOfPar)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2194
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2195
	__ASSERT_ALWAYS(iSource->iFormatMode != CLayoutData::EFPrintPreviewMode,Panic(EPrintPreviewModeError));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2196
	__ASSERT_ALWAYS(aType <= EFRightDelete,Panic(EBadCharacterEditType));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2197
	__ASSERT_ALWAYS(!aFormatFromStartOfPar || aType == EFRightDelete || aType == EFLeftDelete,Panic(EBadCharacterEditType));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2198
	__ASSERT_ALWAYS(aCursorPos >= iText->StartChar() && aCursorPos < iText->EndChar(),Panic(ECharacterNotFormatted));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2199
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2200
	// Mark the entire paragraph invalid if background formatting is taking place.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2201
	iParInvalid = iUnformattedStart != KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2202
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2203
	// Cancel any pending background formatting, which has now been invalidated by the change.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2204
	iUnformattedStart = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2205
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2206
	// Adjust the cursor position and determine the range of characters to reformat.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2207
	TTmReformatParam reformat_param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2208
	reformat_param.iParInvalid = iParInvalid;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2209
	switch (aType)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2210
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2211
		case EFCharacterInsert:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2212
		case EFParagraphDelimiter:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2213
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2214
			reformat_param.iStartChar = aCursorPos++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2215
			reformat_param.iNewLength = 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2216
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2217
			// surrogate support
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2218
			TPtrC textForSurrogate;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2219
			TTmCharFormat formatForSurrogate;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2220
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2221
			iSource->GetText(aCursorPos-1, textForSurrogate, formatForSurrogate);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2222
			if ( textForSurrogate.Length() > 1 )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2223
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2224
				TUint highSurrogate = textForSurrogate[0];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2225
				TUint lowSurrogate = textForSurrogate[1];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2226
				if ( TChar::IsHighSurrogate( highSurrogate ) && TChar::IsLowSurrogate( lowSurrogate ) )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2227
					{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2228
					// if we are inserting a surrogate pair, do not break the pair
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2229
					aCursorPos++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2230
					reformat_param.iNewLength++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2231
					}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2232
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2233
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2234
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2235
		case EFLeftDelete:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2236
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2237
			reformat_param.iStartChar = --aCursorPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2238
			reformat_param.iOldLength = 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2239
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2240
			// surrogate support
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2241
			TPtrC textForSurrogate;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2242
			TTmCharFormat formatForSurrogate;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2243
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2244
			if (aCursorPos >= 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2245
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2246
				iSource->GetText(aCursorPos-1, textForSurrogate, formatForSurrogate);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2247
				if ( textForSurrogate.Length() > 1 )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2248
					{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2249
					TUint highSurrogate = textForSurrogate[0];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2250
					TUint lowSurrogate = textForSurrogate[1];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2251
					if ( TChar::IsHighSurrogate( highSurrogate ) && TChar::IsLowSurrogate( lowSurrogate ) )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2252
						{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2253
						// if we are deleting a surrogate pair, do not break the pair
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2254
						reformat_param.iStartChar = --aCursorPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2255
						reformat_param.iOldLength++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2256
						}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2257
					}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2258
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2259
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2260
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2261
		case EFRightDelete:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2262
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2263
			reformat_param.iStartChar = aCursorPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2264
			reformat_param.iOldLength = 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2265
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2266
			// surrogate support
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2267
			TPtrC textForSurrogate;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2268
			TTmCharFormat formatForSurrogate;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2269
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2270
			iSource->GetText(aCursorPos, textForSurrogate, formatForSurrogate);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2271
			if ( textForSurrogate.Length() > 1 )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2272
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2273
				TUint highSurrogate = textForSurrogate[0];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2274
				TUint lowSurrogate = textForSurrogate[1];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2275
				if ( TChar::IsHighSurrogate( highSurrogate ) && TChar::IsLowSurrogate( lowSurrogate ) )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2276
					{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2277
					reformat_param.iOldLength++;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2278
					}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2279
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2280
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2281
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2282
		default: break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2283
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2284
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2285
	// Set up the formatting parameters.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2286
	TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2287
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2288
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2289
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2290
	// Format the whole band if necessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2291
	TTmDocPos cursorPos(aCursorPos, EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2292
	if (reformat_param.iStartChar < iText->StartChar() || reformat_param.iStartChar + reformat_param.iOldLength >= iText->EndChar())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2293
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2294
		FormatBandL(reformat_param.iStartChar,reformat_param.iStartChar + reformat_param.iOldLength);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2295
		aFormatTop = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2296
		aFormatBottom = iText->LayoutHeight() - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2297
		aGood = aFormatBottom;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2298
		aScroll = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2299
		ScrollDocPosIntoViewL(cursorPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2300
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2301
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2302
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2303
	// Reformat the chosen range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2304
	reformat_param.iMaxExtraLines = KMaxExtraLines;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2305
	TTmReformatResult result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2306
	iText->FormatL(param,reformat_param,result);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2307
	result.iRedrawRect.Move(0,-iBandTop);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2308
	iUnformattedStart = result.iUnformattedStart;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2309
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2310
	// Scroll if necessary and extend the redraw area to include material scrolled into view.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2311
	aScroll = ScrollDocPosIntoViewL(cursorPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2312
	if (aScroll > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2313
		result.iRedrawRect.iBr.iY += aScroll;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2314
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2315
		result.iRedrawRect.iTl.iY += aScroll;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2316
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2317
	// Return coordinates.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2318
	aFormatTop = result.iRedrawRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2319
	aFormatBottom = result.iRedrawRect.iBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2320
	aGood = result.iUnchangedTop - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2321
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2322
	// Add new paragraphs if necessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2323
	int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2324
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2325
	param.iEndChar = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2326
	param.iMaxHeight = (iBandTop + visible_height) - iText->LayoutHeight();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2327
	if(param.iMaxHeight > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2328
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2329
		iText->ExtendFormattingDownwardsL(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2330
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2331
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2332
	//remove formatting from the end if necessary
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2333
	PruneFormatL(EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2334
	// Return TRUE if more text needs to be formatted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2335
	return iUnformattedStart < KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2336
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2337
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2338
/** Reformats to reflect changes to a block of text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2339
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2340
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2341
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2342
@param aSelection The start and new length of the changed block. When
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2343
inserting, specify the insertion position. When deleting, specify the position
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2344
of the start of the deletion. When reformatting, specify the start and length
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2345
of the reformatted block.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2346
@param aOldCharsChanged The old length of the changed block. When inserting,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2347
specify zero. When deleting, specify the number of deleted characters. When
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2348
reformatting, specify the number of reformatted characters.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2349
@param aViewChanges On return, contains the top of the reformatted text
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2350
(iFormattedFrom), the bottom of the reformatted text (iFormattedTo), the amount
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2351
by which the text above the reformatted text has scrolled (iScrollAtTop) and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2352
the amount by which the text below the reformatted text has scrolled
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2353
(iScrollAtBottom) (positive values mean the text moves down).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2354
@param aFormatChanged Indicates whether the paragraph format for the first or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2355
last affected paragraph has changed, meaning that the text to be reformatted
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2356
must extend out to paragraph boundaries and cannot be restricted to only some
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2357
lines. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2358
EXPORT_C void CTextLayout::HandleBlockChangeL(TCursorSelection aSelection,TInt aOldLength,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2359
											  TViewRectChanges& aChanges,TBool aFormatFromStartOfPar)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2360
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2361
	__ASSERT_ALWAYS(iSource->iFormatMode != CLayoutData::EFPrintPreviewMode,Panic(EPrintPreviewModeError));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2362
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2363
	// Do nothing if the selection is outside the formatted range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2364
	if (aSelection.LowerPos() > iText->EndChar() || aSelection.HigherPos() < iText->StartChar())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2365
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2366
		aChanges.iFormattedFrom = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2367
		aChanges.iFormattedTo = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2368
		aChanges.iScrollAtTop = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2369
		aChanges.iScrollAtBottom = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2370
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2371
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2372
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2373
	// Format the whole band if necessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2374
	TTmDocPos cursorPos(aSelection.iCursorPos,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2375
		aSelection.iCursorPos < aSelection.iAnchorPos? ETrue : EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2376
	if (aSelection.LowerPos() < iText->StartChar() || aSelection.LowerPos() + aOldLength >= iText->EndChar())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2377
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2378
		FormatBandL(aSelection.iCursorPos,aSelection.iCursorPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2379
		aChanges.iFormattedFrom = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2380
		aChanges.iFormattedTo = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2381
		aChanges.iScrollAtTop = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2382
		aChanges.iScrollAtBottom = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2383
		ScrollDocPosIntoViewL(cursorPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2384
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2385
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2386
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2387
	// Reformat the chosen range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2388
	TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2389
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2390
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2391
	TTmReformatParam reformat_param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2392
	reformat_param.iStartChar = aSelection.LowerPos();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2393
	reformat_param.iOldLength = aOldLength;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2394
	reformat_param.iNewLength = aSelection.Length();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2395
	reformat_param.iParFormatChanged = aFormatFromStartOfPar;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2396
	TTmReformatResult result;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2397
	iText->FormatL(param,reformat_param,result);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2398
	result.iRedrawRect.Move(0,-iBandTop);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2399
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2400
	// Scroll if necessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2401
	int dy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2402
	if(iTextViewCursorPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2403
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2404
		dy = ScrollDocPosIntoViewL(iTextViewCursorPos->TmDocPos());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2405
		iTextViewCursorPos = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2406
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2407
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2408
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2409
		dy = ScrollDocPosIntoViewL(cursorPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2410
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2411
	result.iRedrawRect.Move(0,dy);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2412
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2413
	aChanges.iFormattedFrom = result.iRedrawRect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2414
	aChanges.iFormattedTo = result.iRedrawRect.iBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2415
	aChanges.iScrollAtTop = dy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2416
	aChanges.iScrollAtBottom = dy + result.iHeightChange;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2417
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2418
	// Extend formatting to fill the band if necessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2419
	int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2420
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2421
	param.iEndChar = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2422
	param.iMaxHeight = (iBandTop + visible_height) - iText->LayoutHeight();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2423
	if(param.iMaxHeight > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2424
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2425
		iText->ExtendFormattingDownwardsL(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2426
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2427
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2428
	//remove formatting from the end if necessary
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2429
	PruneFormatL(EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2430
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2431
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2432
/** Reformats to reflect the addition of one or more complete paragraphs at the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2433
end of the text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2434
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2435
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2436
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2437
@param aFirstPixel On return, the top y coordinate of the added material.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2438
@param aLastPixel On return, the bottom y coordinate of the added material.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2439
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2440
EXPORT_C void CTextLayout::HandleAdditionalCharactersAtEndL(TInt& aNewTextTop,TInt& aNewTextBottom)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2441
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2442
	aNewTextTop = aNewTextBottom = iText->LayoutHeight() - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2443
	int format_required = BandHeightInPixels() - aNewTextBottom;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2444
	if (format_required > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2445
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2446
		TTmFormatParam param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2447
		InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2448
		param.iMaxHeight = format_required;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2449
		TInt oldHeight = iText->LayoutHeight();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2450
		iText->ExtendFormattingDownwardsL(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2451
		aNewTextBottom += (iText->LayoutHeight() - oldHeight);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2452
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2453
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2454
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2455
/** Reformats to reflect changes to the space above and below paragraphs
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2456
(CParaFormat::iSpaceBeforeInTwips and iSpaceAfterInTwips).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2457
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2458
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2459
@deprecated 6.1 Use FormatBandL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2460
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2461
EXPORT_C void CTextLayout::ReformatVerticalSpaceL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2462
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2463
	// Reformat the whole band; only space above and below paragraphs has changed, but who cares?
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2464
	FormatBandL();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2465
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2466
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2467
/** Temporarily changes the vertical alignment of the text with respect to the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2468
visible height.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2469
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2470
Notes:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2471
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2472
Not generally useful.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2473
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2474
Do not use if a CTextView object owns this CTextLayout object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2475
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2476
@param aVerticalAlignment Specifies whether the formatted text should be placed
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2477
at the top (CParaFormat::ETopAlign), vertical centre (CParaFormat::ECenterAlign
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2478
or CParaFormat::EJustifiedAlign) or bottom (CParaFormat::EBottomAlign) of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2479
band. CParaFormat::EUnspecifiedAlign or CParaFormat::ECustomAlign may also be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2480
specified. These values cause the baseline of the first formatted line to be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2481
positioned 82% of the way down the band (provided for the Agenda's
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2482
application's year view). */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2483
EXPORT_C void CTextLayout::AdjustVerticalAlignment(CParaFormat::TAlignment aVerticalAlignment)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2484
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2485
	int excess = BandHeight() - FormattedHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2486
	int space_before = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2487
	__ASSERT_ALWAYS(!IsFormattingBand(),Panic(EMustFormatAllText));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2488
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2489
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2490
	switch (aVerticalAlignment)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2491
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2492
		case CParaFormat::EAbsoluteLeftAlign:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2493
		case CParaFormat::ETopAlign:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2494
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2495
		case CParaFormat::ECenterAlign:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2496
		case CParaFormat::EJustifiedAlign:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2497
			space_before = excess / 2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2498
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2499
		case CParaFormat::EAbsoluteRightAlign:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2500
		case CParaFormat::EBottomAlign:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2501
			space_before = excess;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2502
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2503
		case CParaFormat::EUnspecifiedAlign:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2504
		case CParaFormat::ECustomAlign:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2505
			if (iText->LineNumberToLine(0,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2506
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2507
				space_before = CLayoutData::EFBaseLinePosition * BandHeight() / 100 - info.iBaseline;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2508
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2509
			else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2510
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2511
				space_before = CLayoutData::EFBaseLinePosition * BandHeight() / 100;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2512
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2513
			break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2514
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2515
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2516
	iBandTop = -space_before;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2517
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2518
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2519
static TInt SingleBorderWidthInPixels(const MGraphicsDeviceMap* aGd,const TParaBorder& aBorder,TBool aHoriz)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2520
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2521
	TInt width = aBorder.iThickness;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2522
	if (width > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2523
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2524
		if (aHoriz)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2525
			width = aGd->VerticalTwipsToPixels(width);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2526
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2527
			width = aGd->HorizontalTwipsToPixels(width);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2528
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2529
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2530
		width = 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2531
	return width;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2532
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2533
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2534
/** Draws paragraph borders, optionally with a background colour for the border
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2535
and a clip region. Provided for applications that display a menu of border
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2536
styles, like a wordprocessor.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2537
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2538
@param aGd Provides twip-to-pixel conversion.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2539
@param aGc Graphics context to which to draw the border. Its pen settings are
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2540
overridden by the values specified by aBorder and its draw mode is set to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2541
CGraphicsContext::EDrawModePEN.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2542
@param aRect The outer bounds of the border.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2543
@param aBorder Specifies the four sides of the border.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2544
@param aBackground If not null, the background colour, (used between double
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2545
border lines, or between dots or dashes).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2546
@param aClipRegion If non-null, specifies a clip region.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2547
@param aDrawRect If non-null, and if aClipRegion is non-null, specifies a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2548
rectangle to be subtracted from the clip region. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2549
EXPORT_C void CTextLayout::DrawBorders(const MGraphicsDeviceMap* aGd,CGraphicsContext& aGc,const TRect& aBoundingRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2550
									   const TParaBorderArray& aBorder,const TRgb* aBackground,TRegion *aClipRegion,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2551
									   const TRect* aDrawRect)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2552
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2553
	TPoint pointTl,pointBr;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2554
	TRect rect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2555
	TInt * ptrStartLength=NULL;			//To stop a warning
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2556
	TInt * ptrEndLength=NULL;			//To stop a warning
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2557
	TInt * ptrStartWidth=NULL;			//To stop a warning
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2558
	TInt * ptrEndWidth=NULL;			//To stop a warning
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2559
	TInt directionOut=0;			//To stop a warning
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2560
	TInt indexJoint1=0,indexJoint2=0;			//To stop a warning
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2561
	TBool drawAsLine=EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2562
	TRect clipRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2563
	CGraphicsContext::TPenStyle	penStyle[4];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2564
	TInt widthInPixels[4];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2565
	TBool horiz;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2566
	const MFormParam* form_param = MFormParam::Get();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2567
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2568
	{for (TInt border=0; border<=3; border++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2569
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2570
		TParaBorder::TLineStyle lineStyle=aBorder.iBorder[border].iLineStyle;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2571
		if (lineStyle == TParaBorder::ENullLineStyle)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2572
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2573
			penStyle[border]=CGraphicsContext::ENullPen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2574
			widthInPixels[border]=0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2575
			continue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2576
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2577
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2578
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2579
			horiz=(border==CParaFormat::EParaBorderTop || border==CParaFormat::EParaBorderBottom);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2580
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2581
			widthInPixels[border]=SingleBorderWidthInPixels(aGd,aBorder.iBorder[border],horiz);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2582
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2583
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2584
		if (lineStyle==TParaBorder::ESolid || lineStyle==TParaBorder::EDouble)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2585
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2586
			penStyle[border]=CGraphicsContext::ESolidPen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2587
			continue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2588
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2589
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2590
		if (lineStyle == TParaBorder::EDashed)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2591
			penStyle[border]=CGraphicsContext::EDashedPen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2592
		else if (lineStyle == TParaBorder::EDotted)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2593
			penStyle[border]=CGraphicsContext::EDottedPen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2594
		else if (lineStyle == TParaBorder::EDotDash)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2595
			penStyle[border]=CGraphicsContext::EDotDashPen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2596
		else if (lineStyle == TParaBorder::EDotDotDash)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2597
			penStyle[border]=CGraphicsContext::EDotDotDashPen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2598
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2599
		}}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2600
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2601
	{for (TInt border=0; border<=3; border++)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2602
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2603
// Go to next border, if have NULL linestyle.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2604
		if (widthInPixels[border]==0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2605
			continue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2606
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2607
// Reset clipping region
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2608
		clipRect.SetSize(TSize(0,0));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2609
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2610
// Draw as line if not solid lines.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2611
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2612
		if (penStyle[border]!=CGraphicsContext::ESolidPen)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2613
			drawAsLine=ETrue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2614
			
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2615
		pointTl=aBoundingRect.iTl;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2616
		pointBr=aBoundingRect.iBr;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2617
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2618
		if (border==CParaFormat::EParaBorderLeft)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2619
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2620
			pointBr.iX=pointTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2621
			ptrStartLength=&pointTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2622
			ptrEndLength=&pointBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2623
			ptrStartWidth=&pointTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2624
			ptrEndWidth=&pointBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2625
			directionOut=-1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2626
			indexJoint1=CParaFormat::EParaBorderTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2627
			indexJoint2=CParaFormat::EParaBorderBottom;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2628
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2629
		if (border == CParaFormat::EParaBorderRight)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2630
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2631
			pointTl.iX=pointBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2632
			ptrStartLength=&pointTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2633
			ptrEndLength=&pointBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2634
			ptrStartWidth=&pointTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2635
			ptrEndWidth=&pointBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2636
			directionOut=1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2637
			indexJoint1=CParaFormat::EParaBorderTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2638
			indexJoint2=CParaFormat::EParaBorderBottom;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2639
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2640
		if (border == CParaFormat::EParaBorderTop)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2641
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2642
			pointBr.iY=pointTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2643
			ptrStartLength=&pointTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2644
			ptrEndLength=&pointBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2645
			ptrStartWidth=&pointTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2646
			ptrEndWidth=&pointBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2647
			directionOut=-1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2648
			indexJoint1=CParaFormat::EParaBorderLeft;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2649
			indexJoint2=CParaFormat::EParaBorderRight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2650
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2651
		if (border == CParaFormat::EParaBorderBottom)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2652
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2653
			pointTl.iY=pointBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2654
			ptrStartLength=&pointTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2655
			ptrEndLength=&pointBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2656
			ptrStartWidth=&pointTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2657
			ptrEndWidth=&pointBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2658
			directionOut=1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2659
			indexJoint1=CParaFormat::EParaBorderLeft;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2660
			indexJoint2=CParaFormat::EParaBorderRight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2661
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2662
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2663
		if (!ptrStartWidth || !ptrEndWidth)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2664
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2665
			continue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2666
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2667
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2668
		if (drawAsLine)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2669
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2670
			if (directionOut<0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2671
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2672
				(*ptrStartWidth)+=(widthInPixels[border]-1)/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2673
				(*ptrEndWidth)+=(widthInPixels[border]-1)/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2674
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2675
			else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2676
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2677
				(*ptrStartWidth)-=(widthInPixels[border]+2)/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2678
				(*ptrEndWidth)-=(widthInPixels[border]+2)/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2679
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2680
			(*ptrStartLength)+=(widthInPixels[border]-1)/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2681
			(*ptrEndLength)-=(widthInPixels[border])/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2682
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2683
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2684
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2685
			if (directionOut<0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2686
				(*ptrEndWidth)+=widthInPixels[border];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2687
			else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2688
				(*ptrStartWidth)-=widthInPixels[border];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2689
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2690
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2691
// Colour of pen as is - NO logical combination with background etc.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2692
		aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2693
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2694
		if (drawAsLine)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2695
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2696
// Must draw lines in background colour first, as have dotted/dashed lines.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2697
			aGc.SetPenSize(TSize(widthInPixels[border],widthInPixels[border]));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2698
			if (aBackground)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2699
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2700
				FormUtil::SetPenColor(form_param,&aGc,*aBackground);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2701
				aGc.SetPenStyle(CGraphicsContext::ESolidPen);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2702
				aGc.DrawLine(pointTl,pointBr);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2703
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2704
			FormUtil::SetPenColor(form_param,&aGc,aBorder.iBorder[border].iColor);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2705
			aGc.SetPenStyle(penStyle[border]);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2706
			aGc.DrawLine(pointTl,pointBr);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2707
			(*ptrStartWidth)-=(widthInPixels[border]-1)/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2708
			(*ptrEndWidth)+=(widthInPixels[border]+2)/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2709
			(*ptrStartLength)-=(widthInPixels[border]-1)/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2710
			(*ptrEndLength)+=(widthInPixels[border])/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2711
			clipRect.SetRect(pointTl,pointBr);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2712
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2713
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2714
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2715
// Brush
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2716
			FormUtil::SetBrushColor(form_param,&aGc,aBorder.iBorder[border].iColor);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2717
			aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2718
			aGc.SetPenStyle(CGraphicsContext::ENullPen);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2719
			rect.SetRect(pointTl,pointBr);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2720
			aGc.DrawRect(rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2721
			clipRect=rect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2722
			};
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2723
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2724
// Repeat draw, for double border.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2725
		if (aBorder.iBorder[border].iLineStyle==TParaBorder::EDouble)	 // Now have only got solid border, drawn as rect.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2726
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2727
			__ASSERT_DEBUG(!drawAsLine,Panic(EDrawingBorderError));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2728
			(*ptrStartWidth)-=directionOut*widthInPixels[border];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2729
			(*ptrEndWidth)-=directionOut*widthInPixels[border];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2730
			(*ptrStartLength)+=widthInPixels[indexJoint1];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2731
			(*ptrEndLength)-=widthInPixels[indexJoint2];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2732
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2733
			if (aBackground)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2734
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2735
				rect.SetRect(pointTl,pointBr);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2736
				FormUtil::SetBrushColor(form_param,&aGc,*aBackground);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2737
				aGc.DrawRect(rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2738
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2739
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2740
			(*ptrStartWidth)-=directionOut*widthInPixels[border];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2741
			(*ptrEndWidth)-=directionOut*widthInPixels[border];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2742
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2743
			if (aBorder.iBorder[indexJoint1].iLineStyle==TParaBorder::EDouble)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2744
				(*ptrStartLength)+=widthInPixels[indexJoint1];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2745
			if (aBorder.iBorder[indexJoint2].iLineStyle==TParaBorder::EDouble)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2746
				(*ptrEndLength)-=widthInPixels[indexJoint2];
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2747
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2748
			rect.SetRect(pointTl,pointBr);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2749
			FormUtil::SetBrushColor(form_param,&aGc,aBorder.iBorder[border].iColor);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2750
			aGc.DrawRect(rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2751
			clipRect.BoundingRect(rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2752
			};
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2753
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2754
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2755
// Restore defaults
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2756
		aGc.SetPenStyle(CGraphicsContext::ESolidPen);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2757
		aGc.SetPenSize(TSize(1,1));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2758
// Should change to BACKGROUND colour.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2759
		if (aBackground)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2760
			FormUtil::SetBrushColor(form_param,&aGc,*aBackground);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2761
// If have to clip region, then remove rectangles corresponding to the border region.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2762
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2763
		if (aClipRegion)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2764
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2765
			if (aDrawRect)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2766
				clipRect.Intersection(*aDrawRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2767
			aClipRegion->SubRect(clipRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2768
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2769
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2770
	}};
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2771
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2772
	if (aClipRegion)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2773
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2774
		aClipRegion->Tidy();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2775
		((CWindowGc *) &aGc)->SetClippingRegion(*aClipRegion);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2776
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2777
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2778
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2779
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2780
/** Draws the text. Draws any lines that intersect aDrawRect, which is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2781
specified in window coordinates. The drawing parameters, including the graphics
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2782
context, are given in aDrawTextLayoutContext. If aHighlight is non-null,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2783
highlights (by exclusive-ORing) the specified range of text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2784
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2785
@param aDrawRect The function draw the lines within the visible area, which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2786
intersect this rectangle (which is specified in window coordinates).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2787
@param aDrawTextLayoutContext Provides a graphics context and other parameters
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2788
for the function.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2789
@param aHighlight If not NULL, this range of text is drawn highlighted. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2790
EXPORT_C void CTextLayout::DrawL(const TRect& aDrawRect,const TDrawTextLayoutContext* aDrawTextLayoutContext,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2791
								 const TCursorSelection* aHighlight)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2792
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2793
	// Set the drawing parameters in the MTmSource interface.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2794
	iSource->iFormParam = MFormParam::Get();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2795
	iSource->iLabelsGutter = aDrawTextLayoutContext->iGutterMarginWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2796
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2797
	// Calculate the top left corner of the text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2798
	TPoint top_left = aDrawTextLayoutContext->TopLeftText();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2799
	top_left.iY -= iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2800
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2801
	// Get the graphics context.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2802
	CGraphicsContext* gc = aDrawTextLayoutContext->PrimaryGc();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2803
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2804
	/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2805
	Clip the draw rectangle to the view rectangle, and clip it further to exclude
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2806
	a final partial line if necessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2807
	*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2808
	TRect clip_rect(aDrawRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2809
	clip_rect.Intersection(aDrawTextLayoutContext->iViewRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2810
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2811
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2812
	if (aDrawTextLayoutContext->UseClippingRect())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2813
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2814
		gc->SetClippingRect(clip_rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2815
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2816
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2817
	// Draw the text and background.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2818
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2819
	TBool isDrawingOnAWindowDC = aDrawTextLayoutContext->UseWindowGc();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2820
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2821
	if (isDrawingOnAWindowDC)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2822
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2823
		BeginRedraw(clip_rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2824
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2825
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2826
	iText->DrawLayout(*gc,top_left,clip_rect,&aDrawTextLayoutContext->iBackgroundColor,TRUE, aHighlight, iHighlightExtensions);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2827
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2828
	if (isDrawingOnAWindowDC)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2829
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2830
		EndRedraw();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2831
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2832
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2833
	iSource->iFormParam = NULL;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2834
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2835
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2836
/** Default constructor. 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2837
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2838
The start and end positions are set to zero - Set() should be called to 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2839
initialise the object. */	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2840
EXPORT_C CTextLayout::TRangeChange::TRangeChange()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2841
	: iA(0), iB(0) {}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2842
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2843
/** Sets the start and end positions and whether the highlighting should be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2844
set or cleared.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2845
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2846
Called by the non-default constructor. The start and end positions can be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2847
specified in any order.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2848
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2849
@param aStart The start of the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2850
@param aEnd The end of the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2851
@param aChange Whether the highlighting should be set or cleared. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2852
EXPORT_C void CTextLayout::TRangeChange::Set(TInt aStart, TInt aEnd,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2853
	CTextLayout::TRangeChange::TChangeType aChange)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2854
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2855
	if ((aChange == ESet && aStart < aEnd)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2856
		|| (!(aChange == ESet) && !(aStart < aEnd)))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2857
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2858
		iA = aStart;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2859
		iB = aEnd;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2860
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2861
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2862
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2863
		iA = aEnd;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2864
		iB = aStart;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2865
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2866
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2867
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2868
/** Constructor with a start and end position and whether the highlighting
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2869
in the range should be set or cleared.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2870
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2871
The start and end positions can be specified in any order.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2872
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2873
@param aStart The start position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2874
@param aEnd The end position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2875
@param aChange Specifies whether the highlighting should be set or cleared.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2876
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2877
EXPORT_C CTextLayout::TRangeChange::TRangeChange(TInt aStart, TInt aEnd,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2878
	CTextLayout::TRangeChange::TChangeType aChange)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2879
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2880
	Set(aStart, aEnd, aChange);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2881
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2882
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2883
/** Gets the start and end of the range and whether the highlighting should be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2884
set or cleared.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2885
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2886
@param aStart On return, the start of the range. This is always the lesser of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2887
the two positions.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2888
@param aEnd On return, the end of the range. This is always the greater of the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2889
two positions.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2890
@return Specifies whether the highlighting should be set or cleared. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2891
EXPORT_C CTextLayout::TRangeChange::TChangeType
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2892
	CTextLayout::TRangeChange::Get(TInt& aStart, TInt& aEnd) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2893
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2894
	if (iA < iB)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2895
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2896
		aStart = iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2897
		aEnd = iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2898
		return ESet;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2899
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2900
	aStart = iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2901
	aEnd = iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2902
	return EClear;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2903
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2904
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2905
/** Tests whether the range is not null.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2906
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2907
@return ETrue if the range is not of zero length, EFalse if the range is of zero
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2908
length. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2909
EXPORT_C TBool CTextLayout::TRangeChange::NonNull() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2910
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2911
	return iA - iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2912
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2913
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2914
/** Clips the range so that its start and end positions are within the minimum
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2915
and maximum positions specified.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2916
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2917
@param aMin The minimum value for the start and end of the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2918
@param aMax The maximum value for the start and end of the range.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2919
@return ETrue if the resulting range is not of zero length, EFalse if it is of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2920
zero length. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2921
EXPORT_C TBool CTextLayout::TRangeChange::Clip(TInt aMin, TInt aMax)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2922
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2923
	if (iA < aMin)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2924
		iA = aMin;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2925
	if (iB < aMin)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2926
		iB = aMin;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2927
	if (aMax < iA)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2928
		iA = aMax;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2929
	if (aMax < iB)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2930
		iB = aMax;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2931
	return iA - iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2932
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2933
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2934
/** Try to cancel out sections of the ranges that overlap Merges two ranges of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2935
 characters.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2936
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2937
Two successive calls to CTextLayout::Highlight() could cause unecessary flicker
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2938
or redrawing if the arguments to each call overlap. For example, if extending a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2939
highlight involved removing the old highlight and then drawing the new one,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2940
this would cause visible flicker. This can be eliminated by calling this
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2941
function to remove any overlap between the two ranges. If there is overlap,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2942
this range is set to the result of the merge, and the other range (aBuddy) is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2943
set to zero.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2944
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2945
When calling this function, it does not matter whether or not the two ranges
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2946
overlap. Also it does not matter which range is the parameter and which is the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2947
calling object. After calling OptimizeWith(), it is guaranteed that the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2948
resulting ranges will not overlap, and they will represent the same change to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2949
the highlight as the original two ranges.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2950
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2951
See the code fragment in the class description for TRangeChange for an example
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2952
of how this function is used.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2953
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2954
@param aBuddy The range of characters to combine with this range. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2955
EXPORT_C void CTextLayout::TRangeChange::OptimizeWith(TRangeChange& aBuddy)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2956
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2957
	// we make this have the minimum iA and iB, and aBuddy have the maximum
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2958
	if (aBuddy.iA < iA)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2959
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2960
		TInt temp = aBuddy.iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2961
		aBuddy.iA = iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2962
		iA = temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2963
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2964
	if (aBuddy.iB < iB)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2965
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2966
		TInt temp = aBuddy.iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2967
		aBuddy.iB = iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2968
		iB = temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2969
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2970
	// if they now overlap, we combine them into one and zero the other
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2971
	if (aBuddy.iB <= iA)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2972
		iA = aBuddy.iB = aBuddy.iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2973
	else if (aBuddy.iA <= iB)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2974
		iB = aBuddy.iA = aBuddy.iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2975
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2976
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2977
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2978
TBool CTextLayout::TRangeChange::IsJoinedTo(const TRangeChange aRange)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2979
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2980
	TInt a1 = (iA < iB) ? iA : iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2981
	TInt b1 = (iA < iB) ? iB : iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2982
	TInt a2 = (aRange.iA < aRange.iB) ? aRange.iA : aRange.iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2983
	TInt b2 = (aRange.iA < aRange.iB) ? aRange.iB : aRange.iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2984
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2985
	return a2 <= b1 && a1 <= b2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2986
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2987
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2988
void CTextLayout::TRangeChange::Join(const TRangeChange aRange)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2989
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2990
	TInt a1 = (iA < iB) ? iA : iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2991
	TInt b1 = (iA < iB) ? iB : iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2992
	TInt a2 = (aRange.iA < aRange.iB) ? aRange.iA : aRange.iB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2993
	TInt b2 = (aRange.iA < aRange.iB) ? aRange.iB : aRange.iA;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2994
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2995
	// type set to ESet
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2996
	iA = (a1 < a2) ? a1 : a2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2997
	iB = (b1 > b2) ? b1 : b2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2998
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  2999
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3000
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3001
/** Sets or clears a highlight.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3002
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3003
If the range of characters to highlight is of zero length, the function has no
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3004
effect.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3005
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3006
The function affects only those lines that intersect aDrawRect, which is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3007
specified in window coordinates. The drawing parameters, including the graphics
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3008
context, are given in aDrawTextLayoutContext.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3009
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3010
From v7.0, this function replaces InvertRangeL().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3011
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3012
This function is not intended to be used to set any part of a highlight already
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3013
set, nor to clear any piece of text not highlighted. It is intended to do
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3014
either or both of: clear an existing selection, set a new selection. See the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3015
class description for TRangeChange for a code fragment showing how this
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3016
function should be used.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3017
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3018
@param aHighlight Specifies the range of characters to highlight or from which
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3019
to remove the highlight.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3020
@param aDrawRect Only lines which intersect this rectangle are affected
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3021
(specified in window coordinates).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3022
@param aDrawTextLayoutContext Provides a graphics context and other drawing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3023
parameters, e.g. the text and background colours for the highlighted region. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3024
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3025
EXPORT_C void CTextLayout::Highlight(const CTextLayout::TRangeChange& aChangeHighlight,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3026
	const TRect& aDrawRect,	const TDrawTextLayoutContext* aDrawTextLayoutContext)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3027
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3028
	if (!aChangeHighlight.NonNull())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3029
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3030
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3031
	TRect clip_rect(aDrawRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3032
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3033
	CGraphicsContext* gc = aDrawTextLayoutContext->PrimaryGc();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3034
	if (aDrawTextLayoutContext->UseClippingRect())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3035
		gc->SetClippingRect(clip_rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3036
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3037
	TInt visible_start;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3038
	TInt visible_length = PosRangeInBand(visible_start);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3039
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3040
	TInt start_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3041
	TInt end_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3042
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3043
	CTextLayout::TRangeChange::TChangeType type = aChangeHighlight.Get(start_pos, end_pos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3044
	start_pos = start_pos < visible_start? visible_start : start_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3045
	end_pos = end_pos < visible_start + visible_length? end_pos : start_pos + visible_length;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3046
	TCursorSelection selection(start_pos, end_pos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3047
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3048
	TPoint top_left = aDrawTextLayoutContext->TopLeftText();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3049
	top_left.iY -= iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3050
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3051
	TBool isDrawingOnAWindowDC = aDrawTextLayoutContext->UseWindowGc();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3052
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3053
	TRect boundingRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3054
	iText->GetUpdateBoundingRect(start_pos, end_pos, top_left, boundingRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3055
	iHighlightExtensions->AbsExtendRect(boundingRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3056
	boundingRect.Intersection(clip_rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3057
	if (! boundingRect.IsEmpty())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3058
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3059
		if (isDrawingOnAWindowDC)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3060
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3061
			BeginRedraw(boundingRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3062
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3063
		iText->DrawLayout(*gc, top_left, boundingRect, &aDrawTextLayoutContext->iBackgroundColor, TRUE, &selection, NULL);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3064
		if (isDrawingOnAWindowDC)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3065
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3066
			EndRedraw();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3067
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3068
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3069
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3070
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3071
void CTextLayout::HighlightUsingExtensions(const CTextLayout::TRangeChange& aChangeHighlight,const TRangeChange& aFullHighlight,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3072
	const TRect& aDrawRect,	const TDrawTextLayoutContext* aDrawTextLayoutContext)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3073
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3074
	if (!aChangeHighlight.NonNull())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3075
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3076
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3077
	TRect clip_rect(aDrawRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3078
	clip_rect.Intersection(aDrawTextLayoutContext->TextArea());
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3079
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3080
	CGraphicsContext* gc = aDrawTextLayoutContext->PrimaryGc();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3081
	if (aDrawTextLayoutContext->UseClippingRect())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3082
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3083
		gc->SetClippingRect(clip_rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3084
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3085
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3086
	TInt visible_start;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3087
	TInt visible_length = PosRangeInBand(visible_start);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3088
	TInt start_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3089
	TInt end_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3090
	CTextLayout::TRangeChange::TChangeType type = aChangeHighlight.Get(start_pos, end_pos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3091
	start_pos = start_pos < visible_start? visible_start : start_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3092
	end_pos = end_pos < visible_start + visible_length? end_pos : start_pos + visible_length;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3093
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3094
	TInt full_start_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3095
	TInt full_end_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3096
	(void)aFullHighlight.Get(full_start_pos, full_end_pos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3097
	full_start_pos = full_start_pos < visible_start? visible_start : full_start_pos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3098
	full_end_pos = full_end_pos < visible_start + visible_length? full_end_pos : full_start_pos + visible_length;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3099
	TCursorSelection selection(full_start_pos, full_end_pos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3100
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3101
	TPoint top_left = aDrawTextLayoutContext->TopLeftText();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3102
	top_left.iY -= iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3103
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3104
	TBool isDrawingOnAWindowDC = aDrawTextLayoutContext->UseWindowGc();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3105
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3106
	TRect boundingRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3107
	iText->GetUpdateBoundingRect(start_pos, end_pos, top_left, boundingRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3108
	iHighlightExtensions->AbsExtendRect(boundingRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3109
	boundingRect.Intersection(clip_rect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3110
	if (! boundingRect.IsEmpty())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3111
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3112
		if (isDrawingOnAWindowDC)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3113
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3114
			BeginRedraw(boundingRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3115
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3116
		iText->DrawLayout(*gc, top_left, boundingRect, &aDrawTextLayoutContext->iBackgroundColor, TRUE, &selection, iHighlightExtensions);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3117
		if (isDrawingOnAWindowDC)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3118
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3119
			EndRedraw();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3120
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3121
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3122
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3123
	if (aDrawTextLayoutContext->UseClippingRect())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3124
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3125
		gc->CancelClippingRect();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3126
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3127
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3128
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3129
/** Toggles the selection highlight for the range of text in aHighlight.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3130
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3131
Highlights only those lines that intersect aDrawRect, which is specified in
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3132
window coordinates. The drawing parameters, including the graphics context, are
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3133
given in aDrawTextLayoutContext.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3134
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3135
In v7.0 and onwards, this function is deprecated -Highlight() should be used
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3136
instead.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3137
@deprecated
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3138
@param aHighlight The range of characters for which to invert the highlighting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3139
@param aDrawRect Only lines which intersect this rectangle are affected;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3140
specified in window coordinates.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3141
@param aDrawTextLayoutContext Provides a graphics context and other drawing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3142
parameters. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3143
EXPORT_C void CTextLayout::InvertRangeL(const TCursorSelection& aHighlight,const TRect& aDrawRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3144
	const TDrawTextLayoutContext* aDrawTextLayoutContext)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3145
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3146
	TRangeChange range(aHighlight.iAnchorPos, aHighlight.iCursorPos, TRangeChange::ESet);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3147
	HighlightUsingExtensions(range,range,aDrawRect,aDrawTextLayoutContext);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3148
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3149
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3150
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3151
Return the FORM major version number. This function is not generally useful. It
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3152
is used in test code and was used while making a transition between this and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3153
the former version of FORM. The return value is always 2.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3154
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3155
EXPORT_C TInt CTextLayout::MajorVersion() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3156
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3157
	return 2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3158
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3159
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3160
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3161
This method allows Form clients to register an object able to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3162
create or return references to customisation objects used within Form for
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3163
various tasks e.g. inline text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3164
@param aProvider
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3165
	Reference to interface provider object to register with Formm.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3166
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3167
EXPORT_C void CTextLayout::SetInterfaceProvider( MFormCustomInterfaceProvider* aProvider ) 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3168
    {
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3169
    iSource->iInterfaceProvider = aProvider;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3170
    }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3171
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3172
/** Gets the width and height of the bounding box of the text, including
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3173
indents and margins, when formatted to the specified wrap width.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3174
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3175
This is useful for applications like a web browser that need to determine the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3176
minimum width for a piece of text: if you specify zero as the wrap width, the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3177
returned aSize.iWidth contains the minimum width that could be used for the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3178
text without illegal line breaks, and if you specify KMaxTInt for aWrapWidth,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3179
the returned aSize.iHeight contains the minimum height: the height when each
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3180
paragraph is a single line of unlimited length.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3181
 @since 6.0
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3182
@param aWrapWidth The wrap width for the bounding box.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3183
@param aSize On return, contains the width and height of the bounding box. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3184
EXPORT_C void CTextLayout::GetMinimumSizeL(TInt aWrapWidth,TSize& aSize)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3185
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3186
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3187
	//Get the size of the minimal bounding box of the text when formatted to the specified wrap width.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3188
	//The width may be greater than aWrapWidth. To find the minimum width for the text,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3189
	//pass 0 for aWrapWidth. To find the minimum height, pass KMaxTInt for aWrapWidth.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3190
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3191
	iText->GetMinimumLayoutSizeL(aWrapWidth,aSize);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3192
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3193
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3194
/** Gets the width and height of the bounding box of the text, including
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3195
indents and margins, when formatted to the specified wrap width.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3196
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3197
This is useful for applications like a web browser that need to determine the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3198
minimum width for a piece of text: if you specify zero as the wrap width, the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3199
returned aSize.iWidth contains the minimum width that could be used for the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3200
text, and if you specify KMaxTInt for aWrapWidth, the returned aSize.iHeight
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3201
contains the minimum height: the height when each paragraph is a single
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3202
line of unlimited length. Use aAllowLegalLineBreaksOnly to set whether or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3203
not illegal line breaks should be considered when determining aSize.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3204
 @since 6.0
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3205
@param aWrapWidth The wrap width for the bounding box.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3206
@param aAllowLegalLineBreaksOnly ETrue to only allow legal line breaks, or EFalse to also allow illegal line breaks.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3207
@param aSize On return, contains the width and height of the bounding box. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3208
EXPORT_C void CTextLayout::GetMinimumSizeL(TInt aWrapWidth,TBool aAllowLegalLineBreaksOnly,TSize& aSize)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3209
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3210
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3211
	//Get the size of the minimal bounding box of the text when formatted to the specified wrap width.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3212
	//The width may be greater than aWrapWidth. To find the minimum width for the text,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3213
	//pass 0 for aWrapWidth. To find the minimum height, pass KMaxTInt for aWrapWidth.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3214
	//
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3215
	iText->GetMinimumLayoutSizeL(aWrapWidth,aAllowLegalLineBreaksOnly,aSize);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3216
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3217
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3218
/** Sets the custom drawing object, for customising the way text and its
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3219
background are drawn.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3220
@since 6.0
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3221
@param aCustomDraw Pointer to a custom drawing object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3222
EXPORT_C void CTextLayout::SetCustomDraw(const MFormCustomDraw* aCustomDraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3223
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3224
	iSource->iCustomDraw = aCustomDraw;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3225
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3226
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3227
/** Returns a pointer to the current custom drawing implementation. Returns
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3228
NULL if custom drawing is not in force.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3229
@since 6.0
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3230
@return Pointer to the custom drawing object. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3231
EXPORT_C const MFormCustomDraw* CTextLayout::CustomDraw() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3232
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3233
	return iSource->iCustomDraw;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3234
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3235
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3236
/** Sets custom line breaking.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3237
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3238
If this function is not called, default line breaking behaviour is used.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3239
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3240
Ownership of the custom line breaking object is not transferred to this object.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3241
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3242
@param aCustomWrap A pointer to an object that implements the custom line
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3243
breaking interface. Specify NULL to disable custom line breaking. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3244
EXPORT_C void CTextLayout::SetCustomWrap(const MFormCustomWrap* aCustomWrap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3245
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3246
	iSource->iCustomWrap = aCustomWrap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3247
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3248
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3249
/** Gets the custom line breaking object, as set using SetCustomWrap().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3250
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3251
@return A pointer to the custom line breaking object, or NULL if custom line
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3252
breaking is not in effect. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3253
EXPORT_C const MFormCustomWrap* CTextLayout::CustomWrap() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3254
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3255
	return iSource->iCustomWrap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3256
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3257
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3258
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3259
@internalAll
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3260
@released
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3261
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3262
EXPORT_C void MFormCustomDraw::MFormCustomDraw_Reserved_2()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3263
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3264
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3265
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3266
/** This function is called whenever part of the background of a CTextLayout or
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3267
CTextView object needs to be drawn. The default implementation fills
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3268
aParam.iDrawRect with the colour specified in aBackground.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3269
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3270
The default background colour is contained in aBackground. This is the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3271
background colour of the paragraph if drawing text, or the background colour
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3272
specified in the TDrawTextLayoutContext object passed to CTextLayout::DrawL()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3273
if drawing outside the text area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3274
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3275
The rectangle which is drawn by this function, (this may not be the whole of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3276
aParam.iDrawRect) must be returned in aDrawn; areas not drawn by you are
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3277
automatically filled using the colour aBackground.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3278
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3279
@param aParam Contains the drawing parameters: aParam.iGc is the graphics
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3280
context to use. aParam.iMap is the graphics device map, which allows you to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3281
convert between pixels and twips and create fonts. aParam.iTextLayoutTopLeft is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3282
the origin of the text; bitmaps and other graphics must be drawn relative to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3283
this position. aParam.iDrawRect is the area to be drawn; do not draw outside
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3284
this rectangle.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3285
@param aBackground The default background colour. This is the background colour
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3286
of the paragraph if drawing text, or the background colour specified in the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3287
TDrawTextLayoutContext object passed to CTextLayout::DrawL() if drawing outside
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3288
the text area.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3289
@param aDrawn Must return the rectangle you actually draw. This may not be the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3290
whole of aParam.iDrawRect (for instance, if you are drawing a non-tiled bitmap
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3291
that occupies only part of aRect). */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3292
EXPORT_C void MFormCustomDraw::DrawBackground(const TParam& aParam,const TRgb& aBackground,TRect& aDrawn) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3293
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3294
	MTmCustom c;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3295
	c.DrawBackground(aParam.iGc,aParam.iTextLayoutTopLeft,aParam.iDrawRect,aBackground,aDrawn);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3296
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3297
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3298
/** This function is called after the background has been drawn by
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3299
DrawBackground(), and before drawing the text. This function might be used to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3300
draw a ruled line under each line of text.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3301
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3302
The default implementation of this function does nothing.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3303
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3304
@param aParam Contains the drawing parameters. You should only draw to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3305
aParam.iDrawRect. There is no need to fill aParam.iDrawRect or to indicate the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3306
rectangle drawn.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3307
@param aLineInfo Contains the line metrics: aLineInfo.iOuterLineRect specifies
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3308
the bounding rectangle of the line, including margins, indents and automatic
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3309
space above and below paragraphs, aLineInfo.iInnerLineRect specifies the bounds
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3310
of the text only, aLineInfo.iBaseline specifies the baseline of the text. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3311
EXPORT_C void MFormCustomDraw::DrawLineGraphics(const TParam& /*aParam*/,const TLineInfo& /*aLineInfo*/) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3312
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3313
	// do nothing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3314
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3315
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3316
/** This function is called to draw the text and its highlighted background, if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3317
any, after bidirectional reordering and other character mappings have taken
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3318
place.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3319
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3320
The default implementation of this function draws the text with no special
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3321
effects and supports standard, round-cornered and shadowed highlighting only.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3322
The text is drawn with the left end of its baseline located at aTextOrigin
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3323
after drawing the background, if any, in aParam.iDrawRect.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3324
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3325
The main reason to override this function is to apply custom text highlighting,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3326
(for this, aFormat.iFontPresentation.iHighlightStyle should be in the range
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3327
EFontHighlightFirstCustomStyle to EFontHighlightLastCustomStyle).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3328
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3329
The horizontal spacing between the characters in the text string is increased
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3330
by the number of pixels specified in aExtraPixels. The standard way to do this
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3331
is by calling CGraphicsContext::SetCharJustification().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3332
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3333
The font and other graphics parameters (e.g. pen colour, font style), are
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3334
specified in aParam.iGc but a character format container (aFormat) is supplied
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3335
so that a different font can be used. Note that any graphics drawn cannot
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3336
exceed the bounds of aParam.iDrawRect, so changes are usually restricted to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3337
drawing shadows, outlines, etc. if custom highlighting is in use.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3338
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3339
@param aParam Contains the drawing parameters. Drawing can only occur within
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3340
aParam.iDrawRect.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3341
@param aLineInfo Contains the line metrics.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3342
@param aFormat Specifies the character formatting to apply to the text,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3343
including the type of text highlighting.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3344
@param aText The text string to be drawn.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3345
@param aTextOrigin The point at which the left end of the baseline of the text
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3346
should be drawn.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3347
@param aExtraPixels The number of additional pixels to insert between the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3348
characters in the text string, in order to increase its length. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3349
EXPORT_C void MFormCustomDraw::DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3350
										const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3351
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3352
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3353
	info.iOuterRect = aLineInfo.iOuterRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3354
	info.iInnerRect = aLineInfo.iInnerRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3355
	info.iBaseline = aLineInfo.iBaseline;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3356
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3357
	MTmCustom c;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3358
	c.DrawText(aParam.iGc,aParam.iTextLayoutTopLeft,aParam.iDrawRect,info,aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3359
			   aText,aTextOrigin,aExtraPixels);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3360
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3361
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3362
EXPORT_C void MFormCustomDraw::DrawText(const TParam& aParam,const TLineInfo& aLineInfo,const TCharFormat& aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3363
										const TDesC& aText,const TInt aStart, const TInt aEnd, const TPoint& aTextOrigin,TInt aExtraPixels) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3364
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3365
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3366
	info.iOuterRect = aLineInfo.iOuterRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3367
	info.iInnerRect = aLineInfo.iInnerRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3368
	info.iBaseline = aLineInfo.iBaseline;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3369
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3370
	MTmCustomExtension c;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3371
	c.DrawText(aParam.iGc,aParam.iTextLayoutTopLeft,aParam.iDrawRect,info,aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3372
			   aText,aStart,aEnd,aTextOrigin,aExtraPixels);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3373
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3374
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3375
/** This function translates logical colours specified in FORM objects into
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3376
real colours. The default implementation just returns the default colour that
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3377
is passed in and ignores aColorIndex.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3378
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3379
Overriding implementations may use aColorIndex in any desired way, either to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3380
replace or modify aDefaultColor. The values used in aColorIndex are taken from
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3381
the top byte of a TLogicalRgb object and are thus in the range 0...255. The
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3382
TLogicalRgb class defines two reserved values:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3383
TLogicalRgb::ESystemForegroundIndex = 254 and
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3384
TLogicalRgb::ESystemBackgroundIndex = 255.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3385
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3386
EXPORT_C TRgb MFormCustomDraw::SystemColor(TUint /*aColorIndex*/,TRgb aDefaultColor) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3387
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3388
	return aDefaultColor;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3389
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3390
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3391
void CTextLayout::DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aClipRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3392
								 const TLogicalRgb& aBackground) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3393
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3394
	TPoint top_left(aTopLeft);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3395
	top_left.iY -= iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3396
	iText->DrawBackground(aGc,top_left,aClipRect,aBackground);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3397
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3398
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3399
/** Returns the line break class for a Unicode character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3400
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3401
For convenience, it also gets the range of consecutive characters (if any)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3402
according to the Unicode standard, including aCode, that share the same line
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3403
break class.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3404
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3405
The Unicode line break classes are enumerated in class MTmCustom.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3406
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3407
Each character's line break class is obtained using LineBreakClass(). To find
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3408
out whether a line break is allowed between two adjacent characters, call
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3409
LineBreakPossible() with the line break classes of the two characters as
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3410
arguments. For example, the line break class EClLineBreakClass (closing
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3411
punctuation) applies to characters such as ")", "]" and ";". Line breaks are
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3412
typically allowed after these characters, but not before, so a call to
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3413
LineBreakPossible() with the arguments (EAlLineBreakClass, EClLineBreakClass)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3414
would return EFalse in the default implementation, but a call with
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3415
(EClLineBreakClass, EAlLineBreakClass) would return ETrue.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3416
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3417
@param aCode The Unicode character code of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3418
@param aRangeStart On return, contains the Unicode character code at the start
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3419
of the range including aCode that shares the same line break class as aCode.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3420
@param aRangeEnd On return, contains the Unicode character code at the end of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3421
the range including aCode that shares the same line break class as aCode.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3422
@return The line break class assigned to the character. Line break classes are
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3423
enumerated in class MTmCustom. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3424
 EXPORT_C TUint MFormCustomWrap::LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3425
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3426
	// Create an instance of MTmCustom and then call the MTmCustom's functions for getting a Line Break class 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3427
	MTmCustom c;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3428
	TUint temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3429
	temp=c.LineBreakClass(aCode,aRangeStart,aRangeEnd);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3430
	return temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3431
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3432
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3433
/** Tests whether a line break is possible between two characters.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3434
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3435
If aHaveSpaces is true, the characters are not adjacent one or more space
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3436
characters (with a line break class of ESpLineBreakClass) occur between them.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3437
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3438
The aPrevClass and aNextClass arguments never have the value ESpLineBreakClass.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3439
Instead, this function is called with the classes of the characters on either
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3440
side of the space or run of spaces, (and if so, aHaveSpaces is true). This is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3441
so that line breaks can be prohibited between certain characters with
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3442
intervening spaces, for instance an alphabetic character (EAlLineBreakClass,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3443
such as 'a') and a closing bracket, with a space inbetween.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3444
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3445
Additionally, the arguments to this function never have a value of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3446
ESaLineBreakClass. For such characters, GetLineBreakInContext() is called
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3447
instead.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3448
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3449
@param aPrevClass The line break class of the previous non-space character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3450
@param aNextClass The line break class of the next non-space character.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3451
@param aHaveSpaces ETrue if there are one or more space characters (with a line
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3452
break class of ESpLineBreakClass) between aPrevClass and aNextClass. EFalse if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3453
not.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3454
@return ETrue if a line break is possible between characters with the two line
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3455
break classes, EFalse if not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3456
EXPORT_C TBool MFormCustomWrap::LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3457
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3458
	MTmCustom c;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3459
	TBool temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3460
	temp=c.LineBreakPossible(aPrevClass,aNextClass,aHaveSpaces);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3461
	return temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3462
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3463
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3464
/** Gets the position of the first or last possible line break position in a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3465
text string.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3466
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3467
This function is called instead of LineBreakPossible() for runs of characters
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3468
of class ESaLineBreakClass. It is used for South Asian languages like Thai, Lao
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3469
and Khmer that have no spaces between words, so that line breaks must be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3470
calculated using dictionary lookup or a linguistic algorithm.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3471
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3472
The default implementation of this function just returns false.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3473
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3474
@param aText A string containing characters of class ESaLineBreakClass.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3475
@param aMinBreakPos A position within aText at which to begin searching for a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3476
possible line break position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3477
@param aMaxBreakPos A position within aText at which to stop searching for a
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3478
possible line break position.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3479
@param aForwards If ETrue, the function gets the first possible line break
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3480
position (searches forwards from aMinBreakPos); if EFalse, gets the last one
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3481
(searches backwards from aMaxBreakPos).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3482
@param aBreakPos On return, the position of the first or last possible line
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3483
break within aText. This must be greater than zero and less than aText.Length()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3484
- 1, and must also be in the range aMinBreakPos to aMaxBreakPos.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3485
@return ETrue if a possible line break position is found, EFalse if not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3486
EXPORT_C TBool MFormCustomWrap::GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3487
													  TBool aForwards,TInt& aBreakPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3488
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3489
	MTmCustom c;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3490
	TBool temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3491
	temp=c.GetLineBreakInContext(aText,aMinBreakPos,aMaxBreakPos,aForwards,aBreakPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3492
	return temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3493
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3494
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3495
/** Tests whether a character can overhang the right margin.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3496
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3497
This function can be overridden to customise the line breaking behaviour for
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3498
closing punctuation in Japanese. Any characters for which this function returns
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3499
ETrue are allowed to overhang the right margin. The rest will be moved to the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3500
next line.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3501
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3502
The default implementation of this function just returns false.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3503
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3504
@param aChar The Unicode character code of interest.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3505
@return ETrue if the character specified can overhang the right margin, EFalse if
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3506
not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3507
EXPORT_C TBool MFormCustomWrap::IsHangingCharacter(TUint aChar) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3508
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3509
	MTmCustom c;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3510
	TBool temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3511
	temp=c.IsHangingCharacter(aChar);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3512
	return temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3513
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3514
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3515
// Reserved functions are private until they are used
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3516
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3517
 @internalAll
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3518
 @released
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3519
 */ 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3520
EXPORT_C void MFormCustomWrap::MFormCustomWrap_Reserved_1()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3521
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3522
	// reserved functions
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3523
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3524
// Reserved functions are private until they are used. 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3525
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3526
 @internalAll
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3527
 @released
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3528
 */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3529
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3530
EXPORT_C void MFormCustomWrap::MFormCustomWrap_Reserved_2()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3531
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3532
	// reserved functions 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3533
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3534
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3535
#ifdef _DEBUG
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3536
TBool CTextLayout::__DbgIsFormattingUpToDate() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3537
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3538
	return iUnformattedStart == KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3539
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3540
#endif
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3541
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3542
// TLayDocTextSource stuff begins here.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3543
TLayDocTextSource::TLayDocTextSource():
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3544
	iLayDoc(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3545
	iFlags(EWrap),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3546
	iWidth(KMaxTInt),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3547
	iEllipsis(0x2026),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3548
	iLabelsWidth(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3549
	iLabelsGutter(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3550
	iFormatMode(CLayoutData::EFScreenMode),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3551
	iImageDevice(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3552
	iLabelsDevice(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3553
	iFormatDevice(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3554
	iFontHeightIncreaseFactor(EDefaultFontHeightIncreaseFactor),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3555
	iMinimumLineDescent(EDefaultMinimumLineDescent),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3556
	iNonPrintingCharVisibility(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3557
	iFormParam(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3558
	iCustomDraw(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3559
	iCustomWrap(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3560
	iInterfaceProvider(NULL),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3561
	iDrawOpaque(EFalse),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3562
	iExcessHeightRequired(0),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3563
	iInvisibleCharacterRemapper(NULL)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3564
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3565
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3566
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3567
MGraphicsDeviceMap& TLayDocTextSource::FormatDevice() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3568
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3569
	if (!iFormatDevice)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3570
		CTextLayout::Panic(CTextLayout::EFormatDeviceNotSet);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3571
	if (iLabelsDevice && (iFlags & EUseLabelsDevice))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3572
		return *iLabelsDevice;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3573
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3574
		return *iFormatDevice;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3575
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3576
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3577
MGraphicsDeviceMap& TLayDocTextSource::InterpretDevice() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3578
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3579
	if (!iImageDevice)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3580
		CTextLayout::Panic(CTextLayout::EImageDeviceNotSet);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3581
	if (iLabelsDevice && (iFlags & EUseLabelsDevice))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3582
		return *iLabelsDevice;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3583
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3584
		return *iImageDevice;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3585
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3586
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3587
TInt TLayDocTextSource::DocumentLength() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3588
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3589
	return iLayDoc->LdDocumentLength();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3590
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3591
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3592
void TLayDocTextSource::GetText(TInt aPos,TPtrC& aText,TTmCharFormat& aFormat) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3593
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3594
	TCharFormat f;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3595
	iLayDoc->GetChars(aText,f,aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3596
	aFormat = f;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3597
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3598
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3599
void TLayDocTextSource::GetParagraphFormatL(TInt aPos,RTmParFormat& aFormat) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3600
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3601
	CParaFormat f;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3602
	iLayDoc->GetParagraphFormatL(&f,aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3603
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3604
	// Labels should not have a forced line height or borders so remove these (this is necessary for Agenda).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3605
	if (iFlags & EUseLabelsDevice)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3606
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3607
		f.iLineSpacingInTwips = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3608
		f.iLineSpacingControl = CParaFormat::ELineSpacingAtLeastInTwips;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3609
		f.RemoveAllBorders();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3610
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3611
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3612
	aFormat.CopyL(f);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3613
	f.Reset();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3614
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3615
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3616
TRgb TLayDocTextSource::SystemColor(TUint aColorIndex,TRgb aDefaultColor) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3617
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3618
	if (iCustomDraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3619
		return iCustomDraw->SystemColor(aColorIndex,aDefaultColor);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3620
	else if (iFormParam)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3621
		return iFormParam->SystemColor(aColorIndex,aDefaultColor);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3622
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3623
		return aDefaultColor;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3624
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3625
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3626
CPicture* TLayDocTextSource::PictureL(TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3627
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3628
	return iLayDoc->PictureHandleL(aPos,MLayDoc::EForceLoadTrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3629
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3630
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3631
TInt TLayDocTextSource::GetPictureSizeInTwipsL(TInt aPos,TSize& aSize) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3632
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3633
	return iLayDoc->GetPictureSizeInTwips(aSize,aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3634
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3635
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3636
TInt TLayDocTextSource::ParagraphStart(TInt aPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3637
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3638
	iLayDoc->LdToParagraphStart(aPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3639
	return aPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3640
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3641
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3642
TBool TLayDocTextSource::LabelModeSelect(TLabelType aType, TInt aPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3643
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3644
	if (!(iFlags & EUseLabelsDevice) && aType == EParLabel)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3645
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3646
		// Labels are not allowed on zero-length documents;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3647
		// this is required for Agenda (see ER5U defect EDNGASR-482LSF).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3648
		if (iLayDoc->LdDocumentLength() == 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3649
			return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3650
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3651
		if (iLayDoc->SelectParagraphLabel(aPos))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3652
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3653
			iFlags |= EUseLabelsDevice;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3654
			return TRUE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3655
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3656
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3657
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3658
	return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3659
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3660
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3661
void TLayDocTextSource::LabelMetrics(TLabelType aType, TSize& aLabelSize, TInt& aMarginSize) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3662
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3663
	if (aType == EParLabel)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3664
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3665
		aLabelSize.iWidth = iLabelsWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3666
		aLabelSize.iHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3667
		aMarginSize = iLabelsWidth + iLabelsGutter;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3668
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3669
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3670
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3671
		aLabelSize.iWidth = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3672
		aLabelSize.iHeight = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3673
		aMarginSize = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3674
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3675
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3676
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3677
void TLayDocTextSource::LabelModeCancel()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3678
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3679
	iLayDoc->CancelSelectLabel();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3680
	iFlags &= ~EUseLabelsDevice;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3681
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3682
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3683
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3684
This method is responsible for discovering interface extension objects
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3685
requried by Form for the specified interface Uid.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3686
@param aInterfaceId
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3687
	Identifier for the optional interface requried.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3688
@return
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3689
	Pointer to object supporting the requested interface, 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3690
	or 0 if not supported.	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3691
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3692
TAny* TLayDocTextSource::GetExtendedInterface(const TUid& aInterfaceId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3693
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3694
	TAny* interfacePtr = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3695
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3696
	// First check to see if their is an external interface provider
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3697
	// registered and ask it for the interface.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3698
	if (iInterfaceProvider)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3699
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3700
		interfacePtr = iInterfaceProvider->GetExtendedInterface( aInterfaceId );
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3701
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3702
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3703
	// If interface still not supplied check self and parent to provide it
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3704
	if (!interfacePtr)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3705
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3706
		if (aInterfaceId == KFormLabelApiExtensionUid)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3707
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3708
			return static_cast<MFormLabelApi*>(this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3709
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3710
		else if(aInterfaceId == KTmTextDrawExtId)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3711
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3712
			return static_cast <MTmTextDrawExt*> (this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3713
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3714
		else if(aInterfaceId == KTmCustomExtensionUid)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3715
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3716
			return static_cast <MTmCustomExtension*> (this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3717
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3718
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3719
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3720
			// In this instance, calling the parent class will always return NULL
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3721
			// but the pattern should be followed by all implementors for safety
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3722
			return MTmSource::GetExtendedInterface(aInterfaceId);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3723
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3724
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3725
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3726
	// Return the interface object or 0 if not supported.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3727
	return interfacePtr;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3728
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3729
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3730
void TLayDocTextSource::SetLineHeight(const TLineHeightParam& aParam,TInt& aAscent,TInt& aDescent) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3731
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3732
	// Increase the ascent by the font height increase percentage.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3733
	TLineHeightParam p = aParam;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3734
	p.iFontMaxAscent += ((p.iFontMaxAscent + p.iFontMaxDescent) * iFontHeightIncreaseFactor) / 100;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3735
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3736
	// Call the standard SetLineHeight.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3737
	MTmSource::SetLineHeight(p,aAscent,aDescent);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3738
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3739
	// iExcessHeightRequired is used when height of the highest glyph can be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3740
	// greater than CFont::AscentInPixels() and in iExactLineSpacing mode
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3741
	// This value is set via CTextView::SetExcessHeightRequired()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3742
	if ( aParam.iExactLineHeight )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3743
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3744
		aAscent += iExcessHeightRequired;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3745
		aDescent -= iExcessHeightRequired;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3746
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3747
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3748
	// Enforce the minimum descent; the following logic is borrowed from CLineLayout::WrapLineL in old FORM.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3749
	if (aAscent + aDescent <= iMinimumLineDescent && aDescent == 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3750
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3751
		aDescent = 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3752
		aAscent--;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3753
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3754
	else if (aDescent < iMinimumLineDescent)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3755
		aDescent = iMinimumLineDescent;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3756
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3757
	/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3758
	Ensure the line is at least 1 pixel high and ascent and descent are non-negative so that assertion
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3759
	TCursorPosition::GetLineRectL that cursor pos is contained in line rect doesn't fire.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3760
	*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3761
	if (aAscent < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3762
		aAscent = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3763
	if (aDescent < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3764
		aDescent = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3765
	if (aAscent + aDescent == 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3766
		aDescent = 1;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3767
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3768
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3769
TBool TLayDocTextSource::CanMap() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3770
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3771
	return iFormatMode == CLayoutData::EFScreenMode || iFormatMode == CLayoutData::EFWysiwygMode;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3772
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3773
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3774
TBool TLayDocTextSource::PageBreakInRange(TInt aStartPos,TInt aEndPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3775
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3776
	if (CanMap() && iNonPrintingCharVisibility.PageBreaksVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3777
		return iLayDoc->EnquirePageBreak(aStartPos,aEndPos - aStartPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3778
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3779
		return FALSE;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3780
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3781
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3782
void TLayDocTextSource::DrawBackground(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3783
									   const TLogicalRgb& aBackground,TRect& aDrawn) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3784
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3785
	ResetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3786
	if (iCustomDraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3787
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3788
		MFormCustomDraw::TParam param(aGc,InterpretDevice(),aTopLeft,aRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3789
		TLogicalRgb background = aBackground;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3790
		FormUtil::LogicalToActualColor(iFormParam,background);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3791
		iCustomDraw->DrawBackground(param,background,aDrawn);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3792
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3793
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3794
		MTmSource::DrawBackground(aGc,aTopLeft,aRect,aBackground,aDrawn);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3795
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3796
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3797
void TLayDocTextSource::DrawLineGraphics(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3798
										 const TTmLineInfo& aLineInfo) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3799
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3800
	SetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3801
	if (iCustomDraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3802
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3803
		MFormCustomDraw::TParam param(aGc,InterpretDevice(),aTopLeft,aRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3804
		MFormCustomDraw::TLineInfo lineinfo(aLineInfo.iOuterRect,aLineInfo.iInnerRect,aLineInfo.iBaseline);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3805
		iCustomDraw->DrawLineGraphics(param,lineinfo);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3806
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3807
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3808
		MTmSource::DrawLineGraphics(aGc,aTopLeft,aRect,aLineInfo);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3809
	ResetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3810
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3811
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3812
void TLayDocTextSource::DrawText(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3813
								 const TTmLineInfo& aLineInfo,const TTmCharFormat& aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3814
								 const TDesC& aText,const TPoint& aTextOrigin,TInt aExtraPixels) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3815
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3816
	SetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3817
	if (iCustomDraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3818
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3819
		MFormCustomDraw::TParam param(aGc,InterpretDevice(),aTopLeft,aRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3820
		MFormCustomDraw::TLineInfo lineinfo(aLineInfo.iOuterRect,aLineInfo.iInnerRect,aLineInfo.iBaseline);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3821
		TCharFormat f;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3822
		aFormat.GetTCharFormat(f);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3823
		iCustomDraw->DrawText(param,lineinfo,f,aText,aTextOrigin,aExtraPixels);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3824
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3825
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3826
		MTmSource::DrawText(aGc,aTopLeft,aRect,aLineInfo,aFormat,aText,aTextOrigin,aExtraPixels);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3827
	ResetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3828
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3829
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3830
void TLayDocTextSource::DrawText(CGraphicsContext& aGc,const TPoint& aTopLeft,const TRect& aRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3831
								 const TTmLineInfo& aLineInfo,const TTmCharFormat& aFormat,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3832
								 const TDesC& aText,const TInt aStart, const TInt aEnd, const TPoint& aTextOrigin,TInt aExtraPixels) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3833
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3834
	SetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3835
	if (iCustomDraw)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3836
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3837
		MFormCustomDraw::TParam param(aGc,InterpretDevice(),aTopLeft,aRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3838
		MFormCustomDraw::TLineInfo lineinfo(aLineInfo.iOuterRect,aLineInfo.iInnerRect,aLineInfo.iBaseline);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3839
		TCharFormat f;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3840
		aFormat.GetTCharFormat(f);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3841
		iCustomDraw->DrawText(param,lineinfo,f,aText,aStart,aEnd,aTextOrigin,aExtraPixels);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3842
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3843
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3844
		MTmCustomExtension::DrawText(aGc,aTopLeft,aRect,aLineInfo,aFormat,aText,aStart,aEnd,aTextOrigin,aExtraPixels);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3845
	ResetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3846
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3847
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3848
TBool TLayDocTextSource::LineBreakPossible(TUint aPrevClass,TUint aNextClass,TBool aHaveSpaces) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3849
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3850
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3851
	TBool temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3852
	if (iCustomWrap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3853
		temp=iCustomWrap->LineBreakPossible(aPrevClass,aNextClass,aHaveSpaces);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3854
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3855
		temp=MTmSource::LineBreakPossible(aPrevClass,aNextClass,aHaveSpaces);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3856
	return temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3857
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3858
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3859
TUint TLayDocTextSource::LineBreakClass(TUint aCode,TUint& aRangeStart,TUint& aRangeEnd) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3860
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3861
	TUint temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3862
	if (iCustomWrap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3863
		temp=iCustomWrap->LineBreakClass(aCode,aRangeStart,aRangeEnd);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3864
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3865
		temp=MTmSource::LineBreakClass(aCode,aRangeStart,aRangeEnd);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3866
	return temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3867
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3868
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3869
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3870
TBool TLayDocTextSource::GetLineBreakInContext(const TDesC& aText,TInt aMinBreakPos,TInt aMaxBreakPos,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3871
												 TBool aForwards,TInt& aBreakPos) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3872
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3873
	TBool temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3874
	if (iCustomWrap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3875
		temp=iCustomWrap->GetLineBreakInContext(aText,aMinBreakPos,aMaxBreakPos,aForwards,aBreakPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3876
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3877
		temp=MTmSource::GetLineBreakInContext(aText,aMinBreakPos,aMaxBreakPos,aForwards,aBreakPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3878
	return temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3879
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3880
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3881
TBool TLayDocTextSource::IsHangingCharacter(TUint aChar) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3882
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3883
	TBool temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3884
	if (iCustomWrap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3885
		temp=iCustomWrap->IsHangingCharacter(aChar);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3886
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3887
		temp=MTmSource::IsHangingCharacter(aChar);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3888
	return temp;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3889
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3890
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3891
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3892
TUint TLayDocTextSource::Map(TUint aChar) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3893
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3894
	// Check if custom formatting has been installed
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3895
	if (iInvisibleCharacterRemapper)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3896
		{ // Then use the supplied custom invisible character remapping
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3897
		return iInvisibleCharacterRemapper->Remap(aChar, iNonPrintingCharVisibility, *this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3898
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3899
	else // Use the default
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3900
		return MFormCustomInvisibleCharacterRemapper::DefaultMapping(aChar, iNonPrintingCharVisibility, *this);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3901
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3902
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3903
void TLayDocTextSource::DrawPicture(CGraphicsContext& aGc,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3904
									const TPoint& aTextLayoutTopLeft, const TRect& aRect,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3905
									MGraphicsDeviceMap& aDevice, const CPicture& aPicture) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3906
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3907
	SetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3908
	MTmSource::DrawPicture(aGc, aTextLayoutTopLeft, aRect, aDevice, aPicture);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3909
	ResetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3910
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3911
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3912
//MTmTextDrawExt implementations 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3913
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3914
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3915
Draws a line. Implements MTmTextDrawExt::DrawLine().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3916
If the opaque drawing mode is active, then the line color will stay unchanged (it will not be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3917
alpha-blended in a case of a transparent window).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3918
@param aGc A reference to a graphics context. If the drawing mode is opaque, then this is a 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3919
           CWindowGc reference.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3920
@param aPt1 Line start point
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3921
@param aPt2 Line end point
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3922
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3923
void TLayDocTextSource::DrawLine(CGraphicsContext& aGc, const TPoint& aPt1, const TPoint& aPt2) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3924
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3925
	SetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3926
	aGc.DrawLine(aPt1, aPt2);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3927
	ResetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3928
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3929
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3930
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3931
Draws a text. Implements MTmTextDrawExt::DrawText().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3932
If the opaque drawing mode is active, then the text color will stay unchanged (it will not be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3933
alpha-blended in a case of a transparent window).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3934
@param aGc A reference to a graphics context. If the drawing mode is opaqe, then this is a 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3935
           CWindowGc reference.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3936
@param aPt1 Text start point
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3937
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3938
void TLayDocTextSource::DrawText(CGraphicsContext& aGc, const TDesC& aText, const TPoint& aPt) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3939
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3940
	SetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3941
	aGc.DrawText(aText, aPt);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3942
	ResetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3943
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3944
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3945
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3946
Draws a rectangle. Implements MTmTextDrawExt::DrawRect().
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3947
If the opaque drawing mode is active, then the rectabgle color will stay unchanged (it will not be
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3948
alpha-blended in a case of a transparent window).
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3949
@param aGc A reference to a graphics context. If the drawing mode is opaqe, then this is a 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3950
           CWindowGc reference.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3951
@param aRc Rectangle coordinates
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3952
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3953
void TLayDocTextSource::DrawRect(CGraphicsContext& aGc, const TRect& aRc) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3954
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3955
	SetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3956
	aGc.DrawRect(aRc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3957
	ResetOpaque(aGc);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3958
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3959
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3960
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3961
Sets opaque drawing mode.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3962
@param aGc A reference to a graphics context. If the drawing mode is opaqe, then this is a 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3963
           CWindowGc reference.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3964
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3965
void TLayDocTextSource::SetOpaque(CGraphicsContext& aGc) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3966
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3967
	if(iDrawOpaque)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3968
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3969
		static_cast <CWindowGc&> (aGc).SetOpaque(ETrue);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3970
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3971
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3972
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3973
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3974
Resets opaque drawing mode.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3975
@param aGc A reference to a graphics context. If the drawing mode is opaqe, then this is a 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3976
           CWindowGc reference.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3977
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3978
void TLayDocTextSource::ResetOpaque(CGraphicsContext& aGc) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3979
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3980
	if(iDrawOpaque)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3981
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3982
		static_cast <CWindowGc&> (aGc).SetOpaque(EFalse);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3983
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3984
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3985
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3986
// Private CTextLayout functions start here.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3987
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3988
void CTextLayout::Panic(TPanicNumber aNumber)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3989
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3990
	_LIT(KPanicNumber,"CTextLayout using TAGMA");
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3991
	User::Panic(KPanicNumber,aNumber);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3992
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3993
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3994
void CTextLayout::GetParagraphRect(const TTmDocPos& aDocPos,TRect& aRect) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3995
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3996
	aRect.SetRect(0,0,0,0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3997
	TTmLineInfo info, info2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3998
	if (!iText->DocPosToLine(aDocPos,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  3999
		return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4000
	aRect = info.iOuterRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4001
	if (!(info.iFlags & TTmLineInfo::EParStart))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4002
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4003
		iText->ParNumberToLine(info.iParNumber,0,info2);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4004
		aRect.iTl = info2.iOuterRect.iTl;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4005
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4006
	if (!(info.iFlags & TTmLineInfo::EParEnd))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4007
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4008
		iText->ParNumberToLine(info.iParNumber,KMaxTInt,info2);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4009
		aRect.iBr = info2.iOuterRect.iBr;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4010
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4011
	aRect.Move(0,-iBandTop);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4012
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4013
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4014
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4015
Scroll aDy pixels (positive = text moves down); return number of pixels
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4016
actually scrolled. Create a new formatted band if necessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4017
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4018
TInt CTextLayout::ScrollL(TInt aDy,TAllowDisallow aScrollBlankSpace,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4019
        TBool aTopNoLimitBorder/*=EFalse*/,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4020
        TBool aBottomNoLimitBorder/*=EFalse*/)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4021
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4022
	if ( EFDisallowScrollingBlankSpace == aScrollBlankSpace )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4023
	    {
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4024
	    aTopNoLimitBorder = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4025
	    aBottomNoLimitBorder = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4026
	    }
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4027
	int old_bandtop = iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4028
	int desired_bandtop = iBandTop - aDy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4029
	int pixels_scrolled = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4030
	int height_increase = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4031
	int paragraphs_increase = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4032
	TTmFormatParamBase param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4033
	InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4034
	// Refuse to scroll if the width is illegal. This prevents
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4035
	// time being taken in certain situations where it does
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4036
	// not matter. Once the formatting is capable of
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4037
	// adding smaller chunks of text at a time, this early-out
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4038
	// should become unnecessary.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4039
	if ((param.iWrapWidth < 1 || param.iMaxHeight < 1)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4040
		&& param.iFlags & TTmFormatParamBase::EWrap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4041
		return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4042
	param.iMaxHeight = KMaxTInt;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4043
	int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4044
	if (aDy > 0)		// text moves down; iBandTop decreases
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4045
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4046
		if (aTopNoLimitBorder)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4047
	        iBandTop = desired_bandtop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4048
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4049
		    iBandTop = Max(0,desired_bandtop);//Disallow text scrolled beyond top border
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4050
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4051
		pixels_scrolled = old_bandtop - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4052
		while (pixels_scrolled < aDy)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4053
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4054
			if (!iText->AddParL(param,TRUE,height_increase,paragraphs_increase))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4055
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4056
			pixels_scrolled += height_increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4057
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4058
		if (pixels_scrolled > aDy)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4059
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4060
			iBandTop = pixels_scrolled - aDy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4061
			pixels_scrolled = aDy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4062
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4063
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4064
	else if (aDy < 0)	// text moves up; iBandTop increases
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4065
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4066
        if (aBottomNoLimitBorder)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4067
            iBandTop = desired_bandtop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4068
        else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4069
            iBandTop = Min(iText->LayoutHeight(),desired_bandtop);//Disallow text scrolled beyond bottom border
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4070
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4071
		pixels_scrolled = old_bandtop - iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4072
		while (pixels_scrolled > aDy)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4073
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4074
			if (!AddFormattingAtEndL(param, height_increase,paragraphs_increase))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4075
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4076
			pixels_scrolled -= height_increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4077
			if (pixels_scrolled < aDy)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4078
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4079
				height_increase -= aDy - pixels_scrolled;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4080
				pixels_scrolled = aDy;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4081
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4082
			iBandTop += height_increase;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4083
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4084
		
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4085
		// Fill in missing part of visible height.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4086
		while (iText->LayoutHeight() - iBandTop < visible_height)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4087
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4088
			if (!AddFormattingAtEndL(param, height_increase,paragraphs_increase))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4089
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4090
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4091
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4092
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4093
	// Scroll blank space off the display if desired.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4094
	if (aScrollBlankSpace == EFDisallowScrollingBlankSpace && iText->LayoutHeight() - iBandTop < visible_height)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4095
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4096
		int new_bandtop = iText->LayoutHeight() - visible_height;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4097
		if (new_bandtop < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4098
			new_bandtop = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4099
		pixels_scrolled += iBandTop - new_bandtop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4100
		iBandTop = new_bandtop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4101
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4102
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4103
	PruneFormatL(aDy < 0);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4104
	return pixels_scrolled + SetBandTop();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4105
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4106
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4107
TInt CTextLayout::ScrollDocPosIntoViewL(const TTmDocPos& aDocPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4108
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4109
	__ASSERT_DEBUG(aDocPos.iPos <= iText->Source()->DocumentLength(),
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4110
		Panic(EInvalidDocPos));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4111
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4112
	ExtendFormattingToCoverPosL(aDocPos.iPos);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4113
	if (!iText->DocPosToLine(aDocPos,info))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4114
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4115
		__ASSERT_DEBUG(iText->Source()->DocumentLength() == 0,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4116
			Panic(ECharacterNotFormatted));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4117
		return ScrollL(iBandTop, EFDisallowScrollingBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4118
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4119
	TRect line_rect = info.iOuterRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4120
	line_rect.Move(0,-iBandTop);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4121
	int visible_height = VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4122
	// if the line is taller than the screen, we must not scroll the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4123
	// baseline off the screen.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4124
	if (visible_height < info.iBaseline - info.iOuterRect.iTl.iY)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4125
		return ScrollL(iBandTop + visible_height - info.iBaseline,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4126
			EFDisallowScrollingBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4127
	if (line_rect.iTl.iY < 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4128
		return ScrollL(-line_rect.iTl.iY, EFDisallowScrollingBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4129
	if (line_rect.iBr.iY > visible_height)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4130
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4131
		int available = line_rect.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4132
		int desired = line_rect.iBr.iY - visible_height;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4133
		if (available > 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4134
			return ScrollL(-Min(desired,available), EFDisallowScrollingBlankSpace);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4135
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4136
	return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4137
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4138
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4139
EXPORT_C TInt CTextLayout::GetLineNumber(TInt aDocPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4140
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4141
	TTmLineInfo info;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4142
	TTmDocPos pos(aDocPos,TRUE);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4143
	if (iText->DocPosToLine(pos,info))	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4144
		return info.iLineNumber;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4145
	return 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4146
	};
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4147
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4148
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4149
/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4150
Prune the formatted band, if not formatting all the text, to the required size. If aFromStart is ETrue
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4151
prune from the start, otherwise prune from the end.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4152
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4153
void CTextLayout::PruneFormatL(TBool aFromStart)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4154
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4155
	if (IsFormattingBand())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4156
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4157
		int pixels_to_prune = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4158
		if (aFromStart)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4159
			pixels_to_prune = iBandTop;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4160
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4161
			pixels_to_prune = iText->LayoutHeight() - iBandTop - BandHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4162
		if (pixels_to_prune <= 0)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4163
			return;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4164
		TTmFormatParamBase param;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4165
		InitFormatParam(param);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4166
		int height_decrease = 0;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4167
		if(aFromStart)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4168
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4169
			while (pixels_to_prune > 0 && iText->DeletePar(param,aFromStart,pixels_to_prune,height_decrease))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4170
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4171
				pixels_to_prune -= height_decrease;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4172
				if (aFromStart)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4173
					iBandTop -= height_decrease;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4174
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4175
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4176
		else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4177
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4178
			if (pixels_to_prune > (iBandHeight/2))
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4179
				{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4180
				iText->DeleteFormattingFromEndL(param,pixels_to_prune,height_decrease);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4181
				}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4182
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4183
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4184
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4185
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4186
/** Sets the hotspot.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4187
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4188
@param aHotSpot Which part of the line (top, baseline or bottom) should appear
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4189
at a vertical pixel position. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4190
EXPORT_C void TViewYPosQualifier::SetHotSpot(TPartOfLine aHotSpot)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4191
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4192
	iHotSpot = aHotSpot;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4193
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4194
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4195
/** Sets whether blank space should be allowed at the bottom of the view. This
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4196
applies if the document is more than one page long and the last line is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4197
visible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4198
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4199
@param aFillScreen ETrue (the default) tries to fill the screen, by ensuring
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4200
that there is as little blank space as possible at the bottom of the view.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4201
EFalse allows blank space at the bottom. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4202
EXPORT_C void TViewYPosQualifier::SetFillScreen(TBool aFillScreen)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4203
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4204
	iFillScreen = aFillScreen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4205
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4206
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4207
/** Forces the top line in the view to become fully visible if it is partially
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4208
above the top of the view rectangle.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4209
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4210
@param aMakeLineFullyVisible EFViewForceLineFullyVisible (the default) forces
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4211
the top line to be fully visible EFViewDontForceLineFullyVisible does not. */
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4212
EXPORT_C void TViewYPosQualifier::SetMakeLineFullyVisible(TFullyVisible aMakeLineFullyVisible)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4213
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4214
	iFullyVisible = aMakeLineFullyVisible;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4215
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4216
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4217
void CTextLayout::InitFormatParam(TTmFormatParamBase& aParam)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4218
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4219
	aParam.iMaxHeight = BandHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4220
	iSource->iExcessHeightRequired = iExcessHeightRequired;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4221
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4222
	aParam.iFlags = TTmFormatParamBase::EAtLeastMaxHeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4223
	aParam.iWrapWidth = iSource->iWidth;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4224
	if (iSource->iFlags & TLayDocTextSource::EWrap)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4225
		aParam.iFlags |= TTmFormatParamBase::EWrap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4226
	if (iSource->iFlags & TLayDocTextSource::ETruncateWithEllipsis)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4227
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4228
		aParam.iFlags |= TTmFormatParamBase::ETruncateWithEllipsis;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4229
		aParam.iEllipsis = iSource->iEllipsis;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4230
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4231
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4232
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4233
TInt CTextLayout::VisibleHeightInPixels() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4234
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4235
	if (iSource->iFormatMode == CLayoutData::EFScreenMode || iSource->iFormatMode == CLayoutData::EFWysiwygMode)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4236
		return iVisibleHeight;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4237
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4238
		return iSource->InterpretDevice().VerticalTwipsToPixels(iVisibleHeight);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4239
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4240
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4241
TInt CTextLayout::BandHeightInPixels() const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4242
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4243
	if (iBandHeight == CLayoutData::EFHeightForFormattingAllText)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4244
		return CLayoutData::EFHeightForFormattingAllText;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4245
	else
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4246
		return VisibleHeightInPixels();
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4247
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4248
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4249
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4250
Sets offsets for the edges of the selection highlight.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4251
@param aLeftExtension
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4252
	Number of pixels to move the left edge of the highlight to the left.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4253
@param aRightExtension
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4254
	Number of pixels to move the right edge of the highlight to the right.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4255
@param aTopExtension
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4256
	Number of pixels to move the top edge of the highlight to up.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4257
@param aBottomExtension
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4258
	Number of pixels to move the bottom edge of the highlight down.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4259
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4260
EXPORT_C void CTextLayout::SetHighlightExtensions(TInt aLeftExtension,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4261
	TInt aRightExtension, TInt aTopExtension, TInt aBottomExtension)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4262
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4263
	iHighlightExtensions->SetLeftExtension(aLeftExtension);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4264
	iHighlightExtensions->SetRightExtension(aRightExtension);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4265
	iHighlightExtensions->SetTopExtension(aTopExtension);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4266
	iHighlightExtensions->SetBottomExtension(aBottomExtension);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4267
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4268
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4269
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4270
Set the delta required to position the baseline so there is enough
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4271
space for the highset glyph in pixels.  This is the height of the highest glyph - 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4272
CFont::AscentInPixels().  Only used when using TLineSpacingControl::EAttLineSpacingControl.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4273
By default zero.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4274
@param aExcessHeightRequired
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4275
	Extra height above CFont::AscentInPixels() required for the highest glyph in pixels.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4276
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4277
void CTextLayout::SetExcessHeightRequired(TInt aExcessHeightRequired) 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4278
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4279
	iExcessHeightRequired = aExcessHeightRequired;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4280
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4281
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4282
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4283
For any rectangle, aRect, which may be extended, calculate
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4284
the "remainder" rectanges when the view rectangle is intersected with the
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4285
extended rect and then subtracted.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4286
The remainder rectangles are returned via aRemainderRects, which is required
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4287
to be a pointer to an array of 4 TRect's.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4288
aRemainderRects[0] is top remainder, ...[1] is bottom, ...[2] is left, ...[3] is right
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4289
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4290
void CTextLayout::GetHighlightRemnants(const TRect& aRect, const TDrawTextLayoutContext& aDrawTextLayoutContext,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4291
									   TRect* aRemainderRects) const
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4292
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4293
	ASSERT(aRemainderRects);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4294
	/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4295
	overlap is the portion of the view rect that aRect intersects with
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4296
	subtract this from the aRect, giving 4 non-overlapping remainder rectangles,
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4297
	aRemainderRects, any or all of which may be empty. Copied from SubtractRect in TAGMA
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4298
	*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4299
	TRect overlap(aDrawTextLayoutContext.iViewRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4300
	overlap.Intersection(aRect);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4301
	if (overlap.IsEmpty())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4302
		overlap.SetRect(aRect.iTl,aRect.iTl);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4303
	aRemainderRects[0] = aRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4304
	aRemainderRects[0].iBr.iY = overlap.iTl.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4305
	aRemainderRects[1] = aRect;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4306
	aRemainderRects[1].iTl.iY = overlap.iBr.iY;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4307
	aRemainderRects[2] = overlap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4308
	aRemainderRects[2].iTl.iX = aRect.iTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4309
	aRemainderRects[2].iBr.iX = overlap.iTl.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4310
	aRemainderRects[3] = overlap;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4311
	aRemainderRects[3].iTl.iX = overlap.iBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4312
	aRemainderRects[3].iBr.iX = aRect.iBr.iX;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4313
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4314
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4315
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4316
Cleanup method for the opaque flag.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4317
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4318
void CTextLayout::ResetOpaque(void* aThis)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4319
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4320
	ASSERT(aThis != NULL);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4321
	CTextLayout* p = reinterpret_cast <CTextLayout*> (aThis);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4322
	p->iSource->iDrawOpaque = EFalse;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4323
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4324
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4325
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4326
Sets opaque drawing flag for CTextLayout object. It will used later when the 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4327
content/background has to be drawn.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4328
Until the flag is not reseted, the opaque drawing will be used 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4329
for all the content except the background - the flag has an useful meaning only for transparent
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4330
editors.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4331
A TCleanupItem object will be pushed into the Cleanup Stack, which will reset the opaque
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4332
flag durring its destruction.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4333
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4334
void CTextLayout::SetOpaqueLC()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4335
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4336
	iSource->iDrawOpaque = ETrue;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4337
	CleanupStack::PushL(TCleanupItem(&CTextLayout::ResetOpaque, this));
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4338
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4339
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4340
void FormPanic(TFormPanic aPanic)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4341
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4342
	_LIT(KFormPanic,"Form");
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4343
	User::Panic(KFormPanic,aPanic);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4344
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4345
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4346
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4347
Default implementation of mapping invisible character to its specified alternate.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4348
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4349
Called by TLayDocTextSource::Map() unless overidden by custom mapping class.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4350
May be called by custom mapping class
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4351
@param aChar
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4352
	Invisible character to be remapped
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4353
@param aNonPrintingCharVisibility
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4354
	Current state of flags showing visibility of invisible characters
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4355
@param aLayDoc
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4356
	Const ref to the calling CLayDocTextSource
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4357
@return
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4358
	The replacement character if remapping has taken place, else return original character
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4359
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4360
EXPORT_C TUint MFormCustomInvisibleCharacterRemapper::DefaultMapping( TUint aChar, const TNonPrintingCharVisibility aNonPrintingCharVisibility, const TLayDocTextSource& aLayDoc )
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4361
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4362
	// If mapping special characters is possible, use the specified flags.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4363
	if (!aNonPrintingCharVisibility.NoneVisible() && aLayDoc.CanMap())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4364
		{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4365
		switch (aChar)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4366
			{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4367
			case CEditableText::EParagraphDelimiter:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4368
				if (aNonPrintingCharVisibility.ParagraphDelimitersVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4369
					return KVisibleParagraphBreak;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4370
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4371
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4372
			case CEditableText::ELineBreak:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4373
				if (aNonPrintingCharVisibility.LineBreaksVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4374
					return KVisibleLineBreak;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4375
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4376
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4377
			case CEditableText::ENonBreakingSpace:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4378
				if (aNonPrintingCharVisibility.NonBreakingSpacesVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4379
					return KVisibleNonBreakSpace;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4380
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4381
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4382
			case CEditableText::EPotentialHyphen:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4383
				if (aNonPrintingCharVisibility.PotentialHyphensVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4384
					return KVisiblePotentialHyphen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4385
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4386
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4387
			case CEditableText::ENonBreakingHyphen:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4388
				if (aNonPrintingCharVisibility.NonBreakingHyphensVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4389
					return KVisibleNonBreakHyphen;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4390
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4391
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4392
			case CEditableText::ETabCharacter:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4393
				if (aNonPrintingCharVisibility.TabsVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4394
					return KVisibleTab;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4395
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4396
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4397
			case CEditableText::EPictureCharacter:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4398
				return KVisiblePicture;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4399
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4400
            case 0x200B:    // Zero Width Space: the same behaviour as 0x20, while different category from 0x20.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4401
                if (aNonPrintingCharVisibility.SpacesVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4402
                   return KVisibleSpace;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4403
                break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4404
                   
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4405
			/*
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4406
			For the moment, treat bidirectional controls as if they were non-break spaces, as far as visibility is
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4407
			concerned, and map as follows: LRE=<, RLE=>, PDF=currency symbol, LRO=left guillemet, RLO=right guillemet.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4408
			*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4409
			case 0x202A: // LRE
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4410
				if (aNonPrintingCharVisibility.NonBreakingSpacesVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4411
					return 0x003C;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4412
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4413
			case 0x202B: // RLE
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4414
				if (aNonPrintingCharVisibility.NonBreakingSpacesVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4415
					return 0x003E;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4416
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4417
			case 0x202C: // PDF
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4418
				if (aNonPrintingCharVisibility.NonBreakingSpacesVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4419
					return 0x00A4;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4420
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4421
			case 0x202D: // LRO
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4422
				if (aNonPrintingCharVisibility.NonBreakingSpacesVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4423
					return 0x00AB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4424
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4425
			case 0x202E: // RLO
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4426
				if (aNonPrintingCharVisibility.NonBreakingSpacesVisible())
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4427
					return 0x00BB;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4428
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4429
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4430
			default:
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4431
				if (aNonPrintingCharVisibility.SpacesVisible() && TChar(aChar).GetCategory() == TChar::EZsCategory)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4432
					return KVisibleSpace;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4433
				break;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4434
			}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4435
		}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4436
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4437
	// If not mapping special characters, or not mapping this particular character, use the default mapping.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4438
	return aLayDoc.MTmSource::Map(aChar);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4439
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4440
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4441
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4442
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4443
Allows Form clients to register an invisible character remapper object to 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4444
customize the visible display of invisible characters such as paragraph marks.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4445
@param aInvisibleCharacterRemapper
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4446
	Pointer to custom invisible character remapper to use
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4447
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4448
EXPORT_C void CTextLayout::SetCustomInvisibleCharacterRemapper( MFormCustomInvisibleCharacterRemapper* aInvisibleCharacterRemapper ) 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4449
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4450
	iSource->iInvisibleCharacterRemapper = aInvisibleCharacterRemapper;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4451
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4452
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4453
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4454
Allows Form clients to see which character remapper object is currently 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4455
registered.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4456
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4457
EXPORT_C MFormCustomInvisibleCharacterRemapper* CTextLayout::GetCustomInvisibleCharacterRemapper()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4458
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4459
	return iSource->iInvisibleCharacterRemapper;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4460
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4461
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4462
/** INC092568: CTextView::SetPendingSelection is not honoured
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4463
Sets the cursor position member added for this fix that allows the text layout object
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4464
to access any pending selection made by the owning text view object
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4465
@param aPos:- pointer to the owning textview's iCursorPos
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4466
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4467
void CTextLayout::SetTextViewCursorPos(TCursorPosition* aPos)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4468
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4469
	iTextViewCursorPos = aPos;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4470
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4471
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4472
/**
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4473
This is the function used by CTextLayout when it wants to extend the formatted range downwards. 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4474
It just calls CTmTextLayout::AddParL, but restricts the maximum height of the new formatting to the 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4475
band height/2. If the next paragraph is bigger than this, AddParL will only format part of that 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4476
paragraph, and the formatting will end in the middle of the paragraph.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4477
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4478
TBool CTextLayout::AddFormattingAtEndL(TTmFormatParamBase& aFormatParam, TInt& aHeightIncrease, TInt& aParagraphsIncrease)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4479
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4480
	aFormatParam.iMaxHeight = iBandHeight/2;
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4481
	return iText->AddParL(aFormatParam, EFalse, aHeightIncrease, aParagraphsIncrease);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4482
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4483
	
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4484
/** 
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4485
Stops or allows text to be drawn.  Included to allow users to control visibility
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4486
if text is part of an invisible control.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4487
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4488
@param aVisible		ETrue to make the text visible, EFalse to make it invisible.
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4489
@see CCoeControl::MakeVisible()
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4490
*/
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4491
EXPORT_C void CTextLayout::MakeVisible(TBool aVisible)
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4492
	{
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4493
	iText->MakeVisible(aVisible);
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4494
	}
8b9155204a54 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
  4495