-
Notifications
You must be signed in to change notification settings - Fork 6
/
cProgressBar.h
64 lines (54 loc) · 1.26 KB
/
cProgressBar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#pragma once
#include "WindowLib/cWindow.h"
class cProgressBar : public CWindow, private IRenderEvent {
public:
cProgressBar()
{
m_fMin = 0;
m_fMax = 1;
m_fCurrent = 0.5f;
m_dwColor = 0xFFFFFF;
AddRenderEventHandler( *this );
}
private:
bool OnRender( IWindow & Window, double TimeSlice )
{
float iLeft = GetAbsoluteLeft(),
iRight = iLeft + GetWidth(),
iTop = GetAbsoluteTop(),
iBottom = iTop + GetHeight();
glBindTexture(GL_TEXTURE_2D, 0);
glBegin(GL_QUADS);
glColor3ub((BYTE) (m_dwColor),(BYTE) (m_dwColor >> 8),(BYTE) (m_dwColor >> 16));
glVertex2f(iLeft,iTop);
glVertex2f(iLeft+(GetWidth()*((m_fCurrent - m_fMin)/(m_fMax - m_fMin))),iTop);
glVertex2f(iLeft+(GetWidth()*((m_fCurrent - m_fMin)/(m_fMax - m_fMin))),iBottom);
glVertex2f(iLeft,iBottom);
glEnd();
glBegin(GL_LINE_LOOP);
glColor3f(0.5,0.5,0.5);
glVertex2f(iLeft,iTop);
glVertex2f(iRight,iTop);
glVertex2f(iRight,iBottom);
glVertex2f(iLeft,iBottom);
glEnd();
return true;
}
public:
void SetColor(DWORD dwColor)
{
m_dwColor = dwColor;
}
void SetLimits(float fMin, float fMax)
{
m_fMin = fMin;
m_fMax = fMax;
}
void SetCurrent(float fCurrent)
{
m_fCurrent = fCurrent;
}
private:
float m_fMin, m_fMax, m_fCurrent;
DWORD m_dwColor;
};