]> git.vomp.tv Git - vompclient.git/blob - wprogressbar.cc
Rename TCP class to TCPOld
[vompclient.git] / wprogressbar.cc
1 /*
2     Copyright 2008-2020 Chris Tallon
3
4     This file is part of VOMP.
5
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.
10
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.
15
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/>.
18 */
19
20 #include "colour.h"
21
22 #include "wprogressbar.h"
23
24 void WProgressBar::setPercent(UINT tpercent)
25 {
26   percent = tpercent;
27   if (percent > 100) percent = 0;
28 }
29
30 void WProgressBar::draw()
31 {
32   if (area.w < 5) return;
33   if (area.h < 5) return;
34   
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
37   
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
42   
43   int progressWidth = (area.w - 4) * percent / 100;
44   rectangle(2, 2, progressWidth, area.h - 4, DrawStyle::PROGRESSBAR);
45 }