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,526 @@
|
|
1
|
+
/* scale.c,v 1.50 2007/10/25 06:42:47 jenglish Exp
|
2
|
+
* Copyright (C) 2004 Pat Thoyts <patthoyts@users.sourceforge.net>
|
3
|
+
*
|
4
|
+
* ttk::scale widget.
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <tk.h>
|
8
|
+
#include <string.h>
|
9
|
+
#include <stdio.h>
|
10
|
+
#include "tkTheme.h"
|
11
|
+
#include "widget.h"
|
12
|
+
|
13
|
+
#define DEF_SCALE_LENGTH "100"
|
14
|
+
|
15
|
+
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
16
|
+
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
17
|
+
|
18
|
+
/*
|
19
|
+
* Scale widget record
|
20
|
+
*/
|
21
|
+
typedef struct
|
22
|
+
{
|
23
|
+
/* slider element options */
|
24
|
+
Tcl_Obj *fromObj; /* minimum value */
|
25
|
+
Tcl_Obj *toObj; /* maximum value */
|
26
|
+
Tcl_Obj *valueObj; /* current value */
|
27
|
+
Tcl_Obj *lengthObj; /* length of the long axis of the scale */
|
28
|
+
Tcl_Obj *orientObj; /* widget orientation */
|
29
|
+
int orient;
|
30
|
+
|
31
|
+
/* widget options */
|
32
|
+
Tcl_Obj *commandObj;
|
33
|
+
Tcl_Obj *variableObj;
|
34
|
+
|
35
|
+
/* internal state */
|
36
|
+
Ttk_TraceHandle *variableTrace;
|
37
|
+
|
38
|
+
} ScalePart;
|
39
|
+
|
40
|
+
typedef struct
|
41
|
+
{
|
42
|
+
WidgetCore core;
|
43
|
+
ScalePart scale;
|
44
|
+
} Scale;
|
45
|
+
|
46
|
+
static Tk_OptionSpec ScaleOptionSpecs[] =
|
47
|
+
{
|
48
|
+
WIDGET_TAKES_FOCUS,
|
49
|
+
|
50
|
+
{TK_OPTION_STRING, "-command", "command", "Command", "",
|
51
|
+
Tk_Offset(Scale,scale.commandObj), -1,
|
52
|
+
TK_OPTION_NULL_OK,0,0},
|
53
|
+
{TK_OPTION_STRING, "-variable", "variable", "Variable", "",
|
54
|
+
Tk_Offset(Scale,scale.variableObj), -1,
|
55
|
+
0,0,0},
|
56
|
+
{TK_OPTION_STRING_TABLE, "-orient", "orient", "Orient", "horizontal",
|
57
|
+
Tk_Offset(Scale,scale.orientObj),
|
58
|
+
Tk_Offset(Scale,scale.orient), 0,
|
59
|
+
(ClientData)ttkOrientStrings, STYLE_CHANGED },
|
60
|
+
|
61
|
+
{TK_OPTION_DOUBLE, "-from", "from", "From", "0",
|
62
|
+
Tk_Offset(Scale,scale.fromObj), -1, 0, 0, 0},
|
63
|
+
{TK_OPTION_DOUBLE, "-to", "to", "To", "1.0",
|
64
|
+
Tk_Offset(Scale,scale.toObj), -1, 0, 0, 0},
|
65
|
+
{TK_OPTION_DOUBLE, "-value", "value", "Value", "0",
|
66
|
+
Tk_Offset(Scale,scale.valueObj), -1, 0, 0, 0},
|
67
|
+
{TK_OPTION_PIXELS, "-length", "length", "Length",
|
68
|
+
DEF_SCALE_LENGTH, Tk_Offset(Scale,scale.lengthObj), -1, 0, 0,
|
69
|
+
GEOMETRY_CHANGED},
|
70
|
+
|
71
|
+
WIDGET_INHERIT_OPTIONS(ttkCoreOptionSpecs)
|
72
|
+
};
|
73
|
+
|
74
|
+
static XPoint ValueToPoint(Scale *scalePtr, double value);
|
75
|
+
static double PointToValue(Scale *scalePtr, int x, int y);
|
76
|
+
|
77
|
+
/* ScaleVariableChanged --
|
78
|
+
* Variable trace procedure for scale -variable;
|
79
|
+
* Updates the scale's value.
|
80
|
+
* If the linked variable is not a valid double,
|
81
|
+
* sets the 'invalid' state.
|
82
|
+
*/
|
83
|
+
static void ScaleVariableChanged(void *recordPtr, const char *value)
|
84
|
+
{
|
85
|
+
Scale *scale = recordPtr;
|
86
|
+
double v;
|
87
|
+
|
88
|
+
if (value == NULL || Tcl_GetDouble(0, value, &v) != TCL_OK) {
|
89
|
+
TtkWidgetChangeState(&scale->core, TTK_STATE_INVALID, 0);
|
90
|
+
} else {
|
91
|
+
Tcl_Obj *valueObj = Tcl_NewDoubleObj(v);
|
92
|
+
Tcl_IncrRefCount(valueObj);
|
93
|
+
Tcl_DecrRefCount(scale->scale.valueObj);
|
94
|
+
scale->scale.valueObj = valueObj;
|
95
|
+
TtkWidgetChangeState(&scale->core, 0, TTK_STATE_INVALID);
|
96
|
+
}
|
97
|
+
TtkRedisplayWidget(&scale->core);
|
98
|
+
}
|
99
|
+
|
100
|
+
/* ScaleInitialize --
|
101
|
+
* Scale widget initialization hook.
|
102
|
+
*/
|
103
|
+
static int ScaleInitialize(Tcl_Interp *interp, void *recordPtr)
|
104
|
+
{
|
105
|
+
Scale *scalePtr = recordPtr;
|
106
|
+
|
107
|
+
TtkTrackElementState(&scalePtr->core);
|
108
|
+
return TCL_OK;
|
109
|
+
}
|
110
|
+
|
111
|
+
static void ScaleCleanup(void *recordPtr)
|
112
|
+
{
|
113
|
+
Scale *scale = recordPtr;
|
114
|
+
|
115
|
+
if (scale->scale.variableTrace) {
|
116
|
+
Ttk_UntraceVariable(scale->scale.variableTrace);
|
117
|
+
scale->scale.variableTrace = 0;
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
/* ScaleConfigure --
|
122
|
+
* Configuration hook.
|
123
|
+
*/
|
124
|
+
static int ScaleConfigure(Tcl_Interp *interp, void *recordPtr, int mask)
|
125
|
+
{
|
126
|
+
Scale *scale = recordPtr;
|
127
|
+
Tcl_Obj *varName = scale->scale.variableObj;
|
128
|
+
Ttk_TraceHandle *vt = 0;
|
129
|
+
|
130
|
+
if (varName != NULL && *Tcl_GetString(varName) != '\0') {
|
131
|
+
vt = Ttk_TraceVariable(interp,varName, ScaleVariableChanged,recordPtr);
|
132
|
+
if (!vt) return TCL_ERROR;
|
133
|
+
}
|
134
|
+
|
135
|
+
if (TtkCoreConfigure(interp, recordPtr, mask) != TCL_OK) {
|
136
|
+
if (vt) Ttk_UntraceVariable(vt);
|
137
|
+
return TCL_ERROR;
|
138
|
+
}
|
139
|
+
|
140
|
+
if (scale->scale.variableTrace) {
|
141
|
+
Ttk_UntraceVariable(scale->scale.variableTrace);
|
142
|
+
}
|
143
|
+
scale->scale.variableTrace = vt;
|
144
|
+
|
145
|
+
return TCL_OK;
|
146
|
+
}
|
147
|
+
|
148
|
+
/* ScalePostConfigure --
|
149
|
+
* Post-configuration hook.
|
150
|
+
*/
|
151
|
+
static int ScalePostConfigure(
|
152
|
+
Tcl_Interp *interp, void *recordPtr, int mask)
|
153
|
+
{
|
154
|
+
Scale *scale = recordPtr;
|
155
|
+
int status = TCL_OK;
|
156
|
+
|
157
|
+
if (scale->scale.variableTrace) {
|
158
|
+
status = Ttk_FireTrace(scale->scale.variableTrace);
|
159
|
+
if (WidgetDestroyed(&scale->core)) {
|
160
|
+
return TCL_ERROR;
|
161
|
+
}
|
162
|
+
if (status != TCL_OK) {
|
163
|
+
/* Unset -variable: */
|
164
|
+
Ttk_UntraceVariable(scale->scale.variableTrace);
|
165
|
+
Tcl_DecrRefCount(scale->scale.variableObj);
|
166
|
+
scale->scale.variableTrace = 0;
|
167
|
+
scale->scale.variableObj = NULL;
|
168
|
+
status = TCL_ERROR;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
|
172
|
+
return status;
|
173
|
+
}
|
174
|
+
|
175
|
+
/* ScaleGetLayout --
|
176
|
+
* getLayout hook.
|
177
|
+
*/
|
178
|
+
static Ttk_Layout
|
179
|
+
ScaleGetLayout(Tcl_Interp *interp, Ttk_Theme theme, void *recordPtr)
|
180
|
+
{
|
181
|
+
Scale *scalePtr = recordPtr;
|
182
|
+
return TtkWidgetGetOrientedLayout(
|
183
|
+
interp, theme, recordPtr, scalePtr->scale.orientObj);
|
184
|
+
}
|
185
|
+
|
186
|
+
/*
|
187
|
+
* TroughBox --
|
188
|
+
* Returns the inner area of the trough element.
|
189
|
+
*/
|
190
|
+
static Ttk_Box TroughBox(Scale *scalePtr)
|
191
|
+
{
|
192
|
+
WidgetCore *corePtr = &scalePtr->core;
|
193
|
+
Ttk_LayoutNode *node = Ttk_LayoutFindNode(corePtr->layout, "trough");
|
194
|
+
|
195
|
+
if (node) {
|
196
|
+
return Ttk_LayoutNodeInternalParcel(corePtr->layout, node);
|
197
|
+
} else {
|
198
|
+
return Ttk_MakeBox(
|
199
|
+
0,0, Tk_Width(corePtr->tkwin), Tk_Height(corePtr->tkwin));
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
/*
|
204
|
+
* TroughRange --
|
205
|
+
* Return the value area of the trough element, adjusted
|
206
|
+
* for slider size.
|
207
|
+
*/
|
208
|
+
static Ttk_Box TroughRange(Scale *scalePtr)
|
209
|
+
{
|
210
|
+
Ttk_Box troughBox = TroughBox(scalePtr);
|
211
|
+
Ttk_LayoutNode *slider=Ttk_LayoutFindNode(scalePtr->core.layout,"slider");
|
212
|
+
|
213
|
+
/*
|
214
|
+
* If this is a scale widget, adjust range for slider:
|
215
|
+
*/
|
216
|
+
if (slider) {
|
217
|
+
Ttk_Box sliderBox = Ttk_LayoutNodeParcel(slider);
|
218
|
+
if (scalePtr->scale.orient == TTK_ORIENT_HORIZONTAL) {
|
219
|
+
troughBox.x += sliderBox.width / 2;
|
220
|
+
troughBox.width -= sliderBox.width;
|
221
|
+
} else {
|
222
|
+
troughBox.y += sliderBox.height / 2;
|
223
|
+
troughBox.height -= sliderBox.height;
|
224
|
+
}
|
225
|
+
}
|
226
|
+
|
227
|
+
return troughBox;
|
228
|
+
}
|
229
|
+
|
230
|
+
/*
|
231
|
+
* ScaleFraction --
|
232
|
+
*/
|
233
|
+
static double ScaleFraction(Scale *scalePtr, double value)
|
234
|
+
{
|
235
|
+
double from = 0, to = 1, fraction;
|
236
|
+
|
237
|
+
Tcl_GetDoubleFromObj(NULL, scalePtr->scale.fromObj, &from);
|
238
|
+
Tcl_GetDoubleFromObj(NULL, scalePtr->scale.toObj, &to);
|
239
|
+
|
240
|
+
if (from == to) {
|
241
|
+
return 1.0;
|
242
|
+
}
|
243
|
+
|
244
|
+
fraction = (value - from) / (to - from);
|
245
|
+
|
246
|
+
return fraction < 0 ? 0 : fraction > 1 ? 1 : fraction;
|
247
|
+
}
|
248
|
+
|
249
|
+
/* $scale get ?x y? --
|
250
|
+
* Returns the current value of the scale widget, or if $x and
|
251
|
+
* $y are specified, the value represented by point @x,y.
|
252
|
+
*/
|
253
|
+
static int
|
254
|
+
ScaleGetCommand(
|
255
|
+
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
|
256
|
+
{
|
257
|
+
Scale *scalePtr = recordPtr;
|
258
|
+
int x, y, r = TCL_OK;
|
259
|
+
double value = 0;
|
260
|
+
|
261
|
+
if ((objc != 2) && (objc != 4)) {
|
262
|
+
Tcl_WrongNumArgs(interp, 1, objv, "get ?x y?");
|
263
|
+
return TCL_ERROR;
|
264
|
+
}
|
265
|
+
if (objc == 2) {
|
266
|
+
Tcl_SetObjResult(interp, scalePtr->scale.valueObj);
|
267
|
+
} else {
|
268
|
+
r = Tcl_GetIntFromObj(interp, objv[2], &x);
|
269
|
+
if (r == TCL_OK)
|
270
|
+
r = Tcl_GetIntFromObj(interp, objv[3], &y);
|
271
|
+
if (r == TCL_OK) {
|
272
|
+
value = PointToValue(scalePtr, x, y);
|
273
|
+
Tcl_SetObjResult(interp, Tcl_NewDoubleObj(value));
|
274
|
+
}
|
275
|
+
}
|
276
|
+
return r;
|
277
|
+
}
|
278
|
+
|
279
|
+
/* $scale set $newValue
|
280
|
+
*/
|
281
|
+
static int
|
282
|
+
ScaleSetCommand(
|
283
|
+
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
|
284
|
+
{
|
285
|
+
Scale *scalePtr = recordPtr;
|
286
|
+
double from = 0.0, to = 1.0, value;
|
287
|
+
int result = TCL_OK;
|
288
|
+
|
289
|
+
if (objc != 3) {
|
290
|
+
Tcl_WrongNumArgs(interp, 1, objv, "set value");
|
291
|
+
return TCL_ERROR;
|
292
|
+
}
|
293
|
+
|
294
|
+
if (Tcl_GetDoubleFromObj(interp, objv[2], &value) != TCL_OK) {
|
295
|
+
return TCL_ERROR;
|
296
|
+
}
|
297
|
+
|
298
|
+
if (scalePtr->core.state & TTK_STATE_DISABLED) {
|
299
|
+
return TCL_OK;
|
300
|
+
}
|
301
|
+
|
302
|
+
/* ASSERT: fromObj and toObj are valid doubles.
|
303
|
+
*/
|
304
|
+
Tcl_GetDoubleFromObj(interp, scalePtr->scale.fromObj, &from);
|
305
|
+
Tcl_GetDoubleFromObj(interp, scalePtr->scale.toObj, &to);
|
306
|
+
|
307
|
+
/* Limit new value to between 'from' and 'to':
|
308
|
+
*/
|
309
|
+
if (from < to) {
|
310
|
+
value = value < from ? from : value > to ? to : value;
|
311
|
+
} else {
|
312
|
+
value = value < to ? to : value > from ? from : value;
|
313
|
+
}
|
314
|
+
|
315
|
+
/*
|
316
|
+
* Set value:
|
317
|
+
*/
|
318
|
+
Tcl_DecrRefCount(scalePtr->scale.valueObj);
|
319
|
+
scalePtr->scale.valueObj = Tcl_NewDoubleObj(value);
|
320
|
+
Tcl_IncrRefCount(scalePtr->scale.valueObj);
|
321
|
+
TtkRedisplayWidget(&scalePtr->core);
|
322
|
+
|
323
|
+
/*
|
324
|
+
* Set attached variable, if any:
|
325
|
+
*/
|
326
|
+
if (scalePtr->scale.variableObj != NULL) {
|
327
|
+
Tcl_ObjSetVar2(interp, scalePtr->scale.variableObj, NULL,
|
328
|
+
scalePtr->scale.valueObj, TCL_GLOBAL_ONLY);
|
329
|
+
}
|
330
|
+
if (WidgetDestroyed(&scalePtr->core)) {
|
331
|
+
return TCL_ERROR;
|
332
|
+
}
|
333
|
+
|
334
|
+
/*
|
335
|
+
* Invoke -command, if any:
|
336
|
+
*/
|
337
|
+
if (scalePtr->scale.commandObj != NULL) {
|
338
|
+
Tcl_Obj *cmdObj = Tcl_DuplicateObj(scalePtr->scale.commandObj);
|
339
|
+
Tcl_IncrRefCount(cmdObj);
|
340
|
+
Tcl_AppendToObj(cmdObj, " ", 1);
|
341
|
+
Tcl_AppendObjToObj(cmdObj, scalePtr->scale.valueObj);
|
342
|
+
result = Tcl_EvalObjEx(interp, cmdObj, TCL_EVAL_GLOBAL);
|
343
|
+
Tcl_DecrRefCount(cmdObj);
|
344
|
+
}
|
345
|
+
|
346
|
+
return result;
|
347
|
+
}
|
348
|
+
|
349
|
+
static int
|
350
|
+
ScaleCoordsCommand(
|
351
|
+
Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], void *recordPtr)
|
352
|
+
{
|
353
|
+
Scale *scalePtr = recordPtr;
|
354
|
+
double value;
|
355
|
+
int r = TCL_OK;
|
356
|
+
|
357
|
+
if (objc < 2 || objc > 3) {
|
358
|
+
Tcl_WrongNumArgs(interp, 1, objv, "coords ?value?");
|
359
|
+
return TCL_ERROR;
|
360
|
+
}
|
361
|
+
|
362
|
+
if (objc == 3) {
|
363
|
+
r = Tcl_GetDoubleFromObj(interp, objv[2], &value);
|
364
|
+
} else {
|
365
|
+
r = Tcl_GetDoubleFromObj(interp, scalePtr->scale.valueObj, &value);
|
366
|
+
}
|
367
|
+
|
368
|
+
if (r == TCL_OK) {
|
369
|
+
Tcl_Obj *point[2];
|
370
|
+
XPoint pt = ValueToPoint(scalePtr, value);
|
371
|
+
point[0] = Tcl_NewIntObj(pt.x);
|
372
|
+
point[1] = Tcl_NewIntObj(pt.y);
|
373
|
+
Tcl_SetObjResult(interp, Tcl_NewListObj(2, point));
|
374
|
+
}
|
375
|
+
return r;
|
376
|
+
}
|
377
|
+
|
378
|
+
static void ScaleDoLayout(void *clientData)
|
379
|
+
{
|
380
|
+
WidgetCore *corePtr = clientData;
|
381
|
+
Ttk_LayoutNode *sliderNode = Ttk_LayoutFindNode(corePtr->layout, "slider");
|
382
|
+
|
383
|
+
Ttk_PlaceLayout(corePtr->layout,corePtr->state,Ttk_WinBox(corePtr->tkwin));
|
384
|
+
|
385
|
+
/* Adjust the slider position:
|
386
|
+
*/
|
387
|
+
if (sliderNode) {
|
388
|
+
Scale *scalePtr = clientData;
|
389
|
+
Ttk_Box troughBox = TroughBox(scalePtr);
|
390
|
+
Ttk_Box sliderBox = Ttk_LayoutNodeParcel(sliderNode);
|
391
|
+
double value = 0.0;
|
392
|
+
double fraction;
|
393
|
+
int range;
|
394
|
+
|
395
|
+
Tcl_GetDoubleFromObj(NULL, scalePtr->scale.valueObj, &value);
|
396
|
+
fraction = ScaleFraction(scalePtr, value);
|
397
|
+
|
398
|
+
if (scalePtr->scale.orient == TTK_ORIENT_HORIZONTAL) {
|
399
|
+
range = troughBox.width - sliderBox.width;
|
400
|
+
sliderBox.x += (int)(fraction * range);
|
401
|
+
} else {
|
402
|
+
range = troughBox.height - sliderBox.height;
|
403
|
+
sliderBox.y += (int)(fraction * range);
|
404
|
+
}
|
405
|
+
Ttk_PlaceLayoutNode(corePtr->layout, sliderNode, sliderBox);
|
406
|
+
}
|
407
|
+
}
|
408
|
+
|
409
|
+
/*
|
410
|
+
* ScaleSize --
|
411
|
+
* Compute requested size of scale.
|
412
|
+
*/
|
413
|
+
static int ScaleSize(void *clientData, int *widthPtr, int *heightPtr)
|
414
|
+
{
|
415
|
+
WidgetCore *corePtr = clientData;
|
416
|
+
Scale *scalePtr = clientData;
|
417
|
+
int length;
|
418
|
+
|
419
|
+
Ttk_LayoutSize(corePtr->layout, corePtr->state, widthPtr, heightPtr);
|
420
|
+
|
421
|
+
/* Assert the -length configuration option */
|
422
|
+
Tk_GetPixelsFromObj(NULL, corePtr->tkwin,
|
423
|
+
scalePtr->scale.lengthObj, &length);
|
424
|
+
if (scalePtr->scale.orient == TTK_ORIENT_VERTICAL) {
|
425
|
+
*heightPtr = MAX(*heightPtr, length);
|
426
|
+
} else {
|
427
|
+
*widthPtr = MAX(*widthPtr, length);
|
428
|
+
}
|
429
|
+
|
430
|
+
return 1;
|
431
|
+
}
|
432
|
+
|
433
|
+
static double
|
434
|
+
PointToValue(Scale *scalePtr, int x, int y)
|
435
|
+
{
|
436
|
+
Ttk_Box troughBox = TroughRange(scalePtr);
|
437
|
+
double from = 0, to = 1, fraction;
|
438
|
+
|
439
|
+
Tcl_GetDoubleFromObj(NULL, scalePtr->scale.fromObj, &from);
|
440
|
+
Tcl_GetDoubleFromObj(NULL, scalePtr->scale.toObj, &to);
|
441
|
+
|
442
|
+
if (scalePtr->scale.orient == TTK_ORIENT_HORIZONTAL) {
|
443
|
+
fraction = (double)(x - troughBox.x) / (double)troughBox.width;
|
444
|
+
} else {
|
445
|
+
fraction = (double)(y - troughBox.y) / (double)troughBox.height;
|
446
|
+
}
|
447
|
+
|
448
|
+
fraction = fraction < 0 ? 0 : fraction > 1 ? 1 : fraction;
|
449
|
+
|
450
|
+
return from + fraction * (to-from);
|
451
|
+
}
|
452
|
+
|
453
|
+
/*
|
454
|
+
* Return the center point in the widget corresponding to the given
|
455
|
+
* value. This point can be used to center the slider.
|
456
|
+
*/
|
457
|
+
|
458
|
+
static XPoint
|
459
|
+
ValueToPoint(Scale *scalePtr, double value)
|
460
|
+
{
|
461
|
+
Ttk_Box troughBox = TroughRange(scalePtr);
|
462
|
+
double fraction = ScaleFraction(scalePtr, value);
|
463
|
+
XPoint pt = {0, 0};
|
464
|
+
|
465
|
+
if (scalePtr->scale.orient == TTK_ORIENT_HORIZONTAL) {
|
466
|
+
pt.x = troughBox.x + (int)(fraction * troughBox.width);
|
467
|
+
pt.y = troughBox.y + troughBox.height / 2;
|
468
|
+
} else {
|
469
|
+
pt.x = troughBox.x + troughBox.width / 2;
|
470
|
+
pt.y = troughBox.y + (int)(fraction * troughBox.height);
|
471
|
+
}
|
472
|
+
return pt;
|
473
|
+
}
|
474
|
+
|
475
|
+
static WidgetCommandSpec ScaleCommands[] =
|
476
|
+
{
|
477
|
+
{ "configure", TtkWidgetConfigureCommand },
|
478
|
+
{ "cget", TtkWidgetCgetCommand },
|
479
|
+
{ "state", TtkWidgetStateCommand },
|
480
|
+
{ "instate", TtkWidgetInstateCommand },
|
481
|
+
{ "identify", TtkWidgetIdentifyCommand },
|
482
|
+
{ "set", ScaleSetCommand },
|
483
|
+
{ "get", ScaleGetCommand },
|
484
|
+
{ "coords", ScaleCoordsCommand },
|
485
|
+
{ 0, 0 }
|
486
|
+
};
|
487
|
+
|
488
|
+
static WidgetSpec ScaleWidgetSpec =
|
489
|
+
{
|
490
|
+
"TScale", /* Class name */
|
491
|
+
sizeof(Scale), /* record size */
|
492
|
+
ScaleOptionSpecs, /* option specs */
|
493
|
+
ScaleCommands, /* widget commands */
|
494
|
+
ScaleInitialize, /* initialization proc */
|
495
|
+
ScaleCleanup, /* cleanup proc */
|
496
|
+
ScaleConfigure, /* configure proc */
|
497
|
+
ScalePostConfigure, /* postConfigure */
|
498
|
+
ScaleGetLayout, /* getLayoutProc */
|
499
|
+
ScaleSize, /* sizeProc */
|
500
|
+
ScaleDoLayout, /* layoutProc */
|
501
|
+
TtkWidgetDisplay /* displayProc */
|
502
|
+
};
|
503
|
+
|
504
|
+
TTK_BEGIN_LAYOUT(VerticalScaleLayout)
|
505
|
+
TTK_GROUP("Vertical.Scale.trough", TTK_FILL_BOTH,
|
506
|
+
TTK_NODE("Vertical.Scale.slider", TTK_PACK_TOP) )
|
507
|
+
TTK_END_LAYOUT
|
508
|
+
|
509
|
+
TTK_BEGIN_LAYOUT(HorizontalScaleLayout)
|
510
|
+
TTK_GROUP("Horizontal.Scale.trough", TTK_FILL_BOTH,
|
511
|
+
TTK_NODE("Horizontal.Scale.slider", TTK_PACK_LEFT) )
|
512
|
+
TTK_END_LAYOUT
|
513
|
+
|
514
|
+
/*
|
515
|
+
* Initialization.
|
516
|
+
*/
|
517
|
+
void TtkScale_Init(Tcl_Interp *interp)
|
518
|
+
{
|
519
|
+
Ttk_Theme theme = Ttk_GetDefaultTheme(interp);
|
520
|
+
|
521
|
+
Ttk_RegisterLayout(theme, "Vertical.TScale", VerticalScaleLayout);
|
522
|
+
Ttk_RegisterLayout(theme, "Horizontal.TScale", HorizontalScaleLayout);
|
523
|
+
|
524
|
+
RegisterWidget(interp, "ttk::scale", &ScaleWidgetSpec);
|
525
|
+
}
|
526
|
+
|