Symbian3/PDK/Source/GUID-BD463EF4-2538-51AF-8946-BFEC902A2DD0.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 11 Mar 2010 18:02:22 +0000
changeset 3 46218c8b8afa
parent 1 25a17d01db0c
child 5 f345bda72bc4
permissions -rw-r--r--
week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE concept
  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
<concept xml:lang="en" id="GUID-BD463EF4-2538-51AF-8946-BFEC902A2DD0"><title>Drawing Lines</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This topic provides examples that demonstrate how to draw lines of different widths and styles. </p> <p>The examples assume common start and end points have been defined as follows: </p> <codeblock id="GUID-28F12668-9CDD-5AD4-9EE7-32B01DBBE583" xml:space="preserve">...
// set up a pair of points for drawing diagonal lines
TPoint startPoint(50,50);
TPoint endPoint(590,190);
...</codeblock> <section><title>Drawing a line a single pixel wide</title> <p>You can draw a thin line diagonally across the screen using <codeph>DrawLine()</codeph>. This illustrates how thin a single pixel width line is, and the visible stepping: </p> <codeblock id="GUID-40B3F1CC-567F-59AD-8A8A-B286D3AD95E5" xml:space="preserve">...
// draw a thin line from top left to bottom right 
gc.DrawLine(startPoint,endPoint);
...</codeblock> <p> <b>Note</b>: The line width is a single pixel by default. </p> </section> <section><title>Drawing a line three pixels wide</title> <ol id="GUID-4E0BACED-4D3E-51B9-92FE-569DC594A4BD"><li id="GUID-B3E6B674-5F50-5E53-9ED9-F9C01430363B"><p>Use <codeph>SetPenSize()</codeph> to increase the pen size to three pixels. </p> </li> <li id="GUID-07130AED-6D1C-54B3-81CC-30DA3402FC82"><p>Use <codeph>DrawLine()</codeph> to draw a wide line diagonally across the screen. </p> </li> </ol> <codeblock id="GUID-65E94B19-C30D-5C5A-99E3-BFFEA68B2A9D" xml:space="preserve">// Set up a "bold" size for the pen tip to (default is 1,1)
TSize penSizeBold(3,3);
...
// draw a line from top left to bottom right 
gc.SetPenSize(penSizeBold);
gc.DrawLine(startPoint,endPoint);
...</codeblock> </section> <section><title>Drawing a line thirty pixels wide</title> <ol id="GUID-CD9DD7A1-D62F-5B31-A6EB-3739800317C9"><li id="GUID-7492D2DB-7F32-55F0-8760-AAF1FD85A9BD"><p>Use <codeph>SetPenWidth()</codeph> to set the pen width to thirty pixels wide. </p> </li> <li id="GUID-C24B8085-30DD-584F-A5D6-BD024E5C1215"><p>Use <codeph>DrawLine()</codeph> to draw a thirty pixel wide line, (x dimension), diagonally across the screen. </p> </li> </ol> <codeblock id="GUID-587C939D-359D-5618-946D-1A0C5286D0E0" xml:space="preserve">// Set up a "fat" size for the pen tip
TSize penSizeFat(30,30);
...
// draw a rather wide line from top left to bottom right,
// illustrating rounded ends and their clipping
gc.SetPenWidth(penSizeFat);
gc.DrawLine(startPoint,endPoint);
...</codeblock> <p><b>Notes </b> </p> <ul><li id="GUID-9C1799DF-A1B3-5047-B23E-0AC340EBB607"><p>The ends of wide lines are rounded. </p> </li> <li id="GUID-5888D165-DD1E-5E41-81B5-ADFDF0ED9FF2"><p>The effective width of the line depends on the size of the pen tip, which is elliptical. </p> </li> <li id="GUID-1396D6C5-4F90-56E2-923F-94C4EDC7B170"><p>The rounded end of a wide line may be clipped to the window, even though the end point is within the window. </p> </li> </ul> </section> <section><title>Drawing a dotted line</title> <ol id="GUID-3524D696-5ABC-5E06-910B-26EACA1E2A5E"><li id="GUID-3B6DB02F-BAD2-5EB2-B7EC-9056D737C727"><p>Use <codeph>SetPenStyle()</codeph> to set the style of the pen to dotted. </p> </li> <li id="GUID-3866320E-CEC6-5444-A629-888ABE6B8E4F"><p>Use <codeph>DrawLine()</codeph> to draw a thin dotted line diagonally across the screen. </p> </li> </ol> <codeblock id="GUID-D2785C65-6614-5A2D-8405-295D7C39F96D" xml:space="preserve">...
// draw a dotted line from top left to bottom right 
gc.SetPenStyle(CGraphicsContext::EDottedPen);
gc.DrawLine(startPoint,endPoint);
...</codeblock> <p> <b>Note</b>: The pen style remains in effect until changed by another call to <codeph>SetPenStyle()</codeph> or the graphics context is reset to its default settings. </p> </section> <section><title>Drawing a dot-dashed line</title> <ol id="GUID-92BB412D-E3A3-5D18-A806-EAE6BD960043"><li id="GUID-8F2FEDB5-067E-586D-8531-4761CEBFC1B0"><p>Use <codeph>SetPenStyle()</codeph> to set the style of the pen to dot-dashed. </p> </li> <li id="GUID-252ED7E4-9A04-5D7B-8D0B-9F0869BCC959"><p>Use <codeph>DrawLine()</codeph> to draw a thin dot-dashed line diagonally across the screen. </p> </li> </ol> <codeblock id="GUID-3FDE1DE2-64BD-5312-AA84-A36CE362E655" xml:space="preserve">...
// draw a dot dash line from top left to bottom right 
gc.SetPenStyle(CGraphicsContext::EDotDashPen);
gc.DrawLine(startPoint,endPoint);
...</codeblock> </section> </conbody><related-links><link href="GUID-55C8C429-1BEC-5A58-94EC-DA1E51F62867.dita"><linktext>Drawing
                to a Graphics Context Tutorials</linktext> </link> <link href="GUID-E3AC8F3E-9D5C-5E7D-9760-023B77C7C8A8.dita"><linktext>Drawing and Graphics Contexts</linktext> </link> </related-links></concept>