ProgressBar Class Reference

#include <progress_bar.h>

Inheritance diagram for ProgressBar:

Inheritance graph
[legend]
Collaboration diagram for ProgressBar:

Collaboration graph
[legend]
List of all members.

Public Types

 PROG_BAR_VERTICAL
 PROG_BAR_HORIZONTAL
enum  orientation { PROG_BAR_VERTICAL, PROG_BAR_HORIZONTAL }

Public Member Functions

void SetBorderColor (Color color)
void SetBackgroundColor (Color color)
void SetValueColor (Color color)
 ProgressBar ()
void UpdateValue (long val)
void InitPos (uint x, uint y, uint larg, uint haut)
void InitVal (long val, long min, long max, enum orientation orientation=PROG_BAR_HORIZONTAL)
void SetReferenceValue (bool use, long value=0)
void Draw () const
void DrawXY (const Point2i &pos) const
const long & GetMaxVal () const
const long & GetVal () const
int GetWidth () const
int GetHeight () const
Point2i GetSize () const
marqueur_it AddTag (long val, const Color &coul)
void ResetTag ()

Public Attributes

Color border_color
Color value_color
Color background_color
Surface image

Private Types

typedef ProgressBar::s_marqueur_t marqueur_t
typedef std::list< marqueur_t
>::iterator 
marqueur_it
typedef std::list< marqueur_t
>::const_iterator 
marqueur_it_const

Private Member Functions

uint CalculeVal (long val) const
uint CalculeValBarre (long val) const

Private Attributes

uint x
uint y
uint larg
uint haut
long val
long min
long max
bool m_use_ref_val
long m_ref_val
uint val_barre
enum orientation orientation
std::list< marqueur_tmarqueur

Classes

struct  s_marqueur_t

Detailed Description

Definition at line 31 of file progress_bar.h.


Member Typedef Documentation

typedef std::list<marqueur_t>::iterator ProgressBar::marqueur_it [private]

Definition at line 62 of file progress_bar.h.

typedef std::list<marqueur_t>::const_iterator ProgressBar::marqueur_it_const [private]

Definition at line 63 of file progress_bar.h.

typedef struct ProgressBar::s_marqueur_t ProgressBar::marqueur_t [private]


Member Enumeration Documentation

enum ProgressBar::orientation

Enumerator:
PROG_BAR_VERTICAL 
PROG_BAR_HORIZONTAL 

Definition at line 36 of file progress_bar.h.

00036                    {
00037     PROG_BAR_VERTICAL,
00038     PROG_BAR_HORIZONTAL
00039   };


Constructor & Destructor Documentation

ProgressBar::ProgressBar (  ) 

Definition at line 28 of file progress_bar.cpp.

00028                         {
00029    border_color.SetColor(0, 0, 0, 255);
00030    value_color.SetColor(255, 255, 255, 255);
00031    background_color.SetColor(100, 100 ,100, 255);
00032    x = y = larg = haut = 0;
00033    val = min = max = 0;
00034    m_use_ref_val = false;
00035 }

Here is the call graph for this function:


Member Function Documentation

ProgressBar::marqueur_it ProgressBar::AddTag ( long  val,
const Color coul 
)

Definition at line 159 of file progress_bar.cpp.

00159                                                                        {
00160   marqueur_t m;
00161 
00162   m.val = CalculeValBarre (val);
00163   m.color = color;
00164   marqueur.push_back (m);
00165 
00166   return --marqueur.end();
00167 }

Here is the call graph for this function:

Here is the caller graph for this function:

uint ProgressBar::CalculeVal ( long  val  )  const [private]

Definition at line 82 of file progress_bar.cpp.

00082                                            {
00083   return BorneLong(val, min, max);
00084 }

Here is the call graph for this function:

Here is the caller graph for this function:

uint ProgressBar::CalculeValBarre ( long  val  )  const [private]

Definition at line 86 of file progress_bar.cpp.

00086                                                 {
00087   if(orientation == PROG_BAR_HORIZONTAL)
00088     return ( CalculeVal(val) -min)*(larg-2)/(max-min);
00089   else
00090     return ( CalculeVal(val) -min)*(haut-2)/(max-min);
00091 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ProgressBar::Draw (  )  const

Definition at line 93 of file progress_bar.cpp.

00093                             {
00094   DrawXY( Point2i(x, y) );
00095 }

Here is the call graph for this function:

void ProgressBar::DrawXY ( const Point2i pos  )  const

Definition at line 98 of file progress_bar.cpp.

00098                                                 {
00099   int begin, end;
00100 
00101   // Bordure
00102   image.Fill(border_color);
00103 
00104   // Fond
00105   Rectanglei r_back(1, 1, larg - 2, haut - 2);
00106   image.FillRect(r_back, background_color);
00107 
00108   // Valeur
00109   if (m_use_ref_val) {
00110     int ref = CalculeValBarre (m_ref_val);
00111     if (val < m_ref_val) { // FIXME hum, this seems buggy
00112       begin = 1+val_barre;
00113       end = 1+ref;
00114     } else {
00115       begin = 1+ref;
00116       end = 1+val_barre;
00117     }
00118   } else {
00119     begin = 1;
00120     end = 1+val_barre;
00121   }
00122 
00123   Rectanglei r_value;
00124   if(orientation == PROG_BAR_HORIZONTAL)
00125     r_value = Rectanglei(begin, 1, end - begin, haut - 2);
00126   else
00127     r_value = Rectanglei(1, haut - end + begin - 1, larg - 2, end -1 );
00128 
00129   image.FillRect(r_value, value_color);
00130 
00131   if (m_use_ref_val) {
00132     int ref = CalculeValBarre (m_ref_val);
00133     Rectanglei r_ref;
00134     if(orientation == PROG_BAR_HORIZONTAL)
00135        r_ref = Rectanglei(1 + ref, 1, 1, haut - 2);
00136     else
00137        r_ref = Rectanglei(1, 1 + ref, larg - 2, 1);
00138     image.FillRect(r_ref, border_color);
00139   }
00140 
00141   // Marqueurs
00142   marqueur_it_const it=marqueur.begin(), fin=marqueur.end();
00143   for (; it != fin; ++it)
00144   {
00145     Rectanglei r_marq;
00146     if(orientation == PROG_BAR_HORIZONTAL)
00147       r_marq = Rectanglei(1 + it->val, 1, 1, haut - 2);
00148     else
00149       r_marq = Rectanglei(1, 1 + it->val, larg -2, 1);
00150     image.FillRect( r_marq, it->color);
00151   }
00152   Rectanglei dst(pos.x, pos.y, larg, haut);
00153   AppWormux::GetInstance()->video.window.Blit(image, pos);
00154 
00155   world.ToRedrawOnScreen(dst);
00156 }

Here is the call graph for this function:

Here is the caller graph for this function:

int ProgressBar::GetHeight (  )  const [inline]

Definition at line 92 of file progress_bar.h.

00092 { return haut; }

Here is the caller graph for this function:

const long& ProgressBar::GetMaxVal (  )  const [inline]

Definition at line 88 of file progress_bar.h.

00088 { return max; }

Here is the caller graph for this function:

Point2i ProgressBar::GetSize (  )  const [inline]

Definition at line 93 of file progress_bar.h.

00093 { return Point2i(larg, haut); }

Here is the caller graph for this function:

const long& ProgressBar::GetVal (  )  const [inline]

Definition at line 89 of file progress_bar.h.

00089 { return val; }

Here is the caller graph for this function:

int ProgressBar::GetWidth (  )  const [inline]

Definition at line 91 of file progress_bar.h.

00091 { return larg; }

Here is the caller graph for this function:

void ProgressBar::InitPos ( uint  x,
uint  y,
uint  larg,
uint  haut 
)

Definition at line 49 of file progress_bar.cpp.

00049                                                                   {
00050   assert (3 <= plarg);
00051   assert (3 <= phaut);
00052   x = px;
00053   y = py;
00054   larg = plarg;
00055   haut = phaut;
00056 
00057   image.NewSurface(Point2i(larg, haut), SDL_SWSURFACE|SDL_SRCALPHA, true);
00058 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ProgressBar::InitVal ( long  val,
long  min,
long  max,
enum orientation  orientation = PROG_BAR_HORIZONTAL 
)

Here is the caller graph for this function:

void ProgressBar::ResetTag (  ) 

Definition at line 169 of file progress_bar.cpp.

00169                           {
00170   marqueur.clear();
00171 }

Here is the caller graph for this function:

void ProgressBar::SetBackgroundColor ( Color  color  ) 

Definition at line 41 of file progress_bar.cpp.

00041                                                {
00042    background_color = color;
00043 }

Here is the caller graph for this function:

void ProgressBar::SetBorderColor ( Color  color  ) 

Definition at line 37 of file progress_bar.cpp.

00037                                            {
00038    border_color = color;
00039 }

Here is the caller graph for this function:

void ProgressBar::SetReferenceValue ( bool  use,
long  value = 0 
)

Definition at line 173 of file progress_bar.cpp.

00173                                                         {
00174   m_use_ref_val = use;
00175   m_ref_val = CalculeVal(value);
00176 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ProgressBar::SetValueColor ( Color  color  ) 

Definition at line 45 of file progress_bar.cpp.

00045                                           {
00046    value_color = color;
00047 }

Here is the caller graph for this function:

void ProgressBar::UpdateValue ( long  val  ) 

Definition at line 77 of file progress_bar.cpp.

00077                                        {
00078   val = CalculeVal(pval);
00079   val_barre = CalculeValBarre(val);
00080 }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Color ProgressBar::background_color

Definition at line 34 of file progress_bar.h.

Color ProgressBar::border_color

Definition at line 34 of file progress_bar.h.

uint ProgressBar::haut [private]

Definition at line 42 of file progress_bar.h.

Surface ProgressBar::image

Definition at line 35 of file progress_bar.h.

uint ProgressBar::larg [private]

Definition at line 42 of file progress_bar.h.

long ProgressBar::m_ref_val [private]

Definition at line 45 of file progress_bar.h.

bool ProgressBar::m_use_ref_val [private]

Definition at line 44 of file progress_bar.h.

std::list<marqueur_t> ProgressBar::marqueur [private]

Definition at line 64 of file progress_bar.h.

long ProgressBar::max [private]

Definition at line 43 of file progress_bar.h.

long ProgressBar::min [private]

Definition at line 43 of file progress_bar.h.

enum orientation ProgressBar::orientation [private]

Definition at line 47 of file progress_bar.h.

long ProgressBar::val [private]

Definition at line 43 of file progress_bar.h.

uint ProgressBar::val_barre [private]

Definition at line 46 of file progress_bar.h.

Color ProgressBar::value_color

Definition at line 34 of file progress_bar.h.

uint ProgressBar::x [private]

Definition at line 42 of file progress_bar.h.

uint ProgressBar::y [private]

Definition at line 42 of file progress_bar.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:11:54 2007 for Wormux by  doxygen 1.4.7