src/gui/progress_bar.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Progress bar for GUI.
00020  *****************************************************************************/
00021 
00022 #ifndef PROGRESS_BAR_H
00023 #define PROGRESS_BAR_H
00024 
00025 #include <SDL.h>
00026 #include <list>
00027 #include "../include/base.h"
00028 #include "../graphic/color.h"
00029 #include "../graphic/surface.h"
00030 
00031 class ProgressBar
00032 {
00033 public:
00034   Color border_color, value_color, background_color;
00035   Surface image; // in order to pemit alpha blended progressbar
00036   enum orientation {
00037     PROG_BAR_VERTICAL,
00038     PROG_BAR_HORIZONTAL
00039   };
00040 
00041 private:
00042   uint x, y, larg, haut; // Position
00043   long val, min, max; // current, min and max values
00044   bool m_use_ref_val; // use reference value ?
00045   long m_ref_val; // reference value
00046   uint val_barre; // current value in the progress bar
00047   enum orientation orientation;
00048 
00049   uint CalculeVal (long val) const;
00050   uint CalculeValBarre (long val) const;
00051 
00052   typedef struct s_marqueur_t{
00053           Color color;
00054           uint val;
00055   } marqueur_t;
00056 
00057  public:
00058   void SetBorderColor(Color color);
00059   void SetBackgroundColor(Color color);
00060   void SetValueColor(Color color);
00061  private:
00062   typedef std::list<marqueur_t>::iterator marqueur_it;
00063   typedef std::list<marqueur_t>::const_iterator marqueur_it_const;
00064   std::list<marqueur_t> marqueur;
00065 
00066 public:
00067   ProgressBar();
00068 
00069   // Actualisation de la valeur
00070   void UpdateValue (long val);
00071 
00072   // Initialise la position
00073   void InitPos (uint x, uint y, uint larg, uint haut);
00074 
00075   // Initialise les valeurs
00076   void InitVal (long val, long min, long max, enum orientation orientation = PROG_BAR_HORIZONTAL);
00077 
00078   // Set reference value
00079   // Use it after InitVal !
00080   void SetReferenceValue (bool use, long value=0);
00081 
00082   // Draw la barre de progresssion
00083   void Draw() const;
00084 
00085   // Draw the progress bar
00086   void DrawXY(const Point2i &pos) const;
00087 
00088   inline const long & GetMaxVal() const { return max; }
00089   inline const long & GetVal() const { return val; }
00090 
00091   int GetWidth() const { return larg; }
00092   int GetHeight() const { return haut; }
00093   Point2i GetSize() const { return Point2i(larg, haut); }
00094 
00095   // add/remove value tag
00096   marqueur_it AddTag (long val, const Color& coul);
00097   void ResetTag();
00098 };
00099 
00100 #endif

Generated on Mon Jan 1 13:10:57 2007 for Wormux by  doxygen 1.4.7