Pratt 1.5.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,354 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* cache.c --
|
|
3
|
+
* Tile theme engine, resource cache.
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2004, Joe English
|
|
6
|
+
*
|
|
7
|
+
* cache.c,v 1.10 2005/06/26 16:28:00 jenglish Exp
|
|
8
|
+
*
|
|
9
|
+
* The problem:
|
|
10
|
+
*
|
|
11
|
+
* Tk maintains reference counts for fonts, colors, and images,
|
|
12
|
+
* and deallocates them when the reference count goes to zero.
|
|
13
|
+
* With the theme engine, resources are allocated right before
|
|
14
|
+
* drawing an element and released immediately after.
|
|
15
|
+
* This causes a severe performance penalty, and on PseudoColor
|
|
16
|
+
* visuals it causes colormap cycling as colormap entries are
|
|
17
|
+
* released and reused.
|
|
18
|
+
*
|
|
19
|
+
* Solution: Acquire fonts, colors, and objects from a
|
|
20
|
+
* resource cache instead of directly from Tk; the cache
|
|
21
|
+
* holds a semipermanent reference to the resource to keep
|
|
22
|
+
* it from being deallocated.
|
|
23
|
+
*
|
|
24
|
+
* The plumbing and control flow here is quite contorted;
|
|
25
|
+
* it would be better to address this problem in the core instead.
|
|
26
|
+
*
|
|
27
|
+
* @@@ BUGS/TODO: Need distinct caches for each combination
|
|
28
|
+
* of display, visual, and colormap.
|
|
29
|
+
*
|
|
30
|
+
* @@@ Colormap flashing on PseudoColor visuals is still possible,
|
|
31
|
+
* but this will be a transient effect.
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
#include <stdio.h> /* for sprintf */
|
|
35
|
+
#include <tk.h>
|
|
36
|
+
#include "tkTheme.h"
|
|
37
|
+
|
|
38
|
+
struct Ttk_ResourceCache_ {
|
|
39
|
+
Tcl_Interp *interp; /* Interpreter for error reporting */
|
|
40
|
+
Tk_Window tkwin; /* Cache window. */
|
|
41
|
+
Tcl_HashTable fontTable; /* Entries: Tcl_Obj* holding FontObjs */
|
|
42
|
+
Tcl_HashTable colorTable; /* Entries: Tcl_Obj* holding ColorObjs */
|
|
43
|
+
Tcl_HashTable borderTable; /* Entries: Tcl_Obj* holding BorderObjs */
|
|
44
|
+
Tcl_HashTable imageTable; /* Entries: Tk_Images */
|
|
45
|
+
|
|
46
|
+
Tcl_HashTable namedColors; /* Entries: RGB values as Tcl_StringObjs */
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/*
|
|
50
|
+
* Ttk_CreateResourceCache --
|
|
51
|
+
* Initialize a new resource cache.
|
|
52
|
+
*/
|
|
53
|
+
Ttk_ResourceCache Ttk_CreateResourceCache(Tcl_Interp *interp)
|
|
54
|
+
{
|
|
55
|
+
Ttk_ResourceCache cache = (Ttk_ResourceCache)ckalloc(sizeof(*cache));
|
|
56
|
+
|
|
57
|
+
cache->tkwin = NULL; /* initialized later */
|
|
58
|
+
cache->interp = interp;
|
|
59
|
+
Tcl_InitHashTable(&cache->fontTable, TCL_STRING_KEYS);
|
|
60
|
+
Tcl_InitHashTable(&cache->colorTable, TCL_STRING_KEYS);
|
|
61
|
+
Tcl_InitHashTable(&cache->borderTable, TCL_STRING_KEYS);
|
|
62
|
+
Tcl_InitHashTable(&cache->imageTable, TCL_STRING_KEYS);
|
|
63
|
+
Tcl_InitHashTable(&cache->namedColors, TCL_STRING_KEYS);
|
|
64
|
+
|
|
65
|
+
return cache;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/*
|
|
69
|
+
* Ttk_ClearCache --
|
|
70
|
+
* Release references to all cached resources.
|
|
71
|
+
*/
|
|
72
|
+
static void Ttk_ClearCache(Ttk_ResourceCache cache)
|
|
73
|
+
{
|
|
74
|
+
Tcl_HashSearch search;
|
|
75
|
+
Tcl_HashEntry *entryPtr;
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* Free fonts:
|
|
79
|
+
*/
|
|
80
|
+
entryPtr = Tcl_FirstHashEntry(&cache->fontTable, &search);
|
|
81
|
+
while (entryPtr != NULL) {
|
|
82
|
+
Tcl_Obj *fontObj = (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
|
|
83
|
+
if (fontObj) {
|
|
84
|
+
Tk_FreeFontFromObj(cache->tkwin, fontObj);
|
|
85
|
+
Tcl_DecrRefCount(fontObj);
|
|
86
|
+
}
|
|
87
|
+
entryPtr = Tcl_NextHashEntry(&search);
|
|
88
|
+
}
|
|
89
|
+
Tcl_DeleteHashTable(&cache->fontTable);
|
|
90
|
+
Tcl_InitHashTable(&cache->fontTable, TCL_STRING_KEYS);
|
|
91
|
+
|
|
92
|
+
/*
|
|
93
|
+
* Free colors:
|
|
94
|
+
*/
|
|
95
|
+
entryPtr = Tcl_FirstHashEntry(&cache->colorTable, &search);
|
|
96
|
+
while (entryPtr != NULL) {
|
|
97
|
+
Tcl_Obj *colorObj = (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
|
|
98
|
+
if (colorObj) {
|
|
99
|
+
Tk_FreeColorFromObj(cache->tkwin, colorObj);
|
|
100
|
+
Tcl_DecrRefCount(colorObj);
|
|
101
|
+
}
|
|
102
|
+
entryPtr = Tcl_NextHashEntry(&search);
|
|
103
|
+
}
|
|
104
|
+
Tcl_DeleteHashTable(&cache->colorTable);
|
|
105
|
+
Tcl_InitHashTable(&cache->colorTable, TCL_STRING_KEYS);
|
|
106
|
+
|
|
107
|
+
/*
|
|
108
|
+
* Free borders:
|
|
109
|
+
*/
|
|
110
|
+
entryPtr = Tcl_FirstHashEntry(&cache->borderTable, &search);
|
|
111
|
+
while (entryPtr != NULL) {
|
|
112
|
+
Tcl_Obj *borderObj = (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
|
|
113
|
+
if (borderObj) {
|
|
114
|
+
Tk_Free3DBorderFromObj(cache->tkwin, borderObj);
|
|
115
|
+
Tcl_DecrRefCount(borderObj);
|
|
116
|
+
}
|
|
117
|
+
entryPtr = Tcl_NextHashEntry(&search);
|
|
118
|
+
}
|
|
119
|
+
Tcl_DeleteHashTable(&cache->borderTable);
|
|
120
|
+
Tcl_InitHashTable(&cache->borderTable, TCL_STRING_KEYS);
|
|
121
|
+
|
|
122
|
+
/*
|
|
123
|
+
* Free images:
|
|
124
|
+
*/
|
|
125
|
+
entryPtr = Tcl_FirstHashEntry(&cache->imageTable, &search);
|
|
126
|
+
while (entryPtr != NULL) {
|
|
127
|
+
Tk_Image image = (Tk_Image)Tcl_GetHashValue(entryPtr);
|
|
128
|
+
if (image) {
|
|
129
|
+
Tk_FreeImage(image);
|
|
130
|
+
}
|
|
131
|
+
entryPtr = Tcl_NextHashEntry(&search);
|
|
132
|
+
}
|
|
133
|
+
Tcl_DeleteHashTable(&cache->imageTable);
|
|
134
|
+
Tcl_InitHashTable(&cache->imageTable, TCL_STRING_KEYS);
|
|
135
|
+
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/*
|
|
140
|
+
* Ttk_FreeResourceCache --
|
|
141
|
+
* Release references to all cached resources, delete the cache.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
void Ttk_FreeResourceCache(Ttk_ResourceCache cache)
|
|
145
|
+
{
|
|
146
|
+
Tcl_HashEntry *entryPtr;
|
|
147
|
+
Tcl_HashSearch search;
|
|
148
|
+
|
|
149
|
+
Ttk_ClearCache(cache);
|
|
150
|
+
|
|
151
|
+
Tcl_DeleteHashTable(&cache->colorTable);
|
|
152
|
+
Tcl_DeleteHashTable(&cache->fontTable);
|
|
153
|
+
Tcl_DeleteHashTable(&cache->imageTable);
|
|
154
|
+
|
|
155
|
+
/*
|
|
156
|
+
* Free named colors:
|
|
157
|
+
*/
|
|
158
|
+
entryPtr = Tcl_FirstHashEntry(&cache->namedColors, &search);
|
|
159
|
+
while (entryPtr != NULL) {
|
|
160
|
+
Tcl_Obj *colorNameObj = (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
|
|
161
|
+
Tcl_DecrRefCount(colorNameObj);
|
|
162
|
+
entryPtr = Tcl_NextHashEntry(&search);
|
|
163
|
+
}
|
|
164
|
+
Tcl_DeleteHashTable(&cache->namedColors);
|
|
165
|
+
|
|
166
|
+
ckfree((ClientData)cache);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/*
|
|
170
|
+
* CacheWinEventHandler --
|
|
171
|
+
* Detect when the cache window is destroyed, clear cache.
|
|
172
|
+
*/
|
|
173
|
+
static void CacheWinEventHandler(ClientData clientData, XEvent *eventPtr)
|
|
174
|
+
{
|
|
175
|
+
Ttk_ResourceCache cache = (Ttk_ResourceCache)clientData;
|
|
176
|
+
|
|
177
|
+
if (eventPtr->type != DestroyNotify) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
Tk_DeleteEventHandler(cache->tkwin, StructureNotifyMask,
|
|
181
|
+
CacheWinEventHandler, clientData);
|
|
182
|
+
Ttk_ClearCache(cache);
|
|
183
|
+
cache->tkwin = NULL;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/*
|
|
187
|
+
* InitCacheWindow --
|
|
188
|
+
* Specify the cache window if not already set.
|
|
189
|
+
* @@@ SHOULD: use separate caches for each combination
|
|
190
|
+
* @@@ of display, visual, and colormap.
|
|
191
|
+
*/
|
|
192
|
+
static void InitCacheWindow(Ttk_ResourceCache cache, Tk_Window tkwin)
|
|
193
|
+
{
|
|
194
|
+
if (cache->tkwin == NULL) {
|
|
195
|
+
cache->tkwin = tkwin;
|
|
196
|
+
Tk_CreateEventHandler(tkwin, StructureNotifyMask,
|
|
197
|
+
CacheWinEventHandler, (ClientData)cache);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/*
|
|
202
|
+
* Ttk_RegisterNamedColor --
|
|
203
|
+
* Specify an RGB triplet as a named color.
|
|
204
|
+
* Overrides any previous named color specification.
|
|
205
|
+
*
|
|
206
|
+
*/
|
|
207
|
+
void Ttk_RegisterNamedColor(
|
|
208
|
+
Ttk_ResourceCache cache,
|
|
209
|
+
const char *colorName,
|
|
210
|
+
XColor *colorPtr)
|
|
211
|
+
{
|
|
212
|
+
int newEntry;
|
|
213
|
+
Tcl_HashEntry *entryPtr;
|
|
214
|
+
char nameBuf[14];
|
|
215
|
+
Tcl_Obj *colorNameObj;
|
|
216
|
+
|
|
217
|
+
sprintf(nameBuf, "#%04X%04X%04X",
|
|
218
|
+
colorPtr->red, colorPtr->green, colorPtr->blue);
|
|
219
|
+
colorNameObj = Tcl_NewStringObj(nameBuf, -1);
|
|
220
|
+
Tcl_IncrRefCount(colorNameObj);
|
|
221
|
+
|
|
222
|
+
entryPtr = Tcl_CreateHashEntry(&cache->namedColors, colorName, &newEntry);
|
|
223
|
+
if (!newEntry) {
|
|
224
|
+
Tcl_Obj *oldColor = (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
|
|
225
|
+
Tcl_DecrRefCount(oldColor);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
Tcl_SetHashValue(entryPtr, (ClientData)colorNameObj);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/*
|
|
232
|
+
* CheckNamedColor(objPtr) --
|
|
233
|
+
* If objPtr is a registered color name, return a Tcl_Obj *
|
|
234
|
+
* containing the registered color value specification.
|
|
235
|
+
* Otherwise, return the input argument.
|
|
236
|
+
*/
|
|
237
|
+
static Tcl_Obj *CheckNamedColor(Ttk_ResourceCache cache, Tcl_Obj *objPtr)
|
|
238
|
+
{
|
|
239
|
+
Tcl_HashEntry *entryPtr =
|
|
240
|
+
Tcl_FindHashEntry(&cache->namedColors, Tcl_GetString(objPtr));
|
|
241
|
+
if (entryPtr) { /* Use named color instead */
|
|
242
|
+
objPtr = (Tcl_Obj *)Tcl_GetHashValue(entryPtr);
|
|
243
|
+
}
|
|
244
|
+
return objPtr;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/*
|
|
248
|
+
* Template for allocation routines:
|
|
249
|
+
*/
|
|
250
|
+
typedef void *(*Allocator)(Tcl_Interp *, Tk_Window, Tcl_Obj *);
|
|
251
|
+
|
|
252
|
+
static Tcl_Obj *Ttk_Use(
|
|
253
|
+
Tcl_Interp *interp,
|
|
254
|
+
Tcl_HashTable *table,
|
|
255
|
+
Allocator allocate,
|
|
256
|
+
Tk_Window tkwin,
|
|
257
|
+
Tcl_Obj *objPtr)
|
|
258
|
+
{
|
|
259
|
+
int newEntry;
|
|
260
|
+
Tcl_HashEntry *entryPtr =
|
|
261
|
+
Tcl_CreateHashEntry(table,Tcl_GetString(objPtr),&newEntry);
|
|
262
|
+
Tcl_Obj *cacheObj;
|
|
263
|
+
|
|
264
|
+
if (!newEntry) {
|
|
265
|
+
return (Tcl_Obj*)Tcl_GetHashValue(entryPtr);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
cacheObj = Tcl_DuplicateObj(objPtr);
|
|
269
|
+
Tcl_IncrRefCount(cacheObj);
|
|
270
|
+
|
|
271
|
+
if (allocate(interp, tkwin, cacheObj)) {
|
|
272
|
+
Tcl_SetHashValue(entryPtr, cacheObj);
|
|
273
|
+
return cacheObj;
|
|
274
|
+
} else {
|
|
275
|
+
Tcl_DecrRefCount(cacheObj);
|
|
276
|
+
Tcl_SetHashValue(entryPtr, NULL);
|
|
277
|
+
Tcl_BackgroundError(interp);
|
|
278
|
+
return NULL;
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/*
|
|
283
|
+
* Ttk_UseFont --
|
|
284
|
+
* Acquire a font from the cache.
|
|
285
|
+
*/
|
|
286
|
+
Tcl_Obj *Ttk_UseFont(Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
|
|
287
|
+
{
|
|
288
|
+
InitCacheWindow(cache, tkwin);
|
|
289
|
+
return Ttk_Use(cache->interp,
|
|
290
|
+
&cache->fontTable,(Allocator)Tk_AllocFontFromObj, tkwin, objPtr);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/*
|
|
294
|
+
* Ttk_UseColor --
|
|
295
|
+
* Acquire a color from the cache.
|
|
296
|
+
*/
|
|
297
|
+
Tcl_Obj *Ttk_UseColor(Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
|
|
298
|
+
{
|
|
299
|
+
objPtr = CheckNamedColor(cache, objPtr);
|
|
300
|
+
InitCacheWindow(cache, tkwin);
|
|
301
|
+
return Ttk_Use(cache->interp,
|
|
302
|
+
&cache->colorTable,(Allocator)Tk_AllocColorFromObj, tkwin, objPtr);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/*
|
|
306
|
+
* Ttk_UseBorder --
|
|
307
|
+
* Acquire a Tk_3DBorder from the cache.
|
|
308
|
+
*/
|
|
309
|
+
Tcl_Obj *Ttk_UseBorder(
|
|
310
|
+
Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
|
|
311
|
+
{
|
|
312
|
+
objPtr = CheckNamedColor(cache, objPtr);
|
|
313
|
+
InitCacheWindow(cache, tkwin);
|
|
314
|
+
return Ttk_Use(cache->interp,
|
|
315
|
+
&cache->borderTable,(Allocator)Tk_Alloc3DBorderFromObj, tkwin, objPtr);
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/* NullImageChanged --
|
|
319
|
+
* Tk_ImageChangedProc for Ttk_UseImage
|
|
320
|
+
*/
|
|
321
|
+
|
|
322
|
+
static void NullImageChanged(ClientData clientData,
|
|
323
|
+
int x, int y, int width, int height, int imageWidth, int imageHeight)
|
|
324
|
+
{ /* No-op */ }
|
|
325
|
+
|
|
326
|
+
/*
|
|
327
|
+
* Ttk_UseImage --
|
|
328
|
+
* Acquire a Tk_Image from the cache.
|
|
329
|
+
*/
|
|
330
|
+
Tk_Image Ttk_UseImage(Ttk_ResourceCache cache, Tk_Window tkwin, Tcl_Obj *objPtr)
|
|
331
|
+
{
|
|
332
|
+
const char *imageName = Tcl_GetString(objPtr);
|
|
333
|
+
int newEntry;
|
|
334
|
+
Tcl_HashEntry *entryPtr =
|
|
335
|
+
Tcl_CreateHashEntry(&cache->imageTable,imageName,&newEntry);
|
|
336
|
+
Tk_Image image;
|
|
337
|
+
|
|
338
|
+
InitCacheWindow(cache, tkwin);
|
|
339
|
+
|
|
340
|
+
if (!newEntry) {
|
|
341
|
+
return (Tk_Image)Tcl_GetHashValue(entryPtr);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
image = Tk_GetImage(cache->interp, tkwin, imageName, NullImageChanged,0);
|
|
345
|
+
Tcl_SetHashValue(entryPtr, image);
|
|
346
|
+
|
|
347
|
+
if (!image) {
|
|
348
|
+
Tcl_BackgroundError(cache->interp);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
return image;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/*EOF*/
|
|
@@ -0,0 +1,974 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* clamTheme.c,v 1.30 2007/12/02 04:34:30 jenglish Exp
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2004 Joe English
|
|
5
|
+
*
|
|
6
|
+
* Tile widget set: another theme engine.
|
|
7
|
+
* Inspired by the XFCE family of Gnome themes.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include <tk.h>
|
|
11
|
+
#include "tkTheme.h"
|
|
12
|
+
|
|
13
|
+
/*
|
|
14
|
+
* Under windows, the Tk-provided XDrawLine and XDrawArc have an
|
|
15
|
+
* off-by-one error in the end point. This is especially apparent with this
|
|
16
|
+
* theme. Defining this macro as true handles this case.
|
|
17
|
+
*/
|
|
18
|
+
#if defined(WIN32) && !defined(WIN32_XDRAWLINE_HACK)
|
|
19
|
+
# define WIN32_XDRAWLINE_HACK 1
|
|
20
|
+
#else
|
|
21
|
+
# define WIN32_XDRAWLINE_HACK 0
|
|
22
|
+
#endif
|
|
23
|
+
|
|
24
|
+
#define STR(x) StR(x)
|
|
25
|
+
#define StR(x) #x
|
|
26
|
+
|
|
27
|
+
#define SCROLLBAR_THICKNESS 14
|
|
28
|
+
|
|
29
|
+
#define FRAME_COLOR "#dcdad5"
|
|
30
|
+
#define LIGHT_COLOR "#ffffff"
|
|
31
|
+
#define DARK_COLOR "#cfcdc8"
|
|
32
|
+
#define DARKER_COLOR "#bab5ab"
|
|
33
|
+
#define DARKEST_COLOR "#9e9a91"
|
|
34
|
+
|
|
35
|
+
/*------------------------------------------------------------------------
|
|
36
|
+
* +++ Utilities.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
static GC Ttk_GCForColor(Tk_Window tkwin, Tcl_Obj* colorObj, Drawable d)
|
|
40
|
+
{
|
|
41
|
+
GC gc = Tk_GCForColor(Tk_GetColorFromObj(tkwin, colorObj), d);
|
|
42
|
+
|
|
43
|
+
#ifdef MAC_OSX_TK
|
|
44
|
+
/*
|
|
45
|
+
* Workaround for Tk bug under Aqua where the default line width is 0.
|
|
46
|
+
*/
|
|
47
|
+
Display *display = Tk_Display(tkwin);
|
|
48
|
+
unsigned long mask = 0ul;
|
|
49
|
+
XGCValues gcValues;
|
|
50
|
+
|
|
51
|
+
gcValues.line_width = 1;
|
|
52
|
+
mask = GCLineWidth;
|
|
53
|
+
|
|
54
|
+
XChangeGC(display, gc, mask, &gcValues);
|
|
55
|
+
#endif
|
|
56
|
+
|
|
57
|
+
return gc;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static void DrawSmoothBorder(
|
|
61
|
+
Tk_Window tkwin, Drawable d, Ttk_Box b,
|
|
62
|
+
Tcl_Obj *outerColorObj, Tcl_Obj *upperColorObj, Tcl_Obj *lowerColorObj)
|
|
63
|
+
{
|
|
64
|
+
Display *display = Tk_Display(tkwin);
|
|
65
|
+
int x1 = b.x, x2 = b.x + b.width - 1;
|
|
66
|
+
int y1 = b.y, y2 = b.y + b.height - 1;
|
|
67
|
+
const int w = WIN32_XDRAWLINE_HACK;
|
|
68
|
+
GC gc;
|
|
69
|
+
|
|
70
|
+
if ( outerColorObj
|
|
71
|
+
&& (gc=Ttk_GCForColor(tkwin,outerColorObj,d)))
|
|
72
|
+
{
|
|
73
|
+
XDrawLine(display,d,gc, x1+1,y1, x2-1+w,y1); /* N */
|
|
74
|
+
XDrawLine(display,d,gc, x1+1,y2, x2-1+w,y2); /* S */
|
|
75
|
+
XDrawLine(display,d,gc, x1,y1+1, x1,y2-1+w); /* E */
|
|
76
|
+
XDrawLine(display,d,gc, x2,y1+1, x2,y2-1+w); /* W */
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if ( upperColorObj
|
|
80
|
+
&& (gc=Ttk_GCForColor(tkwin,upperColorObj,d)))
|
|
81
|
+
{
|
|
82
|
+
XDrawLine(display,d,gc, x1+1,y1+1, x2-1+w,y1+1); /* N */
|
|
83
|
+
XDrawLine(display,d,gc, x1+1,y1+1, x1+1,y2-1); /* E */
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if ( lowerColorObj
|
|
87
|
+
&& (gc=Ttk_GCForColor(tkwin,lowerColorObj,d)))
|
|
88
|
+
{
|
|
89
|
+
XDrawLine(display,d,gc, x2-1,y2-1, x1+1-w,y2-1); /* S */
|
|
90
|
+
XDrawLine(display,d,gc, x2-1,y2-1, x2-1,y1+1-w); /* W */
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
static GC BackgroundGC(Tk_Window tkwin, Tcl_Obj *backgroundObj)
|
|
95
|
+
{
|
|
96
|
+
Tk_3DBorder bd = Tk_Get3DBorderFromObj(tkwin, backgroundObj);
|
|
97
|
+
return Tk_3DBorderGC(tkwin, bd, TK_3D_FLAT_GC);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/*------------------------------------------------------------------------
|
|
101
|
+
* +++ Border element.
|
|
102
|
+
*/
|
|
103
|
+
|
|
104
|
+
typedef struct {
|
|
105
|
+
Tcl_Obj *borderColorObj;
|
|
106
|
+
Tcl_Obj *lightColorObj;
|
|
107
|
+
Tcl_Obj *darkColorObj;
|
|
108
|
+
Tcl_Obj *reliefObj;
|
|
109
|
+
Tcl_Obj *borderWidthObj; /* See <<NOTE-BORDERWIDTH>> */
|
|
110
|
+
} BorderElement;
|
|
111
|
+
|
|
112
|
+
static Ttk_ElementOptionSpec BorderElementOptions[] = {
|
|
113
|
+
{ "-bordercolor", TK_OPTION_COLOR,
|
|
114
|
+
Tk_Offset(BorderElement,borderColorObj), DARKEST_COLOR },
|
|
115
|
+
{ "-lightcolor", TK_OPTION_COLOR,
|
|
116
|
+
Tk_Offset(BorderElement,lightColorObj), LIGHT_COLOR },
|
|
117
|
+
{ "-darkcolor", TK_OPTION_COLOR,
|
|
118
|
+
Tk_Offset(BorderElement,darkColorObj), DARK_COLOR },
|
|
119
|
+
{ "-relief", TK_OPTION_RELIEF,
|
|
120
|
+
Tk_Offset(BorderElement,reliefObj), "flat" },
|
|
121
|
+
{ "-borderwidth", TK_OPTION_PIXELS,
|
|
122
|
+
Tk_Offset(BorderElement,borderWidthObj), "2" },
|
|
123
|
+
{0,0,0}
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
* <<NOTE-BORDERWIDTH>>: -borderwidth is only partially supported:
|
|
128
|
+
* in this theme, borders are always exactly 2 pixels thick.
|
|
129
|
+
* With -borderwidth 0, border is not drawn at all;
|
|
130
|
+
* otherwise a 2-pixel border is used. For -borderwidth > 2,
|
|
131
|
+
* the excess is used as padding.
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
static void BorderElementSize(
|
|
135
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
136
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
137
|
+
{
|
|
138
|
+
BorderElement *border = (BorderElement*)elementRecord;
|
|
139
|
+
int borderWidth = 2;
|
|
140
|
+
Tk_GetPixelsFromObj(NULL, tkwin, border->borderWidthObj, &borderWidth);
|
|
141
|
+
if (borderWidth == 1) ++borderWidth;
|
|
142
|
+
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
static void BorderElementDraw(
|
|
146
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
147
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
148
|
+
{
|
|
149
|
+
BorderElement *border = elementRecord;
|
|
150
|
+
int relief = TK_RELIEF_FLAT;
|
|
151
|
+
int borderWidth = 2;
|
|
152
|
+
Tcl_Obj *outer = 0, *upper = 0, *lower = 0;
|
|
153
|
+
|
|
154
|
+
Tk_GetReliefFromObj(NULL, border->reliefObj, &relief);
|
|
155
|
+
Tk_GetPixelsFromObj(NULL, tkwin, border->borderWidthObj, &borderWidth);
|
|
156
|
+
|
|
157
|
+
if (borderWidth == 0) return;
|
|
158
|
+
|
|
159
|
+
switch (relief) {
|
|
160
|
+
case TK_RELIEF_GROOVE :
|
|
161
|
+
case TK_RELIEF_RIDGE :
|
|
162
|
+
case TK_RELIEF_RAISED :
|
|
163
|
+
outer = border->borderColorObj;
|
|
164
|
+
upper = border->lightColorObj;
|
|
165
|
+
lower = border->darkColorObj;
|
|
166
|
+
break;
|
|
167
|
+
case TK_RELIEF_SUNKEN :
|
|
168
|
+
outer = border->borderColorObj;
|
|
169
|
+
upper = border->darkColorObj;
|
|
170
|
+
lower = border->lightColorObj;
|
|
171
|
+
break;
|
|
172
|
+
case TK_RELIEF_FLAT :
|
|
173
|
+
outer = upper = lower = 0;
|
|
174
|
+
break;
|
|
175
|
+
case TK_RELIEF_SOLID :
|
|
176
|
+
outer = upper = lower = border->borderColorObj;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
DrawSmoothBorder(tkwin, d, b, outer, upper, lower);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
static Ttk_ElementSpec BorderElementSpec = {
|
|
184
|
+
TK_STYLE_VERSION_2,
|
|
185
|
+
sizeof(BorderElement),
|
|
186
|
+
BorderElementOptions,
|
|
187
|
+
BorderElementSize,
|
|
188
|
+
BorderElementDraw
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/*------------------------------------------------------------------------
|
|
192
|
+
* +++ Field element.
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
typedef struct {
|
|
196
|
+
Tcl_Obj *borderColorObj;
|
|
197
|
+
Tcl_Obj *lightColorObj;
|
|
198
|
+
Tcl_Obj *darkColorObj;
|
|
199
|
+
Tcl_Obj *backgroundObj;
|
|
200
|
+
} FieldElement;
|
|
201
|
+
|
|
202
|
+
static Ttk_ElementOptionSpec FieldElementOptions[] = {
|
|
203
|
+
{ "-bordercolor", TK_OPTION_COLOR,
|
|
204
|
+
Tk_Offset(FieldElement,borderColorObj), DARKEST_COLOR },
|
|
205
|
+
{ "-lightcolor", TK_OPTION_COLOR,
|
|
206
|
+
Tk_Offset(FieldElement,lightColorObj), LIGHT_COLOR },
|
|
207
|
+
{ "-darkcolor", TK_OPTION_COLOR,
|
|
208
|
+
Tk_Offset(FieldElement,darkColorObj), DARK_COLOR },
|
|
209
|
+
{ "-fieldbackground", TK_OPTION_BORDER,
|
|
210
|
+
Tk_Offset(FieldElement,backgroundObj), "white" },
|
|
211
|
+
{0,0,0}
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
static void FieldElementSize(
|
|
215
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
216
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
217
|
+
{
|
|
218
|
+
*paddingPtr = Ttk_UniformPadding(2);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
static void FieldElementDraw(
|
|
222
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
223
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
224
|
+
{
|
|
225
|
+
FieldElement *field = elementRecord;
|
|
226
|
+
Tk_3DBorder bg = Tk_Get3DBorderFromObj(tkwin, field->backgroundObj);
|
|
227
|
+
Ttk_Box f = Ttk_PadBox(b, Ttk_UniformPadding(2));
|
|
228
|
+
Tcl_Obj *outer = field->borderColorObj,
|
|
229
|
+
*inner = field->lightColorObj;
|
|
230
|
+
|
|
231
|
+
DrawSmoothBorder(tkwin, d, b, outer, inner, inner);
|
|
232
|
+
Tk_Fill3DRectangle(
|
|
233
|
+
tkwin, d, bg, f.x, f.y, f.width, f.height, 0, TK_RELIEF_SUNKEN);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
static Ttk_ElementSpec FieldElementSpec = {
|
|
237
|
+
TK_STYLE_VERSION_2,
|
|
238
|
+
sizeof(FieldElement),
|
|
239
|
+
FieldElementOptions,
|
|
240
|
+
FieldElementSize,
|
|
241
|
+
FieldElementDraw
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
/*
|
|
245
|
+
* Modified field element for comboboxes:
|
|
246
|
+
* Right edge is expanded to overlap the dropdown button.
|
|
247
|
+
*/
|
|
248
|
+
static void ComboboxFieldElementDraw(
|
|
249
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
250
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
251
|
+
{
|
|
252
|
+
FieldElement *field = elementRecord;
|
|
253
|
+
GC gc = Ttk_GCForColor(tkwin,field->borderColorObj,d);
|
|
254
|
+
|
|
255
|
+
++b.width;
|
|
256
|
+
FieldElementDraw(clientData, elementRecord, tkwin, d, b, state);
|
|
257
|
+
|
|
258
|
+
XDrawLine(Tk_Display(tkwin), d, gc,
|
|
259
|
+
b.x + b.width - 1, b.y,
|
|
260
|
+
b.x + b.width - 1, b.y + b.height - 1 + WIN32_XDRAWLINE_HACK);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
static Ttk_ElementSpec ComboboxFieldElementSpec = {
|
|
264
|
+
TK_STYLE_VERSION_2,
|
|
265
|
+
sizeof(FieldElement),
|
|
266
|
+
FieldElementOptions,
|
|
267
|
+
FieldElementSize,
|
|
268
|
+
ComboboxFieldElementDraw
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
/*------------------------------------------------------------------------
|
|
272
|
+
* +++ Indicator elements for check and radio buttons.
|
|
273
|
+
*/
|
|
274
|
+
|
|
275
|
+
typedef struct {
|
|
276
|
+
Tcl_Obj *sizeObj;
|
|
277
|
+
Tcl_Obj *marginObj;
|
|
278
|
+
Tcl_Obj *backgroundObj;
|
|
279
|
+
Tcl_Obj *foregroundObj;
|
|
280
|
+
Tcl_Obj *upperColorObj;
|
|
281
|
+
Tcl_Obj *lowerColorObj;
|
|
282
|
+
} IndicatorElement;
|
|
283
|
+
|
|
284
|
+
static Ttk_ElementOptionSpec IndicatorElementOptions[] = {
|
|
285
|
+
{ "-indicatorsize", TK_OPTION_PIXELS,
|
|
286
|
+
Tk_Offset(IndicatorElement,sizeObj), "10" },
|
|
287
|
+
{ "-indicatormargin", TK_OPTION_STRING,
|
|
288
|
+
Tk_Offset(IndicatorElement,marginObj), "1" },
|
|
289
|
+
{ "-indicatorbackground", TK_OPTION_COLOR,
|
|
290
|
+
Tk_Offset(IndicatorElement,backgroundObj), "white" },
|
|
291
|
+
{ "-indicatorforeground", TK_OPTION_COLOR,
|
|
292
|
+
Tk_Offset(IndicatorElement,foregroundObj), "black" },
|
|
293
|
+
{ "-upperbordercolor", TK_OPTION_COLOR,
|
|
294
|
+
Tk_Offset(IndicatorElement,upperColorObj), DARKEST_COLOR },
|
|
295
|
+
{ "-lowerbordercolor", TK_OPTION_COLOR,
|
|
296
|
+
Tk_Offset(IndicatorElement,lowerColorObj), DARK_COLOR },
|
|
297
|
+
{0,0,0}
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
static void IndicatorElementSize(
|
|
301
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
302
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
303
|
+
{
|
|
304
|
+
IndicatorElement *indicator = elementRecord;
|
|
305
|
+
Ttk_Padding margins;
|
|
306
|
+
int size = 10;
|
|
307
|
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &margins);
|
|
308
|
+
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
|
|
309
|
+
*widthPtr = size + Ttk_PaddingWidth(margins);
|
|
310
|
+
*heightPtr = size + Ttk_PaddingHeight(margins);
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
static void RadioIndicatorElementDraw(
|
|
314
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
315
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
316
|
+
{
|
|
317
|
+
IndicatorElement *indicator = elementRecord;
|
|
318
|
+
GC gcb=Ttk_GCForColor(tkwin,indicator->backgroundObj,d);
|
|
319
|
+
GC gcf=Ttk_GCForColor(tkwin,indicator->foregroundObj,d);
|
|
320
|
+
GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d);
|
|
321
|
+
GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d);
|
|
322
|
+
Ttk_Padding padding;
|
|
323
|
+
|
|
324
|
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
|
|
325
|
+
b = Ttk_PadBox(b, padding);
|
|
326
|
+
|
|
327
|
+
XFillArc(Tk_Display(tkwin),d,gcb, b.x,b.y,b.width,b.height, 0,360*64);
|
|
328
|
+
XDrawArc(Tk_Display(tkwin),d,gcl, b.x,b.y,b.width,b.height, 225*64,180*64);
|
|
329
|
+
XDrawArc(Tk_Display(tkwin),d,gcu, b.x,b.y,b.width,b.height, 45*64,180*64);
|
|
330
|
+
|
|
331
|
+
if (state & TTK_STATE_SELECTED) {
|
|
332
|
+
b = Ttk_PadBox(b,Ttk_UniformPadding(3));
|
|
333
|
+
XFillArc(Tk_Display(tkwin),d,gcf, b.x,b.y,b.width,b.height, 0,360*64);
|
|
334
|
+
XDrawArc(Tk_Display(tkwin),d,gcf, b.x,b.y,b.width,b.height, 0,360*64);
|
|
335
|
+
#if WIN32_XDRAWLINE_HACK
|
|
336
|
+
XDrawArc(Tk_Display(tkwin),d,gcf, b.x,b.y,b.width,b.height, 300*64,360*64);
|
|
337
|
+
#endif
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
static void CheckIndicatorElementDraw(
|
|
342
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
343
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
344
|
+
{
|
|
345
|
+
Display *display = Tk_Display(tkwin);
|
|
346
|
+
IndicatorElement *indicator = elementRecord;
|
|
347
|
+
GC gcb=Ttk_GCForColor(tkwin,indicator->backgroundObj,d);
|
|
348
|
+
GC gcf=Ttk_GCForColor(tkwin,indicator->foregroundObj,d);
|
|
349
|
+
GC gcu=Ttk_GCForColor(tkwin,indicator->upperColorObj,d);
|
|
350
|
+
GC gcl=Ttk_GCForColor(tkwin,indicator->lowerColorObj,d);
|
|
351
|
+
Ttk_Padding padding;
|
|
352
|
+
const int w = WIN32_XDRAWLINE_HACK;
|
|
353
|
+
|
|
354
|
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->marginObj, &padding);
|
|
355
|
+
b = Ttk_PadBox(b, padding);
|
|
356
|
+
|
|
357
|
+
XFillRectangle(display,d,gcb, b.x,b.y,b.width,b.height);
|
|
358
|
+
XDrawLine(display,d,gcl,b.x,b.y+b.height,b.x+b.width+w,b.y+b.height);/*S*/
|
|
359
|
+
XDrawLine(display,d,gcl,b.x+b.width,b.y,b.x+b.width,b.y+b.height+w); /*E*/
|
|
360
|
+
XDrawLine(display,d,gcu,b.x,b.y, b.x,b.y+b.height+w); /*W*/
|
|
361
|
+
XDrawLine(display,d,gcu,b.x,b.y, b.x+b.width+w,b.y); /*N*/
|
|
362
|
+
|
|
363
|
+
if (state & TTK_STATE_SELECTED) {
|
|
364
|
+
int p,q,r,s;
|
|
365
|
+
|
|
366
|
+
b = Ttk_PadBox(b,Ttk_UniformPadding(2));
|
|
367
|
+
p = b.x, q = b.y, r = b.x+b.width, s = b.y+b.height;
|
|
368
|
+
|
|
369
|
+
r+=w, s+=w;
|
|
370
|
+
XDrawLine(display, d, gcf, p, q, r, s);
|
|
371
|
+
XDrawLine(display, d, gcf, p+1, q, r, s-1);
|
|
372
|
+
XDrawLine(display, d, gcf, p, q+1, r-1, s);
|
|
373
|
+
|
|
374
|
+
s-=w, q-=w;
|
|
375
|
+
XDrawLine(display, d, gcf, p, s, r, q);
|
|
376
|
+
XDrawLine(display, d, gcf, p+1, s, r, q+1);
|
|
377
|
+
XDrawLine(display, d, gcf, p, s-1, r-1, q);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
static Ttk_ElementSpec RadioIndicatorElementSpec = {
|
|
382
|
+
TK_STYLE_VERSION_2,
|
|
383
|
+
sizeof(IndicatorElement),
|
|
384
|
+
IndicatorElementOptions,
|
|
385
|
+
IndicatorElementSize,
|
|
386
|
+
RadioIndicatorElementDraw
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
static Ttk_ElementSpec CheckIndicatorElementSpec = {
|
|
390
|
+
TK_STYLE_VERSION_2,
|
|
391
|
+
sizeof(IndicatorElement),
|
|
392
|
+
IndicatorElementOptions,
|
|
393
|
+
IndicatorElementSize,
|
|
394
|
+
CheckIndicatorElementDraw
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
#define MENUBUTTON_ARROW_SIZE 5
|
|
398
|
+
|
|
399
|
+
typedef struct {
|
|
400
|
+
Tcl_Obj *sizeObj;
|
|
401
|
+
Tcl_Obj *colorObj;
|
|
402
|
+
Tcl_Obj *paddingObj;
|
|
403
|
+
} MenuIndicatorElement;
|
|
404
|
+
|
|
405
|
+
static Ttk_ElementOptionSpec MenuIndicatorElementOptions[] =
|
|
406
|
+
{
|
|
407
|
+
{ "-arrowsize", TK_OPTION_PIXELS,
|
|
408
|
+
Tk_Offset(MenuIndicatorElement,sizeObj),
|
|
409
|
+
STR(MENUBUTTON_ARROW_SIZE)},
|
|
410
|
+
{ "-arrowcolor",TK_OPTION_COLOR,
|
|
411
|
+
Tk_Offset(MenuIndicatorElement,colorObj),
|
|
412
|
+
"black" },
|
|
413
|
+
{ "-arrowpadding",TK_OPTION_STRING,
|
|
414
|
+
Tk_Offset(MenuIndicatorElement,paddingObj),
|
|
415
|
+
"3" },
|
|
416
|
+
{ NULL }
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
static void MenuIndicatorElementSize(
|
|
420
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
421
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
422
|
+
{
|
|
423
|
+
MenuIndicatorElement *indicator = elementRecord;
|
|
424
|
+
Ttk_Padding margins;
|
|
425
|
+
int size = MENUBUTTON_ARROW_SIZE;
|
|
426
|
+
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
|
|
427
|
+
Ttk_GetPaddingFromObj(NULL, tkwin, indicator->paddingObj, &margins);
|
|
428
|
+
TtkArrowSize(size, ARROW_DOWN, widthPtr, heightPtr);
|
|
429
|
+
*widthPtr += Ttk_PaddingWidth(margins);
|
|
430
|
+
*heightPtr += Ttk_PaddingHeight(margins);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
static void MenuIndicatorElementDraw(
|
|
434
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
435
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
|
436
|
+
{
|
|
437
|
+
MenuIndicatorElement *indicator = elementRecord;
|
|
438
|
+
XColor *arrowColor = Tk_GetColorFromObj(tkwin, indicator->colorObj);
|
|
439
|
+
GC gc = Tk_GCForColor(arrowColor, d);
|
|
440
|
+
int size = MENUBUTTON_ARROW_SIZE;
|
|
441
|
+
int width, height;
|
|
442
|
+
|
|
443
|
+
Tk_GetPixelsFromObj(NULL, tkwin, indicator->sizeObj, &size);
|
|
444
|
+
|
|
445
|
+
TtkArrowSize(size, ARROW_DOWN, &width, &height);
|
|
446
|
+
b = Ttk_StickBox(b, width, height, 0);
|
|
447
|
+
TtkFillArrow(Tk_Display(tkwin), d, gc, b, ARROW_DOWN);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
static Ttk_ElementSpec MenuIndicatorElementSpec =
|
|
451
|
+
{
|
|
452
|
+
TK_STYLE_VERSION_2,
|
|
453
|
+
sizeof(MenuIndicatorElement),
|
|
454
|
+
MenuIndicatorElementOptions,
|
|
455
|
+
MenuIndicatorElementSize,
|
|
456
|
+
MenuIndicatorElementDraw
|
|
457
|
+
};
|
|
458
|
+
|
|
459
|
+
/*------------------------------------------------------------------------
|
|
460
|
+
* +++ Grips.
|
|
461
|
+
*
|
|
462
|
+
* TODO: factor this with ThumbElementDraw
|
|
463
|
+
*/
|
|
464
|
+
|
|
465
|
+
static Ttk_Orient GripClientData[] = {
|
|
466
|
+
TTK_ORIENT_HORIZONTAL, TTK_ORIENT_VERTICAL
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
typedef struct {
|
|
470
|
+
Tcl_Obj *lightColorObj;
|
|
471
|
+
Tcl_Obj *borderColorObj;
|
|
472
|
+
Tcl_Obj *gripCountObj;
|
|
473
|
+
} GripElement;
|
|
474
|
+
|
|
475
|
+
static Ttk_ElementOptionSpec GripElementOptions[] = {
|
|
476
|
+
{ "-lightcolor", TK_OPTION_COLOR,
|
|
477
|
+
Tk_Offset(GripElement,lightColorObj), LIGHT_COLOR },
|
|
478
|
+
{ "-bordercolor", TK_OPTION_COLOR,
|
|
479
|
+
Tk_Offset(GripElement,borderColorObj), DARKEST_COLOR },
|
|
480
|
+
{ "-gripcount", TK_OPTION_INT,
|
|
481
|
+
Tk_Offset(GripElement,gripCountObj), "5" },
|
|
482
|
+
{0,0,0}
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
static void GripElementSize(
|
|
486
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
487
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
488
|
+
{
|
|
489
|
+
int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
|
|
490
|
+
GripElement *grip = elementRecord;
|
|
491
|
+
int gripCount;
|
|
492
|
+
|
|
493
|
+
Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
|
|
494
|
+
if (horizontal) {
|
|
495
|
+
*widthPtr = 2*gripCount;
|
|
496
|
+
} else {
|
|
497
|
+
*heightPtr = 2*gripCount;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
static void GripElementDraw(
|
|
502
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
503
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
504
|
+
{
|
|
505
|
+
const int w = WIN32_XDRAWLINE_HACK;
|
|
506
|
+
int horizontal = *((Ttk_Orient*)clientData) == TTK_ORIENT_HORIZONTAL;
|
|
507
|
+
GripElement *grip = elementRecord;
|
|
508
|
+
GC lightGC = Ttk_GCForColor(tkwin,grip->lightColorObj,d);
|
|
509
|
+
GC darkGC = Ttk_GCForColor(tkwin,grip->borderColorObj,d);
|
|
510
|
+
int gripPad = 1;
|
|
511
|
+
int i, gripCount;
|
|
512
|
+
|
|
513
|
+
Tcl_GetIntFromObj(NULL, grip->gripCountObj, &gripCount);
|
|
514
|
+
|
|
515
|
+
if (horizontal) {
|
|
516
|
+
int x = b.x + b.width / 2 - gripCount;
|
|
517
|
+
int y1 = b.y + gripPad, y2 = b.y + b.height - gripPad - 1 + w;
|
|
518
|
+
for (i=0; i<gripCount; ++i) {
|
|
519
|
+
XDrawLine(Tk_Display(tkwin), d, darkGC, x,y1, x,y2); ++x;
|
|
520
|
+
XDrawLine(Tk_Display(tkwin), d, lightGC, x,y1, x,y2); ++x;
|
|
521
|
+
}
|
|
522
|
+
} else {
|
|
523
|
+
int y = b.y + b.height / 2 - gripCount;
|
|
524
|
+
int x1 = b.x + gripPad, x2 = b.x + b.width - gripPad - 1 + w;
|
|
525
|
+
for (i=0; i<gripCount; ++i) {
|
|
526
|
+
XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y, x2,y); ++y;
|
|
527
|
+
XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y, x2,y); ++y;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
static Ttk_ElementSpec GripElementSpec = {
|
|
533
|
+
TK_STYLE_VERSION_2,
|
|
534
|
+
sizeof(GripElement),
|
|
535
|
+
GripElementOptions,
|
|
536
|
+
GripElementSize,
|
|
537
|
+
GripElementDraw
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
/*------------------------------------------------------------------------
|
|
541
|
+
* +++ Scrollbar elements: trough, arrows, thumb.
|
|
542
|
+
*
|
|
543
|
+
* Notice that the trough element has 0 internal padding;
|
|
544
|
+
* that way the thumb and arrow borders overlap the trough.
|
|
545
|
+
*/
|
|
546
|
+
|
|
547
|
+
typedef struct { /* Common element record for scrollbar elements */
|
|
548
|
+
Tcl_Obj *orientObj;
|
|
549
|
+
Tcl_Obj *backgroundObj;
|
|
550
|
+
Tcl_Obj *borderColorObj;
|
|
551
|
+
Tcl_Obj *troughColorObj;
|
|
552
|
+
Tcl_Obj *lightColorObj;
|
|
553
|
+
Tcl_Obj *darkColorObj;
|
|
554
|
+
Tcl_Obj *arrowColorObj;
|
|
555
|
+
Tcl_Obj *arrowSizeObj;
|
|
556
|
+
Tcl_Obj *gripCountObj;
|
|
557
|
+
Tcl_Obj *sliderlengthObj;
|
|
558
|
+
} ScrollbarElement;
|
|
559
|
+
|
|
560
|
+
static Ttk_ElementOptionSpec ScrollbarElementOptions[] = {
|
|
561
|
+
{ "-orient", TK_OPTION_ANY,
|
|
562
|
+
Tk_Offset(ScrollbarElement, orientObj), "horizontal" },
|
|
563
|
+
{ "-background", TK_OPTION_BORDER,
|
|
564
|
+
Tk_Offset(ScrollbarElement,backgroundObj), FRAME_COLOR },
|
|
565
|
+
{ "-bordercolor", TK_OPTION_COLOR,
|
|
566
|
+
Tk_Offset(ScrollbarElement,borderColorObj), DARKEST_COLOR },
|
|
567
|
+
{ "-troughcolor", TK_OPTION_COLOR,
|
|
568
|
+
Tk_Offset(ScrollbarElement,troughColorObj), DARKER_COLOR },
|
|
569
|
+
{ "-lightcolor", TK_OPTION_COLOR,
|
|
570
|
+
Tk_Offset(ScrollbarElement,lightColorObj), LIGHT_COLOR },
|
|
571
|
+
{ "-darkcolor", TK_OPTION_COLOR,
|
|
572
|
+
Tk_Offset(ScrollbarElement,darkColorObj), DARK_COLOR },
|
|
573
|
+
{ "-arrowcolor", TK_OPTION_COLOR,
|
|
574
|
+
Tk_Offset(ScrollbarElement,arrowColorObj), "#000000" },
|
|
575
|
+
{ "-arrowsize", TK_OPTION_PIXELS,
|
|
576
|
+
Tk_Offset(ScrollbarElement,arrowSizeObj), STR(SCROLLBAR_THICKNESS) },
|
|
577
|
+
{ "-gripcount", TK_OPTION_INT,
|
|
578
|
+
Tk_Offset(ScrollbarElement,gripCountObj), "5" },
|
|
579
|
+
{ "-sliderlength", TK_OPTION_INT,
|
|
580
|
+
Tk_Offset(ScrollbarElement,sliderlengthObj), "30" },
|
|
581
|
+
{0,0,0}
|
|
582
|
+
};
|
|
583
|
+
|
|
584
|
+
static void TroughElementDraw(
|
|
585
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
586
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
587
|
+
{
|
|
588
|
+
ScrollbarElement *sb = elementRecord;
|
|
589
|
+
GC gcb = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
|
|
590
|
+
GC gct = Ttk_GCForColor(tkwin,sb->troughColorObj,d);
|
|
591
|
+
XFillRectangle(Tk_Display(tkwin), d, gct, b.x, b.y, b.width-1, b.height-1);
|
|
592
|
+
XDrawRectangle(Tk_Display(tkwin), d, gcb, b.x, b.y, b.width-1, b.height-1);
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
static Ttk_ElementSpec TroughElementSpec = {
|
|
596
|
+
TK_STYLE_VERSION_2,
|
|
597
|
+
sizeof(ScrollbarElement),
|
|
598
|
+
ScrollbarElementOptions,
|
|
599
|
+
TtkNullElementSize,
|
|
600
|
+
TroughElementDraw
|
|
601
|
+
};
|
|
602
|
+
|
|
603
|
+
static void ThumbElementSize(
|
|
604
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
605
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
606
|
+
{
|
|
607
|
+
ScrollbarElement *sb = elementRecord;
|
|
608
|
+
int size = SCROLLBAR_THICKNESS;
|
|
609
|
+
Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size);
|
|
610
|
+
*widthPtr = *heightPtr = size;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
static void ThumbElementDraw(
|
|
614
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
615
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
616
|
+
{
|
|
617
|
+
ScrollbarElement *sb = elementRecord;
|
|
618
|
+
int gripCount = 3, orient = TTK_ORIENT_HORIZONTAL;
|
|
619
|
+
GC lightGC, darkGC;
|
|
620
|
+
int x1, y1, x2, y2, dx, dy, i;
|
|
621
|
+
const int w = WIN32_XDRAWLINE_HACK;
|
|
622
|
+
|
|
623
|
+
DrawSmoothBorder(tkwin, d, b,
|
|
624
|
+
sb->borderColorObj, sb->lightColorObj, sb->darkColorObj);
|
|
625
|
+
XFillRectangle(
|
|
626
|
+
Tk_Display(tkwin), d, BackgroundGC(tkwin, sb->backgroundObj),
|
|
627
|
+
b.x+2, b.y+2, b.width-4, b.height-4);
|
|
628
|
+
|
|
629
|
+
/*
|
|
630
|
+
* Draw grip:
|
|
631
|
+
*/
|
|
632
|
+
Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
|
|
633
|
+
Tcl_GetIntFromObj(NULL, sb->gripCountObj, &gripCount);
|
|
634
|
+
lightGC = Ttk_GCForColor(tkwin,sb->lightColorObj,d);
|
|
635
|
+
darkGC = Ttk_GCForColor(tkwin,sb->borderColorObj,d);
|
|
636
|
+
|
|
637
|
+
if (orient == TTK_ORIENT_HORIZONTAL) {
|
|
638
|
+
dx = 1; dy = 0;
|
|
639
|
+
x1 = x2 = b.x + b.width / 2 - gripCount;
|
|
640
|
+
y1 = b.y + 2;
|
|
641
|
+
y2 = b.y + b.height - 3 + w;
|
|
642
|
+
} else {
|
|
643
|
+
dx = 0; dy = 1;
|
|
644
|
+
y1 = y2 = b.y + b.height / 2 - gripCount;
|
|
645
|
+
x1 = b.x + 2;
|
|
646
|
+
x2 = b.x + b.width - 3 + w;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
for (i=0; i<gripCount; ++i) {
|
|
650
|
+
XDrawLine(Tk_Display(tkwin), d, darkGC, x1,y1, x2,y2);
|
|
651
|
+
x1 += dx; x2 += dx; y1 += dy; y2 += dy;
|
|
652
|
+
XDrawLine(Tk_Display(tkwin), d, lightGC, x1,y1, x2,y2);
|
|
653
|
+
x1 += dx; x2 += dx; y1 += dy; y2 += dy;
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
static Ttk_ElementSpec ThumbElementSpec = {
|
|
658
|
+
TK_STYLE_VERSION_2,
|
|
659
|
+
sizeof(ScrollbarElement),
|
|
660
|
+
ScrollbarElementOptions,
|
|
661
|
+
ThumbElementSize,
|
|
662
|
+
ThumbElementDraw
|
|
663
|
+
};
|
|
664
|
+
|
|
665
|
+
/*------------------------------------------------------------------------
|
|
666
|
+
* +++ Slider element.
|
|
667
|
+
*/
|
|
668
|
+
static void SliderElementSize(
|
|
669
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
670
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
671
|
+
{
|
|
672
|
+
ScrollbarElement *sb = elementRecord;
|
|
673
|
+
int length, thickness, orient;
|
|
674
|
+
|
|
675
|
+
length = thickness = SCROLLBAR_THICKNESS;
|
|
676
|
+
Ttk_GetOrientFromObj(NULL, sb->orientObj, &orient);
|
|
677
|
+
Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &thickness);
|
|
678
|
+
Tk_GetPixelsFromObj(NULL, tkwin, sb->sliderlengthObj, &length);
|
|
679
|
+
if (orient == TTK_ORIENT_VERTICAL) {
|
|
680
|
+
*heightPtr = length;
|
|
681
|
+
*widthPtr = thickness;
|
|
682
|
+
} else {
|
|
683
|
+
*heightPtr = thickness;
|
|
684
|
+
*widthPtr = length;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
static Ttk_ElementSpec SliderElementSpec = {
|
|
690
|
+
TK_STYLE_VERSION_2,
|
|
691
|
+
sizeof(ScrollbarElement),
|
|
692
|
+
ScrollbarElementOptions,
|
|
693
|
+
SliderElementSize,
|
|
694
|
+
ThumbElementDraw
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
/*------------------------------------------------------------------------
|
|
698
|
+
* +++ Progress bar element
|
|
699
|
+
*/
|
|
700
|
+
static void PbarElementSize(
|
|
701
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
702
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
703
|
+
{
|
|
704
|
+
SliderElementSize(clientData, elementRecord, tkwin,
|
|
705
|
+
widthPtr, heightPtr, paddingPtr);
|
|
706
|
+
*paddingPtr = Ttk_UniformPadding(2);
|
|
707
|
+
*widthPtr += 4;
|
|
708
|
+
*heightPtr += 4;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
static void PbarElementDraw(
|
|
712
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
713
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
714
|
+
{
|
|
715
|
+
ScrollbarElement *sb = elementRecord;
|
|
716
|
+
|
|
717
|
+
b = Ttk_PadBox(b, Ttk_UniformPadding(2));
|
|
718
|
+
if (b.width > 4 && b.height > 4) {
|
|
719
|
+
DrawSmoothBorder(tkwin, d, b,
|
|
720
|
+
sb->borderColorObj, sb->lightColorObj, sb->darkColorObj);
|
|
721
|
+
XFillRectangle(Tk_Display(tkwin), d,
|
|
722
|
+
BackgroundGC(tkwin, sb->backgroundObj),
|
|
723
|
+
b.x+2, b.y+2, b.width-4, b.height-4);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
static Ttk_ElementSpec PbarElementSpec = {
|
|
728
|
+
TK_STYLE_VERSION_2,
|
|
729
|
+
sizeof(ScrollbarElement),
|
|
730
|
+
ScrollbarElementOptions,
|
|
731
|
+
PbarElementSize,
|
|
732
|
+
PbarElementDraw
|
|
733
|
+
};
|
|
734
|
+
|
|
735
|
+
|
|
736
|
+
/*------------------------------------------------------------------------
|
|
737
|
+
* +++ Scrollbar arrows.
|
|
738
|
+
*/
|
|
739
|
+
static int ArrowElements[] = { ARROW_UP, ARROW_DOWN, ARROW_LEFT, ARROW_RIGHT };
|
|
740
|
+
|
|
741
|
+
static void ArrowElementSize(
|
|
742
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
743
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
744
|
+
{
|
|
745
|
+
ScrollbarElement *sb = elementRecord;
|
|
746
|
+
int size = SCROLLBAR_THICKNESS;
|
|
747
|
+
Tcl_GetIntFromObj(NULL, sb->arrowSizeObj, &size);
|
|
748
|
+
*widthPtr = *heightPtr = size;
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
static void ArrowElementDraw(
|
|
752
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
753
|
+
Drawable d, Ttk_Box b, unsigned state)
|
|
754
|
+
{
|
|
755
|
+
ArrowDirection dir = *(ArrowDirection*)clientData;
|
|
756
|
+
ScrollbarElement *sb = elementRecord;
|
|
757
|
+
GC gc = Ttk_GCForColor(tkwin,sb->arrowColorObj, d);
|
|
758
|
+
int h, cx, cy;
|
|
759
|
+
|
|
760
|
+
DrawSmoothBorder(tkwin, d, b,
|
|
761
|
+
sb->borderColorObj, sb->lightColorObj, sb->darkColorObj);
|
|
762
|
+
|
|
763
|
+
XFillRectangle(
|
|
764
|
+
Tk_Display(tkwin), d, BackgroundGC(tkwin, sb->backgroundObj),
|
|
765
|
+
b.x+2, b.y+2, b.width-4, b.height-4);
|
|
766
|
+
|
|
767
|
+
b = Ttk_PadBox(b, Ttk_UniformPadding(3));
|
|
768
|
+
h = b.width < b.height ? b.width : b.height;
|
|
769
|
+
TtkArrowSize(h/2, dir, &cx, &cy);
|
|
770
|
+
b = Ttk_AnchorBox(b, cx, cy, TK_ANCHOR_CENTER);
|
|
771
|
+
|
|
772
|
+
TtkFillArrow(Tk_Display(tkwin), d, gc, b, dir);
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
static Ttk_ElementSpec ArrowElementSpec = {
|
|
776
|
+
TK_STYLE_VERSION_2,
|
|
777
|
+
sizeof(ScrollbarElement),
|
|
778
|
+
ScrollbarElementOptions,
|
|
779
|
+
ArrowElementSize,
|
|
780
|
+
ArrowElementDraw
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
|
|
784
|
+
/*------------------------------------------------------------------------
|
|
785
|
+
* +++ Notebook elements.
|
|
786
|
+
*
|
|
787
|
+
* Note: Tabs, except for the rightmost, overlap the neighbor to
|
|
788
|
+
* their right by one pixel.
|
|
789
|
+
*/
|
|
790
|
+
|
|
791
|
+
typedef struct {
|
|
792
|
+
Tcl_Obj *backgroundObj;
|
|
793
|
+
Tcl_Obj *borderColorObj;
|
|
794
|
+
Tcl_Obj *lightColorObj;
|
|
795
|
+
Tcl_Obj *darkColorObj;
|
|
796
|
+
} NotebookElement;
|
|
797
|
+
|
|
798
|
+
static Ttk_ElementOptionSpec NotebookElementOptions[] = {
|
|
799
|
+
{ "-background", TK_OPTION_BORDER,
|
|
800
|
+
Tk_Offset(NotebookElement,backgroundObj), FRAME_COLOR },
|
|
801
|
+
{ "-bordercolor", TK_OPTION_COLOR,
|
|
802
|
+
Tk_Offset(NotebookElement,borderColorObj), DARKEST_COLOR },
|
|
803
|
+
{ "-lightcolor", TK_OPTION_COLOR,
|
|
804
|
+
Tk_Offset(NotebookElement,lightColorObj), LIGHT_COLOR },
|
|
805
|
+
{ "-darkcolor", TK_OPTION_COLOR,
|
|
806
|
+
Tk_Offset(NotebookElement,darkColorObj), DARK_COLOR },
|
|
807
|
+
{0,0,0}
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
static void TabElementSize(
|
|
811
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
812
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
813
|
+
{
|
|
814
|
+
int borderWidth = 2;
|
|
815
|
+
paddingPtr->top = paddingPtr->left = paddingPtr->right = borderWidth;
|
|
816
|
+
paddingPtr->bottom = 0;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
static void TabElementDraw(
|
|
820
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
821
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
|
822
|
+
{
|
|
823
|
+
NotebookElement *tab = elementRecord;
|
|
824
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, tab->backgroundObj);
|
|
825
|
+
Display *display = Tk_Display(tkwin);
|
|
826
|
+
int borderWidth = 2, dh = 0;
|
|
827
|
+
int x1,y1,x2,y2;
|
|
828
|
+
GC gc;
|
|
829
|
+
const int w = WIN32_XDRAWLINE_HACK;
|
|
830
|
+
|
|
831
|
+
if (state & TTK_STATE_SELECTED) {
|
|
832
|
+
dh = borderWidth;
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
if (state & TTK_STATE_USER2) { /* Rightmost tab */
|
|
836
|
+
--b.width;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
Tk_Fill3DRectangle(tkwin, d, border,
|
|
840
|
+
b.x+2, b.y+2, b.width-1, b.height-2+dh, borderWidth, TK_RELIEF_FLAT);
|
|
841
|
+
|
|
842
|
+
x1 = b.x, x2 = b.x + b.width;
|
|
843
|
+
y1 = b.y, y2 = b.y + b.height;
|
|
844
|
+
|
|
845
|
+
|
|
846
|
+
gc=Ttk_GCForColor(tkwin,tab->borderColorObj,d);
|
|
847
|
+
XDrawLine(display,d,gc, x1,y1+1, x1,y2+w);
|
|
848
|
+
XDrawLine(display,d,gc, x2,y1+1, x2,y2+w);
|
|
849
|
+
XDrawLine(display,d,gc, x1+1,y1, x2-1+w,y1);
|
|
850
|
+
|
|
851
|
+
gc=Ttk_GCForColor(tkwin,tab->lightColorObj,d);
|
|
852
|
+
XDrawLine(display,d,gc, x1+1,y1+1, x1+1,y2-1+dh+w);
|
|
853
|
+
XDrawLine(display,d,gc, x1+1,y1+1, x2-1+w,y1+1);
|
|
854
|
+
}
|
|
855
|
+
|
|
856
|
+
static Ttk_ElementSpec TabElementSpec =
|
|
857
|
+
{
|
|
858
|
+
TK_STYLE_VERSION_2,
|
|
859
|
+
sizeof(NotebookElement),
|
|
860
|
+
NotebookElementOptions,
|
|
861
|
+
TabElementSize,
|
|
862
|
+
TabElementDraw
|
|
863
|
+
};
|
|
864
|
+
|
|
865
|
+
static void ClientElementSize(
|
|
866
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
867
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
868
|
+
{
|
|
869
|
+
int borderWidth = 2;
|
|
870
|
+
*paddingPtr = Ttk_UniformPadding((short)borderWidth);
|
|
871
|
+
}
|
|
872
|
+
|
|
873
|
+
static void ClientElementDraw(
|
|
874
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
875
|
+
Drawable d, Ttk_Box b, unsigned int state)
|
|
876
|
+
{
|
|
877
|
+
NotebookElement *ce = elementRecord;
|
|
878
|
+
Tk_3DBorder border = Tk_Get3DBorderFromObj(tkwin, ce->backgroundObj);
|
|
879
|
+
int borderWidth = 2;
|
|
880
|
+
|
|
881
|
+
Tk_Fill3DRectangle(tkwin, d, border,
|
|
882
|
+
b.x, b.y, b.width, b.height, borderWidth,TK_RELIEF_FLAT);
|
|
883
|
+
DrawSmoothBorder(tkwin, d, b,
|
|
884
|
+
ce->borderColorObj, ce->lightColorObj, ce->darkColorObj);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
static Ttk_ElementSpec ClientElementSpec =
|
|
888
|
+
{
|
|
889
|
+
TK_STYLE_VERSION_2,
|
|
890
|
+
sizeof(NotebookElement),
|
|
891
|
+
NotebookElementOptions,
|
|
892
|
+
ClientElementSize,
|
|
893
|
+
ClientElementDraw
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
/*------------------------------------------------------------------------
|
|
897
|
+
* +++ Modified widget layouts.
|
|
898
|
+
*/
|
|
899
|
+
|
|
900
|
+
TTK_BEGIN_LAYOUT_TABLE(LayoutTable)
|
|
901
|
+
|
|
902
|
+
TTK_LAYOUT("TCombobox",
|
|
903
|
+
TTK_NODE("Combobox.downarrow", TTK_PACK_RIGHT|TTK_FILL_Y)
|
|
904
|
+
TTK_GROUP("Combobox.field", TTK_PACK_LEFT|TTK_FILL_BOTH|TTK_EXPAND,
|
|
905
|
+
TTK_GROUP("Combobox.padding", TTK_FILL_BOTH,
|
|
906
|
+
TTK_NODE("Combobox.textarea", TTK_FILL_BOTH))))
|
|
907
|
+
|
|
908
|
+
TTK_LAYOUT("Horizontal.Sash",
|
|
909
|
+
TTK_GROUP("Sash.hsash", TTK_FILL_BOTH,
|
|
910
|
+
TTK_NODE("Sash.hgrip", TTK_FILL_BOTH)))
|
|
911
|
+
|
|
912
|
+
TTK_LAYOUT("Vertical.Sash",
|
|
913
|
+
TTK_GROUP("Sash.vsash", TTK_FILL_BOTH,
|
|
914
|
+
TTK_NODE("Sash.vgrip", TTK_FILL_BOTH)))
|
|
915
|
+
|
|
916
|
+
TTK_END_LAYOUT_TABLE
|
|
917
|
+
|
|
918
|
+
/*------------------------------------------------------------------------
|
|
919
|
+
* +++ Initialization.
|
|
920
|
+
*/
|
|
921
|
+
|
|
922
|
+
int DLLEXPORT
|
|
923
|
+
TtkClamTheme_Init(Tcl_Interp *interp)
|
|
924
|
+
{
|
|
925
|
+
Ttk_Theme theme = Ttk_CreateTheme(interp, "clam", 0);
|
|
926
|
+
|
|
927
|
+
if (!theme) {
|
|
928
|
+
return TCL_ERROR;
|
|
929
|
+
}
|
|
930
|
+
|
|
931
|
+
Ttk_RegisterElement(interp,
|
|
932
|
+
theme, "border", &BorderElementSpec, NULL);
|
|
933
|
+
Ttk_RegisterElement(interp,
|
|
934
|
+
theme, "field", &FieldElementSpec, NULL);
|
|
935
|
+
Ttk_RegisterElement(interp,
|
|
936
|
+
theme, "Combobox.field", &ComboboxFieldElementSpec, NULL);
|
|
937
|
+
Ttk_RegisterElement(interp,
|
|
938
|
+
theme, "trough", &TroughElementSpec, NULL);
|
|
939
|
+
Ttk_RegisterElement(interp,
|
|
940
|
+
theme, "thumb", &ThumbElementSpec, NULL);
|
|
941
|
+
Ttk_RegisterElement(interp,
|
|
942
|
+
theme, "uparrow", &ArrowElementSpec, &ArrowElements[0]);
|
|
943
|
+
Ttk_RegisterElement(interp,
|
|
944
|
+
theme, "downarrow", &ArrowElementSpec, &ArrowElements[1]);
|
|
945
|
+
Ttk_RegisterElement(interp,
|
|
946
|
+
theme, "leftarrow", &ArrowElementSpec, &ArrowElements[2]);
|
|
947
|
+
Ttk_RegisterElement(interp,
|
|
948
|
+
theme, "rightarrow", &ArrowElementSpec, &ArrowElements[3]);
|
|
949
|
+
|
|
950
|
+
Ttk_RegisterElement(interp,
|
|
951
|
+
theme, "Radiobutton.indicator", &RadioIndicatorElementSpec, NULL);
|
|
952
|
+
Ttk_RegisterElement(interp,
|
|
953
|
+
theme, "Checkbutton.indicator", &CheckIndicatorElementSpec, NULL);
|
|
954
|
+
Ttk_RegisterElement(interp,
|
|
955
|
+
theme, "Menubutton.indicator", &MenuIndicatorElementSpec, NULL);
|
|
956
|
+
|
|
957
|
+
Ttk_RegisterElement(interp, theme, "tab", &TabElementSpec, NULL);
|
|
958
|
+
Ttk_RegisterElement(interp, theme, "client", &ClientElementSpec, NULL);
|
|
959
|
+
|
|
960
|
+
Ttk_RegisterElement(interp, theme, "slider", &SliderElementSpec, NULL);
|
|
961
|
+
Ttk_RegisterElement(interp, theme, "bar", &PbarElementSpec, NULL);
|
|
962
|
+
Ttk_RegisterElement(interp, theme, "pbar", &PbarElementSpec, NULL);
|
|
963
|
+
|
|
964
|
+
Ttk_RegisterElement(interp, theme, "hgrip",
|
|
965
|
+
&GripElementSpec, &GripClientData[0]);
|
|
966
|
+
Ttk_RegisterElement(interp, theme, "vgrip",
|
|
967
|
+
&GripElementSpec, &GripClientData[1]);
|
|
968
|
+
|
|
969
|
+
Ttk_RegisterLayouts(theme, LayoutTable);
|
|
970
|
+
|
|
971
|
+
Tcl_PkgProvide(interp, "ttk::theme::clam", TILE_VERSION);
|
|
972
|
+
|
|
973
|
+
return TCL_OK;
|
|
974
|
+
}
|