⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editorviewcontainer.cpp

📁 《基于Symbian OS的手机开发与应用实践》这本书的配套源码。
💻 CPP
字号:
/*
* ============================================================================
*  Name     : CEditorViewContainer from EditorViewContainer.cpp
*  Part of  : MultiView
*  Created  : 03.12.2005 by ToBeReplacedByAuthor
*  Implementation notes:
*     Initial content was generated by Series 60 AppWizard.
*  Version  :
*  Copyright: ToBeReplacedByCopyright
* ============================================================================
*/

// INCLUDE FILES
#include "EditorViewContainer.h"

#include <eiklabel.h>  // for Label Control
#include <eikedwin.h>  // for CEikEdwin
#include <barsread.h>  // BAFL, for resource reader
#include <MultiView.rsg>

// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CEditorViewContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CEditorViewContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    iLabel = new (ELeave) CEikLabel;
    iLabel->SetContainerWindowL( *this );
    iLabel->SetTextL( _L("Example View 2") );

    iLabel2 = new (ELeave) CEikLabel;
    iLabel2->SetContainerWindowL( *this );
    iLabel2->SetTextL( _L("Input your name:") );

    TResourceReader reader;
    iCoeEnv->CreateResourceReaderLC(reader, R_AKNEXEDITOR_EDITVIEW_EDWIN);
    iEdwin = new (ELeave) CEikEdwin;
    iEdwin->SetContainerWindowL(*this);
    iEdwin->ConstructFromResourceL(reader);
    CleanupStack::PopAndDestroy();  // Resource reader
    //iEdwin->SetExtent(EDWIN_POS, iEdwin->MinimumSize());

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CEditorViewContainer::~CEditorViewContainer()
    {
    delete iLabel;
    delete iLabel2;
    delete iEdwin;
    }

// ---------------------------------------------------------
// CEditorViewContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CEditorViewContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
    iLabel2->SetExtent( TPoint(10,60), iLabel2->MinimumSize() );
    iEdwin->SetExtent( TPoint(10,80), iEdwin->MinimumSize());
    }

// ---------------------------------------------------------
// CEditorViewContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CEditorViewContainer::CountComponentControls() const
    {
    return 3; // return nbr of controls inside this container
    }

// ---------------------------------------------------------
// CEditorViewContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CEditorViewContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iLabel;
        case 1:
            return iLabel2;
        case 2:
            return iEdwin;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CEditorViewContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CEditorViewContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    // TODO: Add your drawing code here
    // example code...
    gc.SetPenStyle( CGraphicsContext::ENullPen );
    gc.SetBrushColor( KRgbGray );
    gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
    gc.DrawRect( aRect );
    }

// ---------------------------------------------------------
// CEditorViewContainer::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CEditorViewContainer::HandleControlEventL(
    CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
    {
    // TODO: Add your control event handler code here
    }

// ---------------------------------------------------------
// CEditorViewContainer::OfferKeyEventL(...)
// Notify key events to editors.
// ---------------------------------------------------------
//
TKeyResponse CEditorViewContainer::OfferKeyEventL(
    const TKeyEvent& aKeyEvent, TEventCode aType)
    {
    if ( aType != EEventKey )
        {
        return EKeyWasNotConsumed;
        }

    if (aKeyEvent.iCode == EKeyLeftArrow)
        {
        return EKeyWasNotConsumed;
        }
    if (iEdwin)
        {
        return iEdwin->OfferKeyEventL(aKeyEvent, aType);
        }
    return EKeyWasNotConsumed;
    }

// End of File  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -