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_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