Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

(Difference between revisions)

Drawing skins in container

From Wiki
Jump to: navigation, search
nadav70 (Talk | contribs)
(SkinnedContainer.cpp)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - metadata, code example, featured article or Qwidget UI fixes)
 
(5 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[Category:Code_Examples]]
+
{{ArticleMetaData <!-- v1.1 -->
[[Category:Symbian C++]][[Category:Customization]][[Category:Themes]]
+
|sourcecode= <!-- Link to example source code e.g. [[Media:The Code Example ZIP.zip]] -->
 
+
|installfile= <!-- Link to installation file (e.g. [[Media:The Installation File.sis]]) -->
 +
|devices= <!-- Devices tested against - e.g. ''devices=Nokia 6131 NFC, Nokia C7-00'') -->
 +
|sdk= <!-- SDK(s) built and tested against (e.g. [http://linktosdkdownload/ Nokia Qt SDK 1.1]) -->
 +
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later -->
 +
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 +
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
 +
|signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer -->
 +
|capabilities= <!-- Capabilities required by the article/code example (e.g. Location, NetworkServices. -->
 +
|keywords= <!-- APIs, classes and methods (e.g. QSystemScreenSaver, QList, CBase -->
 +
|id= <!-- Article Id (Knowledge base articles only) -->
 +
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 +
|translated-by= <!-- [[User:XXXX]] -->
 +
|translated-from-title= <!-- Title only -->
 +
|translated-from-id= <!-- Id of translated revision -->
 +
|review-by= <!-- After re-review: [[User:username]] -->
 +
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 +
|update-by= <!-- After significant update: [[User:username]]-->
 +
|update-timestamp= <!-- After significant update: YYYYMMDD -->
 +
|creationdate= 20070320
 +
|author= [[User:Symbianyucca]]
 +
}}
 +
[[Category:Symbian C++]]
 
The '''CSkinnedContainer''' implementation illustrates how to draw skins in a '''CCoeControl''' derived container in the [[S60]] platform.  
 
The '''CSkinnedContainer''' implementation illustrates how to draw skins in a '''CCoeControl''' derived container in the [[S60]] platform.  
  
Line 7: Line 28:
  
 
Note that for the skins to work properly you need to enable skins first. Usually this is done in Application user interface class' ''ConstructL()'' method by calling the ''ConstructL()'' method with '''CAknAppUi::EAknEnableSkin''' parameter.
 
Note that for the skins to work properly you need to enable skins first. Usually this is done in Application user interface class' ''ConstructL()'' method by calling the ''ConstructL()'' method with '''CAknAppUi::EAknEnableSkin''' parameter.
 +
 +
'''Library required:'''
 +
<code cpp>
 +
//CAknsBasicBackgroundControlContext , MAknsSkinInstance
 +
LIBRARY  aknskins.lib aknskinsrv.lib aknswallpaperutils.lib
 +
</code>
  
 
== SkinnedContainer.cpp ==
 
== SkinnedContainer.cpp ==
Line 18: Line 45:
  
 
CSkinnedContainer* CSkinnedContainer::NewL(void)
 
CSkinnedContainer* CSkinnedContainer::NewL(void)
    {
+
{
 
     CSkinnedContainer* self = new(ELeave)CSkinnedContainer();
 
     CSkinnedContainer* self = new(ELeave)CSkinnedContainer();
 
     CleanupStack::PushL(self);
 
     CleanupStack::PushL(self);
Line 24: Line 51:
 
     CleanupStack::Pop(self);
 
     CleanupStack::Pop(self);
 
     return self;
 
     return self;
    }
+
}
  
 
void CSkinnedContainer::ConstructL(void)
 
void CSkinnedContainer::ConstructL(void)
    {
+
  {
 
     CreateWindowL();
 
     CreateWindowL();
  
Line 84: Line 111:
 
CWindowGc& gc = SystemGc();
 
CWindowGc& gc = SystemGc();
 
      
 
      
    // draw background skin first.
+
// draw background skin first.
 
   MAknsSkinInstance* skin = AknsUtils::SkinInstance();
 
   MAknsSkinInstance* skin = AknsUtils::SkinInstance();
 
AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect );
 
AknsDrawUtils::Background( skin, iBgContext, this, gc, aRect );
Line 98: Line 125:
 
#include <aknscontrolcontext.h>
 
#include <aknscontrolcontext.h>
 
#include <AknsSkinInstance.h>
 
#include <AknsSkinInstance.h>
#include <aknsutils.h>
+
#include <aknutils.h>
  
  
Line 111: Line 138:
 
virtual void SizeChanged();
 
virtual void SizeChanged();
 
virtual void HandleResourceChange(TInt aType);
 
virtual void HandleResourceChange(TInt aType);
    void ConstructL(void);
+
void ConstructL(void);
 
void Draw(const TRect& aRect) const;
 
void Draw(const TRect& aRect) const;
 
private:
 
private:
 
CAknsBasicBackgroundControlContext* iBgContext;  
 
CAknsBasicBackgroundControlContext* iBgContext;  
 
};
 
};
</code>
+
</code>[[Category:Code Snippet]][[Category:Customization]][[Category:Themes]]

Latest revision as of 06:39, 11 January 2012

Article Metadata
Article
Created: symbianyucca (20 Mar 2007)
Last edited: hamishwillee (11 Jan 2012)

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

The iBgContext is the CAknsBasicBackgroundControlContext which is used to draw the skin on the control's background. To draw on a different screen area you could change KAknsIIDQsnBgScreen identify to the background you would like to use with your container.

Note that for the skins to work properly you need to enable skins first. Usually this is done in Application user interface class' ConstructL() method by calling the ConstructL() method with CAknAppUi::EAknEnableSkin parameter.

Library required:

//CAknsBasicBackgroundControlContext , MAknsSkinInstance
LIBRARY aknskins.lib aknskinsrv.lib aknswallpaperutils.lib

[edit] 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 );
}

[edit] SkinnedContainer.h

#include <coecntrl.h>       // CCoeControl
#include <AknsBasicBackgroundControlContext.h>
#include <aknsdrawutils.h>
#include <aknscontrolcontext.h>
#include <AknsSkinInstance.h>
#include <aknutils.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;
};
This page was last modified on 11 January 2012, at 06:39.
128 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.

×