wg_picture.cpp

00001 // wg_picture.cpp
00002 //
00003 // CPicture class implementation
00004 //
00005 //
00006 // Copyright (c) 2002-2004 Rob Wiskow
00007 // rob-dev@boxedchaos.com
00008 //
00009 // This library is free software; you can redistribute it and/or
00010 // modify it under the terms of the GNU Lesser General Public
00011 // License as published by the Free Software Foundation; either
00012 // version 2.1 of the License, or (at your option) any later version.
00013 //
00014 // This library is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00017 // Lesser General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU Lesser General Public
00020 // License along with this library; if not, write to the Free Software
00021 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00022 //
00023 
00024 
00025 #include "wgui_include_config.h"
00026 #include "wg_picture.h"
00027 
00028 
00029 namespace wGui
00030 {
00031 
00032 CPicture::CPicture(const CRect& WindowRect, CWindow* pParent, const std::wstring& sPictureFile,
00033           bool bDrawBorder, const CRGBColor& BorderColor) :
00034      CWindow(WindowRect, pParent),
00035      m_bDrawBorder(bDrawBorder),
00036      m_BorderColor(BorderColor),
00037      m_hBitmap(CBitmapFileResourceHandle(sPictureFile))
00038 {
00039      if (m_bDrawBorder)
00040      {
00041           m_ClientRect.Grow(-1);
00042      }
00043      Draw();
00044 }
00045 
00046 
00047 CPicture::CPicture(const CRect& WindowRect, CWindow* pParent, const CBitmapResourceHandle& hBitmap,
00048           bool bDrawBorder, const CRGBColor& BorderColor) :
00049      CWindow(WindowRect, pParent),
00050      m_bDrawBorder(bDrawBorder),
00051      m_BorderColor(BorderColor),
00052      m_hBitmap(hBitmap)
00053 {
00054      if (m_bDrawBorder)
00055      {
00056           m_ClientRect.Grow(-1);
00057      }
00058      Draw();
00059 }
00060 
00061 
00062 CPicture::~CPicture(void)
00063 {
00064 
00065 }
00066 
00067 
00068 void CPicture::Draw(void) const
00069 {
00070      CWindow::Draw();
00071 
00072      if (m_pSDLSurface)
00073      {
00074           SDL_Rect SourceRect = m_ClientRect.SizeRect().SDLRect();
00075           SDL_Rect DestRect = m_ClientRect.SDLRect();
00076           SDL_BlitSurface(m_hBitmap.Bitmap(), &SourceRect, m_pSDLSurface, &DestRect);
00077 
00078           CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
00079           if (m_bDrawBorder)
00080           {
00081                Painter.DrawRect(m_WindowRect.SizeRect(), false, m_BorderColor);
00082           }
00083      }
00084 }
00085 
00086 
00087 void CPicture::SetWindowRect(const CRect& WindowRect)
00088 {
00089      CWindow::SetWindowRect(WindowRect);
00090      m_ClientRect = m_WindowRect.SizeRect();
00091      m_ClientRect.Grow(-1);
00092 }
00093 
00094 }
00095 

Generated on Wed May 16 23:11:26 2007 for wGui by  doxygen 1.5.1