home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1997 November
/
PCWorld_1997-11_cd.bin
/
software
/
programy
/
komix
/
DATA.Z
/
browstable.tcl
< prev
next >
Wrap
Text File
|
1996-10-10
|
3KB
|
114 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1996
#
# File: @(#)browstable.tcl /main/hindenburg/4
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)browstable.tcl /main/hindenburg/4 10 Oct 1996 Copyright 1996 Cadre Technologies Inc.
# Start user added include file section
# End user added include file section
# BrowsView derived class that can calculate the width
# of columns to fit the data in its objects exactly.
Class BrowsTable : {BrowsView} {
method destructor
constructor
method setHeaderLabels
method format
method removeAllHeaders
method removeAllObjects
}
method BrowsTable::destructor {this} {
# Start destructor user section
# End destructor user section
}
constructor BrowsTable {class this name} {
set this [BrowsView::constructor $class $this $name]
return $this
}
# Removes all header objects and creates new ones,
# one for each string specified in the list.
#
method BrowsTable::setHeaderLabels {this list} {
$this removeAllHeaders
foreach hdr $list {
BrowsHeader new $this.$hdr -label $hdr
}
}
# Examines all objects in this view's objectSet and calculates the
# maximum width foreach column, and stores that width in the
# corresponding header object.
#
method BrowsTable::format {this} {
set headers [$this headerSet]
set objects [$this objectSet]
if {[llength $headers] == 0} {
return 0
}
set ncols [llength $headers]
for {set i 0} {$i < $ncols} {incr i} {
set hdr [lindex $headers $i]
set max($i) [string length [$hdr label]]
}
foreach obj $objects {
set d [concat [list [$obj label]] [$obj details]]
for {set i 0} {$i < $ncols} {incr i} {
set l [string length [lindex $d $i]]
# If object has a small icon, add 2 to the first column width.
#
if {$i == 0 && [$obj smallIcon] != ""} {
incr l 2
}
if {$l > $max($i)} {
set max($i) $l
}
}
}
set n 0
set i 0
foreach hdr $headers {
set m $max($i)
# add some column separator space
incr m 2
$hdr width $m
incr n $m
incr i
}
return $n
}
# Removes all header objects.
#
method BrowsTable::removeAllHeaders {this} {
foreach e [$this headerSet] { $e delete }
}
# Removes all data objects.
#
method BrowsTable::removeAllObjects {this} {
foreach e [$this objectSet] { $e delete }
}
# Do not delete this line -- regeneration end marker