ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 蔡鸟的一些学习笔记- 框架研究杂七杂八(转)

蔡鸟的一些学习笔记- 框架研究杂七杂八(转)

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-05-13 20:24:04 0 删除 编辑
1.创建应用程序
#include "RetroApplication.h"

GLDEF_C TInt E32Dll(TDllReason)
{
return KErrNone;
}

//创建一个新的应用程序对象,并返回指向该对象的基类对象指针
//APPARC.H
// base class for applications; allows creation of documents & file stores + display of app icon and name.
//CApaApplication,该类是应用程序的基类,允许创建文档和文件存储,显示应用程序图标和名称。
//类的继承结构
//CRetroApplication<--CAknApplication<--CEikApplication<--CApaApplication<--CBase
EXPORT_C CApaApplication * NewApplication()
{
return (new CRetroApplication);
}


2. 应用程序对象
class CRetroApplication:public CAknApplication
{
public:
// from CEikApplication
//返回应用程序UID
TUid AppDllUid() const;
protected:
// from CEikApplication
//创建新的文档对象,并返回指向该对象的基类对象指针
// CApaDocument is base class for documents; allows insertion of glass doors.
//CApaDocument 该类是文档类的指针,允许玻璃窗户的插入
//类的继承结构
//CRetroDocument<--CEikDocument<--CApaDocument<--CBase
CApaDocument* CreateDocumentL();
}

3. 文档对象
class CRetroAppUi;
class CEikApplication;
class CRetroDocument : public CEikDocument
{
public:
//NewL 调用NewLC,NewLC调用ConstructL
static CRetroDocument* NewL(CEikApplication& aApp);
static CRetroDocument* NewLC(CEikApplication& aApp);
~CRetroDocument();
private:
void ConstructL();
CRetroDocument(CEikApplication& aApp);
//创建应用程序用户界面对象,并返回指向该对象的基类对象指针
//类继承体系
//CRetroAppUi<--CAknAppUi<--CEikAppUi,MEikStatusPaneObserver,MCoeViewDeactivationObserver
//CEikAppUi<--CCoeAppUi, MEikMenuObserver, MCoeMessageObserver, MObjectProvider
//CCoeAppUi<--CCoeAppUiBase<---CBase
///**
* The CCoeAppUiBase class is the abstract base class for all application-wide user interface classes.
*/
CEikAppUi* CreateAppUiL();
};


4. 用户界面对象
class CRetroAppView;
class CRetroAppUi : public CAknAppUi
{
public:
//创建应用程序视图,用户能看到的真正的界面。
//视图类继承体系
//CRetroAppView<--CCoeControl<-- CBase, MObjectProvider
/**
* The CCoeControl class is the base class for all controls.
*/
void ConstructL()
{
BaseConstructL();
// Create the application view
// iAppView = CRetroAppViewOld::NewL(ApplicationRect());
iAppView = CRetroAppView::NewL(ApplicationRect());
AddToStackL(iAppView);
}
CRetroAppUi();
~CRetroAppUi();
public:
// from CEikAppUi
//处理菜单命令
void HandleCommandL(TInt aCommand);

// The Uikon framework calls this function immediately before the menu pane is activated
void DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane);
private:
//CRetroAppViewOld* iAppView;
CRetroAppView* iAppView;
};

5 . 视图对象
class CImageFactory;
class CRetroEngine;
class CRetroAppView : public CCoeControl
{
public:
static CRetroAppView* NewL(const TRect& aRect);
static CRetroAppView* NewLC(const TRect& aRect);
~CRetroAppView();
public:
// from CCoeControl
void Draw(const TRect& aRect) const;
TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
public:
void StartGameL();
TBool IsPlaying();
void StopGame();
private:
void ConstructL(const TRect& aRect);
CRetroAppView();
private:
TKeyHandler iKeyHandler;
CImageFactory* iImageFactory;
CRetroEngine* iEngine;
};

6. 资源编辑
菜单
在#include "RetroBlaster.hrh"文件中添加ERetroGameExit
enum TRetroCommands
{
ERetroGameStart = 300,
ERetroGameStop,
ERetroGameExit
};

在资源文件中,添加MENU_ITEM {command = ERetroGameExit; txt = "MyExit";}
RESOURCE MENU_PANE r_retro_menupane
{
items =
{
MENU_ITEM {command = ERetroGameStart; txt = "Start Game";},
MENU_ITEM {command = ERetroGameStop; txt = "Stop Game";},
MENU_ITEM {command = EAknSoftkeyExit; txt = "Exit";},
MENU_ITEM {command = ERetroGameExit; txt = "MyExit";}
};
}

在appUi,HandleCommandL函数中添加
case ERetroGameExit:
Exit();
break;
在appUi,DynInitMenuPaneL函数中添加
aMenuPane->SetItemDimmed(ERetroGameExit,EFalse);

7 在命令行模式下用bmconv创建multibitmap文件
把几个bmp图片融合到一个文件中,并产生.h和.mbm文件供程序使用。程序可以通过这些文件
把位图加载到屏幕。
例如:在命令行,导航到c:myworkimage目录下,此目录有图片image1.bmp,image2.bmp,image3.bmp
执行bmconv /hmyHeadFile.h myMbmFile.mbm /4image1.bmp /1image2.bmp /c16image3.bmp

//myHeadFile.h c:myworkimagemyHeadFile.h
// Generated by BitmapCompiler
// Copyright (c) 1998-2000 Symbian Ltd. All rights reserved.
//
enum TMbmImages
{
EMbmImagesImage1,
EMbmImagesImage2,
EMbmImagesImage3
};

//appView.h
/** background bitmap */
CFbsBitmap* iBackgroundImage;
/** "sprite" image */
CFbsBitmap* iSpriteImage;
/** "sprite" mask */
CFbsBitmap* iSpriteMask;

//appView.cpp 使用
#include "myHeadFile.h"
_LIT (KMultiBitmapFilename,"c:\System\Apps\Graphics\myMbmFile.mbm");
// Load in the bitmap images from the multi bitmap file
iBackgroundImage = NBitmapMethods::CreateBitmapL(KMultiBitmapFilename,EMbmImagesImage1);
iSpriteImage = NBitmapMethods::CreateBitmapL(KMultiBitmapFilename,EMbmImagesImage2);
iSpriteMask = NBitmapMethods::CreateBitmapL(KMultiBitmapFilename,EMbmImagesImage3);

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-126289/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    3488
  • 访问量
    2603759