📄 wg_progress.cpp
字号:
// wg_progress.cpp//// CProgress class implementation////// Copyright (c) 2002 Rob Wiskow// rob-dev@boxedchaos.com//// This library is free software; you can redistribute it and/or// modify it under the terms of the GNU Lesser General Public// License as published by the Free Software Foundation; either// version 2.1 of the License, or (at your option) any later version.//// This library is distributed in the hope that it will be useful,// but WITHOUT ANY WARRANTY; without even the implied warranty of// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU// Lesser General Public License for more details.//// You should have received a copy of the GNU Lesser General Public// License along with this library; if not, write to the Free Software// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA//#include "wgui_include_config.h"#include "wg_progress.h"namespace wGui{CProgress::CProgress(const CRect& WindowRect, CWindow* pParent, CRGBColor BarColor) : CWindow(WindowRect, pParent), m_iMin(0), m_iMax(100), m_iProgress(0), m_BarColor(BarColor){ m_sClassName = "CProgress"; m_BGColor = DEFAULT_FG_COLOR;}CProgress::~CProgress(void){}void CProgress::SetLimits(int iMin, int iMax){ m_iMin = iMin; m_iMax = iMax; StartDrawProc();}void CProgress::SetProgress(int iProgress){ m_iProgress = iProgress; StartDrawProc();}void CProgress::Draw(void) const{ CWindow::Draw(); CRect SubRect(m_WindowRect); SubRect.Grow(-1); CPainter Painter(m_pSDLSurface); Painter.DrawRect(m_WindowRect, false, COLOR_BLACK); Painter.DrawRect(SubRect, false, COLOR_LIGHTGRAY); Painter.DrawHLine(SubRect.Left(), SubRect.Right(), SubRect.Top(), COLOR_DARKGRAY); Painter.DrawVLine(SubRect.Top(), SubRect.Bottom(), SubRect.Left(), COLOR_DARKGRAY); SubRect.Grow(-2); if (m_iProgress > m_iMin) { if (m_iProgress < m_iMax) { SubRect.SetRight(static_cast<int>(SubRect.Left() + SubRect.Width() * (static_cast<double>(m_iProgress - m_iMin) / (m_iMax - m_iMin)))); } Painter.DrawRect(SubRect, true, m_BarColor, m_BarColor); }}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -