Problem in Multi view

Login to reply to this topic.
Thu, 2006-10-26 01:51
Joined: 2005-02-05
Forum posts: 22
I have some problem with setting list.
I try mix setting list from EMCC sample and multi view from default sample of SDK,
but i have problem. I can't jump from 1 item list to other. please help me
this my settinglist container code
--------------------------------------------------------------------------
/* Copyright (c) 2003, Nokia. All rights reserved */

#include <coemain.h>
#include <WAPServ.rsg>

#include "WAPServContainerSetting.h"
#include "WAPServSettingItemsList.h"

CWAPServContainerSetting* CWAPServContainerSetting::NewL(const TRect& aRect)
    {
    CWAPServContainerSetting* self = CWAPServContainerSetting::NewLC(aRect);
    CleanupStack::Pop(self);
    return self;
    }

CWAPServContainerSetting* CWAPServContainerSetting::NewLC(const TRect& aRect)
    {
    CWAPServContainerSetting* self = new (ELeave) CWAPServContainerSetting;
    CleanupStack::PushL(self);
    self->ConstructL(aRect);
    return self;
    }

void CWAPServContainerSetting::ConstructL(const TRect& aRect)
    {
    iSettingItemList = new CWAPServSettingItemsList(iSetting);
    iSettingItemList->SetMopParent(this);
    iSettingItemList->ConstructFromResourceL(R_WAPSERV_SETTING_ITEM_LIST);   
    SetRect(aRect);
    ActivateL();
    }
   
CWAPServContainerSetting::CWAPServContainerSetting()
    {
   // no implementation required
    }
   
CWAPServContainerSetting::~CWAPServContainerSetting()
    {   
    delete iSettingItemList;   
    }

TInt CWAPServContainerSetting::CountComponentControls() const
    {
    return 1;
    }

void CWAPServContainerSetting::Draw(const TRect& /*aRect*/) const
    {   
    // Get the standard graphics context
    CWindowGc& gc = SystemGc();
   
    // Gets the control's extent
    TRect rect = Rect();
   
    // Clears the screen
    gc.Clear(rect);
    }

CCoeControl* CWAPServContainerSetting::ComponentControl(TInt aIndex) const
   {
   switch (aIndex)
      {
      case 0:
         return iSettingItemList;
      default:
         return NULL;
      }
   }

TKeyResponse CWAPServContainerSetting::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
   {
   if (iSettingItemList)
      return iSettingItemList->OfferKeyEventL(aKeyEvent, aType);
   else
      return EKeyWasNotConsumed;
   }

void CWAPServContainerSetting::ChangeSelectedItemL()
   {
   if (iSettingItemList)
      iSettingItemList->ChangeSelectedItemL();
   }
---------------------------------------------------------------------------------
my setting list view code
--------------------------------------------------------------------------------
/* Copyright (c) 2003, Nokia. All rights reserved */

#include <aknviewappui.h>
#include <aknconsts.h>
#include <aknnotewrappers.h>
#include <WAPServ.rsg>

#include "WAPServViewSetting.h"
#include "WAPServContainerSetting.h"
#include "WAPServ.hrh"

CWAPServViewSetting* CWAPServViewSetting::NewL()
    {
    CWAPServViewSetting* self = CWAPServViewSetting::NewLC();
    CleanupStack::Pop(self);
    return self;
    }

CWAPServViewSetting* CWAPServViewSetting::NewLC()
    {
    CWAPServViewSetting* self = new (ELeave) CWAPServViewSetting();
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

CWAPServViewSetting::CWAPServViewSetting()
    {
    // No implementation required
    }

CWAPServViewSetting::~CWAPServViewSetting()
    {
    // No implementation required
    }

void CWAPServViewSetting::ConstructL()
    {
    BaseConstructL(R_WAPSERV_VIEW_SETTING);
    }


TUid CWAPServViewSetting::Id() const
    {
    return TUid::Uid(EWAPServViewSettingId);
    }

void CWAPServViewSetting::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
                                    TUid /*aCustomMessageId*/,
                                    const TDesC8& /*aCustomMessage*/)
    {
    ASSERT(!(iContainer));
    iContainer = CWAPServContainerSetting::NewL(ClientRect());
    }

void CWAPServViewSetting::DoDeactivate()
    {
    if (iContainer)
        {
        AppUi()->RemoveFromStack(iContainer);
        delete iContainer;
        iContainer = NULL;
        }
    }

void CWAPServViewSetting::HandleCommandL(TInt aCommand)
    {   
    if (aCommand == EMultiViewsCommand1)
        {
        _LIT(message,"Hello");
        CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
        informationNote->ExecuteLD(message);
        }
    else if (aCommand == /*EWAPServSwitchToViewApplication*/EAknSoftkeyBack)
        {
        AppUi()->ActivateLocalViewL(TUid::Uid(EWAPServViewApplicationId));
        }
    else if (aCommand == EWAPServCmdChange)
       {
       iContainer->ChangeSelectedItemL();
       }
    else
        {
        AppUi()->HandleCommandL(aCommand);
        }
    }
----------------------------------------------------------------------------------------
and my appui code
----------------------------------------------------------------------------------------
#include <e32std.h>
#include <avkon.hrh>
#include <aknnotewrappers.h>

#include "WAPServ.pan"
#include "WAPServAppUi.h"
#include "WAPServViewApplication.h"
#include "WAPServViewSetting.h"
#include "WAPServ.hrh"

// ConstructL is called by the application framework
void CWAPServAppUi::ConstructL()
    {
    BaseConstructL(EAknEnableSkin);

    iAppViewApplication = CWAPServViewApplication::NewL();
    iAppViewSetting = CWAPServViewSetting::NewL();

    AddViewL(iAppViewApplication); // Transfer ownership to base class
    AddViewL(iAppViewSetting); // Transfer ownership to base class

    SetDefaultViewL(*iAppViewApplication);
    }


// handle any menu commands
void CWAPServAppUi::HandleCommandL(TInt aCommand)
    {
    switch(aCommand)
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;
           
        //case EWAPServStartApplication:
            //_LIT(startMessage,"Start");
           //CAknInformationNote* startNote = new (ELeave) CAknInformationNote;
           //startNote->ExecuteLD(startMessage);
           //iAppViewApplication->StartApplicationL();
            //break;
       
        case EWAPServStopApplication:
            _LIT(stopMessage,"Stop");
           CAknInformationNote* stopNote = new (ELeave) CAknInformationNote;
           stopNote->ExecuteLD(stopMessage);
            break;       
           
        default:
            Panic(EWAPServBasicUi);
            break;
        }
    }

-----------------------------------------------------------------------------

Belajar symbian nggo masa depan.


Fri, 2006-11-03 03:04
Joined: 2005-02-05
Forum posts: 22
Re: Problem in Multi view
Ok thanks all. The proble has been solved. Ijust add  AppUi()->AddToStackL(*this, iContainer); for my appview

Belajar symbian nggo masa depan.

Fri, 2006-11-17 07:01
Joined: 2005-09-30
Forum posts: 3
Re: Problem in Multi view
I am using the multi-views architecture but have defined only one view.
The view has no containers as of now.

I am getting a Program closed error after the Exit command

the view doesnt get deleted in the destructor.

//the VIEW code is as follows

#include <aknviewappui.h>
#include <Editor.rsg>

#include "Editor.hrh"
#include "EditorAppView.h"

// Standard construction sequence
CEditorAppView* CEditorAppView::NewL()
    {
    CEditorAppView* self = CEditorAppView::NewLC();
    CleanupStack::Pop(self);
    return self;
    }

CEditorAppView* CEditorAppView::NewLC()
    {
    CEditorAppView* self = new (ELeave) CEditorAppView();
    CleanupStack::PushL(self);
    self->ConstructL();
    return self;
    }

CEditorAppView::CEditorAppView()
    {
    // No implementation required
    }

CEditorAppView::~CEditorAppView()
    {
   
       
   
    }

void CEditorAppView::ConstructL()
    {
    BaseConstructL(R_EDITOR_MAINVIEW);
    }


TUid CEditorAppView::Id() const
    {
    return TUid::Uid(EViewId);
    }

void CEditorAppView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
                                    TUid /*aCustomMessageId*/,
                                    const TDesC8& /*aCustomMessage*/)
    {
   
   
   
    }

void CEditorAppView::DoDeactivate()
    {
   
    }

void CEditorAppView::HandleCommandL(TInt aCommand)
    {
   
        AppUi()->HandleCommandL(aCommand);
       
    }
///////////////////////////////////////////////////////////

The AppUi code is as follows


#include <avkon.hrh>
#include <aknnotewrappers.h>

#include "Editor.pan"
#include "EditorAppUi.h"
#include "EditorAppView.h"
#include "Editor.hrh"

// ConstructL is called by the application framework
void CEditorAppUi::ConstructL()
    {
    BaseConstructL();
   
    iAppView = CEditorAppView::NewL();
    AddViewL(iAppView);
   
    SetDefaultViewL(*iAppView);
   
    }

CEditorAppUi::CEditorAppUi()                             
    {
   // no implementation required
    }

CEditorAppUi::~CEditorAppUi()
    {
    if (iAppView)
        {
        RemoveView(iAppView->Id());
        delete iAppView;
        iAppView = NULL;
        }
    }

// handle any menu commands
void CEditorAppUi::HandleCommandL(TInt aCommand)
    {
    switch(aCommand)
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
             Exit();
             break;

        case EEditorCmdSave:
            {
            _LIT(message,"Hello!");
            CAknInformationNote* informationNote = new (ELeave) CAknInformationNote;
            informationNote->ExecuteLD(message);
            }
            break;

        default:
            Panic(EEditorBasicUi);
            break;
        }
    }

Fri, 2006-11-17 07:30
Joined: 2005-09-30
Forum posts: 3
Re: Problem in Multi view
problem solved .. after clearing up the destructor of AppUi

but i dont understand why we arent supposed to delete the View object
  • Login to reply to this topic.