Changeset 1604 for trunk/gui


Ignore:
Timestamp:
Oct 29, 2009 2:04:52 PM (15 years ago)
Author:
gah
Message:
 
Location:
trunk/gui/scripts
Files:
2 edited

Legend:

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

    r1531 r1604  
    2424    itk_option define -width width Width "normal"
    2525    itk_option define -height height Height "normal"
     26    itk_option define -onvalue onValue OnValue "normal"
     27    itk_option define -offvalue offValue OffValue "normal"
    2628
    2729    constructor {args} { # defined below }
     
    102104        $itk_component(button) configure -relief raise \
    103105            -image $offimage -bg grey85
     106    } else {
     107        puts stderr "unknown value \"$var\": should be \"$offvalue\" or \"onvalue\""
    104108    }
    105109}
     
    151155    $itk_component(button) configure -height $itk_option(-height)
    152156}
     157
  • trunk/gui/scripts/xyprint.tcl

    r1603 r1604  
    168168    set _clone [CloneGraph $graph]
    169169    InitClone
     170    RestoreSettings $toolName $plotName
    170171    InitializeSettings
    171     # RestoreSettings $toolName $plotName
    172172    set _wait($this) 0
    173173    tkwait variable [itcl::scope _wait($this)]
     
    176176        set output [GetOutput]
    177177    }
    178     # SaveSettings $toolName $plotName
     178    SaveSettings $toolName $plotName
    179179    DestroySettings
    180180    return $output
     
    341341        -plotbackground white -plotpadx 0 -plotpady 0
    342342    #
    343     set _fonts(legend) [font create -family helvetica -size 10 -weight normal]
     343    set _settings($this-layout-width) [Pixels2Inches [$_clone cget -width]]
     344    set _settings($this-layout-height) [Pixels2Inches [$_clone cget -height]]
     345
     346    set _fonts(legend) [font create legend \
     347                            -family helvetica -size 10 -weight normal]
    344348    update
    345349    $_clone legend configure \
     
    353357            continue
    354358        }
    355         set _fonts($axis-ticks) [font create -family helvetica -size 10 \
     359        set _fonts($axis-ticks) [font create $axis-ticks \
     360                                     -family helvetica -size 10 \
    356361                                     -weight normal -slant roman]
    357         set _fonts($axis-title) [font create -family helvetica -size 10 \
     362        set _fonts($axis-title) [font create $axis-title \
     363                                     -family helvetica -size 10 \
    358364                                     -weight normal -slant roman]
    359         puts stderr "tick fonts $_fonts($axis-ticks):  [font configure $_fonts($axis-ticks)]"
    360         puts stderr "title fonts $_fonts($axis-title): [font configure $_fonts($axis-title)]"
    361365        update
    362366        $_clone axis configure $axis -ticklength 5  \
     
    378382    $_clone marker create line -name y-zero \
    379383        -coords "-Inf 0 Inf 0" -dashes 1 -hide yes
     384
     385    puts stderr "font names [font names]"
    380386}
    381387
     
    419425    update
    420426    set img [image create photo]
    421 
    422427    set w [Inches2Pixels $_settings($this-layout-width)]
    423428    set h [Inches2Pixels $_settings($this-layout-height)]
     
    600605        SetComponentOption legend $option
    601606    }
     607    $_clone legend configure -font legend
    602608    ApplyElementSettings
    603609}
     
    710716    Rappture::Combobox $page.fontfamily -width 10 -editable no
    711717    $page.fontfamily choices insert end \
    712         "courier" "Courier" \
    713         "helvetica" "Helvetica"  \
    714         "new*century*schoolbook"  "New Century Schoolbook" \
    715         "symbol"  "Symbol" \
    716         "times"  "Times"         
     718        "courier" "courier" \
     719        "helvetica" "helvetica"  \
     720        "new*century*schoolbook"  "new century schoolbook" \
     721        "symbol"  "symbol" \
     722        "times"  "times"         
    717723    bind $page.fontfamily <<Value>> [itcl::code $this ApplyLegendSettings]
    718724
     
    730736    bind  $page.fontsize <<Value>> [itcl::code $this ApplyLegendSettings]
    731737
    732     Rappture::PushButton $page.fontbold \
     738    Rappture::PushButton $page.fontweight \
    733739        -width 18 -height 18 \
    734740        -onimage [Rappture::icon font-bold] \
    735741        -offimage [Rappture::icon font-bold] \
     742        -onvalue "bold" -offvalue "normal" \
    736743        -command [itcl::code $this ApplyLegendSettings] \
    737         -variable [itcl::scope _settings($this-legend-font-bold)]
    738 
    739     Rappture::PushButton $page.fontitalic \
     744        -variable [itcl::scope _settings($this-legend-font-weight)]
     745
     746    Rappture::PushButton $page.fontslant \
    740747        -width 18 -height 18 \
    741748        -onimage [Rappture::icon font-italic] \
    742749        -offimage [Rappture::icon font-italic] \
     750        -onvalue "italic" -offvalue "roman" \
    743751        -command [itcl::code $this ApplyLegendSettings] \
    744         -variable [itcl::scope _settings($this-legend-font-italic)]
     752        -variable [itcl::scope _settings($this-legend-font-slant)]
    745753
    746754    blt::table $page \
     
    753761        3,1 $page.fontfamily -fill x \
    754762        3,2 $page.fontsize -fill x \
    755         3,3 $page.fontbold -anchor e \
    756         3,4 $page.fontitalic -anchor e \
     763        3,3 $page.fontweight -anchor e \
     764        3,4 $page.fontslant -anchor e \
    757765        4,0 $page.slider_l -anchor e \
    758766        4,1 $page.slider -fill x -cspan 5 \
     
    833841    Rappture::Combobox $page.tickfontfamily -width 10 -editable no
    834842    $page.tickfontfamily choices insert end \
    835         "courier" "Courier" \
    836         "helvetica" "Helvetica"  \
    837         "new*century*schoolbook"  "New Century Schoolbook" \
    838         "symbol"  "Symbol" \
    839         "times"  "Times"         
     843        "courier" "courier" \
     844        "helvetica" "helvetica"  \
     845        "new*century*schoolbook"  "new century schoolbook" \
     846        "symbol"  "symbol" \
     847        "times"  "times"         
    840848    bind $page.tickfontfamily <<Value>> [itcl::code $this ApplyAxisSettings]
    841849
     
    853861    bind $page.tickfontsize <<Value>> [itcl::code $this ApplyAxisSettings]
    854862
    855     Rappture::PushButton $page.tickfontbold \
     863    Rappture::PushButton $page.tickfontweight \
    856864        -width 18 -height 18 \
    857865        -onimage [Rappture::icon font-bold] \
    858866        -offimage [Rappture::icon font-bold] \
     867        -onvalue "bold" -offvalue "normal" \
    859868        -command [itcl::code $this ApplyAxisSettings] \
    860         -variable [itcl::scope _settings($this-axis-tickfont-bold)]
    861 
    862     Rappture::PushButton $page.tickfontitalic \
     869        -variable [itcl::scope _settings($this-axis-tickfont-weight)]
     870
     871    Rappture::PushButton $page.tickfontslant \
    863872        -width 18 -height 18 \
    864873        -onimage [Rappture::icon font-italic] \
    865874        -offimage [Rappture::icon font-italic] \
     875        -onvalue "italic" -offvalue "roman" \
    866876        -command [itcl::code $this ApplyAxisSettings] \
    867         -variable [itcl::scope _settings($this-axis-tickfont-italic)]
     877        -variable [itcl::scope _settings($this-axis-tickfont-slant)]
    868878
    869879    label $page.titlefont_l -text "title font"
    870880    Rappture::Combobox $page.titlefontfamily -width 10 -editable no
    871881    $page.titlefontfamily choices insert end \
    872         "courier" "Courier" \
    873         "helvetica" "Helvetica"  \
    874         "new*century*schoolbook"  "New Century Schoolbook" \
    875         "symbol"  "Symbol" \
    876         "times"  "Times"         
     882        "courier" "courier" \
     883        "helvetica" "helvetica"  \
     884        "new*century*schoolbook"  "new century schoolbook" \
     885        "symbol"  "symbol" \
     886        "times"  "times"         
    877887    bind $page.titlefontfamily <<Value>> [itcl::code $this ApplyAxisSettings]
    878888
     
    890900    bind $page.tickfontsize <<Value>> [itcl::code $this ApplyAxisSettings]
    891901
    892     Rappture::PushButton $page.titlefontbold \
     902    Rappture::PushButton $page.titlefontweight \
    893903        -width 18 -height 18 \
    894904        -onimage [Rappture::icon font-bold] \
    895905        -offimage [Rappture::icon font-bold] \
     906        -onvalue "bold" -offvalue "normal" \
    896907        -command [itcl::code $this ApplyAxisSettings] \
    897         -variable [itcl::scope _settings($this-axis-titlefont-bold)]
    898 
    899     Rappture::PushButton $page.titlefontitalic \
     908        -variable [itcl::scope _settings($this-axis-titlefont-weight)]
     909
     910    Rappture::PushButton $page.titlefontslant \
    900911        -width 18 -height 18 \
    901912        -onimage [Rappture::icon font-italic] \
    902913        -offimage [Rappture::icon font-italic] \
     914        -onvalue "italic" -offvalue "roman" \
    903915        -command [itcl::code $this ApplyAxisSettings] \
    904         -variable [itcl::scope _settings($this-axis-titlefont-italic)]
     916        -variable [itcl::scope _settings($this-axis-titlefont-slant)]
    905917
    906918    blt::table $page \
     
    920932        5,2 $page.titlefontfamily -fill x -cspan 2 \
    921933        5,4 $page.titlefontsize -fill x \
    922         5,5 $page.titlefontbold -anchor e \
    923         5,6 $page.titlefontitalic -anchor e \
     934        5,5 $page.titlefontweight -anchor e \
     935        5,6 $page.titlefontslant -anchor e \
    924936        6,1 $page.tickfont_l -anchor e \
    925937        6,2 $page.tickfontfamily -fill x -cspan 2 \
    926938        6,4 $page.tickfontsize -fill x \
    927         6,5 $page.tickfontbold -anchor e \
    928         6,6 $page.tickfontitalic -anchor e \
     939        6,5 $page.tickfontweight -anchor e \
     940        6,6 $page.tickfontslant -anchor e \
    929941        7,1 $page.loose -cspan 2 -anchor w \
    930942        7,3 $page.grid -anchor w -cspan 2 \
     
    946958        SetComponentOption legend $option
    947959    }
    948     set slant "roman"
    949     if { $_settings($this-legend-font-italic) } {
    950         set slant "italic"
    951     }
    952     set weight "normal"
    953     if { $_settings($this-legend-font-bold) } {
    954         set weight "bold"
    955     }
    956960    font configure $_fonts(legend) \
    957961        -family [$page.fontfamily current] \
    958962        -size [$page.fontsize current] \
    959         -weight $weight -slant $slant
     963        -weight $_settings($this-legend-font-weight) \
     964        -slant $_settings($this-legend-font-slant)
    960965    $_clone legend configure -font $_fonts(legend)
    961966    ApplyElementSettings
     
    976981    }
    977982    $_clone marker configure ${type}-zero -hide $_settings($this-axis-zero)
    978     set slant "roman"
    979     if { $_settings($this-axis-titlefont-italic) } {
    980         set slant "italic"
    981     }
    982     set weight "normal"
    983     if { $_settings($this-axis-titlefont-bold) } {
    984         set weight "bold"
    985     }
    986     font configure $_fonts($axis-title) \
     983    font configure $axis-title \
    987984        -family [$page.titlefontfamily current] \
    988985        -size [$page.titlefontsize current] \
    989         -weight $weight -slant $slant
    990     set slant "roman"
    991     if { $_settings($this-axis-tickfont-italic) } {
    992         set slant "italic"
    993     }
    994     set weight "normal"
    995     if { $_settings($this-axis-tickfont-bold) } {
    996         set weight "bold"
    997     }
    998     font configure $_fonts($axis-ticks) \
     986        -weight $_settings($this-axis-titlefont-weight) \
     987        -slant $_settings($this-axis-titlefont-slant)
     988    font configure $axis-ticks \
    999989        -family [$page.tickfontfamily current] \
    1000990        -size [$page.tickfontsize current] \
    1001         -weight $weight -slant $slant
    1002     $_clone axis configure $axis -tickfont $_fonts($axis-ticks) \
    1003         -titlefont $_fonts($axis-title)
     991        -weight $_settings($this-axis-tickfont-weight) \
     992        -slant $_settings($this-axis-tickfont-slant)
     993    $_clone axis configure $axis -tickfont $axis-ticks -titlefont $axis-title
    1004994    GetAxis
    1005995    RegeneratePreview
     
    10281018            global errorInfo
    10291019            puts stderr "$err: $errorInfo"
    1030             set _settings($this-layout-$opt) [Pixel2Inches $old]
     1020            set _settings($this-layout-$opt) [Pixels2Inches $old]
    10311021        }
    10321022    }
     
    10701060    # Always set the borderwidth to be not displayed
    10711061    set _settings($this-legend-borderwidth) 0
    1072     $page.fontfamily value "Helvetica"
    1073     $page.fontsize value "10"
    1074     set _settings($this-legend-font-bold) 0
    1075     set _settings($this-legend-font-italic) 0
    1076 
     1062
     1063    array unset info
     1064    array set info [font configure legend]
     1065    $page.fontfamily value $info(-family)
     1066    $page.fontsize value $info(-size)
     1067    set _settings($this-legend-font-weight) $info(-weight)
     1068    set _settings($this-legend-font-slant) $info(-slant)
     1069    if { $info(-weight) == "bold" } {
     1070        set _settings($this-legend-font-bold) 1
     1071    }
    10771072    set _settings($this-legend-hide) [$_clone legend cget -hide]
    10781073    set _settings($this-legend-position) [$_clone legend cget -position]
     
    10931088        lappend axisnames $axis
    10941089    }
    1095     $page.titlefontfamily value "Helvetica"
    1096     $page.tickfontfamily value "Helvetica"
    1097     $page.titlefontsize value "10"
    1098     $page.tickfontsize value "10"
    1099     set _settings($this-axis-tickfont-bold) 0
    1100     set _settings($this-axis-tickfont-italic) 0
    1101     set _settings($this-axis-titlefont-bold) 0
    1102     set _settings($this-axis-titlefont-italic) 0
     1090    set axis [lindex $names 0]
     1091
     1092    array set info [font configure $axis-title]
     1093    $page.titlefontfamily value $info(-family)
     1094    $page.titlefontsize value $info(-size)
     1095    set _settings($this-axis-titlefont-weight) $info(-weight)
     1096    set _settings($this-axis-titlefont-slant) $info(-slant)
     1097
     1098    array set info [font configure $axis-ticks]
     1099    $page.tickfontfamily value $info(-family)
     1100    $page.tickfontsize value $info(-size)
     1101    set _settings($this-axis-tickfont-weight) $info(-weight)
     1102    set _settings($this-axis-tickfont-slant) $info(-slant)
     1103
    11031104    # Always hide the zero line.
    11041105    set _settings($this-axis-zero) 1
     
    11251126    set parser [interp create -safe]
    11261127    $parser alias xyprint [itcl::code $this restore]
    1127     set f [open $file "r"]
     1128    $parser alias font font
     1129    set f [open "~/.rappture" "r"]
    11281130    set code [read $f]
    11291131    close $f
     
    11521154
    11531155itcl::body Rappture::XyPrint::SaveSettings { toolName plotName } {
    1154     if { ![file writable "~/.rappture"] } {
     1156    if { !$_settings($this-general-remember) } {
    11551157        return
    11561158    }
    1157     set out [CreateSettings $toolName $plotName]
     1159    if { [catch { open "~/.rappture" "w" 0600 } f ] != 0 } {
     1160        puts stderr "~/.rappture isn't writable: $f"
     1161        bell
     1162        return
     1163    }
     1164    set key [list $toolName $plotName]
     1165    set _savedSettings($key) [CreateSettings $toolName $plotName]
    11581166    # Write the settings out
    1159     set f [open ".rappture" "w" 0600]
    11601167    foreach key [lsort [array names _savedSettings]] {
    11611168        set tool [lindex $key 0]
    11621169        set plot [lindex $key 1]
    1163         if { $plotName == "plot" && $toolName == "$tool" } {
    1164             continue
    1165         }
    11661170        puts $f "xyprint \"$tool\" \"$plot\" \{"
    11671171        puts $f "$_savedSettings($key)"
    11681172        puts $f "\}\n"
    11691173    }
    1170     # Now write the new setting
    1171     puts $f "xyprint \"$toolName\" \"$plotName\" \{"
    1172     puts $f "$out"
    1173     puts $f "\}\n"
    11741174    close $f
    11751175}
     
    11781178    # Create stanza associated with tool and plot title.
    11791179    # General settings
    1180     append out "\n"
    1181     append out "xyprint \"\$toolName\" \"\$plotName\" \{\n"
    11821180    append out "  set general(format) $_settings($this-general-format)\n"
    11831181    append out "  set general(style) $_settings($this-general-style)\n"
    11841182    append out "  set general(remember) 1\n"
    11851183
     1184    foreach font [array names _fonts] {
     1185        append out "  font configure $font \\\n"
     1186        array unset info
     1187        array set info [font configure $font]
     1188        append out "    -family \"$info(-family)\" \\\n"
     1189        append out "    -size \"$info(-size)\" \\\n"
     1190        append out "    -weight \"$info(-weight)\" \\\n"
     1191        append out "    -slant \"$info(-slant)\" \n"
     1192    }
     1193
    11861194    # Layout settings
    11871195    append out "  xygraph configure \\\n"
    1188     append out "    -width \"[Pixels2Inches [$_clone cget -width]]\" \\\n"
    1189     append out "    -height \"[Pixels2Inches [$_clone cget -height]]\" \\\n"
    1190     append out "    -leftmargin \"[Pixels2Inches [$_clone cget -leftmargin]]\" \\\n"
    1191     append out "    -rightmargin \"[Pixels2Inches [$_clone cget -rightmargin]]\" \\\n"
    1192     append out "    -topmargin \"[Pixels2Inches [$_clone cget -topmargin]]\" \\\n"
    1193     append out "    -bottommargin \"[Pixels2Inches [$_clone cget -bottommargin]]\"\\\n"
    1194     append out "    -plotpadx \"[Pixels2Inches [$_clone cget -plotpadx]]\" \\\n"
    1195     append out "    -plotpady \"[Pixels2Inches [$_clone cget -plotpady]]\" \n"
     1196    append out "    -width \"[$_clone cget -width]\" \\\n"
     1197    append out "    -height \"[$_clone cget -height]\" \\\n"
     1198    append out "    -leftmargin \"[$_clone cget -leftmargin]\" \\\n"
     1199    append out "    -rightmargin \"[$_clone cget -rightmargin]\" \\\n"
     1200    append out "    -topmargin \"[$_clone cget -topmargin]\" \\\n"
     1201    append out "    -bottommargin \"[$_clone cget -bottommargin]\"\\\n"
     1202    append out "    -plotpadx \"[$_clone cget -plotpadx]\" \\\n"
     1203    append out "    -plotpady \"[$_clone cget -plotpady]\" \n"
    11961204
    11971205    # Legend settings
     
    12001208    append out "    -anchor \"[$_clone legend cget -anchor]\" \\\n"
    12011209    append out "    -borderwidth \"[$_clone legend cget -borderwidth]\" \\\n"
     1210    append out "    -font legend \\\n"
    12021211    append out "    -hide \"[$_clone legend cget -hide]\" \n"
    12031212   
     
    12251234        append out "      -max \"[$_clone axis cget $axis -max]\" \\\n"
    12261235        append out "      -loose \"[$_clone axis cget $axis -loose]\" \\\n"
     1236        append out "      -tickfont \"$axis-ticks\" \\\n"
    12271237        append out "      -title \"[$_clone axis cget $axis -title]\" \\\n"
     1238        append out "      -titlefont \"$axis-title\" \\\n"
    12281239        append out "      -stepsize \"[$_clone axis cget $axis -stepsize]\" \\\n"
    12291240        append out "      -subdivisions \"[$_clone axis cget $axis -subdivisions]\"\n"
     
    12321243        append out "  \}\n"
    12331244    }   
     1245
    12341246    append out "  xygraph grid configure \\\n"
    12351247    append out "    -hide \"[$_clone grid cget -hide]\" \\\n"
    12361248    append out "    -mapx \"[$_clone grid cget -mapx]\" \\\n"
    12371249    append out "    -mapy \"[$_clone grid cget -mapy]\"\n"
    1238     append out "\}\n"
    12391250    return $out
    12401251}
Note: See TracChangeset for help on using the changeset viewer.