ShapeApp.cpp
资源名称:Shapes.zip [点击查看]
上传用户:wenshuihe
上传日期:2007-01-14
资源大小:10k
文件大小:2k
源码类别:
BREW编程
开发平台:
Visual C++
- // ShapeApp.cpp
- //
- #include "ShapeApp.h"
- #include "SHAPEAPP.BID"
- #include "myShape.h"
- #include "myRect.h"
- #include "myCirc.h"
- #include "myPoint.h"
- #include "myList.h"
- extern "C"
- {
- int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * po,void ** ppObj)
- {
- *ppObj = NULL;
- if(ClsId == AEECLSID_SHAPEAPP)
- {
- if(AEEApplet_New(sizeof(ShapeApp), ClsId, pIShell,po,(IApplet**)ppObj,
- (AEEHANDLER)ShapeApp::HandleEvent,(PFNFREEAPPDATA)ShapeApp::freeAppData))
- {
- if(ShapeApp::initAppData((IApplet *) *ppObj))
- {
- return (AEE_SUCCESS);
- }
- }
- }
- return (EFAILED);
- }
- }
- boolean ShapeApp::HandleEvent(ShapeApp * pi, AEEEvent eCode, uint16 wParam, uint32 dwParam)
- {
- return pi->onEvent(eCode, wParam, dwParam);
- }
- boolean ShapeApp::initAppData(IApplet * pIApplet)
- {
- return ((ShapeApp *) pIApplet)->initData();
- }
- void ShapeApp::freeAppData(ShapeApp * pApp)
- {
- pApp->freeData();
- }
- boolean ShapeApp::initData()
- {
- m_pShapes = new CList();
- return TRUE;
- }
- boolean ShapeApp::onEvent(AEEEvent evt, uint16 wParam, uint32 dwParam)
- {
- switch(evt)
- {
- case EVT_APP_START:
- {
- CShape *ps = new CRect(10,10,30,20,BLUE);
- m_pShapes->insert(ps);
- ps = new CCirc(20, CPoint(20,40),YELLOW);
- m_pShapes->insert(ps);
- m_pShapes->update(m_pIShell);
- return TRUE;
- }
- case EVT_APP_SUSPEND:
- return TRUE;
- case EVT_APP_RESUME:
- return TRUE;
- case EVT_KEY:
- {
- switch(wParam)
- {
- case AVK_CLR:
- return FALSE;
- case AVK_UP:
- case AVK_DOWN:
- case AVK_LEFT:
- case AVK_RIGHT:
- case AVK_SELECT:
- break;
- default:
- break;
- }
- break;
- }
- case EVT_COMMAND:
- {
- break;
- }
- case EVT_APP_STOP:
- return TRUE;
- default:
- break;
- }
- return FALSE;
- }
- void ShapeApp::freeData()
- {
- delete m_pShapes;
- m_pShapes = NULL;
- }