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,663 @@
|
|
|
1
|
+
/* label.c,v 1.22 2007/11/19 01:57:21 jenglish Exp
|
|
2
|
+
*
|
|
3
|
+
* text, image, and label elements.
|
|
4
|
+
*
|
|
5
|
+
* The label element combines text and image elements,
|
|
6
|
+
* with layout determined by the "-compound" option.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include <tcl.h>
|
|
11
|
+
#include <tk.h>
|
|
12
|
+
#include "tkTheme.h"
|
|
13
|
+
|
|
14
|
+
/*----------------------------------------------------------------------
|
|
15
|
+
* +++ Text element.
|
|
16
|
+
*
|
|
17
|
+
* This element displays a textual label in the foreground color.
|
|
18
|
+
*
|
|
19
|
+
* Optionally underlines the mnemonic character if the -underline resource
|
|
20
|
+
* is present and >= 0.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
typedef struct {
|
|
24
|
+
/*
|
|
25
|
+
* Element options:
|
|
26
|
+
*/
|
|
27
|
+
Tcl_Obj *textObj;
|
|
28
|
+
Tcl_Obj *fontObj;
|
|
29
|
+
Tcl_Obj *foregroundObj;
|
|
30
|
+
Tcl_Obj *underlineObj;
|
|
31
|
+
Tcl_Obj *widthObj;
|
|
32
|
+
Tcl_Obj *anchorObj;
|
|
33
|
+
Tcl_Obj *justifyObj;
|
|
34
|
+
Tcl_Obj *wrapLengthObj;
|
|
35
|
+
Tcl_Obj *embossedObj;
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Computed resources:
|
|
39
|
+
*/
|
|
40
|
+
Tk_Font tkfont;
|
|
41
|
+
Tk_TextLayout textLayout;
|
|
42
|
+
int width;
|
|
43
|
+
int height;
|
|
44
|
+
int embossed;
|
|
45
|
+
|
|
46
|
+
} TextElement;
|
|
47
|
+
|
|
48
|
+
/* Text element options table.
|
|
49
|
+
* NB: Keep in sync with label element option table.
|
|
50
|
+
*/
|
|
51
|
+
static Ttk_ElementOptionSpec TextElementOptions[] = {
|
|
52
|
+
{ "-text", TK_OPTION_STRING,
|
|
53
|
+
Tk_Offset(TextElement,textObj), "" },
|
|
54
|
+
{ "-font", TK_OPTION_FONT,
|
|
55
|
+
Tk_Offset(TextElement,fontObj), DEFAULT_FONT },
|
|
56
|
+
{ "-foreground", TK_OPTION_COLOR,
|
|
57
|
+
Tk_Offset(TextElement,foregroundObj), "black" },
|
|
58
|
+
{ "-underline", TK_OPTION_INT,
|
|
59
|
+
Tk_Offset(TextElement,underlineObj), "-1"},
|
|
60
|
+
{ "-width", TK_OPTION_INT,
|
|
61
|
+
Tk_Offset(TextElement,widthObj), "-1"},
|
|
62
|
+
{ "-anchor", TK_OPTION_ANCHOR,
|
|
63
|
+
Tk_Offset(TextElement,anchorObj), "w"},
|
|
64
|
+
{ "-justify", TK_OPTION_JUSTIFY,
|
|
65
|
+
Tk_Offset(TextElement,justifyObj), "left" },
|
|
66
|
+
{ "-wraplength", TK_OPTION_PIXELS,
|
|
67
|
+
Tk_Offset(TextElement,wrapLengthObj), "0" },
|
|
68
|
+
{ "-embossed", TK_OPTION_INT,
|
|
69
|
+
Tk_Offset(TextElement,embossedObj), "0"},
|
|
70
|
+
{NULL}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
static int TextSetup(TextElement *text, Tk_Window tkwin)
|
|
74
|
+
{
|
|
75
|
+
const char *string = Tcl_GetString(text->textObj);
|
|
76
|
+
Tk_Justify justify = TK_JUSTIFY_LEFT;
|
|
77
|
+
int wrapLength = 0;
|
|
78
|
+
|
|
79
|
+
text->tkfont = Tk_GetFontFromObj(tkwin, text->fontObj);
|
|
80
|
+
Tk_GetJustifyFromObj(NULL, text->justifyObj, &justify);
|
|
81
|
+
Tk_GetPixelsFromObj(NULL, tkwin, text->wrapLengthObj, &wrapLength);
|
|
82
|
+
Tcl_GetBooleanFromObj(NULL, text->embossedObj, &text->embossed);
|
|
83
|
+
|
|
84
|
+
text->textLayout = Tk_ComputeTextLayout(
|
|
85
|
+
text->tkfont, string, -1/*numChars*/, wrapLength, justify,
|
|
86
|
+
0/*flags*/, &text->width, &text->height);
|
|
87
|
+
|
|
88
|
+
return 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/*
|
|
92
|
+
* TextReqWidth -- compute the requested width of a text element.
|
|
93
|
+
*
|
|
94
|
+
* If -width is positive, use that as the width
|
|
95
|
+
* If -width is negative, use that as the minimum width
|
|
96
|
+
* If not specified or empty, use the natural size of the text
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
static int TextReqWidth(TextElement *text)
|
|
100
|
+
{
|
|
101
|
+
int reqWidth;
|
|
102
|
+
|
|
103
|
+
if ( text->widthObj
|
|
104
|
+
&& Tcl_GetIntFromObj(NULL, text->widthObj, &reqWidth) == TCL_OK)
|
|
105
|
+
{
|
|
106
|
+
int avgWidth = Tk_TextWidth(text->tkfont, "0", 1);
|
|
107
|
+
if (reqWidth <= 0) {
|
|
108
|
+
int specWidth = avgWidth * -reqWidth;
|
|
109
|
+
if (specWidth > text->width)
|
|
110
|
+
return specWidth;
|
|
111
|
+
} else {
|
|
112
|
+
return avgWidth * reqWidth;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return text->width;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
static void TextCleanup(TextElement *text)
|
|
119
|
+
{
|
|
120
|
+
Tk_FreeTextLayout(text->textLayout);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/*
|
|
124
|
+
* TextDraw --
|
|
125
|
+
* Draw a text element.
|
|
126
|
+
* Called by TextElementDraw() and LabelElementDraw().
|
|
127
|
+
*/
|
|
128
|
+
static void TextDraw(TextElement *text, Tk_Window tkwin, Drawable d, Ttk_Box b)
|
|
129
|
+
{
|
|
130
|
+
XColor *color = Tk_GetColorFromObj(tkwin, text->foregroundObj);
|
|
131
|
+
int underline = -1;
|
|
132
|
+
int lastChar = -1;
|
|
133
|
+
XGCValues gcValues;
|
|
134
|
+
GC gc1, gc2;
|
|
135
|
+
Tk_Anchor anchor = TK_ANCHOR_CENTER;
|
|
136
|
+
|
|
137
|
+
gcValues.font = Tk_FontId(text->tkfont);
|
|
138
|
+
gcValues.foreground = color->pixel;
|
|
139
|
+
gc1 = Tk_GetGC(tkwin, GCFont | GCForeground, &gcValues);
|
|
140
|
+
gcValues.foreground = WhitePixelOfScreen(Tk_Screen(tkwin));
|
|
141
|
+
gc2 = Tk_GetGC(tkwin, GCFont | GCForeground, &gcValues);
|
|
142
|
+
|
|
143
|
+
/*
|
|
144
|
+
* Place text according to -anchor:
|
|
145
|
+
*/
|
|
146
|
+
Tk_GetAnchorFromObj(NULL, text->anchorObj, &anchor);
|
|
147
|
+
b = Ttk_AnchorBox(b, text->width, text->height, anchor);
|
|
148
|
+
|
|
149
|
+
/*
|
|
150
|
+
* Clip text if it's too wide:
|
|
151
|
+
* @@@ BUG: This will overclip multi-line text.
|
|
152
|
+
*/
|
|
153
|
+
if (b.width < text->width) {
|
|
154
|
+
lastChar = Tk_PointToChar(text->textLayout, b.width, 1) + 1;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (text->embossed) {
|
|
158
|
+
Tk_DrawTextLayout(Tk_Display(tkwin), d, gc2,
|
|
159
|
+
text->textLayout, b.x+1, b.y+1, 0/*firstChar*/, lastChar);
|
|
160
|
+
}
|
|
161
|
+
Tk_DrawTextLayout(Tk_Display(tkwin), d, gc1,
|
|
162
|
+
text->textLayout, b.x, b.y, 0/*firstChar*/, lastChar);
|
|
163
|
+
|
|
164
|
+
Tcl_GetIntFromObj(NULL, text->underlineObj, &underline);
|
|
165
|
+
if (underline >= 0 && (lastChar == -1 || underline <= lastChar)) {
|
|
166
|
+
if (text->embossed) {
|
|
167
|
+
Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc2,
|
|
168
|
+
text->textLayout, b.x+1, b.y+1, underline);
|
|
169
|
+
}
|
|
170
|
+
Tk_UnderlineTextLayout(Tk_Display(tkwin), d, gc1,
|
|
171
|
+
text->textLayout, b.x, b.y, underline);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
Tk_FreeGC(Tk_Display(tkwin), gc1);
|
|
175
|
+
Tk_FreeGC(Tk_Display(tkwin), gc2);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
static void TextElementSize(
|
|
179
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
180
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
181
|
+
{
|
|
182
|
+
TextElement *text = elementRecord;
|
|
183
|
+
|
|
184
|
+
if (!TextSetup(text, tkwin))
|
|
185
|
+
return;
|
|
186
|
+
|
|
187
|
+
*heightPtr = text->height;
|
|
188
|
+
*widthPtr = TextReqWidth(text);
|
|
189
|
+
|
|
190
|
+
TextCleanup(text);
|
|
191
|
+
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
static void TextElementDraw(
|
|
196
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
197
|
+
Drawable d, Ttk_Box b, Ttk_State state)
|
|
198
|
+
{
|
|
199
|
+
TextElement *text = elementRecord;
|
|
200
|
+
if (TextSetup(text, tkwin)) {
|
|
201
|
+
TextDraw(text, tkwin, d, b);
|
|
202
|
+
TextCleanup(text);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
static Ttk_ElementSpec TextElementSpec = {
|
|
207
|
+
TK_STYLE_VERSION_2,
|
|
208
|
+
sizeof(TextElement),
|
|
209
|
+
TextElementOptions,
|
|
210
|
+
TextElementSize,
|
|
211
|
+
TextElementDraw
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/*----------------------------------------------------------------------
|
|
215
|
+
* +++ Image element.
|
|
216
|
+
* Draws an image.
|
|
217
|
+
*/
|
|
218
|
+
|
|
219
|
+
typedef struct {
|
|
220
|
+
Tcl_Obj *imageObj;
|
|
221
|
+
Tcl_Obj *stippleObj; /* For TTK_STATE_DISABLED */
|
|
222
|
+
Tcl_Obj *backgroundObj; /* " " */
|
|
223
|
+
|
|
224
|
+
Ttk_ImageSpec *imageSpec;
|
|
225
|
+
Tk_Image tkimg;
|
|
226
|
+
int width;
|
|
227
|
+
int height;
|
|
228
|
+
} ImageElement;
|
|
229
|
+
|
|
230
|
+
/* ===> NB: Keep in sync with label element option table. <===
|
|
231
|
+
*/
|
|
232
|
+
static Ttk_ElementOptionSpec ImageElementOptions[] = {
|
|
233
|
+
{ "-image", TK_OPTION_STRING,
|
|
234
|
+
Tk_Offset(ImageElement,imageObj), "" },
|
|
235
|
+
{ "-stipple", TK_OPTION_STRING, /* Really: TK_OPTION_BITMAP */
|
|
236
|
+
Tk_Offset(ImageElement,stippleObj), "gray50" },
|
|
237
|
+
{ "-background", TK_OPTION_COLOR,
|
|
238
|
+
Tk_Offset(ImageElement,backgroundObj), DEFAULT_BACKGROUND },
|
|
239
|
+
{NULL}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/*
|
|
243
|
+
* ImageSetup() --
|
|
244
|
+
* Look up the Tk_Image from the image element's imageObj resource.
|
|
245
|
+
* Caller must release the image with ImageCleanup().
|
|
246
|
+
*
|
|
247
|
+
* Returns:
|
|
248
|
+
* 1 if successful, 0 if there was an error (unreported)
|
|
249
|
+
* or the image resource was not specified.
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
static int ImageSetup(
|
|
253
|
+
ImageElement *image, Tk_Window tkwin, Ttk_State state)
|
|
254
|
+
{
|
|
255
|
+
|
|
256
|
+
if (!image->imageObj) {
|
|
257
|
+
return 0;
|
|
258
|
+
}
|
|
259
|
+
image->imageSpec = TtkGetImageSpec(NULL, tkwin, image->imageObj);
|
|
260
|
+
if (!image->imageSpec) {
|
|
261
|
+
return 0;
|
|
262
|
+
}
|
|
263
|
+
image->tkimg = TtkSelectImage(image->imageSpec, state);
|
|
264
|
+
if (!image->tkimg) {
|
|
265
|
+
TtkFreeImageSpec(image->imageSpec);
|
|
266
|
+
return 0;
|
|
267
|
+
}
|
|
268
|
+
Tk_SizeOfImage(image->tkimg, &image->width, &image->height);
|
|
269
|
+
|
|
270
|
+
return 1;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
static void ImageCleanup(ImageElement *image)
|
|
274
|
+
{
|
|
275
|
+
TtkFreeImageSpec(image->imageSpec);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/*
|
|
279
|
+
* StippleOver --
|
|
280
|
+
* Draw a stipple over the image area, to make it look "grayed-out"
|
|
281
|
+
* when TTK_STATE_DISABLED is set.
|
|
282
|
+
*/
|
|
283
|
+
static void StippleOver(
|
|
284
|
+
ImageElement *image, Tk_Window tkwin, Drawable d, int x, int y)
|
|
285
|
+
{
|
|
286
|
+
Pixmap stipple = Tk_AllocBitmapFromObj(NULL, tkwin, image->stippleObj);
|
|
287
|
+
XColor *color = Tk_GetColorFromObj(tkwin, image->backgroundObj);
|
|
288
|
+
|
|
289
|
+
if (stipple != None) {
|
|
290
|
+
unsigned long mask = GCFillStyle | GCStipple | GCForeground;
|
|
291
|
+
XGCValues gcvalues;
|
|
292
|
+
GC gc;
|
|
293
|
+
gcvalues.foreground = color->pixel;
|
|
294
|
+
gcvalues.fill_style = FillStippled;
|
|
295
|
+
gcvalues.stipple = stipple;
|
|
296
|
+
gc = Tk_GetGC(tkwin, mask, &gcvalues);
|
|
297
|
+
XFillRectangle(Tk_Display(tkwin),d,gc,x,y,image->width,image->height);
|
|
298
|
+
Tk_FreeGC(Tk_Display(tkwin), gc);
|
|
299
|
+
Tk_FreeBitmapFromObj(tkwin, image->stippleObj);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
static void ImageDraw(
|
|
304
|
+
ImageElement *image, Tk_Window tkwin,Drawable d,Ttk_Box b,Ttk_State state)
|
|
305
|
+
{
|
|
306
|
+
int width = image->width, height = image->height;
|
|
307
|
+
|
|
308
|
+
/* Clip width and height to remain within window bounds:
|
|
309
|
+
*/
|
|
310
|
+
if (b.x + width > Tk_Width(tkwin)) {
|
|
311
|
+
width = Tk_Width(tkwin) - b.x;
|
|
312
|
+
}
|
|
313
|
+
if (b.y + height > Tk_Height(tkwin)) {
|
|
314
|
+
height = Tk_Height(tkwin) - b.y;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
Tk_RedrawImage(image->tkimg, 0,0, width, height, d, b.x, b.y);
|
|
318
|
+
|
|
319
|
+
/* If we're disabled there's no state-specific 'disabled' image,
|
|
320
|
+
* stipple the image.
|
|
321
|
+
* @@@ Possibly: Don't do disabled-stippling at all;
|
|
322
|
+
* @@@ it's ugly and out of fashion.
|
|
323
|
+
*/
|
|
324
|
+
if (state & TTK_STATE_DISABLED) {
|
|
325
|
+
if (TtkSelectImage(image->imageSpec, 0ul) == image->tkimg) {
|
|
326
|
+
StippleOver(image, tkwin, d, b.x,b.y);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
static void ImageElementSize(
|
|
332
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
333
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
334
|
+
{
|
|
335
|
+
ImageElement *image = elementRecord;
|
|
336
|
+
|
|
337
|
+
if (ImageSetup(image, tkwin, 0)) {
|
|
338
|
+
*widthPtr = image->width;
|
|
339
|
+
*heightPtr = image->height;
|
|
340
|
+
ImageCleanup(image);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
static void ImageElementDraw(
|
|
345
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
346
|
+
Drawable d, Ttk_Box b, Ttk_State state)
|
|
347
|
+
{
|
|
348
|
+
ImageElement *image = elementRecord;
|
|
349
|
+
|
|
350
|
+
if (ImageSetup(image, tkwin, state)) {
|
|
351
|
+
ImageDraw(image, tkwin, d, b, state);
|
|
352
|
+
ImageCleanup(image);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
static Ttk_ElementSpec ImageElementSpec = {
|
|
357
|
+
TK_STYLE_VERSION_2,
|
|
358
|
+
sizeof(ImageElement),
|
|
359
|
+
ImageElementOptions,
|
|
360
|
+
ImageElementSize,
|
|
361
|
+
ImageElementDraw
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
/*------------------------------------------------------------------------
|
|
365
|
+
* +++ Label element.
|
|
366
|
+
*
|
|
367
|
+
* Displays an image and/or text, as determined by the -compound option.
|
|
368
|
+
*
|
|
369
|
+
* Differences from Tk 8.4 compound elements:
|
|
370
|
+
*
|
|
371
|
+
* This adds two new values for the -compound option, "text"
|
|
372
|
+
* and "image". (This is useful for configuring toolbars to
|
|
373
|
+
* display icons, text and icons, or text only, as found in
|
|
374
|
+
* many browsers.)
|
|
375
|
+
*
|
|
376
|
+
* "-compound none" is supported, but I'd like to get rid of it;
|
|
377
|
+
* it makes the logic more complex, and the only benefit is
|
|
378
|
+
* backwards compatibility with Tk < 8.3.0 scripts.
|
|
379
|
+
*
|
|
380
|
+
* This adds a new resource, -space, for determining how much
|
|
381
|
+
* space to leave between the text and image; Tk 8.4 reuses the
|
|
382
|
+
* -padx or -pady option for this purpose.
|
|
383
|
+
*
|
|
384
|
+
* -width always specifies the length in characters of the text part;
|
|
385
|
+
* in Tk 8.4 it's either characters or pixels, depending on the
|
|
386
|
+
* value of -compound.
|
|
387
|
+
*
|
|
388
|
+
* Negative values of -width are interpreted as a minimum width
|
|
389
|
+
* on all platforms, not just on Windows.
|
|
390
|
+
*
|
|
391
|
+
* Tk 8.4 ignores -padx and -pady if -compound is set to "none".
|
|
392
|
+
* Here, padding is handled by a different element.
|
|
393
|
+
*/
|
|
394
|
+
|
|
395
|
+
typedef struct {
|
|
396
|
+
/*
|
|
397
|
+
* Element options:
|
|
398
|
+
*/
|
|
399
|
+
Tcl_Obj *compoundObj;
|
|
400
|
+
Tcl_Obj *spaceObj;
|
|
401
|
+
TextElement text;
|
|
402
|
+
ImageElement image;
|
|
403
|
+
|
|
404
|
+
/*
|
|
405
|
+
* Computed values (see LabelSetup)
|
|
406
|
+
*/
|
|
407
|
+
Ttk_Compound compound;
|
|
408
|
+
int space;
|
|
409
|
+
int totalWidth, totalHeight;
|
|
410
|
+
} LabelElement;
|
|
411
|
+
|
|
412
|
+
static Ttk_ElementOptionSpec LabelElementOptions[] = {
|
|
413
|
+
{ "-compound", TK_OPTION_ANY,
|
|
414
|
+
Tk_Offset(LabelElement,compoundObj), "none" },
|
|
415
|
+
{ "-space", TK_OPTION_PIXELS,
|
|
416
|
+
Tk_Offset(LabelElement,spaceObj), "4" },
|
|
417
|
+
|
|
418
|
+
/* Text element part:
|
|
419
|
+
* NB: Keep in sync with TextElementOptions.
|
|
420
|
+
*/
|
|
421
|
+
{ "-text", TK_OPTION_STRING,
|
|
422
|
+
Tk_Offset(LabelElement,text.textObj), "" },
|
|
423
|
+
{ "-font", TK_OPTION_FONT,
|
|
424
|
+
Tk_Offset(LabelElement,text.fontObj), DEFAULT_FONT },
|
|
425
|
+
{ "-foreground", TK_OPTION_COLOR,
|
|
426
|
+
Tk_Offset(LabelElement,text.foregroundObj), "black" },
|
|
427
|
+
{ "-underline", TK_OPTION_INT,
|
|
428
|
+
Tk_Offset(LabelElement,text.underlineObj), "-1"},
|
|
429
|
+
{ "-width", TK_OPTION_INT,
|
|
430
|
+
Tk_Offset(LabelElement,text.widthObj), ""},
|
|
431
|
+
{ "-anchor", TK_OPTION_ANCHOR,
|
|
432
|
+
Tk_Offset(LabelElement,text.anchorObj), "w"},
|
|
433
|
+
{ "-justify", TK_OPTION_JUSTIFY,
|
|
434
|
+
Tk_Offset(LabelElement,text.justifyObj), "left" },
|
|
435
|
+
{ "-wraplength", TK_OPTION_PIXELS,
|
|
436
|
+
Tk_Offset(LabelElement,text.wrapLengthObj), "0" },
|
|
437
|
+
{ "-embossed", TK_OPTION_INT,
|
|
438
|
+
Tk_Offset(LabelElement,text.embossedObj), "0"},
|
|
439
|
+
|
|
440
|
+
/* Image element part:
|
|
441
|
+
* NB: Keep in sync with ImageElementOptions.
|
|
442
|
+
*/
|
|
443
|
+
{ "-image", TK_OPTION_STRING,
|
|
444
|
+
Tk_Offset(LabelElement,image.imageObj), "" },
|
|
445
|
+
{ "-stipple", TK_OPTION_STRING, /* Really: TK_OPTION_BITMAP */
|
|
446
|
+
Tk_Offset(LabelElement,image.stippleObj), "gray50" },
|
|
447
|
+
{ "-background", TK_OPTION_COLOR,
|
|
448
|
+
Tk_Offset(LabelElement,image.backgroundObj), DEFAULT_BACKGROUND },
|
|
449
|
+
|
|
450
|
+
{NULL}
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
/*
|
|
454
|
+
* LabelSetup --
|
|
455
|
+
* Fills in computed fields of the label element.
|
|
456
|
+
*
|
|
457
|
+
* Calculate the text, image, and total width and height.
|
|
458
|
+
*/
|
|
459
|
+
|
|
460
|
+
#define MAX(a,b) ((a) > (b) ? a : b);
|
|
461
|
+
static void LabelSetup(
|
|
462
|
+
LabelElement *c, Tk_Window tkwin, Ttk_State state)
|
|
463
|
+
{
|
|
464
|
+
Tk_GetPixelsFromObj(NULL,tkwin,c->spaceObj,&c->space);
|
|
465
|
+
Ttk_GetCompoundFromObj(NULL,c->compoundObj,(int*)&c->compound);
|
|
466
|
+
|
|
467
|
+
/*
|
|
468
|
+
* Deal with TTK_COMPOUND_NONE.
|
|
469
|
+
*/
|
|
470
|
+
if (c->compound == TTK_COMPOUND_NONE) {
|
|
471
|
+
if (ImageSetup(&c->image, tkwin, state)) {
|
|
472
|
+
c->compound = TTK_COMPOUND_IMAGE;
|
|
473
|
+
} else {
|
|
474
|
+
c->compound = TTK_COMPOUND_TEXT;
|
|
475
|
+
}
|
|
476
|
+
} else if (c->compound != TTK_COMPOUND_TEXT) {
|
|
477
|
+
if (!ImageSetup(&c->image, tkwin, state)) {
|
|
478
|
+
c->compound = TTK_COMPOUND_TEXT;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (c->compound != TTK_COMPOUND_IMAGE)
|
|
482
|
+
TextSetup(&c->text, tkwin);
|
|
483
|
+
|
|
484
|
+
/*
|
|
485
|
+
* ASSERT:
|
|
486
|
+
* if c->compound != IMAGE, then TextSetup() has been called
|
|
487
|
+
* if c->compound != TEXT, then ImageSetup() has returned successfully
|
|
488
|
+
* c->compound != COMPOUND_NONE.
|
|
489
|
+
*/
|
|
490
|
+
|
|
491
|
+
switch (c->compound)
|
|
492
|
+
{
|
|
493
|
+
case TTK_COMPOUND_NONE:
|
|
494
|
+
/* Can't happen */
|
|
495
|
+
break;
|
|
496
|
+
case TTK_COMPOUND_TEXT:
|
|
497
|
+
c->totalWidth = c->text.width;
|
|
498
|
+
c->totalHeight = c->text.height;
|
|
499
|
+
break;
|
|
500
|
+
case TTK_COMPOUND_IMAGE:
|
|
501
|
+
c->totalWidth = c->image.width;
|
|
502
|
+
c->totalHeight = c->image.height;
|
|
503
|
+
break;
|
|
504
|
+
case TTK_COMPOUND_CENTER:
|
|
505
|
+
c->totalWidth = MAX(c->image.width, c->text.width);
|
|
506
|
+
c->totalHeight = MAX(c->image.height, c->text.height);
|
|
507
|
+
break;
|
|
508
|
+
case TTK_COMPOUND_TOP:
|
|
509
|
+
case TTK_COMPOUND_BOTTOM:
|
|
510
|
+
c->totalWidth = MAX(c->image.width, c->text.width);
|
|
511
|
+
c->totalHeight = c->image.height + c->text.height + c->space;
|
|
512
|
+
break;
|
|
513
|
+
|
|
514
|
+
case TTK_COMPOUND_LEFT:
|
|
515
|
+
case TTK_COMPOUND_RIGHT:
|
|
516
|
+
c->totalWidth = c->image.width + c->text.width + c->space;
|
|
517
|
+
c->totalHeight = MAX(c->image.height, c->text.height);
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
static void LabelCleanup(LabelElement *c)
|
|
523
|
+
{
|
|
524
|
+
if (c->compound != TTK_COMPOUND_TEXT)
|
|
525
|
+
ImageCleanup(&c->image);
|
|
526
|
+
if (c->compound != TTK_COMPOUND_IMAGE)
|
|
527
|
+
TextCleanup(&c->text);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
static void LabelElementSize(
|
|
531
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
532
|
+
int *widthPtr, int *heightPtr, Ttk_Padding *paddingPtr)
|
|
533
|
+
{
|
|
534
|
+
LabelElement *label = elementRecord;
|
|
535
|
+
int textReqWidth = 0;
|
|
536
|
+
|
|
537
|
+
LabelSetup(label, tkwin, 0);
|
|
538
|
+
|
|
539
|
+
*heightPtr = label->totalHeight;
|
|
540
|
+
|
|
541
|
+
/* Requested width based on -width option, not actual text width:
|
|
542
|
+
*/
|
|
543
|
+
if (label->compound != TTK_COMPOUND_IMAGE)
|
|
544
|
+
textReqWidth = TextReqWidth(&label->text);
|
|
545
|
+
|
|
546
|
+
switch (label->compound)
|
|
547
|
+
{
|
|
548
|
+
case TTK_COMPOUND_TEXT:
|
|
549
|
+
*widthPtr = textReqWidth;
|
|
550
|
+
break;
|
|
551
|
+
case TTK_COMPOUND_IMAGE:
|
|
552
|
+
*widthPtr = label->image.width;
|
|
553
|
+
break;
|
|
554
|
+
case TTK_COMPOUND_TOP:
|
|
555
|
+
case TTK_COMPOUND_BOTTOM:
|
|
556
|
+
case TTK_COMPOUND_CENTER:
|
|
557
|
+
*widthPtr = MAX(label->image.width, textReqWidth);
|
|
558
|
+
break;
|
|
559
|
+
case TTK_COMPOUND_LEFT:
|
|
560
|
+
case TTK_COMPOUND_RIGHT:
|
|
561
|
+
*widthPtr = label->image.width + textReqWidth + label->space;
|
|
562
|
+
break;
|
|
563
|
+
case TTK_COMPOUND_NONE:
|
|
564
|
+
break; /* Can't happen */
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
LabelCleanup(label);
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
/*
|
|
571
|
+
* DrawCompound --
|
|
572
|
+
* Helper routine for LabelElementDraw;
|
|
573
|
+
* Handles layout for -compound {left,right,top,bottom}
|
|
574
|
+
*/
|
|
575
|
+
static void DrawCompound(
|
|
576
|
+
LabelElement *l, Ttk_Box b, Tk_Window tkwin, Drawable d, Ttk_State state,
|
|
577
|
+
int imageSide, int textSide)
|
|
578
|
+
{
|
|
579
|
+
Ttk_Box imageBox =
|
|
580
|
+
Ttk_PlaceBox(&b, l->image.width, l->image.height, imageSide, 0);
|
|
581
|
+
Ttk_Box textBox =
|
|
582
|
+
Ttk_PlaceBox(&b, l->text.width, l->text.height, textSide, 0);
|
|
583
|
+
ImageDraw(&l->image,tkwin,d,imageBox,state);
|
|
584
|
+
TextDraw(&l->text,tkwin,d,textBox);
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
static void LabelElementDraw(
|
|
588
|
+
void *clientData, void *elementRecord, Tk_Window tkwin,
|
|
589
|
+
Drawable d, Ttk_Box b, Ttk_State state)
|
|
590
|
+
{
|
|
591
|
+
LabelElement *l = elementRecord;
|
|
592
|
+
Tk_Anchor anchor = TK_ANCHOR_CENTER;
|
|
593
|
+
|
|
594
|
+
LabelSetup(l, tkwin, state);
|
|
595
|
+
|
|
596
|
+
/*
|
|
597
|
+
* Adjust overall parcel based on -anchor:
|
|
598
|
+
*/
|
|
599
|
+
Tk_GetAnchorFromObj(NULL, l->text.anchorObj, &anchor);
|
|
600
|
+
b = Ttk_AnchorBox(b, l->totalWidth, l->totalHeight, anchor);
|
|
601
|
+
|
|
602
|
+
/*
|
|
603
|
+
* Draw text and/or image parts based on -compound:
|
|
604
|
+
*/
|
|
605
|
+
switch (l->compound)
|
|
606
|
+
{
|
|
607
|
+
case TTK_COMPOUND_NONE:
|
|
608
|
+
/* Can't happen */
|
|
609
|
+
break;
|
|
610
|
+
case TTK_COMPOUND_TEXT:
|
|
611
|
+
TextDraw(&l->text,tkwin,d,b);
|
|
612
|
+
break;
|
|
613
|
+
case TTK_COMPOUND_IMAGE:
|
|
614
|
+
ImageDraw(&l->image,tkwin,d,b,state);
|
|
615
|
+
break;
|
|
616
|
+
case TTK_COMPOUND_CENTER:
|
|
617
|
+
{
|
|
618
|
+
Ttk_Box pb = Ttk_AnchorBox(
|
|
619
|
+
b, l->image.width, l->image.height, TK_ANCHOR_CENTER);
|
|
620
|
+
ImageDraw(&l->image, tkwin, d, pb, state);
|
|
621
|
+
pb = Ttk_AnchorBox(
|
|
622
|
+
b, l->text.width, l->text.height, TK_ANCHOR_CENTER);
|
|
623
|
+
TextDraw(&l->text, tkwin, d, pb);
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
case TTK_COMPOUND_TOP:
|
|
627
|
+
DrawCompound(l, b, tkwin, d, state, TTK_SIDE_TOP, TTK_SIDE_BOTTOM);
|
|
628
|
+
break;
|
|
629
|
+
case TTK_COMPOUND_BOTTOM:
|
|
630
|
+
DrawCompound(l, b, tkwin, d, state, TTK_SIDE_BOTTOM, TTK_SIDE_TOP);
|
|
631
|
+
break;
|
|
632
|
+
case TTK_COMPOUND_LEFT:
|
|
633
|
+
DrawCompound(l, b, tkwin, d, state, TTK_SIDE_LEFT, TTK_SIDE_RIGHT);
|
|
634
|
+
break;
|
|
635
|
+
case TTK_COMPOUND_RIGHT:
|
|
636
|
+
DrawCompound(l, b, tkwin, d, state, TTK_SIDE_RIGHT, TTK_SIDE_LEFT);
|
|
637
|
+
break;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
LabelCleanup(l);
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
static Ttk_ElementSpec LabelElementSpec = {
|
|
644
|
+
TK_STYLE_VERSION_2,
|
|
645
|
+
sizeof(LabelElement),
|
|
646
|
+
LabelElementOptions,
|
|
647
|
+
LabelElementSize,
|
|
648
|
+
LabelElementDraw
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
/*------------------------------------------------------------------------
|
|
652
|
+
* +++ Initialization.
|
|
653
|
+
*/
|
|
654
|
+
|
|
655
|
+
void TtkLabel_Init(Tcl_Interp *interp)
|
|
656
|
+
{
|
|
657
|
+
Ttk_Theme theme = Ttk_GetDefaultTheme(interp);
|
|
658
|
+
|
|
659
|
+
Ttk_RegisterElement(interp, theme, "text", &TextElementSpec, NULL);
|
|
660
|
+
Ttk_RegisterElement(interp, theme, "image", &ImageElementSpec, NULL);
|
|
661
|
+
Ttk_RegisterElement(interp, theme, "label", &LabelElementSpec, NULL);
|
|
662
|
+
}
|
|
663
|
+
|