OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I686LINUX / util / I686LINUX / lib / blt2.4 / demos / htext.txt
1
2         This is a (for lack of a better name) hypertext widget.
3
4 This widget combines text and other Tk widgets in the same window.
5 It is sort of a cross between a read-only text widget and the pack command.
6 Any widget can be attached to the hypertext window by the %% 
7 set this $htext(widget)
8 label $this.lab -text "append " -relief sunken \
9         -font *-Courier-Bold-R-Normal-*-12-120-*
10 $this append $this.lab 
11 %% command.
12 For example,
13 %% message $this.msg -relief sunken -bd 2 -aspect 10000 -font \
14  *-Courier-Medium-R-Normal-*-12-* -text {set w $htext(widget)
15 label $w.face -bitmap @bitmaps/face.xbm \ 
16   -relief sunken -borderwidth 2
17 $w append $w.face -padx 2 -pady 0.25i}
18 $this append $this.msg \
19         -fill both %% added this %%
20 global tk_library
21 label $this.face \
22         -bitmap @bitmaps/face.xbm  \
23         -relief sunken -borderwidth 2
24 $this append $this.face -padx 2 -pady 0.25i 
25 %%.
26 There can be many types of widgets in the same document.  For example,
27 this is a simple %% 
28 button $this.but -bg pink -text { button } \
29   -command { puts stderr { a stupid message } } 
30 $this append $this.but 
31 %%. If you click on the button, it prints a stupid message.
32 Any Tk widget can be used, including %%
33 set whichTile 0
34 proc ChangeTile { w } {
35    global whichTile
36
37    if { $whichTile } {
38         $w configure -tile bgTexture2
39    } else {
40         $w configure -tile bgTexture1
41    }
42 }
43 checkbutton $this.ckbut -bg lightblue -text { check buttons } \
44    -variable whichTile -command "ChangeTile $this" 
45 $this append $this.ckbut -justify top
46 %%, %%
47 radiobutton $this.rdbut -bg mediumseagreen -text { radio buttons } \
48         -command { puts stderr { radio button pressed } } 
49 $this append $this.rdbut -justify bottom
50 %%, 
51 and scales %%
52 # -sliderforeground
53 scale $this.sc -showvalue true \
54         -length 100 \
55         -foreground powderblue \
56         -sliderlength 10 \
57         -orient horizontal  
58 $this append $this.sc
59 %%.
60
61         Widget trees can be also be included. The following example is
62 *borrowed* from the widget demo. It is a couple of frames surrounding a
63 listbox, a message, and a button widget.
64 %%
65     set w $this.frame 
66     frame $w 
67     message $w.msg -font *times-medium-r-normal--*-12-120-* -aspect 300 \
68             -text "A listbox containing the 50 states is displayed below, along with a scrollbar.  You can scan the list either using the scrollbar or by dragging in the listbox window with button 3 pressed.  Click the \"OK\" button when you've seen enough." -bg lightsteelblue -relief sunken
69     frame $w.frame -borderwidth 10 
70     pack append $w.frame \
71         [scrollbar $w.frame.scroll -relief sunken \
72             -command "$w.frame.list yview"] {right expand filly frame w} \
73         [listbox $w.frame.list -yscroll "$w.frame.scroll set" -relief sunken] \
74             {left expand filly frame e}
75     $w.frame.list insert 0 Alabama Alaska Arizona Arkansas California \
76         Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \
77         Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \
78         Massachusetts Michigan Minnesota Mississippi Missouri \
79         Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \
80         "New York" "North Carolina" "North Dakota" \
81         Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \
82         "South Carolina" "South Dakota" \
83         Tennessee Texas Utah Vermont Virginia Washington \
84         "West Virginia" Wisconsin Wyoming
85     button $w.ok -text OK -command "puts stderr $w; destroy $w"
86
87     pack append $w $w.msg {top fill} $w.frame {top expand fill} \
88         $w.ok {bottom fill}
89     $w config -bg lightsteelblue -relief sunken
90
91 $this append $w -pady 0.25i
92 %%
93
94 You can add you own home-grown widgets.  Here's the graph widget.
95 Beside it is the "color" demo.  Moving the scales, adjusts the background
96 color of the graph.
97 %%
98 #
99 # Simple script to change colors of a window.
100 #
101 global xlabel ylabel red green blue graph
102 set red 255
103 set green 215
104 set blue 0
105
106 option add *Scale.sliderForeground "#cdb79e"
107 option add *Scale.activeForeground "#ffe4c4"
108 set w $this.colorFrame
109 frame $w
110 scale $w.red -command "color red" -label "Red Intensity" \
111         -from 0 -to 255 -orient horizontal -bg "#ffaeb9" -length 250
112 scale $w.green -command "color green" -label "Green Intensity" \
113         -from 0 -to 255 -orient horizontal -bg "#43cd80"
114 scale $w.blue -command "color blue" -label "Blue Intensity"  \
115         -from 0 -to 255 -orient horizontal -bg "#7ec0ee"
116
117 $w.blue set $blue
118 $w.green set $green
119 $w.red set $red
120
121 pack append $w $w.red {top expand fill}
122 pack append $w $w.green {top expand fill}
123 pack append $w $w.blue {top expand fill}
124
125 proc color {which intensity} {
126     global red green blue graph xlabel ylabel
127     set $which $intensity
128     set rgb [format #%02x%02x%02x $red $green $blue]
129     $graph config -bg $rgb
130     $xlabel config -bg $rgb
131     $ylabel config -bg $rgb
132 }
133
134 $this append $w 
135
136 %% 
137 %%
138 proc makeplot { widget } {
139
140     graph $widget
141     set X { 
142         2.00000e-01 4.00000e-01 6.00000e-01 8.00000e-01 1.00000e+00 
143         1.20000e+00 1.40000e+00 1.60000e+00 1.80000e+00 2.00000e+00 
144         2.20000e+00 2.40000e+00 2.60000e+00 2.80000e+00 3.00000e+00 
145         3.20000e+00 3.40000e+00 3.60000e+00 3.80000e+00 4.00000e+00 
146         4.20000e+00 4.40000e+00 4.60000e+00 4.80000e+00 5.00000e+00 
147     } 
148
149     $widget element create Y1 -x $X -y { 
150         1.14471e+01 2.09373e+01 2.84608e+01 3.40080e+01 3.75691e+01 
151         3.91345e+01 3.92706e+01 3.93474e+01 3.94242e+01 3.95010e+01 
152         3.95778e+01 3.96545e+01 3.97313e+01 3.98081e+01 3.98849e+01 
153         3.99617e+01 4.00384e+01 4.01152e+01 4.01920e+01 4.02688e+01 
154         4.03455e+01 4.04223e+01 4.04990e+01 4.05758e+01 4.06526e+01 
155     } -symbol circle -label VGS=2.0 -color blue4 -fill blue
156
157     $widget element create Y2 -x $X -y { 
158         2.61825e+01 5.04696e+01 7.28517e+01 9.33192e+01 1.11863e+02 
159         1.28473e+02 1.43140e+02 1.55854e+02 1.66606e+02 1.75386e+02 
160         1.82185e+02 1.86994e+02 1.89802e+02 1.90683e+02 1.91047e+02 
161         1.91411e+02 1.91775e+02 1.92139e+02 1.92503e+02 1.92867e+02 
162         1.93231e+02 1.93595e+02 1.93958e+02 1.94322e+02 1.94686e+02 
163     } -symbol diamond -label VGS=3.5 -color green4 -fill green
164
165     $widget element create Y3 -x $X -y { 
166         4.07008e+01 7.95658e+01 1.16585e+02 1.51750e+02 1.85051e+02 
167         2.16479e+02 2.46024e+02 2.73676e+02 2.99427e+02 3.23267e+02 
168         3.45187e+02 3.65177e+02 3.83228e+02 3.99331e+02 4.13476e+02 
169         4.25655e+02 4.35856e+02 4.44073e+02 4.50294e+02 4.54512e+02 
170         4.56716e+02 4.57596e+02 4.58448e+02 4.59299e+02 4.60151e+02 
171    } -symbol triangle -label VGS=5.0 -color red4 -fill red
172
173 }
174
175 option add *graph.title  "Plot Title" 
176 option add *graph.xTitle "X Axis Label"
177 option add *graph.yTitle "Y Axis Label" 
178 #option add *graph.legendMapped false 
179 option add *graph.elemPixels 8
180 option add *graph.relief ridge
181 option add *graph.borderWidth 2
182
183 set graph $this.graph
184 set xlabel $this.xlab
185 set ylabel $this.ylab
186 makeplot $graph
187 $this append $graph -padx 0.25i -pady 0.25i 
188
189 %%
190 If you click on any button in the graph, you will get the coordinate 
191 values at the pointer location.  
192
193 The current coordinate values are %%
194 label $xlabel -text { ??? ??? } -relief sunken
195 label $ylabel -text { ??? ??? } -relief sunken
196 bind $graph <ButtonPress> {labelxy [ %W invtransform %x %y ]}
197
198 proc labelxy { values } {
199     global xlabel ylabel
200     scan $values "%e %e" x y
201     $xlabel config -text $x
202     $ylabel config -text $y
203 }
204 $this append $this.xlab -width 100 -fill x
205 %% and %%
206 $this append $this.ylab -width 100 -fill x
207 %%.
208
209
210 There are four global variables automatically created when a hypertext
211 file is read. They are:
212
213 %% 
214 button $this.l1 -text " \$htext(widget) " \
215         -command "puts $this" -bg orange
216 $this append $this.l1 -width 200 -pady 4
217 %%the pathname of the hypertext widget. 
218 %% 
219 button $this.l2 -text " \$htext(file) " \
220         -command "puts $htext(file)" -bg orange
221 $this append $this.l2 -width 200 -pady 4
222 %%the file being read.
223 %% 
224 button $this.l3 -text " \$htext(line) "  \
225         -command "puts $htext(line)" -bg orange
226 $this append $this.l3 -width 200 -pady 4
227 %%the current line number.
228 %% 
229 button $this.l4 -text " \$htext(index) " \
230         -command "puts $htext(index)" -bg orange
231 $this append $this.l4 -width 200 -pady 4
232 %%the current index in the text.
233
234 Click on any button and the current value is printed on standard output.
235
236 The hypertext widget works with plain text too. If you don't want
237 to read it, click on the %% 
238 button $this.goto -text button -fg purple -bg white \
239         -command "global endOfText; $this gotoline \$endOfText"
240 $this append $this.goto
241 %% to jump to the end of the plain text.
242
243          ------------------------------------------------------
244
245 [This is a pre-release version of BLT.  It's basically the latest
246
247 snapshot of BLT, as it moves towards a full release.  What this means
248 is that the documentation and demos still need work.  Let me know
249 about any configuration/compiler/installation goofs so I make sure
250 they're fixed for the next release.]
251
252 This is version 2.4 of the BLT library.  It's an extension to the
253 Tcl/Tk toolkit.  You simply compile and link with the Tcl/Tk
254 libraries. It does not require the Tcl or Tk source files.
255
256 BLT is available from 
257
258     ftp.tcltk.com 
259
260 in the "pub/blt" directory. The URL is 
261
262     ftp://ftp.tcltk.com/pub/blt/BLT2.4.tar.gz
263
264 This release has been compiled and tested with versions:
265
266         Tcl 7.5 / Tk 4.1
267         Tcl 7.6 / Tk 4.2
268         Tcl/Tk 8.0
269         Tcl/Tk 8.1a2
270
271 What is BLT? 
272
273   BLT is an extension to Tk.  It adds plotting widgets (X-Y graph, 
274   barchart, stripchart), a powerful geometry manager, a new canvas 
275   item, and several new commands to Tk.  
276
277   Plotting widgets:  
278
279     graph, barchart, stripchart
280                 BLT has X-Y graph, barchart, and stripchart widgets that are
281                 both easy to use and customize.  All the widgets work with
282                 BLT vector data objects, which makes it easy to manage data.
283  
284   Hierarchical list box:
285
286     hierbox     Displays a general ordered tree which may be built 
287                 on-the-fly or all at once.
288
289   Tab set:
290
291     tabset      Can be used either as a tab notebook or simple tabset.
292                 Multi-tiered and/or scrolled tabsets are available.
293                 Notebook pages can be torn-off into separate windows and 
294                 later put back. 
295     
296   Geometry Manager:  
297
298     table       A table-based geometry manager. Lets you specify widget
299                 layouts by row and column positions in the table. Unlike the
300                 packer or grid, you can finely control and constrain window
301                 sizes.
302
303   Vector Data Object:
304
305     vector      Lets you manage a vector of floating point values in a
306                 high-level fashion.  Vectors inter-operate seamlessly with 
307                 the plotting widgets. The graphs will automatically redraw 
308                 themselves when the vector data changes. Vector's components 
309                 can be managed through a Tcl array variable, a Tcl command, 
310                 or the using its own C API.
311
312   Background Program Execution:
313
314     bgexec      Like Tcl's "exec ... &", but collects the output, error, and 
315                 status of the detached UNIX subprocesses.  Sets a Tcl variable 
316                 upon completion.  
317
318   Busy Command:
319
320     busy        For preventing user-interactions when the application is
321                 busy.  Manages an invisible "busy" window which prevents
322                 further user interactions (keyboard, mouse, button, etc.).
323                 Also you can provide a busy cursor that temporarily 
324                 overrides those of the Tk widgets.
325
326   New Canvas Item:
327
328     eps         An new item is added to the Tk canvas for handling
329                 encapsulated PostScript.  It lets you embed an EPS file into
330                 the canvas displaying either an EPS preview image found in 
331                 the file, or a Tk image that you provide.  When you print 
332                 the canvas the EPS item will automatically include the EPS 
333                 file, translating and scaling the PostScript.  For example, 
334                 you could use "eps" items to tile several PostScript pages 
335                 into single page.
336
337                 The "eps" item can also be used as a replacement for "image"
338                 canvas items.  Unlike "image" canvas items, the image of an 
339                 eps item can be printed and scaled arbitrarily.
340
341   Drag & Drop Facility:
342
343     drag&drop   Adds drag-n-drop capabilities to Tk.  It uses "send"-style 
344                 communication between drag-drop sources and targets.  The 
345                 result is a much more powerful drag-and-drop mechanism than 
346                 is available with OpenLook or Motif.  
347
348   Bitmap Command:
349
350     bitmap      Lets you read and write bitmaps from Tcl.  You can define
351                 bitmaps from ordinary text strings.  Bitmaps can also be
352                 scaled and rotated.  For example, you can create a button
353                 with rotated text by defining a bitmap from a text string
354                 and rotating it.  You can then use the bitmap in the button
355                 widget.
356
357   Miscellaneous Commands:
358
359     winop       Basic window operations. You can raise, lower, map, or, 
360                 unmap windows.  Other operations let you move the pointer
361                 or take photo image snapshots of Tk widgets.
362
363     bltdebug    Lets you trace the execution of Tcl commands and procedures.
364                 Prints out each Tcl command before it's executed.  
365
366     watch       Lets you specify Tcl procedures to be run before and/or
367                 after every Tcl command.  May be used for logging, tracing, 
368                 profiling, or debugging or Tcl code.
369
370     spline      Computes a spline fitting a set of data points (x and y 
371                 vectors) and produces a vector of the interpolated images 
372                 (y-coordinates) at a given set of x-coordinates.
373
374     htext       A simple hypertext widget. Allows text and Tk widgets to
375                 be combined in a scroll-able text window.  Any Tk widget 
376                 can be embedded and used to form hyper-links.  Other 
377                 options allow for selections and text searches.
378
379 What's new in 2.4?
380
381  1. "eps" canvas item.  
382
383     An encapsulated PostScript canvas item lets you embed an EPS file into 
384     the canvas.  The "eps" item displays either a EPS preview image found 
385     in the file, or a Tk image that you provide.  
386
387  2. "hierbox" widget.
388
389     Hierarchical listbox widget. Displays a general ordered tree which 
390     may be built on-the-fly or all at once.
391
392  3. "tabset" widget.
393
394     Can be used either as a tab notebook or simple tabset.  Tabs can 
395     be arranged in a variety of ways: multi-tiered, scrolled, and 
396     attached to any of the four sides.  Tab labels can contain both 
397     images and text (text can be arbitrarily rotated). Notebook pages 
398     can be torn-off into separate windows and replaced later. 
399     
400  4. Changes to vectors.
401
402     New features:
403         
404      o  Vector expressions.  The vector now has an "expr" operation
405         that lets you perform math (including math library
406         functions) on vectors.  There are several new functions
407         (such as "max", "min", "mean" "median", "q1", "q3", "prod",
408         "sum", "adev", "sdev", "skew", ...)
409
410                 vector expr { sin(x)^2 + cos(x)^2 }
411                 y expr { log(x) * $value }
412
413      o  New syntax to create and destroy vectors:
414
415                 vector create x 
416                 vector destroy x
417  
418         The old syntax for creating vectors still works.
419
420                 vector x
421
422      o  Vectors are *not* automatically deleted when their Tcl
423         variable is unset anymore. This means that you can
424         temporarily map vectors to variables and use them as you
425         would an ordinary Tcl array (kind of like "upvar").
426
427             proc AddValue { vecName value } {
428                  $vecName variable x
429         
430                  set x(++end) $value
431             }   
432
433         There's an "-watchunset" flag to restore the old
434         behavior if you need it. 
435
436             vector create x -watchunset yes
437
438      o  Vectors still automatically create Tcl variables by
439         default.  I'd like to change this, but it silently
440         breaks lots of code, so it will stay.
441
442     Bug fixes:
443
444      o  Vector reallocation failed when shrinking the vector.
445
446      o  Vector "destroy" callback made after vector was
447         already freed.
448
449  5. Changes to Graph, Barchart, Stripchart widgets.
450
451     New features:
452
453      o  Drop shadows for text (titles, markers, etc). Drop
454         shadows improve contrast when displaying text over a
455         background with similar color intensities.
456    
457      o  Postscript "-preview" option to generate a EPS
458         PostScript preview image that can be read and
459         displayed by the EPS canvas item.
460
461      o  New "-topvariable", "-bottomvariable",
462         "-leftvariable", and "-rightvariable" options.  They
463         specify variables to contain the current margin
464         sizes.  These variables are updated whenever the
465         graph is redrawn.
466
467      o  New "-aspect" option. Let's you maintain a particular aspect
468         ratio for the the graph.
469
470      o  Image markers can now be stretched and zoomed like
471         bitmap markers.
472
473      o  Bind operation for legend entries, markers, and elements.
474
475         Much thanks to Julian Loaring <bigj@bigj.demon.co.uk> 
476         for the suggestions.
477
478      o  New "-xor" option for line markers, lets you draw the line
479         by rubberbanded by XOR-ing without requiring the graph to
480         be redrawn.  This can be used, for example, to select regions
481         like in zooming.  
482
483         Thanks to Johannes Zellner (joze@krisal.physik.uni-karlsruhe.de) 
484         for the suggestion.
485
486     Bug fixes:
487
488      o  Closest line (point) broken when using pens styles.
489
490      o  Marker elastic coordinates were wrong.
491
492      o  PostScript bounding box included the border of the page.
493
494      o  Bad PostScript generated for barchart symbols with stipples.
495
496      o  Wrong dimensions computed with postscript " -maxpect" option.
497
498      o  Text markers fixed.
499
500         Thanks to De Clarke for the bug report and fix.
501
502
503      o  Renamed axis configuration from "-range" to "-autorange" to
504         match the documentation.  
505
506         Thanks to Brian Smith for the correction.
507
508      o  Fixed polygon marker pick routine.
509
510      o  Fixed active tab labels overlapping the selected tab.
511
512
513 What's incompatible with releases prior to BLT 2.4?
514
515  1. Vector names must start with a letter and contain letters, digits,
516     or underscores.  
517
518     Namespace Issues:   Vector names are still global. If Tcl provides
519                         an API, vectors may in the future be created on
520                         a per-namespace basis.  Right now, there's no
521                         mechanism for detecting when a namespace has been
522                         destroyed. Which is why you can't currently
523                         prefix a vector name with a namespace qualifier.
524
525                         [Ok, there is... Thanks to Michael McLennan for
526                         pointing this out to me.  So maybe soon there 
527                         will be vectors on a per namespace basis.]
528         
529  2. The "-mapped" options throughout the graph have been replaced
530     by the "-hide" option.  The many usages of the word "map" was 
531     getting confusing.  
532
533         # No longer works.
534         .graph legend configure -mapped no
535
536         # Instead use this.
537         .graph legend configure -hide yes    
538  
539    
540 How to compile and test BLT?
541
542   See the file "INSTALL" for instructions.
543
544 When will the so-called "official" BLT work with Windows?  
545
546   It currently compiles and runs with MS VC++ and EGCS 1.1 under 
547   Windows 95/NT (loadable binary versions will be forthcoming).  
548   Everything pretty much works: graphs, bgexec, busy, drag&drop etc.
549    
550 When will...?
551
552   In general, I can't answer the "When will" questions, mostly out of 
553   embarrassment.  My estimates of when new features and releases will
554   occur usually turn out to be way way off.  
555
556 What does BLT stand for?
557
558   Whatever you want it to.
559
560 --gah
561
562 %%
563 global endOfText
564 set endOfText [expr $htext(line)-1 ]
565
566 global updateInterval count barchart
567 global Red Green Blue
568 set updateInterval 200
569 set count 0
570 set Red bb
571 set Green 00
572 set Blue 33
573
574 option add *barchart.title "Bar Chart" 
575 option add *barchart.x.title "X"
576 option add *barchart.y.title "Y"
577 option add *barchart.y2.title "Y"
578 option add *barchart.Axis.subTicks 0
579 option add *barchart.x.stepSize 0
580 option add *barchart.x.Ticks 0
581 option add *barchart.legend.hide yes
582 option add *barchart.Axis.Font *-Courier-Bold-R-Normal-*-8-80-* 
583 option add *barchart.y2.hide yes
584
585 set barchart $this.barchart
586 barchart $barchart -bd 2 -relief raised  -tile bgTexture2
587 $barchart y2axis use y
588 $this append $barchart -fill both -padx 10 -pady 10 -relwidth 0.8
589
590 proc AnimateBarchart {  } {
591     global updateInterval
592     global barchart count Red Blue Green
593     
594     if { [info commands $barchart] != $barchart } {
595         return
596     }   
597     incr count
598     if { $count > 100 } {
599         $barchart element delete [lindex [$barchart element show] end]
600     }
601     set color [format "%x" [expr $count%16]]
602     set Green ${color}${color}
603     $barchart element create $count -data { $count sin($count*0.1)} \
604         -fg #${Red}${Green}${Blue} -bg brown 
605     after $updateInterval AnimateBarchart
606 }
607 AnimateBarchart
608
609 %%
610
611         Press %%
612 button $this.quit -command { exit } -text {Quit} -bg pink
613 $this append $this.quit
614 %% to remove the window.
615