📄 editorcontainerview.cpp
字号:
/*
========================================================================
Name : EditorContainerView.cpp
Author : elite
Copyright : Your copyright notice
Description :
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <aknviewappui.h>
#include <eikmenub.h>
#include <avkon.hrh>
#include <barsread.h>
#include <stringloader.h>
#include <gdi.h>
#include <eikgted.h>
#include <eikenv.h>
#include <akncontext.h>
#include <akntitle.h>
#include <eikbtgpc.h>
#include <Editor.rsg>
// ]]] end generated region [Generated System Includes]
#include <AknUtils.h>
const TInt KLeftImagePositionInTheText = 5;
const TInt KRightImagePositionInTheText = 5;
#include <AknToolbar.h>
#include <akntoolbarextension.h>
// [[[ begin generated region: do not modify [Generated User Includes]
#include "Editor.hrh"
#include "EditorContainerView.h"
#include "EditorContainer.hrh"
#include "EditorContainer.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.
*/
CEditorContainerView::CEditorContainerView()
{
// [[[ begin generated region: do not modify [Generated Contents]
iEditorContainer = NULL;
// ]]] end generated region [Generated Contents]
}
/**
* The view's destructor removes the container from the control
* stack and destroys it.
*/
CEditorContainerView::~CEditorContainerView()
{
// [[[ begin generated region: do not modify [Generated Contents]
delete iEditorContainer;
iEditorContainer = 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 CEditorContainerView
*/
CEditorContainerView* CEditorContainerView::NewL()
{
CEditorContainerView* self = CEditorContainerView::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 CEditorContainerView
*/
CEditorContainerView* CEditorContainerView::NewLC()
{
CEditorContainerView* self = new ( ELeave ) CEditorContainerView();
CleanupStack::PushL( self );
self->ConstructL();
return self;
}
/**
* Second-phase constructor for view.
* Initialize contents from resource.
*/
void CEditorContainerView::ConstructL()
{
// [[[ begin generated region: do not modify [Generated Code]
BaseConstructL( R_EDITOR_CONTAINER_EDITOR_CONTAINER_VIEW );
if( AknLayoutUtils::PenEnabled() && Toolbar() )
{
//By default keep toolbar invisible
ShowToolbarOnViewActivation( ETrue );
Toolbar()->SetToolbarObserver( this );
}
// ]]] end generated region [Generated Code]
// add your own initialization code here
}
/**
* @return The UID for this view
*/
TUid CEditorContainerView::Id() const
{
return TUid::Uid( EEditorContainerViewId );
}
/**
* Handle a command for this view (override)
* @param aCommand command id to be handled
*/
void CEditorContainerView::HandleCommandL( TInt aCommand )
{
// [[[ begin generated region: do not modify [Generated Code]
TBool commandHandled = EFalse;
switch ( aCommand )
{ // code to dispatch to the AknView's menu and CBA commands is generated here
case EEditorContainerViewRedMenuItemCommand:
commandHandled = HandleRedMenuItemSelectedL( aCommand );
break;
case EEditorContainerViewGreenMenuItemCommand:
commandHandled = HandleGreenMenuItemSelectedL( aCommand );
break;
case EEditorContainerViewBlueMenuItemCommand:
commandHandled = HandleBlueMenuItemSelectedL( aCommand );
break;
case EEditorContainerViewRedMenuItem1Command:
commandHandled = HandleRedMenuItem1SelectedL( aCommand );
break;
case EEditorContainerViewGreenMenuItem1Command:
commandHandled = HandleGreenMenuItem1SelectedL( aCommand );
break;
case EEditorContainerViewBlueMenuItem1Command:
commandHandled = HandleBlueMenuItem1SelectedL( aCommand );
break;
case EEditorContainerViewLoad_PictureMenuItemCommand:
commandHandled = HandleLoad_PictureMenuItemSelectedL( aCommand );
break;
case EEditorContainerViewBoldMenuItemCommand:
commandHandled = HandleBoldMenuItemSelectedL( aCommand );
break;
case EEditorContainerViewIttalicMenuItemCommand:
commandHandled = HandleIttalicMenuItemSelectedL( aCommand );
break;
case EEditorContainerViewUnderlineMenuItemCommand:
commandHandled = HandleUnderlineMenuItemSelectedL( 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 CEditorContainerView::DoActivateL(
const TVwsViewId& /*aPrevViewId*/,
TUid /*aCustomMessageId*/,
const TDesC8& /*aCustomMessage*/ )
{
// [[[ begin generated region: do not modify [Generated Contents]
SetupStatusPaneL();
if ( iEditorContainer == NULL )
{
iEditorContainer = CreateContainerL();
iEditorContainer->SetMopParent( this );
AppUi()->AddToStackL( *this, iEditorContainer );
}
// ]]] end generated region [Generated Contents]
}
/**
*/
void CEditorContainerView::DoDeactivate()
{
// [[[ begin generated region: do not modify [Generated Contents]
CleanupStatusPane();
if ( iEditorContainer != NULL )
{
AppUi()->RemoveFromViewStack( *this, iEditorContainer );
delete iEditorContainer;
iEditorContainer = NULL;
}
// ]]] end generated region [Generated Contents]
}
/**
* Handle status pane size change for this view (override)
*/
void CEditorContainerView::HandleStatusPaneSizeChange()
{
CAknView::HandleStatusPaneSizeChange();
// this may fail, but we're not able to propagate exceptions here
TVwsViewId view;
AppUi()->GetActiveViewId( view );
if ( view.iViewUid == Id() )
{
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 CEditorContainerView::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_EDITOR_CONTAINER_TITLE_RESOURCE );
title->SetFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
}
// ]]] end generated function
// [[[ begin generated function: do not modify
void CEditorContainerView::CleanupStatusPane()
{
}
// ]]] end generated function
/**
* Creates the top-level container for the view. You may modify this method's
* contents and the CEditorContainer::NewL() signature as needed to initialize the
* container, but the signature for this method is fixed.
* @return new initialized instance of CEditorContainer
*/
CEditorContainer* CEditorContainerView::CreateContainerL()
{
return CEditorContainer::NewL( ClientRect(), NULL, this );
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleRedMenuItemSelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetFont(LatinBold19()) ;
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleLoad_PictureMenuItemSelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->DrawPictureL(2);
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleGreenMenuItemSelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetFont(LatinBold12()) ;
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleBlueMenuItemSelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetFont(LatinPlain12()) ;
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleRedMenuItem1SelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetColor(KRgbRed);
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleGreenMenuItem1SelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetColor(KRgbGreen);
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleBlueMenuItem1SelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetColor(KRgbBlue);
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleBoldMenuItemSelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetCharacterBIUAttribL(CEikGlobalTextEditor::EBold);
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleIttalicMenuItemSelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetCharacterBIUAttribL(CEikGlobalTextEditor::EItalic);
return ETrue;
}
/**
* Handle the selected event.
* @param aCommand the command id invoked
* @return ETrue if the command was handled, EFalse if not
*/
TBool CEditorContainerView::HandleUnderlineMenuItemSelectedL( TInt aCommand )
{
// TODO: implement selected event handler
iEditorContainer->SetCharacterBIUAttribL(CEikGlobalTextEditor::EUnderline);
return ETrue;
}
/**
* Should be used to set the properties of some toolbar components
* before it is drawn.
* @param aResourceId The resource ID for particular toolbar
* @param aToolbar The toolbar object pointer
*/
void CEditorContainerView::DynInitToolbarL(
TInt aResourceId,
CAknToolbar* aToolBar )
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
/**
* Handles toolbar events for a certain toolbar item.
* @param aCommand The command ID of some toolbar item.
*/
void CEditorContainerView::OfferToolbarEventL( TInt aCommandId )
{
if(Toolbar()->ToolbarExtension()->IsShown())
{
Toolbar()->ToolbarExtension()->SetShown(EFalse);
}
HandleCommandL( aCommandId );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -