File size: 3,704 Bytes
ef99749 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
#
# $Id: MultView.tcl,v 1.3 2001/12/09 05:04:02 idiscovery Exp $
#
# MultView.tcl --
#
# Implements the multi-view widget
#
# Copyright (c) 1993-1999 Ioi Kim Lam.
# Copyright (c) 2000-2001 Tix Project Group.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
tixWidgetClass tixMultiView {
-classname TixMultiView
-superclass tixPrimitive
-method {
add
}
-flag {
-browsecmd -command -view
}
-forcecall {
-view
}
-configspec {
{-browsecmd browseCmd BrowseCmd ""}
{-command command Command ""}
{-view view View icon tixMultiView:VerifyView}
}
-alias {
}
-default {
}
}
proc tixMultiView:InitWidgetRec {w} {
upvar #0 $w data
global env
tixChainMethod $w InitWidgetRec
}
#----------------------------------------------------------------------
# Construct widget
#----------------------------------------------------------------------
proc tixMultiView:ConstructWidget {w} {
upvar #0 $w data
tixChainMethod $w ConstructWidget
set data(w:stlist) [tixScrolledTList $w.stlist]
set data(w:sgrid) [tixScrolledGrid $w.sgrid]
set data(w:icon) [tixIconView $w.icon]
set data(w:tlist) [$data(w:stlist) subwidget tlist]
set data(w:grid) [$data(w:sgrid) subwidget grid]
$data(w:grid) config -formatcmd [list tixMultiView:GridFormat $w] \
-leftmargin 0 -topmargin 1
}
proc tixMultiView:SetBindings {w} {
upvar #0 $w data
tixChainMethod $w SetBindings
}
proc tixMultiView:GetWid {w which} {
upvar #0 $w data
case $which {
list {
return $data(w:stlist)
}
icon {
return $data(w:icon)
}
detail {
return $data(w:sgrid)
}
}
}
#----------------------------------------------------------------------
# Configuration
#----------------------------------------------------------------------
proc tixMultiView:config-view {w value} {
upvar #0 $w data
if {$data(-view) != ""} {
pack forget [tixMultiView:GetWid $w $data(-view)]
}
pack [tixMultiView:GetWid $w $value] -expand yes -fill both
}
#----------------------------------------------------------------------
# Private methods
#----------------------------------------------------------------------
proc tixMultiView:GridFormat {w area x1 y1 x2 y2} {
upvar #0 $w data
case $area {
main {
}
{x-margin y-margin s-margin} {
# cborder specifies consecutive 3d borders
#
$data(w:grid) format cborder $x1 $y1 $x2 $y2 \
-fill 1 -relief raised -bd 2 -bg gray60 \
-selectbackground gray80
}
}
}
#----------------------------------------------------------------------
# Public methods
#----------------------------------------------------------------------
# Return value is the index of "$name" in the grid subwidget
#
#
proc tixMultiView:add {w name args} {
upvar #0 $w data
set validOptions {-image -text}
set opt(-image) ""
set opt(-text) ""
tixHandleOptions -nounknown opt $validOptions $args
$data(w:icon) add $name $opt(-image) $opt(-text)
$data(w:tlist) insert end -itemtype imagetext \
-image $opt(-image) -text $opt(-text)
$data(w:grid) set 0 end -itemtype imagetext \
-image $opt(-image) -text $opt(-text)
return max
}
#----------------------------------------------------------------------
# checker
#----------------------------------------------------------------------
proc tixMultiView:VerifyView {value} {
case $value {
{icon list detail} {
return $value
}
}
error "bad view \"$value\", must be detail, icon or list"
}
|