Layout change events

Layout change events are generated when the screen size or layout is changed. The Symbian platform supports multiple screen resolutions (scalable UI). Thus, layout awareness is particularly crucial for those applications that implement a customized UI instead of using automatically scalable AVKON UI components. Applications can detect the changes in layout with, for example, the following methods:

The following example code demonstrates the implementation of HandleResourceChange():

void CExampleControl::HandleResourceChange( TInt aType )
    {
    CCoeControl::HandleResourceChange(aType);
    //call base class implementation
    if( aType==KEikDynamicLayoutVariantSwitch )
        {
        TRect rect;
        // ask where container's rectangle should be
        // EMainPane equals to area returned by
        //CEikAppUi::ClientRect()
        AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,rect );
        SetRect( rect );
        }
    }

The following example code demonstrates the implementation of HandleResourceChangeL():

void CExampleAppUi::HandleResourceChangeL( TInt aType )
    {
    CAknAppUi::HandleResourceChangeL( aType );
    if( aType == KEikDynamicLayoutVariantSwitch )
        {
        // do the re-layout of the components
        }
    // Controls derived from CCoeControl, handled in a
    // container class
    iExampleControlContainer->HandleResourceChange( aType );
    //Must not call this if the components are on the control stack
    //iView->HandleResourceChangeL( aType );
    }

If iExampleControlContainer is added to the control stack, it will get its HandleResourceChange() called when a layout is switched and there is no need to call it explicitly.