MyList.cpp
资源名称:Shapes.zip [点击查看]
上传用户:wenshuihe
上传日期:2007-01-14
资源大小:10k
文件大小:2k
源码类别:
BREW编程
开发平台:
Visual C++
- // List.cpp: implementation of the CList class.
- //
- //////////////////////////////////////////////////////////////////////
- #include "MyList.h"
- //////////////////////////////////////////////////////////////////////
- // Construction/Destruction
- //////////////////////////////////////////////////////////////////////
- CList::CList(): m_pFront(NULL)
- {
- }
- CList::~CList()
- {
- CNode *pn = NULL;
- while(m_pFront)
- {
- pn = m_pFront;
- m_pFront = m_pFront->next;
- pn->next = NULL;
- delete pn;
- }
- }
- boolean CList::insert(CShape *ps)
- {
- if(m_pFront == NULL)
- {
- m_pFront = new CNode(ps);
- return (m_pFront != NULL);
- }
- CNode *pn = m_pFront;
- while(pn->next)
- pn = pn->next;
- pn->next = new CNode(ps);
- return (pn->next != NULL);
- }
- boolean CList::mt()
- {
- return (m_pFront == NULL);
- }
- boolean CList::update(IShell *pIShell)
- {
- IGraphics *pg = NULL;
- if(ISHELL_CreateInstance(pIShell,AEECLSID_GRAPHICS,(void**)&pg) != SUCCESS)
- return FALSE;
- IGRAPHICS_SetBackground(pg,255,255,255);
- IGRAPHICS_ClearViewport(pg);
- IGRAPHICS_SetFillMode(pg, TRUE);
- IGRAPHICS_SetPaintMode(pg, AEE_PAINT_COPY);
- CNode *pn = m_pFront;
- while(pn)
- {
- IGRAPHICS_SetColor(pg, pn->dat->getClr()->getr(), pn->dat->getClr()->getg(),
- pn->dat->getClr()->getb(), 1);
- IGRAPHICS_SetFillColor(pg, pn->dat->getClr()->getr(), pn->dat->getClr()->getg(),
- pn->dat->getClr()->getb(), 1);
- if(!pn->dat->draw(pg))
- return FALSE;
- pn = pn->next;
- }
- IGRAPHICS_Update(pg);
- IGRAPHICS_Release(pg);
- return TRUE;
- }
- void* CList::operator new(size_t sz)
- {
- return MALLOC(sz);
- }
- void CList::operator delete(void *p)
- {
- FREE(p);
- }