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

📄 httpclientcontainer.cpp

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

// INCLUDE FILES
#include "HttpClientContainer.h"

#include <eikedwin.h>


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

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

    iEdwin = new (ELeave) CEikEdwin();
    iEdwin->SetAknEditorFlags(EAknEditorFlagEnableScrollBars);
    iEdwin->SetContainerWindowL(*this);
    iEdwin->ConstructL(EEikEdwinAvkonDisableCursor|EEikEdwinNoAutoSelection|EEikEdwinReadOnly);
    iEdwin->SetFocus(ETrue);
    iEdwin->SetCursorPosL(0, EFalse); //set cursor to the beginning

    SetRect(aRect);
    ActivateL();
    }

// Destructor
CHttpClientContainer::~CHttpClientContainer()
    {
    delete iEdwin;
    }

// New functions
void CHttpClientContainer::ClearL()
    {
    iEdwin->SetTextL(NULL);
    DrawDeferred();
    }

void CHttpClientContainer::AppendL(const TDesC& aText)
    {
    CPlainText* text = iEdwin->Text();
    TInt len = text->DocumentLength();
    text->InsertL(len, aText);
    len = text->DocumentLength();
    text->InsertL(len, CEditableText::ELineBreak);
    len = text->DocumentLength();
    iEdwin->SetCursorPosL(len, EFalse);
    iEdwin->UpdateScrollBarsL();
    DrawDeferred();
    }

// Functions from base classes
TKeyResponse CHttpClientContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {
    if(aType!=EEventKey)
        {   // we have no interest with keyup or keydown event
        return EKeyWasNotConsumed;
        }
    switch(aKeyEvent.iScanCode)
        {
        case EStdKeyDownArrow:
            {
            TKeyEvent keyEvent = aKeyEvent;
            keyEvent.iCode=EKeyPageDown;
            iEdwin->OfferKeyEventL(keyEvent, aType);
            break;
            }
        case EStdKeyUpArrow:
            {
            TKeyEvent keyEvent = aKeyEvent;
            keyEvent.iCode=EKeyPageUp;
            iEdwin->OfferKeyEventL(keyEvent, aType);
            break;
            }
        default:
            {
            return EKeyWasNotConsumed;
            }
        }
    return EKeyWasConsumed;
    }

// ---------------------------------------------------------
// CHttpClientContainer::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CHttpClientContainer::SizeChanged()
    {
    // TODO: Add here control resize code etc.
    iEdwin->SetExtent( TPoint(1,1), TSize(174, 142));
    }

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

// ---------------------------------------------------------
// CHttpClientContainer::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CHttpClientContainer::ComponentControl(TInt aIndex) const
    {
    switch ( aIndex )
        {
        case 0:
            return iEdwin;
        default:
            return NULL;
        }
    }

// ---------------------------------------------------------
// CHttpClientContainer::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CHttpClientContainer::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 + -