📄 smscryptosymbiancppuilistboxview.cpp
字号:
/*
* ============================================================================
* Name : SMSCryptoSymbianCppUIListBoxView.cpp
* Part of : Open C SMS Crypto Example
* Created : 05/25/2007 by Forum Nokia
* Version : 1.0
* Copyright: Nokia Corporation
* ============================================================================
*/
#include <aknviewappui.h>
#include <eikmenub.h>
#include <avkon.hrh>
#include <barsread.h>
#include <stringloader.h>
#include <aknlists.h>
#include <eikenv.h>
#include <akniconarray.h>
#include <eikclbd.h>
#include <akncontext.h>
#include <akntitle.h>
#include <eikbtgpc.h>
#include <msvapi.h>
#include <SMSCryptoSymbianCppUI.rsg>
#include "SMSCryptoSymbianCppUI.hrh"
#include "SMSCryptoSymbianCppUIListBoxView.h"
#include "SMSCryptoSymbianCppUIListBox.hrh"
#include "SMSCryptoSymbianCppUITextEditor.hrh"
#include "SMSCryptoSymbianCppUIListBox.h"
#include "SMSCryptoSymbianCppUIAppUi.h"
/**
* First phase of Symbian two-phase construction. Should not contain any
* code that could leave.
*/
CSMSCryptoSymbianCppUIListBoxView::CSMSCryptoSymbianCppUIListBoxView()
{
iSMSCryptoSymbianCppUIListBox = NULL;
}
/**
* The view's destructor removes the container from the control
* stack and destroys it.
*/
CSMSCryptoSymbianCppUIListBoxView::~CSMSCryptoSymbianCppUIListBoxView()
{
delete iSMSCryptoSymbianCppUIListBox;
iSMSCryptoSymbianCppUIListBox = NULL;
}
/**
* 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 CSMSCryptoSymbianCppUIListBoxView
*/
CSMSCryptoSymbianCppUIListBoxView* CSMSCryptoSymbianCppUIListBoxView::NewL()
{
CSMSCryptoSymbianCppUIListBoxView* self = CSMSCryptoSymbianCppUIListBoxView::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 CSMSCryptoSymbianCppUIListBoxView
*/
CSMSCryptoSymbianCppUIListBoxView* CSMSCryptoSymbianCppUIListBoxView::NewLC()
{
CSMSCryptoSymbianCppUIListBoxView* self = new ( ELeave ) CSMSCryptoSymbianCppUIListBoxView();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
/**
* Second-phase constructor for view.
* Initialize contents from resource.
*/
void CSMSCryptoSymbianCppUIListBoxView::ConstructL()
{
BaseConstructL( R_SMSCRYPTO_SYMBIAN_CPPUILIST_BOX_SMSCRYPTO_SYMBIAN_CPPUILIST_BOX_VIEW );
}
/**
* @return The UID for this view
*/
TUid CSMSCryptoSymbianCppUIListBoxView::Id() const
{
return TUid::Uid( ESMSCryptoSymbianCppUIListBoxViewId );
}
/**
* Handle a command for this view (override)
* @param aCommand command id to be handled
*/
void CSMSCryptoSymbianCppUIListBoxView::HandleCommandL( TInt aCommand )
{
TBool commandHandled = EFalse;
switch ( aCommand )
{ // code to dispatch to the AknView's menu and CBA commands is generated here
case ESMSCryptoSymbianCppUIListBoxViewOpenMenuItemCommand:
commandHandled = HandleOpenMenuItemSelectedL( aCommand );
break;
case ESMSCryptoSymbianCppUIListBoxViewNew_MessageMenuItemCommand:
CAknView::AppUi()->HandleCommandL( aCommand );
break;
case ESMSCryptoSymbianCppUIListBoxViewRefreshMenuItemCommand:
commandHandled = HandleRefreshMenuItemSelectedL( aCommand );
break;
case ESMSCryptoSymbianCppUIListBoxViewQuitMenuItemCommand:
CAknView::AppUi()->HandleCommandL( aCommand );
break;
default:
break;
}
if ( !commandHandled )
{
if ( aCommand == EAknSoftkeyExit )
{
AppUi()->HandleCommandL( EEikCmdExit );
}
}
}
/**
* Handles user actions during activation of the view,
* such as initializing the content.
*/
void CSMSCryptoSymbianCppUIListBoxView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/ )
{
SetupStatusPaneL();
CEikButtonGroupContainer* cba = AppUi()->Cba();
if ( cba != NULL )
{
cba->MakeVisible( EFalse );
}
if ( iSMSCryptoSymbianCppUIListBox == NULL )
{
iSMSCryptoSymbianCppUIListBox = CSMSCryptoSymbianCppUIListBox::NewL( ClientRect(), NULL, this );
iSMSCryptoSymbianCppUIListBox->SetMopParent( this );
AppUi()->AddToStackL( *this, iSMSCryptoSymbianCppUIListBox );
}
}
/**
*/
void CSMSCryptoSymbianCppUIListBoxView::DoDeactivate()
{
CleanupStatusPane();
CEikButtonGroupContainer* cba = AppUi()->Cba();
if ( cba != NULL )
{
cba->MakeVisible( ETrue );
cba->DrawDeferred();
}
if ( iSMSCryptoSymbianCppUIListBox != NULL )
{
AppUi()->RemoveFromViewStack( *this, iSMSCryptoSymbianCppUIListBox );
delete iSMSCryptoSymbianCppUIListBox;
iSMSCryptoSymbianCppUIListBox = NULL;
}
}
void CSMSCryptoSymbianCppUIListBoxView::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_SMSCRYPTO_SYMBIAN_CPPUILIST_BOX_TITLE_RESOURCE );
title->SetFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
}
void CSMSCryptoSymbianCppUIListBoxView::CleanupStatusPane()
{
}
/**
* Handle status pane size change for this view (override)
*/
void CSMSCryptoSymbianCppUIListBoxView::HandleStatusPaneSizeChange()
{
CAknView::HandleStatusPaneSizeChange();
// this may fail, but we're not able to propagate exceptions here
TInt result;
TRAP( result, SetupStatusPaneL() );
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CSMSCryptoSymbianCppUIListBoxView::HandleOpenMenuItemSelectedL( TInt /*aCommand*/ )
{
iMyAppUi = (CSMSCryptoSymbianCppUIAppUi*)iAvkonAppUi;
iMyAppUi->SetSMSL( iSMSCryptoSymbianCppUIListBox->GetSMSL() );
return ETrue;
}
void CSMSCryptoSymbianCppUIListBoxView::OpenSMSL()
{
HandleOpenMenuItemSelectedL(0);
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CSMSCryptoSymbianCppUIListBoxView::HandleRefreshMenuItemSelectedL( TInt /*aCommand*/ )
{
iSMSCryptoSymbianCppUIListBox->GetSMSFromInboxL();
return ETrue;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -