×
Namespaces

Variants
Actions
(Difference between revisions)

Drawing skins in container

From Nokia Developer Wiki
Jump to: navigation, search
symbianyucca (Talk | contribs)
(New page: Category:Symbian C++ The CSkinnedContainer implementation illustrates how to draw skins in CCoeControl derived container within S60 platform. The iBgContext is the CAknsBasicBackgro...)
 
symbianyucca (Talk | contribs)
Line 1: Line 1:
 +
[[Category:Code_Examples]]
 
[[Category:Symbian C++]]
 
[[Category:Symbian C++]]
  

Revision as of 04:27, 20 March 2007


The CSkinnedContainer implementation illustrates how to draw skins in CCoeControl derived container within S60 platform.

The iBgContext is the CAknsBasicBackgroundControlContext which is used to draw the skin into the controls background. To draw different screen area you could change KAknsIIDQsnBgScreen identify the background you would like to use with your container.

Note that for skins to work properly you need to enable skins first, usually this is done in Application user interface classes ConstructL function, by calling the ConstructL function with CAknAppUi::EAknEnableSkin as a parameter.

SkinnedContainer.cpp

CSkinnedContainer::~CSkinnedContainer()
{
delete iBgContext;
iBgContext = NULL;
}
 
CSkinnedContainer* CSkinnedContainer::NewL(void)
{
CSkinnedContainer* self = new(ELeave)CSkinnedContainer();
CleanupStack::PushL(self);
self->ConstructL();
CleanupStack::Pop(self);
return self;
}
 
void CSkinnedContainer::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();
}
 
void CSkinnedContainer::SizeChanged()
{
if ( iBgContext )
{
iBgContext->SetRect(Rect());
 
if ( &Window() )
{
iBgContext->SetParentPos( PositionRelativeToScreen() );
}
}
}
 
 
void CSkinnedContainer::HandleResourceChange(TInt aType)
{
TRect rect;
 
if ( aType==KEikDynamicLayoutVariantSwitch )
{
AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
SetRect(rect);
}
 
CCoeControl::HandleResourceChange(aType);
}
 
 
TTypeUid::Ptr CSkinnedContainer::MopSupplyObject(TTypeUid aId)
{
if (iBgContext)
{
return MAknsControlContext::SupplyMopObject(aId, iBgContext );
}
 
return CCoeControl::MopSupplyObject(aId);
}
 
 
void CSkinnedContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
 
// draw background skin first.
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect );
}

SkinnedContainer.h

#include <coecntrl.h>       // CCoeControl
#include <AknsBasicBackgroundControlContext.h>
#include <aknsdrawutils.h>
#include <aknscontrolcontext.h>
#include <AknsSkinInstance.h>
#include <aknsutils.h>
 
 
class CSkinnedContainer : public CCoeControl
{
public:
static CSkinnedContainer* NewL(void);
~CSkinnedContainer();
protected:
TTypeUid::Ptr MopSupplyObject(TTypeUid aId); //
private:
virtual void SizeChanged();
virtual void HandleResourceChange(TInt aType);
void ConstructL(void);
void Draw(const TRect& aRect) const;
private:
CAknsBasicBackgroundControlContext* iBgContext;
};
202 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×