📄 simpleex_view.cpp
字号:
// simpleEx_view.cpp
//
// Copyright (c) Symbian Software Ltd 1999 - 2007. All rights reserved.
//
/*=================================================================
File: simpleEx_view.cpp
This file contains the application view class for SimpleEx.
==================================================================*/
#include "eikenv.h"
#include <coemain.h>
#include "SimpleEx.h"
#include <SimpleExWthr.rsg>
#include <QikCommand.h>
CSimpleExAppView* CSimpleExAppView::NewL(CQikAppUi& aAppUi)
{
CSimpleExAppView* self = CSimpleExAppView::NewLC(aAppUi);
CleanupStack::Pop(self);
return self;
}
CSimpleExAppView* CSimpleExAppView::NewLC(CQikAppUi& aAppUi)
{
CSimpleExAppView* self = new (ELeave) CSimpleExAppView(aAppUi);
CleanupStack::PushL(self);
self->ConstructL();
return self;
}
CSimpleExAppView::CSimpleExAppView(CQikAppUi& aAppUi)
: CQikViewBase(aAppUi, KNullViewId)
{
}
CSimpleExAppView::~CSimpleExAppView()
{
delete iWeather;
}
void CSimpleExAppView::ConstructL()
{
BaseConstructL();
iWeather = CWeatherInfo::NewL(*this);
}
void CSimpleExAppView::ViewConstructL()
{
// Loads information about the UI configurations this view supports
// together with definition of each view.
ViewConstructFromResourceL(R_SIMPLEEX_CONFIGURATIONS);
}
TVwsViewId CSimpleExAppView::ViewId()const
{
return TVwsViewId(KUidSimpleExApp, KUidSimpleExView);
}
void CSimpleExAppView::Draw(const TRect& ) const
{
CWindowGc& gc = SystemGc();
const CFont* font;
TRect drawRect = Rect();
gc.Clear();
font = iEikonEnv->TitleFont();
gc.UseFont(font);
TInt baselineOffset=(drawRect.Height() - font->HeightInPixels())/2;
gc.DrawText(_L("Simple Example"),drawRect,baselineOffset,CGraphicsContext::ECenter, 0);
gc.DiscardFont();
}
void CSimpleExAppView::TemperatureReport(TDesC& aCity, TDesC& aTemperature)
{
TBuf<50> str;
_LIT(KTempTitle,"Report:");
_LIT(KTempMessage,"Temperature in %S is %S");
str.Format(KTempMessage,&aCity,&aTemperature);
TRAPD(err,iEikonEnv->InfoWinL(KTempTitle,str));
}
void CSimpleExAppView::TemperatureError(TDesC& aErrStr,TInt aErrCode)
{
TBuf<50> str;
_LIT(KErrTitle,"Error:");
_LIT(KErrMsg,"%S (%d)");
str.Format(KErrMsg,&aErrStr,aErrCode);
TRAPD(err,iEikonEnv->InfoWinL(KErrTitle,str));
}
void CSimpleExAppView::HandleCommandL(CQikCommand& aCommand)
{
switch(aCommand.Id())
{
case ESimpleExCommand:
{
_LIT(KMessage,"Start Selected!");
iEikonEnv->AlertWin(KMessage);
break;
}
case ESimpleExTemperatureCommand:
{
// Display the temperature in Austin, TX
_LIT(KCityCode,"AUS");
iWeather->GetTemperature(KCityCode);
}
default:
CQikViewBase::HandleCommandL(aCommand);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -