2 Copyright 2008-2020 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP. If not, see <https://www.gnu.org/licenses/>.
22 #include "wprogressbar.h"
24 void WProgressBar::setPercent(u4 tpercent)
27 if (percent > 100) percent = 0;
30 void WProgressBar::draw()
32 if (area.w < 5) return;
33 if (area.h < 5) return;
35 // Hmm, can't draw two boxes because should not paint on areas
36 // not needing it - this class does not know the background colour
38 rectangle(0, 0, area.w, 2, DrawStyle::LIGHTTEXT); // top
39 rectangle(0, area.h - 2, area.w, 2, DrawStyle::LIGHTTEXT); // bottom
40 rectangle(0, 0, 2, area.h, DrawStyle::LIGHTTEXT); // left
41 rectangle(area.w - 2, 0, 2, area.h, DrawStyle::LIGHTTEXT); // right
43 int progressWidth = (area.w - 4) * percent / 100;
44 rectangle(2, 2, progressWidth, area.h - 4, DrawStyle::PROGRESSBAR);