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

📄 tcpcocketcontainer.cpp

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

// INCLUDE FILES
#include <eikedwin.h>     // for CEikEdwin
#include <TcpCocket.rsg>

#include "TcpCocketContainer.h"

const TInt KMsgMaxLength = 20;

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

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

    iInputBox = new (ELeave) CEikEdwin();
    iInputBox->SetContainerWindowL( *this );
    iInputBox->ConstructL();
    iInputBox->SetFocus(ETrue);
    iInputBox->SetMaxLength(KMsgMaxLength);

    iOutputBox = new(ELeave) CEikEdwin;
    iOutputBox->SetContainerWindowL( *this );
    iOutputBox->ConstructL();
    iOutputBox->SetReadOnly(ETrue);

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CTcpCocketContainer::~CTcpCocketContainer()
    {
    delete iInputBox;
    delete iOutputBox;
    }

void CTcpCocketContainer::SelectLocalMsgL()
    {
    iInputBox->SelectAllL();
    DrawDeferred();
    }

void CTcpCocketContainer::GetLocalMsg(TDes& aMsg)
    {
    iInputBox->GetText(aMsg);
    }

TInt CTcpCocketContainer::LocalMsgLength()
    {
    return iInputBox->TextLength();
    }

void CTcpCocketContainer::OutputMsgL(const TDesC& aMsg)
    {
    CPlainText* text = iOutputBox->Text();
    TInt len = text->DocumentLength();
    text->InsertL(len, aMsg);
    len = text->DocumentLength();
    text->InsertL(len, CEditableText::ELineBreak);
    len = text->DocumentLength();
    iOutputBox->SetCursorPosL(len, EFalse);
    DrawDeferred();
    }

// Functions from base classes
TKeyResponse CTcpCocketContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    if(aKeyEvent.iScanCode==EStdKeyDevice3)
        {
        return EKeyWasNotConsumed;
        }
    return iInputBox->OfferKeyEventL(aKeyEvent, aType);
    }

// ---------------------------------------------------------
// CTcpCocketContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CTcpCocketContainer::SizeChanged()
    {
    iOutputBox->SetExtent( TPoint(1,1), TSize(174, 119));
    iInputBox->SetExtent( TPoint(1,122), TSize(174, 20));
    }

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

// ---------------------------------------------------------
// CTcpCocketContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CTcpCocketContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iInputBox;
        case 1:
            return iOutputBox;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CTcpCocketContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CTcpCocketContainer::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 );
    }

// End of File  

⌨️ 快捷键说明

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