📄 bluegpsclientappview.cpp
字号:
/*****************************************************************************
COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2003.
The software is the copyrighted work of Sony Ericsson Mobile Communications AB.
The use of the software is subject to the terms of the end-user license
agreement which accompanies or is included with the software. The software is
provided "as is" and Sony Ericsson specifically disclaim any warranty or
condition whatsoever regarding merchantability or fitness for a specific
purpose, title or non-infringement. No warranty of any kind is made in
relation to the condition, suitability, availability, accuracy, reliability,
merchantability and/or non-infringement of the software provided herein.
*****************************************************************************/
#include "BlueGPSClient.h"
#include "BlueGPSClientAppView.h"
#include "fbs.h"
CBlueGPSClientAppView* CBlueGPSClientAppView::NewL(const TRect& aRect)
{
CBlueGPSClientAppView * self = new(ELeave) CBlueGPSClientAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
CleanupStack::Pop();
return self;
}
CBlueGPSClientAppView::~CBlueGPSClientAppView()
{
delete iHelloText;
}
void CBlueGPSClientAppView::ConstructL(const TRect& aRect)
{
CreateWindowL();
SetRect(aRect);
ActivateL();
// Fetch the text from the resource file.
// iHelloText = iEikonEnv->AllocReadResourceL(R_BlueGPSClient_TEXT_HELLO);
_LIT( gpsText, " BlueGPS developer" );
iHelloText = gpsText().AllocL();
iInfoBuf2.Copy(gpsText);
// set the name of the multi-bitmap file containing the bitmaps
_LIT(KMBMFileName,"c:\\documents\\kista.mbm");
// load the bitmap from an .mbm file
bitmap = new (ELeave) CFbsBitmap();
User::LeaveIfError(bitmap->Load(KMBMFileName, 0));
iPos.SetXY(0,0);
iViewMode = ETextViewMode;
}
void CBlueGPSClientAppView::SetText1( TDes& aText )
{
iInfoBuf1.Copy(aText);
// iInfoText = iInfoBuf;
// DrawNow();
}
void CBlueGPSClientAppView::SetText2( TDes& aText )
{
iInfoBuf2.Copy(aText);
// iInfoText = iInfoBuf;
// DrawNow();
}
void CBlueGPSClientAppView::SetText3( TDes& aText )
{
iInfoBuf3.Copy(aText);
// iInfoText = iInfoBuf;
// DrawNow();
}
void CBlueGPSClientAppView::SetText4( TDes& aText )
{
iInfoBuf4.Copy(aText);
// iInfoText = iInfoBuf;
// DrawNow();
}
void CBlueGPSClientAppView::SetText5( TDes& aText )
{
iInfoBuf5.Copy(aText);
// iInfoText = iInfoBuf;
// DrawNow();
}
void CBlueGPSClientAppView::SetText6( TDes& aText )
{
iInfoBuf6.Copy(aText);
// iInfoText = iInfoBuf;
// DrawNow();
}
void CBlueGPSClientAppView::UpdatePosition( TInt aX, TInt aY )
{
iPos.SetXY(104 - aX, 120 - aY);
// DrawNow();
}
void CBlueGPSClientAppView::SetViewMode(TInt aViewMode)
{
iViewMode = aViewMode;
}
void CBlueGPSClientAppView::Draw(const TRect& /*aRect*/) const
{
// Window graphics context
CWindowGc& gc = SystemGc();
TInt baseline;
const CFont* font = iEikonEnv->TitleFont();
TRect rect;
// Start with a clear screen
gc.Clear();
switch (iViewMode)
{
case ETextViewMode:
rect = Rect();
rect.Shrink(5,5);
gc.DrawRect(rect);
rect.Shrink(5,5);
gc.UseFont(font);
baseline = rect.Height()*0.2 - font->AscentInPixels()/2;
gc.DrawText(iInfoBuf3, rect, baseline, CGraphicsContext::ELeft);
baseline = rect.Height()*0.3 - font->AscentInPixels()/2;
gc.DrawText(iInfoBuf1, rect, baseline, CGraphicsContext::ELeft);
baseline = rect.Height()*0.4 - font->AscentInPixels()/2;
gc.DrawText(iInfoBuf2, rect, baseline, CGraphicsContext::ELeft);
baseline = rect.Height()*0.5 - font->AscentInPixels()/2;
gc.DrawText(iInfoBuf4, rect, baseline, CGraphicsContext::ELeft);
baseline = rect.Height()*0.6 - font->AscentInPixels()/2;
gc.DrawText(iInfoBuf5, rect, baseline, CGraphicsContext::ELeft);
baseline = rect.Height()*0.7 - font->AscentInPixels()/2;
gc.DrawText(iInfoBuf6, rect, baseline, CGraphicsContext::ELeft);
gc.DiscardFont();
break;
case EGraphicsViewMode:
// set a rectangle for the top-left quadrant of the source bitmap
/* TSize bmpSizeInPixels=bitmap->SizeInPixels();
TSizebmpPieceSize(bmpSizeInPixels.iWidth/2,bmpSizeInPixels.iHeight/2);
TRect bmpPieceRect(TPoint(0,0),bmpPieceSize);
*/
// blit only the piece of the bitmap indicated by bmpPieceRect
// gc.BitBlt(pos, bitmap, bmpPieceRect);
gc.BitBlt(iPos, bitmap);
TPoint center(104, 120);
TSize size(2,2);
TRgb color(255,255,255);
gc.SetPenColor(color);
gc.SetPenSize(size);
TPoint linePoint1(center.iX - 5, center.iY - 5);
TPoint linePoint2(center.iX - 5, center.iY + 5);
TPoint linePoint3(center.iX + 6, center.iY - 6);
TPoint linePoint4(center.iX + 6, center.iY + 6);
gc.DrawLine(linePoint1, linePoint4);
gc.DrawLine(linePoint2, linePoint3);
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -