Ignore:
Timestamp:
Jun 23, 2010 6:54:49 AM (14 years ago)
Author:
gah
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/gui/scripts/xyprint.tcl

    r1774 r1775  
    3333    private variable _preview "";       # Preview image.
    3434    private variable _savedSettings;    # Array of settings.
     35    private variable _legendFontName ""
    3536
    3637    private common _oldSettingsFile "~/.rpsettings"
     
    167168itcl::body Rappture::XyPrint::print { graph toolName plotName } {
    168169    set _graph $graph
    169     set _clone [CloneGraph $graph]
     170    CloneGraph $graph
    170171    InitClone
    171172    RestoreSettings $toolName $plotName
     
    291292        destroy $top.graph
    292293    }
    293     set clone [blt::graph $top.graph]
    294     CopyOptions "configure" $orig $clone
     294    set _clone [blt::graph $top.graph]
     295    CopyOptions "configure" $orig $_clone
    295296    # Axis component
    296297    foreach axis [$orig axis names] {
     
    298299            continue
    299300        }
    300         if { [$clone axis name $axis] == "" } {
    301             $clone axis create $axis
    302         }
    303         CopyOptions [list axis configure $axis] $orig $clone
     301        if { [$_clone axis name $axis] == "" } {
     302            $_clone axis create $axis
     303        }
     304        CopyOptions [list axis configure $axis] $orig $_clone
    304305    }
    305306    foreach axis { x y x2 y2 } {
    306         $clone ${axis}axis use [$orig ${axis}axis use]
     307        $_clone ${axis}axis use [$orig ${axis}axis use]
    307308    }
    308309    # Pen component
    309310    foreach pen [$orig pen names] {
    310         if { [$clone pen name $pen] == "" } {
    311             $clone pen create $pen
    312         }
    313         CopyOptions [list pen configure $pen] $orig $clone
     311        if { [$_clone pen name $pen] == "" } {
     312            $_clone pen create $pen
     313        }
     314        CopyOptions [list pen configure $pen] $orig $_clone
    314315    }
    315316    # Marker component
    316317    foreach marker [$orig marker names] {
    317         $clone marker create [$orig marker type $marker] -name $marker
    318         CopyOptions [list marker configure $marker] $orig $clone
     318        $_clone marker create [$orig marker type $marker] -name $marker
     319        CopyOptions [list marker configure $marker] $orig $_clone
    319320    }
    320321    # Element component
    321322    foreach elem [$orig element names] {
    322         $clone element create $elem
    323         CopyOptions [list element configure $elem] $orig $clone
    324         if { [$clone element cget $elem -hide] } {
    325             $clone element configure $elem -label ""
     323        $_clone element create $elem
     324        CopyOptions [list element configure $elem] $orig $_clone
     325        if { [$_clone element cget $elem -hide] } {
     326            $_clone element configure $elem -label ""
    326327        }
    327328    }
    328329    # Fix element display list
    329     $clone element show [$orig element show]
     330    $_clone element show [$orig element show]
    330331    # Legend component
    331     CopyOptions {legend configure} $orig $clone
     332    CopyOptions {legend configure} $orig $_clone
    332333    # Postscript component
    333     CopyOptions {postscript configure} $orig $clone
     334    CopyOptions {postscript configure} $orig $_clone
    334335    # Crosshairs component
    335     CopyOptions {crosshairs configure} $orig $clone
    336     return $clone
     336    CopyOptions {crosshairs configure} $orig $_clone
    337337}
    338338
     
    663663    set _settings($this-legend-position)  [$page.position current]
    664664    set _settings($this-legend-anchor)    [$page.anchor current]
    665     foreach option { -hide -position -anchor -borderwidth } {
    666         SetComponentOption legend $option
    667     }
    668     $_clone legend configure -font legend
     665    if { $_clone != "" } {
     666        font configure $_fonts(legend) \
     667            -family $_settings($this-legend-font-family) \
     668            -size [$page.fontsize current] \
     669            -weight $_settings($this-legend-font-weight) \
     670            -slant $_settings($this-legend-font-slant)
     671        foreach option { -hide -position -anchor -borderwidth } {
     672            SetComponentOption legend $option
     673        }
     674        $_clone legend configure -font fixed -font $_fonts(legend)
     675    }
    669676    ApplyElementSettings
    670677}
     
    790797
    791798    label $page.font_l -text "font"
     799    set m $page.fontfamily.menu
     800    blt::comboentry $page.fontfamily \
     801        -width 10 \
     802        -textvariable [itcl::scope _legendFontName] \
     803        -editable no -menu $m \
     804        -command [itcl::code $this ApplyLegendSettings]
     805    blt::combomenu $m \
     806        -xscrollbar $m.xs \
     807        -yscrollbar $m.ys  \
     808        -textvariable [itcl::scope _legendFontName] \
     809        -height { 0 2i }
     810    blt::tk::scrollbar $m.xs
     811    blt::tk::scrollbar $m.ys
     812    $m style create "courier" -font "{courier new} 9"
     813    $m style create "helvetica" -font "{arial} 9"
     814    $m style create "newcentury" -font "{new century schoolbook} 9"
     815    $m style create "times" -font "{times new roman} 9"
     816    $m add -text "courier" -value "courier" -style "courier"
     817    $m add -text "helvetica" -value "helvetica"  -style "helvetica"
     818    $m add -text "new century schoolbook" -value "new*century*schoolbook" \
     819        -style "newcentury"
     820    $m add -text "symbol" -value "symbol"
     821    $m add -text "times" -value "times" -style "times"
     822    $m item configure all \
     823        -variable [itcl::scope _settings($this-legend-font-family)]
     824    $m select "helvetica"
     825    if 0 {
    792826    Rappture::Combobox $page.fontfamily -width 10 -editable no
    793827    $page.fontfamily choices insert end \
     
    797831        "symbol"  "symbol" \
    798832        "times"  "times"         
     833    }
    799834    bind $page.fontfamily <<Value>> [itcl::code $this ApplyLegendSettings]
    800835    Rappture::Tooltip::for $page.fontfamily \
     
    10701105}
    10711106
    1072 itcl::body Rappture::XyPrint::ApplyLegendSettings {} {
    1073     set page $itk_component(legend_page)
    1074     set _settings($this-legend-position)  [$page.position current]
    1075     set _settings($this-legend-anchor)    [$page.anchor current]
    1076 
    1077     foreach option { -hide -position -anchor -borderwidth } {
    1078         SetComponentOption legend $option
    1079     }
    1080     font configure $_fonts(legend) \
    1081         -family [$page.fontfamily current] \
    1082         -size [$page.fontsize current] \
    1083         -weight $_settings($this-legend-font-weight) \
    1084         -slant $_settings($this-legend-font-slant)
    1085     $_clone legend configure -font fixed -font $_fonts(legend)
    1086     ApplyElementSettings
    1087 }
    10881107
    10891108itcl::body Rappture::XyPrint::ApplyAxisSettings {} {
     
    11141133itcl::body Rappture::XyPrint::ApplyElementSettings {} {
    11151134    set index [$itk_component(element_slider) get]
    1116     set elem $_settings($this-element-$index)
    11171135    set page $itk_component(legend_page)
    11181136    set _settings($this-element-color)  [$page.color current]
    11191137    set _settings($this-element-symbol) [$page.symbol current]
    11201138    set _settings($this-element-dashes) [$page.dashes current]
    1121     foreach option { -symbol -color -dashes -label } {
    1122         SetNamedComponentOption element $elem $option
    1123     }
    1124     RegeneratePreview
     1139    if { $_clone != "" } {
     1140        set elem $_settings($this-element-$index)
     1141        foreach option { -symbol -color -dashes -label } {
     1142            SetNamedComponentOption element $elem $option
     1143        }
     1144        RegeneratePreview
     1145    }
    11251146}
    11261147
     
    11841205    array unset info
    11851206    array set info [font configure legend]
    1186     $page.fontfamily value $info(-family)
     1207    set _settings($this-legend-font-family) $info(-family)
    11871208    $page.fontsize value $info(-size)
    11881209    set _settings($this-legend-font-weight) $info(-weight)
Note: See TracChangeset for help on using the changeset viewer.