]> git.vomp.tv Git - vompclient.git/blob - wprogressbar.cc
More compiler warning fixes
[vompclient.git] / wprogressbar.cc
1 /*
2     Copyright 2008 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, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #include "wprogressbar.h"
22
23 #include "colour.h"
24
25 WProgressBar::WProgressBar()
26 {
27   percent = 0;
28 }
29
30 WProgressBar::~WProgressBar()
31 {
32 }
33
34 void WProgressBar::setPercent(UINT tpercent)
35 {
36   percent = tpercent;
37   if (percent > 100) percent = 0;
38 }
39
40 void WProgressBar::draw()
41 {
42   if (area.w < 5) return;
43   if (area.h < 5) return;
44   
45   // Hmm, can't draw two boxes because should not paint on areas
46   // not needing it - this class does not know the background colour
47   
48   rectangle(0, 0, area.w, 2, DrawStyle::LIGHTTEXT); // top
49   rectangle(0, area.h - 2, area.w, 2, DrawStyle::LIGHTTEXT); // bottom
50   rectangle(0, 0, 2, area.h, DrawStyle::LIGHTTEXT); // left
51   rectangle(area.w - 2, 0, 2, area.h, DrawStyle::LIGHTTEXT); // right
52   
53   int progressWidth = (int)((area.w - 4) * (float)percent / 100);
54   rectangle(2, 2, progressWidth, area.h - 4, DrawStyle::PROGRESSBAR);
55 }
56