Problem with UI when It chagnes from Landscape to Potrait.

Login to reply to this topic.
Sat, 2008-03-29 22:26
Joined: 2007-10-09
Forum posts: 25

Hi,
I Was just Doing some Ui Designign Basics,I tried the simple Ui application Hello Wolrd.When I switched from Potrait
To Landscape,the Ui got Distorted.I have changed the View File,in the Following way.Do I need to make any Changes
more as I have not found the desired result.Thanks in Advance

//
Cviewchange1AppView* Cviewchange1AppView::NewL( void )
{
Cviewchange1AppView* self = new ( ELeave ) Cviewchange1AppView();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}

// -----------------------------------------------------------------------------
// Cviewchange1AppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void Cviewchange1AppView::ConstructL( void )
{
CreateWindowL();

// make first with no size at all
iBgContext = CAknsBasicBackgroundControlContext::NewL(
KAknsIIDQsnBgScreen,TRect(0,0,1,1), ETrue);
// Setting rect will cause SizeChanged to be called
// and iBgContext size & position is updated accordingly.
SetRect( CEikonEnv::Static()->EikAppUi()->ClientRect() );

ActivateL();
DrawNow();

}

// -----------------------------------------------------------------------------
// Cviewchange1AppView::Cviewchange1AppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
Cviewchange1AppView::Cviewchange1AppView()
{
// No implementation required
}

// -----------------------------------------------------------------------------
// Cviewchange1AppView::~Cviewchange1AppView()
// Destructor.
// -----------------------------------------------------------------------------
//
Cviewchange1AppView::~Cviewchange1AppView()
{
// No implementation required
delete iBgContext;
iBgContext = NULL;

}

void Cviewchange1AppView::HandleResourceChange(TInt aType)
{
TRect rect;

if ( aType== KEikDynamicLayoutVariantSwitch )
{
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
SetRect(rect);
}
}


TTypeUid::Ptr Cviewchange1AppView::MopSupplyObject(TTypeUid aId)
{
if (iBgContext)
{
return MAknsControlContext::SupplyMopObject(aId, iBgContext );
}

}
// -----------------------------------------------------------------------------
// Cviewchange1AppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void Cviewchange1AppView::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();

// draw background skin first.
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect );

}

// -----------------------------------------------------------------------------
// Cviewchange1AppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void Cviewchange1AppView::SizeChanged()
{

if ( iBgContext )
{
iBgContext->SetRect(Rect());

if ( &Window() )
{
iBgContext->SetParentPos( PositionRelativeToScreen() );
}

  • Login to reply to this topic.