Import build of Tcl/Tk 8.6.10

This commit is contained in:
Steve Dower
2020-09-24 23:32:28 +01:00
parent 86027ce3ed
commit c0c00d5551
498 changed files with 65344 additions and 64042 deletions

View File

@@ -1,201 +1,201 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: AllSampl.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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}}
}
global tcl_platform
# This demo hangs windows
if {$tcl_platform(platform) != "windows"} {
lappend tlist {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
}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: AllSampl.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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}}
}
global tcl_platform
# This demo hangs windows
if {$tcl_platform(platform) != "windows"} {
lappend tlist {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
}
}

View File

@@ -1,187 +1,187 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: ArrowBtn.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> "exit"
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: ArrowBtn.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> "exit"
}

View File

@@ -1,48 +1,48 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Balloon.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Balloon.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}

View File

@@ -1,57 +1,57 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: BtnBox.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: BtnBox.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,80 +1,80 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CObjView.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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.
#
# $Id: CObjView.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
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 -side top
frame $w.f
pack $w.f -side bottom -fill y
tixCObjView $w.c
pack $w.c -expand yes -fill both -padx 4 -pady 2 -side top
button $w.add -command "CVDemo_Add $w.c" -text Add -width 6
button $w.del -command "CVDemo_Delete $w.c" -text Delete -width 6
button $w.exit -command "destroy $w" -text Exit -width 6
pack $w.add $w.del $w.exit -side left -padx 20 -pady 10 \
-anchor c -expand yes -in $w.f
}
proc CVDemo_Add {cov} {
# 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 x [expr int(rand() * 400) - 120]
set y [expr int(rand() * 400) - 120]
set w [expr int(rand() * 120)]
set h [expr int(rand() * 120)]
# Create the canvas object
#
$cov subwidget canvas create rectangle $x $y [expr $x+$w] [expr $y+$h] \
-fill [lindex $colors [expr int(rand() * [llength $colors])]]
# Call the adjustscrollregion command to set the scroll bars so that all
# objects are included in the scroll-region
#
$cov adjustscrollregion
}
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; wm transient $w ""
RunSample $w
bind $w <Destroy> {after 10 exit}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CObjView.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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.
#
# $Id: CObjView.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
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 -side top
frame $w.f
pack $w.f -side bottom -fill y
tixCObjView $w.c
pack $w.c -expand yes -fill both -padx 4 -pady 2 -side top
button $w.add -command "CVDemo_Add $w.c" -text Add -width 6
button $w.del -command "CVDemo_Delete $w.c" -text Delete -width 6
button $w.exit -command "destroy $w" -text Exit -width 6
pack $w.add $w.del $w.exit -side left -padx 20 -pady 10 \
-anchor c -expand yes -in $w.f
}
proc CVDemo_Add {cov} {
# 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 x [expr int(rand() * 400) - 120]
set y [expr int(rand() * 400) - 120]
set w [expr int(rand() * 120)]
set h [expr int(rand() * 120)]
# Create the canvas object
#
$cov subwidget canvas create rectangle $x $y [expr $x+$w] [expr $y+$h] \
-fill [lindex $colors [expr int(rand() * [llength $colors])]]
# Call the adjustscrollregion command to set the scroll bars so that all
# objects are included in the scroll-region
#
$cov adjustscrollregion
}
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; wm transient $w ""
RunSample $w
bind $w <Destroy> {after 10 exit}
}

View File

@@ -1,179 +1,179 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: ChkList.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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) "Eiffel"
set names(6) "Fortran"
set names(7) "Incr Tcl"
set names(8) "Python"
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 on
$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 Python
$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 tixOption
set chklist(disabled) [tixDisplayStyle imagetext -fg $tixOption(disabled_fg) \
-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} {
tixDemo:Status "Selected items: [$clist getselection on]"
tixDemo:Status "Unselected items: [$clist getselection off]"
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: ChkList.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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) "Eiffel"
set names(6) "Fortran"
set names(7) "Incr Tcl"
set names(8) "Python"
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 on
$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 Python
$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 tixOption
set chklist(disabled) [tixDisplayStyle imagetext -fg $tixOption(disabled_fg) \
-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} {
tixDemo:Status "Selected items: [$clist getselection on]"
tixDemo:Status "Unselected items: [$clist getselection off]"
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,64 +1,64 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,182 +1,182 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,136 +1,136 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg2.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg2.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,90 +1,90 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg3.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg3.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,125 +1,125 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg4.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: CmpImg4.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,119 +1,119 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: ComboBox.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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} {
tixDemo:Status "you have selected \"$args\""
}
proc cbx:select_month {s} {
tixDemo:Status "you have selected \"$s\""
}
proc cbx:okcmd {w} {
global demo_month demo_year
tixDemo:Status "The month selected is $demo_month of $demo_year"
destroy $w
}
if {![info exists tix_demo_running]} {
wm withdraw .
set w .demo
toplevel $w; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: ComboBox.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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} {
tixDemo:Status "you have selected \"$args\""
}
proc cbx:select_month {s} {
tixDemo:Status "you have selected \"$s\""
}
proc cbx:okcmd {w} {
global demo_month demo_year
tixDemo:Status "The month selected is $demo_month of $demo_year"
destroy $w
}
if {![info exists tix_demo_running]} {
wm withdraw .
set w .demo
toplevel $w; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,133 +1,133 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Control.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Control.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,90 +1,90 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DirDlg.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 != {}} {
tixDemo:Status "You have selected the directory $demo_ddlg_dirname"
} else {
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DirDlg.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 != {}} {
tixDemo:Status "You have selected the directory $demo_ddlg_dirname"
} else {
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,91 +1,91 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DirList.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> "exit"
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DirList.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> "exit"
}

View File

@@ -1,92 +1,92 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DirTree.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 tixDirTree 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> "exit"
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DirTree.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 tixDirTree 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> "exit"
}

View File

@@ -1,50 +1,50 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DragDrop.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> "exit"
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DragDrop.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> "exit"
}

View File

@@ -1,149 +1,149 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DynTree.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: DynTree.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,104 +1,104 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: EFileDlg.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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}}
}
wm transient $dialog ""
$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 != {}} {
tixDemo:Status "You have selected the file $demo_efdlg_filename"
} else {
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: EFileDlg.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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}}
}
wm transient $dialog ""
$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 != {}} {
tixDemo:Status "You have selected the file $demo_efdlg_filename"
} else {
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,281 +1,281 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: EditGrid.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: EditGrid.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,98 +1,98 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: FileDlg.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 != {}} {
tixDemo:Status "You have selected the file $demo_fdlg_filename"
} else {
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: FileDlg.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 != {}} {
tixDemo:Status "You have selected the file $demo_fdlg_filename"
} else {
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,81 +1,81 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: FileEnt.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
# tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: FileEnt.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
# tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,159 +1,159 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: HList1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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]
tixDemo:Status "You have selected the directory $demo_hlist_dir"
destroy [winfo toplevel $w]
}
proc hlist:okcmd {w} {
global demo_hlist_dir
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: HList1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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]
tixDemo:Status "You have selected the directory $demo_hlist_dir"
destroy [winfo toplevel $w]
}
proc hlist:okcmd {w} {
global demo_hlist_dir
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,94 +1,94 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: LabEntry.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: LabEntry.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,85 +1,85 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: LabFrame.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: LabFrame.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,86 +1,86 @@
#
# $Id: ListNBK.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
#
# $Id: ListNBK.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,77 +1,77 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Meter.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Meter.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}

View File

@@ -1,102 +1,102 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: NoteBook.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: NoteBook.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}

View File

@@ -1,103 +1,103 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: OptMenu.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: OptMenu.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}

View File

@@ -1,112 +1,112 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: PanedWin.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 article
#
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
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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: PanedWin.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 article
#
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
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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}

View File

@@ -1,73 +1,73 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: PopMenu.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: PopMenu.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}

View File

@@ -1,135 +1,135 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SGrid0.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SGrid0.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,215 +1,215 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SGrid1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SGrid1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,111 +1,111 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SHList.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind .demo <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SHList.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind .demo <Destroy> exit
}

View File

@@ -1,159 +1,159 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SHList2.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 \
-font [tix option get bold_font ]]
set style(mgr_posn) [tixDisplayStyle text -refwindow $hlist \
-padx 8]
set style(empl_name) [tixDisplayStyle text -refwindow $hlist \
-font [tix option get bold_font ]]
set style(empl_posn) [tixDisplayStyle text -refwindow $hlist \
-padx 8 ]
# 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; wm transient $w ""
RunSample $w
bind .demo <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SHList2.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 \
-font [tix option get bold_font ]]
set style(mgr_posn) [tixDisplayStyle text -refwindow $hlist \
-padx 8]
set style(empl_name) [tixDisplayStyle text -refwindow $hlist \
-font [tix option get bold_font ]]
set style(empl_posn) [tixDisplayStyle text -refwindow $hlist \
-padx 8 ]
# 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; wm transient $w ""
RunSample $w
bind .demo <Destroy> exit
}

View File

@@ -1,84 +1,84 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SListBox.tcl,v 1.4 2008/02/27 22:17:27 hobbs Exp $
#
# 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
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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SListBox.tcl,v 1.4 2008/02/27 22:17:27 hobbs Exp $
#
# 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
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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,57 +1,57 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: STList1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: STList1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,85 +1,85 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: STList2.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: STList2.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,112 +1,112 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: STList3.tcl,v 1.4 2004/03/28 02:44:56 hobbs Exp $
#
# 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 [list TList:listdir $tlist] \
-command [list TList:listdir $tlist]
# List the directory now
#
TList:listdir $tlist [pwd]
# Create the buttons
#
$box add ok -text Ok -command [list destroy $w] -width 6
$box add cancel -text Cancel -command [list destroy $w] -width 6
}
proc TList:listdir {w dir} {
$w delete 0 end
if {[catch {glob -nocomplain -directory $dir *} entries]} {
# The user has entered an invalid directory
# %% todo: prompt error, go back to last succeed directory
return
}
set files ""
foreach fname [lsort -dictionary $entries] {
if {[file isdirectory $fname]} {
set image [tix getimage folder]
} else {
lappend files [file tail $fname]
continue
}
$w insert end -itemtype imagetext \
-text [file tail $fname] -image $image
}
foreach fname $files {
switch -glob -- $fname {
{*.[ch]} { set image [tix getimage srcfile] }
*.tcl -
*.o { set image [tix getimage file] }
default { set image [tix getimage textfile] }
}
$w insert end -itemtype imagetext -text $fname -image $image
}
}
if {![info exists tix_demo_running]} {
wm withdraw .
set w .demo
toplevel $w; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: STList3.tcl,v 1.4 2004/03/28 02:44:56 hobbs Exp $
#
# 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 [list TList:listdir $tlist] \
-command [list TList:listdir $tlist]
# List the directory now
#
TList:listdir $tlist [pwd]
# Create the buttons
#
$box add ok -text Ok -command [list destroy $w] -width 6
$box add cancel -text Cancel -command [list destroy $w] -width 6
}
proc TList:listdir {w dir} {
$w delete 0 end
if {[catch {glob -nocomplain -directory $dir *} entries]} {
# The user has entered an invalid directory
# %% todo: prompt error, go back to last succeed directory
return
}
set files ""
foreach fname [lsort -dictionary $entries] {
if {[file isdirectory $fname]} {
set image [tix getimage folder]
} else {
lappend files [file tail $fname]
continue
}
$w insert end -itemtype imagetext \
-text [file tail $fname] -image $image
}
foreach fname $files {
switch -glob -- $fname {
{*.[ch]} { set image [tix getimage srcfile] }
*.tcl -
*.o { set image [tix getimage file] }
default { set image [tix getimage textfile] }
}
$w insert end -itemtype imagetext -text $fname -image $image
}
}
if {![info exists tix_demo_running]} {
wm withdraw .
set w .demo
toplevel $w; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,75 +1,75 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SText.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SText.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,89 +1,89 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SWindow.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: SWindow.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,36 +1,36 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Sample.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Sample.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,114 +1,114 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Select.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "The justification is $sel_just"
if {$sel_font == {}} {
tixDemo:Status "The font is normal"
} else {
tixDemo:Status "The font is $sel_font"
}
}
if {![info exists tix_demo_running]} {
wm withdraw .
set w .demo
toplevel $w; wm transient $w ""
RunSample $w
bind .demo <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Select.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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
tixDemo:Status "The justification is $sel_just"
if {$sel_font == {}} {
tixDemo:Status "The font is normal"
} else {
tixDemo:Status "The font is $sel_font"
}
}
if {![info exists tix_demo_running]} {
wm withdraw .
set w .demo
toplevel $w; wm transient $w ""
RunSample $w
bind .demo <Destroy> exit
}

View File

@@ -1,65 +1,65 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: StdBBox.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 "tixDemo:Status {OK pressed}; destroy $w"
$w.box subwidget apply config -text "Filter" -underline 0 \
-command "tixDemo:Status {Filter pressed}"
$w.box subwidget cancel config \
-command "tixDemo:Status {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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: StdBBox.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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 "tixDemo:Status {OK pressed}; destroy $w"
$w.box subwidget apply config -text "Filter" -underline 0 \
-command "tixDemo:Status {Filter pressed}"
$w.box subwidget cancel config \
-command "tixDemo:Status {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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,91 +1,91 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Tree.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Tree.tcl,v 1.4 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> {if {"%W" == ".demo"} exit}
}

View File

@@ -1,89 +1,89 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Xpm.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Xpm.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind $w <Destroy> exit
}

View File

@@ -1,108 +1,108 @@
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Xpm1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind .demo <Destroy> exit
}
# -*-mode: tcl; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: Xpm1.tcl,v 1.3 2001/12/09 05:31:07 idiscovery Exp $
#
# 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; wm transient $w ""
RunSample $w
bind .demo <Destroy> exit
}