Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3244 in orxonox.OLD


Ignore:
Timestamp:
Dec 21, 2004, 8:33:13 PM (19 years ago)
Author:
bensch
Message:

orxonox/branches/updater: implemented class ProgressBar.

Location:
orxonox/branches/updater/src/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.cc

    r3192 r3244  
    11411141  return label;
    11421142}
     1143
     1144/**
     1145   \breif Creates a new ProgressBar.
     1146*/
     1147ProgressBar::ProgressBar (void)
     1148{
     1149  this->init ();
     1150}
     1151
     1152/**
     1153   \breif Creates a new ProgressBar.
     1154   \param label The name you want to get the ProgressBar.
     1155*/
     1156ProgressBar::ProgressBar (char* label)
     1157{
     1158  this->init();
     1159  //  this->setLabel (label);
     1160}
     1161
     1162/**
     1163   \destructs a ProgressBar
     1164*/
     1165ProgressBar::~ProgressBar ()
     1166{
     1167}
     1168
     1169/**
     1170   \brief Initializes a ProgressBar
     1171*/
     1172void ProgressBar::init (void)
     1173{
     1174  isOption = 0;
     1175  progress = 0.0;
     1176  totalSize = 0.0;
     1177
     1178  static_cast<Widget*>(this)->init();
     1179#ifdef HAVE_GTK2
     1180  adjustment = (GtkAdjustment*)gtk_adjustment_new(0, 0, 100, 0, 0, 0);
     1181  widget = gtk_progress_bar_new_with_adjustment(adjustment);
     1182#endif /* HAVE_GTK2 */
     1183}
     1184
     1185/**
     1186   \brief Sets the Total size of the Bar. (ex. The maximum one can download)
     1187*/
     1188void setTotalSize (double totalSize)
     1189{
     1190 
     1191}
     1192
     1193/**
     1194   \brief Sets the progress maximum is this->totalSize
     1195*/
     1196void ProgressBar::setProgress (double progress)
     1197{
     1198  this->progress = progress;
     1199
     1200  if (this->progress > this->totalSize)
     1201    this->progress = this->totalSize;
     1202
     1203#ifdef HAVE_GTK2
     1204  gtk_progress_set_value(GTK_PROGRESS(widget), this->progress*100.0/this->totalSize);
     1205#endif /* HAVE_GTK2 */
     1206}
     1207
     1208/**
     1209    \brief returns the Progress Status
     1210*/
     1211double ProgressBar::getProgress (void)
     1212{
     1213  return this->progress;
     1214}
  • orxonox/branches/updater/src/gui/orxonox_gui_gtk.h

    r3187 r3244  
    2626#include <gtk/gtkimage.h>
    2727#include <gtk/gtkeventbox.h>
     28#include <gtk/gtkprogressbar.h>
    2829#endif /* HAVE_GTK2 */
    2930
     
    313314};
    314315
     316//! A ProgressBar is a Widget, that can display a Progress
     317class ProgressBar : public Widget
     318{
     319 public:
     320  ProgressBar (void);
     321  ProgressBar (char* label);
     322  ~ProgressBar ();
     323  void init (void);
     324 
     325  void setProgress (double progress);
     326  void setTotalSize (double totalSize);
     327  double getProgress (void);
     328
     329 private:
     330  double totalSize;
     331  double progress;
     332#ifdef HAVE_GTK2
     333  GtkAdjustment* adjustment;
     334#endif /* HAVE_GTK2 */
     335};
    315336
    316337//gint orxonox_gui_quit (GtkWidget *widget, GdkEvent *event, gpointer data);
Note: See TracChangeset for help on using the changeset viewer.