📄 biaofengmainwindow.cpp
字号:
/*
* BiaofengMainWindow.cpp
*
* Created on: 2009-4-24
* Author: IBM
*/
#include <eikstart.h>
#include <eiklabel.h>
#include <f32file.h>
#include <eikedwin.h>
#include <aknappui.h>
#include <e32std.h>
#include <aknutils.h>
#include <bautils.h>
#include <apgtask.h>
#include "BiaofengMainWindow.h"
#include "BiaofengAppView.h"
#include "ImageHelper.h"
#include <Biaofeng_0xE4A1DB93.rsg>
//////////////////////////////////////////////////////////////////////////////
//
// -----> CMainWinControl(implementation)
//
//////////////////////////////////////////////////////////////////////////////
CMainWinControl::CMainWinControl()
{
iStartLogo=0;
iTimeCount=0;
TInt k=0;
for( k=0; k<MAX_PIC_NUM; k++ )
iImageArray[k]=NULL ;
}
CMainWinControl::~CMainWinControl()
{
delete iMap;
iMap = NULL;
delete iMapMask;
iMapMask = NULL;
delete iAreaControl;
iAreaControl = NULL;
if( iContainer ) { delete iContainer; iContainer=NULL; }
if( iLabel1 ) { delete iLabel1; iLabel1=NULL; }
if( iImage_bk01 ) { delete iImage_bk01; iImage_bk01=NULL; }
if( iImage_logo ) { delete iImage_logo; iImage_logo=NULL; }
TInt i=0;
for(i=0;i<=18;i++)
{
if(iImageArray[i])
{
delete iImageArray[i];
iImageArray[i]=NULL;
}
}
if( m_BackSurface )
{
delete m_BackSurface;
m_BackSurface=NULL;
}
if( pEdwin )
{
delete pEdwin;
pEdwin=NULL;
}
}
TBool CMainWinControl::LoadImage()
{
// MAX_PIC_NUM
// iImage_bk01 = CXPic::LoadL( m_PrivatePath ,_L("bg01.png"));
// if( !iImageArray[0] || !iImageArray[0]->m_bIsLoadFinish )
iImageArray[0]= iImage_logo;
iImageArray[1]= iImage_bk01;
//if( !iImageArray[2] || !iImageArray[2]->m_bIsLoadFinish )
iImageArray[2]= CXPic::LoadL( m_PrivatePath ,_L("bottombg.png") );
iImageArray[3]= CXPic::LoadL( m_PrivatePath ,_L("bottom02.png") );
iImageArray[4]= CXPic::LoadL( m_PrivatePath ,_L("bottom_left2.png") );
iImageArray[5]= CXPic::LoadL( m_PrivatePath ,_L("bottom_right2.png") );
iImageArray[6]= CXPic::LoadL( m_PrivatePath ,_L("title01.png") );
// iImageArray[7]= CXPic::LoadL( m_PrivatePath ,_L("title02.png") );
iImageArray[8]= CXPic::LoadL( m_PrivatePath ,_L("titlelogo.png") );
iImageArray[9]= CXPic::LoadL( m_PrivatePath ,_L("menubook1.png") );
// iImageArray[10]= CXPic::LoadL( m_PrivatePath ,_L("menubook2.png") );
iImageArray[11]= CXPic::LoadL( m_PrivatePath ,_L("menudown1.png") );
iImageArray[12]= CXPic::LoadL( m_PrivatePath ,_L("menudown2.png") );
iImageArray[13]= CXPic::LoadL( m_PrivatePath ,_L("menufile1.png") );
// iImageArray[14]= CXPic::LoadL( m_PrivatePath ,_L("menufile2.png") );
iImageArray[15]= CXPic::LoadL( m_PrivatePath ,_L("menunet1.png") );
// iImageArray[16]= CXPic::LoadL( m_PrivatePath ,_L("menunet2.png") );
iImageArray[17]= CXPic::LoadL( m_PrivatePath ,_L("menurecom1.png") );
// iImageArray[18]= CXPic::LoadL( m_PrivatePath ,_L("menurecom2.png") );
// iImageArray[19]= CXPic::LoadL( m_PrivatePath ,_L("text_title01.png") );
iImageArray[20]= CXPic::LoadL( m_PrivatePath ,_L("searchicon.png") );
return ETrue;
}
// CMainWinControl needs a ConstructL(), because it is a compound control
// (and a window-owning control).
void CMainWinControl::ConstructL(const TRect& rect, CBiaofengAppUi* aAppUi )
{
// Make this a window-owning control.
CreateWindowL();
SetRect(rect);
iBiaofengAppUi=aAppUi;
iCurrentPage=this;
//TRect allRect= TRect(0,0,240,320);
//iAppView = CBiaofengAppView::NewL(ClientRect());
iAppView=NULL;
#if 1
iAppView = CBiaofengAppView::NewL( rect ,this );
iAppView->SetContainerWindowL(*this);
iCurrentPage=iAppView;
#endif
#if 0
iLabel1 = new(ELeave) CEikLabel;
iLabel1->SetContainerWindowL(*this);
iLabel1->SetTextL(_L("Hello yang."));
#endif
iContainer=NULL;
#if 0
// Create its only component, a CSmileyContainer
iContainer = new(ELeave) CSmileyContainer;
iContainer->SetContainerWindowL(*this);
TRect containerRect=Rect();
iContainer->ConstructL(containerRect);
iCurrentPage=iContainer;
#endif
// Activate the main window control - this will also activate the
// CSmileyContainer and its components.
//######################################################################
// \data\z\private\10003a3f\apps\ \data\z\resource\apps\
#if 1
//#############################################
_LIT(KTestDir,"bfImagePng\\");
RFs fsSession;
User::LeaveIfError(fsSession.Connect());
//CleanupClosePushL( fsSession );
TFileName name;
TFileName path;
//fsSession.PrivatePath( name );
fsSession.PrivatePath( m_PrivatePath );
User::LeaveIfError(fsSession.SessionPath(path));
#if 0
// 1 Create the private path - it is not automatically created by Symbian OS.
// 2. Get the name of the private path
// 3. Create the new directory level f32test\ within the private path
// 4. Set the session path to \private\0fffff04\f32test.
User::LeaveIfError(fsSession.CreatePrivatePath(EDriveC));
fsSession.PrivatePath(path);
path.Append(KTestDir);
User::LeaveIfError(fsSession.MkDir(path));
#endif
// User::LeaveIfError(fsSession.SetSessionPath(path));
#ifdef __WINS__
m_PrivatePath.Insert(0,_L("c:")); //c: z:
//_LIT8( KFromType ,"z:\\resource\\apps\\" );
//m_PrivatePath.Copy(KFromType);
#else
TParsePtrC parse( CEikonEnv::Static()->EikAppUi()->Application()->AppFullName() );
TFileName drive = parse.DriveAndPath();
m_PrivatePath.Insert(0,drive.Left(2));
//name.Insert( 0, parse.Drive() );
#endif
fsSession.Close();
TRect rect1(0,0,240,320);
m_BackSurface = CXSurface::NewL( rect.Size() );
// m_BackSurface = CXSurface::NewL( ClientRect().Size());
// CXPic *pic1= CXPic::CreatL(rect1.Size()); // bg01.png index.png
iImage_logo = CXPic::LoadL( m_PrivatePath ,_L("index.png"));
iImage_bk01 = CXPic::LoadL( m_PrivatePath ,_L("bg01.png"));
/*
* 2009-4-30
* Desciptor:
* */
_LIT(KImagePath,"..\\E4A1DB93\\bg02.png");
iImage_bg02 = CXPic::LoadL(KImagePath(),_L("bg02.png"));
LoadImage();
#endif
// iPeriodicTimer = CPeriodic::NewL(CActive::EPriorityStandard);
// iPeriodicTimer->Start( 200000, 200000, TCallBack( CMainWinControl::TimerFun, this ) );
//############################################################################
ActivateL();
iMap = new (ELeave)CFbsBitmap;
iMapMask = new(ELeave)CFbsBitmap;
LoadMap();
TTag tag;
TBuf<32> text;
iAreaControl = new (ELeave) CMySelectionControl;
tag.Reset();
CEikonEnv::Static()->ReadResource( text, R_MY_REGISTERVIEW_LABEL6 );//"鍦板尯锛�"
tag.AppendAttribule(KSelectName,KAreaText);
tag.AppendAttribule(KLabel,text);
iAreaControl->ParseTag(tag);
AddControlL(iAreaControl,1);
}
void CMainWinControl::LoadMap()
{
RFs fs = CEikonEnv::Static()->Static()->FsSession();
CImageHelper* imgHelper = CImageHelper::NewL(fs);
CleanupStack::PushL(imgHelper);
// 构建文件名
_LIT(KResourcePath, "c:\\resource\\apps\\E4A1DB93\\");
TFileName fileName(KResourcePath);
fileName.Append(_L("bg02"));
_LIT(KExtension, ".png");
fileName.Append(KExtension);
imgHelper->LoadPngImageL(fileName, iMap, iMapMask);
iIsLoadFinished = ETrue;
CleanupStack::Pop(imgHelper);
delete imgHelper;
imgHelper = NULL;
// 强制重绘
DrawNow();
}
TInt CMainWinControl::TimerFun(TAny* aPtr)
{
(static_cast<CMainWinControl*>(aPtr))->ReFresh();
return ETrue;
}
void CMainWinControl::ReFresh()
{
iPeriodicTimer->Cancel();
CWindowGc& gc = SystemGc();
// gc.Activate(*DrawableWindow());
// gc.BitBlt(Rect().iTl,m_BackSurface->GetFbsBitmap());
//gc.BitBlt( TPoint(0,0), iImage_logo->m_iBitmap );
//gc.Deactivate();
iCurrentPage->DrawNow();
// DrawNow();
iTimeCount++;
if( iTimeCount>20 )
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -