CPainter::CPainter(CWindow* pWindow, EPaintMode ePaintMode) : m_pSurface(0), m_pWindow(pWindow), m_PaintMode(ePaintMode) { if (!m_pWindow) { throw Wg_Ex_App("CPainter::CPainter : Invalid pointer to window."); } m_pSurface = pWindow->GetSDLSurface(); if (!m_pSurface) { throw Wg_Ex_App("CPainter::CPainter : Invalid pointer to surface."); } }
CView::CView(SDL_Surface* surface, SDL_Surface* backSurface, const CRect& WindowRect) : CWindow(CRect(0, 0, surface->w, surface->h), 0), m_pMenu(0), m_pFloatingWindow(0), m_pScreenSurface(0) { if (m_pInstance) { throw(Wg_Ex_App("Cannot have more than one view at a time!")); } m_pInstance = this; CMessageServer::Instance().RegisterMessageClient(this, CMessage::APP_PAINT); CMessageServer::Instance().RegisterMessageClient(this, CMessage::APP_DESTROY_FRAME, CMessageServer::PRIORITY_FIRST); CMessageServer::Instance().RegisterMessageClient(this, CMessage::CTRL_RESIZE); CMessageServer::Instance().RegisterMessageClient(this, CMessage::MOUSE_BUTTONDOWN, CMessageServer::PRIORITY_FIRST); CMessageServer::Instance().RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP, CMessageServer::PRIORITY_FIRST); // judb this works, but better rewrite this to make things clearer ! CWindow::SetWindowRect(WindowRect); // judb ClientRect is relative to WindowRect (it is the client area within a Window(Rect) ) so // its coordinates are relative to WindowRect -> // here we use a rectangle with the same dimensions as WindowRect, but (0,0) as its upper left point. // so it covers the entire WindowRect. m_ClientRect = WindowRect.SizeRect(); m_pScreenSurface = surface; m_pBackSurface = backSurface; // judb should not happen:-) if (m_pScreenSurface == NULL) throw( Wg_Ex_SDL(std::string("Surface not created? : ") + SDL_GetError())); CApplication::Instance()->GetApplicationLog().AddLogEntry("Created new CView ", APP_LOG_INFO); Draw(); }
CView::CView(const CRect& WindowRect, std::string sTitle, bool bResizable, bool bFullScreen) : CWindow(WindowRect, 0), m_bResizable(bResizable), m_bFullScreen(bFullScreen), m_pMenu(0), m_pFloatingWindow(0), m_pScreenSurface(0) { if (m_pInstance) { throw(Wg_Ex_App("Cannot have more than one view at a time!")); } m_pInstance = this; CMessageServer::Instance().RegisterMessageClient(this, CMessage::APP_PAINT); CMessageServer::Instance().RegisterMessageClient(this, CMessage::APP_DESTROY_FRAME, CMessageServer::PRIORITY_FIRST); CMessageServer::Instance().RegisterMessageClient(this, CMessage::CTRL_RESIZE); CMessageServer::Instance().RegisterMessageClient(this, CMessage::MOUSE_BUTTONDOWN, CMessageServer::PRIORITY_FIRST); CMessageServer::Instance().RegisterMessageClient(this, CMessage::MOUSE_BUTTONUP, CMessageServer::PRIORITY_FIRST); SetWindowRect(WindowRect); SetWindowText(sTitle); CApplication::Instance()->GetApplicationLog().AddLogEntry("Created new CView : " + sTitle, APP_LOG_INFO); Draw(); }
CPainter::CPainter(SDL_Surface* pSurface, EPaintMode ePaintMode) : m_pSurface(pSurface), m_pWindow(0), m_PaintMode(ePaintMode) { if (!m_pSurface) { throw Wg_Ex_App("CPainter::CPainter : Invalid pointer to surface."); } }
CResourceHandle::~CResourceHandle(void) { if (GetRefCount() > 0) { --m_RefCountMap[m_ResourceId]; } else { throw(Wg_Ex_App("CResourceHandle::~CResourceHandle : Trying to decrement refcount of zero!")); } }
CMessageServer& CMessageServer::Instance(void) { if (!m_pInstance) { m_pInstance = new CMessageServer; if (!m_pInstance) { throw(Wg_Ex_App("CMessageServer::Instance : Unable to instantiate Message Server!")); } } return *m_pInstance; }
CBitmapFileResourceHandle::CBitmapFileResourceHandle(std::string sFilename) : CBitmapResourceHandle(AUTO_CREATE_RESOURCE_ID), m_sFilename(sFilename) { if (m_BitmapMap.find(m_ResourceId) == m_BitmapMap.end()) { SDL_Surface* pSurface = SDL_LoadBMP(m_sFilename.c_str()); if (!pSurface) { throw(Wg_Ex_App("CBitmapFileResourceHandle::CBitmapFileResourceHandle - Unable to load bitmap")); } m_BitmapMap[m_ResourceId] = pSurface; } }