home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
komix
/
DATA.Z
/
browstable.tcl
< prev
next >
Wrap
Text File
|
1997-11-21
|
3KB
|
121 lines
#---------------------------------------------------------------------------
#
# (c) Cadre Technologies Inc. 1996
#
# File: @(#)browstable.tcl /main/titanic/4
# Author: <generated>
# Description:
#---------------------------------------------------------------------------
# SccsId = @(#)browstable.tcl /main/titanic/4 21 Nov 1997 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 {widthList {}}} {
$this removeAllHeaders
set count 0
set empty [lempty $widthList]
foreach header $list {
set width 24
if !$empty {
set width [lindex $widthList $count]
}
incr count
BrowsHeader new $this.header$count -label $header -width $width
}
}
# 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