You Are Here:

Community: Wiki

This page was last modified on 18 June 2009, at 12:07.

CS001438 - Listening for screen orientation changes

From Forum Nokia Wiki


ID CS001438 Creation date June 18, 2009
Platform S60 3rd Edition, S60 5th Edition Tested on devices Nokia N95
Category Symbian C++ Subcategory Code Examples


Keywords (APIs, classes, methods, functions): CAknAppUi::HandleResourceChangeL(), CCoeControl::HandleResourceChange()

Overview

Layout and screen orientation change events are generated when the screen size or layout is changed. The S60 platform supports multiple screen resolutions. Handling this event can be implemented into application CAknAppUi class or application CCoeControl UI controls.


Source

Solution 1: UI control derived from CCoeControl can handle layout changes overriding the CCoeControl::HandleResourceChange() method

void CExampleControl::HandleResourceChange(TInt aType)
{
// Call base class implementation
CCoeControl::HandleResourceChange(aType);
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);
// Set new screen rect
SetRect(rect);
}
}

Solution 2: Application UI class derived from CAknAppUi can override CEikAppUi::HandleResourceChangeL() to get the KEikDynamicLayoutVariantSwitch layout change event.

void CExampleAppUi::HandleResourceChangeL(TInt aType)
{
// Call base class implementation
CAknAppUi::HandleResourceChangeL( aType );
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);
 
// Set new screen rect
// Must not call this if the iExampleControlContainer
// component is on the control stack
iExampleControlContainer->SetRect(rect);
}
 
// Must not call this if the iSomeDialog
// component is on the control stack
//iSomeDialog->HandleResourceChangeL( aType );
}


See also

TSS001178 - Switching orientation in dialog-based applications


Postconditions

A layout change event is received and the new layout size is read.

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fE25E455E25A6E2582E25E454E25BE44E2595E25E455E259CE25A8E25E456E2594E25B6E25E454E25BBE25B6E25E457E25AE45E25B1E25E455E2588E259BE25E455E25BBE25BAE25E457E259FE25AE44E25E454E25BFE25A1X qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtopicQUqfnTopicZseriesE5f60Q qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qfnZuserE5ftagQSxs60X qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ