📄 tcpsocketcontainer.cpp
字号:
/*
* ============================================================================
* Name : CTcpSocketContainer from TcpSocketContainer.h
* Part of : TcpSocket
* 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 <TcpSocket.rsg>
#include "TcpSocketContainer.h"
const TInt KMsgMaxLength = 20;
// ================= MEMBER FUNCTIONS =======================
// ---------------------------------------------------------
// CTcpSocketContainer::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CTcpSocketContainer::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
CTcpSocketContainer::~CTcpSocketContainer()
{
delete iInputBox;
delete iOutputBox;
}
void CTcpSocketContainer::SelectLocalMsgL()
{
iInputBox->SelectAllL();
DrawDeferred();
}
void CTcpSocketContainer::GetLocalMsg(TDes& aMsg)
{
iInputBox->GetText(aMsg);
}
TInt CTcpSocketContainer::LocalMsgLength()
{
return iInputBox->TextLength();
}
void CTcpSocketContainer::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 CTcpSocketContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
{
if(aKeyEvent.iScanCode==EStdKeyDevice3)
{
return EKeyWasNotConsumed;
}
return iInputBox->OfferKeyEventL(aKeyEvent, aType);
}
// ---------------------------------------------------------
// CTcpSocketContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CTcpSocketContainer::SizeChanged()
{
iOutputBox->SetExtent( TPoint(1,1), TSize(174, 119));
iInputBox->SetExtent( TPoint(1,122), TSize(174, 20));
}
// ---------------------------------------------------------
// CTcpSocketContainer::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CTcpSocketContainer::CountComponentControls() const
{
return 2; // return nbr of controls inside this container
}
// ---------------------------------------------------------
// CTcpSocketContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CTcpSocketContainer::ComponentControl(TInt aIndex) const
{
switch ( aIndex )
{
case 0:
return iInputBox;
case 1:
return iOutputBox;
default:
return NULL;
}
}
// ---------------------------------------------------------
// CTcpSocketContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CTcpSocketContainer::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 + -