📄 smscryptosymbiancppuitexteditorview.cpp
字号:
/*
* ============================================================================
* Name : SMSCryptoSymbianCppUITextEditorView.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 <gdi.h>
#include <eikedwin.h>
#include <eikenv.h>
#include <akncontext.h>
#include <akntitle.h>
#include <eikbtgpc.h>
#include <SMSCryptoSymbianCppUI.rsg>
#include "SMSCryptoSymbianCppUI.hrh"
#include "SMSCryptoSymbianCppUITextEditorView.h"
#include "SMSCryptoSymbianCppUIListBox.hrh"
#include "SMSCryptoSymbianCppUITextEditor.hrh"
#include "SMSCryptoSymbianCppUITextEditor.h"
#include "SMSCryptoSymbianCppUIAppUi.h"
/**
* First phase of Symbian two-phase construction. Should not contain any
* code that could leave.
*/
CSMSCryptoSymbianCppUITextEditorView::CSMSCryptoSymbianCppUITextEditorView()
{
iSMSCryptoSymbianCppUITextEditor = NULL;
}
/**
* The view's destructor removes the container from the control
* stack and destroys it.
*/
CSMSCryptoSymbianCppUITextEditorView::~CSMSCryptoSymbianCppUITextEditorView()
{
delete iSMSCryptoSymbianCppUITextEditor;
iSMSCryptoSymbianCppUITextEditor = 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 CSMSCryptoSymbianCppUITextEditorView
*/
CSMSCryptoSymbianCppUITextEditorView* CSMSCryptoSymbianCppUITextEditorView::NewL()
{
CSMSCryptoSymbianCppUITextEditorView* self = CSMSCryptoSymbianCppUITextEditorView::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 CSMSCryptoSymbianCppUITextEditorView
*/
CSMSCryptoSymbianCppUITextEditorView* CSMSCryptoSymbianCppUITextEditorView::NewLC()
{
CSMSCryptoSymbianCppUITextEditorView* self = new ( ELeave ) CSMSCryptoSymbianCppUITextEditorView();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
/**
* Second-phase constructor for view.
* Initialize contents from resource.
*/
void CSMSCryptoSymbianCppUITextEditorView::ConstructL()
{
BaseConstructL( R_SMSCRYPTO_SYMBIAN_CPPUITEXT_EDITOR_SMSCRYPTO_SYMBIAN_CPPUITEXT_EDITOR_VIEW );
}
/**
* @return The UID for this view
*/
TUid CSMSCryptoSymbianCppUITextEditorView::Id() const
{
return TUid::Uid( ESMSCryptoSymbianCppUITextEditorViewId );
}
/**
* Handle a command for this view (override)
* @param aCommand command id to be handled
*/
void CSMSCryptoSymbianCppUITextEditorView::HandleCommandL( TInt aCommand )
{
TBool commandHandled = EFalse;
switch ( aCommand )
{ // code to dispatch to the AknView's menu and CBA commands is generated here
case ESMSCryptoSymbianCppUITextEditorViewSendMenuItemCommand:
commandHandled = HandleSendMenuItemSelectedL( aCommand );
break;
case ESMSCryptoSymbianCppUITextEditorViewBackMenuItemCommand:
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 CSMSCryptoSymbianCppUITextEditorView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/ )
{
SetupStatusPaneL();
CEikButtonGroupContainer* cba = AppUi()->Cba();
if ( cba != NULL )
{
cba->MakeVisible( EFalse );
}
if ( iSMSCryptoSymbianCppUITextEditor == NULL )
{
iSMSCryptoSymbianCppUITextEditor = CSMSCryptoSymbianCppUITextEditor::NewL( ClientRect(), NULL, this );
iSMSCryptoSymbianCppUITextEditor->SetMopParent( this );
AppUi()->AddToStackL( *this, iSMSCryptoSymbianCppUITextEditor );
}
iMyAppUi = (CSMSCryptoSymbianCppUIAppUi*)iAvkonAppUi;
iSMSCryptoSymbianCppUITextEditor->SetSMSL( iMyAppUi->GetSMSL() );
iSMSCryptoSymbianCppUITextEditor->ReadSMSInEditorL();
iSMSCryptoSymbianCppUITextEditor->SetTextEditorStateL();
}
/**
*/
void CSMSCryptoSymbianCppUITextEditorView::DoDeactivate()
{
CleanupStatusPane();
CEikButtonGroupContainer* cba = AppUi()->Cba();
if ( cba != NULL )
{
cba->MakeVisible( ETrue );
cba->DrawDeferred();
}
if ( iSMSCryptoSymbianCppUITextEditor != NULL )
{
AppUi()->RemoveFromViewStack( *this, iSMSCryptoSymbianCppUITextEditor );
delete iSMSCryptoSymbianCppUITextEditor;
iSMSCryptoSymbianCppUITextEditor = NULL;
}
iMyAppUi->ClearSMSL();
}
void CSMSCryptoSymbianCppUITextEditorView::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_CPPUITEXT_EDITOR_TITLE_RESOURCE );
title->SetFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
}
void CSMSCryptoSymbianCppUITextEditorView::CleanupStatusPane()
{
}
/**
* Handle status pane size change for this view (override)
*/
void CSMSCryptoSymbianCppUITextEditorView::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 CSMSCryptoSymbianCppUITextEditorView::HandleSendMenuItemSelectedL( TInt /*aCommand*/ )
{
iSMSCryptoSymbianCppUITextEditor->SendSMSL();
return ETrue;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -