📄 apron.c
字号:
/*=====================================================================
APRON - SVG Viewer
FILE
apron.c
GENERAL DESCRIPTION
Apron is a SVG Viewer application written using BREW APIs.
All svg & svgz content based on SVG Tiny 1.2 specification can be
viewed. The content can be animated or non-animated. Interactive
content which accepts focus or pointer events can also be viewed
& interacted. Zoom & Pan operations can be performed depending on
the content's support. Content with embedded audio/video or scripts
cannot be viewed
EXTERNALIZED FUNCTIONS
boolean apron_InitAppData(apron* pMe);
void apron_FreeAppData(apron* pMe);
INITIALIZATION AND SEQUENCING REQUIREMENTS
None.
Copyright (c) 2008
by QUALCOMM Incorporated. All Rights Reserved.
======================================================================*/
/*=====================================================================
EDIT HISTORY FOR MODULE
This section contains comments describing changes made to the module.
Notice that changes are listed in reverse chronological order.
$Header: //brewplus/extensions/SVG/main/brew_3.1/sdk/examples/apron/apron.c#3 $
when who what, where, why
-------- --- --------------------------------------------------------
07/19/06 rk Used ARROW Keys instead of SOFT keys to navigate
to Options Menu
07/18/06 rk Added headers & descriptions for code sections
09/18/06 rk Added viewport related calls as per SDK rel 0.0.2
======================================================================*/
/*=====================================================================
INCLUDE FILES FOR MODULE
======================================================================*/
#include "apron.h"
/*=====================================================================
DEFINITIONS AND DECLARATIONS FOR MODULE
======================================================================*/
/*=====================================================================
Typedefs
======================================================================*/
/*=====================================================================
Constants and Macros
======================================================================*/
/*=====================================================================
Variables
======================================================================*/
/*=====================================================================
FUNCTION DECLARATIONS FOR MODULE
======================================================================*/
static boolean apron_HandleEvent(
apron * pMe,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
/*=====================================================================
File related Functions
======================================================================*/
static uint16 apron_GetContentCount(
IFileMgr * pFileMgr,
char * contentDir);
static uint16 apron_GetContentTypeIconResId(
char * fileXtn);
static boolean apron_IsContentTypeSupported(
char * fileXtn);
static boolean apron_GetFileNameAndExtension(
char * fileNameWithXtn,
char * fileName,
char * fileXtn);
/*=====================================================================
Content Playback Functions
======================================================================*/
static boolean apron_ContentPlay(
apron * pMe,
char * fileName,
boolean bRepeatPlay);
static void apron_ContentPlayCallback(
void * pUser,
AEEMediaCmdNotify * pNotify);
/*=====================================================================
State Handlers
======================================================================*/
static boolean apron_SVGViewerCore(
apron * pMe,
apron_app_event_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_StateEntry(
apron * pMe,
apron_app_event_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_DisplayStatus(
apron * pMe,
apron_app_state_enum stateType);
static boolean apron_StateOptionsMenu(
apron * pMe,
apron_app_state_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_StateHelp(
apron * pMe,
apron_app_state_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_StateAbout(
apron * pMe,
apron_app_state_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_StateContentMenu(
apron * pMe,
apron_app_state_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_StateContentPlay(
apron * pMe,
apron_app_state_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_StateContentPause(
apron * pMe,
apron_app_state_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_StateContentStop(
apron * pMe,
apron_app_state_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static boolean apron_StateInvalid(
apron * pMe,
apron_app_state_enum appEvent,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static apron_app_event_enum apron_GetStateEvent(
apron * pMe,
apron_app_state_enum appState,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static apron_app_event_enum apron_GetContentMenuEvent(
apron * pMe,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static apron_app_event_enum apron_GetContentPlayEvent(
apron * pMe,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static apron_app_event_enum apron_GetContentPauseEvent(
apron * pMe,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static apron_app_event_enum apron_GetContentStopEvent(
apron * pMe,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static apron_app_event_enum apron_GetOptionsMenuEvent(
apron * pMe,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static apron_app_event_enum apron_GetHelpEvent(
apron * pMe,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
static apron_app_event_enum apron_GetAboutEvent(
apron * pMe,
AEEEvent eCode,
uint16 wParam,
uint32 dwParam);
/*=====================================================================
Menu Related Functions
======================================================================*/
static boolean apron_DisplayMenu(
IMenuCtl * menuCtl,
boolean bEnable);
static boolean apron_EnableMenu(
IMenuCtl * menuCtl,
boolean bEnable);
static boolean apron_ToggleMenu(
IMenuCtl * menuCtl);
static boolean apron_AddOptionsMenu(
IMenuCtl * pMenu,
const char * resFile,
uint16 menuTitleId,
apron_menu_info_struct * pMenuInfo,
int numMenu);
static boolean apron_DisplaySplashScreen(
apron * pMe);
static boolean apron_BuildOptionsMenu(
apron * pMe,
apron_app_event_enum appEvent);
static boolean apron_DisplayContentMenu(
apron * pMe);
static boolean apron_BuildContentMenu(
apron * pMe,
char * path);
static boolean apron_BuildContextMenu(
apron * pMe,
apron_app_state_enum context);
static boolean apron_SetAllMenuProperties(
apron * pMe);
static uint16 apron_GetCurrentOption(
apron * pMe,
apron_app_event_enum appEvent);
static boolean apron_SetSelection(
IMenuCtl * pMenu,
uint16 itemId,
boolean bEnable);
/*=====================================================================
Cursor Functions
======================================================================*/
static boolean apron_ShowPointer(
apron * pMe);
/*=====================================================================
State Init/Cleanup Functions
======================================================================*/
static boolean apron_AppStart(
apron * pMe);
static boolean apron_AppEnd(
apron * pMe);
/*=====================================================================
State Transition Functions
======================================================================*/
static boolean apron_TransitStateToContentMenu(
apron * pMe);
static boolean apron_TransitStateToContentPlay(
apron * pMe,
apron_content_order_enum contentOrder,
uint16 fileId);
/*=====================================================================
Unclassified Functions
======================================================================*/
static void apron_GetNextFrame(
apron * pMe,
int32 time);
static void apron_CancelNextFrame(
apron * pMe);
static void apron_GenerateFrame(
void * pData);
/*===============================================================================
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 IDisplay_InitAppData().
This is done as follows: InitAppData() is called to initialize AppletData
instance. It is app developers responsibility to fill-in app data initialization
code of InitAppData(). App developer is also responsible to release memory
allocated for data contained in AppletData -- this can be done in
IDisplay_FreeAppData().
PROTOTYPE:
int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)
PARAMETERS:
clsID: [in]: Specifies the ClassID of the applet which is being loaded
pIShell: [in]: Contains pointer to the IShell object.
pIModule: pin]: Contains pointer to the IModule object 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
AEE_SUCCESS: If the app needs to be loaded and if AEEApplet_New() invocation was
successful
EFAILED: 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;
if( ClsId == AEECLSID_APRON )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(apron),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)apron_HandleEvent,
(PFNFREEAPPDATA)apron_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(apron_InitAppData((apron*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
apron_FreeAppData((apron*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);
}
/*===========================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -