/*
========================================================================
Name : DocumentExampleContainerView.cpp
Author : liut
Copyright : neusoft
Description :
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <aknviewappui.h>
#include <eikmenub.h>
#include <avkon.hrh>
#include <akncontext.h>
#include <akntitle.h>
#include <stringloader.h>
#include <barsread.h>
#include <eikbtgpc.h>
#include <DocumentExample.rsg>
#include <aknnotewrappers.h>
// ]]] end generated region [Generated System Includes]
// [[[ begin generated region: do not modify [Generated User Includes]
#include "DocumentExample.hrh"
#include "DocumentExampleContainerView.h"
#include "DocumentExampleContainer.h"
#include "DocumentExampleDocument.h"
// ]]] end generated region [Generated User Includes]
// [[[ begin generated region: do not modify [Generated Constants]
// ]]] end generated region [Generated Constants]
/**
* First phase of Symbian two-phase construction. Should not contain any
* code that could leave.
*/
CDocumentExampleContainerView::CDocumentExampleContainerView()
{
// [[[ begin generated region: do not modify [Generated Contents]
iDocumentExampleContainer = NULL;
// ]]] end generated region [Generated Contents]
}
/**
* The view's destructor removes the container from the control
* stack and destroys it.
*/
CDocumentExampleContainerView::~CDocumentExampleContainerView()
{
// [[[ begin generated region: do not modify [Generated Contents]
delete iDocumentExampleContainer;
iDocumentExampleContainer = NULL;
// ]]] end generated region [Generated Contents]
}
/**
* Symbian two-phase constructor.
* This creates an instance then calls the second-phase constructor
* without leaving the instance on the cleanup stack.
* @return new instance of CDocumentExampleContainerView
*/
CDocumentExampleContainerView* CDocumentExampleContainerView::NewL()
{
CDocumentExampleContainerView* self =
CDocumentExampleContainerView::NewLC();
CleanupStack::Pop(self);
return self;
}
/**
* Symbian two-phase constructor.
* This creates an instance, pushes it on the cleanup stack,
* then calls the second-phase constructor.
* @return new instance of CDocumentExampleContainerView
*/
CDocumentExampleContainerView* CDocumentExampleContainerView::NewLC()
{
CDocumentExampleContainerView* self = new ( ELeave ) CDocumentExampleContainerView();
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
/**
* Second-phase constructor for view.
* Initialize contents from resource.
*/
void CDocumentExampleContainerView::ConstructL()
{
// [[[ begin generated region: do not modify [Generated Code]
BaseConstructL( R_DOCUMENT_EXAMPLE_CONTAINER_DOCUMENT_EXAMPLE_CONTAINER_VIEW);
// ]]] end generated region [Generated Code]
// add your own initialization code here
}
/**
* @return The UID for this view
*/
TUid CDocumentExampleContainerView::Id() const
{
return TUid::Uid(EDocumentExampleContainerViewId);
}
/**
* Handle a command for this view (override)
* @param aCommand command id to be handled
*/
void CDocumentExampleContainerView::HandleCommandL(TInt aCommand)
{
// [[[ begin generated region: do not modify [Generated Code]
TBool commandHandled = EFalse;
CDocumentExampleDocument* aDocument =
static_cast< CDocumentExampleDocument* > (AppUi()->Document() );
switch (aCommand)
{ // code to dispatch to the AknView's menu and CBA commands is generated here
case ECmdRestore:
CAknInformationNote* informationNote;
informationNote = new ( ELeave ) CAknInformationNote;
// Show the information Note with
// textResource loaded with StringLoader.
informationNote->ExecuteLD(aDocument->iBirthday.Name());
break;
case ECmdStore:
_LIT(KUserName,"John");
aDocument->iBirthday.SetName(KUserName);
aDocument->SaveL();
break;
case ECmdIniWrite:
AppUi()->HandleCommandL(aCommand);
break;
case ECmdIniRead:
AppUi()->HandleCommandL(aCommand);
break;
default:
break;
}
if ( !commandHandled)
{
if (aCommand == EAknSoftkeyExit)
{
AppUi()->HandleCommandL( EEikCmdExit);
}
}
// ]]] end generated region [Generated Code]
}
/**
* Handles user actions during activation of the view,
* such as initializing the content.
*/
void CDocumentExampleContainerView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/)
{
// [[[ begin generated region: do not modify [Generated Contents]
SetupStatusPaneL();
if (iDocumentExampleContainer == NULL)
{
iDocumentExampleContainer = CreateContainerL();
iDocumentExampleContainer->SetMopParent( this);
AppUi()->AddToStackL( *this, iDocumentExampleContainer);
}
// ]]] end generated region [Generated Contents]
}
/**
*/
void CDocumentExampleContainerView::DoDeactivate()
{
// [[[ begin generated region: do not modify [Generated Contents]
CleanupStatusPane();
CDocumentExampleDocument* aDocument =
static_cast< CDocumentExampleDocument* > (AppUi()->Document() );
if (iDocumentExampleContainer != NULL)
{
AppUi()->RemoveFromViewStack( *this, iDocumentExampleContainer);
delete iDocumentExampleContainer;
iDocumentExampleContainer = NULL;
}
// ]]] end generated region [Generated Contents]
}
/**
* Handle status pane size change for this view (override)
*/
void CDocumentExampleContainerView::HandleStatusPaneSizeChange()
{
CAknView::HandleStatusPaneSizeChange();
// this may fail, but we're not able to propagate exceptions here
TInt result;
TRAP( result, SetupStatusPaneL() );
// [[[ begin generated region: do not modify [Generated Code]
// ]]] end generated region [Generated Code]
}
// [[[ begin generated function: do not modify
void CDocumentExampleContainerView::SetupStatusPaneL()
{
// reset the context pane
TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext);
CEikStatusPaneBase::TPaneCapabilities subPaneContext = StatusPane()->PaneCapabilities(contextPaneUid);
if (subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
{
CAknContextPane* context = static_cast< CAknContextPane* > (StatusPane()->ControlL(contextPaneUid) );
context->SetPictureToDefaultL();
}
// setup the title pane
TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle);
CEikStatusPaneBase::TPaneCapabilities subPaneTitle = StatusPane()->PaneCapabilities(titlePaneUid);
if (subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
{
CAknTitlePane* title = static_cast< CAknTitlePane* >(StatusPane()->ControlL(titlePaneUid) );
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC( reader, R_DOCUMENT_EXAMPLE_CONTAINER_TITLE_RESOURCE );
title->SetFromResourceL(reader);
CleanupStack::PopAndDestroy(); // reader internal state
}
}
// ]]] end generated function
// [[[ begin generated function: do not modify
void CDocumentExampleContainerView::CleanupStatusPane()
{
}
// ]]] end generated function
/**
* Creates the top-level container for the view. You may modify this method's
* contents and the CDocumentExampleContainer::NewL() signature as needed to initialize the
* container, but the signature for this method is fixed.
* @return new initialized instance of CDocumentExampleContainer
*/
CDocumentExampleContainer* CDocumentExampleContainerView::CreateContainerL()
{
return CDocumentExampleContainer::NewL(ClientRect(), NULL, this);
}