Symbian3/SDK/Source/GUID-55165C57-0F32-5363-A2EC-E37B5B36B6E1.dita
changeset 7 51a74ef9ed63
parent 0 89d6a7a84779
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept xml:lang="en" id="GUID-55165C57-0F32-5363-A2EC-E37B5B36B6E1"><title>How to set up the text view</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The following code constructs a text view, first allocating and constructing all its parameters.</p> <ul><li id="GUID-22D4A0CA-4DEC-59DD-8883-1DC6EA59B23A"><p>Before constructing the <xref href="GUID-CF377A98-F11F-380F-AD10-7F3E261D4421.dita"><apiname>CTextView</apiname></xref>  <keyword>text view</keyword> object, first construct a <xref href="GUID-101762DC-E498-3325-88AB-B0FF17DC62B6.dita"><apiname>TRect</apiname></xref>  <keyword>view rectangle</keyword>, then the <xref href="GUID-FEE7C848-2E93-3848-A3DA-7EAA533615AF.dita"><apiname>CTextLayout</apiname></xref> <keyword>layout object</keyword> to be used by the view. </p> <p>Call the <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-DEF7DBC5-5EBA-3A63-8A77-12F308CBF95E"><apiname>CCoeControl::Rect()</apiname></xref> function to construct the view rectangle.</p> </li> <li id="GUID-FE25259A-49E3-5105-AC0A-A3E0CB175303"><p>The following must also be provided:</p> <ul><li id="GUID-CC291486-D789-5188-806D-9F09A9B4637B"><p>A graphics device map for mapping between the physical co-ordinates of the screen or page being drawn to (measured in twips) and the device specific co-ordinates (measured in pixels). Use the <xref href="GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160.dita#GUID-B06F99BD-F032-3B87-AB26-5DD6EBE8C160/GUID-6586DB74-AF5C-330B-9D0A-E4637396A04E"><apiname>CCoeControl::SystemGc()</apiname></xref> function to get the graphics context </p> </li> <li id="GUID-E2CB4365-4805-5231-9372-16A7F3A14621"><p>a window group for the text view. If a window group is not provided, no cursors can be displayed in the document.</p> </li> </ul> </li> </ul> <p>The <keyword>view rectangle</keyword> is the rectangle in which all text, cursors and labels will be displayed. It resides within the <keyword>view window</keyword> and can be smaller than it.</p> <codeblock id="GUID-E2F50CD6-E170-5410-97C6-911A8C9ED10A" xml:space="preserve">TRect iViewRect; // rectangle in which to view text
       
    13 CTextLayout* iLayout; // text layout
       
    14 CTextView* iTextView; // text view
       
    15 CRichText* iRichText; // rich text document
       
    16 // prerequisites for view - viewing rectangle
       
    17 iViewRect=Rect(); // Construct view rectangle
       
    18 // layout
       
    19 iLayout=CTextLayout::NewL(iRichText,iViewRect.Width()); 
       
    20         // construct layout, giving width of view rectangle
       
    21 // context and device
       
    22 CWindowGc&amp; gc=SystemGc(); // get graphics context
       
    23 CBitmapDevice* device=(CBitmapDevice*) (gc.Device()); // device
       
    24 // text view
       
    25 iTextView=CTextView::NewL(iLayout, iViewRect,
       
    26         device,
       
    27         device,
       
    28         &amp;Window(),
       
    29         &amp;iCoeEnv-&gt;RootWin(), // window group, needed for cursor
       
    30         &amp;iCoeEnv-&gt;WsSession()
       
    31         ); // new view</codeblock> </conbody></concept>