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 / ListNBk.tcl < prev    next >
Text File  |  2001-11-03  |  4KB  |  156 lines

  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. #    $Id: ListNBk.tcl,v 1.3.2.1 2001/11/03 07:48:00 idiscovery Exp $
  4. #
  5. # ListNBk.tcl --
  6. #
  7. #    "List NoteBook" widget. Acts similarly to the notebook but uses a
  8. #    HList widget to represent the pages.
  9. #
  10. # Copyright (c) 1993-1999 Ioi Kim Lam.
  11. # Copyright (c) 2000-2001 Tix Project Group.
  12. #
  13. # See the file "license.terms" for information on usage and redistribution
  14. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  15. #
  16.  
  17. tixWidgetClass tixListNoteBook {
  18.     -classname TixListNoteBook
  19.     -superclass tixVStack
  20.     -method {
  21.     }
  22.     -flag {
  23.     -height -width
  24.     }
  25.     -configspec {
  26.     {-width width Width 0}
  27.     {-height height Height 0}
  28.     }
  29.     -forcecall {
  30.     -dynamicgeometry -width -height
  31.     }
  32.     -default {
  33.     {*Orientation        horizontal}
  34.     }
  35. }
  36.  
  37. proc tixListNoteBook:ConstructWidget {w} {
  38.     upvar #0 $w data
  39.  
  40.     tixChainMethod $w ConstructWidget
  41.     set data(w_pane) [tixPanedWindow $w.pane -panerelief flat]
  42.     set p1 [$data(w_pane) add p1 -expand 0]
  43.     set p2 [$data(w_pane) add p2 -expand 1]
  44.     set data(w_p2) $p2
  45.     set data(w:shlist) [tixScrolledHList $p1.shlist]
  46.     set data(w:hlist) [$data(w:shlist) subwidget hlist]
  47.  
  48.     if {[tixStrEq [$data(w_pane) cget -orientation] vertical]} {
  49.     pack $data(w:shlist) -expand yes -fill both -padx 2 -pady 3
  50.     } else {
  51.     pack $data(w:shlist) -expand yes -fill both -padx 3 -pady 2
  52.     }
  53.  
  54.     $data(w:hlist) config \
  55.     -command   "tixListNoteBook:Choose $w"\
  56.     -browsecmd [list tixListNoteBook:Choose $w]\
  57.     -selectmode single
  58.  
  59.     pack $data(w_pane) -expand yes -fill both
  60. }
  61.  
  62. proc tixListNoteBook:add {w child args} {
  63.     upvar #0 $w data
  64.  
  65.     if {[string match *.* $child]} {
  66.     error "the name of the page cannot contain the \".\" character"
  67.     }
  68.     return [eval tixChainMethod $w add $child $args]
  69. }
  70.  
  71. #----------------------------------------------------------------------
  72. # Virtual Methods
  73. #----------------------------------------------------------------------
  74. proc tixListNoteBook:InitGeometryManager {w} {
  75.     tixWidgetDoWhenIdle tixListNoteBook:InitialRaise $w 
  76. }
  77.  
  78. proc tixListNoteBook:InitialRaise {w} {
  79.     upvar #0 $w data
  80.  
  81.     if {![string comp $data(topchild) ""]} {
  82.     set top [lindex $data(windows) 0]
  83.     } else {
  84.     set top $data(topchild)
  85.     }
  86.  
  87.     if {![tixStrEq $top ""]} {
  88.     tixCallMethod $w raise $top
  89.     }
  90. }
  91.  
  92. proc tixListNoteBook:CreateChildFrame {w child} {
  93.     upvar #0 $w data
  94.  
  95.     set f [frame $data(w_p2).$child]
  96.  
  97.     return $f
  98. }
  99.  
  100. proc tixListNoteBook:RaiseChildFrame {w child} {
  101.     upvar #0 $w data
  102.  
  103.     if {[string comp $data(topchild) $child]} {
  104.     if {[string comp $data(topchild) ""]} {
  105.         pack forget $data(w:$data(topchild))
  106.     }
  107.     pack $data(w:$child) -expand yes -fill both
  108.     }
  109. }
  110.  
  111. #
  112. #----------------------------------------------------------------------
  113. #
  114.  
  115. proc tixListNoteBook:config-dynamicgeometry {w value} {
  116.     upvar #0 $w data
  117.  
  118.     $data(w_pane) config -dynamicgeometry $value
  119. }
  120.  
  121. proc tixListNoteBook:config-width {w value} {
  122.     upvar #0 $w data
  123.  
  124.     if {$value != 0} {
  125.     $data(w_pane) config -width $value
  126.     }
  127. }
  128.  
  129. proc tixListNoteBook:config-height {w value} {
  130.     upvar #0 $w data
  131.  
  132.     if {$value != 0} {
  133.     $data(w_pane) config -height $value
  134.     }
  135. }
  136.  
  137. proc tixListNoteBook:raise {w child} {
  138.     upvar #0 $w data
  139.  
  140.     $data(w:hlist) selection clear
  141.     $data(w:hlist) selection set $child
  142.     $data(w:hlist) anchor set $child
  143.  
  144.     tixChainMethod $w raise $child
  145. }
  146.  
  147. proc tixListNoteBook:Choose {w args} {
  148.     upvar #0 $w data
  149.  
  150.     set entry [tixEvent flag V]
  151.  
  152.     if {[lsearch $data(windows) $entry] != -1} {
  153.     tixCallMethod $w raise $entry
  154.     }
  155. }
  156.