Symbian3/SDK/Source/GUID-96E46D0E-1CE3-58B4-AE99-6B2E622ADAF9.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?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 id="GUID-6CF38BB1-2366-4086-856D-B1C0F65B6913"><title>Description</title> <p>This example application demonstrates how to implement the following: </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 background and a foreground window using the <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita"><apiname>RWindow</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-2C194479-3F1C-32BA-A17B-0A4DB1F23F04"><apiname>RWindow::Invalidate(const
TRect &amp;)</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-0AEE5955-C530-35F1-A904-69183331B294.dita#GUID-0AEE5955-C530-35F1-A904-69183331B294/GUID-65C8A51B-DE23-370A-AE9F-1354E7DFD679"><apiname>CWindowGc::Activate(RDrawableWindow
&amp;)</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-47275C08-0C58-3A03-B96F-38F881F49C08"><apiname>RWindow::SetTransparencyAlphaChannel()</apiname></xref>: this function enables the use of an alpha channel to vary a window's
transparency. The alpha value can be varied from 0 (fully transparent)
to 255 (fully opaque). </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-BED44E59-A6A3-3302-8E11-487F005A3AB2"><apiname>RWindow::SetTransparentRegion(const
TRegion&amp;)</apiname></xref>: this function restricts the transparency
to a specified region of the window. </p> </li>
</ul> <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 by
the pointer device. An appropriate message is displayed when a <i>click</i> event is detected. </p> </section>
<section id="GUID-0EBE02D4-1591-49ED-9B75-2383E8420E58"><title>Build</title> <p><xref href="GUID-3100800B-B2F7-50EF-BD4C-3C345ECCB2A5.dita">The Symbian
build process</xref> describes how to build this example. </p> <p>The <codeph>Transparent</codeph> example 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 id="GUID-45BFAED8-FC21-423F-BA86-0C6A2D6BD010"><title>Running
the example</title> <p>The example 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 each half the size of the background window are used to demonstrate
the change in transparency . These windows can be identified by their
labels. </p> </li>
</ul> <p>1. Press the <userinput>VaryTransparency</userinput> button
located at the bottom of the window to vary the first foreground window's
transparency. The alpha value varies gradually from 0 to 255. This
demonstrates calling the <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-47275C08-0C58-3A03-B96F-38F881F49C08"><apiname>RWindow::SetTransparencyAlphaChannel()</apiname></xref> API. </p> <p>2. Press the <userinput>SetTransparent</userinput> button
to call <xref href="GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79.dita#GUID-683603DD-F3D3-3193-BEB3-8236C7DE7F79/GUID-BED44E59-A6A3-3302-8E11-487F005A3AB2"><apiname>RWindow::SetTransparentRegion(const TRegion&amp;)</apiname></xref> on the bottom half of the second foreground window. This makes that
half of the window transparent while the upper half stays opaque.</p> <p>3. Click different mouse buttons to display the various popup
messages </p> </section>
<section id="GUID-98B1DE6E-91E4-4C1C-89A1-727DF95C9903"><title>Related
information</title><ul>
<li><p><xref href="GUID-02BD38E7-A579-5BD5-9444-4E7C14C7809A.dita">Transparent
Windows</xref></p></li>
</ul></section>
</conbody></concept>