]> www.wagner.pp.ru Git - oss/fgis.git/blob - tcl/toolbar.tcl
First checked in version
[oss/fgis.git] / tcl / toolbar.tcl
1 #
2 # toolbar.tcl - some standard interface gadgets for fGIS
3 #  
4 #
5
6 #
7 # Creates standard fGIS toolbar for given planchet
8 # Planchet should exist, otherwise you'll have hard time passing
9 # all toolbar buttons to corresponding planchet options
10 # wpath is pathname for frame which would be created for toolbar
11 #
12 option add *Toolbar*Font -*-times-bold-r-normal--10-* widgetDefault
13
14 proc toolbar {wpath planchet} {
15 global  fgis
16 set $wpath\(ruler) off
17 frame $wpath -class Toolbar
18 button $wpath.print -image [image create bitmap -data {
19 #define printer_width 16
20 #define printer_height 16
21 static unsigned char printer_bits[] = {
22   0x00, 0x00, 0x00, 0x00, 0xe0, 0x3f, 0x20, 0x20, 0x10, 0x10, 0x10, 0x10,
23   0x08, 0x08, 0x08, 0x08, 0xfe, 0x3f, 0x01, 0x40, 0x01, 0x5c, 0x01, 0x40,
24   0x01, 0x40, 0xfe, 0x3f, 0x04, 0x10, 0xfc, 0x1f, };
25 }] -padx 0 -pady 0 -command [list fgisPrintDialog $planchet]
26 button $wpath.zoom -image [image create bitmap -data {
27 #define zoom_width 16
28 #define zoom_height 16
29 static unsigned char zoom_bits[] = {
30   0x00, 0x0e, 0x80, 0x31, 0x40, 0x4e, 0x40, 0x51, 0xa0, 0xa4, 0xa0, 0xae,
31   0xa0, 0xa4, 0x40, 0x51, 0x40, 0x4e, 0xa0, 0x31, 0x50, 0x0e, 0x28, 0x00,
32   0x14, 0x00, 0x0a, 0x00, 0x05, 0x00, 0x03, 0x00, };
33 }] -padx 0 -pady 0 -command "$planchet zoom"
34 button $wpath.unzoom -image [image create bitmap -data {
35 #define unzoom_width 16
36 #define unzoom_height 16
37 static unsigned char unzoom_bits[] = {
38   0x00, 0x0e, 0x80, 0x31, 0x40, 0x4e, 0x40, 0x51, 0xa0, 0xa0, 0xa0, 0xae,
39   0xa0, 0xa0, 0x40, 0x51, 0x40, 0x4e, 0xa0, 0x31, 0x50, 0x0e, 0x28, 0x00,
40   0x14, 0x00, 0x0a, 0x00, 0x05, 0x00, 0x03, 0x00, };
41 }] -padx 0 -pady 0 -command "$planchet unzoom"
42 button $wpath.all -image [image create bitmap -data {
43 #define unzoomall_width 16
44 #define unzoomall_height 16
45 static unsigned char unzoomall_bits[] = {
46   0x00, 0x8e, 0x8c, 0xf1, 0x5a, 0x7e, 0x70, 0x59, 0xa0, 0xae, 0xe0, 0xa7,
47   0xe0, 0xa1, 0xc0, 0x51, 0x70, 0x4f, 0xb8, 0x33, 0x5e, 0x0e, 0x2f, 0x08,
48   0x15, 0x18, 0x0a, 0x30, 0x05, 0x60, 0x03, 0xc0, };
49 }] -padx 0 -pady 0 -command "$planchet limits default"
50 button $wpath.left -image [image create bitmap -data {
51 #define left_width 11
52 #define left_height 10
53 static unsigned char left_bits[] = {
54   0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0xe0, 0x01, 0xf8, 0x01, 0xfe, 0x01,
55   0xf8, 0x01, 0xe0, 0x01, 0x80, 0x01, 0x00, 0x00, };
56 }] -pady 3 -padx 2 -command "$planchet shift left"
57 button $wpath.up -image [image create bitmap -data {
58 #define up_width 10
59 #define up_height 10
60 static unsigned char up_bits[] = {
61   0x00, 0x00, 0x20, 0x00, 0x20, 0x00, 0x70, 0x00, 0x70, 0x00, 0xf8, 0x00,
62   0xf8, 0x00, 0xfc, 0x01, 0xfc, 0x01, 0x00, 0x00, };
63 }] -pady 3 -padx 2 -command "$planchet shift up"
64 button $wpath.down -image [image create bitmap -data {
65 #define down_width 10
66 #define down_height 10
67 static unsigned char down_bits[] = {
68   0x00, 0x00, 0xfc, 0x01, 0xfc, 0x01, 0xf8, 0x00, 0xf8, 0x00, 0x70, 0x00,
69   0x70, 0x00, 0x20, 0x00, 0x20, 0x00, 0x00, 0x00, };
70 }] -padx 2 -pady 3 -command "$planchet shift down"
71 button $wpath.right -image [image create bitmap -data {
72 #define right_width 11
73 #define right_height 10 
74 static unsigned char right_bits[] = {
75   0X00, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x3c, 0x00, 0xfc, 0x00, 0xfc, 0x03, 
76   0xfc, 0x00, 0x3c, 0x00, 0x0c, 0x00, 0x00, 0x00, };
77 }] -padx 2 -pady 3 -command "$planchet shift right"
78 checkbutton $wpath.ruler -image [image create bitmap -data {
79 #define ruler_width 16
80 #define ruler_height 16
81 static char ruler_bits[] = {
82    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
83    0x00, 0x00, 0x02, 0x40, 0x22, 0x44, 0xfe, 0x7f, 0xfe, 0x7f, 0x00, 0x00,
84    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
85 }] -bd 3  -indicatoron 0 -variable $wpath\(ruler) \
86    -onvalue on -offvalue off \
87  -command "$planchet ruler \[set $wpath\(ruler)]"
88 upvar #0 $wpath data
89 set data(ruler) off 
90 label $wpath.scale -textvariable "$wpath\(scale)" 
91 pack $wpath.print $wpath.zoom $wpath.unzoom $wpath.all $wpath.ruler -side left
92 pack $wpath.scale -side left -padx 20
93 pack $wpath.right $wpath.up $wpath.down $wpath.left -side right
94 if [winfo exists $planchet] {
95  $planchet configure -zoombutton $wpath.zoom -unzoombuttons\
96           [list $wpath.unzoom $wpath.all] -shiftbuttons \
97           [list $wpath.left $wpath.down $wpath.up $wpath.right]\
98           -scalevar $wpath\(scale) 
99  $planchet ruler off
100 }
101 }
102
103 proc __ruler_y {canvas} {
104 return [expr [winfo height $canvas] - [$canvas canvasy 1c]+[$canvas canvasy 0c]]
105 }
106
107 proc __show_scale {widget var index op} {
108 global map_items
109 if [llength $map_items($index)]==4 {
110  set canvas [lindex [split $index ","] 0]
111  $widget configure -text "Scale 1:[mapscale $canvas]"
112 } else { 
113  $widget configure -text "Scale unknown"
114 }
115 }
116
117 proc fgisPrintDialog planchet {
118 global fgis
119 set dialog [toplevel $planchet.print]
120 wm title $dialog "Print setup"
121 wm transient $dialog [winfo toplevel $planchet]
122 radiobutton $dialog.l1 -text "Printer" -value {} -variable\
123     fgisPrint(dest) -anchor w\
124  -command  "$dialog.file configure -state disabled;
125    $dialog.printer configure -state normal
126    $dialog.browse configure -state disabled"
127 entry $dialog.printer -width 10 -textvar fgis(printer) 
128 uplevel set fgisPrint(dest) {}  
129 $dialog.printer insert end $fgis(printer)
130 radiobutton $dialog.l2 -text "File" -value "-file \$fgisPrint(file)"\
131  -var fgisPrint(dest) -anchor w\
132  -command  "$dialog.file configure -state normal;
133    $dialog.printer configure -state disabled
134    $dialog.browse configure -state normal"
135 entry $dialog.file -textvar fgisPrint(file) -width 20 -state disable
136 button $dialog.browse -text "Browse.." -command \
137     {set fgisPrint(file) [tk_getSaveFile]} -state disable
138 button $dialog.ok -text Ok -command "eval $planchet print \$fgisPrint(dest) ;\
139             destroy $dialog"
140 button $dialog.cancel -text Cancel -command "destroy $dialog"
141 grid $dialog.l1 - $dialog.printer - - -sticky news
142 grid $dialog.l2 - $dialog.file - - $dialog.browse -sticky news
143 grid x $dialog.ok - x $dialog.cancel x -sticky news 
144 }
145