hello everyone,
i was trying to understand the switching of the views. I created 2 views derived from CAknView and two controls from CcoeControl .compiles properly but does not executes.
when i debug them it debugs well before ActivateL() of CMyViewSwitchingContainer::ConstructL(const TRect& aRect). but terminates after that.
can anyone please help.
following is the list of the followng parts of the program.
MyViewSwitchingAppUi.cpp
the debugger takes me to these classes ..Code:/* ============================================================================ Name : MyViewSwitchingAppUi.cpp Author : Abhishek karmakar Copyright : copyright @ a.karmakar Description : CMyViewSwitchingAppUi implementation ============================================================================ */ // INCLUDE FILES #include <viewcli.h> #include <aknviewappui.h> #include <avkon.hrh> #include <aknmessagequerydialog.h> #include <aknnotewrappers.h> #include <stringloader.h> #include <f32file.h> #include <s32file.h> #include <hlplch.h> #include <MyViewSwitching_0xEB4DB8EB.rsg> #include "MyViewSwitching_0xEB4DB8EB.hlp.hrh" #include "MyViewSwitching.hrh" #include "MyViewSwitching.pan" #include "MyViewSwitchingApplication.h" #include "MyViewSwitchingAppUi.h" #include "MyViewSwitchingAppView.h" _LIT(KFileName, "C:\\private\\EB4DB8EB\\MyViewSwitching.txt"); _LIT(KText, "Messege text from A.karmakar"); // ============================ MEMBER FUNCTIONS =============================== void CMyViewSwitchingAppUi::ConstructL() { BaseConstructL(CAknAppUi::EAknEnableSkin); CEikStatusPane* sp = StatusPane(); iNaviPane = (CAknNavigationControlContainer*) sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)); iDecoratedTabGroup = iNaviPane->ResourceDecorator(); if (iDecoratedTabGroup) { iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl(); } // Initialise app UI with standard value. CMyViewSwitchingAppView* view1 = new(ELeave) CMyViewSwitchingAppView; CleanupStack::PushL(view1); view1->ConstructL(iTabGroup); AddViewL(view1); CleanupStack::Pop(view1); iViewId1 = view1->Id(); CMyViewSwitchingView2* view2 = new(ELeave) CMyViewSwitchingView2; CleanupStack::PushL(view2); view2->ConstructL(); AddViewL(view2); CleanupStack::Pop(view2); iViewId2 = view2->Id(); SetDefaultViewL( *view1); } CMyViewSwitchingAppUi::~CMyViewSwitchingAppUi() { delete iDecoratedTabGroup; } void CMyViewSwitchingAppUi::DynInitMenuPaneL(TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/) { } void CMyViewSwitchingAppUi::HandleCommandL(TInt aCommand) { switch (aCommand) { case EEikCmdExit: { Exit(); break; } // You can add your all application applying commands here. // You would handle here menu commands that are valid for all views. } } TKeyResponse CMyViewSwitchingAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode /*aType*/) { if ( iTabGroup == NULL ) { return EKeyWasNotConsumed; } TInt active = iTabGroup->ActiveTabIndex(); TInt count = iTabGroup->TabCount(); switch ( aKeyEvent.iCode ) { case EKeyLeftArrow: if ( active > 0 ) { active--; iTabGroup->SetActiveTabByIndex( active ); // ActivateLocalViewL() is used to change the view. // To change view from another application we would use ActivateViewL() // Send an empty message ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active))); } break; case EKeyRightArrow: if( (active + 1) < count ) { active++; iTabGroup->SetActiveTabByIndex( active ); // ActivateLocalViewL() is used to change the view. // To change view from another application we would use ActivateViewL() ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active))); } break; default: return EKeyWasNotConsumed; } return EKeyWasConsumed; } void CMyViewSwitchingAppUi::HandleForegroundEventL(TBool aForeground) { if (aForeground==TRUE) iEikonEnv->InfoMsg(_L("Foreground true")); else iEikonEnv->InfoMsg(_L("Foreground false")); } void CMyViewSwitchingAppUi::HandleResourceChangeL(TInt aType) { CAknAppUi::HandleResourceChangeL( aType ); // ADDED FOR SCALABLE UI SUPPORT // ***************************** if ( aType==KEikDynamicLayoutVariantSwitch ) { ((CMyViewSwitchingAppView*) View( iViewId1) )->HandleClientRectChange( ); ((CMyViewSwitchingView2*) View( iViewId2) )->HandleClientRectChange( ); } }
AND THE CONTAINERCode:/* ============================================================================ Name : MyViewSwitchingAppView.cpp Author : Abhishek karmakar Copyright : copyright @ a.karmakar Description : Application view implementation ============================================================================ */ #include "MyViewSwitchingView2.h" #include "MyViewSwitchingContainer.h" #include "MyViewSwitching.hrh" // INCLUDE FILES #include <aknviewappui.h> #include <avkon.hrh> #include <coemain.h> #include <aknview.h> #include "MyViewSwitchingAppView.h" #include <MyViewSwitching_0xEB4DB8EB.rsg> // ============================ MEMBER FUNCTIONS =============================== void CMyViewSwitchingAppView::ConstructL(CAknTabGroup* aTabGroup) { BaseConstructL(R_MYVIEW_VIEW1); //BaseConstructL(R_MYVIEW_VIEW1); iTabGroup = aTabGroup; } CMyViewSwitchingAppView::~CMyViewSwitchingAppView() { if (iContainer) { AppUi()->RemoveFromViewStack( *this, iContainer); } delete iContainer; } TUid CMyViewSwitchingAppView::Id() const { return KViewId; } void CMyViewSwitchingAppView::HandleCommandL(TInt aCommand) { switch (aCommand) { case EAknSoftkeyOk: { iEikonEnv->InfoMsg(_L("view 1 ok")); } break; case EAknSoftkeyExit: { AppUi()->HandleCommandL(EEikCmdExit); } break; case EMyViewCmdView1Cmd1: { } break; case EMyViewCmdView1Cmd2: { } break; case EMyViewCmdView1Cmd3: { } break; default: { } break; } } void CMyViewSwitchingAppView::HandleClientRectChange() { if (iContainer) { iContainer->SetRect(ClientRect()); } } void CMyViewSwitchingAppView::DoActivateL(const TVwsViewId& /*aPrevViewId*/,TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/) { if (!iContainer) { iContainer = new (ELeave) CMyViewSwitchingContainer; iContainer->SetMopParent(this); iContainer->ConstructL(ClientRect()); AppUi()->AddToStackL(*this, iContainer); } } void CMyViewSwitchingAppView::DoDeactivate() { if (iContainer) { AppUi()->RemoveFromViewStack(*this, iContainer); } delete iContainer; iContainer = NULL; }
Code:/* ============================================================================ Name : MyViewSwitchingContainer.cpp Author : Abhishek karmakar Version : 1.0 Copyright : copyright @ a.karmakar Description : CMyViewSwitchingContainer implementation ============================================================================ */ #include "MyViewSwitchingContainer.h" #include <eiklabel.h> void CMyViewSwitchingContainer::ConstructL(const TRect& aRect) { CreateWindowL(); iLabel = new (ELeave) CEikLabel; iLabel->SetContainerWindowL(*this); iLabel->SetTextL(_L("This is my View 1")); SetRect(aRect); ActivateL(); } CMyViewSwitchingContainer::~CMyViewSwitchingContainer() { delete iLabel; } //function from the base classes void CMyViewSwitchingContainer::SizeChanged() { iLabel->SetExtent(TPoint(10,10),iLabel->MinimumSize()); } TInt CMyViewSwitchingContainer::CountComponentControls() const { return 1; } CCoeControl* CMyViewSwitchingContainer::ComponentControls(int aIndex) const { switch(aIndex) { case 0: return iLabel; case 1: return NULL; } return NULL; } void CMyViewSwitchingContainer::Draw(const TRect& aRect) const { CWindowGc& gc = SystemGc(); gc.SetPenStyle(CGraphicsContext::ENullPen); gc.SetBrushColor(KRgbBlue); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.DrawRect(aRect); } void CMyViewSwitchingContainer::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) { }
please help..



