GTK+ IOStream
Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
Main Page
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
ProgressBarTest.C
Go to the documentation of this file.
1
/* Copyright 2000-2013 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
#include "
gtkInterface.H
"
18
#include "
Buttons.H
"
19
#include "
Labels.H
"
20
#include "
ProgressBar.H
"
21
22
float
accumulator
;
// goes between 0 and 1
23
float
fraction
;
// set to +-0.1
24
25
// shifts the accumulator up and down between 0 and 1
26
gboolean
changeProgress
(gpointer data) {
27
28
ProgressBar
*bar=
static_cast<
ProgressBar
*
>
(data);
29
*bar=
accumulator
;
30
31
accumulator+=
fraction
;
32
if
(accumulator>1.0) {
// if we hit 1 reverse
33
accumulator=1.0;
34
fraction=-
fraction
;
35
}
36
if
(accumulator<.0) {
// if we hit 0 reverse
37
accumulator=.0;
38
fraction=-
fraction
;
39
}
40
return
1;
41
}
42
43
// shifts the pulse back and forth (negative numbers pulse)
44
gboolean
pulseProgress
(gpointer data) {
45
46
ProgressBar
*bar=
static_cast<
ProgressBar
*
>
(data);
47
*bar=-
accumulator
;
48
}
49
50
static
void
quit
(
void
*widget, gpointer data) {
51
gtk_main_quit();
52
}
53
54
int
main
(
int
argc,
char
*argv[]) {
55
accumulator =0.0;
56
fraction=0.1;
57
gtk_init( &argc, &argv );
58
59
GtkInterface
topWindow;
60
61
Buttons
buttons;
62
buttons<<
BUTTONLABELSTRUCT
(
"Quit"
,
quit
, NULL);
63
64
ProgressBar
bar, pulsingBar;
65
66
bar=0.5;
67
pulsingBar=-0.5;
68
69
bar.
show
();
70
pulsingBar.
show
();
71
72
VBox
vbox;
73
74
Labels
labels;
75
labels<<
"progress bar"
<<
"pulse bar"
;
76
77
vbox<<buttons.
grab
(1);
78
vbox<<labels.
grab
(1)<<
BoxIS
(
true
,
false
)<<bar.
getWidget
();
// BoxIS is ussed to give widgets space and don't fill
79
vbox<<labels.
grab
(2)<<
BoxIS
(
true
,
false
)<<pulsingBar.
getWidget
();
80
vbox.
show
();
81
82
topWindow<<vbox;
83
g_timeout_add_seconds(1,
changeProgress
, (gpointer)&bar);
84
g_timeout_add_seconds(1,
pulseProgress
, (gpointer)&pulsingBar);
85
gtk_main();
86
}
Generated on Tue Jun 4 2013 11:03:27 for GTK+ IOStream by
1.8.3.1