|
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-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> |
|
13 Rounded rectangle construction |
|
14 </title> <image href="GUID-2ED8BB5F-27CA-5DD3-BA0F-5773AE14A8CC_d0e236519_href.png" placement="inline"/></fig> <codeblock id="GUID-50D54618-4C7E-57D1-90BE-8A92CD5F4161" xml:space="preserve">... |
|
15 // draw a rectangle with rounded corners, centered in the rectangle |
|
16 TSize cornerSize(20,20); // set up the size of a rounded cornerSize |
|
17 gc.DrawRoundRect(box,cornerSize); |
|
18 ...</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">... |
|
19 // draw a rectangle with rounded corners, |
|
20 //centered in the rectangle, showing a corner ellipse |
|
21 TSize cornerSize(20,20); // size of a rounded corner |
|
22 |
|
23 // rect for corner ellipse is twice the corner size |
|
24 TSize cornerEllipseSize(cornerSize.iHeight*2,cornerSize.iWidth*2); |
|
25 TRect cornerRectTl(box.iTl,cornerEllipseSize); |
|
26 gc.DrawRoundRect(box,cornerSize); |
|
27 gc.SetPenStyle(CGraphicsContext::EDottedPen); |
|
28 gc.DrawEllipse(cornerRectTl); // corner construction ellipse |
|
29 ...</codeblock> </conbody><related-links><link href="GUID-55C8C429-1BEC-5A58-94EC-DA1E51F62867.dita"><linktext>Drawing |
|
30 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> |