src/NPRStoryListBoxView.cpp
author tahirm@symbian.org
Fri, 24 Jul 2009 08:46:02 +0100
changeset 0 0049171ecffb
permissions -rw-r--r--
initial release
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     1
/*
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     2
 ==========================================================================================
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     3
 Name	: NPRStoryListBoxView.h
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     4
 Author	: Symsource
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     5
 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     6
 Copyright (c) 2009 Symbian Foundation Ltd
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     7
 This component and the accompanying materials are made available
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     8
 under the terms of the License "Eclipse Public License v1.0"
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
     9
 which accompanies this distribution, and is available
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    10
 at the URL "http://www.eclipse.org/legal/epl-v10.html".
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    11
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    12
 Initial Contributors:
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    13
 - Symsource
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    14
 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    15
 Contributors:
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    16
 - Symsource
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    17
 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    18
 Description :  AknView for wrapping the container to show the NPR's story list
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    19
 ==========================================================================================
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    20
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    21
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    22
#include <barsread.h>
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    23
#include <aknlists.h>
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    24
#include <akncontext.h>
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    25
#include <akntitle.h>
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    26
#include <NPR_0xEEB0E481.rsg>
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    27
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    28
#include "NPR.hrh"
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    29
#include "NPRStoryListBoxView.h"
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    30
#include "NPRStoryListBox.h"
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    31
#include "NPRAppUi.h"
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    32
#include "NPRAppEngine.h"
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    33
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    34
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    35
 * First phase of Symbian two-phase construction. Should not contain any
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    36
 * code that could leave.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    37
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    38
CNPRStoryListBoxView::CNPRStoryListBoxView()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    39
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    40
	iNPRStoryListBox = NULL;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    41
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    42
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    43
/** 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    44
 * The view's destructor removes the container from the control
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    45
 * stack and destroys it.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    46
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    47
CNPRStoryListBoxView::~CNPRStoryListBoxView()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    48
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    49
	delete iNPRStoryListBox;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    50
	iNPRStoryListBox = NULL;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    51
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    52
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    53
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    54
 * Symbian two-phase constructor.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    55
 * This creates an instance then calls the second-phase constructor
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    56
 * without leaving the instance on the cleanup stack.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    57
 * @return new instance of CNPRStoryListBoxView
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    58
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    59
CNPRStoryListBoxView* CNPRStoryListBoxView::NewL()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    60
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    61
	CNPRStoryListBoxView* self = CNPRStoryListBoxView::NewLC();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    62
	CleanupStack::Pop( self );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    63
	return self;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    64
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    65
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    66
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    67
 * Symbian two-phase constructor.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    68
 * This creates an instance, pushes it on the cleanup stack,
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    69
 * then calls the second-phase constructor.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    70
 * @return new instance of CNPRStoryListBoxView
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    71
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    72
CNPRStoryListBoxView* CNPRStoryListBoxView::NewLC()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    73
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    74
	CNPRStoryListBoxView* self = new ( ELeave ) CNPRStoryListBoxView();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    75
	CleanupStack::PushL( self );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    76
	self->ConstructL();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    77
	return self;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    78
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    79
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    80
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    81
 * Second-phase constructor for view.  
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    82
 * Initialize contents from resource.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    83
 */ 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    84
void CNPRStoryListBoxView::ConstructL()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    85
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    86
	BaseConstructL( R_NPRSTORY_LIST_BOX_NPRSTORY_LIST_BOX_VIEW );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    87
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    88
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    89
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    90
 * @return The UID for this view
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    91
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    92
TUid CNPRStoryListBoxView::Id() const
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    93
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    94
	return TUid::Uid(ENPRStoryListBoxViewId);
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    95
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    96
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    97
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    98
 * Handle a command for this view (override)
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
    99
 * @param aCommand command id to be handled
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   100
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   101
void CNPRStoryListBoxView::HandleCommandL( TInt aCommand )
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   102
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   103
	switch ( aCommand )
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   104
		{	// code to dispatch to the AknView's menu and CBA commands is generated here
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   105
		case ESelect:
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   106
			{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   107
			iNPRStoryListBox->ShowSelectedStoryL();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   108
			break;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   109
			}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   110
		case EAknSoftkeyBack:
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   111
			{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   112
			static_cast<CNPRAppUi*>(CEikonEnv::Static()->EikAppUi())->ActivateLocalViewL(TUid::Uid(ENPRListBoxViewId));
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   113
			break;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   114
			}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   115
		default:
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   116
			break;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   117
		}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   118
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   119
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   120
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   121
 *	Handles user actions during activation of the view, 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   122
 *	such as initializing the content.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   123
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   124
void CNPRStoryListBoxView::DoActivateL( 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   125
		const TVwsViewId& /*aPrevViewId*/,
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   126
		TUid /*aCustomMessageId*/,
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   127
		const TDesC8& /*aCustomMessage*/ )
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   128
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   129
	SetupStatusPaneL();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   130
	if ( iNPRStoryListBox == NULL )
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   131
		{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   132
		iNPRStoryListBox = CreateContainerL();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   133
		iNPRStoryListBox->SetMopParent( this );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   134
		AppUi()->AddToStackL( *this, iNPRStoryListBox );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   135
		} 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   136
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   137
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   138
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   139
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   140
void CNPRStoryListBoxView::DoDeactivate()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   141
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   142
	CleanupStatusPane();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   143
	
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   144
	if ( iNPRStoryListBox != NULL )
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   145
		{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   146
		AppUi()->RemoveFromViewStack( *this, iNPRStoryListBox );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   147
		delete iNPRStoryListBox;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   148
		iNPRStoryListBox = NULL;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   149
		}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   150
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   151
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   152
/** 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   153
 * Handle status pane size change for this view (override)
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   154
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   155
void CNPRStoryListBoxView::HandleStatusPaneSizeChange()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   156
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   157
	CAknView::HandleStatusPaneSizeChange();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   158
	
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   159
	// this may fail, but we're not able to propagate exceptions here
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   160
	TVwsViewId view;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   161
	AppUi()->GetActiveViewId( view );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   162
	if ( view.iViewUid == Id() )
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   163
		{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   164
		TInt result;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   165
		TRAP( result, SetupStatusPaneL() );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   166
		}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   167
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   168
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   169
void CNPRStoryListBoxView::SetupStatusPaneL()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   170
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   171
	// reset the context pane
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   172
	TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   173
	CEikStatusPaneBase::TPaneCapabilities subPaneContext = 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   174
		StatusPane()->PaneCapabilities( contextPaneUid );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   175
	if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() )
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   176
		{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   177
		CAknContextPane* context = static_cast< CAknContextPane* > ( 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   178
			StatusPane()->ControlL( contextPaneUid ) );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   179
		context->SetPictureToDefaultL();
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   180
		}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   181
	
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   182
	// setup the title pane
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   183
	TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   184
	CEikStatusPaneBase::TPaneCapabilities subPaneTitle = 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   185
		StatusPane()->PaneCapabilities( titlePaneUid );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   186
	if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() )
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   187
		{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   188
		CAknTitlePane* title = static_cast< CAknTitlePane* >( 
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   189
			StatusPane()->ControlL( titlePaneUid ) );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   190
		TResourceReader reader;
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   191
		iEikonEnv->CreateResourceReaderLC( reader, R_NPRSTORY_LIST_BOX_TITLE_RESOURCE );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   192
		title->SetFromResourceL( reader );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   193
		CleanupStack::PopAndDestroy(); // reader internal state
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   194
		}			
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   195
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   196
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   197
void CNPRStoryListBoxView::CleanupStatusPane()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   198
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   199
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   200
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   201
/**
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   202
 *	Creates the top-level container for the view.  You may modify this method's
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   203
 *	contents and the CNPRStoryListBox::NewL() signature as needed to initialize the
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   204
 *	container, but the signature for this method is fixed.
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   205
 *	@return new initialized instance of CNPRStoryListBox
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   206
 */
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   207
CNPRStoryListBox* CNPRStoryListBoxView::CreateContainerL()
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   208
	{
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   209
	return CNPRStoryListBox::NewL( ClientRect(), NULL, this );
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   210
	}
0049171ecffb initial release
tahirm@symbian.org
parents:
diff changeset
   211