exam0303newguiappview.cpp
来自「国内著名嵌入式培训机构内部资料,内含一些实例代码,包括技术专题书籍」· C++ 代码 · 共 133 行
CPP
133 行
/*
============================================================================
Name : Exam0303NewGuiAppView.cpp
Author :
Copyright : Your copyright notice
Description : Application view implementation
============================================================================
*/
// INCLUDE FILES
#include <coemain.h>
#include <EIKENV.H>
#include "Exam0303NewGuiAppView.h"
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CExam0303NewGuiAppView::NewL()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CExam0303NewGuiAppView* CExam0303NewGuiAppView::NewL(const TRect& aRect)
{
CExam0303NewGuiAppView* self = CExam0303NewGuiAppView::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
// -----------------------------------------------------------------------------
// CExam0303NewGuiAppView::NewLC()
// Two-phased constructor.
// -----------------------------------------------------------------------------
//
CExam0303NewGuiAppView* CExam0303NewGuiAppView::NewLC(const TRect& aRect)
{
CExam0303NewGuiAppView* self = new ( ELeave ) CExam0303NewGuiAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
// -----------------------------------------------------------------------------
// CExam0303NewGuiAppView::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CExam0303NewGuiAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();
// Set the windows size
SetRect(aRect);
m_pRefreshTimer=CUiRefreshTimer::NewL();
m_pRefreshTimer->SetObserver(this);
m_pRefreshTimer->StartL(1000*1000);
// Activate the window, which makes it ready to be drawn
ActivateL();
}
// -----------------------------------------------------------------------------
// CExam0303NewGuiAppView::CExam0303NewGuiAppView()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CExam0303NewGuiAppView::CExam0303NewGuiAppView()
{
// No implementation required
m_pRefreshTimer=NULL;
}
// -----------------------------------------------------------------------------
// CExam0303NewGuiAppView::~CExam0303NewGuiAppView()
// Destructor.
// -----------------------------------------------------------------------------
//
CExam0303NewGuiAppView::~CExam0303NewGuiAppView()
{
// No implementation required
if(m_pRefreshTimer)
{
delete m_pRefreshTimer;
m_pRefreshTimer=NULL;
}
}
// -----------------------------------------------------------------------------
// CExam0303NewGuiAppView::Draw()
// Draws the display.
// -----------------------------------------------------------------------------
//
void CExam0303NewGuiAppView::Draw(const TRect& /*aRect*/) const
{
// Get the standard graphics context
CWindowGc& gc = SystemGc();
// Gets the control's extent
TRect drawRect(Rect());
// Clears the screen
gc.Clear(drawRect);
//draw current time
TTime tCur;
tCur.HomeTime();
TBuf<256> timeAsText;
_LIT ( KTimeFormat, "%D%M%Y%/0%1%/1%2%/2%3%/3 %H:%T:%S " );
tCur.FormatL( timeAsText, KTimeFormat );
gc.UseFont( CEikonEnv::Static()->DenseFont());
gc.DrawText(timeAsText,TPoint(10,40));
gc.DiscardFont();
}
// -----------------------------------------------------------------------------
// CExam0303NewGuiAppView::SizeChanged()
// Called by framework when the view size is changed.
// -----------------------------------------------------------------------------
//
void CExam0303NewGuiAppView::SizeChanged()
{
DrawNow();
}
void CExam0303NewGuiAppView::NotifyRefresh()
{
DrawDeferred();
}
// End of File
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?