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,296 @@
|
|
1
|
+
/* tile.c,v 1.74 2007/01/11 14:49:03 jenglish Exp
|
2
|
+
* Copyright (c) 2003, Joe English
|
3
|
+
*
|
4
|
+
* Tile package: initialization routine and miscellaneous utilities.
|
5
|
+
*/
|
6
|
+
|
7
|
+
#include <string.h>
|
8
|
+
#include <tk.h>
|
9
|
+
#include "tkTheme.h"
|
10
|
+
#include "widget.h"
|
11
|
+
|
12
|
+
/*
|
13
|
+
* Legal values for the button -default option.
|
14
|
+
* See also: enum Ttk_ButtonDefaultState.
|
15
|
+
*/
|
16
|
+
const char *ttkDefaultStrings[] = {
|
17
|
+
"normal", "active", "disabled", NULL
|
18
|
+
};
|
19
|
+
|
20
|
+
int Ttk_GetButtonDefaultStateFromObj(
|
21
|
+
Tcl_Interp *interp, Tcl_Obj *objPtr, int *statePtr)
|
22
|
+
{
|
23
|
+
*statePtr = TTK_BUTTON_DEFAULT_DISABLED;
|
24
|
+
return Tcl_GetIndexFromObj(interp, objPtr,
|
25
|
+
ttkDefaultStrings, "default state", 0, statePtr);
|
26
|
+
}
|
27
|
+
|
28
|
+
/*
|
29
|
+
* Legal values for the -compound option.
|
30
|
+
* See also: enum Ttk_Compound.
|
31
|
+
*/
|
32
|
+
const char *ttkCompoundStrings[] = {
|
33
|
+
"none", "text", "image", "center",
|
34
|
+
"top", "bottom", "left", "right", NULL
|
35
|
+
};
|
36
|
+
|
37
|
+
int Ttk_GetCompoundFromObj(
|
38
|
+
Tcl_Interp *interp, Tcl_Obj *objPtr, int *statePtr)
|
39
|
+
{
|
40
|
+
*statePtr = TTK_COMPOUND_NONE;
|
41
|
+
return Tcl_GetIndexFromObj(interp, objPtr,
|
42
|
+
ttkCompoundStrings, "compound layout", 0, statePtr);
|
43
|
+
}
|
44
|
+
|
45
|
+
/*
|
46
|
+
* Legal values for the -orient option.
|
47
|
+
* See also: enum Ttk_Orient.
|
48
|
+
*/
|
49
|
+
CONST char *ttkOrientStrings[] = {
|
50
|
+
"horizontal", "vertical", NULL
|
51
|
+
};
|
52
|
+
|
53
|
+
int Ttk_GetOrientFromObj(
|
54
|
+
Tcl_Interp *interp, Tcl_Obj *objPtr, int *resultPtr)
|
55
|
+
{
|
56
|
+
*resultPtr = TTK_ORIENT_HORIZONTAL;
|
57
|
+
return Tcl_GetIndexFromObj(interp, objPtr,
|
58
|
+
ttkOrientStrings, "orientation", 0, resultPtr);
|
59
|
+
}
|
60
|
+
|
61
|
+
/*
|
62
|
+
* Recognized values for the -state compatibility option.
|
63
|
+
* Other options are accepted and interpreted as synonyms for "normal".
|
64
|
+
*/
|
65
|
+
static const char *ttkStateStrings[] = {
|
66
|
+
"normal", "readonly", "disabled", "active", NULL
|
67
|
+
};
|
68
|
+
enum {
|
69
|
+
TTK_COMPAT_STATE_NORMAL,
|
70
|
+
TTK_COMPAT_STATE_READONLY,
|
71
|
+
TTK_COMPAT_STATE_DISABLED,
|
72
|
+
TTK_COMPAT_STATE_ACTIVE
|
73
|
+
};
|
74
|
+
|
75
|
+
/* TtkCheckStateOption --
|
76
|
+
* Handle -state compatibility option.
|
77
|
+
*
|
78
|
+
* NOTE: setting -state disabled / -state enabled affects the
|
79
|
+
* widget state, but the internal widget state does *not* affect
|
80
|
+
* the value of the -state option.
|
81
|
+
* This option is present for compatibility only.
|
82
|
+
*/
|
83
|
+
void TtkCheckStateOption(WidgetCore *corePtr, Tcl_Obj *objPtr)
|
84
|
+
{
|
85
|
+
int stateOption = TTK_COMPAT_STATE_NORMAL;
|
86
|
+
unsigned all = TTK_STATE_DISABLED|TTK_STATE_READONLY|TTK_STATE_ACTIVE;
|
87
|
+
# define SETFLAGS(f) TtkWidgetChangeState(corePtr, f, all^f)
|
88
|
+
|
89
|
+
(void)Tcl_GetIndexFromObj(NULL,objPtr,ttkStateStrings,"",0,&stateOption);
|
90
|
+
switch (stateOption) {
|
91
|
+
case TTK_COMPAT_STATE_NORMAL:
|
92
|
+
default:
|
93
|
+
SETFLAGS(0);
|
94
|
+
break;
|
95
|
+
case TTK_COMPAT_STATE_READONLY:
|
96
|
+
SETFLAGS(TTK_STATE_READONLY);
|
97
|
+
break;
|
98
|
+
case TTK_COMPAT_STATE_DISABLED:
|
99
|
+
SETFLAGS(TTK_STATE_DISABLED);
|
100
|
+
break;
|
101
|
+
case TTK_COMPAT_STATE_ACTIVE:
|
102
|
+
SETFLAGS(TTK_STATE_ACTIVE);
|
103
|
+
break;
|
104
|
+
}
|
105
|
+
# undef SETFLAGS
|
106
|
+
}
|
107
|
+
|
108
|
+
/* TtkSendVirtualEvent --
|
109
|
+
* Send a virtual event notification to the specified target window.
|
110
|
+
* Equivalent to "event generate $tgtWindow <<$eventName>>"
|
111
|
+
*
|
112
|
+
* Note that we use Tk_QueueWindowEvent, not Tk_HandleEvent,
|
113
|
+
* so this routine does not reenter the interpreter.
|
114
|
+
*/
|
115
|
+
void TtkSendVirtualEvent(Tk_Window tgtWin, const char *eventName)
|
116
|
+
{
|
117
|
+
XEvent event;
|
118
|
+
|
119
|
+
memset(&event, 0, sizeof(event));
|
120
|
+
event.xany.type = VirtualEvent;
|
121
|
+
event.xany.serial = NextRequest(Tk_Display(tgtWin));
|
122
|
+
event.xany.send_event = False;
|
123
|
+
event.xany.window = Tk_WindowId(tgtWin);
|
124
|
+
event.xany.display = Tk_Display(tgtWin);
|
125
|
+
((XVirtualEvent *) &event)->name = Tk_GetUid(eventName);
|
126
|
+
|
127
|
+
Tk_QueueWindowEvent(&event, TCL_QUEUE_TAIL);
|
128
|
+
}
|
129
|
+
|
130
|
+
/* TtkEnumerateOptions, TtkGetOptionValue --
|
131
|
+
* Common factors for data accessor commands.
|
132
|
+
*/
|
133
|
+
int TtkEnumerateOptions(
|
134
|
+
Tcl_Interp *interp, void *recordPtr, const Tk_OptionSpec *specPtr,
|
135
|
+
Tk_OptionTable optionTable, Tk_Window tkwin)
|
136
|
+
{
|
137
|
+
Tcl_Obj *result = Tcl_NewListObj(0,0);
|
138
|
+
while (specPtr->type != TK_OPTION_END)
|
139
|
+
{
|
140
|
+
Tcl_Obj *optionName = Tcl_NewStringObj(specPtr->optionName, -1);
|
141
|
+
Tcl_Obj *optionValue =
|
142
|
+
Tk_GetOptionValue(interp,recordPtr,optionTable,optionName,tkwin);
|
143
|
+
if (optionValue) {
|
144
|
+
Tcl_ListObjAppendElement(interp, result, optionName);
|
145
|
+
Tcl_ListObjAppendElement(interp, result, optionValue);
|
146
|
+
}
|
147
|
+
++specPtr;
|
148
|
+
|
149
|
+
if (specPtr->type == TK_OPTION_END && specPtr->clientData != NULL) {
|
150
|
+
/* Chain to next option spec array: */
|
151
|
+
specPtr = specPtr->clientData;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
Tcl_SetObjResult(interp, result);
|
155
|
+
return TCL_OK;
|
156
|
+
}
|
157
|
+
|
158
|
+
int TtkGetOptionValue(
|
159
|
+
Tcl_Interp *interp, void *recordPtr, Tcl_Obj *optionName,
|
160
|
+
Tk_OptionTable optionTable, Tk_Window tkwin)
|
161
|
+
{
|
162
|
+
Tcl_Obj *result =
|
163
|
+
Tk_GetOptionValue(interp,recordPtr,optionTable,optionName,tkwin);
|
164
|
+
if (result) {
|
165
|
+
Tcl_SetObjResult(interp, result);
|
166
|
+
return TCL_OK;
|
167
|
+
}
|
168
|
+
return TCL_ERROR;
|
169
|
+
}
|
170
|
+
|
171
|
+
|
172
|
+
/*------------------------------------------------------------------------
|
173
|
+
* Core Option specifications:
|
174
|
+
* type name dbName dbClass default objOffset intOffset flags clientData mask
|
175
|
+
*/
|
176
|
+
|
177
|
+
/* public */
|
178
|
+
Tk_OptionSpec ttkCoreOptionSpecs[] =
|
179
|
+
{
|
180
|
+
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus",
|
181
|
+
"", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 },
|
182
|
+
{TK_OPTION_CURSOR, "-cursor", "cursor", "Cursor", NULL,
|
183
|
+
Tk_Offset(WidgetCore, cursorObj), -1, TK_OPTION_NULL_OK,0,0 },
|
184
|
+
{TK_OPTION_STRING, "-style", "style", "Style", "",
|
185
|
+
Tk_Offset(WidgetCore,styleObj), -1, 0,0,STYLE_CHANGED},
|
186
|
+
{TK_OPTION_STRING, "-class", "", "", NULL,
|
187
|
+
Tk_Offset(WidgetCore,classObj), -1, 0,0,READONLY_OPTION},
|
188
|
+
{TK_OPTION_END}
|
189
|
+
};
|
190
|
+
|
191
|
+
/*------------------------------------------------------------------------
|
192
|
+
* +++ Initialization: elements and element factories.
|
193
|
+
*/
|
194
|
+
|
195
|
+
extern void TtkElements_Init(Tcl_Interp *);
|
196
|
+
extern void TtkLabel_Init(Tcl_Interp *);
|
197
|
+
extern void TtkImage_Init(Tcl_Interp *);
|
198
|
+
|
199
|
+
static void RegisterElements(Tcl_Interp *interp)
|
200
|
+
{
|
201
|
+
TtkElements_Init(interp);
|
202
|
+
TtkLabel_Init(interp);
|
203
|
+
TtkImage_Init(interp);
|
204
|
+
}
|
205
|
+
|
206
|
+
/*------------------------------------------------------------------------
|
207
|
+
* +++ Initialization: Widget definitions.
|
208
|
+
*/
|
209
|
+
|
210
|
+
extern void TtkButton_Init(Tcl_Interp *);
|
211
|
+
extern void TtkEntry_Init(Tcl_Interp *);
|
212
|
+
extern void TtkFrame_Init(Tcl_Interp *);
|
213
|
+
extern void TtkNotebook_Init(Tcl_Interp *);
|
214
|
+
extern void TtkPanedwindow_Init(Tcl_Interp *);
|
215
|
+
extern void TtkProgressbar_Init(Tcl_Interp *);
|
216
|
+
extern void TtkScale_Init(Tcl_Interp *);
|
217
|
+
extern void TtkScrollbar_Init(Tcl_Interp *);
|
218
|
+
extern void TtkSeparator_Init(Tcl_Interp *);
|
219
|
+
extern void TtkSquareWidget_Init(Tcl_Interp *);
|
220
|
+
extern void TtkTreeview_Init(Tcl_Interp *);
|
221
|
+
|
222
|
+
static void RegisterWidgets(Tcl_Interp *interp)
|
223
|
+
{
|
224
|
+
TtkButton_Init(interp);
|
225
|
+
TtkEntry_Init(interp);
|
226
|
+
TtkFrame_Init(interp);
|
227
|
+
TtkNotebook_Init(interp);
|
228
|
+
TtkPanedwindow_Init(interp);
|
229
|
+
TtkProgressbar_Init(interp);
|
230
|
+
TtkScale_Init(interp);
|
231
|
+
TtkScrollbar_Init(interp);
|
232
|
+
TtkSeparator_Init(interp);
|
233
|
+
TtkTreeview_Init(interp);
|
234
|
+
|
235
|
+
#ifdef TTK_SQUARE_WIDGET
|
236
|
+
TtkSquareWidget_Init(interp);
|
237
|
+
#endif
|
238
|
+
}
|
239
|
+
|
240
|
+
/*------------------------------------------------------------------------
|
241
|
+
* +++ Initialization: Built-in themes.
|
242
|
+
*/
|
243
|
+
|
244
|
+
extern int TtkAltTheme_Init(Tcl_Interp *);
|
245
|
+
extern int TtkClassicTheme_Init(Tcl_Interp *);
|
246
|
+
extern int TtkClamTheme_Init(Tcl_Interp *);
|
247
|
+
|
248
|
+
static void RegisterThemes(Tcl_Interp *interp)
|
249
|
+
{
|
250
|
+
|
251
|
+
TtkAltTheme_Init(interp);
|
252
|
+
TtkClassicTheme_Init(interp);
|
253
|
+
TtkClamTheme_Init(interp);
|
254
|
+
}
|
255
|
+
|
256
|
+
/*------------------------------------------------------------------------
|
257
|
+
* +++ Package initialization.
|
258
|
+
* tcl_findLibrary basename version patch initScript enVarName varName
|
259
|
+
*/
|
260
|
+
|
261
|
+
static char initScript[] =
|
262
|
+
"namespace eval tile { variable version " TILE_VERSION " };"
|
263
|
+
"tcl_findLibrary tile $tile::version $tile::version"
|
264
|
+
" tile.tcl TILE_LIBRARY tile::library;";
|
265
|
+
|
266
|
+
extern TtkStubs ttkStubs;
|
267
|
+
|
268
|
+
#define TCL_VERSION_WRONG "8.0" /* Workaround for #1091431 */
|
269
|
+
|
270
|
+
int DLLEXPORT
|
271
|
+
Tile_Init(Tcl_Interp *interp)
|
272
|
+
{
|
273
|
+
if (Tcl_InitStubs(interp, TCL_VERSION_WRONG, 0) == NULL) {
|
274
|
+
return TCL_ERROR;
|
275
|
+
}
|
276
|
+
if (Tk_InitStubs(interp, TK_VERSION, 0) == NULL) {
|
277
|
+
return TCL_ERROR;
|
278
|
+
}
|
279
|
+
|
280
|
+
Ttk_StylePkgInit(interp);
|
281
|
+
|
282
|
+
RegisterElements(interp);
|
283
|
+
RegisterWidgets(interp);
|
284
|
+
RegisterThemes(interp);
|
285
|
+
|
286
|
+
Ttk_PlatformInit(interp);
|
287
|
+
|
288
|
+
if (Tcl_Eval(interp, initScript) != TCL_OK)
|
289
|
+
return TCL_ERROR;
|
290
|
+
|
291
|
+
Tcl_PkgProvideEx(interp, "tile", TILE_VERSION, (void*)&ttkStubs);
|
292
|
+
|
293
|
+
return TCL_OK;
|
294
|
+
}
|
295
|
+
|
296
|
+
/*EOF*/
|
@@ -0,0 +1,1280 @@
|
|
1
|
+
/* tkElements.c,v 1.85 2007/11/19 01:57:21 jenglish Exp
|
2
|
+
*
|
3
|
+
* Copyright (c) 2003, Joe English
|
4
|
+
*
|
5
|
+
* Default implementation for themed elements.
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
|
9
|
+
#include <tcl.h>
|
10
|
+
#include <tk.h>
|
11
|
+
#include <string.h>
|
12
|
+
#include "tkTheme.h"
|
13
|
+
|
14
|
+
#define DEFAULT_BORDERWIDTH "2"
|
15
|
+
#define DEFAULT_ARROW_SIZE "15"
|
16
|
+
#define MIN_THUMB_SIZE 10
|
17
|
+
|
18
|
+
/*----------------------------------------------------------------------
|
19
|
+
* +++ Null element. Does nothing; used as a stub.
|
20
|
+
* Null element methods, option table and element spec are public,
|
21
|
+
* and may be used in other engines.
|
22
|
+
*/
|
23
|
+
|
24
|
+
/* public */ Ttk_ElementOptionSpec TtkNullElementOptions[] = { {NULL} };
|
25
|
+
|
26
|
+
/* public */ void
|
27
|
+
TtkNullElementSize(
|
28
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
29
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
30
|
+
{
|
31
|
+
}
|
32
|
+
|
33
|
+
/* public */ void
|
34
|
+
TtkNullElementDraw(
|
35
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
36
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
37
|
+
{
|
38
|
+
}
|
39
|
+
|
40
|
+
/* public */ Ttk_ElementSpec ttkNullElementSpec = {
|
41
|
+
TK_STYLE_VERSION_2,
|
42
|
+
sizeof(NullElement),
|
43
|
+
TtkNullElementOptions,
|
44
|
+
TtkNullElementSize,
|
45
|
+
TtkNullElementDraw
|
46
|
+
};
|
47
|
+
|
48
|
+
/*----------------------------------------------------------------------
|
49
|
+
* +++ Background and fill elements.
|
50
|
+
*
|
51
|
+
* The fill element fills its parcel with the background color.
|
52
|
+
* The background element ignores the parcel, and fills the entire window.
|
53
|
+
*
|
54
|
+
* Ttk_GetLayout() automatically includes a background element.
|
55
|
+
*/
|
56
|
+
|
57
|
+
typedef struct {
|
58
|
+
Tcl_Obj *backgroundObj;
|
59
|
+
} BackgroundElement;
|
60
|
+
|
61
|
+
static Ttk_ElementOptionSpec BackgroundElementOptions[] = {
|
62
|
+
{ "-background", TK_OPTION_BORDER,
|
63
|
+
Tk_Offset(BackgroundElement,backgroundObj), DEFAULT_BACKGROUND },
|
64
|
+
{NULL}
|
65
|
+
};
|
66
|
+
|
67
|
+
static void FillElementDraw(
|
68
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
69
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
70
|
+
{
|
71
|
+
BackgroundElement *bg = elementRecord;
|
72
|
+
Tk_3DBorder backgroundPtr = Tk_Get3DBorderFromObj(tkwin,bg->backgroundObj);
|
73
|
+
|
74
|
+
XFillRectangle(Tk_Display(tkwin), d,
|
75
|
+
Tk_3DBorderGC(tkwin, backgroundPtr, TK_3D_FLAT_GC),
|
76
|
+
b.x, b.y, b.width, b.height);
|
77
|
+
}
|
78
|
+
|
79
|
+
static void BackgroundElementDraw(
|
80
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
81
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
82
|
+
{
|
83
|
+
FillElementDraw(
|
84
|
+
clientData, elementRecord, tkwin,
|
85
|
+
d, Ttk_WinBox(tkwin), state);
|
86
|
+
}
|
87
|
+
|
88
|
+
static Ttk_ElementSpec FillElementSpec = {
|
89
|
+
TK_STYLE_VERSION_2,
|
90
|
+
sizeof(BackgroundElement),
|
91
|
+
BackgroundElementOptions,
|
92
|
+
TtkNullElementSize,
|
93
|
+
FillElementDraw
|
94
|
+
};
|
95
|
+
|
96
|
+
static Ttk_ElementSpec BackgroundElementSpec = {
|
97
|
+
TK_STYLE_VERSION_2,
|
98
|
+
sizeof(BackgroundElement),
|
99
|
+
BackgroundElementOptions,
|
100
|
+
TtkNullElementSize,
|
101
|
+
BackgroundElementDraw
|
102
|
+
};
|
103
|
+
|
104
|
+
/*----------------------------------------------------------------------
|
105
|
+
* +++ Border element.
|
106
|
+
*/
|
107
|
+
|
108
|
+
typedef struct {
|
109
|
+
Tcl_Obj *borderObj;
|
110
|
+
Tcl_Obj *borderWidthObj;
|
111
|
+
Tcl_Obj *reliefObj;
|
112
|
+
} BorderElement;
|
113
|
+
|
114
|
+
static Ttk_ElementOptionSpec BorderElementOptions[] = {
|
115
|
+
{ "-background", TK_OPTION_BORDER,
|
116
|
+
Tk_Offset(BorderElement,borderObj), DEFAULT_BACKGROUND },
|
117
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
118
|
+
Tk_Offset(BorderElement,borderWidthObj), DEFAULT_BORDERWIDTH },
|
119
|
+
{ "-relief", TK_OPTION_RELIEF,
|
120
|
+
Tk_Offset(BorderElement,reliefObj), "flat" },
|
121
|
+
{NULL}
|
122
|
+
};
|
123
|
+
|
124
|
+
static void BorderElementSize(
|
125
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
126
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
127
|
+
{
|
128
|
+
BorderElement *bd = elementRecord;
|
129
|
+
int borderWidth = 0;
|
130
|
+
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
|
131
|
+
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
|
132
|
+
}
|
133
|
+
|
134
|
+
static void BorderElementDraw(
|
135
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
136
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
137
|
+
{
|
138
|
+
BorderElement *bd = elementRecord;
|
139
|
+
Tk_3DBorder border = NULL;
|
140
|
+
int borderWidth = 1, relief = TK_RELIEF_FLAT;
|
141
|
+
|
142
|
+
border = Tk_Get3DBorderFromObj(tkwin, bd->borderObj);
|
143
|
+
Tcl_GetIntFromObj(NULL, bd->borderWidthObj, &borderWidth);
|
144
|
+
Tk_GetReliefFromObj(NULL, bd->reliefObj, &relief);
|
145
|
+
|
146
|
+
if (border && borderWidth > 0 && relief != TK_RELIEF_FLAT) {
|
147
|
+
Tk_Draw3DRectangle(tkwin, d, border,
|
148
|
+
b.x, b.y, b.width, b.height, borderWidth,relief);
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
static Ttk_ElementSpec BorderElementSpec = {
|
153
|
+
TK_STYLE_VERSION_2,
|
154
|
+
sizeof(BorderElement),
|
155
|
+
BorderElementOptions,
|
156
|
+
BorderElementSize,
|
157
|
+
BorderElementDraw
|
158
|
+
};
|
159
|
+
|
160
|
+
/*----------------------------------------------------------------------
|
161
|
+
* +++ Field element.
|
162
|
+
* Used for editable fields.
|
163
|
+
*/
|
164
|
+
typedef struct {
|
165
|
+
Tcl_Obj *borderObj;
|
166
|
+
Tcl_Obj *borderWidthObj;
|
167
|
+
} FieldElement;
|
168
|
+
|
169
|
+
static Ttk_ElementOptionSpec FieldElementOptions[] = {
|
170
|
+
{ "-fieldbackground", TK_OPTION_BORDER,
|
171
|
+
Tk_Offset(FieldElement,borderObj), "white" },
|
172
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
173
|
+
Tk_Offset(FieldElement,borderWidthObj), "2" },
|
174
|
+
{NULL}
|
175
|
+
};
|
176
|
+
|
177
|
+
static void FieldElementSize(
|
178
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
179
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
180
|
+
{
|
181
|
+
FieldElement *field = elementRecord;
|
182
|
+
int borderWidth = 2;
|
183
|
+
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
|
184
|
+
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
|
185
|
+
}
|
186
|
+
|
187
|
+
static void FieldElementDraw(
|
188
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
189
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
190
|
+
{
|
191
|
+
FieldElement *field = elementRecord;
|
192
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, field->borderObj);
|
193
|
+
int borderWidth = 2;
|
194
|
+
|
195
|
+
Tk_GetPixelsFromObj(NULL, tkwin, field->borderWidthObj, &borderWidth);
|
196
|
+
Tk_Fill3DRectangle(tkwin, d, border,
|
197
|
+
b.x, b.y, b.width, b.height, borderWidth, TK_RELIEF_SUNKEN);
|
198
|
+
}
|
199
|
+
|
200
|
+
static Ttk_ElementSpec FieldElementSpec = {
|
201
|
+
TK_STYLE_VERSION_2,
|
202
|
+
sizeof(FieldElement),
|
203
|
+
FieldElementOptions,
|
204
|
+
FieldElementSize,
|
205
|
+
FieldElementDraw
|
206
|
+
};
|
207
|
+
|
208
|
+
/*
|
209
|
+
*----------------------------------------------------------------------
|
210
|
+
* +++ Padding element.
|
211
|
+
*
|
212
|
+
* This element has no visual representation, only geometry.
|
213
|
+
* It adds a (possibly non-uniform) internal border.
|
214
|
+
* In addition, if "-shiftrelief" is specified,
|
215
|
+
* adds additional pixels to shift child elements "in" or "out"
|
216
|
+
* depending on the -relief.
|
217
|
+
*/
|
218
|
+
|
219
|
+
typedef struct {
|
220
|
+
Tcl_Obj *paddingObj;
|
221
|
+
Tcl_Obj *reliefObj;
|
222
|
+
Tcl_Obj *shiftreliefObj;
|
223
|
+
} PaddingElement;
|
224
|
+
|
225
|
+
static Ttk_ElementOptionSpec PaddingElementOptions[] = {
|
226
|
+
{ "-padding", TK_OPTION_STRING,
|
227
|
+
Tk_Offset(PaddingElement,paddingObj), "0" },
|
228
|
+
{ "-relief", TK_OPTION_RELIEF,
|
229
|
+
Tk_Offset(PaddingElement,reliefObj), "flat" },
|
230
|
+
{ "-shiftrelief", TK_OPTION_INT,
|
231
|
+
Tk_Offset(PaddingElement,shiftreliefObj), "0" },
|
232
|
+
{NULL}
|
233
|
+
};
|
234
|
+
|
235
|
+
static void PaddingElementSize(
|
236
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
237
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
238
|
+
{
|
239
|
+
PaddingElement *padding = elementRecord;
|
240
|
+
int shiftRelief = 0;
|
241
|
+
int relief = TK_RELIEF_FLAT;
|
242
|
+
Ttk_Padding pad;
|
243
|
+
|
244
|
+
Tk_GetReliefFromObj(NULL, padding->reliefObj, &relief);
|
245
|
+
Tcl_GetIntFromObj(NULL, padding->shiftreliefObj, &shiftRelief);
|
246
|
+
Ttk_GetPaddingFromObj(NULL,tkwin,padding->paddingObj,&pad);
|
247
|
+
*paddingPtr = Ttk_RelievePadding(pad, relief, shiftRelief);
|
248
|
+
}
|
249
|
+
|
250
|
+
static Ttk_ElementSpec PaddingElementSpec = {
|
251
|
+
TK_STYLE_VERSION_2,
|
252
|
+
sizeof(PaddingElement),
|
253
|
+
PaddingElementOptions,
|
254
|
+
PaddingElementSize,
|
255
|
+
TtkNullElementDraw
|
256
|
+
};
|
257
|
+
|
258
|
+
/*----------------------------------------------------------------------
|
259
|
+
* +++ Focus ring element.
|
260
|
+
* Draws a dashed focus ring, if the widget has keyboard focus.
|
261
|
+
*/
|
262
|
+
typedef struct {
|
263
|
+
Tcl_Obj *focusColorObj;
|
264
|
+
Tcl_Obj *focusThicknessObj;
|
265
|
+
} FocusElement;
|
266
|
+
|
267
|
+
/*
|
268
|
+
* DrawFocusRing --
|
269
|
+
* Draw a dotted rectangle to indicate focus.
|
270
|
+
*/
|
271
|
+
static void DrawFocusRing(
|
272
|
+
Tk_Window tkwin, Drawable d, Tcl_Obj *colorObj, Ttk_Box b)
|
273
|
+
{
|
274
|
+
XColor *color = Tk_GetColorFromObj(tkwin, colorObj);
|
275
|
+
unsigned long mask = 0UL;
|
276
|
+
XGCValues gcvalues;
|
277
|
+
GC gc;
|
278
|
+
|
279
|
+
gcvalues.foreground = color->pixel;
|
280
|
+
gcvalues.line_style = LineOnOffDash;
|
281
|
+
gcvalues.line_width = 1;
|
282
|
+
gcvalues.dashes = 1;
|
283
|
+
gcvalues.dash_offset = 1;
|
284
|
+
mask = GCForeground | GCLineStyle | GCDashList | GCDashOffset | GCLineWidth;
|
285
|
+
|
286
|
+
gc = Tk_GetGC(tkwin, mask, &gcvalues);
|
287
|
+
XDrawRectangle(Tk_Display(tkwin), d, gc, b.x, b.y, b.width-1, b.height-1);
|
288
|
+
Tk_FreeGC(Tk_Display(tkwin), gc);
|
289
|
+
}
|
290
|
+
|
291
|
+
static Ttk_ElementOptionSpec FocusElementOptions[] = {
|
292
|
+
{ "-focuscolor",TK_OPTION_COLOR,
|
293
|
+
Tk_Offset(FocusElement,focusColorObj), "black" },
|
294
|
+
{ "-focusthickness",TK_OPTION_PIXELS,
|
295
|
+
Tk_Offset(FocusElement,focusThicknessObj), "1" },
|
296
|
+
{NULL}
|
297
|
+
};
|
298
|
+
|
299
|
+
static void FocusElementSize(
|
300
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
301
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
302
|
+
{
|
303
|
+
FocusElement *focus = elementRecord;
|
304
|
+
int focusThickness = 0;
|
305
|
+
|
306
|
+
Tcl_GetIntFromObj(NULL, focus->focusThicknessObj, &focusThickness);
|
307
|
+
*paddingPtr = Ttk_UniformPadding((short)focusThickness);
|
308
|
+
}
|
309
|
+
|
310
|
+
static void FocusElementDraw(
|
311
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
312
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
313
|
+
{
|
314
|
+
FocusElement *focus = elementRecord;
|
315
|
+
int focusThickness = 0;
|
316
|
+
|
317
|
+
if (state & TTK_STATE_FOCUS) {
|
318
|
+
Tcl_GetIntFromObj(NULL,focus->focusThicknessObj,&focusThickness);
|
319
|
+
DrawFocusRing(tkwin, d, focus->focusColorObj, b);
|
320
|
+
}
|
321
|
+
}
|
322
|
+
|
323
|
+
static Ttk_ElementSpec FocusElementSpec = {
|
324
|
+
TK_STYLE_VERSION_2,
|
325
|
+
sizeof(FocusElement),
|
326
|
+
FocusElementOptions,
|
327
|
+
FocusElementSize,
|
328
|
+
FocusElementDraw
|
329
|
+
};
|
330
|
+
|
331
|
+
/*----------------------------------------------------------------------
|
332
|
+
* +++ Separator element.
|
333
|
+
* Just draws a horizontal or vertical bar.
|
334
|
+
* Three elements are defined: horizontal, vertical, and general;
|
335
|
+
* the general separator checks the "-orient" option.
|
336
|
+
*/
|
337
|
+
|
338
|
+
typedef struct {
|
339
|
+
Tcl_Obj *orientObj;
|
340
|
+
Tcl_Obj *borderObj;
|
341
|
+
} SeparatorElement;
|
342
|
+
|
343
|
+
static Ttk_ElementOptionSpec SeparatorElementOptions[] = {
|
344
|
+
{ "-orient", TK_OPTION_ANY,
|
345
|
+
Tk_Offset(SeparatorElement, orientObj), "horizontal" },
|
346
|
+
{ "-background", TK_OPTION_BORDER,
|
347
|
+
Tk_Offset(SeparatorElement,borderObj), DEFAULT_BACKGROUND },
|
348
|
+
{NULL}
|
349
|
+
};
|
350
|
+
|
351
|
+
static void SeparatorElementSize(
|
352
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
353
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
354
|
+
{
|
355
|
+
*widthPtr = *heightPtr = 2;
|
356
|
+
}
|
357
|
+
|
358
|
+
static void HorizontalSeparatorElementDraw(
|
359
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
360
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
361
|
+
{
|
362
|
+
SeparatorElement *separator = elementRecord;
|
363
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, separator->borderObj);
|
364
|
+
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
|
365
|
+
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
|
366
|
+
|
367
|
+
XDrawLine(Tk_Display(tkwin), d, darkGC, b.x, b.y, b.x + b.width, b.y);
|
368
|
+
XDrawLine(Tk_Display(tkwin), d, lightGC, b.x, b.y+1, b.x + b.width, b.y+1);
|
369
|
+
}
|
370
|
+
|
371
|
+
static void VerticalSeparatorElementDraw(
|
372
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
373
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
374
|
+
{
|
375
|
+
SeparatorElement *separator = elementRecord;
|
376
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, separator->borderObj);
|
377
|
+
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
|
378
|
+
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
|
379
|
+
|
380
|
+
XDrawLine(Tk_Display(tkwin), d, darkGC, b.x, b.y, b.x, b.y + b.height);
|
381
|
+
XDrawLine(Tk_Display(tkwin), d, lightGC, b.x+1, b.y, b.x+1, b.y+b.height);
|
382
|
+
}
|
383
|
+
|
384
|
+
static void GeneralSeparatorElementDraw(
|
385
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
386
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
387
|
+
{
|
388
|
+
SeparatorElement *separator = elementRecord;
|
389
|
+
int orient;
|
390
|
+
Ttk_GetOrientFromObj(NULL, separator->orientObj, &orient);
|
391
|
+
switch (orient) {
|
392
|
+
case TTK_ORIENT_HORIZONTAL:
|
393
|
+
HorizontalSeparatorElementDraw(
|
394
|
+
clientData, elementRecord, tkwin, d, b, state);
|
395
|
+
break;
|
396
|
+
case TTK_ORIENT_VERTICAL:
|
397
|
+
VerticalSeparatorElementDraw(
|
398
|
+
clientData, elementRecord, tkwin, d, b, state);
|
399
|
+
break;
|
400
|
+
}
|
401
|
+
}
|
402
|
+
|
403
|
+
static Ttk_ElementSpec HorizontalSeparatorElementSpec = {
|
404
|
+
TK_STYLE_VERSION_2,
|
405
|
+
sizeof(SeparatorElement),
|
406
|
+
SeparatorElementOptions,
|
407
|
+
SeparatorElementSize,
|
408
|
+
HorizontalSeparatorElementDraw
|
409
|
+
};
|
410
|
+
|
411
|
+
static Ttk_ElementSpec VerticalSeparatorElementSpec = {
|
412
|
+
TK_STYLE_VERSION_2,
|
413
|
+
sizeof(SeparatorElement),
|
414
|
+
SeparatorElementOptions,
|
415
|
+
SeparatorElementSize,
|
416
|
+
HorizontalSeparatorElementDraw
|
417
|
+
};
|
418
|
+
|
419
|
+
static Ttk_ElementSpec SeparatorElementSpec = {
|
420
|
+
TK_STYLE_VERSION_2,
|
421
|
+
sizeof(SeparatorElement),
|
422
|
+
SeparatorElementOptions,
|
423
|
+
SeparatorElementSize,
|
424
|
+
GeneralSeparatorElementDraw
|
425
|
+
};
|
426
|
+
|
427
|
+
/*----------------------------------------------------------------------
|
428
|
+
* +++ Sizegrip: lower-right corner grip handle for resizing window.
|
429
|
+
*/
|
430
|
+
|
431
|
+
typedef struct {
|
432
|
+
Tcl_Obj *backgroundObj;
|
433
|
+
} SizegripElement;
|
434
|
+
|
435
|
+
static Ttk_ElementOptionSpec SizegripOptions[] = {
|
436
|
+
{ "-background", TK_OPTION_BORDER,
|
437
|
+
Tk_Offset(SizegripElement,backgroundObj), DEFAULT_BACKGROUND },
|
438
|
+
{0,0,0,0}
|
439
|
+
};
|
440
|
+
|
441
|
+
static void SizegripSize(
|
442
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
443
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
444
|
+
{
|
445
|
+
int gripCount = 3, gripSpace = 2, gripThickness = 3;
|
446
|
+
*widthPtr = *heightPtr = gripCount * (gripSpace + gripThickness);
|
447
|
+
}
|
448
|
+
|
449
|
+
static void SizegripDraw(
|
450
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
451
|
+
Drawable d, Ttk_Box b, Ttk_State state)
|
452
|
+
{
|
453
|
+
SizegripElement *grip = elementRecord;
|
454
|
+
int gripCount = 3, gripSpace = 2;
|
455
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, grip->backgroundObj);
|
456
|
+
GC lightGC = Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC);
|
457
|
+
GC darkGC = Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC);
|
458
|
+
int x1 = b.x + b.width-1, y1 = b.y + b.height-1, x2 = x1, y2 = y1;
|
459
|
+
|
460
|
+
while (gripCount--) {
|
461
|
+
x1 -= gripSpace; y2 -= gripSpace;
|
462
|
+
XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2); --x1; --y2;
|
463
|
+
XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2); --x1; --y2;
|
464
|
+
XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y1, x2,y2); --x1; --y2;
|
465
|
+
}
|
466
|
+
}
|
467
|
+
|
468
|
+
static Ttk_ElementSpec SizegripElementSpec = {
|
469
|
+
TK_STYLE_VERSION_2,
|
470
|
+
sizeof(SizegripElement),
|
471
|
+
SizegripOptions,
|
472
|
+
SizegripSize,
|
473
|
+
SizegripDraw
|
474
|
+
};
|
475
|
+
|
476
|
+
/*----------------------------------------------------------------------
|
477
|
+
* +++ Indicator element.
|
478
|
+
*
|
479
|
+
* Draws the on/off indicator for checkbuttons and radiobuttons.
|
480
|
+
*
|
481
|
+
* Draws a 3-D square (or diamond), raised if off, sunken if on.
|
482
|
+
*
|
483
|
+
* This is actually a regression from Tk 8.5 back to the ugly old Motif
|
484
|
+
* style; use "altTheme" for the newer, nicer version.
|
485
|
+
*/
|
486
|
+
|
487
|
+
typedef struct {
|
488
|
+
Tcl_Obj *backgroundObj;
|
489
|
+
Tcl_Obj *reliefObj;
|
490
|
+
Tcl_Obj *colorObj;
|
491
|
+
Tcl_Obj *diameterObj;
|
492
|
+
Tcl_Obj *marginObj;
|
493
|
+
Tcl_Obj *borderWidthObj;
|
494
|
+
} IndicatorElement;
|
495
|
+
|
496
|
+
static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
|
497
|
+
{ "-background", TK_OPTION_BORDER,
|
498
|
+
Tk_Offset(IndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
|
499
|
+
{ "-indicatorcolor", TK_OPTION_BORDER,
|
500
|
+
Tk_Offset(IndicatorElement,colorObj), DEFAULT_BACKGROUND },
|
501
|
+
{ "-indicatorrelief", TK_OPTION_RELIEF,
|
502
|
+
Tk_Offset(IndicatorElement,reliefObj), "raised" },
|
503
|
+
{ "-indicatordiameter", TK_OPTION_PIXELS,
|
504
|
+
Tk_Offset(IndicatorElement,diameterObj), "12" },
|
505
|
+
{ "-indicatormargin", TK_OPTION_STRING,
|
506
|
+
Tk_Offset(IndicatorElement,marginObj), "0 2 4 2" },
|
507
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
508
|
+
Tk_Offset(IndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
|
509
|
+
{NULL}
|
510
|
+
};
|
511
|
+
|
512
|
+
/*
|
513
|
+
* Checkbutton indicators (default): 3-D square.
|
514
|
+
*/
|
515
|
+
static void SquareIndicatorElementSize(
|
516
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
517
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
518
|
+
{
|
519
|
+
IndicatorElement *indicator = elementRecord;
|
520
|
+
Ttk_Padding margins;
|
521
|
+
int diameter = 0;
|
522
|
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
|
523
|
+
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
|
524
|
+
*widthPtr = diameter + Ttk_PaddingWidth(margins);
|
525
|
+
*heightPtr = diameter + Ttk_PaddingHeight(margins);
|
526
|
+
}
|
527
|
+
|
528
|
+
static void SquareIndicatorElementDraw(
|
529
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
530
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
531
|
+
{
|
532
|
+
IndicatorElement *indicator = elementRecord;
|
533
|
+
Tk_3DBorder border = 0, interior = 0;
|
534
|
+
int relief = TK_RELIEF_RAISED;
|
535
|
+
Ttk_Padding padding;
|
536
|
+
int borderWidth = 2;
|
537
|
+
int diameter;
|
538
|
+
|
539
|
+
interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
|
540
|
+
border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
|
541
|
+
Tcl_GetIntFromObj(NULL,indicator->borderWidthObj,&borderWidth);
|
542
|
+
Tk_GetReliefFromObj(NULL,indicator->reliefObj,&relief);
|
543
|
+
Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding);
|
544
|
+
|
545
|
+
b = Ttk_PadBox(b, padding);
|
546
|
+
|
547
|
+
diameter = b.width < b.height ? b.width : b.height;
|
548
|
+
Tk_Fill3DRectangle(tkwin, d, interior, b.x, b.y,
|
549
|
+
diameter, diameter,borderWidth, TK_RELIEF_FLAT);
|
550
|
+
Tk_Draw3DRectangle(tkwin, d, border, b.x, b.y,
|
551
|
+
diameter, diameter, borderWidth, relief);
|
552
|
+
}
|
553
|
+
|
554
|
+
/*
|
555
|
+
* Radiobutton indicators: 3-D diamond.
|
556
|
+
*/
|
557
|
+
static void DiamondIndicatorElementSize(
|
558
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
559
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
560
|
+
{
|
561
|
+
IndicatorElement *indicator = elementRecord;
|
562
|
+
Ttk_Padding margins;
|
563
|
+
int diameter = 0;
|
564
|
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
|
565
|
+
Tk_GetPixelsFromObj(NULL, tkwin, indicator->diameterObj, &diameter);
|
566
|
+
*widthPtr = diameter + 3 + Ttk_PaddingWidth(margins);
|
567
|
+
*heightPtr = diameter + 3 + Ttk_PaddingHeight(margins);
|
568
|
+
}
|
569
|
+
|
570
|
+
static void DiamondIndicatorElementDraw(
|
571
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
572
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
573
|
+
{
|
574
|
+
IndicatorElement *indicator = elementRecord;
|
575
|
+
Tk_3DBorder border = 0, interior = 0;
|
576
|
+
int borderWidth = 2;
|
577
|
+
int relief = TK_RELIEF_RAISED;
|
578
|
+
int diameter, radius;
|
579
|
+
XPoint points[4];
|
580
|
+
Ttk_Padding padding;
|
581
|
+
|
582
|
+
interior = Tk_Get3DBorderFromObj(tkwin, indicator->colorObj);
|
583
|
+
border = Tk_Get3DBorderFromObj(tkwin, indicator->backgroundObj);
|
584
|
+
Tcl_GetIntFromObj(NULL,indicator->borderWidthObj,&borderWidth);
|
585
|
+
Tk_GetReliefFromObj(NULL,indicator->reliefObj,&relief);
|
586
|
+
Ttk_GetPaddingFromObj(NULL,tkwin,indicator->marginObj,&padding);
|
587
|
+
|
588
|
+
b = Ttk_PadBox(b, padding);
|
589
|
+
|
590
|
+
diameter = b.width < b.height ? b.width : b.height;
|
591
|
+
radius = diameter / 2;
|
592
|
+
|
593
|
+
points[0].x = b.x;
|
594
|
+
points[0].y = b.y + radius;
|
595
|
+
points[1].x = b.x + radius;
|
596
|
+
points[1].y = b.y + 2*radius;
|
597
|
+
points[2].x = b.x + 2*radius;
|
598
|
+
points[2].y = b.y + radius;
|
599
|
+
points[3].x = b.x + radius;
|
600
|
+
points[3].y = b.y;
|
601
|
+
|
602
|
+
Tk_Fill3DPolygon(tkwin,d,interior,points,4,borderWidth,TK_RELIEF_FLAT);
|
603
|
+
Tk_Draw3DPolygon(tkwin,d,border,points,4,borderWidth,relief);
|
604
|
+
}
|
605
|
+
|
606
|
+
static Ttk_ElementSpec CheckbuttonIndicatorElementSpec = {
|
607
|
+
TK_STYLE_VERSION_2,
|
608
|
+
sizeof(IndicatorElement),
|
609
|
+
IndicatorElementOptions,
|
610
|
+
SquareIndicatorElementSize,
|
611
|
+
SquareIndicatorElementDraw
|
612
|
+
};
|
613
|
+
|
614
|
+
static Ttk_ElementSpec RadiobuttonIndicatorElementSpec = {
|
615
|
+
TK_STYLE_VERSION_2,
|
616
|
+
sizeof(IndicatorElement),
|
617
|
+
IndicatorElementOptions,
|
618
|
+
DiamondIndicatorElementSize,
|
619
|
+
DiamondIndicatorElementDraw
|
620
|
+
};
|
621
|
+
|
622
|
+
/*
|
623
|
+
*----------------------------------------------------------------------
|
624
|
+
* +++ Menubutton indicators.
|
625
|
+
*
|
626
|
+
* These aren't functional like radio/check indicators,
|
627
|
+
* they're just affordability indicators.
|
628
|
+
*
|
629
|
+
* Standard Tk sets the indicator size to 4.0 mm by 1.7 mm.
|
630
|
+
* I have no idea where these numbers came from.
|
631
|
+
*/
|
632
|
+
|
633
|
+
typedef struct {
|
634
|
+
Tcl_Obj *backgroundObj;
|
635
|
+
Tcl_Obj *widthObj;
|
636
|
+
Tcl_Obj *heightObj;
|
637
|
+
Tcl_Obj *borderWidthObj;
|
638
|
+
Tcl_Obj *reliefObj;
|
639
|
+
Tcl_Obj *marginObj;
|
640
|
+
} MenuIndicatorElement;
|
641
|
+
|
642
|
+
static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] = {
|
643
|
+
{ "-background", TK_OPTION_BORDER,
|
644
|
+
Tk_Offset(MenuIndicatorElement,backgroundObj), DEFAULT_BACKGROUND },
|
645
|
+
{ "-indicatorwidth", TK_OPTION_PIXELS,
|
646
|
+
Tk_Offset(MenuIndicatorElement,widthObj), "4.0m" },
|
647
|
+
{ "-indicatorheight", TK_OPTION_PIXELS,
|
648
|
+
Tk_Offset(MenuIndicatorElement,heightObj), "1.7m" },
|
649
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
650
|
+
Tk_Offset(MenuIndicatorElement,borderWidthObj), DEFAULT_BORDERWIDTH },
|
651
|
+
{ "-indicatorrelief", TK_OPTION_RELIEF,
|
652
|
+
Tk_Offset(MenuIndicatorElement,reliefObj),"raised" },
|
653
|
+
{ "-indicatormargin", TK_OPTION_STRING,
|
654
|
+
Tk_Offset(MenuIndicatorElement,marginObj), "5 0" },
|
655
|
+
{ NULL }
|
656
|
+
};
|
657
|
+
|
658
|
+
static void MenuIndicatorElementSize(
|
659
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
660
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
661
|
+
{
|
662
|
+
MenuIndicatorElement *mi = elementRecord;
|
663
|
+
Ttk_Padding margins;
|
664
|
+
Tk_GetPixelsFromObj(NULL, tkwin, mi->widthObj, widthPtr);
|
665
|
+
Tk_GetPixelsFromObj(NULL, tkwin, mi->heightObj, heightPtr);
|
666
|
+
Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj, &margins);
|
667
|
+
*widthPtr += Ttk_PaddingWidth(margins);
|
668
|
+
*heightPtr += Ttk_PaddingHeight(margins);
|
669
|
+
}
|
670
|
+
|
671
|
+
static void MenuIndicatorElementDraw(
|
672
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
673
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
674
|
+
{
|
675
|
+
MenuIndicatorElement *mi = elementRecord;
|
676
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, mi->backgroundObj);
|
677
|
+
Ttk_Padding margins;
|
678
|
+
int borderWidth = 2;
|
679
|
+
|
680
|
+
Ttk_GetPaddingFromObj(NULL,tkwin,mi->marginObj,&margins);
|
681
|
+
b = Ttk_PadBox(b, margins);
|
682
|
+
Tk_GetPixelsFromObj(NULL, tkwin, mi->borderWidthObj, &borderWidth);
|
683
|
+
Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
|
684
|
+
borderWidth, TK_RELIEF_RAISED);
|
685
|
+
}
|
686
|
+
|
687
|
+
static Ttk_ElementSpec MenuIndicatorElementSpec = {
|
688
|
+
TK_STYLE_VERSION_2,
|
689
|
+
sizeof(MenuIndicatorElement),
|
690
|
+
MenuIndicatorElementOptions,
|
691
|
+
MenuIndicatorElementSize,
|
692
|
+
MenuIndicatorElementDraw
|
693
|
+
};
|
694
|
+
|
695
|
+
/*----------------------------------------------------------------------
|
696
|
+
* +++ Arrow elements.
|
697
|
+
*
|
698
|
+
* Draws a solid triangle inside a box.
|
699
|
+
* clientData is an enum ArrowDirection pointer.
|
700
|
+
*/
|
701
|
+
|
702
|
+
static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
|
703
|
+
typedef struct {
|
704
|
+
Tcl_Obj *borderObj;
|
705
|
+
Tcl_Obj *borderWidthObj;
|
706
|
+
Tcl_Obj *reliefObj;
|
707
|
+
Tcl_Obj *sizeObj;
|
708
|
+
Tcl_Obj *colorObj;
|
709
|
+
} ArrowElement;
|
710
|
+
|
711
|
+
static Ttk_ElementOptionSpec ArrowElementOptions[] = {
|
712
|
+
{ "-background", TK_OPTION_BORDER,
|
713
|
+
Tk_Offset(ArrowElement,borderObj), DEFAULT_BACKGROUND },
|
714
|
+
{ "-relief",TK_OPTION_RELIEF,
|
715
|
+
Tk_Offset(ArrowElement,reliefObj),"raised"},
|
716
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
717
|
+
Tk_Offset(ArrowElement,borderWidthObj), "1" },
|
718
|
+
{ "-arrowcolor",TK_OPTION_COLOR,
|
719
|
+
Tk_Offset(ArrowElement,colorObj),"black"},
|
720
|
+
{ "-arrowsize", TK_OPTION_PIXELS,
|
721
|
+
Tk_Offset(ArrowElement,sizeObj), "14" },
|
722
|
+
{ NULL }
|
723
|
+
};
|
724
|
+
|
725
|
+
static Ttk_Padding ArrowMargins = { 3,3,3,3 };
|
726
|
+
|
727
|
+
static void ArrowElementSize(
|
728
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
729
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
730
|
+
{
|
731
|
+
ArrowElement *arrow = elementRecord;
|
732
|
+
int direction = *(int *)clientData;
|
733
|
+
int width = 14;
|
734
|
+
|
735
|
+
Tk_GetPixelsFromObj(NULL, tkwin, arrow->sizeObj, &width);
|
736
|
+
width -= Ttk_PaddingWidth(ArrowMargins);
|
737
|
+
TtkArrowSize(width/2, direction, widthPtr, heightPtr);
|
738
|
+
*widthPtr += Ttk_PaddingWidth(ArrowMargins);
|
739
|
+
*heightPtr += Ttk_PaddingWidth(ArrowMargins);
|
740
|
+
}
|
741
|
+
|
742
|
+
static void ArrowElementDraw(
|
743
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
744
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
745
|
+
{
|
746
|
+
int direction = *(int *)clientData;
|
747
|
+
ArrowElement *arrow = elementRecord;
|
748
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, arrow->borderObj);
|
749
|
+
XColor *arrowColor = Tk_GetColorFromObj(tkwin, arrow->colorObj);
|
750
|
+
int relief = TK_RELIEF_RAISED;
|
751
|
+
int borderWidth = 1;
|
752
|
+
|
753
|
+
Tk_GetReliefFromObj(NULL, arrow->reliefObj, &relief);
|
754
|
+
|
755
|
+
Tk_Fill3DRectangle(
|
756
|
+
tkwin, d, border, b.x, b.y, b.width, b.height, borderWidth, relief);
|
757
|
+
|
758
|
+
TtkFillArrow(Tk_Display(tkwin), d, Tk_GCForColor(arrowColor, d),
|
759
|
+
Ttk_PadBox(b, ArrowMargins), direction);
|
760
|
+
}
|
761
|
+
|
762
|
+
static Ttk_ElementSpec ArrowElementSpec = {
|
763
|
+
TK_STYLE_VERSION_2,
|
764
|
+
sizeof(ArrowElement),
|
765
|
+
ArrowElementOptions,
|
766
|
+
ArrowElementSize,
|
767
|
+
ArrowElementDraw
|
768
|
+
};
|
769
|
+
|
770
|
+
/*----------------------------------------------------------------------
|
771
|
+
* +++ Trough element.
|
772
|
+
*
|
773
|
+
* Used in scrollbars and scales in place of "border".
|
774
|
+
*/
|
775
|
+
|
776
|
+
typedef struct {
|
777
|
+
Tcl_Obj *colorObj;
|
778
|
+
Tcl_Obj *borderWidthObj;
|
779
|
+
Tcl_Obj *reliefObj;
|
780
|
+
} TroughElement;
|
781
|
+
|
782
|
+
static Ttk_ElementOptionSpec TroughElementOptions[] = {
|
783
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
784
|
+
Tk_Offset(TroughElement,borderWidthObj), DEFAULT_BORDERWIDTH },
|
785
|
+
{ "-troughcolor", TK_OPTION_BORDER,
|
786
|
+
Tk_Offset(TroughElement,colorObj), DEFAULT_BACKGROUND },
|
787
|
+
{ "-troughrelief",TK_OPTION_RELIEF,
|
788
|
+
Tk_Offset(TroughElement,reliefObj), "sunken" },
|
789
|
+
{ NULL }
|
790
|
+
};
|
791
|
+
|
792
|
+
static void TroughElementSize(
|
793
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
794
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
795
|
+
{
|
796
|
+
TroughElement *troughPtr = elementRecord;
|
797
|
+
int borderWidth = 2;
|
798
|
+
|
799
|
+
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
|
800
|
+
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
|
801
|
+
}
|
802
|
+
|
803
|
+
static void TroughElementDraw(
|
804
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
805
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
806
|
+
{
|
807
|
+
TroughElement *troughPtr = elementRecord;
|
808
|
+
Tk_3DBorder border = NULL;
|
809
|
+
int borderWidth = 2, relief = TK_RELIEF_SUNKEN;
|
810
|
+
|
811
|
+
border = Tk_Get3DBorderFromObj(tkwin, troughPtr->colorObj);
|
812
|
+
Tk_GetReliefFromObj(NULL, troughPtr->reliefObj, &relief);
|
813
|
+
Tk_GetPixelsFromObj(NULL, tkwin, troughPtr->borderWidthObj, &borderWidth);
|
814
|
+
|
815
|
+
Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
|
816
|
+
borderWidth, relief);
|
817
|
+
}
|
818
|
+
|
819
|
+
static Ttk_ElementSpec TroughElementSpec = {
|
820
|
+
TK_STYLE_VERSION_2,
|
821
|
+
sizeof(TroughElement),
|
822
|
+
TroughElementOptions,
|
823
|
+
TroughElementSize,
|
824
|
+
TroughElementDraw
|
825
|
+
};
|
826
|
+
|
827
|
+
/*
|
828
|
+
*----------------------------------------------------------------------
|
829
|
+
* +++ Thumb element.
|
830
|
+
*
|
831
|
+
* Used in scrollbars.
|
832
|
+
*/
|
833
|
+
|
834
|
+
typedef struct {
|
835
|
+
Tcl_Obj *orientObj;
|
836
|
+
Tcl_Obj *thicknessObj;
|
837
|
+
Tcl_Obj *reliefObj;
|
838
|
+
Tcl_Obj *borderObj;
|
839
|
+
Tcl_Obj *borderWidthObj;
|
840
|
+
} ThumbElement;
|
841
|
+
|
842
|
+
static Ttk_ElementOptionSpec ThumbElementOptions[] = {
|
843
|
+
{ "-orient", TK_OPTION_ANY,
|
844
|
+
Tk_Offset(ThumbElement, orientObj), "horizontal" },
|
845
|
+
{ "-width", TK_OPTION_PIXELS,
|
846
|
+
Tk_Offset(ThumbElement,thicknessObj), DEFAULT_ARROW_SIZE },
|
847
|
+
{ "-relief", TK_OPTION_RELIEF,
|
848
|
+
Tk_Offset(ThumbElement,reliefObj), "raised" },
|
849
|
+
{ "-background", TK_OPTION_BORDER,
|
850
|
+
Tk_Offset(ThumbElement,borderObj), DEFAULT_BACKGROUND },
|
851
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
852
|
+
Tk_Offset(ThumbElement,borderWidthObj), DEFAULT_BORDERWIDTH },
|
853
|
+
{ NULL }
|
854
|
+
};
|
855
|
+
|
856
|
+
static void ThumbElementSize(
|
857
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
858
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
859
|
+
{
|
860
|
+
ThumbElement *thumb = elementRecord;
|
861
|
+
int orient, thickness;
|
862
|
+
|
863
|
+
Tk_GetPixelsFromObj(NULL, tkwin, thumb->thicknessObj, &thickness);
|
864
|
+
Ttk_GetOrientFromObj(NULL, thumb->orientObj, &orient);
|
865
|
+
|
866
|
+
if (orient == TTK_ORIENT_VERTICAL) {
|
867
|
+
*widthPtr = thickness;
|
868
|
+
*heightPtr = MIN_THUMB_SIZE;
|
869
|
+
} else {
|
870
|
+
*widthPtr = MIN_THUMB_SIZE;
|
871
|
+
*heightPtr = thickness;
|
872
|
+
}
|
873
|
+
}
|
874
|
+
|
875
|
+
static void ThumbElementDraw(
|
876
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
877
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
878
|
+
{
|
879
|
+
ThumbElement *thumb = elementRecord;
|
880
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, thumb->borderObj);
|
881
|
+
int borderWidth = 2, relief = TK_RELIEF_RAISED;
|
882
|
+
|
883
|
+
Tk_GetPixelsFromObj(NULL, tkwin, thumb->borderWidthObj, &borderWidth);
|
884
|
+
Tk_GetReliefFromObj(NULL, thumb->reliefObj, &relief);
|
885
|
+
Tk_Fill3DRectangle(tkwin, d, border, b.x, b.y, b.width, b.height,
|
886
|
+
borderWidth, relief);
|
887
|
+
}
|
888
|
+
|
889
|
+
static Ttk_ElementSpec ThumbElementSpec = {
|
890
|
+
TK_STYLE_VERSION_2,
|
891
|
+
sizeof(ThumbElement),
|
892
|
+
ThumbElementOptions,
|
893
|
+
ThumbElementSize,
|
894
|
+
ThumbElementDraw
|
895
|
+
};
|
896
|
+
|
897
|
+
/*
|
898
|
+
*----------------------------------------------------------------------
|
899
|
+
* +++ Slider element.
|
900
|
+
*
|
901
|
+
* This is the moving part of the scale widget. Drawn as a raised box.
|
902
|
+
*/
|
903
|
+
|
904
|
+
typedef struct {
|
905
|
+
Tcl_Obj *orientObj; /* orientation of overall slider */
|
906
|
+
Tcl_Obj *lengthObj; /* slider length */
|
907
|
+
Tcl_Obj *thicknessObj; /* slider thickness */
|
908
|
+
Tcl_Obj *reliefObj; /* the relief for this object */
|
909
|
+
Tcl_Obj *borderObj; /* the background color */
|
910
|
+
Tcl_Obj *borderWidthObj; /* the size of the border */
|
911
|
+
} SliderElement;
|
912
|
+
|
913
|
+
static Ttk_ElementOptionSpec SliderElementOptions[] = {
|
914
|
+
{ "-sliderlength", TK_OPTION_PIXELS, Tk_Offset(SliderElement,lengthObj),
|
915
|
+
"30" },
|
916
|
+
{ "-sliderthickness",TK_OPTION_PIXELS,Tk_Offset(SliderElement,thicknessObj),
|
917
|
+
"15" },
|
918
|
+
{ "-sliderrelief", TK_OPTION_RELIEF, Tk_Offset(SliderElement,reliefObj),
|
919
|
+
"raised" },
|
920
|
+
{ "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(SliderElement,borderWidthObj),
|
921
|
+
DEFAULT_BORDERWIDTH },
|
922
|
+
{ "-background", TK_OPTION_BORDER, Tk_Offset(SliderElement,borderObj),
|
923
|
+
DEFAULT_BACKGROUND },
|
924
|
+
{ "-orient", TK_OPTION_ANY, Tk_Offset(SliderElement,orientObj),
|
925
|
+
"horizontal" },
|
926
|
+
{ NULL }
|
927
|
+
};
|
928
|
+
|
929
|
+
static void SliderElementSize(
|
930
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
931
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
932
|
+
{
|
933
|
+
SliderElement *slider = elementRecord;
|
934
|
+
int orient, length, thickness;
|
935
|
+
|
936
|
+
Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
|
937
|
+
Tk_GetPixelsFromObj(NULL, tkwin, slider->lengthObj, &length);
|
938
|
+
Tk_GetPixelsFromObj(NULL, tkwin, slider->thicknessObj, &thickness);
|
939
|
+
|
940
|
+
switch (orient) {
|
941
|
+
case TTK_ORIENT_VERTICAL:
|
942
|
+
*widthPtr = thickness;
|
943
|
+
*heightPtr = length;
|
944
|
+
break;
|
945
|
+
|
946
|
+
case TTK_ORIENT_HORIZONTAL:
|
947
|
+
*widthPtr = length;
|
948
|
+
*heightPtr = thickness;
|
949
|
+
break;
|
950
|
+
}
|
951
|
+
}
|
952
|
+
|
953
|
+
static void SliderElementDraw(
|
954
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
955
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
956
|
+
{
|
957
|
+
SliderElement *slider = elementRecord;
|
958
|
+
Tk_3DBorder border = NULL;
|
959
|
+
int relief, borderWidth, orient;
|
960
|
+
|
961
|
+
border = Tk_Get3DBorderFromObj(tkwin, slider->borderObj);
|
962
|
+
Ttk_GetOrientFromObj(NULL, slider->orientObj, &orient);
|
963
|
+
Tk_GetPixelsFromObj(NULL, tkwin, slider->borderWidthObj, &borderWidth);
|
964
|
+
Tk_GetReliefFromObj(NULL, slider->reliefObj, &relief);
|
965
|
+
|
966
|
+
Tk_Fill3DRectangle(tkwin, d, border,
|
967
|
+
b.x, b.y, b.width, b.height,
|
968
|
+
borderWidth, relief);
|
969
|
+
|
970
|
+
if (relief != TK_RELIEF_FLAT) {
|
971
|
+
if (orient == TTK_ORIENT_HORIZONTAL) {
|
972
|
+
if (b.width > 4) {
|
973
|
+
b.x += b.width/2;
|
974
|
+
XDrawLine(Tk_Display(tkwin), d,
|
975
|
+
Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
|
976
|
+
b.x-1, b.y+borderWidth, b.x-1, b.y+b.height-borderWidth);
|
977
|
+
XDrawLine(Tk_Display(tkwin), d,
|
978
|
+
Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
|
979
|
+
b.x, b.y+borderWidth, b.x, b.y+b.height-borderWidth);
|
980
|
+
}
|
981
|
+
} else {
|
982
|
+
if (b.height > 4) {
|
983
|
+
b.y += b.height/2;
|
984
|
+
XDrawLine(Tk_Display(tkwin), d,
|
985
|
+
Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
|
986
|
+
b.x+borderWidth, b.y-1, b.x+b.width-borderWidth, b.y-1);
|
987
|
+
XDrawLine(Tk_Display(tkwin), d,
|
988
|
+
Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
|
989
|
+
b.x+borderWidth, b.y, b.x+b.width-borderWidth, b.y);
|
990
|
+
}
|
991
|
+
}
|
992
|
+
}
|
993
|
+
}
|
994
|
+
|
995
|
+
static Ttk_ElementSpec SliderElementSpec = {
|
996
|
+
TK_STYLE_VERSION_2,
|
997
|
+
sizeof(SliderElement),
|
998
|
+
SliderElementOptions,
|
999
|
+
SliderElementSize,
|
1000
|
+
SliderElementDraw
|
1001
|
+
};
|
1002
|
+
|
1003
|
+
/*------------------------------------------------------------------------
|
1004
|
+
* +++ Progress bar element:
|
1005
|
+
* Draws the moving part of the progress bar.
|
1006
|
+
*
|
1007
|
+
* -thickness specifies the size along the short axis of the bar.
|
1008
|
+
* -length specifies the default size along the long axis;
|
1009
|
+
* the bar will be this long in indeterminate mode.
|
1010
|
+
*/
|
1011
|
+
|
1012
|
+
#define DEFAULT_PBAR_THICKNESS "15"
|
1013
|
+
#define DEFAULT_PBAR_LENGTH "30"
|
1014
|
+
|
1015
|
+
typedef struct {
|
1016
|
+
Tcl_Obj *orientObj; /* widget orientation */
|
1017
|
+
Tcl_Obj *thicknessObj; /* the height/width of the bar */
|
1018
|
+
Tcl_Obj *lengthObj; /* default width/height of the bar */
|
1019
|
+
Tcl_Obj *reliefObj; /* border relief for this object */
|
1020
|
+
Tcl_Obj *borderObj; /* background color */
|
1021
|
+
Tcl_Obj *borderWidthObj; /* thickness of the border */
|
1022
|
+
} PbarElement;
|
1023
|
+
|
1024
|
+
static Ttk_ElementOptionSpec PbarElementOptions[] = {
|
1025
|
+
{ "-orient", TK_OPTION_ANY, Tk_Offset(PbarElement,orientObj),
|
1026
|
+
"horizontal" },
|
1027
|
+
{ "-thickness", TK_OPTION_PIXELS, Tk_Offset(PbarElement,thicknessObj),
|
1028
|
+
DEFAULT_PBAR_THICKNESS },
|
1029
|
+
{ "-barsize", TK_OPTION_PIXELS, Tk_Offset(PbarElement,lengthObj),
|
1030
|
+
DEFAULT_PBAR_LENGTH },
|
1031
|
+
{ "-pbarrelief", TK_OPTION_RELIEF, Tk_Offset(PbarElement,reliefObj),
|
1032
|
+
"raised" },
|
1033
|
+
{ "-borderwidth", TK_OPTION_PIXELS, Tk_Offset(PbarElement,borderWidthObj),
|
1034
|
+
DEFAULT_BORDERWIDTH },
|
1035
|
+
{ "-background", TK_OPTION_BORDER, Tk_Offset(PbarElement,borderObj),
|
1036
|
+
DEFAULT_BACKGROUND },
|
1037
|
+
{ NULL }
|
1038
|
+
};
|
1039
|
+
|
1040
|
+
static void PbarElementSize(
|
1041
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
1042
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
1043
|
+
{
|
1044
|
+
PbarElement *pbar = elementRecord;
|
1045
|
+
int orient, thickness, length, borderWidth;
|
1046
|
+
|
1047
|
+
Ttk_GetOrientFromObj(NULL, pbar->orientObj, &orient);
|
1048
|
+
Tk_GetPixelsFromObj(NULL, tkwin, pbar->thicknessObj, &thickness);
|
1049
|
+
Tk_GetPixelsFromObj(NULL, tkwin, pbar->lengthObj, &length);
|
1050
|
+
Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth);
|
1051
|
+
|
1052
|
+
switch (orient) {
|
1053
|
+
case TTK_ORIENT_HORIZONTAL:
|
1054
|
+
*widthPtr = length + 2 * borderWidth;
|
1055
|
+
*heightPtr = thickness + 2 * borderWidth;
|
1056
|
+
break;
|
1057
|
+
case TTK_ORIENT_VERTICAL:
|
1058
|
+
*widthPtr = thickness + 2 * borderWidth;
|
1059
|
+
*heightPtr = length + 2 * borderWidth;
|
1060
|
+
break;
|
1061
|
+
}
|
1062
|
+
}
|
1063
|
+
|
1064
|
+
static void PbarElementDraw(
|
1065
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
1066
|
+
Drawable d, Ttk_Box b, Ttk_State state)
|
1067
|
+
{
|
1068
|
+
PbarElement *pbar = elementRecord;
|
1069
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, pbar->borderObj);
|
1070
|
+
int relief, borderWidth;
|
1071
|
+
|
1072
|
+
Tk_GetPixelsFromObj(NULL, tkwin, pbar->borderWidthObj, &borderWidth);
|
1073
|
+
Tk_GetReliefFromObj(NULL, pbar->reliefObj, &relief);
|
1074
|
+
|
1075
|
+
Tk_Fill3DRectangle(tkwin, d, border,
|
1076
|
+
b.x, b.y, b.width, b.height,
|
1077
|
+
borderWidth, relief);
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
static Ttk_ElementSpec PbarElementSpec = {
|
1081
|
+
TK_STYLE_VERSION_2,
|
1082
|
+
sizeof(PbarElement),
|
1083
|
+
PbarElementOptions,
|
1084
|
+
PbarElementSize,
|
1085
|
+
PbarElementDraw
|
1086
|
+
};
|
1087
|
+
|
1088
|
+
/*------------------------------------------------------------------------
|
1089
|
+
* +++ Notebook tabs and client area.
|
1090
|
+
*/
|
1091
|
+
|
1092
|
+
typedef struct {
|
1093
|
+
Tcl_Obj *borderWidthObj;
|
1094
|
+
Tcl_Obj *backgroundObj;
|
1095
|
+
} TabElement;
|
1096
|
+
|
1097
|
+
static Ttk_ElementOptionSpec TabElementOptions[] = {
|
1098
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
1099
|
+
Tk_Offset(TabElement,borderWidthObj),"1" },
|
1100
|
+
{ "-background", TK_OPTION_BORDER,
|
1101
|
+
Tk_Offset(TabElement,backgroundObj), DEFAULT_BACKGROUND },
|
1102
|
+
{0,0,0,0}
|
1103
|
+
};
|
1104
|
+
|
1105
|
+
static void TabElementSize(
|
1106
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
1107
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
1108
|
+
{
|
1109
|
+
TabElement *tab = elementRecord;
|
1110
|
+
int borderWidth = 1;
|
1111
|
+
Tk_GetPixelsFromObj(0, tkwin, tab->borderWidthObj, &borderWidth);
|
1112
|
+
paddingPtr->top = paddingPtr->left = paddingPtr->right = borderWidth;
|
1113
|
+
paddingPtr->bottom = 0;
|
1114
|
+
}
|
1115
|
+
|
1116
|
+
static void TabElementDraw(
|
1117
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
1118
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
1119
|
+
{
|
1120
|
+
TabElement *tab = elementRecord;
|
1121
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj);
|
1122
|
+
int borderWidth = 1;
|
1123
|
+
int cut = 2;
|
1124
|
+
XPoint pts[6];
|
1125
|
+
int n = 0;
|
1126
|
+
|
1127
|
+
Tcl_GetIntFromObj(NULL, tab->borderWidthObj, &borderWidth);
|
1128
|
+
|
1129
|
+
if (state & TTK_STATE_SELECTED) {
|
1130
|
+
/*
|
1131
|
+
* Draw slightly outside of the allocated parcel,
|
1132
|
+
* to overwrite the client area border.
|
1133
|
+
*/
|
1134
|
+
b.height += borderWidth;
|
1135
|
+
}
|
1136
|
+
|
1137
|
+
pts[n].x = b.x; pts[n].y = b.y + b.height - 1; ++n;
|
1138
|
+
pts[n].x = b.x; pts[n].y = b.y + cut; ++n;
|
1139
|
+
pts[n].x = b.x + cut; pts[n].y = b.y; ++n;
|
1140
|
+
pts[n].x = b.x + b.width-1-cut; pts[n].y = b.y; ++n;
|
1141
|
+
pts[n].x = b.x + b.width-1; pts[n].y = b.y + cut; ++n;
|
1142
|
+
pts[n].x = b.x + b.width-1; pts[n].y = b.y + b.height; ++n;
|
1143
|
+
|
1144
|
+
XFillPolygon(Tk_Display(tkwin), d,
|
1145
|
+
Tk_3DBorderGC(tkwin, border, TK_3D_FLAT_GC),
|
1146
|
+
pts, 6, Convex, CoordModeOrigin);
|
1147
|
+
|
1148
|
+
#ifndef WIN32
|
1149
|
+
/*
|
1150
|
+
* Account for whether XDrawLines draws endpoints by platform
|
1151
|
+
*/
|
1152
|
+
--pts[5].y;
|
1153
|
+
#endif
|
1154
|
+
|
1155
|
+
while (borderWidth--) {
|
1156
|
+
XDrawLines(Tk_Display(tkwin), d,
|
1157
|
+
Tk_3DBorderGC(tkwin, border, TK_3D_LIGHT_GC),
|
1158
|
+
pts, 4, CoordModeOrigin);
|
1159
|
+
XDrawLines(Tk_Display(tkwin), d,
|
1160
|
+
Tk_3DBorderGC(tkwin, border, TK_3D_DARK_GC),
|
1161
|
+
pts+3, 3, CoordModeOrigin);
|
1162
|
+
++pts[0].x; ++pts[1].x; ++pts[2].x; --pts[4].x; --pts[5].x;
|
1163
|
+
++pts[2].y; ++pts[3].y;
|
1164
|
+
}
|
1165
|
+
|
1166
|
+
}
|
1167
|
+
|
1168
|
+
static Ttk_ElementSpec TabElementSpec = {
|
1169
|
+
TK_STYLE_VERSION_2,
|
1170
|
+
sizeof(TabElement),
|
1171
|
+
TabElementOptions,
|
1172
|
+
TabElementSize,
|
1173
|
+
TabElementDraw
|
1174
|
+
};
|
1175
|
+
|
1176
|
+
/*
|
1177
|
+
* Client area element:
|
1178
|
+
* Uses same resources as tab element.
|
1179
|
+
*/
|
1180
|
+
typedef TabElement ClientElement;
|
1181
|
+
#define ClientElementOptions TabElementOptions
|
1182
|
+
|
1183
|
+
static void ClientElementDraw(
|
1184
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
1185
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
1186
|
+
{
|
1187
|
+
ClientElement *ce = elementRecord;
|
1188
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj);
|
1189
|
+
int borderWidth = 1;
|
1190
|
+
|
1191
|
+
Tcl_GetIntFromObj(NULL, ce->borderWidthObj, &borderWidth);
|
1192
|
+
|
1193
|
+
Tk_Fill3DRectangle(tkwin, d, border,
|
1194
|
+
b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_RAISED);
|
1195
|
+
}
|
1196
|
+
|
1197
|
+
static void ClientElementSize(
|
1198
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
1199
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
1200
|
+
{
|
1201
|
+
ClientElement *ce = elementRecord;
|
1202
|
+
int borderWidth = 1;
|
1203
|
+
Tk_GetPixelsFromObj(0, tkwin, ce->borderWidthObj, &borderWidth);
|
1204
|
+
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
|
1205
|
+
}
|
1206
|
+
|
1207
|
+
static Ttk_ElementSpec ClientElementSpec = {
|
1208
|
+
TK_STYLE_VERSION_2,
|
1209
|
+
sizeof(ClientElement),
|
1210
|
+
ClientElementOptions,
|
1211
|
+
ClientElementSize,
|
1212
|
+
ClientElementDraw
|
1213
|
+
};
|
1214
|
+
|
1215
|
+
/*----------------------------------------------------------------------
|
1216
|
+
* TtkElements_Init --
|
1217
|
+
* Register default element implementations.
|
1218
|
+
*/
|
1219
|
+
|
1220
|
+
void TtkElements_Init(Tcl_Interp *interp)
|
1221
|
+
{
|
1222
|
+
Ttk_Theme theme = Ttk_GetDefaultTheme(interp);
|
1223
|
+
|
1224
|
+
/*
|
1225
|
+
* Elements:
|
1226
|
+
*/
|
1227
|
+
Ttk_RegisterElement(interp, theme, "background",
|
1228
|
+
&BackgroundElementSpec,NULL);
|
1229
|
+
|
1230
|
+
Ttk_RegisterElement(interp, theme, "fill", &FillElementSpec, NULL);
|
1231
|
+
Ttk_RegisterElement(interp, theme, "border", &BorderElementSpec, NULL);
|
1232
|
+
Ttk_RegisterElement(interp, theme, "field", &FieldElementSpec, NULL);
|
1233
|
+
Ttk_RegisterElement(interp, theme, "focus", &FocusElementSpec, NULL);
|
1234
|
+
|
1235
|
+
Ttk_RegisterElement(interp, theme, "padding", &PaddingElementSpec, NULL);
|
1236
|
+
|
1237
|
+
Ttk_RegisterElement(interp, theme, "Checkbutton.indicator",
|
1238
|
+
&CheckbuttonIndicatorElementSpec, NULL);
|
1239
|
+
Ttk_RegisterElement(interp, theme, "Radiobutton.indicator",
|
1240
|
+
&RadiobuttonIndicatorElementSpec, NULL);
|
1241
|
+
Ttk_RegisterElement(interp, theme, "Menubutton.indicator",
|
1242
|
+
&MenuIndicatorElementSpec, NULL);
|
1243
|
+
|
1244
|
+
Ttk_RegisterElement(interp, theme, "indicator", &ttkNullElementSpec,NULL);
|
1245
|
+
|
1246
|
+
Ttk_RegisterElement(interp, theme, "uparrow",
|
1247
|
+
&ArrowElementSpec, &ArrowElements[0]);
|
1248
|
+
Ttk_RegisterElement(interp, theme, "downarrow",
|
1249
|
+
&ArrowElementSpec, &ArrowElements[1]);
|
1250
|
+
Ttk_RegisterElement(interp, theme, "leftarrow",
|
1251
|
+
&ArrowElementSpec, &ArrowElements[2]);
|
1252
|
+
Ttk_RegisterElement(interp, theme, "rightarrow",
|
1253
|
+
&ArrowElementSpec, &ArrowElements[3]);
|
1254
|
+
Ttk_RegisterElement(interp, theme, "arrow",
|
1255
|
+
&ArrowElementSpec, &ArrowElements[0]);
|
1256
|
+
|
1257
|
+
Ttk_RegisterElement(interp, theme, "trough", &TroughElementSpec, NULL);
|
1258
|
+
Ttk_RegisterElement(interp, theme, "thumb", &ThumbElementSpec, NULL);
|
1259
|
+
Ttk_RegisterElement(interp, theme, "slider", &SliderElementSpec, NULL);
|
1260
|
+
Ttk_RegisterElement(interp, theme, "pbar", &PbarElementSpec, NULL);
|
1261
|
+
|
1262
|
+
Ttk_RegisterElement(interp, theme, "separator",
|
1263
|
+
&SeparatorElementSpec, NULL);
|
1264
|
+
Ttk_RegisterElement(interp, theme, "hseparator",
|
1265
|
+
&HorizontalSeparatorElementSpec, NULL);
|
1266
|
+
Ttk_RegisterElement(interp, theme, "vseparator",
|
1267
|
+
&VerticalSeparatorElementSpec, NULL);
|
1268
|
+
|
1269
|
+
Ttk_RegisterElement(interp, theme, "sizegrip", &SizegripElementSpec, NULL);
|
1270
|
+
|
1271
|
+
Ttk_RegisterElement(interp, theme, "tab", &TabElementSpec, NULL);
|
1272
|
+
Ttk_RegisterElement(interp, theme, "client", &ClientElementSpec, NULL);
|
1273
|
+
|
1274
|
+
/*
|
1275
|
+
* Register "default" as a user-loadable theme (for now):
|
1276
|
+
*/
|
1277
|
+
Tcl_PkgProvide(interp, "ttk::theme::default", TILE_VERSION);
|
1278
|
+
}
|
1279
|
+
|
1280
|
+
/*EOF*/
|