home *** CD-ROM | disk | FTP | other *** search
/ Freelog Special Freeware 31 / FreelogHS31.iso / Texte / scribus / scribus-1.3.3.9-win32-install.exe / tcl / tix8.1 / MultView.tcl < prev    next >
Text File  |  2001-11-03  |  4KB  |  158 lines

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