Pratt 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.exrc +61 -0
- data/.gitignore +4 -0
- data/History.txt +6 -0
- data/Manifest.txt +46 -0
- data/Pratt.gemspec +351 -0
- data/README.txt +66 -0
- data/Rakefile +85 -0
- data/TODO +54 -0
- data/VERSION +1 -0
- data/bin/pratt.rb +13 -0
- data/config.rb +34 -0
- data/lib/pratt.rb +527 -0
- data/lib/pratt/array.rb +11 -0
- data/lib/pratt/string.rb +18 -0
- data/models/app.rb +40 -0
- data/models/customer.rb +24 -0
- data/models/payment.rb +22 -0
- data/models/pratt.rb +19 -0
- data/models/project.rb +82 -0
- data/models/whence.rb +70 -0
- data/pkgs/tile-0.8.2.tar.gz +0 -0
- data/pkgs/tile-0.8.2/ANNOUNCE.txt +95 -0
- data/pkgs/tile-0.8.2/ChangeLog +4651 -0
- data/pkgs/tile-0.8.2/Makefile +250 -0
- data/pkgs/tile-0.8.2/Makefile.in +250 -0
- data/pkgs/tile-0.8.2/README.txt +86 -0
- data/pkgs/tile-0.8.2/aclocal.m4 +2 -0
- data/pkgs/tile-0.8.2/altTheme.o +0 -0
- data/pkgs/tile-0.8.2/blink.o +0 -0
- data/pkgs/tile-0.8.2/button.o +0 -0
- data/pkgs/tile-0.8.2/cache.o +0 -0
- data/pkgs/tile-0.8.2/clamTheme.o +0 -0
- data/pkgs/tile-0.8.2/classicTheme.o +0 -0
- data/pkgs/tile-0.8.2/config.log +1330 -0
- data/pkgs/tile-0.8.2/config.status +795 -0
- data/pkgs/tile-0.8.2/configure +15248 -0
- data/pkgs/tile-0.8.2/configure.in +89 -0
- data/pkgs/tile-0.8.2/demos/autocomplete.tcl +59 -0
- data/pkgs/tile-0.8.2/demos/demo.tcl +870 -0
- data/pkgs/tile-0.8.2/demos/dirbrowser.tcl +167 -0
- data/pkgs/tile-0.8.2/demos/dlgtest.tcl +97 -0
- data/pkgs/tile-0.8.2/demos/iconlib.tcl +110 -0
- data/pkgs/tile-0.8.2/demos/repeater.tcl +117 -0
- data/pkgs/tile-0.8.2/demos/toolbutton.tcl +101 -0
- data/pkgs/tile-0.8.2/doc/Geometry.3 +230 -0
- data/pkgs/tile-0.8.2/doc/INDEX.MAP +153 -0
- data/pkgs/tile-0.8.2/doc/Makefile +36 -0
- data/pkgs/tile-0.8.2/doc/TILE.XML +45 -0
- data/pkgs/tile-0.8.2/doc/Theme.3 +34 -0
- data/pkgs/tile-0.8.2/doc/button.n +75 -0
- data/pkgs/tile-0.8.2/doc/checkbutton.n +61 -0
- data/pkgs/tile-0.8.2/doc/combobox.n +98 -0
- data/pkgs/tile-0.8.2/doc/converting.txt +97 -0
- data/pkgs/tile-0.8.2/doc/dialog.n +122 -0
- data/pkgs/tile-0.8.2/doc/entry.n +438 -0
- data/pkgs/tile-0.8.2/doc/frame.n +43 -0
- data/pkgs/tile-0.8.2/doc/html/Geometry.html +304 -0
- data/pkgs/tile-0.8.2/doc/html/Theme.html +48 -0
- data/pkgs/tile-0.8.2/doc/html/button.html +120 -0
- data/pkgs/tile-0.8.2/doc/html/category-index.html +18 -0
- data/pkgs/tile-0.8.2/doc/html/checkbutton.html +94 -0
- data/pkgs/tile-0.8.2/doc/html/combobox.html +164 -0
- data/pkgs/tile-0.8.2/doc/html/converting.txt +97 -0
- data/pkgs/tile-0.8.2/doc/html/dialog.html +159 -0
- data/pkgs/tile-0.8.2/doc/html/entry.html +613 -0
- data/pkgs/tile-0.8.2/doc/html/frame.html +76 -0
- data/pkgs/tile-0.8.2/doc/html/image.html +100 -0
- data/pkgs/tile-0.8.2/doc/html/index.html +25 -0
- data/pkgs/tile-0.8.2/doc/html/keyword-index.html +228 -0
- data/pkgs/tile-0.8.2/doc/html/label.html +133 -0
- data/pkgs/tile-0.8.2/doc/html/labelframe.html +91 -0
- data/pkgs/tile-0.8.2/doc/html/manpage.css +212 -0
- data/pkgs/tile-0.8.2/doc/html/menubutton.html +63 -0
- data/pkgs/tile-0.8.2/doc/html/notebook.html +280 -0
- data/pkgs/tile-0.8.2/doc/html/paned.html +149 -0
- data/pkgs/tile-0.8.2/doc/html/progressbar.html +138 -0
- data/pkgs/tile-0.8.2/doc/html/radiobutton.html +89 -0
- data/pkgs/tile-0.8.2/doc/html/scrollbar.html +221 -0
- data/pkgs/tile-0.8.2/doc/html/separator.html +48 -0
- data/pkgs/tile-0.8.2/doc/html/sizegrip.html +62 -0
- data/pkgs/tile-0.8.2/doc/html/style.html +172 -0
- data/pkgs/tile-0.8.2/doc/html/tile-intro.html +164 -0
- data/pkgs/tile-0.8.2/doc/html/treeview.html +634 -0
- data/pkgs/tile-0.8.2/doc/html/widget.html +342 -0
- data/pkgs/tile-0.8.2/doc/image.n +81 -0
- data/pkgs/tile-0.8.2/doc/internals.txt +409 -0
- data/pkgs/tile-0.8.2/doc/label.n +75 -0
- data/pkgs/tile-0.8.2/doc/labelframe.n +64 -0
- data/pkgs/tile-0.8.2/doc/man.macros +239 -0
- data/pkgs/tile-0.8.2/doc/menubutton.n +41 -0
- data/pkgs/tile-0.8.2/doc/notebook.n +188 -0
- data/pkgs/tile-0.8.2/doc/paned.n +95 -0
- data/pkgs/tile-0.8.2/doc/progressbar.n +79 -0
- data/pkgs/tile-0.8.2/doc/radiobutton.n +57 -0
- data/pkgs/tile-0.8.2/doc/scrollbar.n +160 -0
- data/pkgs/tile-0.8.2/doc/separator.n +30 -0
- data/pkgs/tile-0.8.2/doc/sizegrip.n +53 -0
- data/pkgs/tile-0.8.2/doc/style.n +119 -0
- data/pkgs/tile-0.8.2/doc/tile-intro.n +165 -0
- data/pkgs/tile-0.8.2/doc/tmml.options +4 -0
- data/pkgs/tile-0.8.2/doc/treeview.n +415 -0
- data/pkgs/tile-0.8.2/doc/widget.n +227 -0
- data/pkgs/tile-0.8.2/doc/xml/Geometry.tmml +379 -0
- data/pkgs/tile-0.8.2/doc/xml/INDEX.MAP +153 -0
- data/pkgs/tile-0.8.2/doc/xml/Theme.tmml +63 -0
- data/pkgs/tile-0.8.2/doc/xml/button.tmml +134 -0
- data/pkgs/tile-0.8.2/doc/xml/checkbutton.tmml +119 -0
- data/pkgs/tile-0.8.2/doc/xml/combobox.tmml +184 -0
- data/pkgs/tile-0.8.2/doc/xml/dialog.tmml +195 -0
- data/pkgs/tile-0.8.2/doc/xml/entry.tmml +630 -0
- data/pkgs/tile-0.8.2/doc/xml/frame.tmml +98 -0
- data/pkgs/tile-0.8.2/doc/xml/image.tmml +101 -0
- data/pkgs/tile-0.8.2/doc/xml/label.tmml +154 -0
- data/pkgs/tile-0.8.2/doc/xml/labelframe.tmml +116 -0
- data/pkgs/tile-0.8.2/doc/xml/menubutton.tmml +80 -0
- data/pkgs/tile-0.8.2/doc/xml/notebook.tmml +306 -0
- data/pkgs/tile-0.8.2/doc/xml/paned.tmml +154 -0
- data/pkgs/tile-0.8.2/doc/xml/progressbar.tmml +151 -0
- data/pkgs/tile-0.8.2/doc/xml/radiobutton.tmml +109 -0
- data/pkgs/tile-0.8.2/doc/xml/scrollbar.tmml +233 -0
- data/pkgs/tile-0.8.2/doc/xml/separator.tmml +59 -0
- data/pkgs/tile-0.8.2/doc/xml/sizegrip.tmml +82 -0
- data/pkgs/tile-0.8.2/doc/xml/style.tmml +171 -0
- data/pkgs/tile-0.8.2/doc/xml/tile-intro.tmml +192 -0
- data/pkgs/tile-0.8.2/doc/xml/treeview.tmml +604 -0
- data/pkgs/tile-0.8.2/doc/xml/widget.tmml +372 -0
- data/pkgs/tile-0.8.2/entry.o +0 -0
- data/pkgs/tile-0.8.2/frame.o +0 -0
- data/pkgs/tile-0.8.2/generic/Makefile.in +221 -0
- data/pkgs/tile-0.8.2/generic/TODO +493 -0
- data/pkgs/tile-0.8.2/generic/altTheme.c +1172 -0
- data/pkgs/tile-0.8.2/generic/blink.c +168 -0
- data/pkgs/tile-0.8.2/generic/button.c +858 -0
- data/pkgs/tile-0.8.2/generic/cache.c +354 -0
- data/pkgs/tile-0.8.2/generic/clamTheme.c +974 -0
- data/pkgs/tile-0.8.2/generic/classicTheme.c +518 -0
- data/pkgs/tile-0.8.2/generic/configure +10334 -0
- data/pkgs/tile-0.8.2/generic/configure.in +100 -0
- data/pkgs/tile-0.8.2/generic/entry.c +1922 -0
- data/pkgs/tile-0.8.2/generic/frame.c +648 -0
- data/pkgs/tile-0.8.2/generic/gunk.h +44 -0
- data/pkgs/tile-0.8.2/generic/image.c +416 -0
- data/pkgs/tile-0.8.2/generic/label.c +663 -0
- data/pkgs/tile-0.8.2/generic/layout.c +1215 -0
- data/pkgs/tile-0.8.2/generic/manager.c +554 -0
- data/pkgs/tile-0.8.2/generic/manager.h +91 -0
- data/pkgs/tile-0.8.2/generic/notebook.c +1380 -0
- data/pkgs/tile-0.8.2/generic/paned.c +958 -0
- data/pkgs/tile-0.8.2/generic/pkgIndex.tcl.in +7 -0
- data/pkgs/tile-0.8.2/generic/progress.c +549 -0
- data/pkgs/tile-0.8.2/generic/scale.c +526 -0
- data/pkgs/tile-0.8.2/generic/scroll.c +253 -0
- data/pkgs/tile-0.8.2/generic/scrollbar.c +346 -0
- data/pkgs/tile-0.8.2/generic/separator.c +132 -0
- data/pkgs/tile-0.8.2/generic/square.c +306 -0
- data/pkgs/tile-0.8.2/generic/tagset.c +147 -0
- data/pkgs/tile-0.8.2/generic/tile.c +296 -0
- data/pkgs/tile-0.8.2/generic/tkElements.c +1280 -0
- data/pkgs/tile-0.8.2/generic/tkTheme.c +1708 -0
- data/pkgs/tile-0.8.2/generic/tkTheme.h +419 -0
- data/pkgs/tile-0.8.2/generic/tkThemeInt.h +45 -0
- data/pkgs/tile-0.8.2/generic/tkstate.c +268 -0
- data/pkgs/tile-0.8.2/generic/trace.c +145 -0
- data/pkgs/tile-0.8.2/generic/track.c +174 -0
- data/pkgs/tile-0.8.2/generic/treeview.c +3211 -0
- data/pkgs/tile-0.8.2/generic/ttk.decls +154 -0
- data/pkgs/tile-0.8.2/generic/ttkDecls.h +340 -0
- data/pkgs/tile-0.8.2/generic/ttkStubInit.c +61 -0
- data/pkgs/tile-0.8.2/generic/ttkStubLib.c +70 -0
- data/pkgs/tile-0.8.2/generic/widget.c +785 -0
- data/pkgs/tile-0.8.2/generic/widget.h +263 -0
- data/pkgs/tile-0.8.2/image.o +0 -0
- data/pkgs/tile-0.8.2/label.o +0 -0
- data/pkgs/tile-0.8.2/layout.o +0 -0
- data/pkgs/tile-0.8.2/library/altTheme.tcl +101 -0
- data/pkgs/tile-0.8.2/library/aquaTheme.tcl +62 -0
- data/pkgs/tile-0.8.2/library/button.tcl +85 -0
- data/pkgs/tile-0.8.2/library/clamTheme.tcl +139 -0
- data/pkgs/tile-0.8.2/library/classicTheme.tcl +108 -0
- data/pkgs/tile-0.8.2/library/combobox.tcl +439 -0
- data/pkgs/tile-0.8.2/library/cursors.tcl +36 -0
- data/pkgs/tile-0.8.2/library/defaults.tcl +118 -0
- data/pkgs/tile-0.8.2/library/dialog.tcl +274 -0
- data/pkgs/tile-0.8.2/library/entry.tcl +580 -0
- data/pkgs/tile-0.8.2/library/fonts.tcl +153 -0
- data/pkgs/tile-0.8.2/library/icons.tcl +105 -0
- data/pkgs/tile-0.8.2/library/keynav.tcl +192 -0
- data/pkgs/tile-0.8.2/library/menubutton.tcl +171 -0
- data/pkgs/tile-0.8.2/library/notebook.tcl +193 -0
- data/pkgs/tile-0.8.2/library/paned.tcl +87 -0
- data/pkgs/tile-0.8.2/library/progress.tcl +51 -0
- data/pkgs/tile-0.8.2/library/scale.tcl +54 -0
- data/pkgs/tile-0.8.2/library/scrollbar.tcl +125 -0
- data/pkgs/tile-0.8.2/library/sizegrip.tcl +77 -0
- data/pkgs/tile-0.8.2/library/tile.tcl +211 -0
- data/pkgs/tile-0.8.2/library/treeview.tcl +382 -0
- data/pkgs/tile-0.8.2/library/utils.tcl +254 -0
- data/pkgs/tile-0.8.2/library/winTheme.tcl +77 -0
- data/pkgs/tile-0.8.2/library/xpTheme.tcl +63 -0
- data/pkgs/tile-0.8.2/libtile0.8.2.so +0 -0
- data/pkgs/tile-0.8.2/libttkstub.a +0 -0
- data/pkgs/tile-0.8.2/license.terms +24 -0
- data/pkgs/tile-0.8.2/macosx/aquaTheme.c +1076 -0
- data/pkgs/tile-0.8.2/manager.o +0 -0
- data/pkgs/tile-0.8.2/notebook.o +0 -0
- data/pkgs/tile-0.8.2/paned.o +0 -0
- data/pkgs/tile-0.8.2/pkgIndex.tcl +3 -0
- data/pkgs/tile-0.8.2/progress.o +0 -0
- data/pkgs/tile-0.8.2/scale.o +0 -0
- data/pkgs/tile-0.8.2/scroll.o +0 -0
- data/pkgs/tile-0.8.2/scrollbar.o +0 -0
- data/pkgs/tile-0.8.2/separator.o +0 -0
- data/pkgs/tile-0.8.2/tagset.o +0 -0
- data/pkgs/tile-0.8.2/tclconfig/install-sh +119 -0
- data/pkgs/tile-0.8.2/tclconfig/tcl.m4 +4069 -0
- data/pkgs/tile-0.8.2/tclconfig/teax.m4 +109 -0
- data/pkgs/tile-0.8.2/tests/all.tcl +18 -0
- data/pkgs/tile-0.8.2/tests/bwidget.test +103 -0
- data/pkgs/tile-0.8.2/tests/cbtest.tcl +125 -0
- data/pkgs/tile-0.8.2/tests/combobox.test +51 -0
- data/pkgs/tile-0.8.2/tests/compound.tcl +92 -0
- data/pkgs/tile-0.8.2/tests/entry.test +285 -0
- data/pkgs/tile-0.8.2/tests/entrytest.tcl +78 -0
- data/pkgs/tile-0.8.2/tests/image.test +94 -0
- data/pkgs/tile-0.8.2/tests/labelframe.tcl +41 -0
- data/pkgs/tile-0.8.2/tests/labelframe.test +137 -0
- data/pkgs/tile-0.8.2/tests/layout.test +33 -0
- data/pkgs/tile-0.8.2/tests/misc.test +35 -0
- data/pkgs/tile-0.8.2/tests/nbtest.tcl +66 -0
- data/pkgs/tile-0.8.2/tests/notebook.test +500 -0
- data/pkgs/tile-0.8.2/tests/paned.test +298 -0
- data/pkgs/tile-0.8.2/tests/progress.test +92 -0
- data/pkgs/tile-0.8.2/tests/pwtest.tcl +90 -0
- data/pkgs/tile-0.8.2/tests/sbtest.tcl +79 -0
- data/pkgs/tile-0.8.2/tests/scrollbar.test +77 -0
- data/pkgs/tile-0.8.2/tests/sgtest.tcl +52 -0
- data/pkgs/tile-0.8.2/tests/testutils.tcl +20 -0
- data/pkgs/tile-0.8.2/tests/tile.test +674 -0
- data/pkgs/tile-0.8.2/tests/treetags.test +78 -0
- data/pkgs/tile-0.8.2/tests/treeview.test +563 -0
- data/pkgs/tile-0.8.2/tests/tvtest.tcl +332 -0
- data/pkgs/tile-0.8.2/tests/validate.test +278 -0
- data/pkgs/tile-0.8.2/tile.o +0 -0
- data/pkgs/tile-0.8.2/tkElements.o +0 -0
- data/pkgs/tile-0.8.2/tkTheme.o +0 -0
- data/pkgs/tile-0.8.2/tkstate.o +0 -0
- data/pkgs/tile-0.8.2/tools/genStubs.tcl +861 -0
- data/pkgs/tile-0.8.2/trace.o +0 -0
- data/pkgs/tile-0.8.2/track.o +0 -0
- data/pkgs/tile-0.8.2/treeview.o +0 -0
- data/pkgs/tile-0.8.2/ttkStubInit.o +0 -0
- data/pkgs/tile-0.8.2/ttkStubLib.o +0 -0
- data/pkgs/tile-0.8.2/widget.o +0 -0
- data/pkgs/tile-0.8.2/win/Tile.dsp +261 -0
- data/pkgs/tile-0.8.2/win/makefile.vc +527 -0
- data/pkgs/tile-0.8.2/win/monitor.c +164 -0
- data/pkgs/tile-0.8.2/win/nmakehlp.c +483 -0
- data/pkgs/tile-0.8.2/win/rules.vc +512 -0
- data/pkgs/tile-0.8.2/win/tile.rc +40 -0
- data/pkgs/tile-0.8.2/win/winTheme.c +734 -0
- data/pkgs/tile-0.8.2/win/xpTheme.c +1029 -0
- data/spec/app_spec.rb +48 -0
- data/spec/customer_spec.rb +31 -0
- data/spec/fixtures/graph.expectation +18 -0
- data/spec/payment_spec.rb +19 -0
- data/spec/pratt_spec.rb +148 -0
- data/spec/project_spec.rb +163 -0
- data/spec/rcov.opts +0 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/whence_spec.rb +54 -0
- data/tasks/pratt.rb +84 -0
- data/templates/model.eruby +12 -0
- data/templates/spec.eruby +8 -0
- data/views/env.rb +22 -0
- data/views/graph.eruby +20 -0
- data/views/invoice.eruby +148 -0
- data/views/main.rb +92 -0
- data/views/pid.eruby +3 -0
- data/views/pop.rb +94 -0
- data/views/pop2.rb +75 -0
- data/views/raw.eruby +11 -0
- metadata +390 -0
@@ -0,0 +1,549 @@
|
|
1
|
+
/* progress.c,v 1.16 2006/12/14 19:51:30 jenglish Exp
|
2
|
+
*
|
3
|
+
* Copyright (c) Joe English, Pat Thoyts, Michael Kirkham
|
4
|
+
*
|
5
|
+
* ttk::progressbar widget.
|
6
|
+
*/
|
7
|
+
|
8
|
+
#include <math.h>
|
9
|
+
#include <tk.h>
|
10
|
+
|
11
|
+
#include "tkTheme.h"
|
12
|
+
#include "widget.h"
|
13
|
+
|
14
|
+
/*------------------------------------------------------------------------
|
15
|
+
* +++ Widget record:
|
16
|
+
*/
|
17
|
+
|
18
|
+
#define DEF_PROGRESSBAR_LENGTH "100"
|
19
|
+
enum {
|
20
|
+
TTK_PROGRESSBAR_DETERMINATE, TTK_PROGRESSBAR_INDETERMINATE
|
21
|
+
};
|
22
|
+
static const char *ProgressbarModeStrings[] = {
|
23
|
+
"determinate", "indeterminate", NULL
|
24
|
+
};
|
25
|
+
|
26
|
+
typedef struct {
|
27
|
+
Tcl_Obj *orientObj;
|
28
|
+
Tcl_Obj *lengthObj;
|
29
|
+
Tcl_Obj *modeObj;
|
30
|
+
Tcl_Obj *variableObj;
|
31
|
+
Tcl_Obj *maximumObj;
|
32
|
+
Tcl_Obj *valueObj;
|
33
|
+
Tcl_Obj *phaseObj;
|
34
|
+
|
35
|
+
int mode;
|
36
|
+
Ttk_TraceHandle *variableTrace; /* Trace handle for -variable option */
|
37
|
+
int period; /* Animation period */
|
38
|
+
int maxPhase; /* Max animation phase */
|
39
|
+
Tcl_TimerToken timer; /* Animation timer */
|
40
|
+
|
41
|
+
} ProgressbarPart;
|
42
|
+
|
43
|
+
typedef struct {
|
44
|
+
WidgetCore core;
|
45
|
+
ProgressbarPart progress;
|
46
|
+
} Progressbar;
|
47
|
+
|
48
|
+
static Tk_OptionSpec ProgressbarOptionSpecs[] =
|
49
|
+
{
|
50
|
+
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient",
|
51
|
+
"horizontal", Tk_Offset(Progressbar,progress.orientObj), -1,
|
52
|
+
0, (ClientData)ttkOrientStrings, STYLE_CHANGED },
|
53
|
+
{TK_OPTION_PIXELS, "-length", "length", "Length",
|
54
|
+
DEF_PROGRESSBAR_LENGTH, Tk_Offset(Progressbar,progress.lengthObj), -1,
|
55
|
+
0, 0, GEOMETRY_CHANGED },
|
56
|
+
{TK_OPTION_STRING_TABLE, "-mode", "mode", "ProgressMode", "determinate",
|
57
|
+
Tk_Offset(Progressbar,progress.modeObj),
|
58
|
+
Tk_Offset(Progressbar,progress.mode),
|
59
|
+
0, (ClientData)ProgressbarModeStrings, 0 },
|
60
|
+
{TK_OPTION_DOUBLE, "-maximum", "maximum", "Maximum",
|
61
|
+
"100", Tk_Offset(Progressbar,progress.maximumObj), -1,
|
62
|
+
0, 0, 0 },
|
63
|
+
{TK_OPTION_STRING, "-variable", "variable", "Variable",
|
64
|
+
NULL, Tk_Offset(Progressbar,progress.variableObj), -1,
|
65
|
+
TK_OPTION_NULL_OK, 0, 0 },
|
66
|
+
{TK_OPTION_DOUBLE, "-value", "value", "Value",
|
67
|
+
"0.0", Tk_Offset(Progressbar,progress.valueObj), -1,
|
68
|
+
0, 0, 0 },
|
69
|
+
{TK_OPTION_INT, "-phase", "phase", "Phase",
|
70
|
+
"0", Tk_Offset(Progressbar,progress.phaseObj), -1,
|
71
|
+
0, 0, 0 },
|
72
|
+
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
|
73
|
+
};
|
74
|
+
|
75
|
+
/*------------------------------------------------------------------------
|
76
|
+
* +++ Animation procedures:
|
77
|
+
*/
|
78
|
+
|
79
|
+
/* AnimationEnabled --
|
80
|
+
* Returns 1 if animation should be active, 0 otherwise.
|
81
|
+
*/
|
82
|
+
static int AnimationEnabled(Progressbar *pb)
|
83
|
+
{
|
84
|
+
double maximum = 100, value = 0;
|
85
|
+
|
86
|
+
Tcl_GetDoubleFromObj(NULL, pb->progress.maximumObj, &maximum);
|
87
|
+
Tcl_GetDoubleFromObj(NULL, pb->progress.valueObj, &value);
|
88
|
+
|
89
|
+
return pb->progress.period > 0
|
90
|
+
&& value > 0.0
|
91
|
+
&& ( value < maximum
|
92
|
+
|| pb->progress.mode == TTK_PROGRESSBAR_INDETERMINATE);
|
93
|
+
}
|
94
|
+
|
95
|
+
/* AnimateProgressProc --
|
96
|
+
* Timer callback for progress bar animation.
|
97
|
+
* Increments the -phase option, redisplays the widget,
|
98
|
+
* and reschedules itself if animation still enabled.
|
99
|
+
*/
|
100
|
+
static void AnimateProgressProc(ClientData clientData)
|
101
|
+
{
|
102
|
+
Progressbar *pb = clientData;
|
103
|
+
|
104
|
+
pb->progress.timer = 0;
|
105
|
+
|
106
|
+
if (AnimationEnabled(pb)) {
|
107
|
+
int phase = 0;
|
108
|
+
Tcl_GetIntFromObj(NULL, pb->progress.phaseObj, &phase);
|
109
|
+
|
110
|
+
/*
|
111
|
+
* Update -phase:
|
112
|
+
*/
|
113
|
+
++phase;
|
114
|
+
if (pb->progress.maxPhase)
|
115
|
+
phase %= pb->progress.maxPhase;
|
116
|
+
Tcl_DecrRefCount(pb->progress.phaseObj);
|
117
|
+
pb->progress.phaseObj = Tcl_NewIntObj(phase);
|
118
|
+
Tcl_IncrRefCount(pb->progress.phaseObj);
|
119
|
+
|
120
|
+
/*
|
121
|
+
* Reschedule:
|
122
|
+
*/
|
123
|
+
pb->progress.timer = Tcl_CreateTimerHandler(
|
124
|
+
pb->progress.period, AnimateProgressProc, clientData);
|
125
|
+
|
126
|
+
TtkRedisplayWidget(&pb->core);
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
/* CheckAnimation --
|
131
|
+
* If animation is enabled and not scheduled, schedule it.
|
132
|
+
* If animation is disabled but scheduled, cancel it.
|
133
|
+
*/
|
134
|
+
static void CheckAnimation(Progressbar *pb)
|
135
|
+
{
|
136
|
+
if (AnimationEnabled(pb)) {
|
137
|
+
if (pb->progress.timer == 0) {
|
138
|
+
pb->progress.timer = Tcl_CreateTimerHandler(
|
139
|
+
pb->progress.period, AnimateProgressProc, (ClientData)pb);
|
140
|
+
}
|
141
|
+
} else {
|
142
|
+
if (pb->progress.timer != 0) {
|
143
|
+
Tcl_DeleteTimerHandler(pb->progress.timer);
|
144
|
+
pb->progress.timer = 0;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
|
149
|
+
/*------------------------------------------------------------------------
|
150
|
+
* +++ Trace hook for progressbar -variable option:
|
151
|
+
*/
|
152
|
+
|
153
|
+
static void VariableChanged(void *recordPtr, const char *value)
|
154
|
+
{
|
155
|
+
Progressbar *pb = recordPtr;
|
156
|
+
Tcl_Obj *newValue;
|
157
|
+
double scratch;
|
158
|
+
|
159
|
+
if (WidgetDestroyed(&pb->core)) {
|
160
|
+
return;
|
161
|
+
}
|
162
|
+
|
163
|
+
if (!value) {
|
164
|
+
/* Linked variable is unset -- disable widget */
|
165
|
+
TtkWidgetChangeState(&pb->core, TTK_STATE_DISABLED, 0);
|
166
|
+
return;
|
167
|
+
}
|
168
|
+
TtkWidgetChangeState(&pb->core, 0, TTK_STATE_DISABLED);
|
169
|
+
|
170
|
+
newValue = Tcl_NewStringObj(value, -1);
|
171
|
+
Tcl_IncrRefCount(newValue);
|
172
|
+
if (Tcl_GetDoubleFromObj(NULL, newValue, &scratch) != TCL_OK) {
|
173
|
+
TtkWidgetChangeState(&pb->core, TTK_STATE_INVALID, 0);
|
174
|
+
return;
|
175
|
+
}
|
176
|
+
TtkWidgetChangeState(&pb->core, 0, TTK_STATE_INVALID);
|
177
|
+
Tcl_DecrRefCount(pb->progress.valueObj);
|
178
|
+
pb->progress.valueObj = newValue;
|
179
|
+
|
180
|
+
CheckAnimation(pb);
|
181
|
+
TtkRedisplayWidget(&pb->core);
|
182
|
+
}
|
183
|
+
|
184
|
+
/*------------------------------------------------------------------------
|
185
|
+
* +++ Widget class methods:
|
186
|
+
*/
|
187
|
+
|
188
|
+
static int ProgressbarInitialize(Tcl_Interp *interp, void *recordPtr)
|
189
|
+
{
|
190
|
+
Progressbar *pb = recordPtr;
|
191
|
+
pb->progress.variableTrace = 0;
|
192
|
+
pb->progress.timer = 0;
|
193
|
+
return TCL_OK;
|
194
|
+
}
|
195
|
+
|
196
|
+
static void ProgressbarCleanup(void *recordPtr)
|
197
|
+
{
|
198
|
+
Progressbar *pb = recordPtr;
|
199
|
+
if (pb->progress.variableTrace)
|
200
|
+
Ttk_UntraceVariable(pb->progress.variableTrace);
|
201
|
+
if (pb->progress.timer)
|
202
|
+
Tcl_DeleteTimerHandler(pb->progress.timer);
|
203
|
+
}
|
204
|
+
|
205
|
+
/*
|
206
|
+
* Configure hook:
|
207
|
+
*
|
208
|
+
* @@@ TODO: deal with [$pb configure -value ... -variable ...]
|
209
|
+
*/
|
210
|
+
static int ProgressbarConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
|
211
|
+
{
|
212
|
+
Progressbar *pb = recordPtr;
|
213
|
+
Tcl_Obj *varName = pb->progress.variableObj;
|
214
|
+
Ttk_TraceHandle *vt = 0;
|
215
|
+
|
216
|
+
if (varName != NULL && *Tcl_GetString(varName) != '\0') {
|
217
|
+
vt = Ttk_TraceVariable(interp, varName, VariableChanged, recordPtr);
|
218
|
+
if (!vt) return TCL_ERROR;
|
219
|
+
}
|
220
|
+
|
221
|
+
if (TtkCoreConfigure(interp, recordPtr, mask) != TCL_OK) {
|
222
|
+
if (vt) Ttk_UntraceVariable(vt);
|
223
|
+
return TCL_ERROR;
|
224
|
+
}
|
225
|
+
|
226
|
+
if (pb->progress.variableTrace) {
|
227
|
+
Ttk_UntraceVariable(pb->progress.variableTrace);
|
228
|
+
}
|
229
|
+
pb->progress.variableTrace = vt;
|
230
|
+
|
231
|
+
return TCL_OK;
|
232
|
+
}
|
233
|
+
|
234
|
+
/*
|
235
|
+
* Post-configuration hook:
|
236
|
+
*/
|
237
|
+
static int ProgressbarPostConfigure(
|
238
|
+
Tcl_Interp *interp, void *recordPtr, int mask)
|
239
|
+
{
|
240
|
+
Progressbar *pb = recordPtr;
|
241
|
+
int status = TCL_OK;
|
242
|
+
|
243
|
+
if (pb->progress.variableTrace) {
|
244
|
+
status = Ttk_FireTrace(pb->progress.variableTrace);
|
245
|
+
if (WidgetDestroyed(&pb->core)) {
|
246
|
+
return TCL_ERROR;
|
247
|
+
}
|
248
|
+
if (status != TCL_OK) {
|
249
|
+
/* Unset -variable: */
|
250
|
+
Ttk_UntraceVariable(pb->progress.variableTrace);
|
251
|
+
Tcl_DecrRefCount(pb->progress.variableObj);
|
252
|
+
pb->progress.variableTrace = 0;
|
253
|
+
pb->progress.variableObj = NULL;
|
254
|
+
return TCL_ERROR;
|
255
|
+
}
|
256
|
+
}
|
257
|
+
|
258
|
+
CheckAnimation(pb);
|
259
|
+
|
260
|
+
return status;
|
261
|
+
}
|
262
|
+
|
263
|
+
/*
|
264
|
+
* Size hook:
|
265
|
+
* Compute base layout size, overrid
|
266
|
+
*/
|
267
|
+
static int ProgressbarSize(void *recordPtr, int *widthPtr, int *heightPtr)
|
268
|
+
{
|
269
|
+
Progressbar *pb = recordPtr;
|
270
|
+
int length = 100, orient = TTK_ORIENT_HORIZONTAL;
|
271
|
+
|
272
|
+
TtkWidgetSize(recordPtr, widthPtr, heightPtr);
|
273
|
+
|
274
|
+
/* Override requested width (height) based on -length and -orient
|
275
|
+
*/
|
276
|
+
Tk_GetPixelsFromObj(NULL, pb->core.tkwin, pb->progress.lengthObj, &length);
|
277
|
+
Ttk_GetOrientFromObj(NULL, pb->progress.orientObj, &orient);
|
278
|
+
|
279
|
+
if (orient == TTK_ORIENT_HORIZONTAL) {
|
280
|
+
*widthPtr = length;
|
281
|
+
} else {
|
282
|
+
*heightPtr = length;
|
283
|
+
}
|
284
|
+
|
285
|
+
return 1;
|
286
|
+
}
|
287
|
+
|
288
|
+
/*
|
289
|
+
* Layout hook:
|
290
|
+
* Adjust size and position of pbar element, if present.
|
291
|
+
*/
|
292
|
+
|
293
|
+
static void ProgressbarDeterminateLayout(
|
294
|
+
Progressbar *pb,
|
295
|
+
Ttk_LayoutNode *pbarNode,
|
296
|
+
Ttk_Box parcel,
|
297
|
+
double fraction,
|
298
|
+
Ttk_Orient orient)
|
299
|
+
{
|
300
|
+
if (fraction < 0.0) fraction = 0.0;
|
301
|
+
if (fraction > 1.0) fraction = 1.0;
|
302
|
+
|
303
|
+
if (orient == TTK_ORIENT_HORIZONTAL) {
|
304
|
+
parcel.width = (int)(parcel.width * fraction);
|
305
|
+
} else {
|
306
|
+
int newHeight = (int)(parcel.height * fraction);
|
307
|
+
parcel.y += (parcel.height - newHeight);
|
308
|
+
parcel.height = newHeight;
|
309
|
+
}
|
310
|
+
Ttk_PlaceLayoutNode(pb->core.layout, pbarNode, parcel);
|
311
|
+
}
|
312
|
+
|
313
|
+
static void ProgressbarIndeterminateLayout(
|
314
|
+
Progressbar *pb,
|
315
|
+
Ttk_LayoutNode *pbarNode,
|
316
|
+
Ttk_Box parcel,
|
317
|
+
double fraction,
|
318
|
+
Ttk_Orient orient)
|
319
|
+
{
|
320
|
+
Ttk_Box pbarBox = Ttk_LayoutNodeParcel(pbarNode);
|
321
|
+
|
322
|
+
fraction = fmod(fabs(fraction), 2.0);
|
323
|
+
if (fraction > 1.0) {
|
324
|
+
fraction = 2.0 - fraction;
|
325
|
+
}
|
326
|
+
|
327
|
+
if (orient == TTK_ORIENT_HORIZONTAL) {
|
328
|
+
pbarBox.x = parcel.x + (int)(fraction * (parcel.width-pbarBox.width));
|
329
|
+
} else {
|
330
|
+
pbarBox.y = parcel.y + (int)(fraction * (parcel.height-pbarBox.height));
|
331
|
+
}
|
332
|
+
Ttk_PlaceLayoutNode(pb->core.layout, pbarNode, pbarBox);
|
333
|
+
}
|
334
|
+
|
335
|
+
static void ProgressbarDoLayout(void *recordPtr)
|
336
|
+
{
|
337
|
+
Progressbar *pb = recordPtr;
|
338
|
+
WidgetCore *corePtr = &pb->core;
|
339
|
+
Ttk_LayoutNode *pbarNode = Ttk_LayoutFindNode(corePtr->layout, "pbar");
|
340
|
+
Ttk_LayoutNode *troughNode = Ttk_LayoutFindNode(corePtr->layout, "trough");
|
341
|
+
double value = 0.0, maximum = 100.0;
|
342
|
+
int orient = TTK_ORIENT_HORIZONTAL;
|
343
|
+
Ttk_Box parcel = Ttk_WinBox(corePtr->tkwin);
|
344
|
+
|
345
|
+
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
|
346
|
+
|
347
|
+
/* Adjust the bar size:
|
348
|
+
*/
|
349
|
+
|
350
|
+
Tcl_GetDoubleFromObj(NULL, pb->progress.valueObj, &value);
|
351
|
+
Tcl_GetDoubleFromObj(NULL, pb->progress.maximumObj, &maximum);
|
352
|
+
Ttk_GetOrientFromObj(NULL, pb->progress.orientObj, &orient);
|
353
|
+
|
354
|
+
if (pbarNode) {
|
355
|
+
double fraction = value / maximum;
|
356
|
+
|
357
|
+
if (troughNode) {
|
358
|
+
parcel = Ttk_LayoutNodeInternalParcel(corePtr->layout, troughNode);
|
359
|
+
}
|
360
|
+
|
361
|
+
if (pb->progress.mode == TTK_PROGRESSBAR_DETERMINATE) {
|
362
|
+
ProgressbarDeterminateLayout(
|
363
|
+
pb, pbarNode, parcel, fraction, orient);
|
364
|
+
} else {
|
365
|
+
ProgressbarIndeterminateLayout(
|
366
|
+
pb, pbarNode, parcel, fraction, orient);
|
367
|
+
}
|
368
|
+
}
|
369
|
+
}
|
370
|
+
|
371
|
+
static Ttk_Layout ProgressbarGetLayout(
|
372
|
+
Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
|
373
|
+
{
|
374
|
+
Progressbar *pb = recordPtr;
|
375
|
+
Ttk_Layout layout = TtkWidgetGetOrientedLayout(
|
376
|
+
interp, theme, recordPtr, pb->progress.orientObj);
|
377
|
+
|
378
|
+
/*
|
379
|
+
* Check if the style supports animation:
|
380
|
+
*/
|
381
|
+
pb->progress.period = 0;
|
382
|
+
pb->progress.maxPhase = 0;
|
383
|
+
if (layout) {
|
384
|
+
Tcl_Obj *periodObj = Ttk_QueryOption(layout,"-period", 0);
|
385
|
+
Tcl_Obj *maxPhaseObj = Ttk_QueryOption(layout,"-maxphase", 0);
|
386
|
+
if (periodObj)
|
387
|
+
Tcl_GetIntFromObj(NULL, periodObj, &pb->progress.period);
|
388
|
+
if (maxPhaseObj)
|
389
|
+
Tcl_GetIntFromObj(NULL, maxPhaseObj, &pb->progress.maxPhase);
|
390
|
+
}
|
391
|
+
|
392
|
+
return layout;
|
393
|
+
}
|
394
|
+
|
395
|
+
/*------------------------------------------------------------------------
|
396
|
+
* +++ Widget commands:
|
397
|
+
*/
|
398
|
+
|
399
|
+
/* $sb step ?amount?
|
400
|
+
*/
|
401
|
+
static int ProgressbarStepCommand(
|
402
|
+
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
|
403
|
+
{
|
404
|
+
Progressbar *pb = recordPtr;
|
405
|
+
double value = 0.0, stepAmount = 1.0;
|
406
|
+
Tcl_Obj *newValueObj;
|
407
|
+
|
408
|
+
if (objc == 3) {
|
409
|
+
if (Tcl_GetDoubleFromObj(interp, objv[2], &stepAmount) != TCL_OK) {
|
410
|
+
return TCL_ERROR;
|
411
|
+
}
|
412
|
+
} else if (objc != 2) {
|
413
|
+
Tcl_WrongNumArgs(interp, 2,objv, "?stepAmount?");
|
414
|
+
return TCL_ERROR;
|
415
|
+
}
|
416
|
+
|
417
|
+
(void)Tcl_GetDoubleFromObj(NULL, pb->progress.valueObj, &value);
|
418
|
+
value += stepAmount;
|
419
|
+
|
420
|
+
/* In determinate mode, wrap around if value exceeds maximum:
|
421
|
+
*/
|
422
|
+
if (pb->progress.mode == TTK_PROGRESSBAR_DETERMINATE) {
|
423
|
+
double maximum = 100.0;
|
424
|
+
(void)Tcl_GetDoubleFromObj(NULL, pb->progress.maximumObj, &maximum);
|
425
|
+
value = fmod(value, maximum);
|
426
|
+
}
|
427
|
+
|
428
|
+
newValueObj = Tcl_NewDoubleObj(value);
|
429
|
+
|
430
|
+
TtkRedisplayWidget(&pb->core);
|
431
|
+
|
432
|
+
/* Update value by setting the linked -variable, if there is one:
|
433
|
+
*/
|
434
|
+
if (pb->progress.variableTrace) {
|
435
|
+
return Tcl_ObjSetVar2(
|
436
|
+
interp, pb->progress.variableObj, 0, newValueObj,
|
437
|
+
TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG)
|
438
|
+
? TCL_OK : TCL_ERROR;
|
439
|
+
}
|
440
|
+
|
441
|
+
/* Otherwise, change the -value directly:
|
442
|
+
*/
|
443
|
+
Tcl_IncrRefCount(newValueObj);
|
444
|
+
Tcl_DecrRefCount(pb->progress.valueObj);
|
445
|
+
pb->progress.valueObj = newValueObj;
|
446
|
+
CheckAnimation(pb);
|
447
|
+
|
448
|
+
return TCL_OK;
|
449
|
+
}
|
450
|
+
|
451
|
+
/* $sb start|stop ?args? --
|
452
|
+
* Change [$sb $cmd ...] to [ttk::progressbar::$cmd ...]
|
453
|
+
* and pass to interpreter.
|
454
|
+
*/
|
455
|
+
static int ProgressbarStartStopCommand(
|
456
|
+
Tcl_Interp *interp, const char *cmdName, int objc, Tcl_Obj *CONST objv[])
|
457
|
+
{
|
458
|
+
Tcl_Obj *cmd = Tcl_NewListObj(objc, objv);
|
459
|
+
Tcl_Obj *prefix[2];
|
460
|
+
int status;
|
461
|
+
|
462
|
+
/* ASSERT: objc >= 2 */
|
463
|
+
|
464
|
+
prefix[0] = Tcl_NewStringObj(cmdName, -1);
|
465
|
+
prefix[1] = objv[0];
|
466
|
+
Tcl_ListObjReplace(interp, cmd, 0,2, 2,prefix);
|
467
|
+
|
468
|
+
Tcl_IncrRefCount(cmd);
|
469
|
+
status = Tcl_EvalObjEx(interp, cmd, 0);
|
470
|
+
Tcl_DecrRefCount(cmd);
|
471
|
+
|
472
|
+
return status;
|
473
|
+
}
|
474
|
+
|
475
|
+
static int ProgressbarStartCommand(
|
476
|
+
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
|
477
|
+
{
|
478
|
+
return ProgressbarStartStopCommand(
|
479
|
+
interp, "::ttk::progressbar::start", objc, objv);
|
480
|
+
}
|
481
|
+
|
482
|
+
static int ProgressbarStopCommand(
|
483
|
+
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
|
484
|
+
{
|
485
|
+
return ProgressbarStartStopCommand(
|
486
|
+
interp, "::ttk::progressbar::stop", objc, objv);
|
487
|
+
}
|
488
|
+
|
489
|
+
static WidgetCommandSpec ProgressbarCommands[] =
|
490
|
+
{
|
491
|
+
{ "configure", TtkWidgetConfigureCommand },
|
492
|
+
{ "cget", TtkWidgetCgetCommand },
|
493
|
+
{ "identify", TtkWidgetIdentifyCommand },
|
494
|
+
{ "instate", TtkWidgetInstateCommand },
|
495
|
+
{ "start", ProgressbarStartCommand },
|
496
|
+
{ "state", TtkWidgetStateCommand },
|
497
|
+
{ "step", ProgressbarStepCommand },
|
498
|
+
{ "stop", ProgressbarStopCommand },
|
499
|
+
{ NULL, NULL }
|
500
|
+
};
|
501
|
+
|
502
|
+
/*
|
503
|
+
* Widget specification:
|
504
|
+
*/
|
505
|
+
static WidgetSpec ProgressbarWidgetSpec =
|
506
|
+
{
|
507
|
+
"TProgressbar", /* className */
|
508
|
+
sizeof(Progressbar), /* recordSize */
|
509
|
+
ProgressbarOptionSpecs, /* optionSpecs */
|
510
|
+
ProgressbarCommands, /* subcommands */
|
511
|
+
ProgressbarInitialize, /* initializeProc */
|
512
|
+
ProgressbarCleanup, /* cleanupProc */
|
513
|
+
ProgressbarConfigure, /* configureProc */
|
514
|
+
ProgressbarPostConfigure, /* postConfigureProc */
|
515
|
+
ProgressbarGetLayout, /* getLayoutProc */
|
516
|
+
ProgressbarSize, /* sizeProc */
|
517
|
+
ProgressbarDoLayout, /* layoutProc */
|
518
|
+
TtkWidgetDisplay /* displayProc */
|
519
|
+
};
|
520
|
+
|
521
|
+
/*
|
522
|
+
* Layouts:
|
523
|
+
*/
|
524
|
+
TTK_BEGIN_LAYOUT(VerticalProgressbarLayout)
|
525
|
+
TTK_GROUP("Vertical.Progressbar.trough", TTK_FILL_BOTH,
|
526
|
+
TTK_NODE("Vertical.Progressbar.pbar", TTK_PACK_BOTTOM|TTK_FILL_X))
|
527
|
+
TTK_END_LAYOUT
|
528
|
+
|
529
|
+
TTK_BEGIN_LAYOUT(HorizontalProgressbarLayout)
|
530
|
+
TTK_GROUP("Horizontal.Progressbar.trough", TTK_FILL_BOTH,
|
531
|
+
TTK_NODE("Horizontal.Progressbar.pbar", TTK_PACK_LEFT|TTK_FILL_Y))
|
532
|
+
TTK_END_LAYOUT
|
533
|
+
|
534
|
+
/*
|
535
|
+
* Initialization:
|
536
|
+
*/
|
537
|
+
void TtkProgressbar_Init(Tcl_Interp *interp)
|
538
|
+
{
|
539
|
+
Ttk_Theme themePtr = Ttk_GetDefaultTheme(interp);
|
540
|
+
|
541
|
+
Ttk_RegisterLayout(themePtr,
|
542
|
+
"Vertical.TProgressbar", VerticalProgressbarLayout);
|
543
|
+
Ttk_RegisterLayout(themePtr,
|
544
|
+
"Horizontal.TProgressbar", HorizontalProgressbarLayout);
|
545
|
+
|
546
|
+
RegisterWidget(interp, "ttk::progressbar", &ProgressbarWidgetSpec);
|
547
|
+
}
|
548
|
+
|
549
|
+
/*EOF*/
|