os/textandloc/textrendering/word/SRC/WPOUTLNE.H
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description: 
    15 *
    16 */
    17 
    18 
    19 #if !defined(__WPOUTLNE_H__)
    20 #define __WPOUTLNE_H__
    21 
    22 
    23 #if !defined(__EIKHLBM_H__)
    24 #include <techview/eikhlbm.h>
    25 #endif
    26 #if !defined(__EIKHLBX_H__)
    27 #include <techview/eikhlbx.h>
    28 #endif
    29 #if !defined(__EIKHLBI_H__)
    30 #include <techview/eikhlbi.h>
    31 #endif
    32 #if !defined(__EIKHLBV_H__)
    33 #include <techview/eikhlbv.h>
    34 #endif
    35 #if !defined(__TXTRICH_H__)
    36 #include <txtrich.h>
    37 #endif
    38 #if !defined(__TXTFMLYR_H__)
    39 #include <txtfmlyr.h>
    40 #endif
    41 #if !defined(__BARSREAD_H__)
    42 #include <barsread.h>
    43 #endif
    44 
    45 
    46 class CRichText;
    47 class COutlineHListBox;	
    48 class COutlineHListBoxView;
    49 class TResourceReader;
    50 
    51 /**
    52 @internalComponent
    53 */
    54 const TInt KErrNoOutline=-50;
    55 
    56 
    57 class TOutlineEntry
    58 /**
    59 TOutlineEntry
    60 An entry in the Outline Table - used to store info for each paragraph in the document
    61 which has an outline level 
    62 @internalComponent
    63 */
    64 {
    65 public:
    66 	TOutlineEntry(TInt aParagraphNo, TInt aOutlineLevel, TInt aParaLen, TInt aParaPos, TBool aChild, TBool aLast);
    67 	TOutlineEntry();
    68 public:
    69 	TInt iParagraphNo;		// The pargagraph number for this entry
    70 	TInt iOutlineLevel;		// The outline level for this paragraph
    71 	TInt iParagraphLength;	// No. of chars in this paragraph
    72 	TInt iParagraphPos;		// Char position of start of paragraph
    73 	TBool iIsChild;			// Is this a child of the previous paragraph
    74 	TBool iLastEntry;		// Is this the last entry at this level
    75 };
    76 
    77 
    78 
    79 class TOutlineMap
    80 /**
    81 TOutlineMap
    82 An entry in the Outline Map Table - maps an index into the Outline Table to 
    83 an entry in the hierarchical list box
    84 @internalComponent
    85 */
    86 {
    87 public:
    88 	TOutlineMap(TInt aIndex, CHierListItem* aPtr);
    89 public:
    90 	TInt iIndex;			// Index reference
    91 	CHierListItem*	iPtr;	// Pointer to a list item
    92 };
    93 
    94 /**
    95 @internalComponent
    96 */
    97 typedef CArrayFixFlat<TOutlineEntry> COutlineTable;
    98 typedef CArrayFixFlat<TOutlineMap> COutlineMapTable;
    99 
   100 
   101 class COutlineMap : public CBase
   102 /**
   103 COutlineMap
   104 Contains an array of TOutlineMap objects, with functions to bind entries
   105 together.
   106 @internalComponent
   107 */
   108 {
   109 public:
   110 static COutlineMap* NewL();
   111 	~COutlineMap();
   112 	void BindL(TInt aIndex, CHierListItem* aPtr);	// Bind a list item with the paragraph index
   113 	TInt Index(CHierListItem* aPtr);				// Given a pointer, return the index
   114 	CHierListItem* Ptr(TInt aIndex);				// Given an index, return the pointer
   115 	TBool IndexPresent(TInt aIndex);				// Has this index been added yet?
   116 private:
   117 	void ConstructL();
   118 private:
   119 	COutlineMapTable* iOutlineMapTable;
   120 };
   121 
   122 
   123 
   124 class COutlineHListBoxModel : public CHierarchicalListBoxModel
   125 /**
   126 COutlineHListBoxModel
   127 This is the list box model which defines the behaviour of an outline list box
   128 @internalComponent
   129 */
   130 {
   131 public:
   132 	static COutlineHListBoxModel* NewL(COutlineHListBox* aParent,CRichText* aText);
   133 	~COutlineHListBoxModel();
   134 	void CreateRootListL();
   135 	void ExpandItemL(TInt aItemIndex);
   136 	TInt ExpandCurrentPositionL(TInt aCursorPos);
   137 	TInt CurrentCharPosition();
   138 	TInt GetItemByParagraph(TInt aPara);
   139 private:
   140 	void ConstructL();
   141 	void CreateEntryTableL();
   142 	void ScanHeading(TDes& aText);
   143 	TInt ExpandParagraphL(TInt aPara);
   144 public:
   145 	COutlineTable* iOutlineTable;	// Table of outline levels in the document
   146 	COutlineMap*	iOutlineMap;	// Table to map between the outline table and the listbox items
   147 private:
   148 	CRichText* iText;
   149 	TInt iCursorPos;
   150 	COutlineHListBox* iParent;
   151 };
   152 
   153 
   154 
   155 class COutlineHListBox : public CEikHierarchicalListBox
   156 /**
   157 COutlineHListBox
   158 Parent control - owns the model and view of the listbox
   159 @internalComponent
   160 */
   161 {
   162 public:
   163 	COutlineHListBox(CRichText* aText, TInt aCursorPos);
   164 	void ConstructL();
   165 	void ConstructFromResourceL(TResourceReader& aReader);
   166 	COutlineHListBoxModel* OutlineModel() const;
   167 	TSize MinimumSize();
   168 	CListBoxView* MakeViewClassInstanceL();
   169 	COutlineHListBoxView* HlView() const;
   170 	TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
   171 	void ExpandAllItemsL();
   172 	void CollapseAllItemsL();
   173 private:
   174 	CRichText* iText;
   175 	TInt iCursorPos;
   176 };
   177 
   178 
   179 class COutlineHListItemDrawer : public CHierarchicalListItemDrawer
   180 /**
   181 COutlineHListItemDrawer
   182 Contains bitmap information about each drawer in the list box
   183 @internalComponent
   184 */
   185 	{
   186 public:
   187 	COutlineHListItemDrawer(COutlineHListBoxModel* aModel, const CFont* aFont, CArrayPtrFlat<CGulIcon>* aIcons);
   188 
   189 protected: // from CHierarchicalListItemDrawer
   190 	CGulIcon* ItemIcon(TInt aItemIndex) const;
   191 	};
   192 
   193 
   194 class COutlineHListBoxView : public CHierarchicalListBoxView
   195 /**
   196 Overriden functions from CHierarchicalListBoxView
   197 @internalComponent
   198 */
   199 {
   200 public:
   201 	void DrawItem(TInt aItemIndex) const;
   202 	void DrawItemLinks(TInt aItemIndex, TInt aParagraphLevel) const;
   203 	TSize ItemSize(TInt aItemIndex, TInt aParagraphLevel) const;
   204 	TPoint ItemPos(TInt aItemIndex, TInt aParagraphLevel) const;
   205 	void ClearPreceedingItemRect(TInt aItemIndex, TInt aParagraphLevel) const;
   206 private:
   207 	TInt GetParagraphLevel(CHierListItem* aItem) const;
   208 
   209 };
   210 
   211 
   212 // Inline functions
   213 
   214 inline COutlineHListBoxModel* COutlineHListBox::OutlineModel() const { return (COutlineHListBoxModel*)iModel; }
   215 
   216 
   217 
   218 #endif
   219