Symbian3/SDK/Source/GUID-B32ED85A-913E-5C06-AEEB-1E2D6EF4CECF.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 13 48780e181b38
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<?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-B32ED85A-913E-5C06-AEEB-1E2D6EF4CECF"><title>Drawing a Rounded Rectangle</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>This topic provides an example that demonstrates how to draw a rounded rectangle using <codeph>DrawRoundRect()</codeph>. The dimensions of each corner (corner size and corner height) are given by a <codeph>TSize</codeph> argument. </p> <fig id="GUID-F54B5E46-9C2A-50DF-BAA9-222BD8EEF283"><title>
          Rounded rectangle construction 
        </title> <image href="GUID-2ED8BB5F-27CA-5DD3-BA0F-5773AE14A8CC_d0e207420_href.png" placement="inline"/></fig> <codeblock id="GUID-50D54618-4C7E-57D1-90BE-8A92CD5F4161" xml:space="preserve">...
// draw a rectangle with rounded corners, centered in the rectangle
TSize cornerSize(20,20); // set up the size of a rounded cornerSize
gc.DrawRoundRect(box,cornerSize);
...</codeblock> <p>In the following example code, one of the ellipses specified by the corner argument is shown, to illustrate how the rounded rectangle is constructed: </p> <codeblock id="GUID-ABF288C3-C830-5E44-B31A-6E4FCEE29A9E" xml:space="preserve">...
// draw a rectangle with rounded corners,
//centered in the rectangle, showing a corner ellipse
TSize cornerSize(20,20); // size of a rounded corner
    
// rect for corner ellipse is twice the corner size
TSize cornerEllipseSize(cornerSize.iHeight*2,cornerSize.iWidth*2);
TRect cornerRectTl(box.iTl,cornerEllipseSize);
gc.DrawRoundRect(box,cornerSize);
gc.SetPenStyle(CGraphicsContext::EDottedPen);
gc.DrawEllipse(cornerRectTl); // corner construction ellipse
...</codeblock> </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>