Symbian3/PDK/Source/GUID-DD15F24B-0786-4531-A6C5-A5E70EBE2732.dita
changeset 1 25a17d01db0c
child 3 46218c8b8afa
equal deleted inserted replaced
0:89d6a7a84779 1:25a17d01db0c
       
     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 id="GUID-DD15F24B-0786-4531-A6C5-A5E70EBE2732" xml:lang="en"><title>Layout
       
    13 change events</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>Layout change events are generated when the screen size or layout is
       
    15 changed. The Symbian platform supports multiple screen resolutions (<xref href="GUID-B02C762B-C452-4184-ABEA-4753E6CD47D2.dita">scalable UI</xref>). Thus,
       
    16 layout awareness is particularly crucial for those applications that implement
       
    17 a customized UI instead of using automatically scalable Avkon UI components.
       
    18 Applications can detect the changes in layout with, for example, the following
       
    19 methods:</p>
       
    20 <ul>
       
    21 <li><p>Controls can override the <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aHandleResourceChange%28TInt%29" format="application/java-archive"><parmname>CCoeControl::HandleResourceChange()</parmname></xref> to detect the <parmname>KEikDynamicLayoutVariantSwitch</parmname> message.</p>
       
    22 </li>
       
    23 <li><p>UI controllers can override the <xref href="jar:GUID-35228542-8C95-4849-A73F-2B4F082F0C44.jar!/sdk/doc_source/reference/reference-cpp/Control_Environment/CCoeControlClass.html#%3a%3aCCoeControl%3a%3aHandleResourceChange%28TInt%29" format="application/java-archive"><parmname>CCoeControl::HandleResourceChange()</parmname></xref> to detect the <parmname>KEikDynamicLayoutVariantSwitch</parmname> message. </p>
       
    24 </li>
       
    25 </ul>
       
    26 <p>The following example code demonstrates the implementation of <parmname>HandleResourceChange()</parmname>:</p>
       
    27 <codeblock id="GUID-8BF5353E-F09F-457A-826A-3F83ADEDF97E" xml:space="preserve">void CExampleControl::HandleResourceChange( TInt aType )
       
    28     {
       
    29     CCoeControl::HandleResourceChange(aType);
       
    30     //call base class implementation
       
    31     if( aType==KEikDynamicLayoutVariantSwitch )
       
    32         {
       
    33         TRect rect;
       
    34         // ask where container's rectangle should be
       
    35         // EMainPane equals to area returned by
       
    36         //CEikAppUi::ClientRect()
       
    37         AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,rect );
       
    38         SetRect( rect );
       
    39         }
       
    40     }
       
    41 </codeblock>
       
    42 <p>The following example code demonstrates the implementation of <parmname>HandleResourceChangeL()</parmname>:</p>
       
    43 <codeblock id="GUID-226A9867-C4C5-4286-B324-30EB17A4374D" xml:space="preserve">void CExampleAppUi::HandleResourceChangeL( TInt aType )
       
    44     {
       
    45     CAknAppUi::HandleResourceChangeL( aType );
       
    46     if( aType == KEikDynamicLayoutVariantSwitch )
       
    47         {
       
    48         // do the re-layout of the components
       
    49         }
       
    50     // Controls derived from CCoeControl, handled in a
       
    51     // container class
       
    52     iExampleControlContainer-&gt;HandleResourceChange( aType );
       
    53     //Must not call this if the components are on the control stack
       
    54     //iView-&gt;HandleResourceChangeL( aType );
       
    55     }
       
    56 </codeblock>
       
    57 <p>If <parmname>iExampleControlContainer</parmname> is added to the control
       
    58 stack, it will get its <parmname>HandleResourceChange()</parmname> called
       
    59 when a layout is switched and there is no need to call it explicitly. </p>
       
    60 <p>For a reference design of a layout-aware application using a custom
       
    61 UI, refer to the <i>S60 Platform: Scalable Screen-Drawing Example</i> available
       
    62 for download from <xref href="http://www.forum.nokia.com/info/sw.nokia.com/id/c5b4228b-992c-4636-8f48-753040760391/S60_Platform_Scalable_Screen_Drawing_Example_v1_3_en.zip.html" scope="external">Forum Nokia</xref>.</p>
       
    63 </conbody></concept>