📄 plaintexteditorcontainer.cpp
字号:
/**
*
* @brief Definition of CPlainTextEditorContainer
*
* Copyright (c) EMCC Software Ltd 2003
* @version 1.0
*/
// INCLUDE FILES
// Class include
#include "PlainTextEditorContainer.h"
// System includes
#include <barsread.h> // TResourceReader
#include <eikedwin.h> // CEikEdwin
#include <PlainTextEditor.rsg> // resources
// CONSTANTS
// N.B. #define'd as DLL cannot contain writeable static data
#define KEditorPosition TPoint(0,0)
// ================= MEMBER FUNCTIONS =======================
/**
* Symbian OS 2nd phase constructor. Creates a Window for the controls, which it contains.
* Constructs a label and adds it to the window, which it then activates.
* @param aRect The rectangle for this window
*/
void CPlainTextEditorContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
iEditor = new (ELeave) CEikEdwin;
iEditor->SetContainerWindowL(*this);
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_PLAINTEXTEDITOR_URLEDITOR);
iEditor->ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(); // reader
iEditor->SetFocus(ETrue);
SetRect(aRect);
ActivateL();
}
/**
* Symbian OS 2 phase constructor.
* Constructs the CPlainTextEditorContainer using the NewLC method, popping
* the constructed object from the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CPlainTextEditorContainer
*/
CPlainTextEditorContainer* CPlainTextEditorContainer::NewL(const TRect& aRect)
{
CPlainTextEditorContainer* self = CPlainTextEditorContainer::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
/**
* Symbian OS 2 phase constructor.
* Constructs the CPlainTextEditorContainer using the constructor and ConstructL
* method, leaving the constructed object on the CleanupStack before returning it.
*
* @param aRect The rectangle for this window
* @return The newly constructed CPlainTextEditorContainer
*/
CPlainTextEditorContainer* CPlainTextEditorContainer::NewLC(const TRect& aRect)
{
CPlainTextEditorContainer* self = new (ELeave) CPlainTextEditorContainer;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
/**
* Destructor. Frees up memory for the iEditor.
*/
CPlainTextEditorContainer::~CPlainTextEditorContainer()
{
delete iEditor;
}
/**
*
* Called by framework when the view size is changed. Resizes the
* iEditor accordingly.
*
*/
void CPlainTextEditorContainer::SizeChanged()
{
iEditor->SetExtent(KEditorPosition, iEditor->MinimumSize());
}
/**
* Called by the framework in compound controls
* @return The number of controls in this CPlainTextEditorContainer
*/
TInt CPlainTextEditorContainer::CountComponentControls() const
{
return 1; // return number of controls inside this container
}
/**
* Called by the framework in compound controls
* @param The index of the control to return
* @return The control for aIndex
*/
CCoeControl* CPlainTextEditorContainer::ComponentControl(TInt aIndex) const
{
switch (aIndex)
{
case 0:
return iEditor;
default:
return NULL;
}
}
/**
* Called by the framework to draw this control. Clears the area in
* aRect.
* @param aRect in which to draw
*/
void CPlainTextEditorContainer::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.Clear(aRect);
}
TKeyResponse CPlainTextEditorContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
if (iEditor)
return iEditor->OfferKeyEventL(aKeyEvent, aType);
else
return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -