GLWProgress.cpp

Go to the documentation of this file.
00001 ////////////////////////////////////////////////////////////////////////////////
00002 //    Scorched3D (c) 2000-2009
00003 //
00004 //    This file is part of Scorched3D.
00005 //
00006 //    Scorched3D is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    Scorched3D is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with Scorched3D; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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 }

Generated on Mon Feb 16 15:14:45 2009 for Scorched3D by  doxygen 1.5.3