StackWin.tcl 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # -*- mode: TCL; fill-column: 75; tab-width: 8; coding: iso-latin-1-unix -*-
  2. #
  3. # $Id: StackWin.tcl,v 1.3 2004/03/28 02:44:57 hobbs Exp $
  4. #
  5. # StackWin.tcl --
  6. #
  7. # Similar to NoteBook but uses a Select widget to represent the pages.
  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. tixWidgetClass tixStackWindow {
  16. -classname TixStackWindow
  17. -superclass tixVStack
  18. -method {
  19. }
  20. -flag {
  21. }
  22. -configspec {
  23. }
  24. }
  25. proc tixStackWindow:ConstructWidget {w} {
  26. upvar #0 $w data
  27. tixChainMethod $w ConstructWidget
  28. set data(w:tabs) [tixSelect $w.tabs]
  29. # We can't use the packer because it will conflict with the
  30. # geometry management of the VStack widget.
  31. #
  32. tixManageGeometry $data(w:tabs) [list tixVStack:ClientGeomProc $w]
  33. }
  34. proc tixStackWindow:add {w child args} {
  35. upvar #0 $w data
  36. set ret [eval [list tixChainMethod $w add $child] $args]
  37. # Find out the -label option
  38. #
  39. foreach {flag value} $args {
  40. if {$flag eq "-label"} {
  41. set label $value
  42. }
  43. }
  44. $data(w:tabs) add $child -command [list $w raise $child] -text $label
  45. return $ret
  46. }
  47. proc tixStackWindow:raise {w child} {
  48. upvar #0 $w data
  49. $data(w:tabs) config -value $child
  50. tixChainMethod $w raise $child
  51. }
  52. proc tixStackWindow:Resize {w} {
  53. upvar #0 $w data
  54. # We have to take care of the size of the tabs so that
  55. #
  56. set tW [winfo reqwidth $data(w:tabs)]
  57. set tH [winfo reqheight $data(w:tabs)]
  58. tixMoveResizeWindow $data(w:tabs) $data(-ipadx) $data(-ipady) $tW $tH
  59. tixMapWindow $data(w:tabs)
  60. set data(pad-y1) [expr $tH + $data(-ipadx)]
  61. set data(minW) [expr $tW + 2 * $data(-ipadx)]
  62. set data(minH) [expr $tH + 2 * $data(-ipady)]
  63. # Now that we know data(pad-y1), we can chain the call
  64. #
  65. tixChainMethod $w Resize
  66. }