wg_progress.cpp

00001 // wg_progress.cpp
00002 //
00003 // CProgress 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_progress.h"
00027 #include "std_ex.h"
00028 
00029 
00030 namespace wGui
00031 {
00032 
00033 CProgress::CProgress(const CRect& WindowRect, CWindow* pParent, CRGBColor BarColor) :
00034      CRangeControl<int>(WindowRect, pParent, 0, 100, 1, 0),
00035      m_BarColor(BarColor)
00036 {
00037      m_BackgroundColor = DEFAULT_FOREGROUND_COLOR;
00038      Draw();
00039 }
00040 
00041 
00042 CProgress::~CProgress(void)
00043 {
00044 
00045 }
00046 
00047 
00048 void CProgress::Draw(void) const
00049 {
00050      CWindow::Draw();
00051 
00052      if (m_pSDLSurface)
00053      {
00054           CRect SubRect(m_WindowRect.SizeRect());
00055           SubRect.Grow(-1);
00056           CPainter Painter(m_pSDLSurface, CPainter::PAINT_REPLACE);
00057           Painter.DrawRect(m_WindowRect.SizeRect(), false, COLOR_BLACK);
00058           Painter.DrawRect(SubRect, false, COLOR_LIGHTGRAY);
00059           Painter.DrawHLine(SubRect.Left(), SubRect.Right(), SubRect.Top(), COLOR_DARKGRAY);
00060           Painter.DrawVLine(SubRect.Top(), SubRect.Bottom(), SubRect.Left(), COLOR_DARKGRAY);
00061           SubRect.Grow(-2);
00062           if (m_Value > m_MinLimit)
00063           {
00064                if (m_Value < m_MaxLimit)
00065                {
00066                     SubRect.SetRight(stdex::safe_static_cast<int>(SubRect.Left() +
00067                          SubRect.Width() * (stdex::safe_static_cast<double>(m_Value - m_MinLimit) / (m_MaxLimit - m_MinLimit))));
00068                }
00069                Painter.DrawRect(SubRect, true, m_BarColor, m_BarColor);
00070           }
00071      }
00072 }
00073 
00074 }
00075 

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