00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <GLEXT/GLState.h>
00022 #include <GLW/GLWProgress.h>
00023
00024 REGISTER_CLASS_SOURCE(GLWProgress);
00025
00026 GLWProgress::GLWProgress(float x, float y, float w, float min, float max) :
00027 GLWPanel(x, y, w, 25.0f, true), x_(x), y_(y), w_(w), min_(min), max_(max), current_(min)
00028 {
00029
00030 }
00031
00032 GLWProgress::~GLWProgress()
00033 {
00034
00035 }
00036
00037 void GLWProgress::draw()
00038 {
00039 GLfloat width = ((current_ - min_) / (max_ - min_)) * (w_ - 4);
00040
00041 GLWPanel::draw();
00042
00043 glColor3f(0.4f, 0.4f, 0.5f);
00044 glBegin(GL_QUADS);
00045 glVertex2f(x_ + 2.0f, y_ + 2.0f);
00046 glVertex2f(x_ + width + 2.0f, y_ + 2.0f);
00047 glVertex2f(x_ + width + 2.0f, y_ + 22.0f);
00048 glVertex2f(x_ + 2.0f, y_ + 22.0f);
00049 glEnd();
00050 }
00051
00052 void GLWProgress::setCurrent(float newCurrent)
00053 {
00054 if (newCurrent < min_) current_ = min_;
00055 else if (newCurrent > max_) current_ = max_;
00056 else current_ = newCurrent;
00057 }