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

📄 aoexampleappui.cpp

📁 Active Object实现动画
💻 CPP
字号:
/*
* ==============================================================================
*  Name     : CAOExampleAppUi
*  Part of  : AOExample
*  Created  : 3.5.2004 by Markus Pelkonen
*  Implementation notes: See detailed documentation from the file
*                        "AOExampleAppUi.h"
*  Version  :
*  Copyright: Nokia
* ==============================================================================
*/

#include "AOExampleAppUi.h"
#include "AOExampleContainer.h"
#include <AOExample.rsg>
#include "aoexample.hrh"
#include "AOExampleEngine.h"
#include <eikedwin.h>
#include <avkon.hrh>
#include <aknquerydialog.h>

// -----------------------------------------------------------------------------
void CAOExampleAppUi::ConstructL()
    {
    BaseConstructL();

    // construct example engine
    iAOExampleEngine = CAOExampleEngine::NewLC();
    CleanupStack::Pop(); //iAOExampleEngine

    // construct dynamic buffer
    iBuf = CBufFlat::NewL(256);

    // construct container
    iAppContainer = new (ELeave) CAOExampleContainer;
    iAppContainer->SetMopParent( this );
    iAppContainer->ConstructL( ClientRect() );
    AddToStackL( iAppContainer );

    // set default url for the dialog
    _LIT( KDefaultUrl, "http://www.forum.nokia.com:80/" );
    iUrl.Copy( KDefaultUrl );
    }

// -----------------------------------------------------------------------------
CAOExampleAppUi::~CAOExampleAppUi()
    {
    if (iAppContainer)
        {
        RemoveFromStack( iAppContainer );
        delete iAppContainer;
        }
    delete iBuf;
    delete iAOExampleEngine;
    }

// -----------------------------------------------------------------------------
void CAOExampleAppUi::DynInitMenuPaneL(
    TInt /*aResourceId*/,CEikMenuPane* /*aMenuPane*/)
    {
    }

// -----------------------------------------------------------------------------
TKeyResponse CAOExampleAppUi::HandleKeyEventL( const TKeyEvent& aKeyEvent,
                                               TEventCode aType )
    {
    return iAppContainer->OfferKeyEventL( aKeyEvent, aType );
    }

// -----------------------------------------------------------------------------
void CAOExampleAppUi::HandleCommandL(TInt aCommand)
    {
    switch ( aCommand )
        {
        case EAknSoftkeyBack:
        case EEikCmdExit:
            {
            Exit();
            break;
            }
        case EAOExampleCmdAppClear:
            iAppContainer->Clear();
            break;
        case EAOExampleCmdAppFetch:
            {
            // show dialog asking an URL
            CAknTextQueryDialog* dlg = new (ELeave) CAknTextQueryDialog(
                iUrl, CAknQueryDialog::ENoTone );
            if( dlg->ExecuteLD( R_AOEXAMPLE_URL_QUERY ) )
                { // ok selected from the dialog
                // reset previous engine state to not connected.
                iPrevState = CAOExampleEngine::ENotConnected;
                // empty buffer reserved for the document
                iBuf->Reset();
                // make fetch request and pass this object to get notifications
                iAOExampleEngine->FetchFileL( iUrl, iBuf, this );
                }
            break;
            }
        default:
            break;
        }
    }

// -----------------------------------------------------------------------------
void CAOExampleAppUi::FileFetched( CBufBase* aContent )
    {
    _LIT(KMsg, "File fetched:\n");
    TRAPD( ignored, iAppContainer->AppendTextL( KMsg ) );
    TRAPD( i2, iAppContainer->AppendTextL( aContent->Ptr(0) ) );
    }

// -----------------------------------------------------------------------------
void CAOExampleAppUi::Cancelled( const TDesC& aReason )
    {
    TBuf<256> msg;
    _LIT(KFormat, "Operation cancelled: %S\n");
    msg.Format( KFormat, &aReason );
    TRAPD( ignored, iAppContainer->AppendTextL( msg ) );
    }

// -----------------------------------------------------------------------------
_LIT( KLookingMsg,    "Looking IP..." );
_LIT( KConnectingMsg, "Connecting..." );
_LIT( KRequestingMsg, "Requesting document..." );
_LIT( KReadingMsg,    "Reading content..." );
_LIT( KStar,          "*" );

void CAOExampleAppUi::ToState(CAOExampleEngine::TStates aState)
    {
    // show info about the activity in the in the editor component.
    TPtrC msg;
    switch( aState )
        {
        case CAOExampleEngine::ELookingUpIP:
            msg.Set( KLookingMsg );
            break;
        case CAOExampleEngine::EConnecting:
            msg.Set( KConnectingMsg );
            break;
        case CAOExampleEngine::EWriting:
            msg.Set( KRequestingMsg );
            break;
        case CAOExampleEngine::EReading:
            msg.Set( KReadingMsg) ;
            if( iPrevState == CAOExampleEngine::EReading )
                {
                msg.Set( KStar );
                }
            break;
        default: break;
        }
    iPrevState = aState;
    TRAPD( ignored, iAppContainer->AppendTextL( msg ) );
    }

⌨️ 快捷键说明

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