# $XConsortium: fdemo,v 1.2 94/04/01 16:33:17 matt Exp $ # This dish script demonstrates some Fresco widgets # # -------------- utility routines # # return a label containing the string proc label {s} { global figure_kit figure_kit label [figure_kit default_style] s } # print a strig to stdout proc print {s} { puts $s flush stdout } # compose the 5 glyphs into a vbox proc v_box {g0 g1 g2 g3 g4} { global layout_kit set b [layout_kit vbox] b append g0 b append g1 b append g2 b append g3 b append g4 return $b } # add an item to a row proc add_panel {row title item} { global layout_kit panel_size set fil [layout_kit _get_fil] set g [ layout_kit margin_lrbt_flexible $item \ 0.0 fil 0.0 0.0 fil 0.0 \ 0.0 [expr 0.5 * $fil] 0.0 0.0 [expr 0.5 * $fil] 0.0 \ ] row append [ layout_kit center [ layout_kit fixed g panel_size panel_size ] ] } # # ---------------- panels # # normal and rotated text (rotated text needs transform setter) proc labels {} { global layout_kit set b [layout_kit vbox] b append [label "Normal text"] return $b } proc push_button {s action} { global widget_kit widget_kit push_button [label $s] action } proc h_center {g} { global layout_kit layout_kit hcenter g } proc push_buttons {} { global layout_kit vspace2 set b0 [push_button "Do nothing" 0] set b1 [push_button "Disable" 0] set b2 [push_button "Quit" [action exit]] # disable second button [b1 _get_state] clear 0 v_box [h_center $b0] $vspace2 [h_center $b1] $vspace2 [h_center $b2] } proc check_box {s} { global widget_kit widget_kit check_box [label $s] [action print $s] } proc check_boxes {} { global vspace2 set b0 [check_box "Column A"] set b1 [check_box "Column B"] set b2 [check_box "Column C"] set s [b2 _get_state] # set chosen s set 3 # clear enabled s clear 0 v_box $b0 $vspace2 $b1 $vspace2 $b2 } proc radio_button {s group} { global widget_kit widget_kit radio_button [label $s] [action print $s] group } proc radio_buttons {} { global widget_kit vspace2 set g [widget_kit telltale_group] set b0 [radio_button "Able" $g] set b1 [radio_button "Baker" $g] set b2 [radio_button "Charlie" $g] v_box $b0 $vspace2 $b1 $vspace2 $b2 } proc palette_button {s} { global widget_kit widget_kit palette_button [label $s] [action print $s] } proc palette_buttons {} { global vspace2 set b0 [palette_button "One"] set b1 [palette_button "Two"] set b2 [palette_button "Three"] v_box $b0 $vspace2 $b1 $vspace2 $b2 } proc panner {x_adj y_adj} { global layout_kit widget_kit panel_size set size [expr $panel_size - 10.0] layout_kit fixed [widget_kit panner x_adj y_adj] size size } proc hscroll_bar {adjustment} { global layout_kit panel_size widget_kit layout_kit vcenter [ layout_kit hfixed [ widget_kit scroll_bar 0 adjustment ] [ expr $panel_size - 8.0 ] ] } proc vscroll_bar {adjustment} { global layout_kit panel_size widget_kit layout_kit hcenter [ layout_kit vfixed [ widget_kit scroll_bar 1 adjustment ] [ expr $panel_size - 8.0 ] ] } # # ------------- global variables # set panel_size 120 set x_adjustment [widget_kit bounded_float 0.0 100.0 50.0] set y_adjustment [widget_kit bounded_float 0.0 100.0 50.0] set vspace2 [layout_kit vspace 2.0] set row1 [layout_kit hbox] set row2 [layout_kit hbox] set row3 [layout_kit hbox] set body [layout_kit vbox] # # -------------- main routine # add_panel $row1 "Labels" [labels] add_panel $row1 "Push buttons" [push_buttons] add_panel $row1 "Check boxes" [check_boxes] add_panel $row2 "Radio buttons" [radio_buttons] add_panel $row2 "Palette buttons" [palette_buttons] add_panel $row3 "Panner" [panner $x_adjustment $y_adjustment] add_panel $row3 "HScrollbar" [hscroll_bar $x_adjustment] add_panel $row3 "VScrollbar" [vscroll_bar $y_adjustment] body append row1 body append row2 body append row3 main 0 body