sl@0: /* sl@0: * Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: sl@0: sl@0: #ifndef __BANDMAINTAINER_H sl@0: #define __BANDMAINTAINER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: /** sl@0: @file sl@0: @internalComponent sl@0: */ sl@0: class CRichText; sl@0: class CRichControl; sl@0: class CTextView; sl@0: sl@0: /** sl@0: This class is responsible for maintaining two CTextView/CTextLayout objects. sl@0: It also provides a simplified version of the CTextView interface for handling sl@0: inserts, deletes and format changes. sl@0: The two CTextView/CTextLayout objects that are maintained are: sl@0: 1) iViewUnderTest is the view/layout we are testing sl@0: 2) iViewReference is the view/layout we testing against sl@0: The test view iViewUnderTest has band formatting enabled and is compared to the sl@0: reference view iViewReference which does not have band formatting enabled. The reference sl@0: view formats all of its document again from scratch each time a change is made so that it sl@0: does not invoke any of the reformmating code being tested by the test view. sl@0: */ sl@0: class CBandMaintainer : public CBase sl@0: { sl@0: public: sl@0: IMPORT_C static CBandMaintainer* NewLC(CRichText& aRichText, TRect aDrawRect, TBool aDisplayTextBox); sl@0: IMPORT_C ~CBandMaintainer(); sl@0: /** sl@0: Scroll the test display (negative = downwards) sl@0: @param aPixels The number of pixels to scroll; may be a positive or negative value. On return, contains sl@0: the number of pixels actually scrolled. Positive values move the text down, negative move it up. sl@0: */ sl@0: IMPORT_C void ScrollDisplayPixelsL(TInt& aPixels); sl@0: /** sl@0: Update the view after a change to the document sl@0: */ sl@0: IMPORT_C void InitialiseViewL(); sl@0: /** sl@0: Scroll both views in the direction and amount specified by the TCursorPosition::TMovementType parameter sl@0: @param aMovement The direction and manner in which to scroll. On return set to the actual cursor movement. sl@0: @return ETrue if the resulting scroll gave the same results for both test and reference views, EFalse otherwise. sl@0: */ sl@0: IMPORT_C TBool ScrollL(TCursorPosition::TMovementType& aMovement); sl@0: /** sl@0: Causes the view objects to be reformatted after a change to the text or paragraph formatting sl@0: The reference view formats the whole document again using CTextView::FormatTextL, so the test view sl@0: can be tested against a view which does not invoke the reformatting logic at all sl@0: @param aSelection The start and new length of the changed block. sl@0: */ sl@0: IMPORT_C void HandleFormatChangeL(TCursorSelection aSelection); sl@0: /** sl@0: Reformats and redraws both views after a global change has been made to the layout. sl@0: */ sl@0: IMPORT_C void HandleGlobalChangeL(); sl@0: /** sl@0: Reformats and redraws both views after a deleting a block of text. sl@0: The reference view formats the whole document again using CTextView::FormatTextL, so the test view sl@0: can be tested against a view which does not invoke the reformatting logic at all. sl@0: @param aStartPos The start position of the delete to be performed sl@0: @param aDeletedChars The amount of characters to be deleted sl@0: */ sl@0: IMPORT_C void HandleDeleteL(TInt aStartPos, TInt aDeletedChars); sl@0: /** sl@0: Reformats and redraws both views after a inserting a block of text. sl@0: The reference view formats the whole document again using CTextView::FormatTextL, so the test view sl@0: can be tested against a view which does not invoke the reformatting logic at all. sl@0: @param aSelection The start and new length of the changed block. sl@0: */ sl@0: IMPORT_C void HandleInsertL(TCursorSelection aSelection); sl@0: //some accessors sl@0: IMPORT_C CTextView& ViewUnderTest() const; sl@0: IMPORT_C CTextView& ViewReference() const; sl@0: IMPORT_C const CTextLayout& LayoutUnderTest() const; sl@0: IMPORT_C const CTextLayout& LayoutReference() const; sl@0: IMPORT_C const CTmTextLayout& TmLayoutUnderTest() const; sl@0: IMPORT_C const CTmTextLayout& TmLayoutReference() const; sl@0: private: sl@0: CBandMaintainer(); sl@0: void ConstructL(CRichText& aRichText, TRect aDrawRect, TBool aDisplayTextBox); sl@0: sl@0: CRichControl* iReferenceControl; sl@0: CRichControl* iTestControl; sl@0: //does not own these 2 sl@0: CTextView* iViewUnderTest; // view/layout we are testing sl@0: CTextView* iViewReference; // view/layout we testing against sl@0: }; sl@0: sl@0: #endif