📄 apron.c
字号:
FUNCTION
SampleAppWizard_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 SampleAppWizard_HandleEvent(IApplet * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
PARAMETERS:
pi: Pointer to the AEEApplet 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
===========================================================================*/
static boolean apron_HandleEvent(apron* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
int retStatus = EBADPARM;
if(NULL != pMe->pOptionsMenu)
{
if(IMENUCTL_HandleEvent(pMe->pOptionsMenu, eCode, wParam, dwParam))
{
return TRUE;
}
}
if(NULL != pMe->pContentMenu)
{
if(IMENUCTL_HandleEvent(pMe->pContentMenu, eCode, wParam, dwParam))
{
return TRUE;
}
}
if(NULL != pMe->pContextMenu)
{
if(IMENUCTL_HandleEvent(pMe->pContextMenu, eCode, wParam, dwParam))
{
return TRUE;
}
}
if(NULL != pMe->pReadOnlyMenu)
{
if(ISTATIC_HandleEvent(pMe->pReadOnlyMenu, eCode, wParam, dwParam))
{
return TRUE;
}
}
if(NULL != pMe->pTextInputMenu)
{
if(ITEXTCTL_HandleEvent(pMe->pTextInputMenu, eCode, wParam, dwParam))
{
return TRUE;
}
}
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
// Add your code here...
return (apron_AppStart(pMe));
// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
return(TRUE);
// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...
if(APRON_STATE_CONTENT_PLAY == pMe->appState)
{
retStatus = IMEDIA_Pause(pMe->pMediaSVG);
if(SUCCESS == retStatus)
{
pMe->appState = APRON_STATE_SUSPEND;
}else
{
DBGPRINTF("APRON: About to Suspend App. IMEDIA_Pause() returned: %d", retStatus);
}
}
return(TRUE);
// App is being resumed
case EVT_APP_RESUME:
// Add your code here...
if(APRON_STATE_SUSPEND == pMe->appState)
{
retStatus = IMEDIA_Resume(pMe->pMediaSVG);
if(SUCCESS == retStatus)
{
pMe->appState = APRON_STATE_CONTENT_PLAY;
}else
{
DBGPRINTF("APRON: About to Resume App. IMEDIA_Resume() returned: %d", retStatus);
}
}
return(TRUE);
// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...
return(TRUE);
case EVT_APP_NO_SLEEP:
//To avoid sleeping while content playback >:O)
return (TRUE);
// If nothing fits up to this point then we'll just break out
// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
case EVT_COMMAND:
default:
return (apron_SVGViewerCore(pMe, APRON_EVENT_UNKNOWN, eCode, wParam, dwParam));
break;
}
return FALSE;
}
/*======================================================================
FUNCTION
apron_InitAppData
DESCRIPTION
This function is called when the application is starting up.
DEPENDENCIES
None.
PARAMETERS
pMe [in] : Pointer to Application's structure
RETURN VALUE
TRUE : On Success.
FALSE : On Failure.
SIDE EFFECTS
None.
======================================================================*/
boolean apron_InitAppData(apron* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->deviceInfo.wStructSize = sizeof(pMe->deviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell, &pMe->deviceInfo);
// Insert your code here for initializing or allocating resources...
//Grouping all pointers for ease of use
pMe->pShell = pMe->a.m_pIShell;
pMe->pDisplay = pMe->a.m_pIDisplay;
//Set the area for graphics display
SETAEERECT(&pMe->screenRect, 0, 0, pMe->deviceInfo.cxScreen,
(pMe->deviceInfo.cyScreen - APRON_CONTEXT_MENU_HEIGHT - APRON_STATUS_MENU_HEIGHT));
//Initialize Interfaces
pMe->pContentMenu = NULL;
pMe->pDrawSurface = NULL;
pMe->pOptionsMenu = NULL;
pMe->pReadOnlyMenu = NULL;
pMe->pTextInputMenu = NULL;
pMe->pContextMenu = NULL;
/* Create all Class Object Instances */
if((SUCCESS != ISHELL_CreateInstance(pMe->pShell, AEECLSID_MENUCTL, (void**)(&pMe->pContentMenu))) ||
(SUCCESS != ISHELL_CreateInstance(pMe->pShell, AEECLSID_GRAPHICS, (void**)(&pMe->pDrawSurface))) ||
(SUCCESS != ISHELL_CreateInstance(pMe->pShell, AEECLSID_MENUCTL, (void**)(&pMe->pOptionsMenu))) ||
(SUCCESS != ISHELL_CreateInstance(pMe->pShell, AEECLSID_STATIC, (void**)(&pMe->pReadOnlyMenu))) ||
(SUCCESS != ISHELL_CreateInstance(pMe->pShell, AEECLSID_TEXTCTL, (void**)(&pMe->pTextInputMenu))) ||
(SUCCESS != ISHELL_CreateInstance(pMe->pShell, AEECLSID_ICONVIEWCTL, (void**)(&pMe->pContextMenu))))
{
DBGPRINTF("APRON: Main/Content/Context Menu/Static/Graphics CreateInstance Failed");
return FALSE;
}
//Initialize Sensitivity
pMe->appOptions.pointerSensitivity = (int16)APRON_DEFAULT_SENSITIVITY_POINTER;
pMe->appOptions.panSensitivity = (int16)APRON_DEFAULT_SENSITIVITY_PAN;
pMe->appOptions.rotateSensitivity = (int16)APRON_DEFAULT_SENSITIVITY_ROTATE;
pMe->appOptions.zoomSensitivity = (uint32)APRON_DEFAULT_SENSITIVITY_ZOOM;
pMe->appOptions.frameInterval = APRON_DEFAULT_FRAMEINTERVAL;
pMe->appOptions.seekInterval = APRON_DEFAULT_SEEK_INTERVAL;
//Initialize Repeat Play Mode
pMe->appOptions.bRepeatPlay = FALSE;
//Initialize User Event Type
pMe->appOptions.userEventType = APRON_DEFAULT_USER_EVENT_TYPE;
//IGRAPHICS Init Settings
IGRAPHICS_SetFillMode(pMe->pDrawSurface,TRUE);
IGRAPHICS_SetFillColor(pMe->pDrawSurface, 0xFF, 0x80, 0x00, 0xFF); //Orange
IGRAPHICS_SetColor(pMe->pDrawSurface, 0, 0, 0, 0xFF); //Black
IGRAPHICS_SetViewport(pMe->pDrawSurface, &pMe->screenRect, AEE_GRAPHICS_FRAME);
IGRAPHICS_SetDestination(pMe->pDrawSurface, NULL);
//Initial State
pMe->appState = APRON_STATE_ENTRY;
// if there have been no failures up to this point then return success
return TRUE;
}
/*======================================================================
FUNCTION
apron_FreeAppData
DESCRIPTION
This function is called when the application is exiting.
DEPENDENCIES
None.
PARAMETERS
pMe [in] : Pointer to Application's structure.
RETURN VALUE
None.
SIDE EFFECTS
None.
======================================================================*/
void apron_FreeAppData(apron * pMe)
{
// insert your code here for freeing any resources you have allocated...
// example to use for releasing each interface:
// if ( pMe->pIMenuCtl != NULL ) // check for NULL first
// {
// IMENUCTL_Release(pMe->pIMenuCtl) // release the interface
// pMe->pIMenuCtl = NULL; // set to NULL so no problems trying to free later
// }
apron_AppEnd(pMe);
}
/*======================================================================
FUNCTION
apron_DisplaySplashScreen
DESCRIPTION
This function is displays a Splash Screen on the centre of the screen.
If the Image is too big to be displayed on the Screen, the Top Left
portion of the Image to the size of the Screen is displayed.
DEPENDENCIES
Loads the Splash Image from a Resource file.
PARAMETERS
pMe [in] : Pointer to Application's structure.
RETURN VALUE
TRUE : On Success.
FALSE : When the Image cannot be loaded from the Resource file.
SIDE EFFECTS
None.
======================================================================*/
static boolean apron_DisplaySplashScreen(
apron * pMe)
{
IImage * pImage = NULL;
AEEImageInfo imageInfo = {0};
uint32 x = 0;
uint32 y = 0;
uint32 temp = 0;
// Load the splash image from the resource file
pImage = ISHELL_LoadResImage(pMe->pShell, APRON_RES_FILE, IDO_SPLASH_IMAGE);
if(pImage)
{
// Clear screen and draw the image in the center of the screen
IDISPLAY_ClearScreen(pMe->pDisplay);
IIMAGE_GetInfo(pImage, &imageInfo);
if(pMe->screenRect.dx > imageInfo.cx)
{
x = ((pMe->screenRect.x + pMe->screenRect.dx) / 2) - (imageInfo.cx / 2);
}else
{
x = pMe->screenRect.x;
}
temp = pMe->screenRect.dy + APRON_CONTEXT_MENU_HEIGHT + APRON_STATUS_MENU_HEIGHT;
if(temp > imageInfo.cy)
{
y = ((pMe->screenRect.y + temp) / 2) - (imageInfo.cy / 2);;
}else
{
y = pMe->screenRect.x;
}
IIMAGE_Draw(pImage, x, y);
IDISPLAY_Update(pMe->pDisplay);
IIMAGE_Release(pImage); // the image is drawn so we don't need it any more
return (TRUE);
}else
{
DBGPRINTF("APRON: Unable to display Splash Screen");
return (FALSE);
}
}
/*======================================================================
FUNCTION
apron_DisplayMenu
DESCRIPTION
This function displays or hides the menu depending on the Display
Flag.
DEPENDENCIES
None.
PARAMETERS
menuCtl [in] : Pointer to IMenuCtl interface.
bEnable [in] : Display Flag
RETURN VALUE
TRUE : Always.
SIDE EFFECTS
None.
======================================================================*/
static boolean apron_DisplayMenu(
IMenuCtl * menuCtl,
boolean bEnable)
{
IMENUCTL_SetActive(menuCtl, bEnable);
return (TRUE);
}
/*======================================================================
FUNCTION
apron_EnableMenu
DESCRIPTION
This function enables or disables contol to the menu depending on the
Enable Flag. The menu is also displayed while enabling.
DEPENDENCIES
None.
PARAMETERS
menuCtl [in] : Pointer to IMenuCtl interface.
bEnable [in] : Enable Flag
RETURN VALUE
TRUE : Always.
SIDE EFFECTS
None.
======================================================================*/
static boolean apron_EnableMenu(
IMenuCtl * menuCtl,
boolean bEnable)
{
IMENUCTL_SetActive(menuCtl, bEnable);
if(FALSE == bEnable)
{
IMENUCTL_Redraw(menuCtl);
}
return (TRUE);
}
/*======================================================================
FUNCTION
apron_DisplayContentMenu
DESCRIPTION
This function displays the content menu by calling the State handling
functions with a TimeOut event.
This function is always called from apron_DisplaySplashScreen().
DEPENDENCIES
None.
PARAMETERS
pMe [in] : Pointer to Application's structure.
RETURN VALUE
TRUE : On Success.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -