diff options
Diffstat (limited to 'tix/demos')
89 files changed, 7442 insertions, 0 deletions
diff --git a/tix/demos/MkChoose.tcl b/tix/demos/MkChoose.tcl new file mode 100644 index 00000000000..edb8e7a9b95 --- /dev/null +++ b/tix/demos/MkChoose.tcl @@ -0,0 +1,279 @@ +# MkChoose.tcl -- +# +# This file implements the "Choosers" page in the widget demo +# +# This file has not been properly documented. It is NOT intended +# to be used as an introductory demo program about Tix +# programming. For such demos, please see the files in the +# demos/samples directory or go to the "Samples" page in the +# "widget demo" +# +# +# Copyright (c) 1996, Expert Interface Technologies +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + + + +proc MkChoosers {nb page} { + set w [$nb subwidget $page] + + set name [tixOptionName $w] + option add *$name*TixLabelFrame*label.padX 4 + + tixLabelFrame $w.til -label "Chooser Widgets" + tixLabelFrame $w.cbx -label "tixComboBox" + tixLabelFrame $w.ctl -label "tixControl" + tixLabelFrame $w.sel -label "tixSelect" + tixLabelFrame $w.opt -label "tixOptionMenu" + tixLabelFrame $w.fil -label "tixFileEntry" + tixLabelFrame $w.fbx -label "tixFileSelectBox" + tixLabelFrame $w.tbr -label "Tool Bar" + + MkTitle [$w.til subwidget frame] + MkCombo [$w.cbx subwidget frame] + MkControl [$w.ctl subwidget frame] + MkSelect [$w.sel subwidget frame] + MkOptMenu [$w.opt subwidget frame] + MkFileBox [$w.fbx subwidget frame] + MkFileEnt [$w.fil subwidget frame] + MkToolBar [$w.tbr subwidget frame] + + # + # First column: comBox and selector + tixForm $w.cbx -top 0 -left 0 -right %33 + tixForm $w.sel -left 0 -right &$w.cbx -top $w.cbx + tixForm $w.opt -left 0 -right &$w.cbx -top $w.sel -bottom -1 + + # + # Second column: title .. etc + tixForm $w.til -left $w.cbx -right %66 -top 0 + tixForm $w.ctl -left $w.cbx -right &$w.til -top $w.til + tixForm $w.fil -left $w.cbx -right &$w.til -top $w.ctl + tixForm $w.tbr -left $w.cbx -right &$w.til -top $w.fil -bottom -1 + + # + # Third column: file selection + tixForm $w.fbx -left %66 -right -1 -top 0 +} + +#---------------------------------------------------------------------- +# ComboBox +#---------------------------------------------------------------------- +proc MkCombo {w} { + set name [tixOptionName $w] + option add *$name*TixComboBox*label.width 10 + option add *$name*TixComboBox*label.anchor e + option add *$name*TixComboBox*entry.width 14 + + tixComboBox $w.static -label "Static" \ + -editable false + tixComboBox $w.editable -label "Editable" \ + -editable true + tixComboBox $w.history -label "History" \ + -editable true -history true -anchor e + + $w.static insert end January + $w.static insert end February + $w.static insert end March + $w.static insert end April + $w.static insert end May + $w.static insert end June + $w.static insert end July + $w.static insert end August + $w.static insert end September + $w.static insert end October + $w.static insert end November + $w.static insert end December + + $w.editable insert end "America" + $w.editable insert end "Britain" + $w.editable insert end "China" + $w.editable insert end "Denmark" + $w.editable insert end "Egypt" + + $w.history insert end "/usr/bin/mail" + $w.history insert end "/etc/profile" + $w.history insert end "/home/d/doe/Mail/letter" + + pack $w.static $w.editable $w.history -side top -padx 5 -pady 3 +} + +#---------------------------------------------------------------------- +# The Control widgets +#---------------------------------------------------------------------- +set states {Alabama "New York" Pennsylvania Washington} + +proc stCmd {w by value} { + global states + + set index [lsearch $states $value] + set len [llength $states] + set index [expr $index + $by] + + if {$index < 0} { + set index [expr $len -1] + } + if {$index >= $len} { + set index 0 + } + + return [lindex $states $index] +} + +proc stValidate {w value} { + global states + + if {[lsearch $states $value] == -1} { + return [lindex $states 0] + } else { + return $value + } +} + +proc MkControl {w} { + set name [tixOptionName $w] + option add *$name*TixControl*label.width 10 + option add *$name*TixControl*label.anchor e + option add *$name*TixControl*entry.width 13 + + + tixControl $w.simple -label Numbers + + tixControl $w.spintext -label States \ + -incrcmd "stCmd $w.spintext 1" \ + -decrcmd "stCmd $w.spintext -1" \ + -validatecmd "stValidate .d" \ + -value "Alabama" + + pack $w.simple $w.spintext -side top -padx 5 -pady 3 +} + +#---------------------------------------------------------------------- +# The Select Widgets +#---------------------------------------------------------------------- +proc MkSelect {w} { + set name [tixOptionName $w] + option add *$name*TixSelect*label.anchor c + option add *$name*TixSelect*orientation vertical + option add *$name*TixSelect*labelSide top + + tixSelect $w.sel1 -label "Mere Mortals" -allowzero true -radio true + tixSelect $w.sel2 -label "Geeks" -allowzero true -radio false + + $w.sel1 add eat -text Eat + $w.sel1 add work -text Work + $w.sel1 add play -text Play + $w.sel1 add party -text Party + $w.sel1 add sleep -text Sleep + + $w.sel2 add eat -text Eat + $w.sel2 add prog1 -text Program + $w.sel2 add prog2 -text Program + $w.sel2 add prog3 -text Program + $w.sel2 add sleep -text Sleep + + pack $w.sel1 $w.sel2 -side left -padx 5 -pady 3 -fill x +} +#---------------------------------------------------------------------- +# The OptMenu Widget +#---------------------------------------------------------------------- +proc MkOptMenu {w} { + set name [tixOptionName $w] + + option add *$name*TixOptionMenu*label.anchor e + + tixOptionMenu $w.menu -label "File Format : " \ + -options { + menubutton.width 15 + } + + $w.menu add command text -label "Plain Text" + $w.menu add command post -label "PostScript" + $w.menu add command format -label "Formatted Text" + $w.menu add command html -label "HTML" + $w.menu add separator sep + $w.menu add command tex -label "LaTeX" + $w.menu add command rtf -label "Rich Text Format" + + pack $w.menu -padx 5 -pady 3 -fill x +} + +#---------------------------------------------------------------------- +# FileEntry +#---------------------------------------------------------------------- +proc MkFileEnt {w} { + set name [tixOptionName $w] + + message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 240 -anchor n\ + -text {Press the "open file" icon button and a\ +TixFileSelectDialog will popup.} + + tixFileEntry $w.ent -label "Select a file : " + + pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3 + pack $w.ent -side top -fill x -padx 3 -pady 3 +} + +proc MkFileBox {w} { + set name [tixOptionName $w] + + message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 240 -anchor n\ + -text {The TixFileSelectBox is Motif-style file selection\ +box with various enhancements. For example, you can adjust the\ +size of the two listboxes and your past selections are recorded.} + + tixFileSelectBox $w.box + + pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3 + pack $w.box -side top -fill x -padx 3 -pady 3 +} + +#---------------------------------------------------------------------- +# Tool Bar +#---------------------------------------------------------------------- +proc MkToolBar {w} { + set name [tixOptionName $w] + + option add $name*TixSelect*frame.borderWidth 1 + message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 240 -anchor n\ + -text {The Select widget is also good for arranging buttons\ +in a tool bar.} + + frame $w.bar -bd 2 -relief raised + tixSelect $w.font -allowzero true -radio false -label {} + tixSelect $w.para -allowzero false -radio true -label {} + + $w.font add bold -bitmap [tix getbitmap bold] + $w.font add italic -bitmap [tix getbitmap italic] + $w.font add underline -bitmap [tix getbitmap underlin] + $w.font add capital -bitmap [tix getbitmap capital] + + $w.para add left -bitmap [tix getbitmap leftj] + $w.para add right -bitmap [tix getbitmap rightj] + $w.para add center -bitmap [tix getbitmap centerj] + $w.para add justify -bitmap [tix getbitmap justify] + + pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3 + pack $w.bar -side top -fill x -padx 3 -pady 3 + pack $w.para $w.font -in $w.bar -side left -padx 4 -pady 3 +} +#---------------------------------------------------------------------- +# Title +#---------------------------------------------------------------------- +proc MkTitle {w} { + set name [tixOptionName $w] + + option add $name*TixSelect*frame.borderWidth 1 + message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 240 -anchor n\ + -text {There are many types of "choose" widgets that allow\ +the user to input different type of information.} + + pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3 +} diff --git a/tix/demos/MkDirLis.tcl b/tix/demos/MkDirLis.tcl new file mode 100644 index 00000000000..89b0edae5a7 --- /dev/null +++ b/tix/demos/MkDirLis.tcl @@ -0,0 +1,65 @@ +# MkDirLis.tcl -- +# +# This file implements the "Directory List" page in the widget demo +# +# This file has not been properly documented. It is NOT intended +# to be used as an introductory demo program about Tix +# programming. For such demos, please see the files in the +# demos/samples directory or go to the "Samples" page in the +# "widget demo" +# +# +# Copyright (c) 1996, Expert Interface Technologies +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + +proc MkDirList {nb page} { + set w [$nb subwidget $page] + + set name [tixOptionName $w] + option add *$name*TixLabelFrame*label.padX 4 + + tixLabelFrame $w.dir -label "tixDirList" + tixLabelFrame $w.fsbox -label "tixExFileSelectBox" + MkDirListWidget [$w.dir subwidget frame] + MkExFileWidget [$w.fsbox subwidget frame] + + tixForm $w.dir -top 0 -left 0 -right %40 -bottom -1 + tixForm $w.fsbox -top 0 -left %40 -right -1 -bottom -1 +} + +proc MkDirListWidget {w} { + set name [tixOptionName $w] + + message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 240 -anchor n\ + -text {The TixDirList widget gives a graphical representation of \ +the file system directory and makes it easy for the user to choose and \ +access directories.} + + tixDirList $w.dirlist -options { + hlist.padY 1 + hlist.width 25 + hlist.height 16 + } + + pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3 + pack $w.dirlist -side top -padx 3 -pady 3 +} + +proc MkExFileWidget {w} { + set name [tixOptionName $w] + + message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 240 -anchor n\ + -text {The TixExFileSelectBox widget is more user friendly \ +than the Motif style FileSelectBox.} + + tixExFileSelectBox $w.exfsbox -bd 2 -relief raised + + pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3 + pack $w.exfsbox -side top -padx 3 -pady 3 +} + diff --git a/tix/demos/MkManag.tcl b/tix/demos/MkManag.tcl new file mode 100644 index 00000000000..045aacbdebc --- /dev/null +++ b/tix/demos/MkManag.tcl @@ -0,0 +1,171 @@ +# MkManag.tcl -- +# +# This file implements the "Manager" page in the widget demo +# +# This file has not been properly documented. It is NOT intended +# to be used as an introductory demo program about Tix +# programming. For such demos, please see the files in the +# demos/samples directory or go to the "Samples" page in the +# "widget demo" +# +# +# Copyright (c) 1996, Expert Interface Technologies +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + +proc MkManager {nb page} { + set w [$nb subwidget $page] + + set name [tixOptionName $w] + option add *$name*TixLabelFrame*label.padX 4 + + tixLabelFrame $w.pane -label "tixPanedWindow" + tixLabelFrame $w.note -label "tixNoteBook" + + MkPanedWindow [$w.pane subwidget frame] + MkNoteBook [$w.note subwidget frame] + + tixForm $w.pane -top 0 -left 0 -right $w.note -bottom -1 + tixForm $w.note -top 0 -right -1 -bottom -1 +} + +proc MkPanedWindow {w} { + set name [tixOptionName $w] + + message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 240 -anchor n\ + -text {The PanedWindow widget allows the user to interactively\ +manipulate the\ +sizes of several panes. The panes can be arranged either vertically or\ +horizontally.} + + label $w.group -text "Newsgroup: comp.lang.tcl" + + tixPanedWindow $w.pane + + set p1 [$w.pane add list -min 70 -size 100] + set p2 [$w.pane add text -min 70] + + tixScrolledListBox $p1.list + $p1.list subwidget listbox config -font [tix option get fixed_font] + + tixScrolledText $p2.text + $p2.text subwidget text config -font [tix option get fixed_font] + + $p1.list subwidget listbox insert end \ + " 12324 Re: TK is good for your health" \ + "+ 12325 Re: TK is good for your health" \ + "+ 12326 Re: Tix is even better for your health (Was: TK is good...)" \ + " 12327 Re: Tix is even better for your health (Was: TK is good...)" \ + "+ 12328 Re: Tix is even better for your health (Was: TK is good...)" \ + " 12329 Re: Tix is even better for your health (Was: TK is good...)" \ + "+ 12330 Re: Tix is even better for your health (Was: TK is good...)" + + $p2.text subwidget text config -wrap none -bg \ + [$p1.list subwidget listbox cget -bg] + $p2.text subwidget text insert end { +Mon, 19 Jun 1995 11:39:52 comp.lang.tcl Thread 34 of 220 +Lines 353 A new way to put text and bitmaps together iNo responses +ioi@xpi.com Ioi K. Lam at Expert Interface Technologies + +Hi, + +I have implemented a new image type called "compound". It allows you +to glue together a bunch of bitmaps, images and text strings together +to form a bigger image. Then you can use this image with widgets that +support the -image option. This way you can display very fancy stuffs +in your GUI. For example, you can display a text string string +together with a bitmap, at the same time, inside a TK button widget. A +screenshot of compound images can be found at the bottom of this page: + + http://www.xpi.com/tix/screenshot.html + +You can also you is in other places such as putting fancy bitmap+text +in menus, tabs of tixNoteBook widgets, etc. This feature will be +included in the next release of Tix (4.0b1). Count on it to make jazzy +interfaces!} + + pack $p1.list -expand yes -fill both -padx 4 -pady 6 + pack $p2.text -expand yes -fill both -padx 4 -pady 6 + + pack $w.msg -side top -padx 3 -pady 3 -fill both + pack $w.group -side top -padx 3 -pady 3 -fill both + pack $w.pane -side top -padx 3 -pady 3 -expand yes -fill both +} + +proc MkNoteBook {w} { + + message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 240 -anchor n\ + -text {The NoteBook widget allows you to lay out a complex\ +interface into individual pages.} + + # We use these options to set the sizes of the subwidgets inside the + # notebook, so that they are well-aligned on the screen. + # + set name [tixOptionName $w] + option add *$name*TixControl*entry.width 10 + option add *$name*TixControl*label.width 18 + option add *$name*TixControl*label.anchor e + option add *$name*TixNoteBook*tagPadX 8 + + + tixNoteBook $w.nb -ipadx 6 -ipady 6 + + # Create the two tabs on the notebook. The -underline option + # puts a underline on the first character of the labels of the tabs. + # Keyboard accelerators will be defined automatically according + # to the underlined character. + # + $w.nb add hard_disk -label "Hard Disk" -underline 8 + $w.nb add network -label "Network" -underline 0 + + # Create the first page + # + set f [$w.nb subwidget hard_disk] + + # the frame for the buttons that are present in all the pages + # + frame $f.common + pack $f.common -side right -padx 2 -pady 2 -fill y + CreateCommonButtons $w $f.common + + + # Create the controls that only belong to this page + # + tixControl $f.a -value 12 -label "Access Time: " + tixControl $f.w -value 400 -label "Write Throughput: " + tixControl $f.r -value 400 -label "Read Throughput: " + tixControl $f.c -value 1021 -label "Capacity: " + pack $f.a $f.w $f.r $f.c -side top -padx 20 -pady 2 + + # Create the second page + # + set f [$w.nb subwidget network] + + # the frame for the buttons that are present in all the pages + # + frame $f.common + pack $f.common -side right -padx 2 -pady 2 -fill y + + tixControl $f.a -value 12 -label "Access Time: " + tixControl $f.w -value 400 -label "Write Throughput: " + tixControl $f.r -value 400 -label "Read Throughput: " + tixControl $f.c -value 1021 -label "Capacity: " + tixControl $f.u -value 10 -label "Users: " + + CreateCommonButtons $w $f.common + + pack $f.a $f.w $f.r $f.c $f.u -side top -padx 20 -pady 2 + pack $w.msg -side top -padx 3 -pady 3 -fill both + pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top + } + +proc CreateCommonButtons {w f} { + button $f.ok -text OK -width 6 + button $f.cancel -text Cancel -width 6 + + pack $f.ok $f.cancel -side top -padx 2 -pady 2 +} diff --git a/tix/demos/MkSample.tcl b/tix/demos/MkSample.tcl new file mode 100644 index 00000000000..20ca11753db --- /dev/null +++ b/tix/demos/MkSample.tcl @@ -0,0 +1,269 @@ +# MkSample.tcl -- +# +# This file implements the "Sample" page in the widget demo +# +# This file has not been properly documented. It is NOT intended +# to be used as an introductory demo program about Tix +# programming. For such demos, please see the files in the +# demos/samples directory or go to the "Samples" page in the +# "widget demo" +# +# +# Copyright (c) 1996, Expert Interface Technologies +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# +# +# + +set tix_demo_running 1 +set samples_dir [tixNSubFolder $demo_dir samples] +set sample_filename {} + +uplevel #0 source [list [tixNSubFolder $samples_dir AllSampl.tcl]] + + +proc MkSample {nb page} { + global tixOption + + #---------------------------------------------------------------------- + set w [$nb subwidget $page] + + set pane [tixPanedWindow $w.pane -orient horizontal] + pack $pane -expand yes -fill both + + set f1 [$pane add 1 -expand 1] + set f2 [$pane add 2 -expand 3] + $f1 config -relief flat + $f2 config -relief flat + + # Left pane: the Tree: + # + set lab [label $f1.lab -text "Select a sample program:" -anchor w] + set tree [tixTree $f1.slb \ + -options { + hlist.selectMode single + hlist.width 40 + }] + $tree config \ + -command "Sample:Action $w $tree run" \ + -browsecmd "Sample:Action $w $tree browse" + + pack $lab -side top -fill x -padx 5 -pady 5 + pack $tree -side top -fill both -expand yes -padx 5 + + # Right pane: the Text + # + set labe [tixLabelEntry $f2.lab -label "Source:" -options { + label.anchor w + }] + + $labe subwidget entry config -state disabled + + set stext [tixScrolledText $f2.stext] + set f3 [frame $f2.f3] + + set run [button $f3.run -text "Run ..." \ + -command "Sample:Action $w $tree run"] + set view [button $f3.view -text "View Source in Browser ..." \ + -command "Sample:Action $w $tree view"] + + pack $run $view -side left -fill y -pady 2 + + pack $labe -side top -fill x -padx 7 -pady 2 + pack $f3 -side bottom -fill x -padx 7 + pack $stext -side top -fill both -expand yes -padx 7 + + # + # Set up the text subwidget + + set text [$stext subwidget text] + bind $text <1> "focus %W" + bind $text <Up> "%W yview scroll -1 unit" + bind $text <Down> "%W yview scroll 1 unit" + bind $text <Left> "%W xview scroll -1 unit" + bind $text <Right> "%W xview scroll 1 unit" + bind $text <Tab> {focus [tk_focusNext %W]; break} + + bindtags $text "$text Text [winfo toplevel $text] all" + + $text config -bg [$tree subwidget hlist cget -bg] \ + -state disabled -font $tixOption(fixed_font) -wrap none + + $run config -state disabled + $view config -state disabled + + global demo + set demo(w:run) $run + set demo(w:view) $view + set demo(w:tree) $tree + set demo(w:lab1) $labe + set demo(w:stext) $stext + + set hlist [$tree subwidget hlist] + $hlist config -separator "." -width 30 -drawbranch 0 \ + -wideselect false + + set style [tixDisplayStyle imagetext -refwindow $hlist \ + -fg #202060 -padx 4] + + uplevel #0 set TRANSPARENT_GIF_COLOR [$hlist cget -bg] + + set file [tix getimage textfile] + set folder [tix getimage openfold] + + ForAllSamples root "" \ + [list AddSampleToHList $tree $hlist $style $file $folder] +} + +# AddSampleToHList -- +# +# A callback from ForAllSamples. Add all the possible sample files +# into the Tree widget. +# +proc AddSampleToHList {tree hlist style file folder token type text dest} { + case $type { + d { + return [$hlist addchild $token -itemtype imagetext -style $style \ + -image $folder -text $text] + } + done { + if {![tixStrEq $token ""]} { + $tree setmode $token close + $tree close $token + } + } + f { + return [$hlist addchild $token -itemtype imagetext \ + -image $file -text $text -data [list $text $dest]] + } + } +} + +proc Sample:Action {w slb action args} { + global samples demo_dir demo samples_dir + + set hlist [$slb subwidget hlist] + set ent [$hlist info anchor] + + if {$ent == ""} { + $demo(w:run) config -state disabled + $demo(w:view) config -state disabled + return + } + if {[$hlist info data $ent] == {}} { + # This is just a comment + $demo(w:run) config -state disabled + $demo(w:view) config -state disabled + return + } else { + $demo(w:run) config -state normal + $demo(w:view) config -state normal + } + + set theSample [$hlist info data $ent] + set title [lindex $theSample 0] + set prog [lindex $theSample 1] + + case $action { + "run" { + RunProg $title $prog + } + "view" { + LoadFile [tixNSubFolder $samples_dir $prog] + } + "browse" { + # Bring up a short description of the sample program + # in the scrolled text about + + set text [$demo(w:stext) subwidget text] + uplevel #0 set sample_filename [list [tixNSubFolder $samples_dir $prog]] + tixWidgetDoWhenIdle ReadFileWhenIdle $text + + $demo(w:lab1) subwidget entry config -state normal + $demo(w:lab1) subwidget entry delete 0 end + $demo(w:lab1) subwidget entry insert end [tixNSubFolder $samples_dir $prog] + $demo(w:lab1) subwidget entry xview end + $demo(w:lab1) subwidget entry config -state disabled + } + } +} + +proc RunProg {title prog} { + global samples demo_dir demo samples_dir + + set w .[lindex [split $prog .] 0] + set w [string tolower $w] + + if [winfo exists $w] { + wm deiconify $w + raise $w + return + } + + uplevel #0 source [list [tixNSubFolder $samples_dir $prog]] + + toplevel $w + wm title $w $title + RunSample $w +} + + +proc LoadFile {filename} { + global tixOption + + set tmp $filename + regsub -all . $filename _ tmp + set w [string tolower .$tmp] + + if [winfo exists $w] { + wm deiconify $w + raise $w + return + } + + toplevel $w + wm title $w "Source View: $filename" + + button $w.b -text Close -command "destroy $w" + set t [tixScrolledText $w.text] + tixForm $w.b -left 0 -bottom -0 -padx 4 -pady 4 + tixForm $w.text -left 0 -right -0 -top 0 -bottom $w.b + + $t subwidget text config -highlightcolor [$t cget -bg] -bd 2 \ + -bg [$t cget -bg] -font $tixOption(fixed_font) + if {$filename == {}} { + return + } + + set text [$w.text subwidget text] + $text config -wrap none + + ReadFile $text $filename +} + +proc ReadFileWhenIdle {text} { + global sample_filename + + if ![file isdir $sample_filename] { + ReadFile $text $sample_filename + } +} + +proc ReadFile {text filename} { + set oldState [$text cget -state] + $text config -state normal + $text delete 0.0 end + + set fd [open $filename {RDONLY}] + $text delete 1.0 end + + while {![eof $fd]} { + $text insert end [gets $fd]\n + } + close $fd + + $text see 1.0 + $text config -state $oldState +} diff --git a/tix/demos/MkScroll.tcl b/tix/demos/MkScroll.tcl new file mode 100644 index 00000000000..cd4850cee34 --- /dev/null +++ b/tix/demos/MkScroll.tcl @@ -0,0 +1,156 @@ +# MkScroll.tcl -- +# +# This file implements the "Scrolled Widgets" page in the widget demo +# +# This file has not been properly documented. It is NOT intended +# to be used as an introductory demo program about Tix +# programming. For such demos, please see the files in the +# demos/samples directory or go to the "Samples" page in the +# "widget demo" +# +# +# Copyright (c) 1996, Expert Interface Technologies +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + +proc MkScroll {nb page} { + set w [$nb subwidget $page] + + set name [tixOptionName $w] + option add *$name*TixLabelFrame*label.padX 4 + + tixLabelFrame $w.sls -label "tixScrolledListBox" + tixLabelFrame $w.swn -label "tixScrolledWindow" + tixLabelFrame $w.stx -label "tixScrolledText" + MkSList [$w.sls subwidget frame] + + MkSText [$w.stx subwidget frame] + MkSWindow [$w.swn subwidget frame] + + tixForm $w.sls -top 0 -left 0 -right %33 -bottom -1 + tixForm $w.swn -top 0 -left $w.sls -right %66 -bottom -1 + tixForm $w.stx -top 0 -left $w.swn -right -1 -bottom -1 +} + +#---------------------------------------------------------------------- +# ScrolledListBox +#---------------------------------------------------------------------- +proc MkSList {w} { + frame $w.top -width 300 -height 330 + frame $w.bot + + message $w.top.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 200 -anchor n\ + -text {This TixScrolledListBox is configured so that it uses\ +scrollbars only when it is necessary. Use the handles to\ +resize the listbox and watch the scrollbars automatically\ +appear and disappear.} + + set list [tixScrolledListBox $w.top.list -scrollbar auto] + place $list -x 50 -y 150 -width 120 -height 80 + $list subwidget listbox insert end Alabama + $list subwidget listbox insert end California + $list subwidget listbox insert end Montana + $list subwidget listbox insert end "New Jersy" + $list subwidget listbox insert end "New York" + $list subwidget listbox insert end Pennsylvania + $list subwidget listbox insert end Washington + + set rh [tixResizeHandle $w.top.r -bg #202060 -relief raised \ + -handlesize 8 -gridded true -minwidth 50 -minheight 30] + + button $w.bot.btn -text Reset -command "SList:Reset $rh $list" + pack propagate $w.top 0 + pack $w.top.msg -fill x + pack $w.bot.btn -anchor c + pack $w.top -expand yes -fill both + pack $w.bot -fill both + + bind $list <Map> "tixDoWhenIdle $rh attachwidget $list" +} + +proc SList:Reset {rh list} { + place $list -x 50 -y 150 -width 120 -height 80 + update + $rh attachwidget $list +} + +#---------------------------------------------------------------------- +# ScrolledWindow +#---------------------------------------------------------------------- +proc MkSWindow {w} { + global demo_dir + frame $w.top -width 330 -height 330 + frame $w.bot + + message $w.top.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 200 -anchor n\ + -text {The TixScrolledWindow widget allows you\ +to scroll any kind of TK widget. It is more versatile\ +than a scrolled canvas widget} + + set win [tixScrolledWindow $w.top.win -scrollbar auto] + set f [$win subwidget window] + set image [image create photo -file $demo_dir/bitmaps/tix.gif] + + label $f.b1 -image $image + + pack $f.b1 -expand yes -fill both + + place $win -x 30 -y 150 -width 190 -height 120 + set rh [tixResizeHandle $w.top.r -bg #202060 -relief raised \ + -handlesize 8 -gridded true -minwidth 50 -minheight 30] + + button $w.bot.btn -text Reset -command "SWindow:Reset $rh $win" + pack propagate $w.top 0 + pack $w.top.msg -fill x + pack $w.bot.btn -anchor c + pack $w.top -expand yes -fill both + pack $w.bot -fill both + + bind $win <Map> "tixDoWhenIdle $rh attachwidget $win" +} + +proc SWindow:Reset {rh win} { + place $win -x 30 -y 150 -width 190 -height 120 + update + $rh attachwidget $win +} + +#---------------------------------------------------------------------- +# ScrolledText +#---------------------------------------------------------------------- +proc MkSText {w} { + frame $w.top -width 330 -height 330 + frame $w.bot + + message $w.top.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -relief flat -width 200 -anchor n\ + -text {The TixScrolledWindow widget allows you\ +to scroll any kind of TK widget. It is more versatile\ +than a scrolled canvas widget} + + set win [tixScrolledText $w.top.win -scrollbar both] + $win subwidget text config -wrap none + + place $win -x 30 -y 150 -width 190 -height 100 + set rh [tixResizeHandle $w.top.r -bg #202060 -relief raised \ + -handlesize 8 -gridded true -minwidth 50 -minheight 30] + + button $w.bot.btn -text Reset -command "SText:Reset $rh $win" + pack propagate $w.top 0 + pack $w.top.msg -fill x + pack $w.bot.btn -anchor c + pack $w.top -expand yes -fill both + pack $w.bot -fill both + + bind $win <Map> "tixDoWhenIdle $rh attachwidget $win" +} + +proc SText:Reset {rh win} { + place $win -x 30 -y 150 -width 190 -height 100 + update + $rh attachwidget $win +} diff --git a/tix/demos/README b/tix/demos/README new file mode 100644 index 00000000000..aff0bbbaed1 --- /dev/null +++ b/tix/demos/README @@ -0,0 +1,24 @@ +Files in this directory +---------------------------------------------------------------------- +widget Demonstrates the widgets in Tix. This is not + intended to be an introductory sample program. + For sample programs, please see the files + under the samples/ directory. + +MkChoose.tcl Part of the "widget" demo. +MkDirLis.tcl Part of the "widget" demo. +MkManag.tcl Part of the "widget" demo. +MkSample.tcl Part of the "widget" demo. +MkScroll.tcl Part of the "widget" demo. +tclIndex index file for the "widget" demo. +bitmaps/ Contains bitmaps used by "widget". + +c-code/ Demonstrates how to link Tix with applications + written in C. + +et/ Currently empty. + +samples/ Sample Tix programs. + + + diff --git a/tix/demos/bitmaps/about.xpm b/tix/demos/bitmaps/about.xpm new file mode 100644 index 00000000000..33ffcc06ef5 --- /dev/null +++ b/tix/demos/bitmaps/about.xpm @@ -0,0 +1,50 @@ +/* XPM */ +static char * about_xpm[] = { +"50 40 7 1", +" s None c None", +". c black", +"X c white", +"o c gray70", +"O c navy", +"+ c red", +"@ c yellow", +" ", +" ", +" ", +" ................................. ", +" ..XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXoo. ", +" .XooooooooooooooooooooooooooooooXo. ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXooXo. ", +" ..oooooooooooooooooooooooooooooooXo. ", +" ...............................XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo.++++ ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo+++ ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Xo+++++ ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Xo++++++ ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Xo+++ + ", +" .OOOOO@@@@@OOOOOOOOOOOOOOOOOOO.Xo++. ", +" .OOOOOOO@OOOOO@OOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOO@OOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOO@OOOO@@OOO@OOO@OOOOOOO.XoXo. ", +" .OOOOOOO@OOOOO@OOOO@O@OOOOOOOO.XoXo. ", +" .OOOOOOO@OOOOO@OOOOO@OOOOOOOOO.XoXo. ", +" .OOOOOOO@OOOOO@OOOOO@OOOOOOOOO.XoXo. ", +" .OOOOOOO@OOOOO@OOOO@O@OOOOOOOO.XoXo. ", +" .OOOOOOO@OOOO@@@OO@OOO@OOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XoXo. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Xo.. ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Xo ", +" OOOOOOOOOOOOOOOOOOOOOOOOOOOOO.X. ", +" ............................. ", +" ", +" ", +" "}; diff --git a/tix/demos/bitmaps/bold.xbm b/tix/demos/bitmaps/bold.xbm new file mode 100644 index 00000000000..ebff8d11781 --- /dev/null +++ b/tix/demos/bitmaps/bold.xbm @@ -0,0 +1,6 @@ +#define bold_width 16 +#define bold_height 16 +static unsigned char bold_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfc, 0x07, 0xfc, 0x0f, 0x18, 0x1c, 0x18, 0x18, + 0x18, 0x18, 0x18, 0x1c, 0xf8, 0x0f, 0xf8, 0x0f, 0x18, 0x18, 0x18, 0x30, + 0x18, 0x30, 0x18, 0x38, 0xfc, 0x3f, 0xfc, 0x1f}; diff --git a/tix/demos/bitmaps/capital.xbm b/tix/demos/bitmaps/capital.xbm new file mode 100644 index 00000000000..fb4e0703b11 --- /dev/null +++ b/tix/demos/bitmaps/capital.xbm @@ -0,0 +1,6 @@ +#define capital_width 16 +#define capital_height 16 +static unsigned char capital_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x08, 0x30, 0x0c, 0x30, 0x06, + 0x30, 0x03, 0xb0, 0x01, 0xf0, 0x00, 0xf0, 0x00, 0xf0, 0x01, 0xb0, 0x03, + 0x30, 0x07, 0x30, 0x0e, 0x30, 0x1c, 0x00, 0x00}; diff --git a/tix/demos/bitmaps/centerj.xbm b/tix/demos/bitmaps/centerj.xbm new file mode 100644 index 00000000000..9d2c0648343 --- /dev/null +++ b/tix/demos/bitmaps/centerj.xbm @@ -0,0 +1,6 @@ +#define centerj_width 16 +#define centerj_height 16 +static unsigned char centerj_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x3e, 0x00, 0x00, 0xc0, 0x0d, + 0x00, 0x00, 0x58, 0x77, 0x00, 0x00, 0xb0, 0x3b, 0x00, 0x00, 0xdc, 0xf7, + 0x00, 0x00, 0xf0, 0x3e, 0x00, 0x00, 0xd8, 0x7e}; diff --git a/tix/demos/bitmaps/combobox.xbm b/tix/demos/bitmaps/combobox.xbm new file mode 100644 index 00000000000..f5947f57b4a --- /dev/null +++ b/tix/demos/bitmaps/combobox.xbm @@ -0,0 +1,14 @@ +#define combobox_width 32 +#define combobox_height 32 +static unsigned char combobox_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xfc, 0xff, 0xff, 0x3e, 0x04, 0x00, 0x80, 0x2a, 0x04, 0x00, 0x80, 0x2a, + 0x04, 0x00, 0x80, 0x2a, 0x04, 0x00, 0x80, 0x2b, 0xfc, 0xff, 0xff, 0x3e, + 0x08, 0x00, 0x00, 0x20, 0x08, 0x00, 0x00, 0x3e, 0x08, 0x00, 0x00, 0x2a, + 0x28, 0x49, 0x00, 0x2a, 0x08, 0x00, 0x00, 0x3e, 0x08, 0x00, 0x00, 0x22, + 0x08, 0x00, 0x00, 0x22, 0x28, 0x49, 0x12, 0x22, 0x08, 0x00, 0x00, 0x22, + 0x08, 0x00, 0x00, 0x22, 0x08, 0x00, 0x00, 0x22, 0x28, 0x49, 0x02, 0x22, + 0x08, 0x00, 0x00, 0x3e, 0x08, 0x00, 0x00, 0x2a, 0x08, 0x00, 0x00, 0x2a, + 0xf8, 0xff, 0xff, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/tix/demos/bitmaps/combobox.xpm b/tix/demos/bitmaps/combobox.xpm new file mode 100644 index 00000000000..d0234ab8e2d --- /dev/null +++ b/tix/demos/bitmaps/combobox.xpm @@ -0,0 +1,49 @@ +/* XPM */ +static char * combobox_xpm[] = { +"50 40 6 1", +" s None c None", +". c black", +"X c white", +"o c #FFFF80808080", +"O c gray70", +"+ c #808000008080", +" ", +" ", +" ", +" .................................... XXXXXXX ", +" .ooooooooooooooooooooooooooooooooooX X . . ", +" .ooooooooooooooooooooooooooooooooooX X . . ", +" .oooo.oooooooooooooooooooooooooooooX X . . ", +" .oo.o..oo.o.oo.o.ooooooooooooooooooX X . . ", +" .o..o.o.o.oo.oo.oo.ooooooooooooooooX X ... . ", +" .oo.oo.oo.o.oo.ooo.ooooooooooooooooX X . . ", +" .ooooooooooooooooooooooooooooooooooX X . ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX X...... ", +" ", +" ", +" ", +" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ", +" X............................................ ", +" X.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOX.OOOOX. ", +" X.O+OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOX.OX OX. ", +" X.O++OOO+OO+++OOOOOOOOOOOOOOOOOOOOOOOX.X ..X. ", +" X.O+O+O+OOO+O+OOOOOOOOOOOOOOOOOOOOOOOX.OOOOX. ", +" X.O++OOO+OO+++OOOOOOOOOOOOOOOOOOOOOOOX.OOOOX. ", +" X.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOX.XXXXX. ", +" X.O.....X..........................OOX.X .X. ", +" X.OX...XXX.X.XX.XX.................OOX.X .X. ", +" X.OX.X..X..X.XX..XX.X..............OOX.X .X. ", +" X.O.X...X..X.X...X..X..............OOX.X .X. ", +" X.OOOOOOOOOOOOOOOOOOOOOOOO+OOOOOOOOOOX.X .X. ", +" X.OOOOOOOOO+OOO+OOOOO+OOOO+OOOOOOOOOOX.X .X. ", +" X.O+++OO+OO+O+OO++O++OO+OO+OOOOOOOOOOX.X...X. ", +" X.OO+OO++OO+O+OO+OOO+OO+O++OOOOOOOOOOX.OOOOX. ", +" X.OOOOOOOO+OOOOO++OO+OOOOOOOOOOOOOOOOX.OOOOX. ", +" X.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOX.X .X. ", +" X.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOX.O .OX. ", +" X.OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOX.OOOOX. ", +" X.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.XXXXX. ", +" X............................................ ", +" ", +" ", +" "}; diff --git a/tix/demos/bitmaps/drivea.xbm b/tix/demos/bitmaps/drivea.xbm new file mode 100644 index 00000000000..83c636c6707 --- /dev/null +++ b/tix/demos/bitmaps/drivea.xbm @@ -0,0 +1,14 @@ +#define drivea_width 32 +#define drivea_height 32 +static unsigned char drivea_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf8, 0xff, 0xff, 0x1f, 0x08, 0x00, 0x00, 0x18, 0xa8, 0xaa, 0xaa, 0x1a, + 0x48, 0x55, 0xd5, 0x1d, 0xa8, 0xaa, 0xaa, 0x1b, 0x48, 0x55, 0x55, 0x1d, + 0xa8, 0xfa, 0xaf, 0x1a, 0xc8, 0xff, 0xff, 0x1d, 0xa8, 0xfa, 0xaf, 0x1a, + 0x48, 0x55, 0x55, 0x1d, 0xa8, 0xaa, 0xaa, 0x1a, 0x48, 0x55, 0x55, 0x1d, + 0xa8, 0xaa, 0xaa, 0x1a, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/tix/demos/bitmaps/drivea.xpm b/tix/demos/bitmaps/drivea.xpm new file mode 100644 index 00000000000..4d274b995f1 --- /dev/null +++ b/tix/demos/bitmaps/drivea.xpm @@ -0,0 +1,43 @@ +/* XPM */ +static char * drivea_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 5 1", +/* colors */ +" s None c None", +". c #000000000000", +"X c white", +"o c #c000c000c000", +"O c #800080008000", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .......................... ", +" .XXXXXXXXXXXXXXXXXXXXXXXo. ", +" .XooooooooooooooooooooooO. ", +" .Xooooooooooooooooo..oooO. ", +" .Xooooooooooooooooo..oooO. ", +" .XooooooooooooooooooooooO. ", +" .Xoooooooo.......oooooooO. ", +" .Xoo...................oO. ", +" .Xoooooooo.......oooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .oOOOOOOOOOOOOOOOOOOOOOOO. ", +" .......................... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/tix/demos/bitmaps/exit.xpm b/tix/demos/bitmaps/exit.xpm new file mode 100644 index 00000000000..505a07bdf69 --- /dev/null +++ b/tix/demos/bitmaps/exit.xpm @@ -0,0 +1,48 @@ +/* XPM */ +static char * exit_xpm[] = { +"50 40 5 1", +" s None c None", +". c black", +"X c white", +"o c #000080800000", +"O c yellow", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ....................................... ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. ", +" .XoooooooooooooooooooooooooooooooooooX. ", +" .XoooooooooooooooooooooooooooooooooooX. ", +" .XoooooooooooooooooooooooOoooooooooooX. ", +" .XoooooooooooooooooooooooOOooooooooooX. ", +" .XoooooooooooooooooooooooOOOoooooooooX. ", +" .XoooooOOOOOOOOOOOOOOOOOOOOOOooooooooX. ", +" .XoooooOOOOOOOOOOOOOOOOOOOOOOOoooooooX. ", +" .XoooooOOOOOOOOOOOOOOOOOOOOOOOOooooooX. ", +" .XoooooOOOOOOOOOOOOOOOOOOOOOOOOOoooooX. ", +" .XoooooOOOOOOOOOOOOOOOOOOOOOOOOooooooX. ", +" .XoooooOOOOOOOOOOOOOOOOOOOOOOOoooooooX. ", +" .XoooooOOOOOOOOOOOOOOOOOOOOOOooooooooX. ", +" .XoooooooooooooooooooooooOOOoooooooooX. ", +" .XoooooooooooooooooooooooOOooooooooooX. ", +" .XoooooooooooooooooooooooOoooooooooooX. ", +" .XoooooooooooooooooooooooooooooooooooX. ", +" .XoooooooooooooooooooooooooooooooooooX. ", +" .XoooooooooooooooooooooooooooooooooooX. ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. ", +" ....................................... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/tix/demos/bitmaps/filebox.xbm b/tix/demos/bitmaps/filebox.xbm new file mode 100644 index 00000000000..c8f7ac255bb --- /dev/null +++ b/tix/demos/bitmaps/filebox.xbm @@ -0,0 +1,14 @@ +#define filebox_width 32 +#define filebox_height 32 +static unsigned char filebox_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0xfc, 0xff, 0xff, 0x3f, 0x04, 0x00, 0x00, 0x20, + 0xe4, 0xff, 0xff, 0x27, 0x24, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x24, + 0xe4, 0xff, 0xff, 0x27, 0x04, 0x00, 0x00, 0x20, 0xe4, 0x7f, 0xfe, 0x27, + 0x24, 0x50, 0x02, 0x25, 0x24, 0x40, 0x02, 0x24, 0x24, 0x50, 0x02, 0x25, + 0x24, 0x40, 0x02, 0x24, 0x24, 0x50, 0x02, 0x25, 0x24, 0x40, 0x02, 0x24, + 0x24, 0x50, 0x02, 0x25, 0xe4, 0x7f, 0xfe, 0x27, 0x04, 0x00, 0x00, 0x20, + 0xe4, 0xff, 0xff, 0x27, 0x24, 0x00, 0x00, 0x24, 0x24, 0x00, 0x00, 0x24, + 0xe4, 0xff, 0xff, 0x27, 0x04, 0x00, 0x00, 0x20, 0xfc, 0xff, 0xff, 0x3f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/tix/demos/bitmaps/filebox.xpm b/tix/demos/bitmaps/filebox.xpm new file mode 100644 index 00000000000..7377ee60e68 --- /dev/null +++ b/tix/demos/bitmaps/filebox.xpm @@ -0,0 +1,49 @@ +/* XPM */ +static char * filebox_xpm[] = { +"50 40 6 1", +" s None c None", +". c white", +"X c gray80", +"o c black", +"O c #FFFF80808080", +"+ c gray70", +" ", +" ", +" ", +" ............................................ ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXooXooXoXooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXooXooXoXooXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXooooooooooooooooooooooooooooooooooooo.XXo ", +" .XXoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XXo ", +" .XXoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.XXo ", +" .XX......................................XXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXoooooooooooooooo.XXXXoooooooooooooooo.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XXo+++++++++++++++.XXXXo+++++++++++++++.XXo ", +" .XX.................XXXX.................XXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXooXooXoXooXoXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXooXooXoXooXoXooXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXoooooooooooooooooooooooooooooooooooooo.Xo ", +" .XXoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Xo ", +" .XXoOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.Xo ", +" .XX.......................................Xo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .ooooooooooooooooooooooooooooooooooooooooooo ", +" ", +" ", +" "}; diff --git a/tix/demos/bitmaps/harddisk.xbm b/tix/demos/bitmaps/harddisk.xbm new file mode 100644 index 00000000000..83c636c6707 --- /dev/null +++ b/tix/demos/bitmaps/harddisk.xbm @@ -0,0 +1,14 @@ +#define drivea_width 32 +#define drivea_height 32 +static unsigned char drivea_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xf8, 0xff, 0xff, 0x1f, 0x08, 0x00, 0x00, 0x18, 0xa8, 0xaa, 0xaa, 0x1a, + 0x48, 0x55, 0xd5, 0x1d, 0xa8, 0xaa, 0xaa, 0x1b, 0x48, 0x55, 0x55, 0x1d, + 0xa8, 0xfa, 0xaf, 0x1a, 0xc8, 0xff, 0xff, 0x1d, 0xa8, 0xfa, 0xaf, 0x1a, + 0x48, 0x55, 0x55, 0x1d, 0xa8, 0xaa, 0xaa, 0x1a, 0x48, 0x55, 0x55, 0x1d, + 0xa8, 0xaa, 0xaa, 0x1a, 0xf8, 0xff, 0xff, 0x1f, 0xf8, 0xff, 0xff, 0x1f, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/tix/demos/bitmaps/harddisk.xpm b/tix/demos/bitmaps/harddisk.xpm new file mode 100644 index 00000000000..4d274b995f1 --- /dev/null +++ b/tix/demos/bitmaps/harddisk.xpm @@ -0,0 +1,43 @@ +/* XPM */ +static char * drivea_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 5 1", +/* colors */ +" s None c None", +". c #000000000000", +"X c white", +"o c #c000c000c000", +"O c #800080008000", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .......................... ", +" .XXXXXXXXXXXXXXXXXXXXXXXo. ", +" .XooooooooooooooooooooooO. ", +" .Xooooooooooooooooo..oooO. ", +" .Xooooooooooooooooo..oooO. ", +" .XooooooooooooooooooooooO. ", +" .Xoooooooo.......oooooooO. ", +" .Xoo...................oO. ", +" .Xoooooooo.......oooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .oOOOOOOOOOOOOOOOOOOOOOOO. ", +" .......................... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/tix/demos/bitmaps/italic.xbm b/tix/demos/bitmaps/italic.xbm new file mode 100644 index 00000000000..169c3cb75f6 --- /dev/null +++ b/tix/demos/bitmaps/italic.xbm @@ -0,0 +1,6 @@ +#define italic_width 16 +#define italic_height 16 +static unsigned char italic_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x80, 0x3f, 0x00, 0x06, 0x00, 0x06, + 0x00, 0x03, 0x00, 0x03, 0x80, 0x01, 0x80, 0x01, 0xc0, 0x00, 0xc0, 0x00, + 0x60, 0x00, 0x60, 0x00, 0xfc, 0x01, 0xfc, 0x01}; diff --git a/tix/demos/bitmaps/justify.xbm b/tix/demos/bitmaps/justify.xbm new file mode 100644 index 00000000000..bba660acec2 --- /dev/null +++ b/tix/demos/bitmaps/justify.xbm @@ -0,0 +1,6 @@ +#define justify_width 16 +#define justify_height 16 +static unsigned char justify_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xec, 0xdb, 0x00, 0x00, 0x7c, 0xdb, + 0x00, 0x00, 0xbc, 0xf7, 0x00, 0x00, 0xdc, 0xde, 0x00, 0x00, 0x6c, 0xdf, + 0x00, 0x00, 0x6c, 0xef, 0x00, 0x00, 0xdc, 0xdf}; diff --git a/tix/demos/bitmaps/leftj.xbm b/tix/demos/bitmaps/leftj.xbm new file mode 100644 index 00000000000..5f8e006f4ec --- /dev/null +++ b/tix/demos/bitmaps/leftj.xbm @@ -0,0 +1,6 @@ +#define leftj_width 16 +#define leftj_height 16 +static unsigned char leftj_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x6d, 0x00, 0x00, 0xdc, 0x01, + 0x00, 0x00, 0xec, 0x0e, 0x00, 0x00, 0xfc, 0x7e, 0x00, 0x00, 0xdc, 0x03, + 0x00, 0x00, 0x6c, 0x3b, 0x00, 0x00, 0x6c, 0x1f}; diff --git a/tix/demos/bitmaps/netw.xbm b/tix/demos/bitmaps/netw.xbm new file mode 100644 index 00000000000..a684d65d4b7 --- /dev/null +++ b/tix/demos/bitmaps/netw.xbm @@ -0,0 +1,14 @@ +#define netw_width 32 +#define netw_height 32 +static unsigned char netw_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x02, 0x40, + 0x00, 0x00, 0xfa, 0x5f, 0x00, 0x00, 0x0a, 0x50, 0x00, 0x00, 0x0a, 0x52, + 0x00, 0x00, 0x0a, 0x52, 0x00, 0x00, 0x8a, 0x51, 0x00, 0x00, 0x0a, 0x50, + 0x00, 0x00, 0x4a, 0x50, 0x00, 0x00, 0x0a, 0x50, 0x00, 0x00, 0x0a, 0x50, + 0x00, 0x00, 0xfa, 0x5f, 0x00, 0x00, 0x02, 0x40, 0xfe, 0x7f, 0x52, 0x55, + 0x02, 0x40, 0xaa, 0x6a, 0xfa, 0x5f, 0xfe, 0x7f, 0x0a, 0x50, 0xfe, 0x7f, + 0x0a, 0x52, 0x80, 0x00, 0x0a, 0x52, 0x80, 0x00, 0x8a, 0x51, 0x80, 0x00, + 0x0a, 0x50, 0x80, 0x00, 0x4a, 0x50, 0x80, 0x00, 0x0a, 0x50, 0xe0, 0x03, + 0x0a, 0x50, 0x20, 0x02, 0xfa, 0xdf, 0x3f, 0x03, 0x02, 0x40, 0xa0, 0x02, + 0x52, 0x55, 0xe0, 0x03, 0xaa, 0x6a, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, + 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/tix/demos/bitmaps/netw.xpm b/tix/demos/bitmaps/netw.xpm new file mode 100644 index 00000000000..fff6593bca3 --- /dev/null +++ b/tix/demos/bitmaps/netw.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static char * netw_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 7 1", +/* colors */ +" s None c None", +". c #000000000000", +"X c white", +"o c #c000c000c000", +"O c #404040", +"+ c blue", +"@ c red", +/* pixels */ +" ", +" .............. ", +" .XXXXXXXXXXXX. ", +" .XooooooooooO. ", +" .Xo.......XoO. ", +" .Xo.++++o+XoO. ", +" .Xo.++++o+XoO. ", +" .Xo.++oo++XoO. ", +" .Xo.++++++XoO. ", +" .Xo.+o++++XoO. ", +" .Xo.++++++XoO. ", +" .Xo.XXXXXXXoO. ", +" .XooooooooooO. ", +" .Xo@ooo....oO. ", +" .............. .XooooooooooO. ", +" .XXXXXXXXXXXX. .XooooooooooO. ", +" .XooooooooooO. .OOOOOOOOOOOO. ", +" .Xo.......XoO. .............. ", +" .Xo.++++o+XoO. @ ", +" .Xo.++++o+XoO. @ ", +" .Xo.++oo++XoO. @ ", +" .Xo.++++++XoO. @ ", +" .Xo.+o++++XoO. @ ", +" .Xo.++++++XoO. ..... ", +" .Xo.XXXXXXXoO. .XXX. ", +" .XooooooooooO.@@@@@@.X O. ", +" .Xo@ooo....oO. .OOO. ", +" .XooooooooooO. ..... ", +" .XooooooooooO. ", +" .OOOOOOOOOOOO. ", +" .............. ", +" "}; diff --git a/tix/demos/bitmaps/network.xbm b/tix/demos/bitmaps/network.xbm new file mode 100644 index 00000000000..a684d65d4b7 --- /dev/null +++ b/tix/demos/bitmaps/network.xbm @@ -0,0 +1,14 @@ +#define netw_width 32 +#define netw_height 32 +static unsigned char netw_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, 0x02, 0x40, + 0x00, 0x00, 0xfa, 0x5f, 0x00, 0x00, 0x0a, 0x50, 0x00, 0x00, 0x0a, 0x52, + 0x00, 0x00, 0x0a, 0x52, 0x00, 0x00, 0x8a, 0x51, 0x00, 0x00, 0x0a, 0x50, + 0x00, 0x00, 0x4a, 0x50, 0x00, 0x00, 0x0a, 0x50, 0x00, 0x00, 0x0a, 0x50, + 0x00, 0x00, 0xfa, 0x5f, 0x00, 0x00, 0x02, 0x40, 0xfe, 0x7f, 0x52, 0x55, + 0x02, 0x40, 0xaa, 0x6a, 0xfa, 0x5f, 0xfe, 0x7f, 0x0a, 0x50, 0xfe, 0x7f, + 0x0a, 0x52, 0x80, 0x00, 0x0a, 0x52, 0x80, 0x00, 0x8a, 0x51, 0x80, 0x00, + 0x0a, 0x50, 0x80, 0x00, 0x4a, 0x50, 0x80, 0x00, 0x0a, 0x50, 0xe0, 0x03, + 0x0a, 0x50, 0x20, 0x02, 0xfa, 0xdf, 0x3f, 0x03, 0x02, 0x40, 0xa0, 0x02, + 0x52, 0x55, 0xe0, 0x03, 0xaa, 0x6a, 0x00, 0x00, 0xfe, 0x7f, 0x00, 0x00, + 0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; diff --git a/tix/demos/bitmaps/network.xpm b/tix/demos/bitmaps/network.xpm new file mode 100644 index 00000000000..fff6593bca3 --- /dev/null +++ b/tix/demos/bitmaps/network.xpm @@ -0,0 +1,45 @@ +/* XPM */ +static char * netw_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 7 1", +/* colors */ +" s None c None", +". c #000000000000", +"X c white", +"o c #c000c000c000", +"O c #404040", +"+ c blue", +"@ c red", +/* pixels */ +" ", +" .............. ", +" .XXXXXXXXXXXX. ", +" .XooooooooooO. ", +" .Xo.......XoO. ", +" .Xo.++++o+XoO. ", +" .Xo.++++o+XoO. ", +" .Xo.++oo++XoO. ", +" .Xo.++++++XoO. ", +" .Xo.+o++++XoO. ", +" .Xo.++++++XoO. ", +" .Xo.XXXXXXXoO. ", +" .XooooooooooO. ", +" .Xo@ooo....oO. ", +" .............. .XooooooooooO. ", +" .XXXXXXXXXXXX. .XooooooooooO. ", +" .XooooooooooO. .OOOOOOOOOOOO. ", +" .Xo.......XoO. .............. ", +" .Xo.++++o+XoO. @ ", +" .Xo.++++o+XoO. @ ", +" .Xo.++oo++XoO. @ ", +" .Xo.++++++XoO. @ ", +" .Xo.+o++++XoO. @ ", +" .Xo.++++++XoO. ..... ", +" .Xo.XXXXXXXoO. .XXX. ", +" .XooooooooooO.@@@@@@.X O. ", +" .Xo@ooo....oO. .OOO. ", +" .XooooooooooO. ..... ", +" .XooooooooooO. ", +" .OOOOOOOOOOOO. ", +" .............. ", +" "}; diff --git a/tix/demos/bitmaps/optmenu.xpm b/tix/demos/bitmaps/optmenu.xpm new file mode 100644 index 00000000000..63bab812996 --- /dev/null +++ b/tix/demos/bitmaps/optmenu.xpm @@ -0,0 +1,48 @@ +/* XPM */ +static char * optmenu_xpm[] = { +"50 40 5 1", +" s None c None", +". c white", +"X c gray80", +"o c gray50", +"O c black", +" ", +" ", +" .............................. ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXOXOXXOXXOXXXXOOXXXXXXXXXXo ", +" .XXXOXOXXOXOXXXOXXOXXXXXXXXXXo ", +" .XXXXOXXOXXOXXXOXXXOXXXXXXXXXo ", +" .XXXXOXXXOXXOOXXOXOXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo.............o ", +" .............................o o ", +" ..XXXOXXXXXOXXXXXXXXOXXXXXXXOo o ", +" ..XXOXOXOXXOXOXXXOXXOXXXXXXXOo ...... o ", +" ..XXXOXXXOXXOXXXOXXXOXXXXXXXOo . o o ", +" ..XXOXXXOXXXOXOXXOXXOXXXXXXXOo . o o ", +" ..XXXXXXXXXXXXXXXXXXXXXXXXXXOo .ooooo o ", +" .OOOOOOOOOOOOOOOOOOOOOOOOOOOOo o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo o ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXooooooooooooooo ", +" .XXXXOXXXXXOXXXXXXXXXXXXXXXXXo ", +" .XXXOXXXXXXXXXOXXXXXXXXXXXXXXo ", +" .XXXXOXXOXXOXOXOXXXXXXXXXXXXXo ", +" .XXXXXOXXOXOXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXOXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXOXOXXXXXXXOXOXXXXXOXXXXXXo ", +" .XXXXXOXOXOXXOXXXXXOXXOXXXXXXo ", +" .XXXXOXXOXOXOXXXOXOXOXXOXXXXXo ", +" .XXXOXXXXOXXOXXXOXXOXXXXOXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" .XXXXXXXXXXXXXXXXXXXXXXXXXXXXo ", +" oooooooooooooooooooooooooooooo ", +" ", +" ", +" ", +" "}; diff --git a/tix/demos/bitmaps/rightj.xbm b/tix/demos/bitmaps/rightj.xbm new file mode 100644 index 00000000000..1d438e00902 --- /dev/null +++ b/tix/demos/bitmaps/rightj.xbm @@ -0,0 +1,6 @@ +#define rightj_width 16 +#define rightj_height 16 +static unsigned char rightj_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xdb, 0x00, 0x00, 0x70, 0xdb, + 0x00, 0x00, 0x00, 0xef, 0x00, 0x00, 0xd8, 0xde, 0x00, 0x00, 0xc0, 0xdd, + 0x00, 0x00, 0xa0, 0xef, 0x00, 0x00, 0xd8, 0xde}; diff --git a/tix/demos/bitmaps/select.xpm b/tix/demos/bitmaps/select.xpm new file mode 100644 index 00000000000..392e5a08345 --- /dev/null +++ b/tix/demos/bitmaps/select.xpm @@ -0,0 +1,52 @@ +/* XPM */ +static char * select_xpm[] = { +"50 40 9 1", +" s None c None", +". c black", +"X c gray95", +"o c gray50", +"O c gray70", +"+ c navy", +"@ c #000080800000", +"# c #808000000000", +"$ c white", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .............................................. ", +" .XXXXXXXXXXooooooooooooXXXXXXXXXXXoXXXXXXXXXX. ", +" .X ooOOOOOOOOOOXX oX o. ", +" .X ooOOOOOOOOOOXX oX o. ", +" .X ++++ ooOOOOOOOOOOXX ... oX @ o. ", +" .X +++++ ooOOOOOOOOOOXX . . oX @@@ o. ", +" .X +++ + ooOOOOOOOOOOXX . . oX @ @ o. ", +" .X + + ooOO#####OOOXX . . oX @ @ o. ", +" .X + + ooOO#OOO##OOXX . oX @ @ o. ", +" .X + + ooO##OOOO##OXX . oX @ @ o. ", +" .X ++ ++ ooO###OOO#OOXX . oX @ @ o. ", +" .X +++++++ ooO#######OOXX . oX @ @ o. ", +" .X + + ooO##O#OO#OOXX . oX @ @ o. ", +" .X + ++ ooO##OOOOO#OXX . . oX @ @ o. ", +" .X + + ooOO#OOOOO#OXX . . oX @ @@ o. ", +" .X + ++ ooOO#OOOOO#OXX .... oX @@@@@ o. ", +" .X ooOO######OOXX oX o. ", +" .X ooOOOOOOOOOOXX $oX o. ", +" .XoooooooooooXXXXXXXXXXXoooooooooooXooooooooo. ", +" .............................................. ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "}; diff --git a/tix/demos/bitmaps/tix.gif b/tix/demos/bitmaps/tix.gif Binary files differnew file mode 100644 index 00000000000..e7d51a086cc --- /dev/null +++ b/tix/demos/bitmaps/tix.gif diff --git a/tix/demos/bitmaps/underlin.xbm b/tix/demos/bitmaps/underlin.xbm new file mode 100644 index 00000000000..f07bb460546 --- /dev/null +++ b/tix/demos/bitmaps/underlin.xbm @@ -0,0 +1,6 @@ +#define underline_width 16 +#define underline_height 16 +static unsigned char underline_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x1c, 0x38, 0x1c, + 0x30, 0x0c, 0x30, 0x0c, 0x30, 0x0c, 0x30, 0x0c, 0x30, 0x0c, 0x70, 0x0e, + 0xf0, 0x0f, 0xe0, 0x07, 0x00, 0x00, 0xf8, 0x1f}; diff --git a/tix/demos/c-code/Makefile.in b/tix/demos/c-code/Makefile.in new file mode 100644 index 00000000000..62be8c89837 --- /dev/null +++ b/tix/demos/c-code/Makefile.in @@ -0,0 +1,147 @@ +# +# This file is a Makefile for Tk. If it has the name "Makefile.in" +# then it is a template for a Makefile; to generate the actual Makefile, +# run "./configure", which is a configuration script generated by the +# "autoconf" program (constructs like "@foo@" will get replaced in the +# actual Makefile. +# +# @(#) Makefile.in 1.19 95/01/08 16:55:30 + +#---------------------------------------------------------------- +# Things you can change to personalize the Makefile for your own +# site (you can make these changes in either Makefile.in or +# Makefile, but changes to Makefile will get lost if you re-run +# the configuration script). +#---------------------------------------------------------------- + +# Default top-level directories in which to install architecture- +# specific files (exec_prefix) and machine-independent files such +# as scripts (prefix). The values specified here may be overridden +# at configure-time with the --exec-prefix and --prefix options +# to the "configure" script. + +prefix = @prefix@ +exec_prefix = @exec_prefix@ + +@SET_MAKE@ + +# Directory in which to install the library of Tix scripts and demos +# (note: you can set the TIX_LIBRARY environment variable at run-time to +# override the compiled-in location): +TIX_LIBRARY = $(prefix)/lib/tix + +# Directory in which to install the archive libtix.a: +LIB_DIR = $(exec_prefix)/lib + +# Directory in which to install the program wish: +BIN_DIR = $(exec_prefix)/bin + +# Directory in which to install the include file tix.h: +INCLUDE_DIR = $(prefix)/include + +# Top-level directory for manual entries: +MAN_DIR = $(prefix)/man + +# Directory in which to install manual entry for wish: +MAN1_DIR = $(MAN_DIR)/man1 + +# Directory in which to install manual entries for Tix's C library +# procedures: +MAN3_DIR = $(MAN_DIR)/man3 + +# Directory in which to install manual entries for the built-in +# Tcl commands implemented by Tix: +MANN_DIR = $(MAN_DIR)/mann + + +# A "-I" switch that can be used when compiling to make all of the +# X11 include files accessible (the configure script will try to +# set this value, and will cause it to be an empty string if the +# include files are accessible via /usr/include). +X11_INCLUDES = @XINCLUDES@ + +# Linker switch(es) to use to link with the X11 library archive (the +# configure script will try to set this value automatically, but you +# can override it). +X11_LIB_SWITCHES = @XLIBSW@ + +# Libraries to use when linking: must include at least Tix, Tcl, Xlib, +# and the math library (in that order). The "@LIBS@" part will be +# replaced (or has already been replaced) with relevant libraries as +# determined by the configure script. +LIBS = ../../unix-tk4.0/libtix.a @TK40_LIB@ @TCL74_LIB@ \ + $(X11_LIB_SWITCHES) @LIBS@ @MATH_LIBS@ + +# To change the compiler switches, for example to change from -O +# to -g, change the following line: +CFLAGS = @TIX_DEBUG_FLAG@ + +# To disable ANSI-C procedure prototypes reverse the comment characters +# on the following lines: +PROTO_FLAGS = +#PROTO_FLAGS = -DNO_PROTOTYPE + +# To enable memory debugging reverse the comment characters on the following +# lines. Warning: if you enable memory debugging, you must do it +# *everywhere*, including all the code that calls Tcl, and you must use +# ckalloc and ckfree everywhere instead of malloc and free. +MEM_DEBUG_FLAGS = +#MEM_DEBUG_FLAGS = -DTCL_MEM_DEBUG + +# Some versions of make, like SGI's, use the following variable to +# determine which shell to use for executing commands: +SHELL = /bin/sh + +#---------------------------------------------------------------- +# The information below is modified by the configure script when +# Makefile is generated from Makefile.in. You shouldn't normally +# modify any of this stuff by hand. +#---------------------------------------------------------------- + +AC_FLAGS = @DEFS@ +SRC_DIR = @SRC_DIR@ +INC_DIR = @SRC_DIR@/include +VPATH = @SRC_DIR@ + +#---------------------------------------------------------------- +# The information below should be usable as is. The configure +# script won't modify it and you shouldn't need to modify it +# either. +#---------------------------------------------------------------- + + +CC = @CC@ +CC_SWITCHES = ${CFLAGS} -I${INC_DIR} -I@TCL74_SRC_DIR@ -I@TK40_SRC_DIR@ \ +${X11_INCLUDES} ${AC_FLAGS} ${PROTO_FLAGS} ${MEM_DEBUG_FLAGS} \ +-DTIX_LIBRARY=\"${TIX_LIBRARY}\" @TIX_EXTRA_CFLAGS@ + +OBJS = tixAppInit.o myInit.o myCmds.o + +HDRS = + +all: mytixwish + +mytixwish: $(OBJS) + $(CC) $(CC_SWITCHES) $(OBJS) @TIX_EXTRA_LDFLAGS@ $(LIBS) -o mytixwish + +Makefile: Makefile.in + cd $(SRC_DIR); $(SHELL) config.status + +clean: + - rm -f *.a *.o core errs *~ \#* TAGS *.E a.out errors \ + config.info mytixwish + +distclean: clean + - rm -f Makefile config.status config.log config.cache + +depend: + makedepend -- $(CC_SWITCHES) -- $(SRCS) + +install: + @echo nothing to be done. + +.c.o: + $(CC) -c $(CC_SWITCHES) $< + + +# DO NOT DELETE THIS LINE -- make depend depends on it. diff --git a/tix/demos/c-code/library/Init.tcl b/tix/demos/c-code/library/Init.tcl new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/tix/demos/c-code/library/Init.tcl diff --git a/tix/demos/c-code/library/tclIndex b/tix/demos/c-code/library/tclIndex new file mode 100644 index 00000000000..4d9f691e728 --- /dev/null +++ b/tix/demos/c-code/library/tclIndex @@ -0,0 +1,9 @@ +# Tcl autoload index file, version 2.0 +# This file is generated by the "tixindex" program, +# *NOT* by the "auto_mkindex" command, +# and sourced to set up indexing information for one or +# more commands. Typically each line is a command that +# sets an element in the auto_index array, where the +# element name is the name of a command and the value is +# a script that loads the command. + diff --git a/tix/demos/c-code/myCmds.c b/tix/demos/c-code/myCmds.c new file mode 100644 index 00000000000..23643d465d4 --- /dev/null +++ b/tix/demos/c-code/myCmds.c @@ -0,0 +1,48 @@ +#include <tk.h> +#include <tix.h> + +int +My_AddTwoCmd(clientData, interp, argc, argv) + ClientData clientData; + Tcl_Interp *interp; /* Current interpreter. */ + int argc; /* Number of arguments. */ + char **argv; /* Argument strings. */ +{ + int num; + char buf[30]; + + if (argc != 2) { + return Tix_ArgcError(interp, 1, argv, 1, "integer"); + } + + if (Tcl_GetInt(interp, argv[1], &num) != TCL_OK) { + return TCL_ERROR; + } + + sprintf(buf, "%d", num+2); + Tcl_AppendResult(interp, buf, NULL); + return TCL_OK; +} + +int +My_SubTwoCmd(clientData, interp, argc, argv) + ClientData clientData; + Tcl_Interp *interp; /* Current interpreter. */ + int argc; /* Number of arguments. */ + char **argv; /* Argument strings. */ +{ + int num; + char buf[30]; + + if (argc != 2) { + return Tix_ArgcError(interp, 1, argv, 1, "integer"); + } + + if (Tcl_GetInt(interp, argv[1], &num) != TCL_OK) { + return TCL_ERROR; + } + + sprintf(buf, "%d", num-2); + Tcl_AppendResult(interp, buf, NULL); + return TCL_OK; +} diff --git a/tix/demos/c-code/myInit.c b/tix/demos/c-code/myInit.c new file mode 100644 index 00000000000..b82b79c3c3a --- /dev/null +++ b/tix/demos/c-code/myInit.c @@ -0,0 +1,60 @@ +/* + * myInit.c -- + * + * Initialze the Tix demo application. + * + * Copyright (c) 1996, Expert Interface Technologies + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + */ + +#include <tk.h> +#include <tix.h> + +#ifndef _Windows +# ifndef _export +# define _export +# endif +#endif + +extern TIX_DECLARE_CMD(My_AddTwoCmd); +extern TIX_DECLARE_CMD(My_SubTwoCmd); + +#ifndef MY_LIBRARY +#define MY_LIBRARY "/usr/local/myapp" +#endif + + +static Tix_TclCmd commands[] = { + {"myAddTwo", My_AddTwoCmd}, + {"mySubTwo", My_SubTwoCmd}, + + /* + * Make sure this list is terminated by a NULL element + */ + {(char *) NULL, (int (*)()) NULL} +}; + +/* My_Init -- + * + * This is the function to call in your Tcl_AppInit() function. It + * creates the commands of this application that are defined by + * C functions. + */ +int _export +My_Init(interp) + Tcl_Interp * interp; +{ + /* Initialize the Tix commands */ + Tix_CreateCommands(interp, commands, (ClientData) NULL, + (void (*)()) NULL); + + if (Tix_LoadTclLibrary(interp, "MY_LIBRARY", "my_library", + "Init.tcl", MY_LIBRARY, "myapp") != TCL_OK) { + return TCL_ERROR; + } + + return TCL_OK; +} diff --git a/tix/demos/c-code/tixAppInit.c b/tix/demos/c-code/tixAppInit.c new file mode 100644 index 00000000000..eb2f7983403 --- /dev/null +++ b/tix/demos/c-code/tixAppInit.c @@ -0,0 +1,122 @@ +/* + * myAppInit.c -- + * + * This is a demo program that shows how to link your C programs + * with Tcl/Tk/Tix. + * + * The program created in this directory is a demo program + * called "myapp". You can modify the files in this directory + * to use in your applications. + * + * Copyright (c) 1996, Expert Interface Technologies + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + */ + +#include <tk.h> +#include <tix.h> + +/* + * The following variable is a special hack that is needed in order for + * Sun shared libraries to be used for Tcl. + */ + +extern int matherr(); +int *tclDummyMathPtr = (int *) matherr; + + +/* + *---------------------------------------------------------------------- + * + * main -- + * + * This is the main program for the application. + * + * Results: + * None: Tk_Main never returns here, so this procedure never + * returns either. + * + * Side effects: + * Whatever the application does. + * + *---------------------------------------------------------------------- + */ + +int +main(argc, argv) + int argc; /* Number of command-line arguments. */ + char **argv; /* Values of command-line arguments. */ +{ + Tk_Main(argc, argv, Tcl_AppInit); + return 0; /* Needed only to prevent compiler warning. */ +} + +/* + *---------------------------------------------------------------------- + * + * Tcl_AppInit -- + * + * This procedure performs application-specific initialization. + * Most applications, especially those that incorporate additional + * packages, will have their own version of this procedure. + * + * Results: + * Returns a standard Tcl completion code, and leaves an error + * message in interp->result if an error occurs. + * + * Side effects: + * Depends on the startup script. + * + *---------------------------------------------------------------------- + */ + +int +Tcl_AppInit(interp) + Tcl_Interp *interp; /* Interpreter for application. */ +{ + /* Initialize the Tcl, Tk and Tix packages (in this order) */ + + if (Tcl_Init(interp) != TCL_OK) { + return TCL_ERROR; + } + if (Tk_Init(interp) != TCL_OK) { + return TCL_ERROR; + } + if (Tix_Init(interp) != TCL_OK) { + return TCL_ERROR; + } + + /* + * If you want to use other packages, call their initialization + * procedures here. Each call should look like this: + * + * if (Mod_Init(interp) != TCL_OK) { + * return TCL_ERROR; + * } + * + * where "Mod" is the name of the module. + * + * For example, the intialization procedure for the BLT package is + * BLT_Init(). + */ + + + + /* + * Call My_Init() to do application specific initialization. + */ + + if (My_Init(interp) != TCL_OK) { + return TCL_ERROR; + } + + /* + * Specify a user-specific startup file to invoke + */ + + Tix_SetRcFileName(interp, "my"); + + return TCL_OK; +} diff --git a/tix/demos/et/Makefile.demo b/tix/demos/et/Makefile.demo new file mode 100644 index 00000000000..18745ab52a3 --- /dev/null +++ b/tix/demos/et/Makefile.demo @@ -0,0 +1,16 @@ +# This is an example Makefile that demonstrates how to link Tix into +# an ET-enabled wish. You need to modify this file to suit the +# configuration on your system +# + +# etwish+tix: an ET-enabled wish executable that includes Tix +# +# etdemo.et an ET initialization file that includes Tix +# It should be translated into C code by et2c +# and then compiled into etdemo.o +# +# et42.o compiled from et42.c that came with ET. +# + +etwish+tix: + ld etdemo.o libtixsam4.1.7.6.so et42.o -ltcl -ltk -o etwish+tix diff --git a/tix/demos/et/README b/tix/demos/et/README new file mode 100644 index 00000000000..5f5d921f9df --- /dev/null +++ b/tix/demos/et/README @@ -0,0 +1,9 @@ +This directory is intended only for those who are already using ET and +would like to use Tix in their ET-enabled applications. + +The file etdemo.et demonstrates how the stand-alone module of Tix can +be used in an ET application. You should have et2c installed in your +system and should know how to compile ET-enabled applications. + +For more information on ET, please see docs/ET.txt. +For more information on stand-alone modules, see unix-sam/README. diff --git a/tix/demos/et/etdemo.et b/tix/demos/et/etdemo.et new file mode 100644 index 00000000000..b46eaca6003 --- /dev/null +++ b/tix/demos/et/etdemo.et @@ -0,0 +1,52 @@ +/* + * etdemo.et -- + * + * This file demonstrates how the stand-alone module of Tix can be + * used in an ET application. + * + * Copyright (c) 1996, Expert Interface Technologies + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + */ + +#include <stdio.h> + +int main(int argc, char **argv) +{ + /* + * Initialize ET, this will load the TCL and TK libraries and call + * Tcl_Init() and Tk_Init() for you. + */ + + Et_Init(&argc,argv); + + /* + * Initialize the stand-alone version of Tix. + */ + + if (Tixsam_Init(Et_Interp) != ET_OK ){ + fprintf(stderr,"Can't initialize the Tix extension.\n"); + exit(1); + } + + + /* + * Now put your code here. As an example, I just "source" in the file + * test.tcl in the curent directory. Notice this file is loaded in + * dynamically. If you want to load in test.tcl statically, you should + * use ET_INCLUDE(test.tcl) instead. Please consult your ET manual + * for more details. + */ + + /* ET(source test.tcl); */ + + /* + * Go into the ET mainloop. This won't return until the application + * exits. + */ + + Et_MainLoop(); + return 0; +} diff --git a/tix/demos/samples/AllSampl.tcl b/tix/demos/samples/AllSampl.tcl new file mode 100644 index 00000000000..55c7d5a46de --- /dev/null +++ b/tix/demos/samples/AllSampl.tcl @@ -0,0 +1,193 @@ +# AllSampl.tcl -- +# +# This file is a directory of all the sample programs in the +# demos/samples subdirectory. +# +# +# Copyright (c) 1996, Expert Interface Technologies +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# +# + +# The following data structures contains information about the requirements +# of the sample programs, as well as the relationship/grouping of the sample +# programs. +# +# Each element in an info list has four parts: type, name, group/filename, and +# condition. A group or a file is loaded only if the conditions are met. +# +# types: "d" directory "f" file +# conditions: +# "i": an image type must exist +# "c": a command must exist +# "v": a variable must exist + +set root { + {d "File Selectors" file } + {d "Hierachical ListBox" hlist } + {d "Tabular ListBox" tlist {c tixTList}} + {d "Grid Widget" grid {c tixGrid}} + {d "Manager Widgets" manager } + {d "Scrolled Widgets" scroll } + {d "Miscellaneous Widgets" misc } + {d "Image Types" image } +} + +set image { + {d "Compound Image" cmpimg } + {d "XPM Image" xpm {i pixmap}} +} + +set cmpimg { + {f "In Buttons" CmpImg.tcl } + {f "In NoteBook" CmpImg2.tcl } + {f "Notebook Color Tabs" CmpImg4.tcl } + {f "Icons" CmpImg3.tcl } +} + +set xpm { + {f "In Button" Xpm.tcl {i pixmap}} + {f "In Menu" Xpm1.tcl {i pixmap}} +} + +set file { + {f DirList DirList.tcl } + {f DirTree DirTree.tcl } + {f DirSelectDialog DirDlg.tcl } + {f ExFileSelectDialog EFileDlg.tcl } + {f FileSelectDialog FileDlg.tcl } + {f FileEntry FileEnt.tcl } +} + +set hlist { + {f HList HList1.tcl } + {f CheckList ChkList.tcl {c tixCheckList}} + {f "ScrolledHList (1)" SHList.tcl } + {f "ScrolledHList (2)" SHList2.tcl } + {f Tree Tree.tcl } + {f "Tree (Dynamic)" DynTree.tcl {v win}} +} + +set tlist { + {f "ScrolledTList (1)" STList1.tcl {c tixTList}} + {f "ScrolledTList (2)" STList2.tcl {c tixTList}} + {f "TList File Viewer" STList3.tcl {c tixTList}} +} + +set grid { + {f "Simple Grid" SGrid0.tcl {c tixGrid}} + {f "ScrolledGrid" SGrid1.tcl {c tixGrid}} + {f "Editable Grid" EditGrid.tcl {c tixGrid}} +} + +set scroll { + {f ScrolledListBox SListBox.tcl } + {f ScrolledText SText.tcl } + {f ScrolledWindow SWindow.tcl } + {f "Canvas Object View" CObjView.tcl {c tixCObjView}} +} + +set manager { + {f ListNoteBook ListNBK.tcl } + {f NoteBook NoteBook.tcl } + {f PanedWindow PanedWin.tcl } +} + +set misc { + {f Balloon Balloon.tcl } + {f ButtonBox BtnBox.tcl } + {f ComboBox ComboBox.tcl } + {f Control Control.tcl } + {f LabelEntry LabEntry.tcl } + {f LabelFrame LabFrame.tcl } + {f Meter Meter.tcl {c tixMeter}} + {f OptionMenu OptMenu.tcl } + {f PopupMenu PopMenu.tcl } + {f Select Select.tcl } + {f StdButtonBox StdBBox.tcl } +} + +# ForAllSamples -- +# +# Iterates over all the samples that can be run on this platform. +# +# Arguments: +# name: For outside callers, it must be "root" +# token: An arbtrary string passed in by the caller. +# command: Command prefix to be executed for each node +# in the samples hierarchy. It should return the +# token of the node that it has just created, if any. +# +proc ForAllSamples {name token command} { + global $name win + + if {[tix platform] == "windows"} { + set win 1 + } + + foreach line [set $name] { + set type [lindex $line 0] + set text [lindex $line 1] + set dest [lindex $line 2] + set cond [lindex $line 3] + + case [lindex $cond 0] { + c { + set cmd [lindex $cond 1] + if {[info command $cmd] != $cmd} { + if ![auto_load $cmd] { + continue + } + } + } + i { + if {[lsearch [image types] [lindex $cond 1]] == -1} { + continue + } + } + v { + set doit 1 + foreach var [lrange $cond 1 end] { + if [uplevel #0 info exists [list $var]] { + set doit 0 + break + } + } + if !$doit { + continue + } + } + } + + + if {$type == "d"} { + set tok [eval $command [list $token] $type [list $text] \ + [list $dest]] + ForAllSamples $dest $tok $command + eval $command [list $tok] done xx xx + } else { + set tok [eval $command [list $token] $type [list $text] \ + [list $dest]] + } + } +} + + +proc DoAll {hlist {path ""}} { + catch { + set theSample [$hlist info data $path] + if {$theSample != {}} { + set title [lindex $theSample 0] + set prog [lindex $theSample 1] + + RunProg $title $prog + update + } + } + + foreach p [$hlist info children $path] { + DoAll $hlist $p + } +} diff --git a/tix/demos/samples/ArrowBtn.tcl b/tix/demos/samples/ArrowBtn.tcl new file mode 100644 index 00000000000..4fa7692f33d --- /dev/null +++ b/tix/demos/samples/ArrowBtn.tcl @@ -0,0 +1,183 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates how to write a new Tix widget class. +# + +# ArrowBtn.tcl -- +# +# Arrow Button: a sample Tix widget. +# +set arrow(n) [image create bitmap -data { + #define up_width 15 + #define up_height 15 + static unsigned char up_bits[] = { + 0x80, 0x00, 0xc0, 0x01, 0xe0, 0x03, 0xf0, 0x07, 0xf8, 0x0f, 0xfc, 0x1f, + 0xfe, 0x3f, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0x00, 0x00}; +}] +set arrow(w) [image create bitmap -data { + #define left_width 15 + #define left_height 15 + static unsigned char left_bits[] = { + 0x00, 0x00, 0x40, 0x00, 0x60, 0x00, 0x70, 0x00, 0x78, 0x00, 0x7c, 0x00, + 0xfe, 0x3f, 0xff, 0x3f, 0xfe, 0x3f, 0x7c, 0x00, 0x78, 0x00, 0x70, 0x00, + 0x60, 0x00, 0x40, 0x00, 0x00, 0x00}; +}] +set arrow(s) [image create bitmap -data { + #define down_width 15 + #define down_height 15 + static unsigned char down_bits[] = { + 0x00, 0x00, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, 0xc0, 0x01, + 0xc0, 0x01, 0xc0, 0x01, 0xfe, 0x3f, 0xfc, 0x1f, 0xf8, 0x0f, 0xf0, 0x07, + 0xe0, 0x03, 0xc0, 0x01, 0x80, 0x00}; +}] +set arrow(e) [image create bitmap -data { + #define right_width 15 + #define right_height 15 + static unsigned char right_bits[] = { + 0x00, 0x00, 0x00, 0x01, 0x00, 0x03, 0x00, 0x07, 0x00, 0x0f, 0x00, 0x1f, + 0xfe, 0x3f, 0xfe, 0x7f, 0xfe, 0x3f, 0x00, 0x1f, 0x00, 0x0f, 0x00, 0x07, + 0x00, 0x03, 0x00, 0x01, 0x00, 0x00}; +}] + +tixWidgetClass tixArrowButton { + -classname TixArrowButton + -superclass tixPrimitive + -method { + flash invoke invert + } + -flag { + -direction -state + } + -configspec { + {-direction direction Direction e tixArrowButton:CheckDirection} + {-state state State normal} + } + -alias { + {-dir -direction} + } +} + +proc tixArrowButton:InitWidgetRec {w} { + upvar #0 $w data + + tixChainMethod $w InitWidgetRec + set data(count) 0 +} + +proc tixArrowButton:ConstructWidget {w} { + upvar #0 $w data + global arrow + + tixChainMethod $w ConstructWidget + + set data(w:button) [button $w.button -image $arrow($data(-direction))] + pack $data(w:button) -expand yes -fill both +} + +proc tixArrowButton:SetBindings {w} { + upvar #0 $w data + + tixChainMethod $w SetBindings + + bind $data(w:button) <1> "tixArrowButton:IncrCount $w" +} + +proc tixArrowButton:IncrCount {w} { + upvar #0 $w data + + incr data(count) +} + +proc tixArrowButton:CheckDirection {dir} { + if {[lsearch {n w s e} $dir] != -1} { + return $dir + } else { + error "wrong direction value \"$dir\"" + } +} + +proc tixArrowButton:flash {w} { + upvar #0 $w data + + $data(w:button) flash +} + +proc tixArrowButton:invoke {w} { + upvar #0 $w data + + $data(w:button) invoke +} + +proc tixArrowButton:invert {w} { + upvar #0 $w data + + set curDirection $data(-direction) + case $curDirection { + n { + set newDirection s + } + s { + set newDirection n + } + e { + set newDirection w + } + w { + set newDirection e + } + } + $w config -direction $newDirection +} + +proc tixArrowButton:config-direction {w value} { + upvar #0 $w data + global arrow + + $data(w:button) configure -image $arrow($value) +} + +proc tixArrowButton:config-state {w value} { + upvar #0 $w data + global arrow + + $data(w:button) configure -state $value +} + +#---------------------------------------------------------------------- +# +# Instantiate several widgets of the tixArrowButton class +# +#---------------------------------------------------------------------- + +proc RunSample {w} { + set top [frame $w.top -border 1 -relief raised] + tixArrowButton $top.a -dir w + tixArrowButton $top.b -dir e + + pack $top.a $top.b -side left -expand yes -fill both -padx 50 -pady 10 + + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> "exit" +} diff --git a/tix/demos/samples/Balloon.tcl b/tix/demos/samples/Balloon.tcl new file mode 100644 index 00000000000..63ea7a24f20 --- /dev/null +++ b/tix/demos/samples/Balloon.tcl @@ -0,0 +1,44 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixBalloon widget, which provides +# a interesting way to give help tips about elements in your user interface. +# Your can display the help message in a "balloon" and a status bar widget. +# +proc RunSample {w} { + + # Create the status bar widget + # + label $w.status -width 40 -relief sunken -bd 1 + pack $w.status -side bottom -fill y -padx 2 -pady 1 + + # These are two a mysterious widgets that need some explanation + # + button $w.button1 -text " Something Unexpected " \ + -command "destroy $w" + button $w.button2 -text " Something Else Unexpected " \ + -command "destroy $w.button2" + pack $w.button1 $w.button2 -side top -expand yes + + # Create the balloon widget and associate it with the widgets that we want + # to provide tips for: + tixBalloon $w.b -statusbar $w.status + + $w.b bind $w.button1 -balloonmsg "Close window" \ + -statusmsg "Press this button to close this window" + $w.b bind $w.button2 -balloonmsg "Self-destruct\nButton" \ + -statusmsg "Press this button and it will get rid of itself" +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> {if {"%W" == ".demo"} exit} +} diff --git a/tix/demos/samples/BtnBox.tcl b/tix/demos/samples/BtnBox.tcl new file mode 100644 index 00000000000..2b8f8103205 --- /dev/null +++ b/tix/demos/samples/BtnBox.tcl @@ -0,0 +1,53 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixButtonBox widget, which is a +# group of TK buttons. You can use it to manage the buttons in a dialog box, +# for example. +# +proc RunSample {w} { + + # Create the label on the top of the dialog box + # + label $w.top -padx 20 -pady 10 -border 1 -relief raised -anchor c -text \ + "This dialog box is\n a demostration of the\n tixButtonBox widget" + + # Create the button box and add a few buttons in it. Set the + # -width of all the buttons to the same value so that they + # appear in the same size. + # + # Note that the -text, -underline, -command and -width options are all + # standard options of the button widgets. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text OK -underline 0 -command "destroy $w" -width 5 + $w.box add close -text Close -underline 0 -command "destroy $w" -width 5 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes + + # "after 0" is used so that the key bindings won't interfere with + # tkTraverseMenu + # + bind [winfo toplevel $w] <Alt-o> \ + "after 0 tkButtonInvoke [$w.box subwidget ok]" + bind [winfo toplevel $w] <Alt-c> \ + "after 0 tkButtonInvoke [$w.box subwidget close]" + bind [winfo toplevel $w] <Escape> \ + "after 0 tkButtonInvoke [$w.box subwidget close]" + + focus [$w.box subwidget ok] +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/CObjView.tcl b/tix/demos/samples/CObjView.tcl new file mode 100644 index 00000000000..891d6cf5fb7 --- /dev/null +++ b/tix/demos/samples/CObjView.tcl @@ -0,0 +1,85 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This program demonstrates the use of the CObjView (Canvas Object +# View) class. +# + + +proc RunSample {w} { + label $w.lab -justify left -text \ +"Click on the buttons to add or delete canvas +objects randomally. Notice the scrollbars automatically +adjust to include all objects in the scroll-region." + + pack $w.lab -anchor c -padx 10 -pady 6 + tixCObjView $w.c + pack $w.c -expand yes -fill both -padx 4 -pady 2 + button $w.add -command "CVDemo_Add $w.c" -text Add -width 6 + button $w.del -command "CVDemo_Delete $w.c" -text Delete -width 6 + pack $w.add $w.del -side left -padx 20 -pady 10 -anchor c -expand yes +} + +set cvdemo_counter 0 +proc CVDemo_Add {cov} { + global cvdemo_counter + + # Generate four pseudo random numbers (x,y,w,h) to define the coordinates + # of a rectangle object in the canvas. + # + set colors {red green blue white black gray yellow} + + set px [expr [lindex [time update] 0] + $cvdemo_counter] + set py [expr [lindex [time update] 0] + $cvdemo_counter] + set pw [expr [lindex [time update] 0] + $cvdemo_counter] + set ph [expr [lindex [time update] 0] + $cvdemo_counter] + set pc [expr [lindex [time update] 0] + $cvdemo_counter] + + set x [expr (20 - ($px % 37)) * 10] + set y [expr (10 - ($py % 23)) * 10] + set w [expr ($pw % 17) * 10] + set h [expr ($ph % 17) * 10] + + # Create the canvas object + # + $cov subwidget canvas create rectangle $x $y [expr $x+$w] [expr $y+$h] \ + -fill [lindex $colors [expr $pc % [llength $colors]]] + + # Call the adjustscrollregion command to set the scroll bars so that all + # objects are included in the scroll-region + # + $cov adjustscrollregion + + # This number acts as the seed for the next round of randomization. + # + set cvdemo_counter [expr ($px % 37)] +} + +proc CVDemo_Delete {cov} { + set px [lindex [time update] 0] + set w [$cov subwidget canvas] + set items [$w find withtag all] + + if [string compare $items ""] { + # There are items in the canvas, randomally delete one of them + # and re-adjust the scroll-region + # + set toDelete [expr $px % [llength $items]] + $w delete [lindex $items $toDelete] + + $cov adjustscrollregion + } +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/ChkList.tcl b/tix/demos/samples/ChkList.tcl new file mode 100644 index 00000000000..44603b4db3f --- /dev/null +++ b/tix/demos/samples/ChkList.tcl @@ -0,0 +1,175 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This program demonstrates the use of the tixCheckList widget. +# + +proc RunSample {w} { + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + #------------------------------------------------------------ + # Create the 1st CheckList (Multiple Selection) + # + set f [frame $top.f1] + pack $f -side left -expand yes -fill both -padx 4 + + set l [label $f.l -text "Choose languages: "] + pack $l -side top -fill x -padx 4 -pady 4 + + set c1 [tixCheckList $f.c -scrollbar auto] + pack $c1 -expand yes -fill both -padx 4 -pady 4 + + set b1 [button $f.btn -text "Results >>" -command "ChkList_Result $c1"] + pack $b1 -anchor c + #------------------------------------------------------------ + # Create the 2nd CheckList (Single Selection, using the -radio option) + # + set f [frame $top.f2] + pack $f -side left -expand yes -fill both -padx 4 + + set l [label $f.l -text "Choose one language: "] + pack $l -side top -fill x -padx 4 -pady 4 + + set c2 [tixCheckList $f.c -scrollbar auto -radio true] + pack $c2 -expand yes -fill both -padx 4 -pady 4 + + # Fill up the two checklists with languages + # + set names(1) "Ada" + set names(2) "BCPL" + set names(3) "C" + set names(4) "Dylan" + set names(5) "Eiffle" + set names(6) "Fortran" + set names(7) "Incr Tcl" + set names(8) "Matlab" + set names(9) "Scheme" + set names(0) "TCL" + + set h1 [$c1 subwidget hlist] + set h2 [$c2 subwidget hlist] + + foreach ent {1 2 3 4 5 6 7 8 9 0} { + $h1 add $ent -itemtype imagetext -text $names($ent) + } + + foreach ent {1 2 3 4 5 6 7 8 9 0} { + $h2 add $ent -itemtype imagetext -text $names($ent) + $c2 setstatus $ent off + } + + $c1 setstatus 1 on + $c1 setstatus 2 on + $c1 setstatus 3 default + $c1 setstatus 4 off + $c1 setstatus 5 off + $c1 setstatus 6 on + $c1 setstatus 7 off + $c1 setstatus 8 off + $c1 setstatus 9 on + $c1 setstatus 0 default + + + #------------------------------------------------------------ + # Create the 3nd CheckList (a tree). Also, we disable some + # sub-selections if the top-level selections are not selected. + # i.e., if the user doesn't like any functional languages, + # make sure he doesn't select Lisp. + # + set f [frame $top.f3] + pack $f -side left -expand yes -fill both -padx 4 + + set l [label $f.l -text "Choose languages: "] + pack $l -side top -fill x -padx 4 -pady 4 + + set c3 [tixCheckList $f.c -scrollbar auto -options { + hlist.indicator 1 + hlist.indent 20 + }] + pack $c3 -expand yes -fill both -padx 4 -pady 4 + + set h3 [$c3 subwidget hlist] + + $h3 add 0 -itemtype imagetext -text "Functional Languages" + $h3 add 1 -itemtype imagetext -text "Imperative Languages" + + $h3 add 0.0 -itemtype imagetext -text Lisp + $h3 add 0.1 -itemtype imagetext -text Scheme + $h3 add 1.0 -itemtype imagetext -text C + $h3 add 1.1 -itemtype imagetext -text Pascal + + $c3 setstatus 0 on + $c3 setstatus 1 on + $c3 setstatus 0.0 off + $c3 setstatus 0.1 off + $c3 setstatus 1.0 on + $c3 setstatus 1.1 off + + $c3 config -browsecmd "ChkList:Monitor $c3" + $c3 config -command "ChkList:Monitor $c3" + + $c3 autosetmode + + global chklist + set chklist(disabled) [tixDisplayStyle imagetext -fg gray48 \ + -refwindow [$c3 subwidget hlist]] + set chklist(normal) [tixDisplayStyle imagetext -fg black \ + -refwindow [$c3 subwidget hlist]] + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + +proc ChkList_Result {clist} { + puts "Selected items: [$clist getselection on]" + puts "Unselected items: [$clist getselection off]" + puts "Default items: [$clist getselection default]" +} + +# This function monitors if any of the two "general groups" +# (functional and imperative languages) are de-selected. If so, it +# sets all the sub-selections to non-selectable by setting their -state +# to disabled. +# +proc ChkList:Monitor {c3 ent} { + global chklist + + set h [$c3 subwidget hlist] + + if {[$c3 getstatus 0] == "on"} { + set state normal + } else { + set state disabled + } + + $h entryconfig 0.0 -state $state -style $chklist($state) + $h entryconfig 0.1 -state $state -style $chklist($state) + + if {[$c3 getstatus 1] == "on"} { + set state normal + } else { + set state disabled + } + + $h entryconfig 1.0 -state $state -style $chklist($state) + $h entryconfig 1.1 -state $state -style $chklist($state) +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/CmpImg.tcl b/tix/demos/samples/CmpImg.tcl new file mode 100644 index 00000000000..54ee60fcabd --- /dev/null +++ b/tix/demos/samples/CmpImg.tcl @@ -0,0 +1,60 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the compound images: it uses compound +# images to display a text string together with a pixmap inside +# buttons +# +proc RunSample {w} { + + set img0 [tix getimage network] + set img1 [tix getimage harddisk] + + button $w.hdd -padx 4 -pady 1 -width 120 + button $w.net -padx 4 -pady 1 -width 120 + + # Create the first image: we create a line, then put a string, + # a space and a image into this line, from left to right. + # The result: we have a one-line image that consists of three + # individual items + # + set hdd_img [image create compound -window $w.hdd] + $hdd_img add line + $hdd_img add text -text "Hard Disk" -underline 0 + $hdd_img add space -width 7 + $hdd_img add image -image $img1 + + # Put this image into the first button + # + $w.hdd config -image $hdd_img + + # Create the second compound image. Very similar to what we did above + # + set net_img [image create compound -window $w.net] + $net_img add line + $net_img add text -text "Network" -underline 0 + $net_img add space -width 7 + $net_img add image -image $img0 + + $w.net config -image $net_img + + # The button to close the window + # + + button $w.clo -pady 1 -text Close -command "destroy $w" + + pack $w.hdd $w.net $w.clo -side left -padx 10 -pady 10 -fill y -expand yes +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} diff --git a/tix/demos/samples/CmpImg1.tcl b/tix/demos/samples/CmpImg1.tcl new file mode 100644 index 00000000000..59109dca6c4 --- /dev/null +++ b/tix/demos/samples/CmpImg1.tcl @@ -0,0 +1,178 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixNoteBook widget, which allows +# you to lay out your interface using a "notebook" metaphore +# + +proc RunSample {w} { + + # We use these options to set the sizes of the subwidgets inside the + # notebook, so that they are well-aligned on the screen. + # + set name [tixOptionName $w] + option add *$name*TixControl*entry.width 10 + option add *$name*TixControl*label.width 18 + option add *$name*TixControl*label.anchor e + option add *$name*TixNoteBook*tabPadX 8 + + # Create the notebook widget and set its backpagecolor to gray. + # Note that the -backpagecolor option belongs to the "nbframe" + # subwidget. + tixNoteBook $w.nb -ipadx 6 -ipady 6 + $w config -bg gray + $w.nb subwidget nbframe config -backpagecolor gray -tabpady 0 + + # Create the two tabs on the notebook. The -underline option + # puts a underline on the first character of the labels of the tabs. + # Keyboard accelerators will be defined automatically according + # to the underlined character. + # + global network_pixmap hard_disk_pixmap + set img0 [image create pixmap -data $network_pixmap] + set img1 [image create pixmap -data $hard_disk_pixmap] + + set hd_img [image create compound -window [$w.nb subwidget nbframe]] + $hd_img add line + $hd_img add text -text "Hard Disk" -underline 0 + $hd_img add space -width 7 + $hd_img add image -image $img1 + + $w.nb add hard_disk -image $hd_img + + set net_img [image create compound -window [$w.nb subwidget nbframe]] + $net_img add line + $net_img add text -text "Network" -underline 0 + $net_img add space -width 7 + $net_img add image -image $img0 + + $w.nb add network -image $net_img + # Create the first page + # + set f [$w.nb subwidget hard_disk] + + tixControl $f.a -value 12 -label "Access Time: " + tixControl $f.w -value 400 -label "Write Throughput: " + tixControl $f.r -value 400 -label "Read Throughput: " + tixControl $f.c -value 1021 -label "Capacity: " + pack $f.a $f.w $f.r $f.c -side top -padx 20 -pady 2 + + # Create the second page + # + set f [$w.nb subwidget network] + + tixControl $f.a -value 12 -label "Access Time: " + tixControl $f.w -value 400 -label "Write Throughput: " + tixControl $f.r -value 400 -label "Read Throughput: " + tixControl $f.c -value 1021 -label "Capacity: " + tixControl $f.u -value 10 -label "Users: " + + pack $f.a $f.w $f.r $f.c $f.u -side top -padx 20 -pady 2 + pack $w.nb -expand yes -fill both -padx 5 -pady 5 + +} + +set network_pixmap {/* XPM */ +static char * netw_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 7 1", +/* colors */ +" s None c None", +". c #000000000000", +"X c white", +"o c #c000c000c000", +"O c #404040", +"+ c blue", +"@ c red", +/* pixels */ +" ", +" .............. ", +" .XXXXXXXXXXXX. ", +" .XooooooooooO. ", +" .Xo.......XoO. ", +" .Xo.++++o+XoO. ", +" .Xo.++++o+XoO. ", +" .Xo.++oo++XoO. ", +" .Xo.++++++XoO. ", +" .Xo.+o++++XoO. ", +" .Xo.++++++XoO. ", +" .Xo.XXXXXXXoO. ", +" .XooooooooooO. ", +" .Xo@ooo....oO. ", +" .............. .XooooooooooO. ", +" .XXXXXXXXXXXX. .XooooooooooO. ", +" .XooooooooooO. .OOOOOOOOOOOO. ", +" .Xo.......XoO. .............. ", +" .Xo.++++o+XoO. @ ", +" .Xo.++++o+XoO. @ ", +" .Xo.++oo++XoO. @ ", +" .Xo.++++++XoO. @ ", +" .Xo.+o++++XoO. @ ", +" .Xo.++++++XoO. ..... ", +" .Xo.XXXXXXXoO. .XXX. ", +" .XooooooooooO.@@@@@@.X O. ", +" .Xo@ooo....oO. .OOO. ", +" .XooooooooooO. ..... ", +" .XooooooooooO. ", +" .OOOOOOOOOOOO. ", +" .............. ", +" "};} + +set hard_disk_pixmap {/* XPM */ +static char * drivea_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 5 1", +/* colors */ +" s None c None", +". c #000000000000", +"X c white", +"o c #c000c000c000", +"O c #800080008000", +/* pixels */ +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" .......................... ", +" .XXXXXXXXXXXXXXXXXXXXXXXo. ", +" .XooooooooooooooooooooooO. ", +" .Xooooooooooooooooo..oooO. ", +" .Xooooooooooooooooo..oooO. ", +" .XooooooooooooooooooooooO. ", +" .Xoooooooo.......oooooooO. ", +" .Xoo...................oO. ", +" .Xoooooooo.......oooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .XooooooooooooooooooooooO. ", +" .oOOOOOOOOOOOOOOOOOOOOOOO. ", +" .......................... ", +" ", +" ", +" ", +" ", +" ", +" ", +" ", +" "};} + + + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} diff --git a/tix/demos/samples/CmpImg2.tcl b/tix/demos/samples/CmpImg2.tcl new file mode 100644 index 00000000000..90f79432a84 --- /dev/null +++ b/tix/demos/samples/CmpImg2.tcl @@ -0,0 +1,132 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates how to use the compound image inside NoteBook +# widgets. This file is basically a cross-over of NoteBook.tcl and CmpImg.tcl +# +proc RunSample {w} { + + # Create the notebook widget and set its backpagecolor to gray. + # Note that the -backpagecolor option belongs to the "nbframe" + # subwidget. + tixNoteBook $w.nb -ipadx 6 -ipady 6 + $w config -bg gray + $w.nb subwidget nbframe config -backpagecolor gray -tabpady 0 + + # Create the two compound images + # + # + + # these are two Tix built-in images + # + set img0 [tix getimage network] + set img1 [tix getimage harddisk] + + # Create the first image: + # + # Notice that the -window option must be set to the nbframe + # subwidget of the notebook because the image will be displayed + # in that widget. + # + set hdd_img [image create compound -window [$w.nb subwidget nbframe] \ + -pady 0] + $hdd_img add line + $hdd_img add image -image $img1 + $hdd_img add space -width 7 + $hdd_img add text -text "Hard Disk" -underline 0 + + # Create the second compound image. Very similar to what we did above + # + set net_img [image create compound -window [$w.nb subwidget nbframe] \ + -pady 0] + $net_img add line + $net_img add image -image $img0 + $net_img add space -width 7 + $net_img add text -text "Network" -underline 0 + + # + # Now create the pages + # + + # We use these options to set the sizes of the subwidgets inside the + # notebook, so that they are well-aligned on the screen. + # + set name [tixOptionName $w] + option add *$name*TixControl*entry.width 10 + option add *$name*TixControl*label.width 18 + option add *$name*TixControl*label.anchor e + + # Create the two tabs on the notebook. The -underline option + # puts a underline on the first character of the labels of the tabs. + # Keyboard accelerators will be defined automatically according + # to the underlined character. + # + $w.nb add hard_disk -image $hdd_img + $w.nb add network -image $net_img + pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top + + #---------------------------------------- + # Create the first page + #---------------------------------------- + set f [$w.nb subwidget hard_disk] + + # Create two frames: one for the common buttons, one for the + # other widgets + # + frame $f.f + frame $f.common + pack $f.f -side left -padx 2 -pady 2 -fill both -expand yes + pack $f.common -side right -padx 2 -pady 2 -fill y + + # Create the controls that only belong to this page + # + tixControl $f.f.a -value 12 -label "Access Time: " + tixControl $f.f.w -value 400 -label "Write Throughput: " + tixControl $f.f.r -value 400 -label "Read Throughput: " + tixControl $f.f.c -value 1021 -label "Capacity: " + pack $f.f.a $f.f.w $f.f.r $f.f.c -side top -padx 20 -pady 2 + + # Create the common buttons + # + CreateCommonButtons $w $f.common + + #---------------------------------------- + # Create the second page + #---------------------------------------- + set f [$w.nb subwidget network] + + frame $f.f + frame $f.common + pack $f.f -side left -padx 2 -pady 2 -fill both -expand yes + pack $f.common -side right -padx 2 -pady 2 -fill y + + tixControl $f.f.a -value 12 -label "Access Time: " + tixControl $f.f.w -value 400 -label "Write Throughput: " + tixControl $f.f.r -value 400 -label "Read Throughput: " + tixControl $f.f.c -value 1021 -label "Capacity: " + tixControl $f.f.u -value 10 -label "Users: " + + pack $f.f.a $f.f.w $f.f.r $f.f.c $f.f.u -side top -padx 20 -pady 2 + + CreateCommonButtons $w $f.common +} + +proc CreateCommonButtons {w f} { + button $f.ok -text OK -width 6 -command "destroy $w" + button $f.cancel -text Cancel -width 6 -command "destroy $w" + + pack $f.ok $f.cancel -side top -padx 2 -pady 2 +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} diff --git a/tix/demos/samples/CmpImg3.tcl b/tix/demos/samples/CmpImg3.tcl new file mode 100644 index 00000000000..26c08032030 --- /dev/null +++ b/tix/demos/samples/CmpImg3.tcl @@ -0,0 +1,86 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# Demonstrates how to use compound images to display icons in a canvas widget. +# + +proc RunSample {w} { + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + label $top.lab -text "Drag the icons" + pack $top.lab -anchor c -side top -pady 4 + + # Create the canvas to display the icons + # + set c [canvas $top.c -relief sunken -bd 1] + pack $c -side top -expand yes -fill both -padx 4 -pady 4 + + # create several compound images in the canvas + # + set network [tix getimage network] + set harddisk [tix getimage harddisk] + + set cmp_1 [image create compound -window $c -bd 1] + $cmp_1 add image -image $network + $cmp_1 add line + $cmp_1 add text -text " Network " + + set cmp_2 [image create compound -window $c -bd 1] + $cmp_2 add image -image $harddisk + $cmp_2 add line + $cmp_2 add text -text " Hard disk " + + set cmp_3 [image create compound -window $c -bd 1 \ + -background #c0c0ff -relief raised \ + -showbackground 1] + $cmp_3 add image -image $network + $cmp_3 add line + $cmp_3 add text -text " Network 2 " + + $c create image 50 50 -image $cmp_1 + $c create image 150 50 -image $cmp_2 + $c create image 250 50 -image $cmp_3 + + bind $c <1> "itemStartDrag $c %x %y" + bind $c <B1-Motion> "itemDrag $c %x %y" + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + + +proc itemStartDrag {c x y} { + global lastX lastY + $c raise current + + set lastX [$c canvasx $x] + set lastY [$c canvasy $y] +} + +proc itemDrag {c x y} { + global lastX lastY + set x [$c canvasx $x] + set y [$c canvasy $y] + $c move current [expr $x-$lastX] [expr $y-$lastY] + set lastX $x + set lastY $y +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/CmpImg4.tcl b/tix/demos/samples/CmpImg4.tcl new file mode 100644 index 00000000000..95a9e461345 --- /dev/null +++ b/tix/demos/samples/CmpImg4.tcl @@ -0,0 +1,121 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates how to use the compound image to add +# colors in Notebook tabs. +# +proc RunSample {w} { + + # Create the notebook widget and set its backpagecolor to gray. + # Note that the -backpagecolor option belongs to the "nbframe" + # subwidget. + tixNoteBook $w.nb -ipadx 6 -ipady 6 + $w config -bg gray + $w.nb subwidget nbframe config -backpagecolor gray -tabpady 0 + + # Create the two compound images -- + # + # Create the first image: + # + # Notice that the -window option must be set to the nbframe + # subwidget of the notebook because the image will be displayed + # in that widget. + # + set hdd_img [image create compound -window [$w.nb subwidget nbframe] \ + -pady 4 -padx 4 -bg #f09090 -showbackground 1] + $hdd_img add line + $hdd_img add text -text "Hard Disk" -underline 0 -padx 6 -pady 4 + + # Create the second compound image. Very similar to what we did above + # + set net_img [image create compound -window [$w.nb subwidget nbframe] \ + -pady 4 -pady 4 -bg #9090f0 -showbackground 1] + $net_img add line + $net_img add text -text "Network" -underline 0 -padx 6 -pady 4 + + # + # Now create the pages + # + + # We use these options to set the sizes of the subwidgets inside the + # notebook, so that they are well-aligned on the screen. + # + set name [tixOptionName $w] + option add *$name*TixControl*entry.width 10 + option add *$name*TixControl*label.width 18 + option add *$name*TixControl*label.anchor e + + # Create the two tabs on the notebook. The -underline option + # puts a underline on the first character of the labels of the tabs. + # Keyboard accelerators will be defined automatically according + # to the underlined character. + # + $w.nb add hard_disk -image $hdd_img + $w.nb add network -image $net_img + pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top + + #---------------------------------------- + # Create the first page + #---------------------------------------- + set f [$w.nb subwidget hard_disk] + + # Create two frames: one for the common buttons, one for the + # other widgets + # + frame $f.f + frame $f.common + pack $f.f -side left -padx 2 -pady 2 -fill both -expand yes + pack $f.common -side right -padx 2 -pady 2 -fill y + + # Create the controls that only belong to this page + # + tixControl $f.f.a -value 12 -label "Access Time: " + tixControl $f.f.w -value 400 -label "Write Throughput: " + tixControl $f.f.r -value 400 -label "Read Throughput: " + tixControl $f.f.c -value 1021 -label "Capacity: " + pack $f.f.a $f.f.w $f.f.r $f.f.c -side top -padx 20 -pady 2 + + # Create the common buttons + # + CreateCommonButtons $w $f.common + + #---------------------------------------- + # Create the second page + #---------------------------------------- + set f [$w.nb subwidget network] + + frame $f.f + frame $f.common + pack $f.f -side left -padx 2 -pady 2 -fill both -expand yes + pack $f.common -side right -padx 2 -pady 2 -fill y + + tixControl $f.f.a -value 12 -label "Access Time: " + tixControl $f.f.w -value 400 -label "Write Throughput: " + tixControl $f.f.r -value 400 -label "Read Throughput: " + tixControl $f.f.c -value 1021 -label "Capacity: " + tixControl $f.f.u -value 10 -label "Users: " + + pack $f.f.a $f.f.w $f.f.r $f.f.c $f.f.u -side top -padx 20 -pady 2 + + CreateCommonButtons $w $f.common +} + +proc CreateCommonButtons {w f} { + button $f.ok -text OK -width 6 -command "destroy $w" + button $f.cancel -text Cancel -width 6 -command "destroy $w" + + pack $f.ok $f.cancel -side top -padx 2 -pady 2 +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} diff --git a/tix/demos/samples/ComboBox.tcl b/tix/demos/samples/ComboBox.tcl new file mode 100644 index 00000000000..fb639ed9bcc --- /dev/null +++ b/tix/demos/samples/ComboBox.tcl @@ -0,0 +1,115 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixComboBox widget, which is close +# to the MS Window Combo Box control. +# +proc RunSample {w} { + + # Create the comboboxes on the top of the dialog box + # + frame $w.top -border 1 -relief raised + + # $w.top.a is a drop-down combo box. It is not editable -- who wants + # to invent new months? + # + # [Hint] The -options switch sets the options of the subwidgets. + # [Hint] We set the label.width subwidget option of both comboboxes to + # be 10 so that their labels appear to be aligned. + # + tixComboBox $w.top.a -label "Month: " -dropdown true \ + -command cbx:select_month -editable false -variable demo_month \ + -options { + listbox.height 6 + label.width 10 + label.anchor e + } + + + # $w.top.b is a non-drop-down combo box. It is not editable: we provide + # four choices for the user, but he can enter an alternative year if he + # wants to. + # + # [Hint] Use the padY and anchor options of the label subwidget to + # aligh the label with the entry subwidget. + # [Hint] Notice that you should use padY (the NAME of the option) and not + # pady (the SWITCH of the option). + # + tixComboBox $w.top.b -label "Year: " -dropdown false \ + -command cbx:select_year -editable true -variable demo_year \ + -options { + listbox.height 4 + label.padY 5 + label.width 10 + label.anchor ne + } + + pack $w.top.a -side top -anchor w + pack $w.top.b -side top -anchor w + + # Insert the choices into the combo boxes + # + $w.top.a insert end January + $w.top.a insert end February + $w.top.a insert end March + $w.top.a insert end April + $w.top.a insert end May + $w.top.a insert end June + $w.top.a insert end July + $w.top.a insert end August + $w.top.a insert end September + $w.top.a insert end October + $w.top.a insert end November + $w.top.a insert end December + + $w.top.b insert end 1992 + $w.top.b insert end 1993 + $w.top.b insert end 1994 + $w.top.b insert end 1995 + + # Use "tixSetSilent" to set the values of the combo box if you + # don't want your -command procedures (cbx:select_month and + # cbx:select_year) to be called. + # + tixSetSilent $w.top.a January + tixSetSilent $w.top.b 1995 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "cbx:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +proc cbx:select_year {args} { + puts "you have selected \"$args\"" +} + +proc cbx:select_month {s} { + puts "you have selected \"$s\"" +} + +proc cbx:okcmd {w} { + global demo_month demo_year + + puts "The month selected is $demo_month of $demo_year" + destroy $w +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/Control.tcl b/tix/demos/samples/Control.tcl new file mode 100644 index 00000000000..d0b09017d33 --- /dev/null +++ b/tix/demos/samples/Control.tcl @@ -0,0 +1,129 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixControl widget -- it is an +# entry widget with up/down arrow buttons. You can use the arrow buttons +# to adjust the value inside the entry widget. +# +# This example program uses three Control widgets. One lets you select +# integer values; one lets you select floating point values and the last +# one lets you select a few names. +# +proc RunSample {w} { + + # Create the tixControls on the top of the dialog box + # + frame $w.top -border 1 -relief raised + + # $w.top.a allows only integer values + # + # [Hint] The -options switch sets the options of the subwidgets. + # [Hint] We set the label.width subwidget option of the Controls to + # be 16 so that their labels appear to be aligned. + # + global demo_maker demo_thrust demo_num_engins + set demo_maker P&W + set demo_thrust 20000.0 + set demo_num_engins 2 + + + tixControl $w.top.a -label "Number of Engines: " -integer true \ + -variable demo_num_engins -min 1 -max 4\ + -options { + entry.width 10 + label.width 20 + label.anchor e + } + + tixControl $w.top.b -label "Thrust: " -integer false \ + -min 10000.0 -max 60000.0 -step 500\ + -variable demo_thrust \ + -options { + entry.width 10 + label.width 20 + label.anchor e + } + + tixControl $w.top.c -label "Engin Maker: " \ + -incrcmd "ctl:adjust_maker $w.top.c +1" \ + -decrcmd "ctl:adjust_maker $w.top.c -1" \ + -validatecmd "ctl:validate_maker $w.top.c" \ + -value "P&W" \ + -options { + entry.width 10 + label.width 20 + label.anchor e + } + + pack $w.top.a $w.top.b $w.top.c -side top -anchor w + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "ctl:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +set ctl_makers {GE P&W "Rolls Royce"} + +# This procedure gets called when the user presses the up/down arrow buttons. +# We return the "previous" or "next" engin maker according to the "$by" +# argument +# +proc ctl:adjust_maker {w by value} { + global ctl_makers + + set index [lsearch $ctl_makers $value] + set len [llength $ctl_makers] + set index [expr $index $by] + + if {$index < 0} { + set index [expr $len -1] + } + if {$index >= $len} { + set index 0 + } + + return [lindex $ctl_makers $index] +} + +proc ctl:validate_maker {w value} { + global ctl_makers + + if {[lsearch $ctl_makers $value] == -1} { + return [lindex $ctl_makers 0] + } else { + return $value + } +} + +proc ctl:okcmd {w} { + global demo_maker demo_thrust demo_num_engins + + puts "You selected $demo_num_engins engin(s) of thrust $demo_thrust made \ +by $demo_maker" + + destroy $w +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/DirDlg.tcl b/tix/demos/samples/DirDlg.tcl new file mode 100644 index 00000000000..ca0cb34ccdc --- /dev/null +++ b/tix/demos/samples/DirDlg.tcl @@ -0,0 +1,86 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixDirSelectDialog widget: +# it allows the user to select a directory. +# +proc RunSample {w} { + + # Create an entry for the user to input a directory. If he can't + # bother to type in the name, he can press the "Browse ..." button + # and call up the diretcory dialog + # + frame $w.top -border 1 -relief raised + + tixLabelEntry $w.top.ent -label "Select A Directory:" -labelside top \ + -options { + entry.width 25 + entry.textVariable demo_ddlg_dirname + label.anchor w + } + bind [$w.top.ent subwidget entry] <Return> "ddlg:okcmd $w" + + uplevel #0 set demo_ddlg_dirname {} + + button $w.top.btn -text "Browse ..." -command "ddlg:browse" + + pack $w.top.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4 + pack $w.top.btn -side left -anchor s -padx 4 -pady 4 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "ddlg:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +# Pop up a directory selection dialog +# +proc ddlg:browse {} { + set dialog .dirdlg_popup + if ![winfo exists $dialog] { + tixDirSelectDialog $dialog + } + $dialog config -command ddlg:select_dir + + $dialog popup +} + +proc ddlg:select_dir {dir} { + global demo_ddlg_dirname + + set demo_ddlg_dirname $dir +} + +proc ddlg:okcmd {w} { + global demo_ddlg_dirname + + if {$demo_ddlg_dirname != {}} { + puts "You have selected the directory $demo_ddlg_dirname" + } else { + puts "You haven't selected any directory" + } + + destroy $w +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} diff --git a/tix/demos/samples/DirList.tcl b/tix/demos/samples/DirList.tcl new file mode 100644 index 00000000000..f1a358a20cd --- /dev/null +++ b/tix/demos/samples/DirList.tcl @@ -0,0 +1,87 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixDirList widget -- you can +# use it for the user to select a directory. For example, an installation +# program can use the tixDirList widget to ask the user to select the +# installation directory for an application. +# +proc RunSample {w} { + + # Create the tixDirList and the tixLabelEntry widgets on the on the top + # of the dialog box + # + frame $w.top -border 1 -relief raised + + # Create the DirList widget. By default it will show the current + # directory (returned by [pwd]) + # + # + tixDirList $w.top.dir + + # When the user presses the ".." button, the selected directory + # is "transferred" into the entry widget + # + button $w.top.btn -text " >> " -pady 0 \ + -command "dlist:copy_name $w.top.dir" + + # We use a LabelEntry to hold the installation directory. The user + # can choose from the DirList widget, or he can type in the directory + # manually + # + tixLabelEntry $w.top.ent -label "Installation Directory:" -labelside top \ + -options { + entry.width 25 + entry.textVariable demo_dlist_dir + label.anchor w + } + bind [$w.top.ent subwidget entry] <Return> "dlist:okcmd $w" + + uplevel #0 set demo_dlist_dir [list [pwd]] + + pack $w.top.dir -side left -expand yes -fill both -padx 4 -pady 4 + pack $w.top.btn -side left -anchor s -padx 4 -pady 4 + pack $w.top.ent -side left -fill x -anchor s -padx 4 -pady 4 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "dlist:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + + +proc dlist:copy_name {w} { + global demo_dlist_dir + + set demo_dlist_dir [$w cget -value] +} + +proc dlist:okcmd {w} { + global demo_dlist_dir + + puts "You have selected the directory $demo_dlist_dir" + + destroy $w +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> "exit" +} diff --git a/tix/demos/samples/DirTree.tcl b/tix/demos/samples/DirTree.tcl new file mode 100644 index 00000000000..08da543f860 --- /dev/null +++ b/tix/demos/samples/DirTree.tcl @@ -0,0 +1,88 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixDirList widget -- you can +# use it for the user to select a directory. For example, an installation +# program can use the tixDirList widget to ask the user to select the +# installation directory for an application. +# +proc RunSample {w} { + + # Create the tixDirTree and the tixLabelEntry widgets on the on the top + # of the dialog box + # + frame $w.top -border 1 -relief raised + + # Create the DirTree widget. By default it will show the current + # directory (returned by [pwd]) + # + # + tixDirTree $w.top.dir -browsecmd "dtree:browse $w.top.ent" + + # When the user presses the ".." button, the selected directory + # is "transferred" into the entry widget + # + + # We use a LabelEntry to hold the installation directory. The user + # can choose from the DirTree widget, or he can type in the directory + # manually + # + tixLabelEntry $w.top.ent -label "Installation Directory:" -labelside top \ + -options { + entry.width 25 + entry.textVariable demo_dtree_dir + label.anchor w + } + bind [$w.top.ent subwidget entry] <Return> "dtree:okcmd $w" + + uplevel #0 set demo_dtree_dir [list [pwd]] + + pack $w.top.dir -side left -expand yes -fill both -padx 4 -pady 4 + pack $w.top.ent -side left -fill x -anchor c -padx 4 -pady 4 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "dtree:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +proc dtree:browse {ent filename} { + uplevel #0 set demo_dtree_dir $filename + +} + +proc dtree:copy_name {w} { + global demo_dtree_dir + + set demo_dtree_dir [$w cget -value] +} + +proc dtree:okcmd {w} { + global demo_dtree_dir + + puts "You have selected the directory $demo_dtree_dir" + + destroy $w +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> "exit" +} diff --git a/tix/demos/samples/DragDrop.tcl b/tix/demos/samples/DragDrop.tcl new file mode 100644 index 00000000000..1feb61fa271 --- /dev/null +++ b/tix/demos/samples/DragDrop.tcl @@ -0,0 +1,46 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the Drag+Drop features in Tix. Drag+Drop is still +# experimental in Tix. Please don't use. For your eyes only. +# +# +proc RunSample {w} { + + text $w.d -height 5 + $w.d insert end {Quick and dirty example: +click on any node on on the directory lists and drag. You can see the +cursor change its shape. The "dropsite" of the directory lists will be +highlighted when you drag the cursor accorss the directory nodes. +Nothing will happen when you drop. } + + pack $w.d -padx 10 -pady 5 + + tixDirList $w.d1; pack $w.d1 -fill both -padx 10 -pady 5 \ + -side left + tixDirList $w.d2; pack $w.d2 -fill both -padx 10 -pady 5 \ + -side left + + button $w.b -text "Close" -command "destroy $w" + pack $w.b -side left -anchor c -expand yes + + $w.d1 subwidget hlist config -selectmode dragdrop + $w.d2 subwidget hlist config -selectmode dragdrop +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> "exit" +} + diff --git a/tix/demos/samples/DynTree.tcl b/tix/demos/samples/DynTree.tcl new file mode 100644 index 00000000000..dd63abff77b --- /dev/null +++ b/tix/demos/samples/DynTree.tcl @@ -0,0 +1,145 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates how to use the TixTree widget to display +# dynamic hierachical data (the files in the Unix file system) +# + +proc RunSample {w} { + + # We create the frame and the ScrolledHList widget + # at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + # Create a TixTree widget to display the hypothetical DOS disk drive + # + # + tixTree $w.top.a -options { + hlist.separator "/" + hlist.width 35 + hlist.height 25 + } + + pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left + + set tree $w.top.a + set hlist [$tree subwidget hlist] + + $tree config -opencmd "DynTree:OpenDir $tree" + + # Add the root directory the TixTree widget + DynTree:AddDir $tree / + + # The / directory is added in the "open" mode. The user can open it + # and then browse its subdirectories ... + + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +proc DynTree:AddDir {tree dir} { + set hlist [$tree subwidget hlist] + + if {$dir == "/"} { + set text / + } else { + set text [file tail $dir] + } + + $hlist add $dir -itemtype imagetext \ + -text $text -image [tix getimage folder] + + catch { + # We need a catch here because the directory may not be readable by us + # + $tree setmode $dir none + if {[glob -nocomplain $dir/*] != {}} { + $tree setmode $dir open + } + } +} + + +# This command is called whenever the user presses the (+) indicator or +# double clicks on a directory whose mode is "open". It loads the files +# inside that directory into the Tree widget. +# +# Note we didn't specify the -closecmd option for the Tree widget, so it +# performs the default action when the user presses the (-) indicator or +# double clicks on a directory whose mode is "close": hide all of its child +# entries +# +proc DynTree:OpenDir {tree dir} { + set PWD [pwd] + set hlist [$tree subwidget hlist] + + if {[$hlist info children $dir] != {}} { + # We have already loaded this directory. Let's just + # show all the child entries + # + # Note: since we load the directory only once, it will not be + # refreshed if the you add or remove files from this + # directory. + # + foreach kid [$hlist info children $dir] { + $hlist show entry $kid + } + return + } + + if [catch {cd $dir}] { + # We can't read that directory, better not do anything + cd $PWD + return + } + + set files [lsort [glob -nocomplain *]] + foreach f $files { + if [file isdirectory $f] { + if {$dir == "/"} { + set subdir /$f + } else { + set subdir $dir/$f + } + DynTree:AddDir $tree $subdir + } else { + if {$dir == "/"} { + set file /$f + } else { + set file $dir/$f + } + + $hlist add $file -itemtype imagetext \ + -text $f -image [tix getimage file] + } + } + + cd $PWD +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} + diff --git a/tix/demos/samples/EFileDlg.tcl b/tix/demos/samples/EFileDlg.tcl new file mode 100644 index 00000000000..512e71aed59 --- /dev/null +++ b/tix/demos/samples/EFileDlg.tcl @@ -0,0 +1,99 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixExFileSelectDialog widget -- +# This is a neat file selection dialog that will make your apps look +# real good! +# +proc RunSample {w} { + + # Create an entry for the user to input a filename. If he can't + # bother to type in the name, he can press the "Browse ..." button + # and call up the file dialog + # + frame $w.top -border 1 -relief raised + + tixLabelEntry $w.top.ent -label "Select A File:" -labelside top \ + -options { + entry.width 25 + entry.textVariable demo_efdlg_filename + label.anchor w + } + bind [$w.top.ent subwidget entry] <Return> "efdlg:okcmd $w" + + uplevel #0 set demo_efdlg_filename {} + + + button $w.top.btn -text "Browse ..." -command "efdlg:browse" + + pack $w.top.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4 + pack $w.top.btn -side left -anchor s -padx 4 -pady 4 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "efdlg:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +# Pop up a file selection dialog +# +proc efdlg:browse {} { + # [Hint] + # The best way to use an ExFileSelectDialog is not to create one yourself + # but to call the command "tix filedialog". This command creates one file + # dialog box that is shared by different parts of the application. + # This way, your application can save resources because it doesn't + # need to create a lot of file dialog boxes even if it needs to input + # file names at a lot of different occasions. + # + set dialog [tix filedialog tixExFileSelectDialog] + $dialog config -command efdlg:select_file + + $dialog subwidget fsbox config -filetypes { + {{*} {* -- All files}} + {{*.txt} {*.txt -- Text files}} + {{*.c} {*.c -- C source files}} + } + + $dialog popup +} + +proc efdlg:select_file {file} { + global demo_efdlg_filename + + set demo_efdlg_filename $file +} + +proc efdlg:okcmd {w} { + global demo_efdlg_filename + + if {$demo_efdlg_filename != {}} { + puts "You have selected the file $demo_efdlg_filename" + } else { + puts "You haven't selected any file" + } + + destroy $w +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} diff --git a/tix/demos/samples/EditGrid.tcl b/tix/demos/samples/EditGrid.tcl new file mode 100644 index 00000000000..615d6fde6b9 --- /dev/null +++ b/tix/demos/samples/EditGrid.tcl @@ -0,0 +1,277 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# Demonstrates the use of editable entries in a Grid widget. +# + +proc RunSample {w} { + global editgrid + + wm title $w "Doe Inc. Performance" + wm geometry $w 640x300 + + label $w.lab -justify left -text \ +"The left column is calculated automatically. To calculate the right column, +press the \"Calculate\" button" + pack $w.lab -side top -anchor c -padx 3 -pady 3 + + # Create the buttons + # + set f [frame $w.f -relief flat] + pack $f -side right -fill y + set add [button $f.add -text "Add Row" -width 9 \ + -command "EditGrid_addRow"] + set edit [button $f.edit -text "Edit" -width 9 \ + -command "EditGrid_edit"] + set cal [button $f.cal -text "Calculate" -width 9 \ + -command "EditGrid_calculate"] + set close [button $f.close -text "Close" -width 9 \ + -command "destroy $w"] + pack $add -side top -padx 10 + pack $edit -side top -padx 10 + pack $cal -side top -padx 10 -pady 2 + pack $close -side bottom -padx 10 + + # Create the grid and set options to make it editable. + # + tixScrolledGrid $w.g -bd 0 + pack $w.g -expand yes -fill both -padx 3 -pady 3 + + set grid [$w.g subwidget grid] + $grid config \ + -formatcmd "EditGrid_format $grid" \ + -editnotifycmd "EditGrid_editNotify" \ + -editdonecmd "EditGrid_editDone" \ + -selectunit cell \ + -selectmode single + + # Insert some initial data + # + $grid set 0 1 -text "City #1" + $grid set 0 2 -text "City #2" + $grid set 0 3 -text "City #3" + $grid set 0 5 -text "Combined" + + $grid set 2 0 -text "Population" + $grid set 4 0 -text "Avg. Income" + + $grid set 2 1 -text 125 + $grid set 2 2 -text 81 + $grid set 2 3 -text 724 + + $grid set 4 1 -text 24432.12 + $grid set 4 2 -text 18290.24 + $grid set 4 3 -text 18906.34 + + # Global data used by other EditGrid_ procedures. + # + set editgrid(g) $grid + set editgrid(top) 1 + set editgrid(bot) 3 + set editgrid(result) 5 + + EditGrid_calPop + EditGrid_calIncome +} + +# EditGrid_edit -- +# +# Prompts the user to edit a cell. +# +proc EditGrid_edit {} { + global editgrid + set grid $editgrid(g) + + set ent [$grid anchor get] + if [string comp $ent ""] { + $grid edit set [lindex $ent 0] [lindex $ent 1] + } +} + +# EditGrid_addRow -- +# +# Adds a new row to the table. +# +proc EditGrid_addRow {} { + global editgrid + set grid $editgrid(g) + + $grid edit apply + + $grid move row $editgrid(result) $editgrid(result) 1 + + incr editgrid(bot) + set editgrid(result) [expr $editgrid(bot) + 2] + $grid set 0 $editgrid(bot) -text "City #$editgrid(bot)" + $grid set 2 $editgrid(bot) -text 0 + $grid set 4 $editgrid(bot) -text 0.0 + + EditGrid_calPop + EditGrid_calIncome +} + +# EditGrid_calPop -- +# +# Calculates the total population +# +proc EditGrid_calPop {} { + global editgrid + set grid $editgrid(g) + + set pop 0 + + for {set i $editgrid(top)} {$i <= $editgrid(bot)} {incr i} { + incr pop [$grid entrycget 2 $i -text] + } + + $grid set 2 $editgrid(result) -text $pop +} + +# EditGrid_calIncome -- +# +# Calculates the average income. +# +proc EditGrid_calIncome {} { + global editgrid + set grid $editgrid(g) + + set income 0 + set total_pop 0 + for {set i $editgrid(top)} {$i <= $editgrid(bot)} {incr i} { + set pop [$grid entrycget 2 $i -text] + set inc [$grid entrycget 4 $i -text] + set income [expr $income + $pop.0 * $inc] + incr total_pop $pop + } + + $grid set 4 $editgrid(result) -text [expr $income/$total_pop] + +} + +# EditGrid_calculate -- +# +# Recalculates both columns. +# +proc EditGrid_calculate {} { + global editgrid + set grid $editgrid(g) + + $grid edit apply + EditGrid_calIncome +} + +# EditGrid_editNotify -- +# +# Returns true if an entry can be edited. +# +proc EditGrid_editNotify {x y} { + global editgrid + set grid $editgrid(g) + + if {$x == 2 || $x == 4} { + if {$y >= $editgrid(top) && $y <= $editgrid(bot)} { + set editgrid(oldValue) [$grid entrycget $x $y -text] + return 1 + } + } + return 0 +} + +# EditGrid_editDone -- +# +# Gets called when the user is done editing an entry. +# +proc EditGrid_editDone {x y} { + global editgrid + set grid $editgrid(g) + + if {$x == 2} { + set pop [$grid entrycget $x $y -text] + if [catch { + format %d $pop + }] { + $grid entryconfig $x $y -text $editgrid(oldValue) + tk_dialog .editGridWarn "" \ + "$pop is not an valid integer. Try again" \ + warning 0 Ok + } else { + $grid entryconfig 4 $editgrid(result) -text "-" + EditGrid_calPop + } + } else { + set income [$grid entrycget $x $y -text] + if [catch { + format %f $income + }] { + $grid entryconfig $x $y -text $editgrid(oldValue) + tk_dialog .editGridWarn "" \ + "$income is not an valid floating number. Try again" \ + warning 0 Ok + } else { + $grid entryconfig 4 $editgrid(result) -text "-" + } + } +} + +# EditGrid_format -- +# +# This command is called whenever the background of the grid +# needs to be reformatted. The x1, y1, x2, y2 sprcifies the four +# corners of the area that needs to be reformatted. +# +proc EditGrid_format {w area x1 y1 x2 y2} { + global editgrid + + set bg(s-margin) gray65 + set bg(x-margin) gray65 + set bg(y-margin) gray65 + set bg(main) gray20 + + case $area { + main { + foreach col {2 4} { + $w format border $col 1 $col $editgrid(bot) \ + -relief flat -filled 1 -yon 1 -yoff 1\ + -bd 0 -bg #b0b0f0 -selectbackground #a0b0ff + $w format border $col 2 $col $editgrid(bot) \ + -relief flat -filled 1 -yon 1 -yoff 1\ + -bd 0 -bg #80b080 -selectbackground #80b0ff + } + + $w format grid $x1 $y1 $x2 $y2 \ + -relief raised -bd 1 -bordercolor $bg($area) -filled 0 -bg red\ + -xon 1 -yon 1 -xoff 0 -yoff 0 -anchor se + } + y-margin { + $w format border $x1 $y1 $x2 $y2 \ + -fill 1 -relief raised -bd 1 -bg $bg($area) \ + -selectbackground gray80 + } + default { + $w format border $x1 $y1 $x2 $y2 \ + -filled 1 \ + -relief raised -bd 1 -bg $bg($area) \ + -selectbackground gray80 + } + } + +# case $area { +# {main y-margin} { +# set y [expr $editgrid(bot) + 1] +# $w format border 0 $y 100 $y -bg black -filled 1 -bd 0 +# } +# } +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/FileDlg.tcl b/tix/demos/samples/FileDlg.tcl new file mode 100644 index 00000000000..0a80b08b0fd --- /dev/null +++ b/tix/demos/samples/FileDlg.tcl @@ -0,0 +1,94 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixFileSelectDialog widget -- +# This is a neat file selection dialog that looks like the Motif +# file-selection dialog widget. I know that Motif sucks, but +# tixFileSelectDialog looks neat nevertheless. +# +proc RunSample {w} { + + # Create an entry for the user to input a filename. If he can't + # bother to type in the name, he can press the "Browse ..." button + # and call up the file dialog + # + frame $w.top -border 1 -relief raised + + tixLabelEntry $w.top.ent -label "Select A File:" -labelside top \ + -options { + entry.width 25 + entry.textVariable demo_fdlg_filename + label.anchor w + } + bind [$w.top.ent subwidget entry] <Return> "fdlg:okcmd $w" + + uplevel #0 set demo_fdlg_filename {} + + + button $w.top.btn -text "Browse ..." -command "fdlg:browse" + + pack $w.top.ent -side left -expand yes -fill x -anchor s -padx 4 -pady 4 + pack $w.top.btn -side left -anchor s -padx 4 -pady 4 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "fdlg:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +# Pop up a file selection dialog +# +proc fdlg:browse {} { + # [Hint] + # The best way to use an FileSelectDialog is not to create one yourself + # but to call the command "tix filedialog". This command creates one file + # dialog box that is shared by different parts of the application. + # This way, your application can save resources because it doesn't + # need to create a lot of file dialog boxes even if it needs to input + # file names at a lot of different occasions. + # + set dialog [tix filedialog tixFileSelectDialog] + $dialog config -command fdlg:select_file + + $dialog popup +} + +proc fdlg:select_file {file} { + global demo_fdlg_filename + + set demo_fdlg_filename $file +} + +proc fdlg:okcmd {w} { + global demo_fdlg_filename + + if {$demo_fdlg_filename != {}} { + puts "You have selected the file $demo_fdlg_filename" + } else { + puts "You haven't selected any file" + } + + destroy $w +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} diff --git a/tix/demos/samples/FileEnt.tcl b/tix/demos/samples/FileEnt.tcl new file mode 100644 index 00000000000..c70c0827973 --- /dev/null +++ b/tix/demos/samples/FileEnt.tcl @@ -0,0 +1,77 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixFileEntry widget -- an +# easy of letting the user select a filename +# +proc RunSample {w} { + + # Create the tixFileEntry's on the top of the dialog box + # + frame $w.top -border 1 -relief raised + + global demo_fent_from demo_fent_to + + tixFileEntry $w.top.a -label "Move File From: " \ + -variable demo_fent_from \ + -options { + entry.width 25 + label.width 16 + label.underline 10 + label.anchor e + } + + tixFileEntry $w.top.b -label "To: " \ + -variable demo_fent_to \ + -options { + entry.width 25 + label.underline 0 + label.width 16 + label.anchor e + } + + pack $w.top.a $w.top.b -side top -anchor w -pady 3 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "fent:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes + + # Let's set some nice bindings for keyboard accelerators + # + bind $w <Alt-f> "focus $w.top.a" + bind $w <Alt-t> "focus $w.top.b" + bind $w <Alt-o> "[$w.box subwidget ok] invoke; break" + bind $w <Alt-c> "[$w.box subwidget cancel] invoke; break" +} + +proc fent:okcmd {w} { + global demo_fent_from demo_fent_to + + puts "You wanted to move file from $demo_fent_from to $demo_fent_to" + + destroy $w +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/HList1.tcl b/tix/demos/samples/HList1.tcl new file mode 100644 index 00000000000..eb3150a03e8 --- /dev/null +++ b/tix/demos/samples/HList1.tcl @@ -0,0 +1,155 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixHList widget -- you can +# use to display data in a tree structure. For example, your family tree +# +# +proc RunSample {w} { + + # Create the tixHList and the tixLabelEntry widgets on the on the top + # of the dialog box + # + # [Hint] We create the tixHList and and the scrollbar by ourself, + # but it is more convenient to use the tixScrolledHlist widget + # which does all the chores for us. + # + # [Hint] Use of the -browsecmd and -command options: + # We want to set the tixLabelEntry accordingly whenever the user + # single-clicks on an entry in the HList box. Also, when the user + # double-clicks, we want to print out the selection and close + # the dialog box + # + frame $w.top -border 1 -relief raised + + tixHList $w.top.h -yscrollcommand "$w.top.s set" -separator / \ + -browsecmd "hlist1:browse $w.top.h" \ + -command "hlist1:activate $w.top.h"\ + -wideselection false \ + -indent 15 + scrollbar $w.top.s -command "$w.top.h yview" -takefocus 0 + + # Some icons for our list entries + # + global folder1 folder2 + set img1 [image create bitmap -data $folder1] + set img2 [image create bitmap -data $folder2] + + # Put our directories into the HList entry + # + set h $w.top.h + set dirs { + / + /lib + /pkg + /usr + /usr/lib + /usr/local + /usr/local/lib + /pkg/lib + } + foreach d $dirs { + $h add $d -itemtype imagetext -text $d -image $img2 -data $d + + # We only want the user to select the directories that + # ends by "lib" + if {![string match "*lib" $d]} { + $h entryconfig $d -state disabled -image $img1 + } + } + + # We use a LabelEntry to hold the installation directory. The user + # can choose from the DirList widget, or he can type in the directory + # manually + # + tixLabelEntry $w.top.e -label "Installation Directory:" -labelside top \ + -options { + entry.width 25 + entry.textVariable demo_hlist_dir + label.anchor w + } + bind [$w.top.e subwidget entry] <Return> "hlist:okcmd $w" + + # Set the default value + # + uplevel #0 set demo_hlist_dir /usr/local/lib + $h anchor set /usr/local/lib + $h select set /usr/local/lib + + pack $w.top.h -side left -expand yes -fill both -padx 2 -pady 2 + pack $w.top.s -side left -fill y -pady 2 + pack $w.top.e -side left -expand yes -fill x -anchor s -padx 4 -pady 2 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "hlist:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +# In an actual program, you may want to tell the user how much space he has +# left in this directory +# +# +proc hlist1:browse {w dir} { + global demo_hlist_dir + + set demo_hlist_dir [$w entrycget $dir -data] +} + +# In an actual program, you will install your favorit application +# in the selected directory +# +proc hlist1:activate {w dir} { + global demo_hlist_dir + + set demo_hlist_dir [$w entrycget $dir -data] + puts "You have selected the directory $demo_hlist_dir" + + destroy [winfo toplevel $w] +} + +proc hlist:okcmd {w} { + global demo_hlist_dir + + puts "You have selected the directory $demo_hlist_dir" + + destroy $w +} + +set folder1 { +#define foo_width 16 +#define foo_height 12 +static unsigned char foo_bits[] = { + 0x00, 0x00, 0x00, 0x3e, 0xfe, 0x41, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, + 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0x02, 0x40, 0xfe, 0x7f, 0x00, 0x00};} + +set folder2 { +#define foo_width 16 +#define foo_height 12 +static unsigned char foo_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x02, 0x40, 0x02, 0x44, 0xf2, 0x4f, + 0xf2, 0x5f, 0xf2, 0x4f, 0x02, 0x44, 0x02, 0x40, 0xfe, 0x7f, 0x00, 0x00}; +} + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} + diff --git a/tix/demos/samples/LabEntry.tcl b/tix/demos/samples/LabEntry.tcl new file mode 100644 index 00000000000..62a52087da8 --- /dev/null +++ b/tix/demos/samples/LabEntry.tcl @@ -0,0 +1,90 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixLabelEntry widget -- an entry that +# come with a label at its side, so you don't need to create +# extra frames on your own and do the messy hierarchical packing. This +# example is adapted from the tixControl example, except now you don't +# have arrow buttons to adjust the values for you ... +# + +proc RunSample {w} { + + # Create the tixLabelEntrys on the top of the dialog box + # + frame $w.top -border 1 -relief raised + + # $w.top.a allows only integer values + # + # [Hint] The -options switch sets the options of the subwidgets. + # [Hint] We set the label.width subwidget option of the Controls to + # be 16 so that their labels appear to be aligned. + # + global lent_demo_maker lent_demo_thrust lent_demo_num_engins + set lent_demo_maker P&W + set lent_demo_thrust 20000.0 + set lent_demo_num_engins 2 + + tixLabelEntry $w.top.a -label "Number of Engines: " \ + -options { + entry.width 10 + label.width 20 + label.anchor e + entry.textVariable lent_demo_num_engins + } + + tixLabelEntry $w.top.b -label "Thrust: "\ + -options { + entry.width 10 + label.width 20 + label.anchor e + entry.textVariable lent_demo_thrust + } + + tixLabelEntry $w.top.c -label "Engin Maker: " \ + -options { + entry.width 10 + label.width 20 + label.anchor e + entry.textVariable lent_demo_maker + } + + pack $w.top.a $w.top.b $w.top.c -side top -anchor w + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "labe:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +proc labe:okcmd {w} { + global lent_demo_maker lent_demo_thrust lent_demo_num_engins + + puts "You selected $lent_demo_num_engins engin(s) of thrust $lent_demo_thrust made \ +by $lent_demo_maker" + + destroy $w +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/LabFrame.tcl b/tix/demos/samples/LabFrame.tcl new file mode 100644 index 00000000000..3bae9e9e1d1 --- /dev/null +++ b/tix/demos/samples/LabFrame.tcl @@ -0,0 +1,81 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixLabelFrame widget -- a frame that +# come with a label at its side. It looks nifty when you use the set the +# -labelside option to "acrosstop". Note that a lot of Tix widgets, such +# as tixComboBox or tixControl, have the -labelside and -label options. So +# you can use these options to achieve the same effect as in this file +# + +proc RunSample {w} { + + # Create the radiobuttons at the top of the dialog box, put them + # inside two tixLabelFrames: + # + frame $w.top -border 1 -relief raised + + tixLabelFrame $w.top.a -label Font: -labelside acrosstop -options { + label.padX 5 + } + tixLabelFrame $w.top.b -label Size: -labelside acrosstop -options { + label.padX 5 + } + + pack $w.top.a $w.top.b -side left -expand yes -fill both + + # Create the radiobuttons inside the left frame. + # + # [Hint] You *must* create the new widgets inside the "frame" + # subwidget, *not* as immediate children of $w.top.a! + # + set f [$w.top.a subwidget frame] + foreach color {Red Green Blue Yellow Orange Purple} { + set lower [string tolower $color] + radiobutton $f.$lower -text $color -variable demo_color \ + -relief flat -value $lower -bd 2 -pady 0 -width 7 -anchor w + pack $f.$lower -side top -pady 0 -anchor w -padx 6 + } + + # Create the radiobuttons inside the right frame. + # + set f [$w.top.b subwidget frame] + foreach point {8 10 12 14 18 24} { + set lower [string tolower $point] + radiobutton $f.$lower -text $point -variable demo_point \ + -relief flat -value $lower -bd 2 -pady 0 -width 4 -anchor w + pack $f.$lower -side top -pady 0 -anchor w -padx 8 + } + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "labf:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +proc labf:okcmd {w} { + destroy $w +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/ListNBK.tcl b/tix/demos/samples/ListNBK.tcl new file mode 100644 index 00000000000..c975dea7e52 --- /dev/null +++ b/tix/demos/samples/ListNBK.tcl @@ -0,0 +1,83 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This program demonstrates the ListBoteBook widget, which is very similar +# to a NoteBook widget but uses an HList instead of page tabs to list the +# pages. + +proc RunSample {w} { + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + #---------------------------------------------------------------------- + # Create the ListNoteBook with nice icons + #---------------------------------------------------------------------- + tixListNoteBook $top.n -ipadx 6 -ipady 6 + + set img0 [tix getimage harddisk] + set img1 [tix getimage network] + + $top.n subwidget hlist add hard_disk -itemtype imagetext \ + -image $img0 -text "Hard Disk" -under 0 + $top.n subwidget hlist add network -itemtype imagetext \ + -image $img1 -text "Network" -under 0 + + $top.n add hard_disk + $top.n add network + + # + # Create the widgets inside the two pages + + # We use these options to set the sizes of the subwidgets inside the + # notebook, so that they are well-aligned on the screen. + # + set name [tixOptionName $w] + option add *$name*TixControl*entry.width 10 + option add *$name*TixControl*label.width 18 + option add *$name*TixControl*label.anchor e + + set f [$top.n subwidget hard_disk] + + tixControl $f.a -value 12 -label "Access Time: " + tixControl $f.w -value 400 -label "Write Throughput: " + tixControl $f.r -value 400 -label "Read Throughput: " + tixControl $f.c -value 1021 -label "Capacity: " + pack $f.a $f.w $f.r $f.c -side top -padx 20 -pady 2 + + set f [$top.n subwidget network] + + tixControl $f.a -value 12 -label "Access Time: " + tixControl $f.w -value 400 -label "Write Throughput: " + tixControl $f.r -value 400 -label "Read Throughput: " + tixControl $f.c -value 1021 -label "Capacity: " + tixControl $f.u -value 10 -label "Users: " + + pack $f.a $f.w $f.r $f.c $f.u -side top -padx 20 -pady 2 + + pack $top.n -expand yes -fill both -padx 5 -pady 5 + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + +#---------------------------------------------------------------------- +# Start-up code +#---------------------------------------------------------------------- + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/Meter.tcl b/tix/demos/samples/Meter.tcl new file mode 100644 index 00000000000..aa60c39169c --- /dev/null +++ b/tix/demos/samples/Meter.tcl @@ -0,0 +1,73 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This program demonstrates the use of the tixMeter widget -- it is +# used to display the progress of a background job +# + +proc RunSample {w} { + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + # Create the Meter and the Label + # + label $top.lab -text "Work in progress ...." + tixMeter $top.met -value 0 -text 0% + + pack $top.lab -side top -padx 50 -pady 10 -anchor c + pack $top.met -side top -padx 50 -pady 10 -anchor c + + + # Create the buttons + # + $box add cancel -text Cancel -command "destroy $w" \ + -width 6 -under 0 + $box add restart -text Restart -width 6 -under 0 + + $box subwidget restart config -command \ + "Meter:Start $top.met [$box subwidget cancel] [$box subwidget restart]" + + $box subwidget restart invoke +} + +proc Meter:Start {meter cancel restart} { + $restart config -state disabled + $cancel config -text Cancel + after 40 Meter:BackgroundJob $meter 0 $cancel $restart +} + +proc Meter:BackgroundJob {meter progress cancel restart} { + if ![winfo exists $meter] { + # the window has already been destroyed + # + return + } + + set progress [expr $progress + 0.02] + set text [expr int($progress*100.0)]% + + $meter config -value $progress -text $text + + if {$progress < 1.0} { + after 40 Meter:BackgroundJob $meter $progress $cancel $restart + } else { + $cancel config -text OK -under 0 + $restart config -state normal + } +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/NoteBook.tcl b/tix/demos/samples/NoteBook.tcl new file mode 100644 index 00000000000..3db07202e1a --- /dev/null +++ b/tix/demos/samples/NoteBook.tcl @@ -0,0 +1,98 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixNoteBook widget, which allows +# you to lay out your interface using a "notebook" metaphore +# + +proc RunSample {w} { + + # We use these options to set the sizes of the subwidgets inside the + # notebook, so that they are well-aligned on the screen. + # + set name [tixOptionName $w] + option add *$name*TixControl*entry.width 10 + option add *$name*TixControl*label.width 18 + option add *$name*TixControl*label.anchor e + + # Create the notebook widget and set its backpagecolor to gray. + # Note that the -backpagecolor option belongs to the "nbframe" + # subwidget. + tixNoteBook $w.nb -ipadx 6 -ipady 6 + $w config -bg gray + $w.nb subwidget nbframe config -backpagecolor gray + + # Create the two tabs on the notebook. The -underline option + # puts a underline on the first character of the labels of the tabs. + # Keyboard accelerators will be defined automatically according + # to the underlined character. + # + $w.nb add hard_disk -label "Hard Disk" -underline 0 + $w.nb add network -label "Network" -underline 0 + pack $w.nb -expand yes -fill both -padx 5 -pady 5 -side top + + #---------------------------------------- + # Create the first page + #---------------------------------------- + set f [$w.nb subwidget hard_disk] + + # Create two frames: one for the common buttons, one for the + # other widgets + # + frame $f.f + frame $f.common + pack $f.f -side left -padx 2 -pady 2 -fill both -expand yes + pack $f.common -side right -padx 2 -pady 2 -fill y + + # Create the controls that only belong to this page + # + tixControl $f.f.a -value 12 -label "Access Time: " + tixControl $f.f.w -value 400 -label "Write Throughput: " + tixControl $f.f.r -value 400 -label "Read Throughput: " + tixControl $f.f.c -value 1021 -label "Capacity: " + pack $f.f.a $f.f.w $f.f.r $f.f.c -side top -padx 20 -pady 2 + + # Create the common buttons + # + CreateCommonButtons $w $f.common + + #---------------------------------------- + # Create the second page + #---------------------------------------- + set f [$w.nb subwidget network] + + frame $f.f + frame $f.common + pack $f.f -side left -padx 2 -pady 2 -fill both -expand yes + pack $f.common -side right -padx 2 -pady 2 -fill y + + tixControl $f.f.a -value 12 -label "Access Time: " + tixControl $f.f.w -value 400 -label "Write Throughput: " + tixControl $f.f.r -value 400 -label "Read Throughput: " + tixControl $f.f.c -value 1021 -label "Capacity: " + tixControl $f.f.u -value 10 -label "Users: " + + pack $f.f.a $f.f.w $f.f.r $f.f.c $f.f.u -side top -padx 20 -pady 2 + + CreateCommonButtons $w $f.common +} + +proc CreateCommonButtons {w f} { + button $f.ok -text OK -width 6 -command "destroy $w" + button $f.cancel -text Cancel -width 6 -command "destroy $w" + + pack $f.ok $f.cancel -side top -padx 2 -pady 2 +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> {if {"%W" == ".demo"} exit} +} diff --git a/tix/demos/samples/OptMenu.tcl b/tix/demos/samples/OptMenu.tcl new file mode 100644 index 00000000000..fea64799a29 --- /dev/null +++ b/tix/demos/samples/OptMenu.tcl @@ -0,0 +1,99 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixOptionMenu widget -- you can +# use it for the user to choose from a fixed set of options +# +set opt_options {text formatted post html tex rtf} + +set opt_labels(text) "Plain Text" +set opt_labels(formatted) "Formatted Text" +set opt_labels(post) "PostScript" +set opt_labels(html) "HTML" +set opt_labels(tex) "LaTeX" +set opt_labels(rtf) "Rich Text Format" + +proc RunSample {w} { + catch {uplevel #0 unset demo_opt_from} + catch {uplevel #0 unset demo_opt_to } + + # Create the tixOptionMenu's on the top of the dialog box + # + frame $w.top -border 1 -relief raised + + tixOptionMenu $w.top.from -label "From File Format : " \ + -variable demo_opt_from \ + -options { + label.width 19 + label.anchor e + menubutton.width 15 + } + + tixOptionMenu $w.top.to -label "To File Format : " \ + -variable demo_opt_to \ + -options { + label.width 19 + label.anchor e + menubutton.width 15 + } + + # Add the available options to the two OptionMenu widgets + # + # [Hint] You have to add the options first before you set the + # global variables "demo_opt_from" and "demo_opt_to". Otherwise + # the OptionMenu widget will complain about "unknown options"! + # + global opt_options opt_labels + foreach opt $opt_options { + $w.top.from add command $opt -label $opt_labels($opt) + $w.top.to add command $opt -label $opt_labels($opt) + } + + uplevel #0 set demo_opt_from html + uplevel #0 set demo_opt_to post + + pack $w.top.from $w.top.to -side top -anchor w -pady 3 -padx 6 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "opt:okcmd $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes + + # Let's set some nice bindings for keyboard accelerators + # + bind $w <Alt-f> "focus $w.top.from" + bind $w <Alt-t> "focus $w.top.to" + bind $w <Alt-o> "[$w.box subwidget ok] invoke; break" + bind $w <Alt-c> "[$w.box subwidget cancel] invoke; break" +} + +proc opt:okcmd {w} { + global demo_opt_from demo_opt_to opt_labels + + puts "You wanted to convert file from $opt_labels($demo_opt_from) to $opt_labels($demo_opt_to)" + + destroy $w +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> {if {"%W" == ".demo"} exit} +} diff --git a/tix/demos/samples/PanedWin.tcl b/tix/demos/samples/PanedWin.tcl new file mode 100644 index 00000000000..180e89e0459 --- /dev/null +++ b/tix/demos/samples/PanedWin.tcl @@ -0,0 +1,108 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixPanedWindow widget. This program +# is a dummy news reader: the user can adjust the sizes of the list +# of artical names and the size of the text widget that shows the body +# of the artical +# + +proc RunSample {w} { + + # We create the frame at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + # Use a LabelEntry widget to show the name of the newsgroup + # [Hint] We disable the entry widget so that the user can't + # mess up with the name of the newsgroup + # + tixLabelEntry $w.top.name -label "Newsgroup: " -options { + entry.width 25 + } + $w.top.name subwidget entry insert 0 "comp.lang.tcl" + $w.top.name subwidget entry config -state disabled + + pack $w.top.name -side top -anchor c -fill x -padx 14 -pady 6 + # Now use a PanedWindow to contain the list and text widgets + # + tixPanedWindow $w.top.pane -paneborderwidth 0 -separatorbg gray50 + pack $w.top.pane -side top -expand yes -fill both -padx 10 -pady 10 + + set p1 [$w.top.pane add list -min 70 -size 100] + set p2 [$w.top.pane add text -min 70] + + tixScrolledListBox $p1.list + $p1.list subwidget listbox config -font [tix option get fixed_font] + + tixScrolledText $p2.text + $p2.text subwidget text config -font [tix option get fixed_font] + + pack $p1.list -expand yes -fill both -padx 4 -pady 6 + pack $p2.text -expand yes -fill both -padx 4 -pady 6 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 8 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 8 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes + + # Put the junk inside the listbox and the tetx widget + # + $p1.list subwidget listbox insert end \ + " 12324 Re: TK is good for your health" \ + "+ 12325 Re: TK is good for your health" \ + "+ 12326 Re: Tix is even better for your health (Was: TK is good...)" \ + " 12327 Re: Tix is even better for your health (Was: TK is good...)" \ + "+ 12328 Re: Tix is even better for your health (Was: TK is good...)" \ + " 12329 Re: Tix is even better for your health (Was: TK is good...)" \ + "+ 12330 Re: Tix is even better for your health (Was: TK is good...)" + + $p2.text subwidget text config -wrap none -bg \ + [$p1.list subwidget listbox cget -bg] + $p2.text subwidget text insert end { +Mon, 19 Jun 1995 11:39:52 comp.lang.tcl Thread 34 of 220 +Lines 353 A new way to put text and bitmaps together iNo responses +ioi@blue.seas.upenn.edu Ioi K. Lam at University of Pennsylvania + +Hi, + +I have implemented a new image type called "compound". It allows you +to glue together a bunch of bitmaps, images and text strings together +to form a bigger image. Then you can use this image with widgets that +support the -image option. This way you can display very fancy stuffs +in your GUI. For example, you can display a text string string +together with a bitmap, at the same time, inside a TK button widget. A +screenshot of compound images can be found at the bottom of this page: + + http://www.cis.upenn.edu/~ioi/tix/screenshot.html + +You can also you is in other places such as putting fancy bitmap+text +in menus, tabs of tixNoteBook widgets, etc. This feature will be +included in the next release of Tix (4.0b1). Count on it to make jazzy +interfaces!} + +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> {if {"%W" == ".demo"} exit} +} + diff --git a/tix/demos/samples/PopMenu.tcl b/tix/demos/samples/PopMenu.tcl new file mode 100644 index 00000000000..aa4f9d2c7a6 --- /dev/null +++ b/tix/demos/samples/PopMenu.tcl @@ -0,0 +1,69 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixPopupMenu widget. +# + +proc RunSample {w} { + + # We create the frame and the button, then we'll bind the PopupMenu + # to both widgets. The result is, when you press the right mouse + # button over $w.top or $w.top.but, the PopupMenu will come up. + # + + frame $w.top -relief raised -bd 1 + + button $w.top.but -text {Press the right mouse button over +this button or its surrounding area} + + pack $w.top.but -expand yes -fill both -padx 50 -pady 50 + + tixPopupMenu $w.top.p -title "Popup Test" + $w.top.p bind $w.top + $w.top.p bind $w.top.but + + # Set the entries inside the PopupMenu widget. + # [Hint] You have to manipulate the "menu" subwidget. + # $w.top.p itself is NOT a menu widget. + # [Hint] Watch carefully how the sub-menu is created + # + set menu [$w.top.p subwidget menu] + $menu add command -label Desktop -under 0 + $menu add command -label Select -under 0 + $menu add command -label Find -under 0 + $menu add command -label System -under 1 + $menu add command -label Help -under 0 + $menu add cascade -label More -menu $menu.m1 + menu $menu.m1 + $menu.m1 add command -label Hello + + pack $w.top.but -side top -padx 40 -pady 50 + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> {if {"%W" == ".demo"} exit} +} diff --git a/tix/demos/samples/SGrid0.tcl b/tix/demos/samples/SGrid0.tcl new file mode 100644 index 00000000000..e3d5149981a --- /dev/null +++ b/tix/demos/samples/SGrid0.tcl @@ -0,0 +1,131 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# A very simple demonstration of the tixGrid widget +# + +proc RunSample {w} { + wm title $w "The First Grid Example" + wm geometry $w 480x300 + + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + label $top.lab -text "This widget is still under alpha +Please ignore the debug messages +Not all features have been implemented" -justify left + pack $top.lab -side top -anchor c -padx 3 -pady 3 + + MakeGrid $top + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + +# This command is called whenever the background of the grid needs to +# be reformatted. The x1, y1, x2, y2 specifies the four corners of the area +# that needs to be reformatted. +# +# area: +# x-margin: the horizontal margin +# y-margin: the vertical margin +# s-margin: the overlap area of the x- and y-margins +# main: The rest +# +proc SimpleFormat {w area x1 y1 x2 y2} { + + global margin + set bg(s-margin) gray65 + set bg(x-margin) gray65 + set bg(y-margin) gray65 + set bg(main) gray20 + + case $area { + main { + # The "grid" format is consecutive boxes without 3d borders + # + $w format grid $x1 $y1 $x2 $y2 \ + -relief raised -bd 1 -bordercolor $bg($area) -filled 0 -bg red\ + -xon 1 -yon 1 -xoff 0 -yoff 0 -anchor se + } + {x-margin y-margin s-margin} { + # border specifies consecutive 3d borders + # + $w format border $x1 $y1 $x2 $y2 \ + -fill 1 -relief raised -bd 1 -bg $bg($area) \ + -selectbackground gray80 + } + } +} + +# Print a number in $ format +# +# +proc Dollar {s} { + set n [string len $s] + set start [expr $n % 3] + if {$start == 0} { + set start 3 + } + + set str "" + for {set i 0} {$i < $n} {incr i} { + if {$start == 0} { + append str "," + set start 3 + } + incr start -1 + append str [string index $s $i] + } + return $str +} + +proc MakeGrid {w} { + # Create the grid + # + tixScrolledGrid $w.g -bd 0 + pack $w.g -expand yes -fill both -padx 3 -pady 3 + + set grid [$w.g subwidget grid] + $grid config -formatcmd "SimpleFormat $grid" + + + # Set the size of the columns + # + $grid size col 0 -size 10char + $grid size col 1 -size auto + $grid size col 2 -size auto + $grid size col 3 -size auto + $grid size col 4 -size auto + + # set the default size of the column and rows. these sizes will be used + # if the size of a row or column has not be set via the "size col ?" + # command + $grid size col default -size 5char + $grid size row default -size 1.1char -pad0 3 + + for {set x 0} {$x < 10} {incr x} { + for {set y 0} {$y < 10} {incr y} { + $grid set $x $y -itemtype text -text ($x,$y) + } + } +} + + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/SGrid1.tcl b/tix/demos/samples/SGrid1.tcl new file mode 100644 index 00000000000..1b94860f493 --- /dev/null +++ b/tix/demos/samples/SGrid1.tcl @@ -0,0 +1,211 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# Demonstrates the tixGrid widget +# + +proc RunSample {w} { + wm title $w "Doe Inc. Performance" + wm geometry $w 640x300 + + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + label $top.lab -text "This widget is still under alpha +Please ignore the debug messages +Not all features have been implemented" -justify left + pack $top.lab -side top -anchor c -padx 3 -pady 3 + + MakeGrid $top + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + +# This command is called whenever the background of the grid needs to +# be reformatted. The x1, y1, x2, y2 sprcifies the four corners of the area +# that needs to be reformatted. +# +proc gformat {w area x1 y1 x2 y2} { + set bg(s-margin) gray65 + set bg(x-margin) gray65 + set bg(y-margin) gray65 + set bg(main) gray20 + + case $area { + main { + for {set y [expr ($y1/2) * 2]} {$y <= $y2} {incr y 2} { + $w format border $x1 $y $x2 $y \ + -relief flat -filled 1\ + -bd 0 -bg #80b080 -selectbackground #80b0ff + } + $w format grid $x1 $y1 $x2 $y2 \ + -relief raised -bd 1 -bordercolor $bg($area) -filled 0 -bg red\ + -xon 1 -yon 1 -xoff 0 -yoff 0 -anchor se + } + y-margin { + $w format border $x1 $y1 $x2 $y2 \ + -fill 1 -relief raised -bd 1 -bg $bg($area) \ + -selectbackground gray80 + } + + default { + $w format border $x1 $y1 $x2 $y2 \ + -filled 1 \ + -relief raised -bd 1 -bg $bg($area) \ + -selectbackground gray80 + } + } +} + +# Print a number in $ format +# +# +proc Dollar {s} { + set n [string len $s] + set start [expr $n % 3] + if {$start == 0} { + set start 3 + } + + set str "" + for {set i 0} {$i < $n} {incr i} { + if {$start == 0} { + append str "," + set start 3 + } + incr start -1 + append str [string index $s $i] + } + return $str +} + +proc MakeGrid {w} { + + # data format {year revenue profit} + # + set data { + {1970 1000000000 1000000} + {1971 1100000000 2000000} + {1972 1200000000 3000000} + {1973 1300000000 4000000} + {1974 1400000000 5000000} + {1975 1500000000 6000000} + {1976 1600000000 7000000} + {1977 1700000000 8000000} + {1978 1800000000 9000000} + {1979 1900000000 10000000} + {1980 2000000000 11000000} + {1981 2100000000 22000000} + {1982 2200000000 33000000} + {1983 2300000000 44000000} + {1984 2400000000 55000000} + {1985 3500000000 36000000} + {1986 4600000000 57000000} + {1987 5700000000 68000000} + {1988 6800000000 79000000} + {1989 7900000000 90000000} + {1990 13000000000 111000000} + {1991 14100000000 122000000} + {1992 16200000000 233000000} + {1993 28300000000 344000000} + {1994 29400000000 455000000} + {1995 38500000000 536000000} + } + + set headers { + "Revenue ($)" + "Rev. Growth (%)" + "Profit ($)" + "Profit Growth (%)" + } + + # Create the grid + # + tixScrolledGrid $w.g -bd 0 + pack $w.g -expand yes -fill both -padx 3 -pady 3 + + set grid [$w.g subwidget grid] + $grid config -formatcmd "gformat $grid" + + # Set the size of the columns + # + $grid size col 0 -size 10char + $grid size col 1 -size auto + $grid size col 2 -size auto + $grid size col 3 -size auto + $grid size col 4 -size auto + + # set the default size of the column and rows. these sizes will be used + # if the size of a row or column has not be set via the "size col ?" + # command + $grid size col default -size 5char + $grid size row default -size 1.1char -pad0 3 + + set margin [tixDisplayStyle text -refwindow $grid \ + -anchor c -padx 3 -font [tix option get bold_font]] + set dollar [tixDisplayStyle text -refwindow $grid \ + -anchor e] + + # Create the headers + # + set x 1 + foreach h $headers { + $grid set $x 0 -itemtype text -text $h -style $margin + incr x + } + + # Insert the data, year by year + # + set lastRevn {} + set lastProf {} + set i 1 + foreach line $data { + set year [lindex $line 0] + set revn [lindex $line 1] + set prof [lindex $line 2] + + if {$lastRevn != {}} { + set rgrowth \ + [format %4.2f [expr ($revn.0-$lastRevn)/$lastRevn*100.0]] + } else { + set rgrowth "-" + } + if {$lastProf != {}} { + set pgrowth \ + [format %4.2f [expr ($prof.0-$lastProf)/$lastProf*100.0]] + } else { + set pgrowth "-" + } + + $grid set 0 $i -itemtype text -style $margin -text $year + $grid set 1 $i -itemtype text -style $dollar -text [Dollar $revn] + $grid set 2 $i -itemtype text -style $dollar -text $rgrowth + $grid set 3 $i -itemtype text -style $dollar -text [Dollar $prof] + $grid set 4 $i -itemtype text -style $dollar -text $pgrowth + + set lastRevn $revn.0 + set lastProf $prof.0 + + incr i + } +} + + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/SHList.tcl b/tix/demos/samples/SHList.tcl new file mode 100644 index 00000000000..d416071ee28 --- /dev/null +++ b/tix/demos/samples/SHList.tcl @@ -0,0 +1,107 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixScrolledHList widget. +# + +proc RunSample {w} { + + # We create the frame and the ScrolledHList widget + # at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + # Put a simple hierachy into the HList (two levels). Use colors and + # separator widgets (frames) to make the list look fancy + # + tixScrolledHList $w.top.a + pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left + + + # This is our little relational database + # + set bosses { + {jeff "Jeff Waxman"} + {john "John Lee"} + {peter "Peter Kenson"} + } + + set employees { + {alex john "Alex Kellman"} + {alan john "Alan Adams"} + {andy peter "Andreas Crawford"} + {doug jeff "Douglas Bloom"} + {jon peter "Jon Baraki"} + {chris jeff "Chris Geoffrey"} + {chuck jeff "Chuck McLean"} + } + + set hlist [$w.top.a subwidget hlist] + + # Let configure the appearance of the HList subwidget + # + $hlist config -separator "." -width 25 -drawbranch 0 -indent 10 + + set index 0 + foreach line $bosses { + if {$index != 0} { + frame $hlist.sep$index -bd 2 -height 2 -width 150 -relief sunken \ + -bg [$hlist cget -bg] + + $hlist addchild {} -itemtype window \ + -window $hlist.sep$index -state disabled + } + $hlist add [lindex $line 0] -itemtype text \ + -text [lindex $line 1] + incr index + } + + foreach line $employees { + # "." is the separator character we chose above + # + set entrypath [lindex $line 1].[lindex $line 0] + # ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + # parent entryPath / child's name + + $hlist add $entrypath -text [lindex $line 2] + + # [Hint] Make sure the [lindex $line 1].[lindex $line 0] you choose + # are unique names. If you cannot be sure of this (because of + # the structure of your database, e.g.) you can use the + # "addchild" widget command instead: + # + # $hlist addchild [lindex $line 1] -text [lindex $line 2] + # ^^^^^^^^^^^^^^^^ + # parent entryPath + + } + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} + diff --git a/tix/demos/samples/SHList2.tcl b/tix/demos/samples/SHList2.tcl new file mode 100644 index 00000000000..0a3de00a4c5 --- /dev/null +++ b/tix/demos/samples/SHList2.tcl @@ -0,0 +1,161 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates how to use multiple columns and multiple styles +# in the tixHList widget +# +# In a tixHList widget, you can have one ore more columns. +# + +proc RunSample {w} { + + # We create the frame and the ScrolledHList widget + # at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + # Put a simple hierachy into the HList (two levels). Use colors and + # separator widgets (frames) to make the list look fancy + # + tixScrolledHList $w.top.a -options { + hlist.columns 3 + hlist.header true + } + pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left + + set hlist [$w.top.a subwidget hlist] + + # Create the title for the HList widget + # >> Notice that we have set the hlist.header subwidget option to true + # so that the header is displayed + # + + # First some styles for the headers + set style(header) [tixDisplayStyle text -refwindow $hlist \ + -fg black -anchor c \ + -padx 8 -pady 2\ + -font [tix option get bold_font ]] + + $hlist header create 0 -itemtype text -text Name \ + -style $style(header) + $hlist header create 1 -itemtype text -text Position \ + -style $style(header) + + # Notice that we use 3 columns in the hlist widget. This way when the user + # expands the windows wide, the right side of the header doesn't look + # chopped off. The following line ensures that the 3 column header is + # not shown unless the hlist window is wider than its contents. + # + $hlist column width 2 0 + + # This is our little relational database + # + set boss {doe "John Doe" Director} + + set managers { + {jeff "Jeff Waxman" Manager} + {john "John Lee" Manager} + {peter "Peter Kenson" Manager} + } + + set employees { + {alex john "Alex Kellman" Clerk} + {alan john "Alan Adams" Clerk} + {andy peter "Andreas Crawford" Salesman} + {doug jeff "Douglas Bloom" Clerk} + {jon peter "Jon Baraki" Salesman} + {chris jeff "Chris Geoffrey" Clerk} + {chuck jeff "Chuck McLean" Cleaner} + } + + set style(mgr_name) [tixDisplayStyle text -refwindow $hlist \ + -fg #202060 \ + -selectforeground #202060 \ + -font [tix option get bold_font ]] + set style(mgr_posn) [tixDisplayStyle text -refwindow $hlist \ + -fg #202060 -padx 8 \ + -selectforeground #202060] + + set style(empl_name) [tixDisplayStyle text -refwindow $hlist \ + -fg #602020 \ + -selectforeground #602020 \ + -font [tix option get bold_font ]] + set style(empl_posn) [tixDisplayStyle text -refwindow $hlist \ + -fg #602020 -padx 8 \ + -selectforeground #602020 ] + + # Let configure the appearance of the HList subwidget + # + $hlist config -separator "." -width 25 -drawbranch 0 -indent 10 + $hlist column width 0 -char 20 + + # Create the boss + # + $hlist add . -itemtype text -text [lindex $boss 1] \ + -style $style(mgr_name) + $hlist item create . 1 -itemtype text -text [lindex $boss 2] \ + -style $style(mgr_posn) + + # Create the managers + # + set index 0 + foreach line $managers { + set row [$hlist add .[lindex $line 0] -itemtype text \ + -text [lindex $line 1] -style $style(mgr_name)] + $hlist item create $row 1 -itemtype text -text [lindex $line 2] \ + -style $style(mgr_posn) + incr index + } + + foreach line $employees { + # "." is the separator character we chose above + # + set entrypath .[lindex $line 1].[lindex $line 0] + # ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + # parent entryPath / child's name + + set row [$hlist add $entrypath -text [lindex $line 2] \ + -style $style(empl_name)] + $hlist item create $row 1 -itemtype text -text [lindex $line 3] \ + -style $style(empl_posn) + + # [Hint] Make sure the .[lindex $line 1].[lindex $line 0] you choose + # are unique names. If you cannot be sure of this (because of + # the structure of your database, e.g.) you can use the + # "addchild" widget command instead: + # + # $hlist addchild [lindex $line 1] -text [lindex $line 2] + # ^^^^^^^^^^^^^^^^ + # parent entryPath + + } + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} + diff --git a/tix/demos/samples/SListBox.tcl b/tix/demos/samples/SListBox.tcl new file mode 100644 index 00000000000..9638341678f --- /dev/null +++ b/tix/demos/samples/SListBox.tcl @@ -0,0 +1,81 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixScrolledListBox widget. +# + +proc RunSample {w} { + + # We create the frame and the two ScrolledListBox widgets + # at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + # The first ScrolledListBox widget always shows both scrollbars + # + tixScrolledListBox $w.top.a -scrollbar both + pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left + + # The second ScrolledListBox widget shows the scrollbars only when + # needed. + # + # [Hint] See how you can use the -options switch to set the options + # for the subwidgets + # + tixScrolledListBox $w.top.b -scrollbar auto -options { + listbox.font 8x13 + } + pack $w.top.b -expand yes -fill both -padx 10 -pady 10 -side left + + # Put the elements inside the two listboxes: notice that you need + # to insert inside the "listbox" subwidget of the ScrolledListBox. + # $w.top.a itself does NOT have an "insert" command. + # + $w.top.a subwidget listbox insert 0 \ + Alabama Alaska Arizona Arkansas California \ + Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \ + Indiana Iowa Kansas Kentucky Louisiana Maine Maryland \ + Massachusetts Michigan Minnesota Mississippi Missouri \ + Montana Nebraska Nevada "New Hampshire" "New Jersey" "New Mexico" \ + "New York" "North Carolina" "North Dakota" \ + Ohio Oklahoma Oregon Pennsylvania "Rhode Island" \ + "South Carolina" "South Dakota" \ + Tennessee Texas Utah Vermont Virginia Washington \ + "West Virginia" Wisconsin Wyoming + + $w.top.a subwidget listbox config -cursor left_ptr + raise [$w.top.a subwidget listbox ] + $w.top.b subwidget listbox insert 0 \ + Alabama Alaska Arizona Arkansas California \ + Colorado Connecticut Delaware Florida Georgia Hawaii Idaho Illinois \ + Indiana Iowa Kansas Kentucky + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} + diff --git a/tix/demos/samples/STList1.tcl b/tix/demos/samples/STList1.tcl new file mode 100644 index 00000000000..215c8ac1601 --- /dev/null +++ b/tix/demos/samples/STList1.tcl @@ -0,0 +1,53 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# Demonstrates the scrolled tlist widget +# + +proc RunSample {w} { + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + # Create the scrolled tlist + # + tixScrolledTList $top.st -options { + tlist.orient vertical + tlist.selectMode single + } + pack $top.st -expand yes -fill both -padx 10 -pady 10 + + # Insert a list of numbers into the tlist subwidget + # + set tlist [$top.st subwidget tlist] + + set numbers { + one two three fours five six seven eight nine ten eleven + twelve thirdteen fourteen + } + + foreach num $numbers { + $tlist insert end -itemtype imagetext -text $num \ + -image [tix getimage openfold] + } + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/STList2.tcl b/tix/demos/samples/STList2.tcl new file mode 100644 index 00000000000..c5997cfd309 --- /dev/null +++ b/tix/demos/samples/STList2.tcl @@ -0,0 +1,81 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# Demonstrates the scrolled tlist widget +# + +proc RunSample {w} { + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + # Create the Paned Window to contain two scrolled tlist's + # + set p [tixPanedWindow $top.p -orient horizontal] + pack $p -expand yes -fill both -padx 4 -pady 4 + + set p1 [$p add pane1 -expand 1] + set p2 [$p add pane2 -expand 1] + + $p1 config -relief flat + $p2 config -relief flat + + # Create a TList with vertical orientation + # + tixScrolledTList $p1.st -options { + tlist.orient vertical + tlist.selectMode single + } + label $p1.lab -text "Vertical Orientation" + + pack $p1.lab -anchor c -side top -pady 2 + pack $p1.st -expand yes -fill both -padx 10 -pady 10 + + # Create a TList with horizontal orientation + # + tixScrolledTList $p2.st -options { + tlist.orient horizontal + tlist.selectMode single + } + label $p2.lab -text "Horizontal Orientation" + + pack $p2.lab -anchor c -side top -pady 2 + pack $p2.st -expand yes -fill both -padx 10 -pady 10 + + # Insert a list of numbers into the two tlist subwidget's + # + set vt [$p1.st subwidget tlist] + set ht [$p2.st subwidget tlist] + + set numbers { + one two three fours five six seven eight nine ten eleven + twelve thirdteen fourteen + } + + foreach num $numbers { + $vt insert end -itemtype imagetext -text $num \ + -image [tix getimage openfold] + $ht insert end -itemtype imagetext -text $num \ + -image [tix getimage openfold] + } + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/STList3.tcl b/tix/demos/samples/STList3.tcl new file mode 100644 index 00000000000..eef41137ca0 --- /dev/null +++ b/tix/demos/samples/STList3.tcl @@ -0,0 +1,121 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# Demonstrates the use of DirTree with the TList +# + +proc RunSample {w} { + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + # Create the Paned Window to contain the dirtree and scrolled tlist + # + set p [tixPanedWindow $top.p -orient horizontal] + pack $p -expand yes -fill both -padx 4 -pady 4 + + set p1 [$p add pane1 -expand 1] + set p2 [$p add pane2 -expand 4] + + $p1 config -relief flat + $p2 config -relief flat + + # Create a DirTree + # + tixDirTree $p1.dirtree -options { + hlist.width 28 + } + + pack $p1.dirtree -expand yes -fill both -padx 4 -pady 4 + + + # Create a TList + # NOTE: we set the width of the tlist to 60 characters, since we'll have + # quite a few files to display + # + tixScrolledTList $p2.st -options { + tlist.orient vertical + tlist.selectMode single + tlist.width 60 + tlist.height 25 + } + pack $p2.st -expand yes -fill both -padx 4 -pady 4 + + set tlist [$p2.st subwidget tlist] + + # setup the callbacks: when the user selects a directory, we'll display + # its content in the tlist widget + $p1.dirtree config \ + -browsecmd "TList:listdir $tlist" \ + -command "TList:listdir $tlist" + + # List the directory now + # + TList:listdir $tlist [pwd] + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + +proc TList:listdir {w dir} { + $w delete 0 end + + set appPWD [pwd] + + if [catch {cd $dir} err] { + # The user has entered an invalid directory + # %% todo: prompt error, go back to last succeed directory + cd $appPWD + return + } + + foreach fname [lsort [glob -nocomplain *]] { + if [file isdirectory $fname] { + set image [tix getimage folder] + } else { + continue + } + + $w insert end -itemtype imagetext \ + -text $fname -image $image + } + + foreach fname [lsort [glob -nocomplain *]] { + if [file isdirectory $fname] { + continue + } elseif [string match *.c $fname] { + set image [tix getimage srcfile] + } elseif [string match *.h $fname] { + set image [tix getimage srcfile] + } elseif [string match *.tcl $fname] { + set image [tix getimage file] + } elseif [string match *.o $fname] { + set image [tix getimage file] + } else { + set image [tix getimage textfile] + } + + $w insert end -itemtype imagetext \ + -text $fname -image $image + } + + cd $appPWD +} + + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/SText.tcl b/tix/demos/samples/SText.tcl new file mode 100644 index 00000000000..6dea90ad6dd --- /dev/null +++ b/tix/demos/samples/SText.tcl @@ -0,0 +1,71 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixScrolledText widget. +# + +proc RunSample {w} { + + # We create the frame and the ScrolledText widget + # at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + # Create a Scrolled Text widget. + # + tixScrolledText $w.top.a + pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes + + # Put the junk inside the text subwidget of the ScrolledText widget + # + $w.top.a subwidget text insert end { +Mon, 19 Jun 1995 11:39:52 comp.lang.tcl Thread 34 of 220 +Lines 353 A new way to put text and bitmaps together +ioi@xpi.com Ioi K. Lam at Expert Interface Technologies + +Hi, + +I have implemented a new image type called "compound". It allows you +to glue together a bunch of bitmaps, images and text strings together +to form a bigger image. Then you can use this image with widgets that +support the -image option. This way you can display very fancy stuffs +in your GUI. For example, you can display a text string string +together with a bitmap, at the same time, inside a TK button widget. A +screenshot of compound images can be found at the bottom of this page: + + http://www.xpi.com/tix/screenshot.html + +You can also you is in other places such as putting fancy bitmap+text +in menus, tabs of tixNoteBook widgets, etc. This feature will be +included in the next release of Tix (4.0b1). Count on it to make jazzy +interfaces!} +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} + diff --git a/tix/demos/samples/SWindow.tcl b/tix/demos/samples/SWindow.tcl new file mode 100644 index 00000000000..59d29b367f6 --- /dev/null +++ b/tix/demos/samples/SWindow.tcl @@ -0,0 +1,85 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixScrolledWindow widget. +# + +proc RunSample {w} { + + # We create the frame and the ScrolledWindow widget + # at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + # Create a complex window inside the ScrolledWindow widget. + # ScrolledWindow are very convenient: unlink the canvas widget, + # you don't need to specify the scroll-redions for the + # ScrolledWindow. It will automatically adjust itself to fit + # size of the "window" subwidget + # + # [Hint] Be sure you create and pack new widgets inside the + # "window" subwidget and NOT inside $w.top.a itself! + # + tixScrolledWindow $w.top.a + pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left + + set f [$w.top.a subwidget window] + tixNoteBook $f.nb + pack $f.nb -expand yes -fill both -padx 20 -pady 20 + + + $f.nb add image -label "Image" -underline 0 + $f.nb add buttons -label "Buttons" -underline 0 + + # The first page: an image + # + global demo_dir + set p [$f.nb subwidget image] + set im [image create photo -file $demo_dir/bitmaps/tix.gif] + label $p.lab -image $im + pack $p.lab -padx 20 -pady 20 + + # The second page: buttons + # + set p [$f.nb subwidget buttons] + button $p.b1 -text "Welcome" -width 8 + button $p.b2 -text "to" -width 8 + button $p.b3 -text "the" -width 8 + button $p.b4 -text "World" -width 8 + button $p.b5 -text "of" -width 8 + button $p.b6 -text "Tix" -width 8 + + pack $p.b1 $p.b2 $p.b3 $p.b4 $p.b5 $p.b6 -anchor c -side top + + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes + + wm geometry $w 240x220 +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} + diff --git a/tix/demos/samples/Sample.tcl b/tix/demos/samples/Sample.tcl new file mode 100644 index 00000000000..063f9b0d8f7 --- /dev/null +++ b/tix/demos/samples/Sample.tcl @@ -0,0 +1,32 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# REPLACE WITH DESCRIPTION OF THIS DEMO. +# + +proc RunSample {w} { + set top [frame $w.f -bd 1 -relief raised] + set box [tixButtonBox $w.b -bd 1 -relief raised] + + pack $box -side bottom -fill both + pack $top -side top -fill both -expand yes + + + # Create the buttons + # + $box add ok -text Ok -command "destroy $w" -width 6 + $box add cancel -text Cancel -command "destroy $w" -width 6 +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/Select.tcl b/tix/demos/samples/Select.tcl new file mode 100644 index 00000000000..80e6c5a690b --- /dev/null +++ b/tix/demos/samples/Select.tcl @@ -0,0 +1,110 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixSelect widget. +# +proc RunSample {w} { + global demo_dir + + # Create the frame on the top of the dialog box with two tixSelect + # widgets inside. + # + frame $w.top + + # There can be one and only type of justification for any piece of text. + # So we set -radio to be true. Also, -allowzero is set to false: the user + # cannot select a "none" justification + # + tixSelect $w.top.just -allowzero false -radio true \ + -label "Justification: "\ + -options { + label.width 15 + label.padx 4 + label.anchor e + } + + # The user can select one or many or none of the font attributes in + # the font Select widget, so we set -radio to false (can select one or + # many) and -allowzero to true (can select none) + # + tixSelect $w.top.font -allowzero true -radio false \ + -label "Font: " \ + -options { + label.width 15 + label.padx 4 + label.anchor e + } + + pack $w.top.just $w.top.font -side top -expand yes -anchor c \ + -padx 4 -pady 4 + + # Add the choices of available font attributes + # + # + $w.top.font add bold -bitmap @$demo_dir/bitmaps/bold.xbm + $w.top.font add italic -bitmap @$demo_dir/bitmaps/italic.xbm + $w.top.font add underline -bitmap @$demo_dir/bitmaps/underlin.xbm + $w.top.font add capital -bitmap @$demo_dir/bitmaps/capital.xbm + + # Add the choices of available justification types + # + # + $w.top.just add left -bitmap @$demo_dir/bitmaps/leftj.xbm + $w.top.just add right -bitmap @$demo_dir/bitmaps/rightj.xbm + $w.top.just add center -bitmap @$demo_dir/bitmaps/centerj.xbm + $w.top.just add justified -bitmap @$demo_dir/bitmaps/justify.xbm + + $w.top.font config -variable sel_font + $w.top.just config -variable sel_just + + # Set the default value of the two Select widgets + # + # + global sel_just sel_font + set sel_just justified + set sel_font {bold underline} + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -width 6\ + -command "sel:cmd $w; destroy $w" + + $w.box add apply -text Apply -underline 0 -width 6\ + -command "sel:cmd $w" + + $w.box add cancel -text Cancel -underline 0 -width 6\ + -command "destroy $w" + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + +# This procedure is called whenever the user pressed the OK or the Apply button +# +# +proc sel:cmd {w} { + global sel_font sel_just + + puts "The justification is $sel_just" + + if {$sel_font == {}} { + puts "The font is normal" + } else { + puts "The font is $sel_font" + } + +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} diff --git a/tix/demos/samples/StdBBox.tcl b/tix/demos/samples/StdBBox.tcl new file mode 100644 index 00000000000..af5c4f9c9ab --- /dev/null +++ b/tix/demos/samples/StdBBox.tcl @@ -0,0 +1,61 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of the tixStdButtonBox widget, which is a +# group of "Standard" buttons for Motif-like dialog boxes. +# +proc RunSample {w} { + + # Create the label on the top of the dialog box + # + label $w.top -padx 20 -pady 10 -border 1 -relief raised -text \ + "This dialog box is\n a demostration of the\n tixStdButtonBox widget" \ + -justify center -anchor c + + # Create the button box. We also do some manipulation of the + # button widgets inside: we disable the help button and change + # the label string of the "apply" button to "Filter" + # + # Note that the -text, -underline, -command and -width options are all + # standard options of the button widgets. + # + tixStdButtonBox $w.box + $w.box subwidget ok config \ + -command "puts {OK pressed}; destroy $w" + $w.box subwidget apply config -text "Filter" -underline 0 \ + -command "puts {Filter pressed}" + $w.box subwidget cancel config \ + -command "puts {Cancel pressed}; destroy $w" + $w.box subwidget help config -state disabled + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes -anchor c + + + # "after 0" is used so that the key bindings won't interfere with + # tkTraverseMenu + # + bind [winfo toplevel $w] <Alt-o> \ + "after 0 tkButtonInvoke [$w.box subwidget ok]" + bind [winfo toplevel $w] <Alt-f> \ + "after 0 tkButtonInvoke [$w.box subwidget apply]" + bind [winfo toplevel $w] <Alt-c> \ + "after 0 tkButtonInvoke [$w.box subwidget cancel]" + bind [winfo toplevel $w] <Escape> \ + "after 0 tkButtonInvoke [$w.box subwidget cancel]" + + focus [$w.box subwidget apply] +} + +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} diff --git a/tix/demos/samples/Tree.tcl b/tix/demos/samples/Tree.tcl new file mode 100644 index 00000000000..b32a63d572c --- /dev/null +++ b/tix/demos/samples/Tree.tcl @@ -0,0 +1,87 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates how to use the TixTree widget to display +# hierachical data (A hypothetical DOS disk drive). +# + +proc RunSample {w} { + + # We create the frame and the ScrolledHList widget + # at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + # Create a TixTree widget to display the hypothetical DOS disk drive + # + # + tixTree $w.top.a -options { + separator "\\" + } + + pack $w.top.a -expand yes -fill both -padx 10 -pady 10 -side left + + set tree $w.top.a + set hlist [$w.top.a subwidget hlist] + + # STEP (1) Add the directories into the TixTree widget (using the + # hlist subwidget) + + set directories { + C: + C:\\Dos + C:\\Windows + C:\\Windows\\System + } + + foreach d $directories { + set text [lindex [split $d \\] end] + $hlist add $d -itemtype imagetext \ + -text $text -image [tix getimage folder] + } + + # STEP (2) Use the "autosetmode" method of TixTree to indicate + # which entries can be opened or closed. The + # "autosetmode" command will call the "setmode" method + # to set the mode of each entry to the following: + # + # "open" : the entry has some children and the children are + # currently visible + # "close": the entry has some children and the children are + # currently INvisible + # "none": the entry does not have children. + # + # If you don't like the "autosetmode" method, you can always call + # "setmode" yourself, but that takes more work. + + $tree autosetmode + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> {if {"%W" == ".demo"} exit} +} + diff --git a/tix/demos/samples/Xpm.tcl b/tix/demos/samples/Xpm.tcl new file mode 100644 index 00000000000..a2f33999947 --- /dev/null +++ b/tix/demos/samples/Xpm.tcl @@ -0,0 +1,85 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of XPM images. +# + +proc RunSample {w} { + + set hard_disk_pixmap {/* XPM */ + static char * drivea_xpm[] = { + /* width height ncolors chars_per_pixel */ + "32 32 5 1", + /* colors */ + " s None c None", + ". c #000000000000", + "X c white", + "o c #c000c000c000", + "O c #800080008000", + /* pixels */ + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " .......................... ", + " .XXXXXXXXXXXXXXXXXXXXXXXo. ", + " .XooooooooooooooooooooooO. ", + " .Xooooooooooooooooo..oooO. ", + " .Xooooooooooooooooo..oooO. ", + " .XooooooooooooooooooooooO. ", + " .Xoooooooo.......oooooooO. ", + " .Xoo...................oO. ", + " .Xoooooooo.......oooooooO. ", + " .XooooooooooooooooooooooO. ", + " .XooooooooooooooooooooooO. ", + " .XooooooooooooooooooooooO. ", + " .XooooooooooooooooooooooO. ", + " .oOOOOOOOOOOOOOOOOOOOOOOO. ", + " .......................... ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " "}; + } + + frame $w.top -relief raised -bd 1 + button $w.top.b -image [image create pixmap -data $hard_disk_pixmap] + pack $w.top -expand yes -fill both + pack $w.top.b -expand yes -padx 20 -pady 20 + + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind $w <Destroy> exit +} + diff --git a/tix/demos/samples/Xpm1.tcl b/tix/demos/samples/Xpm1.tcl new file mode 100644 index 00000000000..8ad88784f95 --- /dev/null +++ b/tix/demos/samples/Xpm1.tcl @@ -0,0 +1,104 @@ +# Tix Demostration Program +# +# This sample program is structured in such a way so that it can be +# executed from the Tix demo program "widget": it must have a +# procedure called "RunSample". It should also have the "if" statment +# at the end of this file so that it can be run as a standalone +# program using tixwish. + +# This file demonstrates the use of XPM images in the menu. +# + +proc RunSample {w} { + + set hard_disk_pixmap {/* XPM */ + static char * drivea_xpm[] = { + /* width height ncolors chars_per_pixel */ + "32 32 5 1", + /* colors */ + " s None c None", + ". c #000000000000", + "X c white", + "o c #c000c000c000", + "O c #800080008000", + /* pixels */ + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " .......................... ", + " .XXXXXXXXXXXXXXXXXXXXXXXo. ", + " .XooooooooooooooooooooooO. ", + " .Xooooooooooooooooo..oooO. ", + " .Xooooooooooooooooo..oooO. ", + " .XooooooooooooooooooooooO. ", + " .Xoooooooo.......oooooooO. ", + " .Xoo...................oO. ", + " .Xoooooooo.......oooooooO. ", + " .XooooooooooooooooooooooO. ", + " .XooooooooooooooooooooooO. ", + " .XooooooooooooooooooooooO. ", + " .XooooooooooooooooooooooO. ", + " .oOOOOOOOOOOOOOOOOOOOOOOO. ", + " .......................... ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " "}; + } + # We create the frame and the ScrolledText widget + # at the top of the dialog box + # + frame $w.top -relief raised -bd 1 + + set m [frame $w.top.menu -relief raised -bd 2] + set mb [menubutton $m.mb -text Options -menu $m.mb.m] + set menu [menu $mb.m] + + pack $m -side top -fill x + pack $mb -side left -fill y + + # Put the label there + # + set lab [label $w.top.label -text "Go to the \"Options\" menu" -anchor c] + pack $lab -padx 40 -pady 40 -fill both -expand yes + + set image [image create pixmap -data $hard_disk_pixmap] + $menu add command -image $image \ + -command "$lab config -image $image" + + # Use a ButtonBox to hold the buttons. + # + tixButtonBox $w.box -orientation horizontal + $w.box add ok -text Ok -underline 0 -command "destroy $w" \ + -width 6 + $w.box add cancel -text Cancel -underline 0 -command "destroy $w" \ + -width 6 + + pack $w.box -side bottom -fill x + pack $w.top -side top -fill both -expand yes + + wm geometry $w 300x300 +} + + +# This "if" statement makes it possible to run this script file inside or +# outside of the main demo program "widget". +# +if {![info exists tix_demo_running]} { + wm withdraw . + set w .demo + toplevel $w + RunSample $w + bind .demo <Destroy> exit +} + diff --git a/tix/demos/tclIndex b/tix/demos/tclIndex new file mode 100644 index 00000000000..1d1a5700b29 --- /dev/null +++ b/tix/demos/tclIndex @@ -0,0 +1,54 @@ +# Tcl autoload index file, version 2.0 +# This file is generated by the "tixindex" program, +# *NOT* by the "auto_mkindex" command, +# and sourced to set up indexing information for one or +# more commands. Typically each line is a command that +# sets an element in the auto_index array, where the +# element name is the name of a command and the value is +# a script that loads the command. + +set auto_index(MkChoosers) "source {$dir/MkChoose.tcl}" +set auto_index(MkCombo) "source {$dir/MkChoose.tcl}" +set auto_index(stCmd) "source {$dir/MkChoose.tcl}" +set auto_index(stValidate) "source {$dir/MkChoose.tcl}" +set auto_index(MkControl) "source {$dir/MkChoose.tcl}" +set auto_index(MkSelect) "source {$dir/MkChoose.tcl}" +set auto_index(MkOptMenu) "source {$dir/MkChoose.tcl}" +set auto_index(MkFileEnt) "source {$dir/MkChoose.tcl}" +set auto_index(MkFileBox) "source {$dir/MkChoose.tcl}" +set auto_index(MkToolBar) "source {$dir/MkChoose.tcl}" +set auto_index(MkTitle) "source {$dir/MkChoose.tcl}" +set auto_index(MkDirList) "source {$dir/MkDirLis.tcl}" +set auto_index(MkDirListWidget) "source {$dir/MkDirLis.tcl}" +set auto_index(MkExFileWidget) "source {$dir/MkDirLis.tcl}" +set auto_index(MkManager) "source {$dir/MkManag.tcl}" +set auto_index(MkPanedWindow) "source {$dir/MkManag.tcl}" +set auto_index(MkNoteBook) "source {$dir/MkManag.tcl}" +set auto_index(CreateCommonButtons) "source {$dir/MkManag.tcl}" +set auto_index(MkSample) "source {$dir/MkSample.tcl}" +set auto_index(AddSampleToHList) "source {$dir/MkSample.tcl}" +set auto_index(Sample:Action) "source {$dir/MkSample.tcl}" +set auto_index(RunProg) "source {$dir/MkSample.tcl}" +set auto_index(LoadFile) "source {$dir/MkSample.tcl}" +set auto_index(ReadFileWhenIdle) "source {$dir/MkSample.tcl}" +set auto_index(ReadFile) "source {$dir/MkSample.tcl}" +set auto_index(MkScroll) "source {$dir/MkScroll.tcl}" +set auto_index(MkSList) "source {$dir/MkScroll.tcl}" +set auto_index(SList:Reset) "source {$dir/MkScroll.tcl}" +set auto_index(MkSWindow) "source {$dir/MkScroll.tcl}" +set auto_index(SWindow:Reset) "source {$dir/MkScroll.tcl}" +set auto_index(MkSText) "source {$dir/MkScroll.tcl}" +set auto_index(SText:Reset) "source {$dir/MkScroll.tcl}" +set auto_index(MkMainWindow) "source {$dir/widget}" +set auto_index(MkMainMenu) "source {$dir/widget}" +set auto_index(MkMainNoteBook) "source {$dir/widget}" +set auto_index(CreatePage) "source {$dir/widget}" +set auto_index(MkMainStatus) "source {$dir/widget}" +set auto_index(MkWelcome) "source {$dir/widget}" +set auto_index(MkWelcomeBar) "source {$dir/widget}" +set auto_index(MkWelcomeText) "source {$dir/widget}" +set auto_index(MainTextFont) "source {$dir/widget}" +set auto_index(FileOpen) "source {$dir/widget}" +set auto_index(FileOpen:Doit) "source {$dir/widget}" +set auto_index(BalloonHelp) "source {$dir/widget}" +set auto_index(Widget:SelfTest) "source {$dir/widget}" diff --git a/tix/demos/widget b/tix/demos/widget new file mode 100755 index 00000000000..e0841d7e21b --- /dev/null +++ b/tix/demos/widget @@ -0,0 +1,367 @@ +#!/bin/sh +# the next line restarts using tixwish \ +exec tixwish "$0" "$@" + +# widget -- +# +# This is a demo program of all the available Tix widgets. If +# have installed Tix properly, you can execute this program +# directly: +# +# % widget +# +# Otherwise try the following in csh +# +# % env TIX_LIBRARY=../library tixwish widget +# +# Or this in sh +# +# $ TIX_LIBRARY=../library tixwish widget +# +# +# +#---------------------------------------------------------------------- +# +# +# This file has not been properly documented. It is NOT intended +# to be used as an introductory demo program about Tix +# programming. For such demos, please see the files in the +# demos/samples directory or go to the "Samples" page in the +# "widget demo" +# +# +# Copyright (c) 1996, Expert Interface Technologies +# +# See the file "license.terms" for information on usage and redistribution +# of this file, and for a DISCLAIMER OF ALL WARRANTIES. +# + + +proc MkMainWindow {w} { + global demo auto_path demo_dir + + if ![info exists demo_dir] { + # Initialize the auto_path and the bitmap directory. The demo_dir + # variable would be already set by the test program, if we are + # running in the self test more + # + set script [info script] + if {$script != {}} { + set demo_dir [file dirname $script] + } else { + set demo_dir [pwd] + } + + set demo_dir [tixFSAbsPath $demo_dir] + } + + lappend auto_path $demo_dir + tix addbitmapdir [tixFSJoin $demo_dir bitmaps] + + toplevel $w + wm title $w "Tix Widget Demonstration" + wm geometry $w 830x566+100+100 + + set demo(balloon) [tixBalloon .demos_balloon] + + set frame1 [MkMainMenu $w] + set frame2 [MkMainNoteBook $w] + set frame3 [MkMainStatus $w] + + pack $frame1 -side top -fill x + pack $frame3 -side bottom -fill x + pack $frame2 -side top -expand yes -fill both -padx 4 -pady 4 + + $demo(balloon) config -statusbar $demo(statusbar) + set demo(notebook) $frame2 +} + +proc MkMainMenu {top} { + global demo usebal + + set w [frame $top.f1 -bd 2 -relief raised] + + menubutton $w.file -menu $w.file.m -text File -underline 0 \ + -takefocus 0 + menubutton $w.help -menu $w.help.m -text Help -underline 0 \ + -takefocus 0 + + menu $w.file.m + $w.file.m add command -label "Open ... " -command FileOpen -underline 1 \ + -accelerator "Ctrl+O" + $w.file.m add sep + $w.file.m add command -label "Exit " -command exit -underline 1 \ + -accelerator "Ctrl+X" + + menu $w.help.m + + $w.help.m add checkbutton -under 0 -label "Balloon Help " \ + -variable usebal -onvalue 1 -offvalue 0 + + tixForm $w.file + tixForm $w.help -right -0 + + trace variable usebal w BalloonHelp + + set usebal 1 + + # Accelerator bindings + + bind all <Control-x> "exit" + bind all <Control-o> "FileOpen" + + return $w +} + +# Create the main display area of the widget programm. This area should +# utilize the "tixNoteBook" widget once it is available. But now +# we use the cheap substitute "tixStackWindow" +# +proc MkMainNoteBook {top} { + global demo + set hasGL 0 + + option add *TixNoteBook.tagPadX 6 + option add *TixNoteBook.tagPadY 4 + option add *TixNoteBook.borderWidth 2 + option add *TixNoteBook.font\ + -*-helvetica-bold-o-normal-*-14-*-*-*-*-*-*-* + + set w [tixNoteBook $top.f2 -ipadx 5 -ipady 5] + + + $w add wel -createcmd "CreatePage MkWelcome $w wel" \ + -label "Welcome" \ + -under 0 + $w add cho -createcmd "CreatePage MkChoosers $w cho" \ + -label "Choosers" \ + -under 0 + $w add scr -createcmd "CreatePage MkScroll $w scr" \ + -label "Scrolled Widgets" \ + -under 0 + $w add mgr -createcmd "CreatePage MkManager $w mgr" \ + -label "Manager Widgets" \ + -under 0 + $w add dir -createcmd "CreatePage MkDirList $w dir" \ + -label "Directory List" \ + -under 0 + $w add exp -createcmd "CreatePage MkSample $w exp" \ + -label "Run Sample Programs" \ + -under 0 + + if {$hasGL} { + $w add glw -createcmd "MkGL $w glw" -tag "GL Widgets" + } + + return $w +} + +proc CreatePage {command w name} { + tixBusy $w on + set id [after 10000 tixBusy $w off] + $command $w $name + after cancel $id + after 0 tixBusy $w off +} + +proc MkMainStatus {top} { + global demo + + set w [frame $top.f3 -relief raised -bd 1] + set demo(statusbar) \ + [label $w.status -font -*-helvetica-medium-r-normal-*-14-*-*-*-*-*-*-*\ + -relief sunken -bd 1] + + tixForm $demo(statusbar) -padx 3 -pady 3 -left 0 -right %70 + + return $w +} + +proc MkWelcome {nb page} { + set w [$nb subwidget $page] + + set bar [MkWelcomeBar $w] + set text [MkWelcomeText $w] + + pack $bar -side top -fill x -padx 2 -pady 2 + pack $text -side top -fill both -expand yes +} + +proc MkWelcomeBar {top} { + global demo + + set w [frame $top.bar -bd 2 -relief groove] + + # Create and configure comboBox 1 + # + tixComboBox $w.cbx1 -command "MainTextFont $top" \ + -options { + entry.width 15 + listbox.height 3 + } + tixComboBox $w.cbx2 -command "MainTextFont $top" \ + -options { + entry.width 4 + listbox.height 3 + } + set demo(welfont) $w.cbx1 + set demo(welsize) $w.cbx2 + + $w.cbx1 insert end "Courier" + $w.cbx1 insert end "Helvetica" + $w.cbx1 insert end "Lucida" + $w.cbx1 insert end "Times Roman" + + $w.cbx2 insert end 8 + $w.cbx2 insert end 10 + $w.cbx2 insert end 12 + $w.cbx2 insert end 14 + $w.cbx2 insert end 18 + + $w.cbx1 pick 1 + $w.cbx2 pick 3 + + # Pack the comboboxes together + # + pack $w.cbx1 $w.cbx2 -side left -padx 4 -pady 4 + + $demo(balloon) bind $w.cbx1\ + -msg "Choose\na font" -statusmsg "Choose a font for this page" + $demo(balloon) bind $w.cbx2\ + -msg "Point size" -statusmsg "Choose the font size for this page" + + + tixDoWhenIdle MainTextFont $top + return $w +} + +proc MkWelcomeText {top} { + global demo tix_version + + set w [tixScrolledWindow $top.f3 -scrollbar auto] + set win [$w subwidget window] + + label $win.title -font -*-times-bold-r-normal-*-18-*-*-*-*-*-*-*\ + -bd 0 -width 30 -anchor n\ + -text "Welcome to TIX version $tix_version" + + message $win.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\ + -bd 0 -width 400 -anchor n\ + -text "\ +Tix $tix_version is a library of mega-widgets based on TK. This program \ +demonstrates the widgets in the Tix widget. You can choose the pages \ +in this window to look at the corresponding widgets. \ +To quit this program, choose the \"File | Exit\" command." + + + pack $win.title -expand yes -fill both -padx 10 -pady 10 + pack $win.msg -expand yes -fill both -padx 10 -pady 10 + set demo(welmsg) $win.msg + return $w +} + +proc MainTextFont {w args} { + global demo + + if {![info exists demo(welmsg)]} { + return + } + + set font [$demo(welfont) cget -value] + set point [$demo(welsize) cget -value] + + case $font { + "Courier" { + set f courier + } + "Helvetica" { + set f helvetica + } + "Lucida" { + set f lucida + } + default { + set f times + } + } + + set xfont [format "-*-%s-bold-r-normal-*-%s-*-*-*-*-*-*-*" $f $point] + if [catch {$demo(welmsg) config -font $xfont} err] { + puts \a$err + } +} + +proc FileOpen {} { + global demo demo_dir + set filedlg [tix filedialog tixExFileSelectDialog] + if {![info exists demo(filedialog)]} { + $filedlg subwidget fsbox config -pattern *.tcl + $filedlg subwidget fsbox config -directory $demo_dir/samples + $filedlg config -command FileOpen:Doit + set demo(filedialog) $filedlg + } + $filedlg config -title "Open Tix Sample Programs" + $filedlg popup + tixPushGrab $filedlg +} + +proc FileOpen:Doit {filename} { + global demo + + LoadFile $filename + tixPopGrab + $demo(filedialog) popdown +} + +#---------------------------------------------------------------------- +# Balloon Help +#---------------------------------------------------------------------- +proc BalloonHelp {args} { + global demo usebal + + if {$usebal} { + $demo(balloon) config -state "both" + } else { + $demo(balloon) config -state "none" + } +} + +#---------------------------------------------------------------------- +# Self-testing +# +# The following code are called by the Tix test suite. It opens +# every page in the demo program. +#---------------------------------------------------------------------- +proc Widget:SelfTest {} { + global demo testConfig + + if ![info exists testConfig] { + return + } + + MkMainWindow .widget + + update + foreach p [$demo(notebook) pages] { + $demo(notebook) raise $p + update + } + + destroy .widget +} + + +#---------------------------------------------------------------------- +# Start! +#---------------------------------------------------------------------- +if ![info exists testConfig] { + # + # If the testConfig variable exists, we are driven by the regression + # test. In that case, don't open the main window. The test program will + # call Widget:SelfTest + # + wm withdraw . + MkMainWindow .widget + bind .widget <Destroy> "exit" +} + |