📄 editorcontainer.cpp
字号:
/*
========================================================================
Name : EditorContainer.cpp
Author : elite
Copyright : Your copyright notice
Description :
========================================================================
*/
// [[[ begin generated region: do not modify [Generated System Includes]
#include <barsread.h>
#include <stringloader.h>
#include <gdi.h>
#include <eikgted.h>
#include <eikenv.h>
#include <aknviewappui.h>
#include <eikappui.h>
#include <txtfrmat.h>
#include <eikrted.h>
#include <txtrich.h>
#include <gulcolor.h>
#include <Editor.rsg>
// ]]] end generated region [Generated System Includes]
#include <mypicture.h>
#include <AknUtils.h>
#include <avkon.mbg>
#include <gulicon.h>
#include <akniconarray.h>
// [[[ begin generated region: do not modify [Generated User Includes]
#include "EditorContainer.h"
#include "EditorContainerView.h"
#include "Editor.hrh"
#include "EditorContainer.hrh"
// ]]] end generated region [Generated User Includes]
// [[[ begin generated region: do not modify [Generated Constants]
// ]]] end generated region [Generated Constants]
#ifdef __SERIES60_3X__
#include <eikapp.h>
#endif
// CONSTANTS
//_LIT( KImageBitmapFile, "picture.mbm");
_LIT( KImageBitmapFile1, "_picture.mbm");
//_LIT( KImageBitmapFile, "Editor.mbm");
_LIT(KImageBitmapFile,"z:\\resource\\apps\\Editor.mbm");
//Text and images positions.
const TInt KLeftImagePositionInTheText = 0;
const TInt KRightImagePositionInTheText = 1;
const TInt KEndofCenterFormat = 55;
const TInt KLeftNokia = 6;
const TInt KRightNokia = 11;
const TInt KKImageWidth = 283;
const TInt KImageHeight = 113;
//buffer size
const TInt KBufSize = 256;
/**
* First phase of Symbian two-phase construction. Should not
* contain any code that could leave.
*/
CEditorContainer::CEditorContainer()
{
// [[[ begin generated region: do not modify [Generated Contents]
iRichText1 = NULL;
// ]]] end generated region [Generated Contents]
}
/**
* Destroy child controls.
*/
CEditorContainer::~CEditorContainer()
{
// [[[ begin generated region: do not modify [Generated Contents]
delete iRichText1;
iRichText1 = NULL;
// ]]] end generated region [Generated Contents]
}
/**
* Construct the control (first phase).
* Creates an instance and initializes it.
* Instance is not left on cleanup stack.
* @param aRect bounding rectangle
* @param aParent owning parent, or NULL
* @param aCommandObserver command observer
* @return initialized instance of CEditorContainer
*/
CEditorContainer* CEditorContainer::NewL(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
CEditorContainer* self = CEditorContainer::NewLC(
aRect,
aParent,
aCommandObserver );
CleanupStack::Pop( self );
return self;
}
/**
* Construct the control (first phase).
* Creates an instance and initializes it.
* Instance is left on cleanup stack.
* @param aRect The rectangle for this window
* @param aParent owning parent, or NULL
* @param aCommandObserver command observer
* @return new instance of CEditorContainer
*/
CEditorContainer* CEditorContainer::NewLC(
const TRect& aRect,
const CCoeControl* aParent,
MEikCommandObserver* aCommandObserver )
{
CEditorContainer* self = new ( ELeave ) CEditorContainer();
CleanupStack::PushL( self );
self->ConstructL( aRect, aParent, aCommandObserver );
return self;
}
/**
* Construct the control (second phase).
* Creates a window to contain the controls and activates it.
* @param aRect bounding rectangle
* @param aCommandObserver command observer
* @param aParent owning parent, or NULL
*/
void CEditorContainer::ConstructL(const TRect& aRect, const CCoeControl* aParent, MEikCommandObserver* aCommandObserver )
{
if ( aParent == NULL )
{
CreateWindowL();
}
else
{
SetContainerWindowL( *aParent );
}
iFocusControl = NULL;
iCommandObserver = aCommandObserver;
InitializeControlsL();
iBitmap = new (ELeave) CArrayFixFlat<CFbsBitmap *>(2);
iconArray = new( ELeave ) CAknIconArray( 1 );
// CleanupStack::PushL( iconArray );
iRichText1->ConstructL(this,0,0,0);
iRichText1->SetFocus(ETrue);
Prepare();
PrepareBitmapL();
SetRect( aRect );
ActivateL();
// [[[ begin generated region: do not modify [Post-ActivateL initializations]
SetRichText1FormattingL();
// ]]] end generated region [Post-ActivateL initializations]
SetupL();
}
/**
* Return the number of controls in the container (override)
* @return count
*/
TInt CEditorContainer::CountComponentControls() const
{
return ( int ) ELastControl;
}
/**
* Get the control with the given index (override)
* @param aIndex Control index [0...n) (limited by #CountComponentControls)
* @return Pointer to control
*/
CCoeControl* CEditorContainer::ComponentControl( TInt aIndex ) const
{
// [[[ begin generated region: do not modify [Generated Contents]
switch ( aIndex )
{
case ERichText1:
return iRichText1;
}
// ]]] end generated region [Generated Contents]
// handle any user controls here...
return NULL;
}
/**
* Handle resizing of the container. This implementation will lay out
* full-sized controls like list boxes for any screen size, and will layout
* labels, editors, etc. to the size they were given in the UI designer.
* This code will need to be modified to adjust arbitrary controls to
* any screen size.
*/
void CEditorContainer::SizeChanged()
{
CCoeControl::SizeChanged();
LayoutControls();
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
}
// [[[ begin generated function: do not modify
/**
* Layout components as specified in the UI Designer
*/
void CEditorContainer::LayoutControls()
{
iRichText1->SetExtent( TPoint( -1, 4 ), TSize( 239, 217 ) );
}
// ]]] end generated function
/**
* Handle key events.
*/
TKeyResponse CEditorContainer::OfferKeyEventL(
const TKeyEvent& aKeyEvent,
TEventCode aType )
{
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
if ( iFocusControl != NULL
&& iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
{
return EKeyWasConsumed;
}
return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
}
// [[[ begin generated function: do not modify
/**
* Initialize each control upon creation.
*/
void CEditorContainer::InitializeControlsL()
{
iRichText1 = new ( ELeave ) CEikRichTextEditor;
iRichText1->SetContainerWindowL( *this );
{
TResourceReader reader;
iEikonEnv->CreateResourceReaderLC( reader, R_EDITOR_CONTAINER_RICH_TEXT1 );
iRichText1->ConstructFromResourceL( reader );
CleanupStack::PopAndDestroy(); // reader internal state
}
{
HBufC* text = StringLoader::LoadLC( R_EDITOR_CONTAINER_RICH_TEXT1_2 );
iRichText1->SetTextL( text );
CleanupStack::PopAndDestroy( text );
}
iRichText1->SetFocus( ETrue );
iFocusControl = iRichText1;
}
// ]]] end generated function
/**
* Handle global resource changes, such as scalable UI or skin events (override)
*/
void CEditorContainer::HandleResourceChange( TInt aType )
{
CCoeControl::HandleResourceChange( aType );
SetRect( iAvkonViewAppUi->View( TUid::Uid( EEditorContainerViewId ) )->ClientRect() );
// [[[ begin generated region: do not modify [Generated Contents]
// ]]] end generated region [Generated Contents]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -