gtkIOStream  1.7.0
GTK+ << C++ IOStream operators for GTK+. Now with ORBing, numerical computation, audio client and more ...
ProgressBar.H
Go to the documentation of this file.
1 /* Copyright 2000-2018 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #ifndef PROGRESSBAR_H_
18 #define PROGRESSBAR_H_
19 
20 #include <iomanip>
21 #include <gtk/gtk.h>
22 #ifdef _MSC_VER
23 #define _USE_MATH_DEFINES
24 #endif
25 #include <math.h>
26 
27 #include "Widget.H"
28 
33 class ProgressBar : public Widget {
34  GtkWidget* widget;
35  float last;
36 public:
37 
39  ProgressBar(void) {
40  widget=NULL;
41 #if DEBUG_PB >1
42  cout<<"ProgressBar::ProgressBar()"<<endl;
43 #endif
44  widget=gtk_progress_bar_new();
45  //gtk_progress_set_format_string (GTK_PROGRESS (widget), "%v from [%l-%u] (=%p%%)");
46  show();
47  last=0.;
48  }
49 
51  ~ProgressBar(void) {
52 #if DEBUG_PB >1
53  cout<<"ProgressBar::~ProgressBar()"<<endl;
54 #endif
55  if (widget)
56  g_object_unref(widget);
57  widget=NULL;
58  }
59 
65  ProgressBar& operator =(float what) {
66  if (what>1.0)
67  what=1.0;
68  if (fabs(what-last)>0.05) {
69  if (what<0.0)
70  gtk_progress_bar_pulse (GTK_PROGRESS_BAR(widget));
71  else
72  gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR(widget), what);
73  last=what;
74  }
75  return *this;
76  }
77 };
78 #endif //PROGRESSBAR_H_
~ProgressBar(void)
Destructor.
Definition: ProgressBar.H:51
GtkWidget * show(void)
Definition: Widget.H:65
float last
Definition: ProgressBar.H:35
Definition: Widget.H:31
ProgressBar(void)
Constructor.
Definition: ProgressBar.H:39
ProgressBar & operator=(float what)
Definition: ProgressBar.H:65
GtkWidget * widget
The progress bar.
Definition: ProgressBar.H:34
Class to show progress This class shows a progress bar which may be initialised at construction or la...
Definition: ProgressBar.H:33
gtkIOStream: /tmp/gtkiostream/include/ProgressBar.H Source File
GTK+ IOStream  Beta