00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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