Namespaces
Variants
Actions

Handling scalability in Symbian C++ on touch enabled device

Jump to: navigation, search
Article Metadata

Tested with
Devices(s): Nokia 5800 XpressMusic

Compatibility
Platform(s): S60 5th Edition

Article
Keywords: CAknAppUi::HandleResourceChangeL(), CCoeControl::HandleResourceChange()
Created: tepaa (03 Oct 2008)
Last edited: hamishwillee (14 Jun 2012)

Contents

Overview

S60 5th Edition supports touch events. All AVKON UI controls handle touch UI events and you do not need to implement anything new.

If you implement your own custom CCoeControl UI control, it is important to handle its scalability. If scalability is not handled, the S60 platform may not receive touch events, or it may receive touch events for the incorrect control because the correct location of the touch event may not be known.


MMP file

The following libraries are required:

LIBRARY cone.lib


Handle resoucre change

Custom CCoeControl-derived classes must be able to react to changes in UI layout.

void CMyControl::HandleResourceChange(TInt aType)
{
// Call base class implementation
CCoeControl::HandleResourceChange(aType);
if ( aType==KEikDynamicLayoutVariantSwitch )
{
// Setting new rect for this control
TRect rect;
AknLayoutUtils::LayoutMetricsRect(
AknLayoutUtils::EMainPane,rect);
// SetRect() causes calling components SizeChanged()
SetRect(rect);
}
}

Handle scalability in your application CAknAppUi class:

void CMyAppUi::HandleResourceChangeL(TInt aType)
{
// Call base class implementation
CAknAppUi::HandleResourceChangeL( aType );
if ( aType == KEikDynamicLayoutVariantSwitch )
{
// Do the re-layout of the components
// TODO: do some layout impl here if needed
}
 
// NOTE: Must not call this if the components are on the control stack
// iMyView->HandleResourceChangeL( aType );
 
// NOTE: If CMyControl is in control stack is
// CMyControl::HandleResourceChange() called automatically
}


Adding controls into control stack

If a control is in the control stack, it will receive key events and resource change events.

In traditional Symbian C++ applications, when CMyAppUi is derived from CAknAppUi:

void CMyAppUi::ConstructL ( )
{
// Initialise app UI with standard value.
BaseConstructL (EAknEnableSkin | EAknTouchCompatible);
 
// Create view
iAppView = CMobilePaintAppView::NewL (ClientRect ( ) );
 
// --> Add view into control stack
AddToStackL( iAppView );
}

When using view switching CMyAppUi is derived from CAknViewAppUi. The control is added into the control stack when the view is activated.

void CMyView::DoActivateL(const TVwsViewId& aPrevViewId,
TUid aCustomMessageId, const TDesC8& aCustomMessage)
{
if (!iContainer)
{
iContainer = CMyControl::NewL(ClientRect());
 
// --> Add view into control stack
AppUi()->AddToStackL (*this, iContainer);
}
}


Postconditions

Scalability of the control is handled.


See also

S60 Platform: Image Converter Example

This page was last modified on 14 June 2012, at 05:09.
92 page views in the last 30 days.
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved