Ignore:
Timestamp:
Jul 19, 2007, 5:21:51 AM (17 years ago)
Author:
mmc
Message:

Added support for a <note> on the output side of an <image> object.
This was needed for app-nsopticsjr. We should experiement a little
more with this, design it properly, and apply the same idea to all
output items.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gui/scripts/imageresult.tcl

    r767 r785  
    3636
    3737    protected method _rebuild {args}
    38     protected method _topimage {}
     38    protected method _top {what}
    3939    protected method _zoom {option args}
    4040    protected method _move {option args}
     
    6363        max 1.0
    6464        current 1.0
     65        default 1
    6566        x 0
    6667        y 0
     
    7071    pack propagate $itk_component(hull) no
    7172
     73    Rappture::Panes $itk_interior.panes -sashwidth 1 -sashrelief solid -sashpadding 2
     74    pack $itk_interior.panes -expand yes -fill both
     75    set main [$itk_interior.panes pane 0]
     76    $itk_interior.panes fraction 0 1
     77
    7278    itk_component add controls {
    73         frame $itk_interior.cntls
     79        frame $main.cntls
    7480    } {
    7581        usual
     
    122128
    123129    itk_component add image {
    124         label $itk_interior.image -image $_image(final)
     130        label $main.image -image $_image(final)
    125131    } {
    126132        keep -background -foreground -cursor -font
     
    140146    bind $itk_component(image) <ButtonRelease-1> \
    141147        [itcl::code $this _move release %x %y]
     148
     149    #
     150    # Add area at the bottom for notes.
     151    #
     152    set notes [$itk_interior.panes insert end -fraction 0.15]
     153    $itk_interior.panes visibility 1 off
     154    Rappture::Scroller $notes.scr -xscrollmode auto -yscrollmode auto
     155    pack $notes.scr -expand yes -fill both
     156    itk_component add notes {
     157        Rappture::HTMLviewer $notes.scr.html
     158    }
     159    $notes.scr contents $notes.scr.html
    142160
    143161    eval itk_initialize $args
     
    287305        }
    288306        now {
    289             set top [_topimage]
     307            set top [_top image]
    290308            if {$top == ""} {
    291309                return ""
     
    331349        }
    332350    }
    333     if {$_scale(current) == "?"} {
    334         _zoom reset
     351    if {$_scale(current) == "?" || $_scale(default)} {
     352        set _scale(current) $_scale(max)
     353        set _scale(x) 0
     354        set _scale(y) 0
    335355    }
    336356
     
    343363    $_image(final) put $bg -to 0 0 $w $h
    344364
    345     set imh [_topimage]
     365    set imh [_top image]
    346366    if {$imh != ""} {
    347367        if {$_scale(current) <= 1.0} {
     
    369389        }
    370390    }
    371 }
    372 
    373 # ----------------------------------------------------------------------
    374 # USAGE: _topimage
     391
     392    set note [_top note]
     393    if {[string length $note] > 0} {
     394        if {[regexp {^html://} $note]} {
     395            set note [string range $note 7 end]
     396        } else {
     397            regexp {&} $note {\007} note
     398            regexp {<} $note {\&lt;} note
     399            regexp {>} $note {\&gt;} note
     400            regexp {\007} $note {\&amp;} note
     401            regexp "\n\n" $note {<br/>} note
     402            set note "<html><body>$note</body></html>"
     403        }
     404        set notes [$itk_interior.panes pane 1]
     405        $itk_component(notes) load $note -in [file join [_top tooldir] docs]
     406        $itk_interior.panes visibility 1 on
     407    } else {
     408        $itk_interior.panes visibility 1 off
     409    }
     410}
     411
     412# ----------------------------------------------------------------------
     413# USAGE: _top image|note|tooldir
    375414#
    376415# Used internally to get the topmost image currently being displayed.
    377416# ----------------------------------------------------------------------
    378 itcl::body Rappture::ImageResult::_topimage {} {
     417itcl::body Rappture::ImageResult::_top {option} {
    379418    set top $_topmost
    380419    if {"" == $top} {
     
    382421    }
    383422    if {"" != $top} {
    384         return [$top tkimage]
     423        switch -- $option {
     424            image   { return [$top tkimage] }
     425            note    { return [$top hints note] }
     426            tooldir { return [$top hints tooldir] }
     427            default { error "bad option \"$option\": should be image, note, tooldir" }
     428        }
    385429    }
    386430    return ""
     
    418462        reset {
    419463            set _scale(current) $_scale(max)
     464            set _scale(default) 1
    420465            set _scale(x) 0
    421466            set _scale(y) 0
     
    423468        in {
    424469            set _scale(current) [expr {$_scale(current)*0.5}]
     470            set _scale(default) 0
    425471        }
    426472        out {
     
    442488                }
    443489            }
     490            set _scale(default) 0
    444491        }
    445492    }
Note: See TracChangeset for help on using the changeset viewer.