/*===========================================================================
FILE: iimageusage.c
SERVICES: Sample applet using AEE
DESCRIPTION
This file contains usage examples of the IImage interface. IImage interface
functions allow the user to display bitmap objects.
PUBLIC CLASSES:
N/A
Copyright � 2000-2001 QUALCOMM Incorporated.
All Rights Reserved.
QUALCOMM Proprietary/GTDR
===========================================================================*/
/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
// Mandatory includes
#include "AEEAppGen.h" // AEEApplet declaration
#include "AEEUsageAppIDs.h" // Class IDs of usage apps (including this one)
#include "AEE.h" // Standard AEE Declarations
#include "AEEShell.h" // AEE Shell Services
#include "AEEDisp.h" // AEE Display Services
#include "AEEStdLib.h" // AEE StdLib Services
// Services used by app
#include "AEEFile.h" // AEEFile Services
#include "AEEMenu.h" // Menu Services
// App resource header generated by BREW ResourceEditor.
#include "image_res.h"
/*===========================================================================
PUBLIC DATA DECLARATIONS
===========================================================================*/
/*-------------------------------------------------------------------
Type Declarations
-------------------------------------------------------------------*/
// IImage app struct. This is the main struct for this applet. This will hold
// all the data members that need to be remembered throughout the life of
// the applet.
// THE FIRST DATA MEMBER OF THIS STRUCT MUST BE AN AEEApplet OBJECT.
// This is a critical requirement which is related to an applet being
// dynamically loaded. The app developers should add their data members
// following the AEEApplet data member.
typedef struct _CIImageApp {
AEEApplet a;
IMenuCtl * m_pIMenu;
IImage * m_pIImage;
} CIImageApp;
/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
// Mandatory function:
// App Handle Event function
static boolean ImageApp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam);
// App specific data alloc-init/free functions
static boolean IImage_InitAppData(IApplet* pMe);
static void IImage_FreeAppData(IApplet* pMe);
static void BuildMainMenu(CIImageApp *pMe);
static void IImageUsage (CIImageApp *pMe, uint16 wParam);
static void DisplayEvent (CIImageApp *pMe, uint16 wParam);
static void DisplayOutput(CIImageApp * pMe, int nline, char *pszStr);
/*-------------------------------------------------------------------
Global Constant Definitions
-------------------------------------------------------------------*/
// App Resource File
#define APP_RES_FILE "image.bar"
#define SAMPLE_BITMAP_FILE "sample.bmp"
// App specific constants
#define USAGE_BASIC_USAGE 100
#define USAGE_DRAW 101
#define USAGE_DRAWFRAME 102
#define USAGE_GETINFO 103
#define USAGE_SETDATA 104
#define USAGE_SETPARM_SIZE 105
#define USAGE_SETPARM_OFFSET 106
#define USAGE_SETPARM_CXFRAME 107
#define USAGE_SETPARM_ROP_OR 108
#define USAGE_SETPARM_ROP_NOT 109
#define USAGE_SETPARM_ROP_XOR 110
#define USAGE_SETPARM_ROP_COPY 111
#define USAGE_SETPARM_ROP_TRANSPARENT 112
#define USAGE_SETPARM_ROP_MASK 113
#define USAGE_SETPARM_ROP_MERGENOT 114
#define USAGE_SETPARM_ROP_MASKNOT 115
#define USAGE_SETPARM_NFRAMES 116
#define USAGE_SETPARM_RATE 117
#define USAGE_SETPARM_OFFSCREEN 118
#define USAGE_START 119
#define USAGE_STOP 120
#define USAGE_ERASE_SCREEN 121 // Special case to erase screen
#define USAGE_SETSTREAM 122
// Size of buffer used to hold text strings
#define TEXT_BUFFER_SIZE (100 * sizeof(AECHAR))
/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */
/*===========================================================================
FUNCTION: AEEClsCreateInstance
DESCRIPTION
This function is invoked while the app is being loaded. All Modules must provide this
function. Ensure to retain the same name and parameters for this function.
In here, the module must verify the ClassID and then invoke the AEEApplet_New() function
that has been provided in AEEAppGen.c.
After invoking AEEApplet_New(), this function can do app specific initialization. In this
example, a generic structure is provided so that app developers need not change app specific
initialization section every time except for a call to IImage_InitAppData(). This is done as follows:
IImage_InitAppData() is called to initialize CIImageApp instance. It is app developer's
responsibility to fill-in app data initialization code in IImage_InitAppData(). App developer
is also responsible to release memory allocated for data contained in CIImageApp -- this can be
done in IImage_FreeAppData().
PROTOTYPE:
boolean AEEClsCreateInstance(AEECLSID clsID, IShell* pIShell, IModule* pIModule,
void** ppObj)
PARAMETERS:
clsID: [in]: Specifies the ClassID of the applet which is being loaded
pIShell: [in]: Contains pointer to the IShell interface.
pIModule: [in]: Contains pointer to the IModule interface to the current module to which
this app belongs
ppObj: [out]: On return, *ppObj must point to a valid IApplet structure. Allocation
of memory for this structure and initializing the base data members is done by AEEApplet_New().
DEPENDENCIES
none
RETURN VALUE
TRUE: If the app needs to be loaded and if AEEApplet_New() invocation was successful
FALSE: If the app does not need to be loaded or if errors occurred in AEEApplet_New().
If this function returns FALSE, the app will not be loaded.
SIDE EFFECTS
none
===========================================================================*/
int AEEClsCreateInstance(AEECLSID ClsId, IShell* pIShell, IModule* po, void** ppObj)
{
*ppObj = NULL;
// We want to load this App. So, invoke AEEApplet_New().To it, pass the
// address of the app-specific handle event function.
if(ClsId == AEECLSID_IMAGE_APP){
if(AEEApplet_New(sizeof(CIImageApp), ClsId, pIShell,po,(IApplet**)ppObj,
(AEEHANDLER)ImageApp_HandleEvent,(PFNFREEAPPDATA)IImage_FreeAppData))
{
if (IImage_InitAppData((IApplet*)*ppObj))
return(AEE_SUCCESS);
}
}
return (EFAILED);
}
/*===========================================================================
FUNCTION ImageApp_HandleEvent
DESCRIPTION
This is the EventHandler for this app. All events to this app are handled in this
function. All apps must supply an Event Handler.
PROTOTYPE:
boolean ImageApp_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
PARAMETERS:
pi: Pointer to the IApplet structure. This structure contains information specific
to this applet. It was initialized during the AEEClsCreateInstance() function.
ecode: Specifies the Event sent to this applet
wParam, dwParam: Event specific data.
DEPENDENCIES
none
RETURN VALUE
TRUE: If the app has processed the event
FALSE: If the app did not process the event
SIDE EFFECTS
none
==========
- 1
- 2
- 3
- 4
- 5
- 6
前往页