wg_groupbox.cpp

00001 // wg_groupbox.cpp
00002 //
00003 // CGroupBox 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_application.h"
00027 #include "wg_groupbox.h"
00028 
00029 
00030 namespace wGui
00031 {
00032 
00033 CGroupBox::CGroupBox(const CRect& WindowRect, CWindow* pParent, std::wstring sText, CRGBColor& FontColor, CFontEngine* pFontEngine) :
00034      CWindow(WindowRect, pParent),
00035      m_FontColor(FontColor)
00036 {
00037      m_sWindowText = sText;
00038      if (pFontEngine)
00039      {
00040           m_pFontEngine = pFontEngine;
00041      }
00042      else
00043      {
00044           m_pFontEngine = CApplication::Instance()->GetDefaultFontEngine();
00045      }
00046      m_ClientRect.Grow(-2);
00047      m_ClientRect.SetTop(15);
00048      std::auto_ptr<CRenderedString> pRenderedString(new CRenderedString(
00049           m_pFontEngine, sText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
00050      m_pRenderedString = pRenderedString;
00051      m_BackgroundColor = CApplication::Instance()->GetDefaultBackgroundColor();
00052      Draw();
00053 }
00054 
00055 
00056 CGroupBox::~CGroupBox(void)
00057 {
00058 
00059 }
00060 
00061 
00062 void CGroupBox::Draw(void) const
00063 {
00064      CWindow::Draw();
00065 
00066      if (m_pSDLSurface)
00067      {
00068           CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
00069           Painter.DrawRect(CRect(0, 5, m_WindowRect.Width() - 1, m_WindowRect.Height() - 5),
00070                false, DEFAULT_LINE_COLOR);
00071           CPoint Dims, Offset;
00072           m_pRenderedString->GetMetrics(&Dims, &Offset, 0);
00073           Painter.DrawRect(CRect(CPoint(6, 0), CPoint(14, 0) + Dims),
00074                true, m_BackgroundColor, m_BackgroundColor);
00075 
00076           if (m_pRenderedString.get())
00077           {
00078                m_pRenderedString->Draw(m_pSDLSurface, m_WindowRect.SizeRect(), CPoint(10, 0), m_FontColor);
00079           }
00080      }
00081 }
00082 
00083 
00084 void CGroupBox::SetWindowText(const std::wstring& sWindowText)
00085 {
00086      std::auto_ptr<CRenderedString> pRenderedString(new CRenderedString(
00087           m_pFontEngine, sWindowText, CRenderedString::VALIGN_TOP, CRenderedString::HALIGN_LEFT));
00088      m_pRenderedString = pRenderedString;
00089      CWindow::SetWindowText(sWindowText);
00090 }
00091 
00092 
00093 void CGroupBox::SetWindowRect(const CRect& WindowRect)
00094 {
00095      CWindow::SetWindowRect(WindowRect);
00096      m_ClientRect = m_WindowRect.SizeRect();
00097      m_ClientRect.Grow(-2);
00098      m_ClientRect.SetTop(15);
00099 }
00100 
00101 }
00102 
00103 
00104 
00105 

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