skin on CAknDialog

Login to reply to this topic.
Sun, 2006-05-14 07:43
Joined: 2003-10-21
Forum posts: 40
Hi everybody,

I search and searched but couldn't find an answer to my problem. Maybe you can.
In my application i'm using a simple dialog as my main screen. My problem is that I can't show the skin on the background of the main pane. Instead, I have the default white BG. I saw that simple dialog is not skin-aware but form, lists and more are skin-aware. I've managed to display the BG bacground on my forms using BaseConstruct(EAknEnableSkin) in my UI class.
I guess I can use AknsUtils but I don't know where to put the code. Also, please note that I'm not using controls. I just you my CAknDialog-derived class.

I'll appreciate any help
Imzadi

Sun, 2006-05-14 07:45
Joined: 2003-10-21
Forum posts: 40
Re: skin on CAknDialog
I forgot to mention that I read eric's article regarding skins but I strill couldn't adapt it to dialogs.

imzadi
Wed, 2006-08-02 12:12
Joined: 2006-04-24
Forum posts: 5
Re: skin on CAknDialog
For a dialog...u would have some CCoeControl derived control filling up the view
Suppose u have a CEikEdwin control filling the entire dialog
This should work

void CMyEditorDialog::PreLayoutDynInitL()
    {
    iEditor = STATIC_CAST(CMyEdwin*, Control(EIdMyEdwin));
    TRect rect(iEikonEnv->EikAppUi()->ClientRect());
    iEditor->SetRect(rect);
    }


SEikControlInfo CMyEditorDialog::CreateCustomControlL(TInt aControlType)
    {
    CCoeControl *control = NULL;
    SEikControlInfo info = {control,0,0};
Wed, 2006-08-02 12:34
Joined: 2006-04-24
Forum posts: 5
Re: skin on CAknDialog
For a dialog...u would have some CCoeControl derived control filling up the dialog's view
Suppose u have a CEikEdwin control filling the entire dialog
This should work

//MyEditorDialog.cpp
...
void CMyEditorDialog::PreLayoutDynInitL()
   {
   iEditor = STATIC_CAST(CMyEdwin*, Control(EIdMyEdwin));
   TRect rect(iEikonEnv->EikAppUi()->ClientRect());
   iEditor->SetRect(rect);
   }

SEikControlInfo CMyEditorDialog::CreateCustomControlL(TInt aControlType)
   {
   CCoeControl *control = NULL;
   SEikControlInfo info = {control,0,0};
   if(aControlType == EIdMyEdwin)
      {
       info.iControl = new(ELeave) CMyEdwin(this);
           break;
        ((CMyEdwin*)info.iControl)
               ->SetSkinBackgroundControlContextL(NULL);
       }
     }

CMyEditorDialog::ActivateL()
 {
  ...
  iEditor->InitEditor();
 }
....

//MyEdwin.h
...
CAknsBasicBackgroundControlContext* iSkinContext;
CEikDialog* iParent;
TRect iBackgroundRect;
...

//MyEdwin.cpp
...
CMyEdwin::CMyEdwin(CEikDialog* aParent)
:iParent(aParent)
  {
  }

CMyEdwin::InitEditor()
 {
  ...
  iBackgroundRect = iParent->Rect();
  if(!iSkinContext)
      {
                iSkinContext = CAknsBasicBackgroundControlContext::NewL(KAknsIIDQsnBgAreaMain,iBackgroundRect,EFalse);
      }
 ...
 }

TBool CMyEdwin::SupplyMopObject(TTypeUid aId,TTypeUid::Ptr& ptr)
   {
   if(aId.iUid == MAknsControlContext::ETypeId)
      {
      ptr = MAknsControlContext::
                                      SupplyMopObject(aId, iSkinContext);
      return ETrue;
      }
   return EFalse;
   }

void CMyEdwin::Draw(const TRect& aRect) const  
 {
 CWindowGc& gc = SystemGc();
 TRect tempMainPane;
 AknLayoutUtils::LayoutMetricsRect
             (AknLayoutUtils::EMainPane,tempMainPane);
 TRect mainPane(TPoint(0, 0), tempMainPane.Size());
 if(iSkinContext)
   {
   iSkinContext->SetRect(iParent->Rect());
   SetSkinBackgroundControlContextL
                              (iSkinContext);
   AknsDrawUtils::Background( AknsUtils::SkinInstance(),
            iSkinContext, this, gc, mainPane);   
   }
 }            
  • Login to reply to this topic.