OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [iwidgets3.0.0/] [demos/] [scrolledcanvas] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#!/bin/sh
2
# ----------------------------------------------------------------------
3
#  DEMO: scrolledcanvas in [incr Widgets]
4
# ----------------------------------------------------------------------
5
#\
6
exec itkwish "$0" ${1+"$@"}
7
package require Iwidgets 3.0
8
 
9
# itkwish interprets the rest...
10
# ----------------------------------------------------------------------
11
option add *textBackground seashell
12
. configure -background white
13
 
14
iwidgets::scrolledcanvas .canv -labeltext "Scrolledcanvas" \
15
    -vscrollmode dynamic -hscrollmode dynamic -autoresize yes
16
 
17
pack .canv -expand yes -fill both -padx 4 -pady 4
18
.canv xview moveto 0
19
.canv yview moveto 0
20
 
21
 
22
button .zoomin -text "Zoom In" -command {
23
    .canv scale all 0 0 2 2
24
    .canv configure -scrollregion [.canv bbox all]
25
}
26
pack .zoomin -side left -expand yes -padx 4 -pady 4
27
 
28
button .zoomout -text "Zoom Out" -command {
29
    .canv scale all 0 0 0.5 0.5
30
    .canv xview moveto 0
31
    .canv yview moveto 0
32
    .canv configure -scrollregion [.canv bbox all]
33
}
34
pack .zoomout -side left -expand yes -padx 4 -pady 4
35
 
36
 
37
bind [.canv component canvas]  {add_rectangle %W %x %y}
38
bind [.canv component canvas]  {add_rectangle %W %x %y}
39
 
40
proc add_rectangle {win x y} {
41
    set x [$win canvasx $x]
42
    set y [$win canvasy $y]
43
 
44
    $win create rectangle \
45
        [expr $x-4] [expr $y-4] \
46
        [expr $x+4] [expr $y+4] \
47
        -outline "" -fill red
48
 
49
    $win configure -scrollregion [$win bbox all]
50
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.