Symbian3/PDK/Source/GUID-96E46D0E-1CE3-58B4-AE99-6B2E622ADAF9.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 id="GUID-96E46D0E-1CE3-58B4-AE99-6B2E622ADAF9" xml:lang="en"><title>Transparent:
Drawing Transparent Windows</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<section id="GUID-51F2B6AB-A086-58C5-A08C-117666483C98"><title>Download</title> <p>Click
on the following link to download the example: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/zips/guid-30acccf3-7e22-4243-91ea-48f857e9a053.zip" scope="external">Transparent.zip</xref></p><p>Click: <xref href="guid-6013a680-57f9-415b-8851-c4fa63356636/guid-30acccf3-7e22-4243-91ea-48f857e9a053.html" scope="peer">browse</xref> to view the example code. </p> </section>
<section><title>Description</title> <p>This example application demonstrates
how to implement the following window server features using the <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-9337538E-7A53-3153-A330-968B5E4F2FF2"><apiname>RWindow::BeginRedraw()</apiname></xref> and <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-3DE16607-AD3B-3946-BEB3-88512EAAB9CE"><apiname>RWindow::EndRedraw()</apiname></xref> functions: </p> <ul>
<li id="GUID-C4C7ECAB-D57F-5E74-93A2-B64C477FA8D8"><p>creating transparent,
non-transparent and blank windows, </p> </li>
<li id="GUID-EBE379F4-5F98-50ED-8B9C-9311B1CF534D"><p>changing the transparency
of a window, </p> </li>
<li id="GUID-5A9447AD-598F-5463-9C35-D051628DA7E5"><p>drawing content on a
window. </p> </li>
</ul> <p><b>Creating transparent windows</b> </p> <p>This example creates
a blank window on which a background and a foreground window are drawn. The
blank window is constructed using the <xref href="GUID-A5DFCFA7-7B2D-3872-B6D0-4526DF743630.dita"><apiname>RBlankWindow</apiname></xref> class.
The <xref href="GUID-3CECC9FC-58C1-3117-AAF2-FDF88341F56F.dita"><apiname>CPeriodic</apiname></xref> class triggers periodic redraws on the window.
The following functions are used to re-draw content on the window: </p> <ul>
<li id="GUID-C511264A-1FC4-5BD2-854B-B3739D2E3E79"><p> <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-28202F81-52FE-30F5-8B8C-ABED0915822E"><apiname>RWindow::Invalidate()</apiname></xref>  </p> </li>
<li id="GUID-8ECB575C-F838-5993-AEC1-AC2277CAE069"><p> <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-9337538E-7A53-3153-A330-968B5E4F2FF2"><apiname>RWindow::BeginRedraw()</apiname></xref>  </p> </li>
<li id="GUID-AC222F59-26B4-5BA0-9949-B750F551C4D6"><p> <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-3DE16607-AD3B-3946-BEB3-88512EAAB9CE"><apiname>RWindow::EndRedraw()</apiname></xref>  </p> </li>
<li id="GUID-603B5C7D-EA52-5EEA-A057-D49D55F70835"><p> <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-E6C34115-B257-392D-A619-202C600065E6"><apiname>RWindow::Activate()</apiname></xref>  </p> </li>
</ul> <p>The transparency of the foreground window is changed using the following
functions: </p> <ul>
<li id="GUID-018046D6-FA87-5616-986B-223D40A82227"><p> <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-F1BDA5B0-5F6A-3066-B5D9-9833FC79FA25"><apiname>RWindow::SetTransparencyFactor()</apiname></xref>:
the transparency factor of the foreground window is incremented from 0 to
255 (transparent to opaque) using this function. </p> </li>
<li id="GUID-4537F6DA-1880-5351-A194-079C4ECDE81D"><p> <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-111FEE92-09C0-3E8F-81B5-F4584231AC1D"><apiname>RWindow::SetTransparentRegion()</apiname></xref>  </p> </li>
</ul> <p><b>Related APIs</b></p><p><xref href="GUID-3CECC9FC-58C1-3117-AAF2-FDF88341F56F.dita"><apiname>CPeriodic</apiname></xref></p><p><xref href="GUID-A5DFCFA7-7B2D-3872-B6D0-4526DF743630.dita"><apiname>RBlankWindow</apiname></xref></p><p><xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-E6C34115-B257-392D-A619-202C600065E6"><apiname>RWindow::Activate()</apiname></xref></p><p><xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-3DE16607-AD3B-3946-BEB3-88512EAAB9CE"><apiname>RWindow::EndRedraw()</apiname></xref></p><p><xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-28202F81-52FE-30F5-8B8C-ABED0915822E"><apiname>RWindow::Invalidate()</apiname></xref></p><p><xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-F1BDA5B0-5F6A-3066-B5D9-9833FC79FA25"><apiname>RWindow::SetTransparencyFactor()</apiname></xref></p><p><xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-111FEE92-09C0-3E8F-81B5-F4584231AC1D"><apiname>RWindow::SetTransparentRegion()</apiname></xref></p><p><b>Handling
window server events</b> </p> <p>The user-defined class <codeph>CEventHandler</codeph> handles
pointer events when transparent areas of the window are clicked on by the
pointer device. An appropriate message is displayed when a <i>click</i> event
is detected. </p><p><b>Related APIs</b></p><p><xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-9337538E-7A53-3153-A330-968B5E4F2FF2"><apiname>RWindow::BeginRedraw()</apiname></xref></p><p><xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-3DE16607-AD3B-3946-BEB3-88512EAAB9CE"><apiname>RWindow::EndRedraw()</apiname></xref></p> </section>
<section><title>Build</title> <p><xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">The
Symbian OS build process</xref> describes how to build this example. </p> <p>The <codeph>Transparent</codeph> builds
an executable called <filepath>transparent.exe</filepath> in the standard
location (<filepath>\epoc32\release\winscw\&lt;build_variant&gt;</filepath> for
Carbide.c++). </p> </section>
<section><title>Running the example</title> <p>The examples creates three
windows: </p> <ul>
<li id="GUID-A8AD34F4-034C-5359-861E-25807691B7A5"><p>One background window
with height equal to the full emulator screen and width of half the emulator
screen. The "Background Window" label is set for this window. </p> </li>
<li id="GUID-DF6E6F57-0057-5D2D-BB93-80D7AB077DF4"><p>Two foreground windows
half the size of the background window that are used for the two buttons respectively.
They can be identified by the labels set for the respective windows. </p> </li>
</ul> <p>1. Press the <userinput>Vary Transparency</userinput> button on the
toolbar located at the right hand side of the window to vary the foreground
window's transparency. The transparency varies gradually from 0 to 255. This
use case demonstrates the <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-F1BDA5B0-5F6A-3066-B5D9-9833FC79FA25"><apiname>RWindow::SetTransparencyFactor()</apiname></xref> API. </p> <p>2.
Press the <userinput>Set Transparent Region</userinput> button to set the
user-defined transparent region in the foreground window. <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-111FEE92-09C0-3E8F-81B5-F4584231AC1D"><apiname>RWindow::SetTransparentRegion()</apiname></xref> is
called for the bottom half of the foreground window which ensures that the
bottom half remains transparent and the remaining window can have opaque pixels.</p> <p>3.
Click different mouse buttons to display the respective popup messages </p> </section>
</conbody></concept>