OSDN Git Service

FIRST REPOSITORY
[eos/hostdependOTHERS.git] / I386LINUX / util / I386LINUX / lib / blt2.4 / demos / barchart3
1 #!/home/people/tkys/Eos/util/I386LINUX/bin/bltwish
2 #!../bltwish
3
4 source bltDemo.tcl
5
6 set graph .graph
7
8 bitmap define pattern1 { {4 4} {01 02 04 08} }
9 bitmap define pattern2 { {4 4} {08 04 02 01} }
10 bitmap define pattern3 { {2 2} {01 02 } }
11 bitmap define pattern4 { {4 4} {0f 00 00 00} }
12 bitmap define pattern5 { {4 4} {01 01 01 01} }
13 bitmap define pattern6 { {2 2} {01 00 } }
14 bitmap define pattern7 { {4 4} {0f 01 01 01} }
15 bitmap define pattern8 { {8 8} {ff 00 ff 00 ff 00 ff 00 } }
16 bitmap define pattern9 { {4 4} {03 03 0c 0c} }
17 bitmap define hobbes { {25 25} {
18    00 00 00 00 00 00 00 00 00 c0 03 00 78 e0 07 00 fc f8 07 00 cc 07 04 00
19    0c f0 0b 00 7c 1c 06 00 38 00 00 00 e0 03 10 00 e0 41 11 00 20 40 11 00
20    e0 07 10 00 e0 c1 17 00 10 e0 2f 00 20 e0 6f 00 18 e0 2f 00 20 c6 67 00
21    18 84 2b 00 20 08 64 00 70 f0 13 00 80 01 08 00 00 fe 07 00 00 00 00 00
22    00 00 00 00 }
23 }
24
25 option add *graph.xTitle "X Axis Label"
26 option add *graph.yTitle "Y Axis Label"
27 option add *graph.title "A Simple Barchart"
28 option add *graph.xFont *Times-Medium-R*12*
29 option add *graph.elemBackground white
30 option add *graph.elemRelief raised
31
32 set visual [winfo screenvisual .] 
33 if { $visual != "staticgray" && $visual != "grayscale" } {
34     option add *print.background yellow
35     option add *quit.background red
36 }
37
38 htext .header -text {
39 This is an example of the barchart widget.  To create a postscript 
40 file "bar.ps", press the %% 
41 button $htext(widget).print -text {Print} -command {
42   $graph postscript output bar.ps  -maxpect 1
43
44 $htext(widget) append $htext(widget).print
45 %% button.}
46
47 barchart $graph -invert true 
48 $graph xaxis configure -command FormatLabel -descending true
49 $graph legend configure -hide yes
50
51 htext .footer -text {Hit the %%
52 button $htext(widget).quit -text quit -command exit
53 $htext(widget) append $htext(widget).quit 
54 %% button when you've seen enough.%%
55 label $htext(widget).logo -bitmap BLT
56 $htext(widget) append $htext(widget).logo -padx 20
57 %%}
58
59 set names { One Two Three Four Five Six Seven Eight }
60 if { $visual == "staticgray" || $visual == "grayscale" } {
61     set fgcolors { white white white white white white white white }
62     set bgcolors { black black black black black black black black }
63 } else {
64     set fgcolors { red green blue purple orange brown cyan navy }
65     set bgcolors { green blue purple orange brown cyan navy red }
66 }
67 set numColors [llength $names]
68
69 for { set i 0} { $i < $numColors } { incr i } {
70     $graph element create [lindex $names $i] \
71         -data { $i+1 $i+1 } \
72         -fg [lindex $fgcolors $i] \
73         -bg [lindex $bgcolors $i] \
74         -stipple pattern[expr $i+1]  \
75         -relief raised \
76         -bd 2 
77 }
78
79 $graph element create Nine \
80     -data { 9 -1.0 } \
81     -fg red  \
82     -relief sunken 
83 $graph element create Ten \
84     -data { 10 2 } \
85     -fg seagreen \
86     -stipple hobbes \
87     -background palegreen 
88 $graph element create Eleven \
89     -data { 11 3.3 } \
90     -fg blue  
91
92 #    -coords { -Inf Inf  } 
93
94 $graph marker create bitmap \
95     -coords { 11 3.3 } -anchor center \
96     -bitmap @bitmaps/sharky.bm \
97     -name bitmap \
98     -bg {} 
99
100
101 table . \
102     .header 0,0 -padx .25i \
103     .graph 1,0 -fill both \
104     .footer 2,0 -padx .25i  
105
106 table configure . r0 r2 -resize none
107
108 wm min . 0 0
109
110 proc FormatLabel { w value } {
111     # Determine the element name from the value
112     set displaylist [$w element show]
113     set index [expr round($value)-1]
114     set name [lindex $displaylist $index]
115     if { $name == "" } { 
116         return $name
117     }
118     # Return the element label
119     set info [$w element configure $name -label]
120     return [lindex $info 4]
121 }
122
123 Blt_ZoomStack $graph
124 Blt_Crosshairs $graph
125 Blt_ActiveLegend $graph
126 Blt_ClosestPoint $graph
127
128
129 .graph marker bind all <B2-Motion> {
130     set coords [%W invtransform %x %y]
131     catch { %W marker configure [%W marker get current] -coords $coords }
132 }
133
134 .graph marker bind all <Enter> {
135     set marker [%W marker get current]
136     catch { %W marker configure $marker -bg green}
137     catch { %W marker configure $marker -fill green}
138 }
139
140 .graph marker bind all <Leave> {
141     set marker [%W marker get current]
142     catch { %W marker configure $marker -bg ""}
143     catch { %W marker configure $marker -fill ""}
144 }
145