📄 tcpex_appui.cpp
字号:
// TCPEx_CTCPExAppUi.cpp
// ----------------------------
//
// Copyright (c) 2002 Symbian Ltd. All rights reserved.
//
////////////////////////////////////////////////////////////////////////
//
// Source file for the implementation of the
// application UI class - CTCPExAppUi
//
////////////////////////////////////////////////////////////////////////
// To enable the dynamic loading of the menu with a Close command in the UDEB version
#include <eikmenub.h>
#include "TCPEx.h"
#include <HttpStringConstants.h>
#include <http\mhttpdatasupplier.h>
namespace // anon
{
_LIT(KDemoURL,"http://www.google.com");
} // anon namespace
// The second phase constructor of the application UI class.
// The application UI creates and owns the one and only view.
//
void CTCPExAppUi::ConstructL()
{
// BaseConstructL() completes the UI framework's
// construction of the App UI.
BaseConstructL();
// Create the single application view in which to
// draw the text "Hello World!", passing into it
// the rectangle available to it.
iAppView = CTCPExAppView::NewL(ClientRect());
iRetriever = CRetrieveHttp::NewL(*this) ;
}
// The app Ui owns the two views and is.
// therefore, responsible for destroying them
//
CTCPExAppUi::~CTCPExAppUi()
{
delete iAppView;
}
// Called by the UI framework when a command has been issued.
// In this example, a command can originate through a
// hot-key press or by selection of a menu item.
// The command Ids are defined in the .hrh file
// and are 'connected' to the hot-key and menu item in the
// resource file.
// Note that the EEikCmdExit is defined by the UI
// framework and is pulled in by including eikon.hrh
//
void CTCPExAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
// begin a transaction?
case EMenuGo:
switch(iAppView->State()) // enforce sequential requests
{
// states that are ok to beginning fetching
case EIdle:
case EComplete:
case EFailed:
{
iAppView->SetState(EResolving);
StartRequest(KDemoURL);
}
break;
// else a state where we are inside a transaction already
default:
{
User::InfoPrint(_L("busy"));
}
}
break;
// Exit the application. The call is
// implemented by the UI framework.
case EEikCmdExit:
Exit();
break;
}
}
// This is a way to dynamically initialize the menu.
void CTCPExAppUi::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane)
{
if(aMenuId == R_MAIN_MENU)
{
// If it is the debug version, the menu should contain a Close command.
// In releaseable versions, there should be no Close command. But this is
// an example app only, so we always want a close button
//#if defined(_DEBUG)
CEikMenuPaneItem::SData itemData;
TBuf<16> closeCommandText;
iEikonEnv->ReadResource(closeCommandText, R_CLOSE_COMMAND);
itemData.iText=closeCommandText;
itemData.iCommandId=EEikCmdExit;
itemData.iFlags=0;
itemData.iCascadeId=0;
aMenuPane->AddMenuItemL(itemData);
//#endif
}
}
//*** methods from MRetrieveHttpCallback ***
void CTCPExAppUi::StateChange(TRetrieveHttpProgress aState)
{
iAppView->SetState(aState);
if ((aState == EComplete) ||(aState == EFailed))
iAppView->SetTextL(iRetriever->GetResponseData());
}
//*** doers ***
void CTCPExAppUi::StartRequest(const TDesC& aUri)
{
iRetriever->RequestL(aUri) ;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -